diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp index 074055405..72c38c0e7 100644 --- a/src/game/GameController.cpp +++ b/src/game/GameController.cpp @@ -405,6 +405,7 @@ void GameController::Exit() void GameController::LoadRenderPreset(RenderPreset preset) { Renderer * renderer = gameModel->GetRenderer(); + gameModel->SetInfoTip(preset.Name); renderer->SetRenderMode(preset.RenderModes); renderer->SetDisplayMode(preset.DisplayModes); renderer->SetColourMode(preset.ColourMode); diff --git a/src/game/GameModel.cpp b/src/game/GameModel.cpp index 668b75597..bec2c9833 100644 --- a/src/game/GameModel.cpp +++ b/src/game/GameModel.cpp @@ -517,6 +517,28 @@ void GameModel::RemoveNotification(Notification * notification) notifyNotificationsChanged(); } +void GameModel::SetToolTip(std::string text) +{ + toolTip = text; + notifyToolTipChanged(); +} + +void GameModel::SetInfoTip(std::string text) +{ + infoTip = text; + notifyInfoTipChanged(); +} + +std::string GameModel::GetToolTip() +{ + return toolTip; +} + +std::string GameModel::GetInfoTip() +{ + return infoTip; +} + void GameModel::notifyNotificationsChanged() { for(std::vector::iterator iter = observers.begin(); iter != observers.end(); ++iter) @@ -644,3 +666,19 @@ void GameModel::notifyLogChanged(string entry) observers[i]->NotifyLogChanged(this, entry); } } + +void GameModel::notifyInfoTipChanged() +{ + for(int i = 0; i < observers.size(); i++) + { + observers[i]->NotifyInfoTipChanged(this); + } +} + +void GameModel::notifyToolTipChanged() +{ + for(int i = 0; i < observers.size(); i++) + { + observers[i]->NotifyToolTipChanged(this); + } +} \ No newline at end of file diff --git a/src/game/GameModel.h b/src/game/GameModel.h index 5f656c129..28b86e649 100644 --- a/src/game/GameModel.h +++ b/src/game/GameModel.h @@ -53,6 +53,9 @@ private: User currentUser; bool colourSelector; ui::Colour colour; + + std::string infoTip; + std::string toolTip; //bool zoomEnabled; void notifyRendererChanged(); void notifySimulationChanged(); @@ -71,6 +74,8 @@ private: void notifyColourSelectorVisibilityChanged(); void notifyNotificationsChanged(); void notifyLogChanged(string entry); + void notifyInfoTipChanged(); + void notifyToolTipChanged(); public: GameModel(); ~GameModel(); @@ -81,6 +86,11 @@ public: void SetColourSelectorColour(ui::Colour colour); ui::Colour GetColourSelectorColour(); + void SetToolTip(std::string text); + void SetInfoTip(std::string text); + std::string GetToolTip(); + std::string GetInfoTip(); + void SetVote(int direction); SaveInfo * GetSave(); Brush * GetBrush(); diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index 62fd6a95c..8fee0eddc 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -33,7 +33,10 @@ GameView::GameView(): placeSaveThumb(NULL), mousePosition(0, 0), lastOffset(0), - drawSnap(false) + drawSnap(false), + toolTip(""), + infoTip(""), + infoTipPresence(0) { int currentX = 1; @@ -520,6 +523,17 @@ void GameView::NotifyPausedChanged(GameModel * sender) pauseButton->SetToggleState(sender->GetPaused()); } +void GameView::NotifyToolTipChanged(GameModel * sender) +{ + toolTip = sender->GetToolTip(); +} + +void GameView::NotifyInfoTipChanged(GameModel * sender) +{ + infoTip = sender->GetInfoTip(); + infoTipPresence = 120; +} + void GameView::NotifySaveChanged(GameModel * sender) { if(sender->GetSave()) @@ -922,6 +936,12 @@ void GameView::OnTick(float dt) { c->DrawFill(toolIndex, currentMouse); } + if(infoTipPresence>0) + { + infoTipPresence -= int(dt)>0?int(dt):1; + if(infoTipPresence<0) + infoTipPresence = 0; + } c->Update(); if(lastLogEntry > -0.1f) lastLogEntry -= 0.16*dt; @@ -1227,6 +1247,12 @@ void GameView::OnDraw() sampleInfo << ", Ctype: " << c->ElementResolve(sample.ctype); g->drawtext(XRES+BARSIZE-(10+Graphics::textwidth((char*)sampleInfo.str().c_str())), 10, (const char*)sampleInfo.str().c_str(), 255, 255, 255, 255); + + if(infoTipPresence) + { + int infoTipAlpha = (infoTipPresence>50?50:infoTipPresence)*5; + g->drawtext((XRES-Graphics::textwidth((char*)infoTip.c_str()))/2, (YRES/2)-2, (char*)infoTip.c_str(), 255, 255, 255, infoTipAlpha); + } } ui::Point GameView::lineSnapCoords(ui::Point point1, ui::Point point2) diff --git a/src/game/GameView.h b/src/game/GameView.h index 324f71646..59861bf21 100644 --- a/src/game/GameView.h +++ b/src/game/GameView.h @@ -38,6 +38,11 @@ private: bool zoomCursorFixed; bool drawSnap; int toolIndex; + + int infoTipPresence; + std::string toolTip; + std::string infoTip; + queue pointQueue; GameController * c; Renderer * ren; @@ -111,6 +116,9 @@ public: void NotifyPlaceSaveChanged(GameModel * sender); void NotifyNotificationsChanged(GameModel * sender); void NotifyLogChanged(GameModel * sender, string entry); + void NotifyToolTipChanged(GameModel * sender); + void NotifyInfoTipChanged(GameModel * sender); + 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);