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

96 lines
2.2 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"
2012-07-06 10:06:26 -05:00
#include "graphics/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_; }
inline bool Broken() { return break_; }
2012-08-20 19:24:38 -05:00
inline int LastTick() { return lastTick; }
inline void LastTick(int tick) { lastTick = tick; }
2012-01-14 12:51:24 -06:00
void Exit();
void Break();
void UnBreak();
2012-01-14 12:51:24 -06:00
void SetFullscreen(bool fullscreen) { Fullscreen = fullscreen; }
inline bool GetFullscreen() { return Fullscreen; }
void SetScale(int scale) { Scale = scale; }
inline int GetScale() { return Scale; }
void Tick();
2012-01-14 12:51:24 -06:00
void Draw();
void SetFps(float fps);
2012-07-24 08:58:39 -05:00
inline float GetFps() { return 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;
int Scale;
bool Fullscreen;
unsigned int FrameIndex;
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_;
bool break_;
2012-01-14 12:51:24 -06:00
2012-08-20 19:24:38 -05:00
int lastTick;
2012-01-14 12:51:24 -06:00
int mousex_;
int mousey_;
int mousexp_;
int mouseyp_;
int width_;
int height_;
};
}