summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-01-17 20:46:06 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-01-17 20:46:06 (GMT)
commit4a60b97c700c2f1843b7e99313554cb89fb5da4e (patch)
tree3b33ef6f74a4e8a4ff5968a81b9c4c429ccaa7c6
parent6273089bf486bf46ad325d72c7290ebb272bd3d8 (diff)
downloadpowder-4a60b97c700c2f1843b7e99313554cb89fb5da4e.zip
powder-4a60b97c700c2f1843b7e99313554cb89fb5da4e.tar.gz
Some minor changes
-rw-r--r--Makefile37
-rw-r--r--PowderToy++.files156
-rw-r--r--build/obj/core/.empty0
-rw-r--r--build/obj/elements/.empty0
-rw-r--r--build/obj/ui/.empty0
-rw-r--r--includes/GameSession.h10
-rw-r--r--includes/interface.old/Button.h42
-rw-r--r--includes/interface.old/Component.h53
-rw-r--r--includes/interface.old/ControlFactory.h15
-rw-r--r--includes/interface.old/Panel.h22
-rw-r--r--includes/interface.old/Sandbox.h36
-rw-r--r--includes/interface.old/State.h61
-rw-r--r--includes/interface.old/Window.h22
-rw-r--r--includes/interface/Button.h51
-rw-r--r--src/Air.h (renamed from includes/Air.h)0
-rw-r--r--src/Config.h (renamed from includes/Config.h)0
-rw-r--r--src/Console.h (renamed from includes/Console.h)0
-rw-r--r--src/Element.h (renamed from includes/Element.h)0
-rw-r--r--src/ElementFunctions.h (renamed from includes/ElementFunctions.h)0
-rw-r--r--src/ElementGraphics.h (renamed from includes/ElementGraphics.h)0
-rw-r--r--src/Elements.h (renamed from includes/Elements.h)0
-rw-r--r--src/GameSession.cpp6
-rw-r--r--src/Global.cpp3
-rw-r--r--src/Global.h (renamed from includes/Global.h)4
-rw-r--r--src/Graphics.h (renamed from includes/Graphics.h)0
-rw-r--r--src/Gravity.h (renamed from includes/Gravity.h)0
-rw-r--r--src/Misc.h (renamed from includes/Misc.h)0
-rw-r--r--src/PowderToy.cpp21
-rw-r--r--src/Renderer.h (renamed from includes/Renderer.h)0
-rw-r--r--src/Simulation.h (renamed from includes/Simulation.h)0
-rw-r--r--src/Singleton.h (renamed from includes/Singleton.h)0
-rw-r--r--src/elements/O2.cpp (renamed from elements/O2.cpp)0
-rw-r--r--src/elements/acel.cpp (renamed from elements/acel.cpp)0
-rw-r--r--src/elements/acid.cpp (renamed from elements/acid.cpp)0
-rw-r--r--src/elements/amtr.cpp (renamed from elements/amtr.cpp)0
-rw-r--r--src/elements/anar.cpp (renamed from elements/anar.cpp)0
-rw-r--r--src/elements/aray.cpp (renamed from elements/aray.cpp)0
-rw-r--r--src/elements/bang.cpp (renamed from elements/bang.cpp)0
-rw-r--r--src/elements/bcln.cpp (renamed from elements/bcln.cpp)0
-rw-r--r--src/elements/bcol.cpp (renamed from elements/bcol.cpp)0
-rw-r--r--src/elements/bizr.cpp (renamed from elements/bizr.cpp)0
-rw-r--r--src/elements/bmtl.cpp (renamed from elements/bmtl.cpp)0
-rw-r--r--src/elements/bomb.cpp (renamed from elements/bomb.cpp)0
-rw-r--r--src/elements/boyl.cpp (renamed from elements/boyl.cpp)0
-rw-r--r--src/elements/brmt.cpp (renamed from elements/brmt.cpp)0
-rw-r--r--src/elements/btry.cpp (renamed from elements/btry.cpp)0
-rw-r--r--src/elements/c5.cpp (renamed from elements/c5.cpp)0
-rw-r--r--src/elements/caus.cpp (renamed from elements/caus.cpp)0
-rw-r--r--src/elements/cbnw.cpp (renamed from elements/cbnw.cpp)0
-rw-r--r--src/elements/clne.cpp (renamed from elements/clne.cpp)0
-rw-r--r--src/elements/clst.cpp (renamed from elements/clst.cpp)0
-rw-r--r--src/elements/co2.cpp (renamed from elements/co2.cpp)0
-rw-r--r--src/elements/coal.cpp (renamed from elements/coal.cpp)0
-rw-r--r--src/elements/conv.cpp (renamed from elements/conv.cpp)0
-rw-r--r--src/elements/dest.cpp (renamed from elements/dest.cpp)0
-rw-r--r--src/elements/deut.cpp (renamed from elements/deut.cpp)0
-rw-r--r--src/elements/dlay.cpp (renamed from elements/dlay.cpp)0
-rw-r--r--src/elements/dstw.cpp (renamed from elements/dstw.cpp)0
-rw-r--r--src/elements/elec.cpp (renamed from elements/elec.cpp)0
-rw-r--r--src/elements/elementmisc.cpp (renamed from elements/elementmisc.cpp)0
-rw-r--r--src/elements/emp.cpp (renamed from elements/emp.cpp)0
-rw-r--r--src/elements/figh.cpp (renamed from elements/figh.cpp)0
-rw-r--r--src/elements/fire.cpp (renamed from elements/fire.cpp)0
-rw-r--r--src/elements/firw.cpp (renamed from elements/firw.cpp)0
-rw-r--r--src/elements/fog.cpp (renamed from elements/fog.cpp)0
-rw-r--r--src/elements/frzw.cpp (renamed from elements/frzw.cpp)0
-rw-r--r--src/elements/frzz.cpp (renamed from elements/frzz.cpp)0
-rw-r--r--src/elements/fsep.cpp (renamed from elements/fsep.cpp)0
-rw-r--r--src/elements/fuse.cpp (renamed from elements/fuse.cpp)0
-rw-r--r--src/elements/fwrk.cpp (renamed from elements/fwrk.cpp)0
-rw-r--r--src/elements/gbmb.cpp (renamed from elements/gbmb.cpp)0
-rw-r--r--src/elements/glas.cpp (renamed from elements/glas.cpp)0
-rw-r--r--src/elements/glow.cpp (renamed from elements/glow.cpp)0
-rw-r--r--src/elements/goo.cpp (renamed from elements/goo.cpp)0
-rw-r--r--src/elements/gpmp.cpp (renamed from elements/gpmp.cpp)0
-rw-r--r--src/elements/graphics_default.cpp (renamed from elements/graphics_default.cpp)0
-rw-r--r--src/elements/h2.cpp (renamed from elements/h2.cpp)0
-rw-r--r--src/elements/hswc.cpp (renamed from elements/hswc.cpp)0
-rw-r--r--src/elements/ice.cpp (renamed from elements/ice.cpp)0
-rw-r--r--src/elements/ignt.cpp (renamed from elements/ignt.cpp)0
-rw-r--r--src/elements/iron.cpp (renamed from elements/iron.cpp)0
-rw-r--r--src/elements/isz.cpp (renamed from elements/isz.cpp)0
-rw-r--r--src/elements/lava.cpp (renamed from elements/lava.cpp)0
-rw-r--r--src/elements/lcry.cpp (renamed from elements/lcry.cpp)0
-rw-r--r--src/elements/legacy.cpp (renamed from elements/legacy.cpp)0
-rw-r--r--src/elements/ligh.cpp (renamed from elements/ligh.cpp)0
-rw-r--r--src/elements/merc.cpp (renamed from elements/merc.cpp)0
-rw-r--r--src/elements/mort.cpp (renamed from elements/mort.cpp)0
-rw-r--r--src/elements/nbhl.cpp (renamed from elements/nbhl.cpp)0
-rw-r--r--src/elements/neut.cpp (renamed from elements/neut.cpp)0
-rw-r--r--src/elements/newgraphics.cpp (renamed from elements/newgraphics.cpp)0
-rw-r--r--src/elements/none.cpp (renamed from elements/none.cpp)0
-rw-r--r--src/elements/nptct.cpp (renamed from elements/nptct.cpp)0
-rw-r--r--src/elements/nwhl.cpp (renamed from elements/nwhl.cpp)0
-rw-r--r--src/elements/pbcn.cpp (renamed from elements/pbcn.cpp)0
-rw-r--r--src/elements/pcln.cpp (renamed from elements/pcln.cpp)0
-rw-r--r--src/elements/phot.cpp (renamed from elements/phot.cpp)0
-rw-r--r--src/elements/pipe.cpp (renamed from elements/pipe.cpp)0
-rw-r--r--src/elements/plnt.cpp (renamed from elements/plnt.cpp)0
-rw-r--r--src/elements/plsm.cpp (renamed from elements/plsm.cpp)0
-rw-r--r--src/elements/plut.cpp (renamed from elements/plut.cpp)0
-rw-r--r--src/elements/prti.cpp (renamed from elements/prti.cpp)0
-rw-r--r--src/elements/prto.cpp (renamed from elements/prto.cpp)0
-rw-r--r--src/elements/pump.cpp (renamed from elements/pump.cpp)0
-rw-r--r--src/elements/pvod.cpp (renamed from elements/pvod.cpp)0
-rw-r--r--src/elements/pyro.cpp (renamed from elements/pyro.cpp)0
-rw-r--r--src/elements/qrtz.cpp (renamed from elements/qrtz.cpp)0
-rw-r--r--src/elements/rime.cpp (renamed from elements/rime.cpp)0
-rw-r--r--src/elements/shld.cpp (renamed from elements/shld.cpp)0
-rw-r--r--src/elements/sing.cpp (renamed from elements/sing.cpp)0
-rw-r--r--src/elements/sltw.cpp (renamed from elements/sltw.cpp)0
-rw-r--r--src/elements/smke.cpp (renamed from elements/smke.cpp)0
-rw-r--r--src/elements/soap.cpp (renamed from elements/soap.cpp)0
-rw-r--r--src/elements/spng.cpp (renamed from elements/spng.cpp)0
-rw-r--r--src/elements/sprk.cpp (renamed from elements/sprk.cpp)0
-rw-r--r--src/elements/stkm.cpp (renamed from elements/stkm.cpp)0
-rw-r--r--src/elements/stkm2.cpp (renamed from elements/stkm2.cpp)0
-rw-r--r--src/elements/stor.cpp (renamed from elements/stor.cpp)0
-rw-r--r--src/elements/swch.cpp (renamed from elements/swch.cpp)0
-rw-r--r--src/elements/thdr.cpp (renamed from elements/thdr.cpp)0
-rw-r--r--src/elements/thrm.cpp (renamed from elements/thrm.cpp)0
-rw-r--r--src/elements/uran.cpp (renamed from elements/uran.cpp)0
-rw-r--r--src/elements/vine.cpp (renamed from elements/vine.cpp)0
-rw-r--r--src/elements/warp.cpp (renamed from elements/warp.cpp)0
-rw-r--r--src/elements/watr.cpp (renamed from elements/watr.cpp)0
-rw-r--r--src/elements/wifi.cpp (renamed from elements/wifi.cpp)0
-rw-r--r--src/elements/wire.cpp (renamed from elements/wire.cpp)0
-rw-r--r--src/elements/wtrv.cpp (renamed from elements/wtrv.cpp)0
-rw-r--r--src/elements/yest.cpp (renamed from elements/yest.cpp)0
-rw-r--r--src/game/GameController.cpp62
-rw-r--r--src/game/GameController.h28
-rw-r--r--src/game/GameModel.cpp75
-rw-r--r--src/game/GameModel.h37
-rw-r--r--src/game/GameView.cpp83
-rw-r--r--src/game/GameView.h48
-rw-r--r--src/interface.old/Button.cpp127
-rw-r--r--src/interface.old/Component.cpp89
-rw-r--r--src/interface.old/ControlFactory.cpp11
-rw-r--r--src/interface.old/Panel.cpp23
-rw-r--r--src/interface.old/Sandbox.cpp76
-rw-r--r--src/interface.old/State.cpp233
-rw-r--r--src/interface.old/Window.cpp23
-rw-r--r--src/interface/Button.cpp26
-rw-r--r--src/interface/Button.h60
-rw-r--r--src/interface/Component.cpp14
-rw-r--r--src/interface/Component.h (renamed from includes/interface/Component.h)12
-rw-r--r--src/interface/ControlFactory.cpp5
-rw-r--r--src/interface/ControlFactory.h (renamed from includes/interface/ControlFactory.h)0
-rw-r--r--src/interface/Engine.cpp44
-rw-r--r--src/interface/Engine.h (renamed from includes/interface/Engine.h)19
-rw-r--r--src/interface/Label.cpp4
-rw-r--r--src/interface/Label.h (renamed from includes/interface/Label.h)2
-rw-r--r--src/interface/Panel.cpp10
-rw-r--r--src/interface/Panel.h (renamed from includes/interface/Panel.h)4
-rw-r--r--src/interface/Platform.h (renamed from includes/interface/Platform.h)0
-rw-r--r--src/interface/Point.h (renamed from includes/interface/Point.h)0
-rw-r--r--src/interface/Sandbox.cpp3
-rw-r--r--src/interface/Sandbox.h (renamed from includes/interface/Sandbox.h)0
-rw-r--r--src/interface/Window.cpp (renamed from src/interface/State.cpp)90
-rw-r--r--src/interface/Window.h (renamed from includes/interface/State.h)80
-rw-r--r--src/search/Save.h41
-rw-r--r--src/search/SearchController.cpp14
-rw-r--r--src/search/SearchController.h18
-rw-r--r--src/search/SearchModel.cpp23
-rw-r--r--src/search/SearchModel.h23
-rw-r--r--src/search/SearchView.cpp10
-rw-r--r--src/search/SearchView.h13
167 files changed, 913 insertions, 1056 deletions
diff --git a/Makefile b/Makefile
index 7bbac6d..4d20bfc 100644
--- a/Makefile
+++ b/Makefile
@@ -1,22 +1,12 @@
-HEADERS := $(wildcard includes/*.h)
+HEADERS := $(wildcard src/*.h) $(wildcard src/*/*.h)
-OLD_SOURCES := $(wildcard src/*.c)
-OLD_OBJS := $(patsubst src/%.c,build/obj/%.o,$(OLD_SOURCES))
+SOURCES := $(wildcard src/*.cpp) $(wildcard src/*/*.cpp)
+OBJS += $(patsubst src/%.cpp,build/obj/powder.exe/%.o,$(SOURCES))
-EL_SOURCES := $(wildcard elements/*.cpp)
-EL_OBJS := $(patsubst elements/%.cpp,build/obj/elements/%.o,$(EL_SOURCES))
-EL_PREREQ := $(patsubst build/obj/elements/%.o,build/obj/elements/%.powder.exe.o,$(EL_OBJS))
+FOLDERS := $(sort $(dir $(OBJS)))
-CORE_SOURCES := $(wildcard src/*.cpp)
-CORE_OBJS := $(patsubst src/%.cpp,build/obj/core/%.o,$(CORE_SOURCES))
-CORE_PREREQ := $(patsubst build/obj/core/%.o,build/obj/core/%.powder.exe.o,$(CORE_OBJS))
-
-UI_SOURCES := $(wildcard src/interface/*.cpp)
-UI_OBJS := $(patsubst src/interface/%.cpp,build/obj/ui/%.o,$(UI_SOURCES))
-UI_PREREQ := $(patsubst build/obj/ui/%.o,build/obj/ui/%.powder.exe.o,$(UI_OBJS))
-
-CFLAGS := -Iincludes/ -Idata/ -DWIN32 -DWINCONSOLE
-OFLAGS := -fkeep-inline-functions #-O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations
+CFLAGS := -Wno-deprecated -Wno-deprecated-declarations -Isrc/ -Idata/ -DWIN32 -DWINCONSOLE
+OFLAGS := -O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations -msse2 -fkeep-inline-functions
LFLAGS := -lmingw32 -lregex -lws2_32 -lSDLmain -lpthread -lSDL -lm -lbz2 # -mwindows
CFLAGS += $(OFLAGS)
@@ -28,14 +18,15 @@ WIN_RES := i686-w64-mingw32-windres
all: build/powder.exe
powder.exe: build/powder.exe
-build/powder.exe: $(EL_PREREQ) $(CORE_PREREQ) $(UI_PREREQ)
- $(CPPC) $(CFLAGS) $(LDFLAGS) $(EXTRA_OBJS) $(EL_PREREQ) $(CORE_PREREQ) $(UI_PREREQ) $(LFLAGS) -o $@ -ggdb
-build/obj/ui/%.powder.exe.o: src/interface/%.cpp $(HEADERS)
- $(CPPC) -c $(CFLAGS) -o $@ $< -ggdb
-build/obj/elements/%.powder.exe.o: elements/%.cpp $(HEADERS)
- $(CPPC) -c $(CFLAGS) -o $@ $< -ggdb
-build/obj/core/%.powder.exe.o: src/%.cpp $(HEADERS)
+
+build/powder.exe: buildpaths $(OBJS)
+ echo $(OBJS)
+ $(CPPC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LFLAGS) -o $@ -ggdb
+build/obj/powder.exe/%.o: src/%.cpp $(HEADERS)
$(CPPC) -c $(CFLAGS) -o $@ $< -ggdb
+buildpaths:
+ $(shell mkdir build/obj/powder.exe/)
+ $(shell mkdir $(FOLDERS))
clean:
rm build/obj/core/*.o
diff --git a/PowderToy++.files b/PowderToy++.files
index bcc42cd..5a30285 100644
--- a/PowderToy++.files
+++ b/PowderToy++.files
@@ -152,3 +152,159 @@ src/interface/Label.cpp
includes/interface/Label.h
includes/Global.h
src/Global.cpp
+src/search/SearchModel.h
+src/search/SearchModel.cpp
+src/search/Save.h
+src/search/SearchView.h
+src/search/SearchView.cpp
+src/search/SearchController.h
+src/search/SearchController.cpp
+src/game/GameController.h
+src/game/GameController.cpp
+src/game/GameModel.h
+src/game/GameModel.cpp
+src/interface/Window.h
+src/interface/Window.cpp
+src/game/GameView.h
+src/game/GameView.cpp
+src/Singleton.h
+src/Simulation.h
+src/Renderer.h
+src/Misc.h
+src/Gravity.h
+src/Graphics.h
+src/Global.h
+src/Elements.h
+src/ElementGraphics.h
+src/ElementFunctions.h
+src/Element.h
+src/Console.h
+src/Config.h
+src/Air.h
+src/Simulation.cpp
+src/Renderer.cpp
+src/PowderToy.cpp
+src/Misc.cpp
+src/Gravity.cpp
+src/Graphics.cpp
+src/Global.cpp
+src/Console.cpp
+src/Air.cpp
+src/elements/yest.cpp
+src/elements/wtrv.cpp
+src/elements/wire.cpp
+src/elements/wifi.cpp
+src/elements/watr.cpp
+src/elements/warp.cpp
+src/elements/vine.cpp
+src/elements/uran.cpp
+src/elements/thrm.cpp
+src/elements/thdr.cpp
+src/elements/swch.cpp
+src/elements/stor.cpp
+src/elements/stkm2.cpp
+src/elements/stkm.cpp
+src/elements/sprk.cpp
+src/elements/spng.cpp
+src/elements/soap.cpp
+src/elements/smke.cpp
+src/elements/sltw.cpp
+src/elements/sing.cpp
+src/elements/shld.cpp
+src/elements/rime.cpp
+src/elements/qrtz.cpp
+src/elements/pyro.cpp
+src/elements/pvod.cpp
+src/elements/pump.cpp
+src/elements/prto.cpp
+src/elements/prti.cpp
+src/elements/plut.cpp
+src/elements/plsm.cpp
+src/elements/plnt.cpp
+src/elements/pipe.cpp
+src/elements/phot.cpp
+src/elements/pcln.cpp
+src/elements/pbcn.cpp
+src/elements/O2.cpp
+src/elements/nwhl.cpp
+src/elements/nptct.cpp
+src/elements/none.cpp
+src/elements/newgraphics.cpp
+src/elements/neut.cpp
+src/elements/nbhl.cpp
+src/elements/mort.cpp
+src/elements/merc.cpp
+src/elements/ligh.cpp
+src/elements/legacy.cpp
+src/elements/lcry.cpp
+src/elements/lava.cpp
+src/elements/isz.cpp
+src/elements/iron.cpp
+src/elements/ignt.cpp
+src/elements/ice.cpp
+src/elements/hswc.cpp
+src/elements/h2.cpp
+src/elements/graphics_default.cpp
+src/elements/gpmp.cpp
+src/elements/goo.cpp
+src/elements/glow.cpp
+src/elements/glas.cpp
+src/elements/gbmb.cpp
+src/elements/fwrk.cpp
+src/elements/fuse.cpp
+src/elements/fsep.cpp
+src/elements/frzz.cpp
+src/elements/frzw.cpp
+src/elements/fog.cpp
+src/elements/firw.cpp
+src/elements/fire.cpp
+src/elements/figh.cpp
+src/elements/emp.cpp
+src/elements/elementmisc.cpp
+src/elements/elec.cpp
+src/elements/dstw.cpp
+src/elements/dlay.cpp
+src/elements/deut.cpp
+src/elements/dest.cpp
+src/elements/conv.cpp
+src/elements/coal.cpp
+src/elements/co2.cpp
+src/elements/clst.cpp
+src/elements/clne.cpp
+src/elements/cbnw.cpp
+src/elements/caus.cpp
+src/elements/c5.cpp
+src/elements/btry.cpp
+src/elements/brmt.cpp
+src/elements/boyl.cpp
+src/elements/bomb.cpp
+src/elements/bmtl.cpp
+src/elements/bizr.cpp
+src/elements/bcol.cpp
+src/elements/bcln.cpp
+src/elements/bang.cpp
+src/elements/aray.cpp
+src/elements/anar.cpp
+src/elements/amtr.cpp
+src/elements/acid.cpp
+src/elements/acel.cpp
+src/interface/Window.h
+src/interface/State.h
+src/interface/Sandbox.h
+src/interface/Point.h
+src/interface/Platform.h
+src/interface/Panel.h
+src/interface/Label.h
+src/interface/Engine.h
+src/interface/ControlFactory.h
+src/interface/Component.h
+src/interface/Button.h
+src/interface/Window.cpp
+src/interface/State.cpp
+src/interface/Sandbox.cpp
+src/interface/Panel.cpp
+src/interface/Label.cpp
+src/interface/Engine.cpp
+src/interface/ControlFactory.cpp
+src/interface/Component.cpp
+src/interface/Button.cpp
diff --git a/build/obj/core/.empty b/build/obj/core/.empty
deleted file mode 100644
index e69de29..0000000
--- a/build/obj/core/.empty
+++ /dev/null
diff --git a/build/obj/elements/.empty b/build/obj/elements/.empty
deleted file mode 100644
index e69de29..0000000
--- a/build/obj/elements/.empty
+++ /dev/null
diff --git a/build/obj/ui/.empty b/build/obj/ui/.empty
deleted file mode 100644
index e69de29..0000000
--- a/build/obj/ui/.empty
+++ /dev/null
diff --git a/includes/GameSession.h b/includes/GameSession.h
deleted file mode 100644
index 8417e0c..0000000
--- a/includes/GameSession.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef GAMESESSION_H
-#define GAMESESSION_H
-
-class GameSession
-{
-public:
- GameSession();
-};
-
-#endif // GAMESESSION_H
diff --git a/includes/interface.old/Button.h b/includes/interface.old/Button.h
deleted file mode 100644
index 1b2900e..0000000
--- a/includes/interface.old/Button.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Button.h
- *
- * Created on: Jan 8, 2012
- * Author: Simon
- */
-
-#ifndef BUTTON_H_
-#define BUTTON_H_
-
-#include <string>
-
-#include "Component.h"
-
-namespace ui
-{
- class Button : public Component
- {
- public:
- Button(int x, int y, int width, int height, const std::string& buttonText);
-
- bool Toggleable;
-
- std::string ButtonText;
-
- virtual void OnMouseClick(int x, int y, unsigned int button);
- virtual void OnMouseUnclick(int x, int y, unsigned int button);
- virtual void OnMouseUp(int x, int y, unsigned int button);
-
- virtual void OnMouseEnter(int x, int y, int dx, int dy);
- virtual void OnMouseLeave(int x, int y, int dx, int dy);
-
- virtual void Draw(void* userdata);
-
- inline bool GetState() { return state; }
- virtual void DoAction(); //action of button what ever it may be
-
- protected:
- bool isButtonDown, state, isMouseInside;
- };
-}
-#endif /* BUTTON_H_ */
diff --git a/includes/interface.old/Component.h b/includes/interface.old/Component.h
deleted file mode 100644
index a4d02db..0000000
--- a/includes/interface.old/Component.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Component.h
- *
- * Created on: Jan 8, 2012
- * Author: Simon
- */
-
-#ifndef COMPONENT_H_
-#define COMPONENT_H_
-
-namespace ui
-{
- class State;
-
- class Component
- {
- public:
- Component(int x, int y, int width, int height);
- virtual ~Component();
-
- inline void LocalizePoint(int& x, int& y) { x -= X; y -= Y; } //convert a global point (point on the state) to a point based on component's position
- inline void GlobalizePoint(int& x, int& y) { x += X; y += Y; } //convert a local point based on component's position to a global point on the state
-
- bool Focused;
- bool Visible;
- bool Enabled;
- int Width;
- int Height;
- int X;
- int Y;
-
- virtual void Tick(float dt);
- virtual void Draw(void* userdata);
-
- virtual void OnMouseEnter(int localx, int localy, int dx, int dy);
- virtual void OnMouseLeave(int localx, int localy, int dx, int dy);
- virtual void OnMouseMoved(int localx, int localy, int dx, int dy);
- virtual void OnMouseMovedInside(int localx, int localy, int dx, int dy);
- virtual void OnMouseHover(int localx, int localy);
- virtual void OnMouseDown(int localx, int localy, unsigned int button);
- virtual void OnMouseUp(int localx, int localy, unsigned int button);
- virtual void OnMouseClick(int localx, int localy, unsigned int button);
- virtual void OnMouseUnclick(int localx, int localy, unsigned int button);
- virtual void OnMouseWheel(int localx, int localy, int d);
- virtual void OnMouseWheelInside(int localx, int localy, int d);
- virtual void OnMouseWheelFocused(int localx, int localy, int d);
- virtual void OnKeyPress(int key, bool shift, bool ctrl, bool alt);
- virtual void OnKeyRelease(int key, bool shift, bool ctrl, bool alt);
-
- State* Parent;
- };
-}
-#endif /* COMPONENT_H_ */
diff --git a/includes/interface.old/ControlFactory.h b/includes/interface.old/ControlFactory.h
deleted file mode 100644
index 8bfd780..0000000
--- a/includes/interface.old/ControlFactory.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef CONTROLFACTORY_H
-#define CONTROLFACTORY_H
-
-#include "Panel.h"
-#include "Window.h"
-#include "GameSession.h"
-
-class ControlFactory
-{
-public:
- static ui::Panel * MainMenu(GameSession * session, int x, int y, int width, int height);
-
-};
-
-#endif // CONTROLFACTORY_H
diff --git a/includes/interface.old/Panel.h b/includes/interface.old/Panel.h
deleted file mode 100644
index 9549ff4..0000000
--- a/includes/interface.old/Panel.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Panel.h
- *
- * Created on: Jan 8, 2012
- * Author: Simon
- */
-
-#ifndef PANEL_H_
-#define PANEL_H_
-
-#include "interface/Component.h"
-
-namespace ui {
-
-class Panel: public ui::Component {
-public:
- Panel(int x, int y, int width, int height);
- virtual ~Panel();
-};
-
-} /* namespace ui */
-#endif /* PANEL_H_ */
diff --git a/includes/interface.old/Sandbox.h b/includes/interface.old/Sandbox.h
deleted file mode 100644
index 32a0471..0000000
--- a/includes/interface.old/Sandbox.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Sandbox.h
- *
- * Created on: Jan 8, 2012
- * Author: Simon
- */
-
-#ifndef SANDBOX_H_
-#define SANDBOX_H_
-
-#include "Component.h"
-#include "Simulation.h"
-#include "Renderer.h"
-
-namespace ui {
-
-class Sandbox: public ui::Component {
-private:
- int lastCoordX, lastCoordY;
- int activeElement;
- bool isMouseDown;
- Renderer * ren;
- Simulation * sim;
-public:
- Sandbox();
- virtual Simulation * GetSimulation();
- virtual void OnMouseMovedInside(int localx, int localy, int dx, int dy);
- virtual void OnMouseDown(int localx, int localy, unsigned int button);
- virtual void OnMouseUp(int localx, int localy, unsigned int button);
- virtual void Draw(void* userdata);
- virtual void Tick(float delta);
- virtual ~Sandbox();
-};
-
-} /* namespace ui */
-#endif /* SANDBOX_H_ */
diff --git a/includes/interface.old/State.h b/includes/interface.old/State.h
deleted file mode 100644
index 00df199..0000000
--- a/includes/interface.old/State.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * State.h
- *
- * Created on: Jan 8, 2012
- * Author: Simon
- */
-
-#ifndef STATE_H_
-#define STATE_H_
-
-#include <vector>
-
-#include "interface/Component.h"
-
-namespace ui {
-
-class State
-{
-public:
- State(int w, int h);
- virtual ~State();
-
- bool AllowExclusiveDrawing; //false will not call draw on objects outside of bounds
-
- virtual void Tick(float dt);
- virtual void Draw(void* userdata);
-
- virtual void OnMouseMove(int x, int y);
- virtual void OnMouseDown(int x, int y, unsigned int button);
- virtual void OnMouseUp(int x, int y, unsigned int button);
- virtual void OnMouseWheel(int x, int y, int d);
- virtual void OnKeyPress(int key, bool shift, bool ctrl, bool alt);
- virtual void OnKeyRelease(int key, bool shift, bool ctrl, bool alt);
-
- virtual void Add(Component *child);
- virtual void Remove(Component *child);
-
- inline bool IsFocused(Component* c) { return (c == focusedComponent_); }
- inline int GetMouseX() { return mouseX; }
- inline int GetMouseY() { return mouseY; }
- inline int GetWidth() { return width; }
- inline int GetHeight() { return height; }
-
-protected:
- std::vector<Component*> Components;
-
- int width;
- int height;
-
- int mouseX;
- int mouseY;
- int mouseXP;
- int mouseYP;
-
-private:
- Component* focusedComponent_;
-
-};
-
-} /* namespace ui */
-#endif /* STATE_H_ */
diff --git a/includes/interface.old/Window.h b/includes/interface.old/Window.h
deleted file mode 100644
index 86a4bcd..0000000
--- a/includes/interface.old/Window.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Window.h
- *
- * Created on: Jan 8, 2012
- * Author: Simon
- */
-
-#ifndef WINDOW_H_
-#define WINDOW_H_
-
-#include "interface/State.h"
-
-namespace ui {
-
-class Window: public ui::State {
-public:
- Window();
- virtual ~Window();
-};
-
-} /* namespace ui */
-#endif /* WINDOW_H_ */
diff --git a/includes/interface/Button.h b/includes/interface/Button.h
deleted file mode 100644
index 9046ea1..0000000
--- a/includes/interface/Button.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Button.h
- *
- * Created on: Jan 8, 2012
- * Author: Simon
- */
-
-#ifndef BUTTON_H_
-#define BUTTON_H_
-
-#include <string>
-
-#include "Component.h"
-
-namespace ui
-{
- class Button : public Component
- {
- public:
- Button(State* parent_state, std::string buttonText);
-
- Button(Point position, Point size, std::string buttonText);
-
- Button(std::string buttonText);
- virtual ~Button();
-
- bool Toggleable;
-
- std::string ButtonText;
-
- virtual void OnMouseClick(int x, int y, unsigned int button);
- virtual void OnMouseUnclick(int x, int y, unsigned int button);
- //virtual void OnMouseUp(int x, int y, unsigned int button);
-
- virtual void OnMouseEnter(int x, int y);
- virtual void OnMouseLeave(int x, int y);
-
- virtual void Draw(const Point& screenPos);
-
- inline bool GetState() { return state; }
- virtual void DoAction(); //action of button what ever it may be
- void SetTogglable(bool isTogglable);
- bool GetTogglable();
- inline bool GetToggleState();
- inline void SetToggleState(bool state);
-
- protected:
- bool isButtonDown, state, isMouseInside, isTogglable, toggle;
- };
-}
-#endif /* BUTTON_H_ */
diff --git a/includes/Air.h b/src/Air.h
index 8e4dc25..8e4dc25 100644
--- a/includes/Air.h
+++ b/src/Air.h
diff --git a/includes/Config.h b/src/Config.h
index 4cb2da3..4cb2da3 100644
--- a/includes/Config.h
+++ b/src/Config.h
diff --git a/includes/Console.h b/src/Console.h
index 657f935..657f935 100644
--- a/includes/Console.h
+++ b/src/Console.h
diff --git a/includes/Element.h b/src/Element.h
index 449bf51..449bf51 100644
--- a/includes/Element.h
+++ b/src/Element.h
diff --git a/includes/ElementFunctions.h b/src/ElementFunctions.h
index ef80b6f..ef80b6f 100644
--- a/includes/ElementFunctions.h
+++ b/src/ElementFunctions.h
diff --git a/includes/ElementGraphics.h b/src/ElementGraphics.h
index a880e71..a880e71 100644
--- a/includes/ElementGraphics.h
+++ b/src/ElementGraphics.h
diff --git a/includes/Elements.h b/src/Elements.h
index 204460c..204460c 100644
--- a/includes/Elements.h
+++ b/src/Elements.h
diff --git a/src/GameSession.cpp b/src/GameSession.cpp
deleted file mode 100644
index 364f268..0000000
--- a/src/GameSession.cpp
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "GameSession.h"
-
-GameSession::GameSession()
-{
- //Boop
-}
diff --git a/src/Global.cpp b/src/Global.cpp
index 7bf28f0..c1e0559 100644
--- a/src/Global.cpp
+++ b/src/Global.cpp
@@ -1,5 +1,6 @@
-#include "Global.h"
+/*#include "Global.h"
Global::Global(){
}
+*/
diff --git a/includes/Global.h b/src/Global.h
index 8e94255..ceff38e 100644
--- a/includes/Global.h
+++ b/src/Global.h
@@ -4,11 +4,11 @@
#include "Singleton.h"
#include "Graphics.h"
-class Global : public Singleton<Global>
+/*class Global : public Singleton<Global>
{
public:
Graphics * g;
Global();
-};
+};*/
#endif // GAMESESSION_H
diff --git a/includes/Graphics.h b/src/Graphics.h
index 6cd5b36..6cd5b36 100644
--- a/includes/Graphics.h
+++ b/src/Graphics.h
diff --git a/includes/Gravity.h b/src/Gravity.h
index 9f36240..9f36240 100644
--- a/includes/Gravity.h
+++ b/src/Gravity.h
diff --git a/includes/Misc.h b/src/Misc.h
index c5a61ef..c5a61ef 100644
--- a/includes/Misc.h
+++ b/src/Misc.h
diff --git a/src/PowderToy.cpp b/src/PowderToy.cpp
index 1e9630c..cf7d804 100644
--- a/src/PowderToy.cpp
+++ b/src/PowderToy.cpp
@@ -19,6 +19,9 @@
#include "interface/Point.h"
#include "interface/Label.h"
+#include "game/GameController.h"
+#include "game/GameView.h"
+
using namespace std;
SDL_Surface * SDLOpen()
@@ -66,20 +69,24 @@ int main(int argc, char * argv[])
//Simulation * sim = new Simulation();
//ren = new Renderer(g, sim);
- Global::Ref().g = new Graphics();
- Global::Ref().g->AttachSDLSurface(SDLOpen());
+ ui::Engine::Ref().g = new Graphics();
+ ui::Engine::Ref().g->AttachSDLSurface(SDLOpen());
ui::Engine * engine = &ui::Engine::Ref();//new ui::Engine();
- ui::State * engineState = new ui::State();
- ui::Sandbox * sandbox = new ui::Sandbox();
- ui::Button * button = new ui::Button(ui::Point(100, 100), ui::Point(100, 100), std::string("poP"));
+ //ui::State * engineState = new ui::State();
ui::Label * fpsLabel = new ui::Label(ui::Point(2, 2), ui::Point(200, 14), std::string("FPS: 0"));
+ //engineState->AddComponent(fpsLabel);
engine->Begin(XRES, YRES);
- engine->SetState(engineState);
+// engine->SetState(engineState);
+
+ GameController * gameController = new GameController();
+ engine->ShowWindow(gameController->GetView());
+ /*ui::Sandbox * sandbox = new ui::Sandbox();
+ ui::Button * button = new ui::Button(ui::Point(100, 100), ui::Point(100, 100), std::string("poP"));
engineState->AddComponent(fpsLabel);
engineState->AddComponent(sandbox);
engineState->AddComponent(button);
- engineState->AddComponent(ControlFactory::MainMenu(0, YRES+MENUSIZE-17, XRES+BARSIZE, 16));
+ engineState->AddComponent(ControlFactory::MainMenu(0, YRES+MENUSIZE-17, XRES+BARSIZE, 16));*/
SDL_Event event;
while(engine->Running())
diff --git a/includes/Renderer.h b/src/Renderer.h
index 39c8c1a..39c8c1a 100644
--- a/includes/Renderer.h
+++ b/src/Renderer.h
diff --git a/includes/Simulation.h b/src/Simulation.h
index b3c51af..b3c51af 100644
--- a/includes/Simulation.h
+++ b/src/Simulation.h
diff --git a/includes/Singleton.h b/src/Singleton.h
index 6b2214e..6b2214e 100644
--- a/includes/Singleton.h
+++ b/src/Singleton.h
diff --git a/elements/O2.cpp b/src/elements/O2.cpp
index 78b4229..78b4229 100644
--- a/elements/O2.cpp
+++ b/src/elements/O2.cpp
diff --git a/elements/acel.cpp b/src/elements/acel.cpp
index 7ab9684..7ab9684 100644
--- a/elements/acel.cpp
+++ b/src/elements/acel.cpp
diff --git a/elements/acid.cpp b/src/elements/acid.cpp
index 3a72b9d..3a72b9d 100644
--- a/elements/acid.cpp
+++ b/src/elements/acid.cpp
diff --git a/elements/amtr.cpp b/src/elements/amtr.cpp
index d119cc9..d119cc9 100644
--- a/elements/amtr.cpp
+++ b/src/elements/amtr.cpp
diff --git a/elements/anar.cpp b/src/elements/anar.cpp
index 83eaf5a..83eaf5a 100644
--- a/elements/anar.cpp
+++ b/src/elements/anar.cpp
diff --git a/elements/aray.cpp b/src/elements/aray.cpp
index 65b0d53..65b0d53 100644
--- a/elements/aray.cpp
+++ b/src/elements/aray.cpp
diff --git a/elements/bang.cpp b/src/elements/bang.cpp
index 658a567..658a567 100644
--- a/elements/bang.cpp
+++ b/src/elements/bang.cpp
diff --git a/elements/bcln.cpp b/src/elements/bcln.cpp
index 8c00f95..8c00f95 100644
--- a/elements/bcln.cpp
+++ b/src/elements/bcln.cpp
diff --git a/elements/bcol.cpp b/src/elements/bcol.cpp
index d941508..d941508 100644
--- a/elements/bcol.cpp
+++ b/src/elements/bcol.cpp
diff --git a/elements/bizr.cpp b/src/elements/bizr.cpp
index 538b87f..538b87f 100644
--- a/elements/bizr.cpp
+++ b/src/elements/bizr.cpp
diff --git a/elements/bmtl.cpp b/src/elements/bmtl.cpp
index a3dc4b8..a3dc4b8 100644
--- a/elements/bmtl.cpp
+++ b/src/elements/bmtl.cpp
diff --git a/elements/bomb.cpp b/src/elements/bomb.cpp
index b2e9e7d..b2e9e7d 100644
--- a/elements/bomb.cpp
+++ b/src/elements/bomb.cpp
diff --git a/elements/boyl.cpp b/src/elements/boyl.cpp
index e4ee6d2..e4ee6d2 100644
--- a/elements/boyl.cpp
+++ b/src/elements/boyl.cpp
diff --git a/elements/brmt.cpp b/src/elements/brmt.cpp
index c23bd99..c23bd99 100644
--- a/elements/brmt.cpp
+++ b/src/elements/brmt.cpp
diff --git a/elements/btry.cpp b/src/elements/btry.cpp
index 3f11003..3f11003 100644
--- a/elements/btry.cpp
+++ b/src/elements/btry.cpp
diff --git a/elements/c5.cpp b/src/elements/c5.cpp
index 412245f..412245f 100644
--- a/elements/c5.cpp
+++ b/src/elements/c5.cpp
diff --git a/elements/caus.cpp b/src/elements/caus.cpp
index 2ec268e..2ec268e 100644
--- a/elements/caus.cpp
+++ b/src/elements/caus.cpp
diff --git a/elements/cbnw.cpp b/src/elements/cbnw.cpp
index cf0c13e..cf0c13e 100644
--- a/elements/cbnw.cpp
+++ b/src/elements/cbnw.cpp
diff --git a/elements/clne.cpp b/src/elements/clne.cpp
index 13b25b9..13b25b9 100644
--- a/elements/clne.cpp
+++ b/src/elements/clne.cpp
diff --git a/elements/clst.cpp b/src/elements/clst.cpp
index 2c31d87..2c31d87 100644
--- a/elements/clst.cpp
+++ b/src/elements/clst.cpp
diff --git a/elements/co2.cpp b/src/elements/co2.cpp
index 5a3bbf5..5a3bbf5 100644
--- a/elements/co2.cpp
+++ b/src/elements/co2.cpp
diff --git a/elements/coal.cpp b/src/elements/coal.cpp
index 256aa69..256aa69 100644
--- a/elements/coal.cpp
+++ b/src/elements/coal.cpp
diff --git a/elements/conv.cpp b/src/elements/conv.cpp
index ce4ee48..ce4ee48 100644
--- a/elements/conv.cpp
+++ b/src/elements/conv.cpp
diff --git a/elements/dest.cpp b/src/elements/dest.cpp
index 014fad4..014fad4 100644
--- a/elements/dest.cpp
+++ b/src/elements/dest.cpp
diff --git a/elements/deut.cpp b/src/elements/deut.cpp
index 03de364..03de364 100644
--- a/elements/deut.cpp
+++ b/src/elements/deut.cpp
diff --git a/elements/dlay.cpp b/src/elements/dlay.cpp
index 4643b30..4643b30 100644
--- a/elements/dlay.cpp
+++ b/src/elements/dlay.cpp
diff --git a/elements/dstw.cpp b/src/elements/dstw.cpp
index 03ae7dd..03ae7dd 100644
--- a/elements/dstw.cpp
+++ b/src/elements/dstw.cpp
diff --git a/elements/elec.cpp b/src/elements/elec.cpp
index 6b06f8f..6b06f8f 100644
--- a/elements/elec.cpp
+++ b/src/elements/elec.cpp
diff --git a/elements/elementmisc.cpp b/src/elements/elementmisc.cpp
index a169e80..a169e80 100644
--- a/elements/elementmisc.cpp
+++ b/src/elements/elementmisc.cpp
diff --git a/elements/emp.cpp b/src/elements/emp.cpp
index a187196..a187196 100644
--- a/elements/emp.cpp
+++ b/src/elements/emp.cpp
diff --git a/elements/figh.cpp b/src/elements/figh.cpp
index 8b18871..8b18871 100644
--- a/elements/figh.cpp
+++ b/src/elements/figh.cpp
diff --git a/elements/fire.cpp b/src/elements/fire.cpp
index 1f9c0c2..1f9c0c2 100644
--- a/elements/fire.cpp
+++ b/src/elements/fire.cpp
diff --git a/elements/firw.cpp b/src/elements/firw.cpp
index 74605b0..74605b0 100644
--- a/elements/firw.cpp
+++ b/src/elements/firw.cpp
diff --git a/elements/fog.cpp b/src/elements/fog.cpp
index 28952e9..28952e9 100644
--- a/elements/fog.cpp
+++ b/src/elements/fog.cpp
diff --git a/elements/frzw.cpp b/src/elements/frzw.cpp
index 932bccb..932bccb 100644
--- a/elements/frzw.cpp
+++ b/src/elements/frzw.cpp
diff --git a/elements/frzz.cpp b/src/elements/frzz.cpp
index 8e09c1d..8e09c1d 100644
--- a/elements/frzz.cpp
+++ b/src/elements/frzz.cpp
diff --git a/elements/fsep.cpp b/src/elements/fsep.cpp
index 3db5ba5..3db5ba5 100644
--- a/elements/fsep.cpp
+++ b/src/elements/fsep.cpp
diff --git a/elements/fuse.cpp b/src/elements/fuse.cpp
index e1db1ff..e1db1ff 100644
--- a/elements/fuse.cpp
+++ b/src/elements/fuse.cpp
diff --git a/elements/fwrk.cpp b/src/elements/fwrk.cpp
index d217ad9..d217ad9 100644
--- a/elements/fwrk.cpp
+++ b/src/elements/fwrk.cpp
diff --git a/elements/gbmb.cpp b/src/elements/gbmb.cpp
index 95afc4e..95afc4e 100644
--- a/elements/gbmb.cpp
+++ b/src/elements/gbmb.cpp
diff --git a/elements/glas.cpp b/src/elements/glas.cpp
index e8c0a6c..e8c0a6c 100644
--- a/elements/glas.cpp
+++ b/src/elements/glas.cpp
diff --git a/elements/glow.cpp b/src/elements/glow.cpp
index e83e2f4..e83e2f4 100644
--- a/elements/glow.cpp
+++ b/src/elements/glow.cpp
diff --git a/elements/goo.cpp b/src/elements/goo.cpp
index c305182..c305182 100644
--- a/elements/goo.cpp
+++ b/src/elements/goo.cpp
diff --git a/elements/gpmp.cpp b/src/elements/gpmp.cpp
index dcde7a9..dcde7a9 100644
--- a/elements/gpmp.cpp
+++ b/src/elements/gpmp.cpp
diff --git a/elements/graphics_default.cpp b/src/elements/graphics_default.cpp
index 1270977..1270977 100644
--- a/elements/graphics_default.cpp
+++ b/src/elements/graphics_default.cpp
diff --git a/elements/h2.cpp b/src/elements/h2.cpp
index da39ad0..da39ad0 100644
--- a/elements/h2.cpp
+++ b/src/elements/h2.cpp
diff --git a/elements/hswc.cpp b/src/elements/hswc.cpp
index c727395..c727395 100644
--- a/elements/hswc.cpp
+++ b/src/elements/hswc.cpp
diff --git a/elements/ice.cpp b/src/elements/ice.cpp
index aece17b..aece17b 100644
--- a/elements/ice.cpp
+++ b/src/elements/ice.cpp
diff --git a/elements/ignt.cpp b/src/elements/ignt.cpp
index 1d7ea64..1d7ea64 100644
--- a/elements/ignt.cpp
+++ b/src/elements/ignt.cpp
diff --git a/elements/iron.cpp b/src/elements/iron.cpp
index b887cf8..b887cf8 100644
--- a/elements/iron.cpp
+++ b/src/elements/iron.cpp
diff --git a/elements/isz.cpp b/src/elements/isz.cpp
index 25446d2..25446d2 100644
--- a/elements/isz.cpp
+++ b/src/elements/isz.cpp
diff --git a/elements/lava.cpp b/src/elements/lava.cpp
index 3d7827b..3d7827b 100644
--- a/elements/lava.cpp
+++ b/src/elements/lava.cpp
diff --git a/elements/lcry.cpp b/src/elements/lcry.cpp
index 546c2ca..546c2ca 100644
--- a/elements/lcry.cpp
+++ b/src/elements/lcry.cpp
diff --git a/elements/legacy.cpp b/src/elements/legacy.cpp
index dd58173..dd58173 100644
--- a/elements/legacy.cpp
+++ b/src/elements/legacy.cpp
diff --git a/elements/ligh.cpp b/src/elements/ligh.cpp
index 8108c4b..8108c4b 100644
--- a/elements/ligh.cpp
+++ b/src/elements/ligh.cpp
diff --git a/elements/merc.cpp b/src/elements/merc.cpp
index 2df113b..2df113b 100644
--- a/elements/merc.cpp
+++ b/src/elements/merc.cpp
diff --git a/elements/mort.cpp b/src/elements/mort.cpp
index bbb6264..bbb6264 100644
--- a/elements/mort.cpp
+++ b/src/elements/mort.cpp
diff --git a/elements/nbhl.cpp b/src/elements/nbhl.cpp
index 056313c..056313c 100644
--- a/elements/nbhl.cpp
+++ b/src/elements/nbhl.cpp
diff --git a/elements/neut.cpp b/src/elements/neut.cpp
index a48fc09..a48fc09 100644
--- a/elements/neut.cpp
+++ b/src/elements/neut.cpp
diff --git a/elements/newgraphics.cpp b/src/elements/newgraphics.cpp
index 83da27b..83da27b 100644
--- a/elements/newgraphics.cpp
+++ b/src/elements/newgraphics.cpp
diff --git a/elements/none.cpp b/src/elements/none.cpp
index 50f301f..50f301f 100644
--- a/elements/none.cpp
+++ b/src/elements/none.cpp
diff --git a/elements/nptct.cpp b/src/elements/nptct.cpp
index 2d68a9b..2d68a9b 100644
--- a/elements/nptct.cpp
+++ b/src/elements/nptct.cpp
diff --git a/elements/nwhl.cpp b/src/elements/nwhl.cpp
index f53b657..f53b657 100644
--- a/elements/nwhl.cpp
+++ b/src/elements/nwhl.cpp
diff --git a/elements/pbcn.cpp b/src/elements/pbcn.cpp
index 7e99397..7e99397 100644
--- a/elements/pbcn.cpp
+++ b/src/elements/pbcn.cpp
diff --git a/elements/pcln.cpp b/src/elements/pcln.cpp
index cd1ed4f..cd1ed4f 100644
--- a/elements/pcln.cpp
+++ b/src/elements/pcln.cpp
diff --git a/elements/phot.cpp b/src/elements/phot.cpp
index 3ed6b5d..3ed6b5d 100644
--- a/elements/phot.cpp
+++ b/src/elements/phot.cpp
diff --git a/elements/pipe.cpp b/src/elements/pipe.cpp
index 08432f5..08432f5 100644
--- a/elements/pipe.cpp
+++ b/src/elements/pipe.cpp
diff --git a/elements/plnt.cpp b/src/elements/plnt.cpp
index a44c8c2..a44c8c2 100644
--- a/elements/plnt.cpp
+++ b/src/elements/plnt.cpp
diff --git a/elements/plsm.cpp b/src/elements/plsm.cpp
index c6f7c20..c6f7c20 100644
--- a/elements/plsm.cpp
+++ b/src/elements/plsm.cpp
diff --git a/elements/plut.cpp b/src/elements/plut.cpp
index 3e2820d..3e2820d 100644
--- a/elements/plut.cpp
+++ b/src/elements/plut.cpp
diff --git a/elements/prti.cpp b/src/elements/prti.cpp
index df212d4..df212d4 100644
--- a/elements/prti.cpp
+++ b/src/elements/prti.cpp
diff --git a/elements/prto.cpp b/src/elements/prto.cpp
index ee61abf..ee61abf 100644
--- a/elements/prto.cpp
+++ b/src/elements/prto.cpp
diff --git a/elements/pump.cpp b/src/elements/pump.cpp
index 8a7254e..8a7254e 100644
--- a/elements/pump.cpp
+++ b/src/elements/pump.cpp
diff --git a/elements/pvod.cpp b/src/elements/pvod.cpp
index e645d0a..e645d0a 100644
--- a/elements/pvod.cpp
+++ b/src/elements/pvod.cpp
diff --git a/elements/pyro.cpp b/src/elements/pyro.cpp
index 790e295..790e295 100644
--- a/elements/pyro.cpp
+++ b/src/elements/pyro.cpp
diff --git a/elements/qrtz.cpp b/src/elements/qrtz.cpp
index 7768765..7768765 100644
--- a/elements/qrtz.cpp
+++ b/src/elements/qrtz.cpp
diff --git a/elements/rime.cpp b/src/elements/rime.cpp
index 617414b..617414b 100644
--- a/elements/rime.cpp
+++ b/src/elements/rime.cpp
diff --git a/elements/shld.cpp b/src/elements/shld.cpp
index cbe8306..cbe8306 100644
--- a/elements/shld.cpp
+++ b/src/elements/shld.cpp
diff --git a/elements/sing.cpp b/src/elements/sing.cpp
index fa6121c..fa6121c 100644
--- a/elements/sing.cpp
+++ b/src/elements/sing.cpp
diff --git a/elements/sltw.cpp b/src/elements/sltw.cpp
index c965fd4..c965fd4 100644
--- a/elements/sltw.cpp
+++ b/src/elements/sltw.cpp
diff --git a/elements/smke.cpp b/src/elements/smke.cpp
index d19bd0a..d19bd0a 100644
--- a/elements/smke.cpp
+++ b/src/elements/smke.cpp
diff --git a/elements/soap.cpp b/src/elements/soap.cpp
index 0d31292..0d31292 100644
--- a/elements/soap.cpp
+++ b/src/elements/soap.cpp
diff --git a/elements/spng.cpp b/src/elements/spng.cpp
index 28b3e1b..28b3e1b 100644
--- a/elements/spng.cpp
+++ b/src/elements/spng.cpp
diff --git a/elements/sprk.cpp b/src/elements/sprk.cpp
index 244e831..244e831 100644
--- a/elements/sprk.cpp
+++ b/src/elements/sprk.cpp
diff --git a/elements/stkm.cpp b/src/elements/stkm.cpp
index 322eba1..322eba1 100644
--- a/elements/stkm.cpp
+++ b/src/elements/stkm.cpp
diff --git a/elements/stkm2.cpp b/src/elements/stkm2.cpp
index 967bea2..967bea2 100644
--- a/elements/stkm2.cpp
+++ b/src/elements/stkm2.cpp
diff --git a/elements/stor.cpp b/src/elements/stor.cpp
index 66eb072..66eb072 100644
--- a/elements/stor.cpp
+++ b/src/elements/stor.cpp
diff --git a/elements/swch.cpp b/src/elements/swch.cpp
index ee2c467..ee2c467 100644
--- a/elements/swch.cpp
+++ b/src/elements/swch.cpp
diff --git a/elements/thdr.cpp b/src/elements/thdr.cpp
index f7f95b4..f7f95b4 100644
--- a/elements/thdr.cpp
+++ b/src/elements/thdr.cpp
diff --git a/elements/thrm.cpp b/src/elements/thrm.cpp
index 91939e6..91939e6 100644
--- a/elements/thrm.cpp
+++ b/src/elements/thrm.cpp
diff --git a/elements/uran.cpp b/src/elements/uran.cpp
index a8b2a06..a8b2a06 100644
--- a/elements/uran.cpp
+++ b/src/elements/uran.cpp
diff --git a/elements/vine.cpp b/src/elements/vine.cpp
index 165d391..165d391 100644
--- a/elements/vine.cpp
+++ b/src/elements/vine.cpp
diff --git a/elements/warp.cpp b/src/elements/warp.cpp
index ddc1b81..ddc1b81 100644
--- a/elements/warp.cpp
+++ b/src/elements/warp.cpp
diff --git a/elements/watr.cpp b/src/elements/watr.cpp
index 09b66a9..09b66a9 100644
--- a/elements/watr.cpp
+++ b/src/elements/watr.cpp
diff --git a/elements/wifi.cpp b/src/elements/wifi.cpp
index ee5e264..ee5e264 100644
--- a/elements/wifi.cpp
+++ b/src/elements/wifi.cpp
diff --git a/elements/wire.cpp b/src/elements/wire.cpp
index 49d3720..49d3720 100644
--- a/elements/wire.cpp
+++ b/src/elements/wire.cpp
diff --git a/elements/wtrv.cpp b/src/elements/wtrv.cpp
index de0eae4..de0eae4 100644
--- a/elements/wtrv.cpp
+++ b/src/elements/wtrv.cpp
diff --git a/elements/yest.cpp b/src/elements/yest.cpp
index c6c7db6..c6c7db6 100644
--- a/elements/yest.cpp
+++ b/src/elements/yest.cpp
diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp
new file mode 100644
index 0000000..becb540
--- /dev/null
+++ b/src/game/GameController.cpp
@@ -0,0 +1,62 @@
+
+#include <iostream>
+#include <queue>
+#include "Config.h"
+#include "GameController.h"
+#include "GameModel.h"
+#include "interface/Point.h"
+
+using namespace std;
+
+GameController::GameController()
+{
+ gameView = new GameView();
+ gameModel = new GameModel();
+
+ gameView->AttachController(this);
+ gameModel->AddObserver(gameView);
+
+ sim = new Simulation();
+}
+
+GameView * GameController::GetView()
+{
+ return gameView;
+}
+
+void GameController::DrawPoints(queue<ui::Point*> & pointQueue)
+{
+ Simulation * sim = gameModel->GetSimulation();
+ int activeElement = gameModel->GetActiveElement();
+ if(!pointQueue.empty())
+ {
+ ui::Point * sPoint = NULL;
+ while(!pointQueue.empty())
+ {
+ ui::Point * fPoint = pointQueue.front();
+ pointQueue.pop();
+ if(sPoint)
+ {
+ sim->create_line(fPoint->X, fPoint->Y, sPoint->X, sPoint->Y, 1, 1, activeElement, 0);
+ delete sPoint;
+ }
+ else
+ {
+ sim->create_parts(fPoint->X, fPoint->Y, 1, 1, activeElement, 0);
+ }
+ sPoint = fPoint;
+ }
+ if(sPoint)
+ delete sPoint;
+ }
+}
+
+void GameController::Tick()
+{
+ gameModel->GetSimulation()->update_particles();
+}
+
+void GameController::SetPaused(bool pauseState)
+{
+ gameModel->SetPaused(pauseState);
+}
diff --git a/src/game/GameController.h b/src/game/GameController.h
new file mode 100644
index 0000000..c3c8273
--- /dev/null
+++ b/src/game/GameController.h
@@ -0,0 +1,28 @@
+#ifndef GAMECONTROLLER_H
+#define GAMECONTROLLER_H
+
+#include <queue>
+#include "GameView.h"
+#include "GameModel.h"
+#include "interface/Point.h"
+#include "Simulation.h"
+
+using namespace std;
+
+class GameModel;
+class GameView;
+class GameController
+{
+private:
+ Simulation * sim;
+ GameView * gameView;
+ GameModel * gameModel;
+public:
+ GameController();
+ GameView * GetView();
+ void DrawPoints(queue<ui::Point*> & pointQueue);
+ void Tick();
+ void SetPaused(bool pauseState);
+};
+
+#endif // GAMECONTROLLER_H
diff --git a/src/game/GameModel.cpp b/src/game/GameModel.cpp
new file mode 100644
index 0000000..96b29a9
--- /dev/null
+++ b/src/game/GameModel.cpp
@@ -0,0 +1,75 @@
+#include "interface/Engine.h"
+#include "GameModel.h"
+#include "GameView.h"
+#include "Simulation.h"
+#include "Renderer.h"
+
+GameModel::GameModel():
+ activeElement(1)
+{
+ sim = new Simulation();
+ ren = new Renderer(ui::Engine::Ref().g, sim);
+}
+
+void GameModel::AddObserver(GameView * observer){
+ observers.push_back(observer);
+
+ observer->NotifySimulationChanged(this);
+ observer->NotifyRendererChanged(this);
+ observer->NotifyPausedChanged(this);
+}
+
+int GameModel::GetActiveElement()
+{
+ return activeElement;
+}
+
+void GameModel::SetActiveElement(int element)
+{
+ activeElement = element;
+}
+
+Simulation * GameModel::GetSimulation()
+{
+ return sim;
+}
+
+Renderer * GameModel::GetRenderer()
+{
+ return ren;
+}
+
+void GameModel::SetPaused(bool pauseState)
+{
+ sim->sys_pause = pauseState?1:0;
+ notifyPausedChanged();
+}
+
+bool GameModel::GetPaused()
+{
+ return sim->sys_pause?true:false;
+}
+
+void GameModel::notifyRendererChanged()
+{
+ for(int i = 0; i < observers.size(); i++)
+ {
+ observers[i]->NotifyRendererChanged(this);
+ }
+}
+
+void GameModel::notifySimulationChanged()
+{
+ for(int i = 0; i < observers.size(); i++)
+ {
+ observers[i]->NotifySimulationChanged(this);
+ }
+}
+
+void GameModel::notifyPausedChanged()
+{
+ for(int i = 0; i < observers.size(); i++)
+ {
+ observers[i]->NotifyPausedChanged(this);
+ }
+}
diff --git a/src/game/GameModel.h b/src/game/GameModel.h
new file mode 100644
index 0000000..a2eb3ce
--- /dev/null
+++ b/src/game/GameModel.h
@@ -0,0 +1,37 @@
+#ifndef GAMEMODEL_H
+#define GAMEMODEL_H
+
+#include <vector>
+#include "Simulation.h"
+#include "Renderer.h"
+#include "GameView.h"
+
+using namespace std;
+
+class GameView;
+class Simulation;
+class Renderer;
+
+class GameModel
+{
+private:
+ vector<GameView*> observers;
+ Simulation * sim;
+ Renderer * ren;
+ int activeElement;
+ void notifyRendererChanged();
+ void notifySimulationChanged();
+ void notifyPausedChanged();
+public:
+ GameModel();
+ void AddObserver(GameView * observer);
+ int GetActiveElement();
+ void SetActiveElement(int element);
+ bool GetPaused();
+ void SetPaused(bool pauseState);
+
+ Simulation * GetSimulation();
+ Renderer * GetRenderer();
+};
+
+#endif // GAMEMODEL_H
diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp
new file mode 100644
index 0000000..2576527
--- /dev/null
+++ b/src/game/GameView.cpp
@@ -0,0 +1,83 @@
+#include "Config.h"
+#include "GameView.h"
+#include "interface/Window.h"
+#include "interface/Button.h"
+
+GameView::GameView():
+ ui::Window(ui::Point(0, 0), ui::Point(XRES+BARSIZE, YRES+MENUSIZE)),
+ pointQueue(queue<ui::Point*>()),
+ isMouseDown(false),
+ ren(NULL)
+{
+ //Set up UI
+ class PauseAction : public ui::ButtonAction
+ {
+ GameView * v;
+ public:
+ PauseAction(GameView * _v) { v = _v; }
+ void ActionCallback(ui::Button * sender)
+ {
+ v->c->SetPaused(sender->GetToggleState());
+ }
+ };
+ pauseButton = new ui::Button(ui::Point(Size.X-18, Size.Y-18), ui::Point(16, 16), "\x90"); //Pause
+ pauseButton->SetTogglable(true);
+ pauseButton->SetActionCallback(new PauseAction(this));
+ AddComponent(pauseButton);
+}
+
+void GameView::NotifyRendererChanged(GameModel * sender)
+{
+ ren = sender->GetRenderer();
+}
+
+void GameView::NotifySimulationChanged(GameModel * sender)
+{
+
+}
+
+void GameView::NotifyPausedChanged(GameModel * sender)
+{
+ pauseButton->SetToggleState(sender->GetPaused());
+}
+
+void GameView::OnMouseMove(int x, int y, int dx, int dy)
+{
+ if(isMouseDown)
+ {
+ pointQueue.push(new ui::Point(x-dx, y-dy));
+ pointQueue.push(new ui::Point(x, y));
+ }
+}
+
+void GameView::OnMouseDown(int x, int y, unsigned button)
+{
+ isMouseDown = true;
+ pointQueue.push(new ui::Point(x, y));
+}
+
+void GameView::OnMouseUp(int x, int y, unsigned button)
+{
+ if(isMouseDown)
+ {
+ isMouseDown = false;
+ pointQueue.push(new ui::Point(x, y));
+ }
+}
+
+void GameView::OnTick(float dt)
+{
+ if(!pointQueue.empty())
+ {
+ c->DrawPoints(pointQueue);
+ }
+ c->Tick();
+}
+
+void GameView::OnDraw()
+{
+ if(ren)
+ {
+ ren->render_parts();
+ }
+}
diff --git a/src/game/GameView.h b/src/game/GameView.h
new file mode 100644
index 0000000..531a4b9
--- /dev/null
+++ b/src/game/GameView.h
@@ -0,0 +1,48 @@
+#ifndef GAMEVIEW_H
+#define GAMEVIEW_H
+
+#include <queue>
+#include "GameController.h"
+#include "GameModel.h"
+#include "interface/Window.h"
+#include "interface/Point.h"
+#include "interface/Button.h"
+
+using namespace std;
+
+class GameController;
+class GameModel;
+class GameView: public ui::Window
+{
+private:
+ bool isMouseDown;
+ queue<ui::Point*> pointQueue;
+ GameController * c;
+ Renderer * ren;
+ //UI Elements
+ ui::Button * pauseButton;
+public:
+ GameView();
+ void AttachController(GameController * _c){ c = _c; }
+ void NotifyRendererChanged(GameModel * sender);
+ void NotifySimulationChanged(GameModel * sender);
+ void NotifyPausedChanged(GameModel * sender);
+ /*virtual void DoMouseMove(int x, int y, int dx, int dy);
+ virtual void DoMouseDown(int x, int y, unsigned button);
+ virtual void DoMouseUp(int x, int y, unsigned button);
+ //virtual void DoMouseWheel(int x, int y, int d);
+ //virtual void DoKeyPress(int key, bool shift, bool ctrl, bool alt);
+ //virtual void DoKeyRelease(int key, bool shift, bool ctrl, bool alt);
+ virtual void DoTick(float dt);
+ virtual void DoDraw();*/
+ virtual void OnMouseMove(int x, int y, int dx, int dy);
+ virtual void OnMouseDown(int x, int y, unsigned button);
+ virtual void OnMouseUp(int x, int y, unsigned button);
+ //virtual void OnMouseWheel(int x, int y, int d) {}
+ //virtual void OnKeyPress(int key, bool shift, bool ctrl, bool alt) {}
+ //virtual void OnKeyRelease(int key, bool shift, bool ctrl, bool alt) {}
+ virtual void OnTick(float dt);
+ virtual void OnDraw();
+};
+
+#endif // GAMEVIEW_H
diff --git a/src/interface.old/Button.cpp b/src/interface.old/Button.cpp
deleted file mode 100644
index a357c36..0000000
--- a/src/interface.old/Button.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Button.cpp
- *
- * Created on: Jan 8, 2012
- * Author: Simon
- */
-
-#include <iostream>
-
-#include "interface/Button.h"
-#include "Graphics.h"
-
-namespace ui {
-
-Button::Button(int x, int y, int width, int height, const std::string& buttonText):
- Component(x, y, width, height),
- Toggleable(false),
- ButtonText(buttonText),
- isMouseInside(false),
- isButtonDown(false),
- state(false)
-{
-
-}
-
-void Button::Draw(void* userdata)
-{
- Graphics * g = reinterpret_cast<Graphics*>(userdata);
- //TODO: Cache text location, that way we don't have the text alignment code here
- if(isButtonDown)
- {
- g->fillrect(X, Y, Width, Height, 255, 255, 255, 255);
- g->drawtext(X+(Width-Graphics::textwidth((char *)ButtonText.c_str()))/2, Y+(Height-10)/2, ButtonText, 0, 0, 0, 255);
- }
- else
- {
- if(isMouseInside)
- g->fillrect(X, Y, Width, Height, 20, 20, 20, 255);
- g->drawrect(X, Y, Width, Height, 255, 255, 255, 255);
- g->drawtext(X+(Width-Graphics::textwidth((char *)ButtonText.c_str()))/2, Y+(Height-10)/2, ButtonText, 255, 255, 255, 255);
- }
- /*sf::RenderWindow* rw = reinterpret_cast<sf::RenderWindow*>(userdata); //it better be a RenderWindow or so help your god
-
- //Draw component here
- sf::Text textGraphic(ButtonText);
- textGraphic.SetCharacterSize(11);
- if(isButtonDown)
- textGraphic.SetColor(sf::Color::Black);
- else
- textGraphic.SetColor(sf::Color::White);
- sf::FloatRect tempRect = textGraphic.GetRect();
- textGraphic.SetPosition(ceil(X + Width/2 - tempRect.Width/2), ceil(Y + Height/2 - tempRect.Height/2));
-
- if(isMouseInside)
- {
- if(isButtonDown)
- rw->Draw(sf::Shape::Rectangle(X+2, Y+2, Width-4, Width-4, sf::Color::White, 2.f, sf::Color::Black));
- else
- rw->Draw(sf::Shape::Rectangle(X+2, Y+2, Width-4, Width-4, sf::Color::Black, 2.f, sf::Color::White));
- }
- else
- {
- if(isButtonDown)
- rw->Draw(sf::Shape::Rectangle(X+2, Y+2, Width-4, Width-4, sf::Color::White, 2.f, sf::Color::Black));
- else
- rw->Draw(sf::Shape::Rectangle(X+1, Y+1, Width-2, Width-2, sf::Color::Black, 1.f, sf::Color::White));
- }
-
- rw->Draw(textGraphic);*/
-}
-
-void Button::OnMouseUnclick(int x, int y, unsigned int button)
-{
- if(button != 1)
- {
- return; //left click only!
- }
-
- if(isButtonDown)
- {
- if(state)
- {
- state = false;
- }
- else
- {
- if(Toggleable)
- {
- state = true;
- }
- DoAction();
- }
- }
-
- isButtonDown = false;
-}
-
-void Button::OnMouseUp(int x, int y, unsigned int button) //mouse unclick is called before this
-{
- if(button != 1) return; //left click only!
-
- isButtonDown = false;
-}
-
-void Button::OnMouseClick(int x, int y, unsigned int button)
-{
- if(button != 1) return; //left click only!
-
- isButtonDown = true;
-}
-
-void Button::OnMouseEnter(int x, int y, int dx, int dy)
-{
- isMouseInside = true;
-}
-
-void Button::OnMouseLeave(int x, int y, int dx, int dy)
-{
- isMouseInside = false;
-}
-
-void Button::DoAction()
-{
- std::cout << "Do action!"<<std::endl;
-}
-
-} /* namespace ui */
diff --git a/src/interface.old/Component.cpp b/src/interface.old/Component.cpp
deleted file mode 100644
index 48a329b..0000000
--- a/src/interface.old/Component.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Component.cpp
- *
- * Created on: Jan 8, 2012
- * Author: Simon
- */
-
-#include "interface/Component.h"
-
-namespace ui {
-
-Component::Component(int x, int y, int width, int height):
- X(x),
- Y(y),
- Width(width),
- Height(height),
- Enabled(true),
- Visible(true)
-{
-}
-
-Component::~Component()
-{
-}
-
-void Component::Draw(void* userdata)
-{
-}
-
-void Component::Tick(float dt)
-{
-}
-
-void Component::OnKeyPress(int key, bool shift, bool ctrl, bool alt)
-{
-}
-
-void Component::OnKeyRelease(int key, bool shift, bool ctrl, bool alt)
-{
-}
-
-void Component::OnMouseEnter(int localx, int localy, int dx, int dy)
-{
-}
-
-void Component::OnMouseLeave(int localx, int localy, int dx, int dy)
-{
-}
-
-void Component::OnMouseClick(int localx, int localy, unsigned int button)
-{
-}
-
-void Component::OnMouseUnclick(int localx, int localy, unsigned int button)
-{
-}
-
-void Component::OnMouseDown(int localx, int localy, unsigned int button)
-{
-}
-
-void Component::OnMouseHover(int localx, int localy)
-{
-}
-
-void Component::OnMouseMoved(int localx, int localy, int dx, int dy)
-{
-}
-
-void Component::OnMouseMovedInside(int localx, int localy, int dx, int dy)
-{
-}
-
-void Component::OnMouseUp(int localx, int localy, unsigned int button)
-{
-}
-
-void Component::OnMouseWheel(int localx, int localy, int d)
-{
-}
-
-void Component::OnMouseWheelInside(int localx, int localy, int d)
-{
-}
-
-void Component::OnMouseWheelFocused(int localx, int localy, int d)
-{
-}
-} /* namespace ui */
diff --git a/src/interface.old/ControlFactory.cpp b/src/interface.old/ControlFactory.cpp
deleted file mode 100644
index 300ceba..0000000
--- a/src/interface.old/ControlFactory.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "interface/ControlFactory.h"
-#include "interface/Button.h"
-#include "interface/Panel.h"
-#include "interface/Window.h"
-
-ui::Panel * ControlFactory::MainMenu(GameSession * session, int x, int y, int width, int height)
-{
- ui::Panel * mainMenu = new ui::Panel(x, y, width, height);
- //mainMenu->Add(new ui::Button(0, 0, 20, 20, "Turd"));
- return mainMenu;
-}
diff --git a/src/interface.old/Panel.cpp b/src/interface.old/Panel.cpp
deleted file mode 100644
index 164bfa3..0000000
--- a/src/interface.old/Panel.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Panel.cpp
- *
- * Created on: Jan 8, 2012
- * Author: Simon
- */
-
-#include "interface/Panel.h"
-
-namespace ui {
-
-Panel::Panel(int x, int y, int width, int height):
- Component(x, y, width, height)
-{
- // TODO Auto-generated constructor stub
-
-}
-
-Panel::~Panel() {
- // TODO Auto-generated destructor stub
-}
-
-} /* namespace ui */
diff --git a/src/interface.old/Sandbox.cpp b/src/interface.old/Sandbox.cpp
deleted file mode 100644
index 5e29bae..0000000
--- a/src/interface.old/Sandbox.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Sandbox.cpp
- *
- * Created on: Jan 8, 2012
- * Author: Simon
- */
-
-#include <iostream>
-
-#include "Config.h"
-
-#include "interface/Sandbox.h"
-#include "interface/Component.h"
-#include "Renderer.h"
-#include "Simulation.h"
-
-namespace ui {
-
-Sandbox::Sandbox():
- Component(0, 0, XRES, YRES),
- ren(NULL),
- isMouseDown(false),
- activeElement(1)
-{
- sim = new Simulation();
-}
-
-Simulation * Sandbox::GetSimulation()
-{
- return sim;
-}
-
-void Sandbox::OnMouseMovedInside(int localx, int localy, int dx, int dy)
-{
- if(isMouseDown)
- {
- sim->create_line(lastCoordX, lastCoordY, localx, localy, 2, 2, activeElement, 0);
- lastCoordX = localx;
- lastCoordY = localy;
- }
-}
-
-void Sandbox::OnMouseDown(int localx, int localy, unsigned int button)
-{
- sim->create_line(localx, localy, localx, localy, 2, 2, activeElement, 0);
- lastCoordX = localx;
- lastCoordY = localy;
- isMouseDown = true;
-}
-
-void Sandbox::OnMouseUp(int localx, int localy, unsigned int button)
-{
- sim->create_line(lastCoordX, lastCoordY, localx, localy, 2, 2, activeElement, 0);
- lastCoordX = localx;
- lastCoordY = localy;
- isMouseDown = false;
-}
-
-void Sandbox::Draw(void* userdata)
-{
- Graphics * g = reinterpret_cast<Graphics*>(userdata);
- if(!ren)
- ren = new Renderer(g, sim);
- ren->render_parts();
-}
-
-void Sandbox::Tick(float delta)
-{
- sim->update_particles();
-}
-
-Sandbox::~Sandbox() {
- // TODO Auto-generated destructor stub
-}
-
-} /* namespace ui */
diff --git a/src/interface.old/State.cpp b/src/interface.old/State.cpp
deleted file mode 100644
index 2828751..0000000
--- a/src/interface.old/State.cpp
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * State.cpp
- *
- * Created on: Jan 8, 2012
- * Author: Simon
- */
-
-#include <vector>
-#include <iostream>
-#include <cstring>
-
-#include "interface/State.h"
-
-namespace ui {
-
-State::State(int w, int h):
- mouseX(0),
- mouseY(0),
- mouseXP(0),
- mouseYP(0),
- width(w),
- height(h),
- Components()
-{
-}
-
-State::~State()
-{
- //Components.~vector(); // just in case // devnote : Nope.jpg Nate :3 -frankbro
-}
-
-void State::Add(Component* child)
-{
- Components.push_back(child);
- child->Parent = this;
-}
-
-void State::Remove(Component* child)
-{
- for(int i = 0; i < Components.size(); i++)
- if(Components[i] == child)
- {
- Components.erase(Components.begin() + i);
- break;
- }
-}
-
-void State::Draw(void* userdata)
-{
- //draw
- for(int i = 0; i < Components.size(); i++)
- {
- if(Components[i]->Visible)
- {
- if(AllowExclusiveDrawing)
- {
- Components[i]->Draw(userdata);
- }
- else if(
- Components[i]->X + Components[i]->Width >= 0 &&
- Components[i]->Y + Components[i]->Height >= 0 &&
- Components[i]->X < width &&
- Components[i]->Y < height )
- {
- Components[i]->Draw(userdata);
- }
- }
- }
-}
-
-void State::Tick(float dt)
-{
- //on mouse hover
- for(int i = 0; i < Components.size(); i++)
- if( mouseX >= Components[i]->X &&
- mouseY >= Components[i]->Y &&
- mouseX < Components[i]->X + Components[i]->Width &&
- mouseY < Components[i]->Y + Components[i]->Height )
- {
- if(Components[i]->Enabled)
- {
- Components[i]->OnMouseHover(mouseX, mouseY);
- }
- break;
- }
-
- //tick
- for(int i = 0; i < Components.size(); i++)
- Components[i]->Tick(dt);
-}
-
-void State::OnKeyPress(int key, bool shift, bool ctrl, bool alt)
-{
- //on key press
- if(focusedComponent_ != NULL)
- if(focusedComponent_->Enabled)
- focusedComponent_->OnKeyPress(key, shift, ctrl, alt);
-}
-
-void State::OnKeyRelease(int key, bool shift, bool ctrl, bool alt)
-{
- //on key unpress
- if(focusedComponent_ != NULL)
- if(focusedComponent_->Enabled)
- focusedComponent_->OnKeyRelease(key, shift, ctrl, alt);
-}
-
-void State::OnMouseDown(int x, int y, unsigned int button)
-{
- //on mouse click
- for(int i = Components.size() - 1; i > -1 ; i--)
- if(Components[i]->Enabled)
- if(x >= Components[i]->X && y >= Components[i]->Y && x < Components[i]->X + Components[i]->Width && y < Components[i]->Y + Components[i]->Height)
- {
- Components[i]->OnMouseClick(x - Components[i]->X, y - Components[i]->Y, button);
- this->focusedComponent_ = Components[i]; //set this component as the focused component
- break;
- }
-
- //on mouse down
- for(int i = Components.size() - 1; i > -1 ; i--)
- if(Components[i]->Enabled)
- Components[i]->OnMouseDown(x - Components[i]->X, y - Components[i]->Y, button);
-}
-
-void State::OnMouseMove(int x, int y)
-{
- //update mouse coords
- mouseX = x;
- mouseY = y;
-
- //on mouse move (if true, and inside)
- for(int i = Components.size() - 1; i > -1 ; i--)
- if(Components[i]->Enabled)
- {
- int localX = x - Components[i]->X;
- int localY = y - Components[i]->Y;
- int localXP = mouseXP - Components[i]->X;
- int localYP = mouseYP - Components[i]->Y;
- int dx = x - mouseXP;
- int dy = x - mouseYP;
-
- Components[i]->OnMouseMoved(localX, localY, dx, dy);
-
- //is the mouse inside
- if(localX >= 0 &&
- localY >= 0 &&
- localX < Components[i]->Width &&
- localY < Components[i]->Height )
- {
- //was the mouse outside last tick?
- if(localXP < 0 ||
- localXP >= Components[i]->Width ||
- localYP < 0 ||
- localYP >= Components[i]->Height )
- {
- Components[i]->OnMouseEnter(localX, localY, dx, dy);
- }
-
- Components[i]->OnMouseMovedInside(localX, localY, dx, dy);
-
- break; //found the top-most component under mouse, break that shit
- }
- //not inside, let's see if it used to be inside last tick
- else if (localXP >= 0 &&
- localYP >= 0 &&
- localXP < Components[i]->Width &&
- localYP < Components[i]->Height )
- {
- Components[i]->OnMouseLeave(localX, localY, x - mouseXP, y - mouseYP);
- }
- }
- else //is locked
- {
- int localX = x - Components[i]->X;
- int localY = y - Components[i]->Y;
-
- //is the mouse inside
- if(localX >= 0 &&
- localY >= 0 &&
- localX < Components[i]->Width &&
- localY < Components[i]->Height )
- {
- break; //it's the top-most component under the mouse, we don't want to go under it.
- }
- }
- // end of for loop here
-
- //set the previous mouse coords
- mouseXP = x;
- mouseYP = y;
-}
-
-void State::OnMouseUp(int x, int y, unsigned int button)
-{
- //on mouse unclick
- for(int i = Components.size() - 1; i > -1 ; i--)
- if(Components[i]->Enabled)
- if(x >= Components[i]->X && y >= Components[i]->Y && x < Components[i]->X + Components[i]->Width && y < Components[i]->Y + Components[i]->Height)
- {
- Components[i]->OnMouseUnclick(x - Components[i]->X, y - Components[i]->Y, button);
- break;
- }
-
- //on mouse up
- for(int i = Components.size() - 1; i > -1 ; i--)
- if(Components[i]->Enabled)
- Components[i]->OnMouseUp(x - Components[i]->X, y - Components[i]->Y, button);
-}
-
-void State::OnMouseWheel(int x, int y, int d)
-{
- //focused mouse wheel
- if(focusedComponent_ != NULL)
- focusedComponent_->OnMouseWheelFocused(x - focusedComponent_->X, y - focusedComponent_->Y, d);
-
- //mouse wheel inside
- for(int i = Components.size() - 1; i > -1 ; i--)
- if(x >= Components[i]->X && y >= Components[i]->Y && x < Components[i]->X + Components[i]->Width && y < Components[i]->Y + Components[i]->Height)
- {
- if(Components[i]->Enabled)
- Components[i]->OnMouseWheelInside(x - Components[i]->X, y - Components[i]->Y, d);
- break; //found top-most component under mouse
- }
-
- //on mouse wheel
- for(int i = Components.size() - 1; i > -1 ; i--)
- if(Components[i]->Enabled)
- Components[i]->OnMouseWheel(x - Components[i]->X, y - Components[i]->Y, d);
-}
-
-
-} /* namespace ui */
diff --git a/src/interface.old/Window.cpp b/src/interface.old/Window.cpp
deleted file mode 100644
index 624bf9a..0000000
--- a/src/interface.old/Window.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Window.cpp
- *
- * Created on: Jan 8, 2012
- * Author: Simon
- */
-
-#include "interface/Window.h"
-
-namespace ui {
-
-Window::Window():
- State(width, height)
-{
- // TODO Auto-generated constructor stub
-
-}
-
-Window::~Window() {
- // TODO Auto-generated destructor stub
-}
-
-} /* namespace ui */
diff --git a/src/interface/Button.cpp b/src/interface/Button.cpp
index 6ea9854..a3f76b9 100644
--- a/src/interface/Button.cpp
+++ b/src/interface/Button.cpp
@@ -10,15 +10,17 @@
#include "interface/Button.h"
#include "Graphics.h"
#include "Global.h"
+#include "Engine.h"
namespace ui {
-Button::Button(State* parent_state, std::string buttonText):
+Button::Button(Window* parent_state, std::string buttonText):
Component(parent_state),
ButtonText(buttonText),
isMouseInside(false),
isButtonDown(false),
- isTogglable(false)
+ isTogglable(false),
+ actionCallback(NULL)
{
}
@@ -28,7 +30,8 @@ Button::Button(Point position, Point size, std::string buttonText):
ButtonText(buttonText),
isMouseInside(false),
isButtonDown(false),
- isTogglable(false)
+ isTogglable(false),
+ actionCallback(NULL)
{
}
@@ -38,7 +41,8 @@ Button::Button(std::string buttonText):
ButtonText(buttonText),
isMouseInside(false),
isButtonDown(false),
- isTogglable(false)
+ isTogglable(false),
+ actionCallback(NULL)
{
}
@@ -68,13 +72,13 @@ inline void Button::SetToggleState(bool state)
void Button::Draw(const Point& screenPos)
{
- Graphics * g = Global::Ref().g;
+ Graphics * g = ui::Engine::Ref().g;
Point Position = screenPos;
// = reinterpret_cast<Graphics*>(userdata);
//TODO: Cache text location, that way we don't have the text alignment code here
if(isButtonDown || (isTogglable && toggle))
{
- g->fillrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255);
+ g->fillrect(Position.X-1, Position.Y-1, Size.X+2, Size.Y+2, 255, 255, 255, 255);
g->drawtext(Position.X+(Size.X-Graphics::textwidth((char *)ButtonText.c_str()))/2, Position.Y+(Size.Y-10)/2, ButtonText, 0, 0, 0, 255);
}
else
@@ -116,7 +120,6 @@ void Button::Draw(const Point& screenPos)
void Button::OnMouseUnclick(int x, int y, unsigned int button)
{
- std::cout << "Unclick!" << std::endl;
if(button != 1)
{
return; //left click only!
@@ -160,6 +163,15 @@ void Button::OnMouseLeave(int x, int y)
void Button::DoAction()
{
std::cout << "Do action!"<<std::endl;
+ //if(actionCallback)
+ // (*(actionCallback))();
+ if(actionCallback)
+ actionCallback->ActionCallback(this);
+}
+
+void Button::SetActionCallback(ButtonAction * action)
+{
+ actionCallback = action;
}
Button::~Button()
diff --git a/src/interface/Button.h b/src/interface/Button.h
new file mode 100644
index 0000000..5f2d71f
--- /dev/null
+++ b/src/interface/Button.h
@@ -0,0 +1,60 @@
+/*
+ * Button.h
+ *
+ * Created on: Jan 8, 2012
+ * Author: Simon
+ */
+
+#ifndef BUTTON_H_
+#define BUTTON_H_
+
+#include <string>
+
+#include "Component.h"
+
+namespace ui
+{
+class Button;
+class ButtonAction
+{
+public:
+ virtual void ActionCallback(ui::Button * sender) {}
+};
+
+class Button : public Component
+{
+public:
+ Button(Window* parent_state, std::string buttonText);
+
+ Button(Point position, Point size, std::string buttonText);
+
+ Button(std::string buttonText);
+ virtual ~Button();
+
+ bool Toggleable;
+
+ std::string ButtonText;
+
+ virtual void OnMouseClick(int x, int y, unsigned int button);
+ virtual void OnMouseUnclick(int x, int y, unsigned int button);
+ //virtual void OnMouseUp(int x, int y, unsigned int button);
+
+ virtual void OnMouseEnter(int x, int y);
+ virtual void OnMouseLeave(int x, int y);
+
+ virtual void Draw(const Point& screenPos);
+
+ inline bool GetState() { return state; }
+ virtual void DoAction(); //action of button what ever it may be
+ void SetTogglable(bool isTogglable);
+ bool GetTogglable();
+ inline bool GetToggleState();
+ inline void SetToggleState(bool state);
+ void SetActionCallback(ButtonAction * action);
+
+protected:
+ bool isButtonDown, state, isMouseInside, isTogglable, toggle;
+ ButtonAction * actionCallback;
+};
+}
+#endif /* BUTTON_H_ */
diff --git a/src/interface/Component.cpp b/src/interface/Component.cpp
index 49ff7f8..75e9c40 100644
--- a/src/interface/Component.cpp
+++ b/src/interface/Component.cpp
@@ -2,12 +2,12 @@
#include "interface/Component.h"
#include "interface/Engine.h"
#include "interface/Point.h"
-#include "interface/State.h"
+#include "interface/Window.h"
#include "interface/Panel.h"
using namespace ui;
-Component::Component(State* parent_state):
+Component::Component(Window* parent_state):
parentstate_(parent_state),
_parent(NULL),
Position(Point(0,0)),
@@ -45,9 +45,9 @@ bool Component::IsFocused() const
return parentstate_->IsFocused(this);
}
-void Component::SetParentState(State* state)
+void Component::SetParentWindow(Window* window)
{
- parentstate_ = state;
+ parentstate_ = window;
}
void Component::SetParent(Panel* new_parent)
@@ -65,7 +65,7 @@ void Component::SetParent(Panel* new_parent)
_parent->RemoveChild(i, false);
// add ourself to the parent state
- GetParentState()->AddComponent(this);
+ GetParentWindow()->AddComponent(this);
//done in this loop.
break;
@@ -76,8 +76,8 @@ void Component::SetParent(Panel* new_parent)
else
{
// remove from parent state (if in parent state) and place in new parent
- if(GetParentState())
- GetParentState()->RemoveComponent(this);
+ if(GetParentWindow())
+ GetParentWindow()->RemoveComponent(this);
new_parent->children.push_back(this);
}
this->_parent = new_parent;
diff --git a/includes/interface/Component.h b/src/interface/Component.h
index 5759c08..578aba6 100644
--- a/includes/interface/Component.h
+++ b/src/interface/Component.h
@@ -1,12 +1,12 @@
#pragma once
#include "Point.h"
-#include "State.h"
+#include "Window.h"
#include "Platform.h"
namespace ui
{
- class State;
+ class Window;
class Panel;
/* class Component
@@ -17,13 +17,13 @@ namespace ui
class Component
{
public:
- Component(State* parent_state);
+ Component(Window* parent_state);
Component(Point position, Point size);
Component();
virtual ~Component();
void* UserData;
- inline State* const GetParentState() const { return parentstate_; }
+ inline Window* const GetParentWindow() const { return parentstate_; }
bool IsFocused() const;
Point Position;
@@ -34,7 +34,7 @@ namespace ui
/* See the parent of this component.
* If new_parent is NULL, this component will have no parent. (THIS DOES NOT delete THE COMPONENT. See XComponent::RemoveChild)
*/
- void SetParentState(State* state);
+ void SetParentWindow(Window* window);
void SetParent(Panel* new_parent);
//Get the parent component.
@@ -198,7 +198,7 @@ namespace ui
virtual void OnKeyRelease(int key, bool shift, bool ctrl, bool alt);
private:
- State* parentstate_;
+ Window* parentstate_;
Panel* _parent;
};
}
diff --git a/src/interface/ControlFactory.cpp b/src/interface/ControlFactory.cpp
index 372ed31..7132499 100644
--- a/src/interface/ControlFactory.cpp
+++ b/src/interface/ControlFactory.cpp
@@ -50,10 +50,5 @@ ui::Panel * ControlFactory::MainMenu(int x, int y, int width, int height)
mainMenu->AddChild(tempButton); //Render options
currentX += 18;
- tempButton = new ui::Button(ui::Point(currentX, 1), ui::Point(16, height-2), "\x90"); //Pause
- tempButton->SetTogglable(true);
- mainMenu->AddChild(tempButton);
- currentX += 18;
-
return mainMenu;
}
diff --git a/includes/interface/ControlFactory.h b/src/interface/ControlFactory.h
index 0f8ad61..0f8ad61 100644
--- a/includes/interface/ControlFactory.h
+++ b/src/interface/ControlFactory.h
diff --git a/src/interface/Engine.cpp b/src/interface/Engine.cpp
index 25f2038..55a2370 100644
--- a/src/interface/Engine.cpp
+++ b/src/interface/Engine.cpp
@@ -1,22 +1,25 @@
#include <iostream>
#include "Config.h"
+#include <stack>
+
#include "Global.h"
+#include "interface/Window.h"
#include "interface/Platform.h"
#include "interface/Engine.h"
-#include "interface/State.h"
#include "Graphics.h"
using namespace ui;
+using namespace std;
Engine::Engine():
state_(NULL),
- statequeued_(NULL),
mousex_(0),
mousey_(0),
mousexp_(0),
mouseyp_(0),
- FpsLimit(60.0f)
+ FpsLimit(60.0f),
+ windows(stack<Window*>())
{
}
@@ -40,7 +43,30 @@ void Engine::Exit()
running_ = false;
}
-void Engine::SetState(State * state)
+void Engine::ShowWindow(Window * window)
+{
+ if(state_)
+ {
+ windows.push(window);
+ }
+ state_ = window;
+ windows.push(window);
+}
+
+void Engine::CloseWindow()
+{
+ if(!windows.empty())
+ {
+ state_ = windows.top();
+ windows.pop();
+ }
+ else
+ {
+ state_ = NULL;
+ }
+}
+
+/*void Engine::SetState(State * state)
{
if(state_) //queue if currently in a state
statequeued_ = state;
@@ -50,7 +76,7 @@ void Engine::SetState(State * state)
if(state_)
state_->DoInitialized();
}
-}
+}*/
void Engine::SetSize(int width, int height)
{
@@ -63,7 +89,7 @@ void Engine::Tick(float dt)
if(state_ != NULL)
state_->DoTick(dt);
- if(statequeued_ != NULL)
+ /*if(statequeued_ != NULL)
{
if(state_ != NULL)
{
@@ -76,15 +102,15 @@ void Engine::Tick(float dt)
if(state_ != NULL)
state_->DoInitialized();
- }
+ }*/
}
void Engine::Draw()
{
if(state_)
state_->DoDraw();
- Global::Ref().g->Blit();
- Global::Ref().g->Clear();
+ g->Blit();
+ g->Clear();
}
void Engine::onKeyPress(int key, bool shift, bool ctrl, bool alt)
diff --git a/includes/interface/Engine.h b/src/interface/Engine.h
index 6136fb4..7bf78f9 100644
--- a/includes/interface/Engine.h
+++ b/src/interface/Engine.h
@@ -1,14 +1,15 @@
#pragma once
+#include <stack>
#include <SDL/SDL.h>
#include "Singleton.h"
#include "Platform.h"
-#include "State.h"
#include "Graphics.h"
+#include "Window.h"
namespace ui
{
- class State;
+ class Window;
/* class Engine
*
@@ -21,6 +22,9 @@ namespace ui
Engine();
~Engine();
+ void ShowWindow(Window * window);
+ void CloseWindow();
+
void onMouseMove(int x, int y);
void onMouseClick(int x, int y, unsigned button);
void onMouseUnclick(int x, int y, unsigned button);
@@ -44,12 +48,15 @@ namespace ui
inline void SetSize(int width, int height);
- void SetState(State* state);
- inline State* GetState() { return state_; }
+ //void SetState(Window* state);
+ //inline State* GetState() { return state_; }
+ inline Window* GetWindow() { return state_; }
float FpsLimit;
+ Graphics * g;
private:
- State* statequeued_;
- State* state_;
+ std::stack<Window*> windows;
+ //Window* statequeued_;
+ Window* state_;
bool running_;
diff --git a/src/interface/Label.cpp b/src/interface/Label.cpp
index c77b6bf..cf09d4e 100644
--- a/src/interface/Label.cpp
+++ b/src/interface/Label.cpp
@@ -6,7 +6,7 @@
using namespace ui;
-Label::Label(State* parent_state, std::string labelText):
+Label::Label(Window* parent_state, std::string labelText):
Component(parent_state),
LabelText(labelText)
{
@@ -35,6 +35,6 @@ Label::~Label()
void Label::Draw(const Point& screenPos)
{
- Graphics * g = Global::Ref().g;
+ Graphics * g = Engine::Ref().g;
g->drawtext(Position.X+(Size.X-Graphics::textwidth((char *)LabelText.c_str()))/2, Position.Y+(Size.Y-10)/2, LabelText, 255, 255, 255, 255);
}
diff --git a/includes/interface/Label.h b/src/interface/Label.h
index 2168956..e56852e 100644
--- a/includes/interface/Label.h
+++ b/src/interface/Label.h
@@ -10,7 +10,7 @@ namespace ui
class Label : public Component
{
public:
- Label(State* parent_state, std::string labelText);
+ Label(Window* parent_state, std::string labelText);
Label(Point position, Point size, std::string labelText);
diff --git a/src/interface/Panel.cpp b/src/interface/Panel.cpp
index e44663a..acfcf53 100644
--- a/src/interface/Panel.cpp
+++ b/src/interface/Panel.cpp
@@ -5,12 +5,12 @@
#include "interface/Panel.h"
#include "interface/Point.h"
-#include "interface/State.h"
+#include "interface/Window.h"
#include "interface/Component.h"
using namespace ui;
-Panel::Panel(State* parent_state):
+Panel::Panel(Window* parent_state):
Component(parent_state)
{
@@ -84,7 +84,7 @@ void Panel::Draw(const Point& screenPos)
// the component must be visible
if(children[i]->Visible)
{
- if(GetParentState()->AllowExclusiveDrawing)
+ if(GetParentWindow()->AllowExclusiveDrawing)
{
//who cares if the component is off the screen? draw anyway.
Point scrpos = screenPos + children[i]->Position;
@@ -143,7 +143,7 @@ void Panel::OnMouseClick(int localx, int localy, unsigned button)
localy < children[i]->Position.Y + children[i]->Size.Y )
{
childclicked = true;
- GetParentState()->FocusComponent(children[i]);
+ GetParentWindow()->FocusComponent(children[i]);
children[i]->OnMouseClick(localx - children[i]->Position.X, localy - children[i]->Position.Y, button);
break;
}
@@ -154,7 +154,7 @@ void Panel::OnMouseClick(int localx, int localy, unsigned button)
if(!childclicked)
{
XOnMouseClick(localx, localy, button);
- GetParentState()->FocusComponent(this);
+ GetParentWindow()->FocusComponent(this);
}
}
diff --git a/includes/interface/Panel.h b/src/interface/Panel.h
index 7c9adab..51f52aa 100644
--- a/includes/interface/Panel.h
+++ b/src/interface/Panel.h
@@ -3,7 +3,7 @@
//#include "Platform.h"
#include "interface/Point.h"
-#include "interface/State.h"
+#include "interface/Window.h"
#include "interface/Component.h"
namespace ui
@@ -21,7 +21,7 @@ class Component;
public:
friend class Component;
- Panel(State* parent_state);
+ Panel(Window* parent_state);
Panel(Point position, Point size);
Panel();
virtual ~Panel();
diff --git a/includes/interface/Platform.h b/src/interface/Platform.h
index c57dca6..c57dca6 100644
--- a/includes/interface/Platform.h
+++ b/src/interface/Platform.h
diff --git a/includes/interface/Point.h b/src/interface/Point.h
index 0d0250c..0d0250c 100644
--- a/includes/interface/Point.h
+++ b/src/interface/Point.h
diff --git a/src/interface/Sandbox.cpp b/src/interface/Sandbox.cpp
index a9760e7..9a858f8 100644
--- a/src/interface/Sandbox.cpp
+++ b/src/interface/Sandbox.cpp
@@ -16,6 +16,7 @@
#include "interface/Component.h"
#include "Renderer.h"
#include "Simulation.h"
+#include "Engine.h"
namespace ui {
@@ -60,7 +61,7 @@ void Sandbox::OnMouseUp(int localx, int localy, unsigned int button)
void Sandbox::Draw(const Point& screenPos)
{
- Graphics * g = Global::Ref().g;
+ Graphics * g = Engine::Ref().g;
if(!ren)
ren = new Renderer(g, sim);
ren->render_parts();
diff --git a/includes/interface/Sandbox.h b/src/interface/Sandbox.h
index fb4a668..fb4a668 100644
--- a/includes/interface/Sandbox.h
+++ b/src/interface/Sandbox.h
diff --git a/src/interface/State.cpp b/src/interface/Window.cpp
index 665e2e8..e28d34b 100644
--- a/src/interface/State.cpp
+++ b/src/interface/Window.cpp
@@ -1,30 +1,29 @@
-#include <vector>
-#include "interface/Component.h"
-#include "interface/Engine.h"
-#include "interface/State.h"
-//#include "Platform.h"
+#include "Window.h"
+#include "Component.h"
+#include "interface/Point.h"
using namespace ui;
-State::State()
-: UserData(NULL)
-, focusedComponent_(NULL)
+Window::Window(Point _position, Point _size):
+ Position(_position),
+ Size(_size),
+ focusedComponent_(NULL)
{
}
-State::~State()
+Window::~Window()
{
for(unsigned i = 0, sz = Components.size(); i < sz; ++i)
if( Components[i] )
delete Components[i];
}
-void State::AddComponent(Component* c)
+void Window::AddComponent(Component* c)
{
// TODO: do a check if component was already added?
- if(c->GetParentState()==NULL)
+ if(c->GetParentWindow()==NULL)
{
- c->SetParentState(this);
+ c->SetParentWindow(this);
Components.push_back(c);
}
else
@@ -33,17 +32,17 @@ void State::AddComponent(Component* c)
}
}
-unsigned State::GetComponentCount()
+unsigned Window::GetComponentCount()
{
return Components.size();
}
-Component* State::GetComponent(unsigned idx)
+Component* Window::GetComponent(unsigned idx)
{
return Components[idx];
}
-void State::RemoveComponent(Component* c)
+void Window::RemoveComponent(Component* c)
{
// remove component WITHOUT freeing it.
for(unsigned i = 0; i < Components.size(); ++i)
@@ -52,43 +51,43 @@ void State::RemoveComponent(Component* c)
if(Components[i] == c)
{
Components.erase(Components.begin() + i);
-
+
// we're done
return;
}
}
}
-void State::RemoveComponent(unsigned idx)
+void Window::RemoveComponent(unsigned idx)
{
// free component and remove it.
delete Components[idx];
Components.erase(Components.begin() + idx);
}
-bool State::IsFocused(const Component* c) const
+bool Window::IsFocused(const Component* c) const
{
return c == focusedComponent_;
}
-void State::FocusComponent(Component* c)
+void Window::FocusComponent(Component* c)
{
this->focusedComponent_ = c;
}
-void State::DoExit()
+void Window::DoExit()
{
OnExit();
}
-void State::DoInitialized()
+void Window::DoInitialized()
{
OnInitialized();
}
-void State::DoDraw()
+void Window::DoDraw()
{
//draw
for(int i = 0, sz = Components.size(); i < sz; ++i)
@@ -101,12 +100,12 @@ void State::DoDraw()
}
else
{
- if( Components[i]->Position.X + Components[i]->Size.X >= 0 &&
- Components[i]->Position.Y + Components[i]->Size.Y >= 0 &&
- Components[i]->Position.X < ui::Engine::Ref().GetWidth() &&
- Components[i]->Position.Y < ui::Engine::Ref().GetHeight() )
+ if( Components[i]->Position.X+Position.X + Components[i]->Size.X >= 0 &&
+ Components[i]->Position.Y+Position.Y + Components[i]->Size.Y >= 0 &&
+ Components[i]->Position.X+Position.X < ui::Engine::Ref().GetWidth() &&
+ Components[i]->Position.Y+Position.Y < ui::Engine::Ref().GetHeight() )
{
- Point scrpos(Components[i]->Position.X, Components[i]->Position.Y);
+ Point scrpos(Components[i]->Position.X + Position.X, Components[i]->Position.Y + Position.Y);
Components[i]->Draw( Point(scrpos) );
}
}
@@ -115,22 +114,22 @@ void State::DoDraw()
OnDraw();
}
-void State::DoTick(float dt)
+void Window::DoTick(float dt)
{
//on mouse hover
for(int i = Components.size() - 1; i >= 0; --i)
{
if(!Components[i]->Locked &&
- ui::Engine::Ref().GetMouseX() >= Components[i]->Position.X &&
- ui::Engine::Ref().GetMouseY() >= Components[i]->Position.Y &&
- ui::Engine::Ref().GetMouseX() < Components[i]->Position.X + Components[i]->Size.X &&
- ui::Engine::Ref().GetMouseY() < Components[i]->Position.Y + Components[i]->Size.Y )
+ ui::Engine::Ref().GetMouseX() >= Components[i]->Position.X+Position.X &&
+ ui::Engine::Ref().GetMouseY() >= Components[i]->Position.Y+Position.Y &&
+ ui::Engine::Ref().GetMouseX() < Components[i]->Position.X+Position.X + Components[i]->Size.X &&
+ ui::Engine::Ref().GetMouseY() < Components[i]->Position.Y+Position.Y + Components[i]->Size.Y )
{
- Components[i]->OnMouseHover(ui::Engine::Ref().GetMouseX() - Components[i]->Position.X, ui::Engine::Ref().GetMouseY() - Components[i]->Position.Y);
+ Components[i]->OnMouseHover(ui::Engine::Ref().GetMouseX() - (Components[i]->Position.X + Position.X), ui::Engine::Ref().GetMouseY() - (Components[i]->Position.Y + Position.Y));
break;
}
}
-
+
//tick
for(int i = 0, sz = Components.size(); i < sz; ++i)
{
@@ -140,7 +139,7 @@ void State::DoTick(float dt)
OnTick(dt);
}
-void State::DoKeyPress(int key, bool shift, bool ctrl, bool alt)
+void Window::DoKeyPress(int key, bool shift, bool ctrl, bool alt)
{
//on key press
if(focusedComponent_ != NULL)
@@ -152,7 +151,7 @@ void State::DoKeyPress(int key, bool shift, bool ctrl, bool alt)
OnKeyPress(key, shift, ctrl, alt);
}
-void State::DoKeyRelease(int key, bool shift, bool ctrl, bool alt)
+void Window::DoKeyRelease(int key, bool shift, bool ctrl, bool alt)
{
//on key unpress
if(focusedComponent_ != NULL)
@@ -164,7 +163,7 @@ void State::DoKeyRelease(int key, bool shift, bool ctrl, bool alt)
OnKeyRelease(key, shift, ctrl, alt);
}
-void State::DoMouseDown(int x, int y, unsigned button)
+void Window::DoMouseDown(int x, int y, unsigned button)
{
//on mouse click
bool clickState = false;
@@ -195,7 +194,7 @@ void State::DoMouseDown(int x, int y, unsigned button)
OnMouseDown(x, y, button);
}
-void State::DoMouseMove(int x, int y, int dx, int dy)
+void Window::DoMouseMove(int x, int y, int dx, int dy)
{
//on mouse move (if true, and inside)
for(int i = Components.size() - 1; i > -1 ; --i)
@@ -204,16 +203,16 @@ void State::DoMouseMove(int x, int y, int dx, int dy)
{
Point local (x - Components[i]->Position.X, y - Components[i]->Position.Y)
, a (local.X - dx, local.Y - dy);
-
+
Components[i]->OnMouseMoved(local.X, local.Y, dx, dy);
-
+
if(local.X >= 0 &&
local.Y >= 0 &&
local.X < Components[i]->Size.X &&
local.Y < Components[i]->Size.Y )
{
Components[i]->OnMouseMovedInside(local.X, local.Y, dx, dy);
-
+
// entering?
if(!(
a.X >= 0 &&
@@ -234,7 +233,7 @@ void State::DoMouseMove(int x, int y, int dx, int dy)
{
Components[i]->OnMouseLeave(local.X, local.Y);
}
-
+
}
}
}
@@ -242,7 +241,7 @@ void State::DoMouseMove(int x, int y, int dx, int dy)
OnMouseMove(x, y, dx, dy);
}
-void State::DoMouseUp(int x, int y, unsigned button)
+void Window::DoMouseUp(int x, int y, unsigned button)
{
//on mouse unclick
for(int i = Components.size() - 1; i >= 0 ; --i)
@@ -267,7 +266,7 @@ void State::DoMouseUp(int x, int y, unsigned button)
OnMouseUp(x, y, button);
}
-void State::DoMouseWheel(int x, int y, int d)
+void Window::DoMouseWheel(int x, int y, int d)
{
//on mouse wheel focused
for(int i = Components.size() - 1; i >= 0 ; --i)
@@ -279,7 +278,7 @@ void State::DoMouseWheel(int x, int y, int d)
break;
}
}
-
+
//on mouse wheel
for(int i = Components.size() - 1; i >= 0 ; --i)
{
@@ -289,3 +288,4 @@ void State::DoMouseWheel(int x, int y, int d)
OnMouseWheel(x, y, d);
}
+
diff --git a/includes/interface/State.h b/src/interface/Window.h
index 75e969d..581b91f 100644
--- a/includes/interface/State.h
+++ b/src/interface/Window.h
@@ -1,54 +1,59 @@
-#pragma once
+#ifndef WINDOW_H
+#define WINDOW_H
#include <vector>
-
+#include "interface/Point.h"
#include "Engine.h"
-#include "Component.h"
-#include "Platform.h"
namespace ui
{
+
+enum ChromeStyle
+{
+ None, Title, Resizable
+};
+//class State;
class Engine;
class Component;
-
+
/* class State
- *
+ *
* A UI state. Contains all components.
*/
- class State
+ class Window
{
public:
- State();
- virtual ~State();
+ Window(Point _position, Point _size);
+ virtual ~Window();
bool AllowExclusiveDrawing; //false will not call draw on objects outside of bounds
// Add Component to state
void AddComponent(Component* c);
-
+
// Get the number of components this state has.
unsigned GetComponentCount();
-
+
// Get component by index. (See GetComponentCount())
Component* GetComponent(unsigned idx);
-
+
// Remove a component from state. NOTE: This DOES NOT free component from memory.
void RemoveComponent(Component* c);
-
+
// Remove a component from state. NOTE: This WILL free component from memory.
void RemoveComponent(unsigned idx);
-
- void DoInitialized();
- void DoExit();
- void DoTick(float dt);
- void DoDraw();
-
- void DoMouseMove(int x, int y, int dx, int dy);
- void DoMouseDown(int x, int y, unsigned button);
- void DoMouseUp(int x, int y, unsigned button);
- void DoMouseWheel(int x, int y, int d);
- void DoKeyPress(int key, bool shift, bool ctrl, bool alt);
- void DoKeyRelease(int key, bool shift, bool ctrl, bool alt);
+
+ virtual void DoInitialized();
+ virtual void DoExit();
+ virtual void DoTick(float dt);
+ virtual void DoDraw();
+
+ virtual void DoMouseMove(int x, int y, int dx, int dy);
+ virtual void DoMouseDown(int x, int y, unsigned button);
+ virtual void DoMouseUp(int x, int y, unsigned button);
+ virtual void DoMouseWheel(int x, int y, int d);
+ virtual void DoKeyPress(int key, bool shift, bool ctrl, bool alt);
+ virtual void DoKeyRelease(int key, bool shift, bool ctrl, bool alt);
bool IsFocused(const Component* c) const;
void FocusComponent(Component* c);
@@ -67,11 +72,32 @@ namespace ui
virtual void OnMouseWheel(int x, int y, int d) {}
virtual void OnKeyPress(int key, bool shift, bool ctrl, bool alt) {}
virtual void OnKeyRelease(int key, bool shift, bool ctrl, bool alt) {}
-
- private:
std::vector<Component*> Components;
Component* focusedComponent_;
+ Point Position;
+ Point Size;
+ ChromeStyle chrome;
+
};
+
+/*class Window : public State
+{
+private:
+ ChromeStyle chrome;
+public:
+ Window(Point _position, Point _size);
+ Point Position;
+ Point Size;
+
+ virtual void DoTick(float dt);
+ virtual void DoDraw();
+
+ virtual void DoMouseMove(int x, int y, int dx, int dy);
+ virtual void DoMouseDown(int x, int y, unsigned button);
+ virtual void DoMouseUp(int x, int y, unsigned button);
+ virtual void DoMouseWheel(int x, int y, int d);
+};*/
}
+#endif // WINDOW_H
diff --git a/src/search/Save.h b/src/search/Save.h
new file mode 100644
index 0000000..a3ef485
--- /dev/null
+++ b/src/search/Save.h
@@ -0,0 +1,41 @@
+#ifndef SAVE_H
+#define SAVE_H
+
+#include <string>
+
+using namespace std;
+
+class Save
+{
+private:
+ int id;
+ int votesUp, votesDown;
+ string userName;
+ string name;
+public:
+ Save(int _id, int _votesUp, int _votesDown, string _userName, string _name):
+ id(_id),
+ votesUp(_votesUp),
+ votesDown(_votesDown),
+ userName(_userName),
+ name(_name)
+ {
+ }
+
+ void SetName(string name){ this->name = name; }
+ string GetName(){ return name; }
+
+ void SetUserName(string userName){ this->userName = userName; }
+ string GetUserName(){ return userName; }
+
+ void SetID(int id){ this->id = id; }
+ int GetID(){ return id; }
+
+ void SetVotesUp(int votesUp){ this->votesUp = votesUp; }
+ int GetVotesUp(){ return votesUp; }
+
+ void SetVotesDown(int votesDown){ this->votesDown = votesDown; }
+ int GetVotesDown(){ return votesDown; }
+};
+
+#endif // SAVE_H
diff --git a/src/search/SearchController.cpp b/src/search/SearchController.cpp
new file mode 100644
index 0000000..cf13f2e
--- /dev/null
+++ b/src/search/SearchController.cpp
@@ -0,0 +1,14 @@
+#include "SearchController.h"
+#include "SearchModel.h"
+#include "SearchView.h"
+#include "interface/Panel.h"
+
+SearchController::SearchController()
+{
+ searchModel = new SearchModel();
+ searchView = new SearchView();
+ searchModel->AddObserver(searchView);
+
+ //Set up interface
+ //windowPanel.AddChild();
+}
diff --git a/src/search/SearchController.h b/src/search/SearchController.h
new file mode 100644
index 0000000..8755a07
--- /dev/null
+++ b/src/search/SearchController.h
@@ -0,0 +1,18 @@
+#ifndef SEARCHCONTROLLER_H
+#define SEARCHCONTROLLER_H
+
+#include "interface/Panel.h"
+#include "SearchModel.h"
+#include "SearchView.h"
+
+class SearchController
+{
+private:
+ SearchModel * searchModel;
+ SearchView * searchView;
+ ui::Panel * windowPanel;
+public:
+ SearchController();
+};
+
+#endif // SEARCHCONTROLLER_H
diff --git a/src/search/SearchModel.cpp b/src/search/SearchModel.cpp
new file mode 100644
index 0000000..63188bd
--- /dev/null
+++ b/src/search/SearchModel.cpp
@@ -0,0 +1,23 @@
+#include "SearchModel.h"
+#include "Save.h"
+
+SearchModel::SearchModel()
+{
+}
+
+void SearchModel::UpdateSaveList()
+{
+ saveList.clear();
+ notifySaveListChanged();
+ saveList.push_back(Save(1, 45, 5, "Simon", "Post logic gates"));
+ notifySaveListChanged();
+}
+
+void SearchModel::notifySaveListChanged()
+{
+ for(int i = 0; i < observers.size(); i++)
+ {
+ SearchView* cObserver = observers[i];
+ cObserver->NotifySaveListChanged(this);
+ }
+}
diff --git a/src/search/SearchModel.h b/src/search/SearchModel.h
new file mode 100644
index 0000000..0951577
--- /dev/null
+++ b/src/search/SearchModel.h
@@ -0,0 +1,23 @@
+#ifndef SEARCHMODEL_H
+#define SEARCHMODEL_H
+
+#include <vector>
+#include "Save.h"
+#include "SearchView.h"
+
+using namespace std;
+
+class SearchModel
+{
+private:
+ vector<SearchView*> observers;
+ vector<Save> saveList;
+ void notifySaveListChanged();
+public:
+ SearchModel();
+ void AddObserver(SearchView * observer){ observers.push_back(observer); }
+ void UpdateSaveList();
+ vector<Save> GetSaveList();
+};
+
+#endif // SEARCHMODEL_H
diff --git a/src/search/SearchView.cpp b/src/search/SearchView.cpp
new file mode 100644
index 0000000..4b551f3
--- /dev/null
+++ b/src/search/SearchView.cpp
@@ -0,0 +1,10 @@
+#include "SearchView.h"
+
+SearchView::SearchView()
+{
+}
+
+void SearchView::NotifySaveListChanged(SearchModel * sender)
+{
+
+}
diff --git a/src/search/SearchView.h b/src/search/SearchView.h
new file mode 100644
index 0000000..e540f21
--- /dev/null
+++ b/src/search/SearchView.h
@@ -0,0 +1,13 @@
+#ifndef SEARCHVIEW_H
+#define SEARCHVIEW_H
+
+class SearchModel;
+
+class SearchView
+{
+public:
+ void NotifySaveListChanged(SearchModel * sender);
+ SearchView();
+};
+
+#endif // SEARCHVIEW_H