#ifndef GAMEVIEW_H #define GAMEVIEW_H #include #include #include #include #include "GameController.h" #include "GameModel.h" #include "interface/Window.h" #include "interface/Point.h" #include "interface/Button.h" #include "interface/Slider.h" #include "ToolButton.h" #include "RenderPreset.h" #include "Brush.h" using namespace std; enum DrawMode { DrawPoints, DrawLine, DrawRect, DrawFill }; enum SelectMode { SelectNone, SelectStamp, SelectCopy, PlaceSave }; class GameController; class GameModel; class GameView: public ui::Window { private: DrawMode drawMode; bool isMouseDown; bool zoomEnabled; bool zoomCursorFixed; bool drawSnap; int toolIndex; int infoTipPresence; std::string toolTip; ui::Point toolTipPosition; std::string infoTip; queue pointQueue; GameController * c; Renderer * ren; Brush * activeBrush; //UI Elements vector menuButtons; vector toolButtons; vector notificationComponents; deque logEntries; float lastLogEntry; ui::Button * scrollBar; ui::Button * searchButton; ui::Button * reloadButton; ui::Button * saveSimulationButton; ui::Button * downVoteButton; ui::Button * upVoteButton; ui::Button * tagSimulationButton; ui::Button * clearSimButton; ui::Button * loginButton; ui::Button * simulationOptionButton; ui::Button * displayModeButton; ui::Button * pauseButton; ui::Point currentMouse; ui::Slider * colourRSlider; ui::Slider * colourGSlider; ui::Slider * colourBSlider; ui::Slider * colourASlider; bool drawModeReset; ui::Point drawPoint1; ui::Point drawPoint2; SelectMode selectMode; ui::Point selectPoint1; ui::Point selectPoint2; ui::Point mousePosition; RenderPreset * renderModePresets; Thumbnail * placeSaveThumb; Particle sample; int lastOffset; void setToolButtonOffset(int offset); void changeColour(); virtual ui::Point lineSnapCoords(ui::Point point1, ui::Point point2); virtual ui::Point rectSnapCoords(ui::Point point1, ui::Point point2); public: GameView(); //Breaks MVC, but any other way is going to be more of a mess. ui::Point GetMousePosition(); void SetSample(Particle sample); void AttachController(GameController * _c){ c = _c; } void NotifyRendererChanged(GameModel * sender); void NotifySimulationChanged(GameModel * sender); void NotifyPausedChanged(GameModel * sender); void NotifySaveChanged(GameModel * sender); void NotifyBrushChanged(GameModel * sender); void NotifyMenuListChanged(GameModel * sender); void NotifyToolListChanged(GameModel * sender); void NotifyActiveToolsChanged(GameModel * sender); void NotifyUserChanged(GameModel * sender); void NotifyZoomChanged(GameModel * sender); void NotifyColourSelectorVisibilityChanged(GameModel * sender); void NotifyColourSelectorColourChanged(GameModel * sender); void NotifyPlaceSaveChanged(GameModel * sender); void NotifyNotificationsChanged(GameModel * sender); void NotifyLogChanged(GameModel * sender, string entry); void NotifyToolTipChanged(GameModel * sender); void NotifyInfoTipChanged(GameModel * sender); virtual void ToolTip(ui::Component * sender, ui::Point mousePosition, std::string toolTip); 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, Uint16 character, bool shift, bool ctrl, bool alt); virtual void OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt); //Top-level handers, for Lua interface 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, Uint16 character, bool shift, bool ctrl, bool alt); virtual void DoKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt); //virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt) {} //virtual void OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt) {} virtual void OnTick(float dt); virtual void OnDraw(); class MenuAction; class ToolAction; }; #endif // GAMEVIEW_H