Implemented tooltip element descriptor display in element search.

This commit is contained in:
RobertBScott 2017-11-20 12:02:21 -05:00 committed by jacob1
parent b5bc4ad3d2
commit 4c3b4dab47
2 changed files with 30 additions and 2 deletions

View File

@ -30,7 +30,9 @@ ElementSearchActivity::ElementSearchActivity(GameController * gameController, st
shiftPressed(false),
ctrlPressed(false),
altPressed(false),
exit(false)
exit(false),
toolTip(""),
isToolTipFadingIn(false)
{
ui::Label * title = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 15), "Element Search");
title->SetTextColour(style::Colour::InformationTitle);
@ -193,12 +195,28 @@ void ElementSearchActivity::OnDraw()
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255);
g->drawrect(Position.X+searchField->Position.X, Position.Y+searchField->Position.Y+searchField->Size.Y+8, searchField->Size.X, Size.Y-(searchField->Position.Y+searchField->Size.Y+8)-23, 255, 255, 255, 180);
if (toolTipPresence && toolTip.length())
{
g->drawtext(10, Size.Y+70, (char*)toolTip.c_str(), 255, 255, 255, toolTipPresence>51?255:toolTipPresence*5);
}
}
void ElementSearchActivity::OnTick(float dt)
{
if (exit)
Exit();
if (isToolTipFadingIn)
{
isToolTipFadingIn = false;
if (toolTipPresence < 120)
toolTipPresence += int(dt*2)>1?int(dt*2):2;
}
if (toolTipPresence>0)
{
toolTipPresence -= int(dt)>0?int(dt):1;
if (toolTipPresence<0)
toolTipPresence = 0;
}
}
void ElementSearchActivity::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
@ -246,6 +264,12 @@ void ElementSearchActivity::OnKeyRelease(int key, Uint16 character, bool shift,
}
}
void ElementSearchActivity::ToolTip(ui::Point senderPosition, std::string toolTip)
{
this->toolTip = toolTip;
this->isToolTipFadingIn = true;
}
ElementSearchActivity::~ElementSearchActivity() {
}

View File

@ -18,9 +18,12 @@ class ElementSearchActivity: public WindowActivity
std::vector<Tool*> tools;
ui::Textbox * searchField;
std::vector<ToolButton*> toolButtons;
std::string toolTip;
int toolTipPresence;
bool shiftPressed;
bool ctrlPressed;
bool altPressed;
bool isToolTipFadingIn;
void searchTools(std::string query);
public:
@ -30,10 +33,11 @@ public:
ElementSearchActivity(GameController * gameController, std::vector<Tool*> tools);
void SetActiveTool(int selectionState, Tool * tool);
virtual ~ElementSearchActivity();
virtual void OnDraw();
virtual void OnTick(float dt);
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnDraw();
virtual void ToolTip(ui::Point senderPosition, std::string ToolTip);
};
#endif /* ELEMENTSEARCHACTIVITY_H_ */