diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index fcfa95c24..925ff2c60 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -171,6 +171,8 @@ GameView::GameView(): infoTip(""), infoTipPresence(0), buttonTipShow(0), + isToolTipFadingIn(false), + isButtonTipFadingIn(false), toolTipPosition(-1, -1), shiftBehaviour(false), ctrlBehaviour(false), @@ -1154,8 +1156,7 @@ void GameView::ToolTip(ui::Component * sender, ui::Point mousePosition, std::str if (selectMode == PlaceSave || selectMode == SelectNone) { buttonTip = toolTip; - if (buttonTipShow < 120) - buttonTipShow += 3; + isButtonTipFadingIn = true; } } else if(sender->Position.X > Size.X-BARSIZE)// < Size.Y-(quickOptionButtons.size()+1)*16) @@ -1164,15 +1165,13 @@ void GameView::ToolTip(ui::Component * sender, ui::Point mousePosition, std::str toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth((char*)toolTip.c_str()), sender->Position.Y+3); if(toolTipPosition.Y+10 > Size.Y-MENUSIZE) toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth((char*)toolTip.c_str()), Size.Y-MENUSIZE-10); - if (toolTipPresence < 120) - toolTipPresence += 3; + isToolTipFadingIn = true; } else { this->toolTip = toolTip; toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth((char*)toolTip.c_str()), Size.Y-MENUSIZE-10); - if (toolTipPresence < 160) - toolTipPresence += 3; + isToolTipFadingIn = true; } } @@ -1526,15 +1525,33 @@ void GameView::OnTick(float dt) if(infoTipPresence<0) infoTipPresence = 0; } - if (selectMode != PlaceSave && selectMode != SelectNone && buttonTipShow < 120) - buttonTipShow += 2; + if (isButtonTipFadingIn || (selectMode != PlaceSave && selectMode != SelectNone)) + { + isButtonTipFadingIn = false; + if(buttonTipShow < 120) + { + buttonTipShow += int(dt*2)>0?int(dt*2):1; + if(buttonTipShow>120) + buttonTipShow = 120; + } + } else if(buttonTipShow>0) { buttonTipShow -= int(dt)>0?int(dt):1; if(buttonTipShow<0) buttonTipShow = 0; } - if(toolTipPresence>0) + if (isToolTipFadingIn) + { + isToolTipFadingIn = false; + if(toolTipPresence < 120) + { + toolTipPresence += int(dt*2)>0?int(dt*2):1; + if(toolTipPresence>120) + toolTipPresence = 120; + } + } + else if(toolTipPresence>0) { toolTipPresence -= int(dt)>0?int(dt):1; if(toolTipPresence<0) diff --git a/src/gui/game/GameView.h b/src/gui/game/GameView.h index 093d80b2a..8d5c57b03 100644 --- a/src/gui/game/GameView.h +++ b/src/gui/game/GameView.h @@ -51,18 +51,20 @@ private: bool showDebug; bool wallBrush; int introText; - int buttonTipShow; - std::string buttonTip; std::string introTextMessage; int toolIndex; int currentSaveType; Menu * lastMenu; - int infoTipPresence; - std::string toolTip; - ui::Point toolTipPosition; - std::string infoTip; int toolTipPresence; + std::string toolTip; + bool isToolTipFadingIn; + ui::Point toolTipPosition; + int infoTipPresence; + std::string infoTip; + int buttonTipShow; + std::string buttonTip; + bool isButtonTipFadingIn; queue pointQueue; GameController * c; diff --git a/src/gui/interface/Engine.cpp b/src/gui/interface/Engine.cpp index 6911c2518..29fd5aab1 100644 --- a/src/gui/interface/Engine.cpp +++ b/src/gui/interface/Engine.cpp @@ -247,7 +247,7 @@ void Engine::SetFps(float fps) { this->fps = fps; if(FpsLimit > 2.0f) - this->dt = FpsLimit/fps; + this->dt = 60/fps; else this->dt = 1.0f; } diff --git a/src/gui/render/RenderView.cpp b/src/gui/render/RenderView.cpp index 3b3a91afe..8c09ceb6f 100644 --- a/src/gui/render/RenderView.cpp +++ b/src/gui/render/RenderView.cpp @@ -80,6 +80,7 @@ RenderView::RenderView(): ui::Window(ui::Point(0, 0), ui::Point(XRES, YRES+MENUSIZE)), toolTip(""), toolTipPresence(0), + isToolTipFadingIn(false), ren(NULL) { ui::Button * presetButton; @@ -373,6 +374,16 @@ void RenderView::OnDraw() void RenderView::OnTick(float dt) { + if (isToolTipFadingIn) + { + isToolTipFadingIn = false; + if(toolTipPresence < 120) + { + toolTipPresence += int(dt*2)>0?int(dt*2):1; + if(toolTipPresence > 120) + toolTipPresence = 0; + } + } if(toolTipPresence>0) { toolTipPresence -= int(dt)>0?int(dt):1; @@ -394,8 +405,7 @@ void RenderView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bo void RenderView::ToolTip(ui::Component * sender, ui::Point mousePosition, std::string toolTip) { this->toolTip = toolTip; - if (toolTipPresence < 120) - toolTipPresence += 3; + this->isToolTipFadingIn = true; } RenderView::~RenderView() { diff --git a/src/gui/render/RenderView.h b/src/gui/render/RenderView.h index 8a65eb151..4cf8cf0da 100644 --- a/src/gui/render/RenderView.h +++ b/src/gui/render/RenderView.h @@ -20,6 +20,7 @@ class RenderView: public ui::Window { std::vector colourModes; std::string toolTip; int toolTipPresence; + bool isToolTipFadingIn; int line1, line2, line3, line4; public: class RenderModeAction;