summaryrefslogtreecommitdiff
path: root/src/gui/interface/Engine.h
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2013-03-24 12:24:17 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2013-03-24 12:24:17 (GMT)
commit9b5b85f9b01cbda7ef9a7ec2a15b2a35630a5b9d (patch)
treeac7d040253b459ce102e476cb19ab59e3cfa90d7 /src/gui/interface/Engine.h
parent6bf98ccdca39936a3c51367862eed7c49f8786ec (diff)
parentbdc69f31c0be94191015838886bdcc2bc67f1acb (diff)
downloadpowder-9b5b85f9b01cbda7ef9a7ec2a15b2a35630a5b9d.zip
powder-9b5b85f9b01cbda7ef9a7ec2a15b2a35630a5b9d.tar.gz
Merge branch 'reorganisation' of github.com:FacialTurd/The-Powder-Toy
Diffstat (limited to 'src/gui/interface/Engine.h')
-rw-r--r--src/gui/interface/Engine.h108
1 files changed, 108 insertions, 0 deletions
diff --git a/src/gui/interface/Engine.h b/src/gui/interface/Engine.h
new file mode 100644
index 0000000..fb110e4
--- /dev/null
+++ b/src/gui/interface/Engine.h
@@ -0,0 +1,108 @@
+#pragma once
+
+#include <stack>
+#include "Singleton.h"
+#include "Platform.h"
+#include "graphics/Graphics.h"
+#include "Window.h"
+
+namespace ui
+{
+ class Window;
+
+ /* class Engine
+ *
+ * Controls the User Interface.
+ * Send user inputs to the Engine and the appropriate controls and components will interact.
+ */
+ class Engine: public Singleton<Engine>
+ {
+ public:
+ Engine();
+ ~Engine();
+
+ void ShowWindow(Window * window);
+ int CloseWindow();
+
+ void onMouseMove(int x, int y);
+ void onMouseClick(int x, int y, unsigned button);
+ void onMouseUnclick(int x, int y, unsigned button);
+ void onMouseWheel(int x, int y, int delta);
+ void onKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
+ void onKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
+ void onResize(int newWidth, int newHeight);
+ void onClose();
+
+ void Begin(int width, int height);
+ inline bool Running() { return running_; }
+ inline bool Broken() { return break_; }
+ inline int LastTick() { return lastTick; }
+ inline void LastTick(int tick) { lastTick = tick; }
+ void Exit();
+ void Break();
+ void UnBreak();
+
+ void SetFullscreen(bool fullscreen) { Fullscreen = fullscreen; }
+ inline bool GetFullscreen() { return Fullscreen; }
+ void SetScale(int scale) { Scale = scale; }
+ inline int GetScale() { return Scale; }
+ void SetFastQuit(bool fastquit) { FastQuit = fastquit; }
+ inline bool GetFastQuit() {return FastQuit; }
+
+ void Tick();
+ void Draw();
+
+ void SetFps(float fps);
+ inline float GetFps() { return fps; };
+
+ inline int GetMouseButton() { return mouseb_; }
+ inline int GetMouseX() { return mousex_; }
+ inline int GetMouseY() { return mousey_; }
+ inline int GetWidth() { return width_; }
+ inline int GetHeight() { return height_; }
+ inline int GetMaxWidth() { return maxWidth; }
+ inline int GetMaxHeight() { return maxHeight; }
+
+ TPT_NO_INLINE void SetMaxSize(int width, int height);
+
+ inline void SetSize(int width, int height);
+
+ //void SetState(Window* state);
+ //inline State* GetState() { return state_; }
+ inline Window* GetWindow() { return state_; }
+ float FpsLimit;
+ Graphics * g;
+ int Scale;
+ bool Fullscreen;
+
+ unsigned int FrameIndex;
+ private:
+ float dt;
+ float fps;
+ pixel * lastBuffer;
+ std::stack<pixel*> prevBuffers;
+ std::stack<Window*> windows;
+ std::stack<Point> mousePositions;
+ //Window* statequeued_;
+ Window* state_;
+ Point windowTargetPosition;
+ float windowOpenState;
+
+ bool running_;
+ bool break_;
+ bool FastQuit;
+
+ int lastTick;
+ int mouseb_;
+ int mousex_;
+ int mousey_;
+ int mousexp_;
+ int mouseyp_;
+ int width_;
+ int height_;
+
+ int maxWidth;
+ int maxHeight;
+ };
+
+}