Info tip for changing display modes

This commit is contained in:
Simon Robertshaw 2012-07-18 18:33:44 +01:00
parent 80044bb0f0
commit 26dbd547d3
5 changed files with 84 additions and 1 deletions

View File

@ -405,6 +405,7 @@ void GameController::Exit()
void GameController::LoadRenderPreset(RenderPreset preset)
{
Renderer * renderer = gameModel->GetRenderer();
gameModel->SetInfoTip(preset.Name);
renderer->SetRenderMode(preset.RenderModes);
renderer->SetDisplayMode(preset.DisplayModes);
renderer->SetColourMode(preset.ColourMode);

View File

@ -517,6 +517,28 @@ void GameModel::RemoveNotification(Notification * notification)
notifyNotificationsChanged();
}
void GameModel::SetToolTip(std::string text)
{
toolTip = text;
notifyToolTipChanged();
}
void GameModel::SetInfoTip(std::string text)
{
infoTip = text;
notifyInfoTipChanged();
}
std::string GameModel::GetToolTip()
{
return toolTip;
}
std::string GameModel::GetInfoTip()
{
return infoTip;
}
void GameModel::notifyNotificationsChanged()
{
for(std::vector<GameView*>::iterator iter = observers.begin(); iter != observers.end(); ++iter)
@ -644,3 +666,19 @@ void GameModel::notifyLogChanged(string entry)
observers[i]->NotifyLogChanged(this, entry);
}
}
void GameModel::notifyInfoTipChanged()
{
for(int i = 0; i < observers.size(); i++)
{
observers[i]->NotifyInfoTipChanged(this);
}
}
void GameModel::notifyToolTipChanged()
{
for(int i = 0; i < observers.size(); i++)
{
observers[i]->NotifyToolTipChanged(this);
}
}

View File

@ -53,6 +53,9 @@ private:
User currentUser;
bool colourSelector;
ui::Colour colour;
std::string infoTip;
std::string toolTip;
//bool zoomEnabled;
void notifyRendererChanged();
void notifySimulationChanged();
@ -71,6 +74,8 @@ private:
void notifyColourSelectorVisibilityChanged();
void notifyNotificationsChanged();
void notifyLogChanged(string entry);
void notifyInfoTipChanged();
void notifyToolTipChanged();
public:
GameModel();
~GameModel();
@ -81,6 +86,11 @@ public:
void SetColourSelectorColour(ui::Colour colour);
ui::Colour GetColourSelectorColour();
void SetToolTip(std::string text);
void SetInfoTip(std::string text);
std::string GetToolTip();
std::string GetInfoTip();
void SetVote(int direction);
SaveInfo * GetSave();
Brush * GetBrush();

View File

@ -33,7 +33,10 @@ GameView::GameView():
placeSaveThumb(NULL),
mousePosition(0, 0),
lastOffset(0),
drawSnap(false)
drawSnap(false),
toolTip(""),
infoTip(""),
infoTipPresence(0)
{
int currentX = 1;
@ -520,6 +523,17 @@ void GameView::NotifyPausedChanged(GameModel * sender)
pauseButton->SetToggleState(sender->GetPaused());
}
void GameView::NotifyToolTipChanged(GameModel * sender)
{
toolTip = sender->GetToolTip();
}
void GameView::NotifyInfoTipChanged(GameModel * sender)
{
infoTip = sender->GetInfoTip();
infoTipPresence = 120;
}
void GameView::NotifySaveChanged(GameModel * sender)
{
if(sender->GetSave())
@ -922,6 +936,12 @@ void GameView::OnTick(float dt)
{
c->DrawFill(toolIndex, currentMouse);
}
if(infoTipPresence>0)
{
infoTipPresence -= int(dt)>0?int(dt):1;
if(infoTipPresence<0)
infoTipPresence = 0;
}
c->Update();
if(lastLogEntry > -0.1f)
lastLogEntry -= 0.16*dt;
@ -1227,6 +1247,12 @@ void GameView::OnDraw()
sampleInfo << ", Ctype: " << c->ElementResolve(sample.ctype);
g->drawtext(XRES+BARSIZE-(10+Graphics::textwidth((char*)sampleInfo.str().c_str())), 10, (const char*)sampleInfo.str().c_str(), 255, 255, 255, 255);
if(infoTipPresence)
{
int infoTipAlpha = (infoTipPresence>50?50:infoTipPresence)*5;
g->drawtext((XRES-Graphics::textwidth((char*)infoTip.c_str()))/2, (YRES/2)-2, (char*)infoTip.c_str(), 255, 255, 255, infoTipAlpha);
}
}
ui::Point GameView::lineSnapCoords(ui::Point point1, ui::Point point2)

View File

@ -38,6 +38,11 @@ private:
bool zoomCursorFixed;
bool drawSnap;
int toolIndex;
int infoTipPresence;
std::string toolTip;
std::string infoTip;
queue<ui::Point*> pointQueue;
GameController * c;
Renderer * ren;
@ -111,6 +116,9 @@ public:
void NotifyPlaceSaveChanged(GameModel * sender);
void NotifyNotificationsChanged(GameModel * sender);
void NotifyLogChanged(GameModel * sender, string entry);
void NotifyToolTipChanged(GameModel * sender);
void NotifyInfoTipChanged(GameModel * sender);
virtual void OnMouseMove(int x, int y, int dx, int dy);
virtual void OnMouseDown(int x, int y, unsigned button);
virtual void OnMouseUp(int x, int y, unsigned button);