summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2013-05-12 01:43:52 (GMT)
committer jacob1 <jfu614@gmail.com>2013-05-12 01:43:52 (GMT)
commit9d89d4b79b26584490e55cfb992fc58d3e11ea2b (patch)
tree4564d725ae9def30ee6d2128b67592fd7aaddfdd
parent67e1213905edbd248ef4d434c3e5e53c151828a7 (diff)
downloadpowder-9d89d4b79b26584490e55cfb992fc58d3e11ea2b.zip
powder-9d89d4b79b26584490e55cfb992fc58d3e11ea2b.tar.gz
fix tooltips and dt
-rw-r--r--src/gui/game/GameView.cpp35
-rw-r--r--src/gui/game/GameView.h10
-rw-r--r--src/gui/interface/Engine.cpp2
-rw-r--r--src/gui/render/RenderView.cpp14
-rw-r--r--src/gui/render/RenderView.h1
5 files changed, 46 insertions, 16 deletions
diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp
index fcfa95c..925ff2c 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 093d80b..8d5c57b 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;
+ int toolTipPresence;
std::string toolTip;
+ bool isToolTipFadingIn;
ui::Point toolTipPosition;
+ int infoTipPresence;
std::string infoTip;
- int toolTipPresence;
+ int buttonTipShow;
+ std::string buttonTip;
+ bool isButtonTipFadingIn;
queue<ui::Point> pointQueue;
GameController * c;
diff --git a/src/gui/interface/Engine.cpp b/src/gui/interface/Engine.cpp
index 6911c25..29fd5aa 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 3b3a91a..8c09ceb 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 8a65eb1..4cf8cf0 100644
--- a/src/gui/render/RenderView.h
+++ b/src/gui/render/RenderView.h
@@ -20,6 +20,7 @@ class RenderView: public ui::Window {
std::vector<ui::Checkbox*> colourModes;
std::string toolTip;
int toolTipPresence;
+ bool isToolTipFadingIn;
int line1, line2, line3, line4;
public:
class RenderModeAction;