fix tooltips and dt

This commit is contained in:
jacob1 2013-05-11 21:43:52 -04:00
parent 67e1213905
commit 9d89d4b79b
5 changed files with 48 additions and 18 deletions

View File

@ -171,6 +171,8 @@ GameView::GameView():
infoTip(""), infoTip(""),
infoTipPresence(0), infoTipPresence(0),
buttonTipShow(0), buttonTipShow(0),
isToolTipFadingIn(false),
isButtonTipFadingIn(false),
toolTipPosition(-1, -1), toolTipPosition(-1, -1),
shiftBehaviour(false), shiftBehaviour(false),
ctrlBehaviour(false), ctrlBehaviour(false),
@ -1154,8 +1156,7 @@ void GameView::ToolTip(ui::Component * sender, ui::Point mousePosition, std::str
if (selectMode == PlaceSave || selectMode == SelectNone) if (selectMode == PlaceSave || selectMode == SelectNone)
{ {
buttonTip = toolTip; buttonTip = toolTip;
if (buttonTipShow < 120) isButtonTipFadingIn = true;
buttonTipShow += 3;
} }
} }
else if(sender->Position.X > Size.X-BARSIZE)// < Size.Y-(quickOptionButtons.size()+1)*16) 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); toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth((char*)toolTip.c_str()), sender->Position.Y+3);
if(toolTipPosition.Y+10 > Size.Y-MENUSIZE) if(toolTipPosition.Y+10 > Size.Y-MENUSIZE)
toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth((char*)toolTip.c_str()), Size.Y-MENUSIZE-10); toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth((char*)toolTip.c_str()), Size.Y-MENUSIZE-10);
if (toolTipPresence < 120) isToolTipFadingIn = true;
toolTipPresence += 3;
} }
else else
{ {
this->toolTip = toolTip; this->toolTip = toolTip;
toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth((char*)toolTip.c_str()), Size.Y-MENUSIZE-10); toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth((char*)toolTip.c_str()), Size.Y-MENUSIZE-10);
if (toolTipPresence < 160) isToolTipFadingIn = true;
toolTipPresence += 3;
} }
} }
@ -1526,15 +1525,33 @@ void GameView::OnTick(float dt)
if(infoTipPresence<0) if(infoTipPresence<0)
infoTipPresence = 0; infoTipPresence = 0;
} }
if (selectMode != PlaceSave && selectMode != SelectNone && buttonTipShow < 120) if (isButtonTipFadingIn || (selectMode != PlaceSave && selectMode != SelectNone))
buttonTipShow += 2; {
isButtonTipFadingIn = false;
if(buttonTipShow < 120)
{
buttonTipShow += int(dt*2)>0?int(dt*2):1;
if(buttonTipShow>120)
buttonTipShow = 120;
}
}
else if(buttonTipShow>0) else if(buttonTipShow>0)
{ {
buttonTipShow -= int(dt)>0?int(dt):1; buttonTipShow -= int(dt)>0?int(dt):1;
if(buttonTipShow<0) if(buttonTipShow<0)
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; toolTipPresence -= int(dt)>0?int(dt):1;
if(toolTipPresence<0) if(toolTipPresence<0)

View File

@ -51,18 +51,20 @@ private:
bool showDebug; bool showDebug;
bool wallBrush; bool wallBrush;
int introText; int introText;
int buttonTipShow;
std::string buttonTip;
std::string introTextMessage; std::string introTextMessage;
int toolIndex; int toolIndex;
int currentSaveType; int currentSaveType;
Menu * lastMenu; Menu * lastMenu;
int infoTipPresence;
std::string toolTip;
ui::Point toolTipPosition;
std::string infoTip;
int toolTipPresence; int toolTipPresence;
std::string toolTip;
bool isToolTipFadingIn;
ui::Point toolTipPosition;
int infoTipPresence;
std::string infoTip;
int buttonTipShow;
std::string buttonTip;
bool isButtonTipFadingIn;
queue<ui::Point> pointQueue; queue<ui::Point> pointQueue;
GameController * c; GameController * c;

View File

@ -247,7 +247,7 @@ void Engine::SetFps(float fps)
{ {
this->fps = fps; this->fps = fps;
if(FpsLimit > 2.0f) if(FpsLimit > 2.0f)
this->dt = FpsLimit/fps; this->dt = 60/fps;
else else
this->dt = 1.0f; this->dt = 1.0f;
} }

View File

@ -80,6 +80,7 @@ RenderView::RenderView():
ui::Window(ui::Point(0, 0), ui::Point(XRES, YRES+MENUSIZE)), ui::Window(ui::Point(0, 0), ui::Point(XRES, YRES+MENUSIZE)),
toolTip(""), toolTip(""),
toolTipPresence(0), toolTipPresence(0),
isToolTipFadingIn(false),
ren(NULL) ren(NULL)
{ {
ui::Button * presetButton; ui::Button * presetButton;
@ -373,6 +374,16 @@ void RenderView::OnDraw()
void RenderView::OnTick(float dt) 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) if(toolTipPresence>0)
{ {
toolTipPresence -= int(dt)>0?int(dt):1; 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) void RenderView::ToolTip(ui::Component * sender, ui::Point mousePosition, std::string toolTip)
{ {
this->toolTip = toolTip; this->toolTip = toolTip;
if (toolTipPresence < 120) this->isToolTipFadingIn = true;
toolTipPresence += 3;
} }
RenderView::~RenderView() { RenderView::~RenderView() {

View File

@ -20,6 +20,7 @@ class RenderView: public ui::Window {
std::vector<ui::Checkbox*> colourModes; std::vector<ui::Checkbox*> colourModes;
std::string toolTip; std::string toolTip;
int toolTipPresence; int toolTipPresence;
bool isToolTipFadingIn;
int line1, line2, line3, line4; int line1, line2, line3, line4;
public: public:
class RenderModeAction; class RenderModeAction;