The-Powder-Toy/src/interface/Engine.h

79 lines
1.7 KiB
C
Raw Normal View History

2012-01-14 12:51:24 -06:00
#pragma once
2012-01-17 14:46:06 -06:00
#include <stack>
2012-01-14 12:51:24 -06:00
#include "Singleton.h"
#include "Platform.h"
#include "Graphics.h"
2012-01-17 14:46:06 -06:00
#include "Window.h"
2012-01-14 12:51:24 -06:00
namespace ui
{
2012-01-17 14:46:06 -06:00
class Window;
2012-01-14 12:51:24 -06:00
/* 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();
2012-01-17 14:46:06 -06:00
void ShowWindow(Window * window);
void CloseWindow();
2012-01-14 12:51:24 -06:00
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);
2012-01-14 12:51:24 -06:00
void onResize(int newWidth, int newHeight);
void onClose();
void Begin(int width, int height);
2012-01-14 12:51:24 -06:00
inline bool Running() { return running_; }
void Exit();
void Tick();
2012-01-14 12:51:24 -06:00
void Draw();
void SetFps(float fps);
2012-01-14 12:51:24 -06:00
inline int GetMouseX() { return mousex_; }
inline int GetMouseY() { return mousey_; }
inline int GetWidth() { return width_; }
inline int GetHeight() { return height_; }
inline void SetSize(int width, int height);
2012-01-17 14:46:06 -06:00
//void SetState(Window* state);
//inline State* GetState() { return state_; }
inline Window* GetWindow() { return state_; }
float FpsLimit;
2012-01-17 14:46:06 -06:00
Graphics * g;
2012-01-14 12:51:24 -06:00
private:
float dt;
float fps;
2012-01-21 17:29:40 -06:00
pixel * lastBuffer;
std::stack<pixel*> prevBuffers;
2012-01-17 14:46:06 -06:00
std::stack<Window*> windows;
//Window* statequeued_;
Window* state_;
Point windowTargetPosition;
float windowOpenState;
2012-01-14 12:51:24 -06:00
bool running_;
int mousex_;
int mousey_;
int mousexp_;
int mouseyp_;
int width_;
int height_;
};
}