summaryrefslogtreecommitdiff
path: root/src/game/GameView.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-07-29 14:08:38 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-07-29 14:08:38 (GMT)
commit418373a3cd6cf93ee1e41ffa502b8f4754831349 (patch)
tree59789683795957c93fdf46f11e58150c883828f2 /src/game/GameView.cpp
parentf8a6d2ea1f8f6789645279f69471c13c7caa352b (diff)
downloadpowder-418373a3cd6cf93ee1e41ffa502b8f4754831349.zip
powder-418373a3cd6cf93ee1e41ffa502b8f4754831349.tar.gz
HUD toggle, addresses "h should toggle the HUD" in issue #23
Diffstat (limited to 'src/game/GameView.cpp')
-rw-r--r--src/game/GameView.cpp47
1 files changed, 27 insertions, 20 deletions
diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp
index 290a72b..d7d0a50 100644
--- a/src/game/GameView.cpp
+++ b/src/game/GameView.cpp
@@ -39,7 +39,8 @@ GameView::GameView():
infoTipPresence(0),
toolTipPosition(-1, -1),
shiftBehaviour(false),
- ctrlBehaviour(false)
+ ctrlBehaviour(false),
+ showHud(true)
{
int currentX = 1;
@@ -943,6 +944,9 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
case 'f':
c->FrameStep();
break;
+ case 'h':
+ showHud = !showHud;
+ break;
case 'b':
if(ctrl)
c->SetDecoration();
@@ -1390,34 +1394,37 @@ void GameView::OnDraw()
}
}
- //Draw info about simulation under cursor
- std::stringstream sampleInfo;
- sampleInfo.precision(2);
- if(sample.particle.type)
- sampleInfo << c->ElementResolve(sample.particle.type) << ", Temp: " << std::fixed << sample.particle.temp -273.15f;
- else
- sampleInfo << "Empty";
+ if(showHud)
+ {
+ //Draw info about simulation under cursor
+ std::stringstream sampleInfo;
+ sampleInfo.precision(2);
+ if(sample.particle.type)
+ sampleInfo << c->ElementResolve(sample.particle.type) << ", Temp: " << std::fixed << sample.particle.temp -273.15f;
+ else
+ sampleInfo << "Empty";
- sampleInfo << ", Pressure: " << std::fixed << sample.AirPressure;
+ sampleInfo << ", Pressure: " << std::fixed << sample.AirPressure;
- int textWidth = Graphics::textwidth((char*)sampleInfo.str().c_str());
- g->fillrect(XRES-20-textWidth, 12, textWidth+8, 15, 0, 0, 0, 255*0.5);
- g->drawtext(XRES-16-textWidth, 16, (const char*)sampleInfo.str().c_str(), 255, 255, 255, 255*0.75);
+ int textWidth = Graphics::textwidth((char*)sampleInfo.str().c_str());
+ g->fillrect(XRES-20-textWidth, 12, textWidth+8, 15, 0, 0, 0, 255*0.5);
+ g->drawtext(XRES-16-textWidth, 16, (const char*)sampleInfo.str().c_str(), 255, 255, 255, 255*0.75);
- //FPS and some version info
+ //FPS and some version info
#ifndef DEBUG //In debug mode, the Engine will draw FPS and other info instead
- std::stringstream fpsInfo;
- fpsInfo.precision(2);
+ std::stringstream fpsInfo;
+ fpsInfo.precision(2);
#ifdef SNAPSHOT
- fpsInfo << "Snapshot " << SNAPSHOT_ID << ". ";
+ fpsInfo << "Snapshot " << SNAPSHOT_ID << ". ";
#endif
- fpsInfo << "FPS: " << std::fixed << ui::Engine::Ref().GetFps();
+ fpsInfo << "FPS: " << std::fixed << ui::Engine::Ref().GetFps();
- textWidth = Graphics::textwidth((char*)fpsInfo.str().c_str());
- g->fillrect(12, 12, textWidth+8, 15, 0, 0, 0, 255*0.5);
- g->drawtext(16, 16, (const char*)fpsInfo.str().c_str(), 32, 216, 255, 255*0.75);
+ textWidth = Graphics::textwidth((char*)fpsInfo.str().c_str());
+ g->fillrect(12, 12, textWidth+8, 15, 0, 0, 0, 255*0.5);
+ g->drawtext(16, 16, (const char*)fpsInfo.str().c_str(), 32, 216, 255, 255*0.75);
#endif
+ }
//Tooltips
if(infoTipPresence)