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) void GameController::LoadRenderPreset(RenderPreset preset)
{ {
Renderer * renderer = gameModel->GetRenderer(); Renderer * renderer = gameModel->GetRenderer();
gameModel->SetInfoTip(preset.Name);
renderer->SetRenderMode(preset.RenderModes); renderer->SetRenderMode(preset.RenderModes);
renderer->SetDisplayMode(preset.DisplayModes); renderer->SetDisplayMode(preset.DisplayModes);
renderer->SetColourMode(preset.ColourMode); renderer->SetColourMode(preset.ColourMode);

View File

@ -517,6 +517,28 @@ void GameModel::RemoveNotification(Notification * notification)
notifyNotificationsChanged(); 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() void GameModel::notifyNotificationsChanged()
{ {
for(std::vector<GameView*>::iterator iter = observers.begin(); iter != observers.end(); ++iter) 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); 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; User currentUser;
bool colourSelector; bool colourSelector;
ui::Colour colour; ui::Colour colour;
std::string infoTip;
std::string toolTip;
//bool zoomEnabled; //bool zoomEnabled;
void notifyRendererChanged(); void notifyRendererChanged();
void notifySimulationChanged(); void notifySimulationChanged();
@ -71,6 +74,8 @@ private:
void notifyColourSelectorVisibilityChanged(); void notifyColourSelectorVisibilityChanged();
void notifyNotificationsChanged(); void notifyNotificationsChanged();
void notifyLogChanged(string entry); void notifyLogChanged(string entry);
void notifyInfoTipChanged();
void notifyToolTipChanged();
public: public:
GameModel(); GameModel();
~GameModel(); ~GameModel();
@ -81,6 +86,11 @@ public:
void SetColourSelectorColour(ui::Colour colour); void SetColourSelectorColour(ui::Colour colour);
ui::Colour GetColourSelectorColour(); ui::Colour GetColourSelectorColour();
void SetToolTip(std::string text);
void SetInfoTip(std::string text);
std::string GetToolTip();
std::string GetInfoTip();
void SetVote(int direction); void SetVote(int direction);
SaveInfo * GetSave(); SaveInfo * GetSave();
Brush * GetBrush(); Brush * GetBrush();

View File

@ -33,7 +33,10 @@ GameView::GameView():
placeSaveThumb(NULL), placeSaveThumb(NULL),
mousePosition(0, 0), mousePosition(0, 0),
lastOffset(0), lastOffset(0),
drawSnap(false) drawSnap(false),
toolTip(""),
infoTip(""),
infoTipPresence(0)
{ {
int currentX = 1; int currentX = 1;
@ -520,6 +523,17 @@ void GameView::NotifyPausedChanged(GameModel * sender)
pauseButton->SetToggleState(sender->GetPaused()); 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) void GameView::NotifySaveChanged(GameModel * sender)
{ {
if(sender->GetSave()) if(sender->GetSave())
@ -922,6 +936,12 @@ void GameView::OnTick(float dt)
{ {
c->DrawFill(toolIndex, currentMouse); c->DrawFill(toolIndex, currentMouse);
} }
if(infoTipPresence>0)
{
infoTipPresence -= int(dt)>0?int(dt):1;
if(infoTipPresence<0)
infoTipPresence = 0;
}
c->Update(); c->Update();
if(lastLogEntry > -0.1f) if(lastLogEntry > -0.1f)
lastLogEntry -= 0.16*dt; lastLogEntry -= 0.16*dt;
@ -1227,6 +1247,12 @@ void GameView::OnDraw()
sampleInfo << ", Ctype: " << c->ElementResolve(sample.ctype); 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); 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) ui::Point GameView::lineSnapCoords(ui::Point point1, ui::Point point2)

View File

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