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(""),
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)

View File

@ -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<ui::Point> pointQueue;
GameController * c;

View File

@ -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;
}

View File

@ -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() {

View File

@ -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;