diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-07-18 17:33:44 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-07-18 17:33:44 (GMT) |
| commit | 26dbd547d3a3662c62e7b3ecadae5609f1726df4 (patch) | |
| tree | 8932ab52b1562ab90a9541962a85c93cea369683 /src | |
| parent | 80044bb0f06b4186bcc2f07e1c5ddc4e195f2426 (diff) | |
| download | powder-26dbd547d3a3662c62e7b3ecadae5609f1726df4.zip powder-26dbd547d3a3662c62e7b3ecadae5609f1726df4.tar.gz | |
Info tip for changing display modes
Diffstat (limited to 'src')
| -rw-r--r-- | src/game/GameController.cpp | 1 | ||||
| -rw-r--r-- | src/game/GameModel.cpp | 38 | ||||
| -rw-r--r-- | src/game/GameModel.h | 10 | ||||
| -rw-r--r-- | src/game/GameView.cpp | 28 | ||||
| -rw-r--r-- | src/game/GameView.h | 8 |
5 files changed, 84 insertions, 1 deletions
diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp index 0740554..72c38c0 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 668b755..bec2c98 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<GameView*>::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 5f656c1..28b86e6 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 62fd6a9..8fee0ed 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 324f716..59861bf 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<ui::Point*> 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); |
