diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-08-09 20:28:43 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-08-09 20:28:43 (GMT) |
| commit | b01b0e422a7486a4d1063b54a3c9713e2c1456c4 (patch) | |
| tree | 25b30ca04673b1b7e54190c918388bce6d5e149b /src | |
| parent | 9971ea63b7aca6f23dfdee9ceb5d7cb3dcd1fa58 (diff) | |
| download | powder-b01b0e422a7486a4d1063b54a3c9713e2c1456c4.zip powder-b01b0e422a7486a4d1063b54a3c9713e2c1456c4.tar.gz | |
HUD verbose sample info with 'd', fixes #71
Diffstat (limited to 'src')
| -rw-r--r-- | src/game/GameView.cpp | 45 | ||||
| -rw-r--r-- | src/game/GameView.h | 1 | ||||
| -rw-r--r-- | src/simulation/Sample.h | 4 | ||||
| -rw-r--r-- | src/simulation/Simulation.cpp | 10 |
4 files changed, 54 insertions, 6 deletions
diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index 65c0ddd..9b1010d 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -172,6 +172,7 @@ GameView::GameView(): shiftBehaviour(false), ctrlBehaviour(false), showHud(true), + showDebug(false), introText(2048), introTextMessage(introTextData) { @@ -1182,6 +1183,9 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool case 'f': c->FrameStep(); break; + case 'd': + showDebug = !showDebug; + break; case KEY_F1: if(!introText) introText = 8047; @@ -1705,16 +1709,49 @@ void GameView::OnDraw() std::stringstream sampleInfo; sampleInfo.precision(2); if(sample.particle.type) - sampleInfo << c->ElementResolve(sample.particle.type) << ", Temp: " << std::fixed << sample.particle.temp -273.15f; + { + if(showDebug) + { + sampleInfo << c->ElementResolve(sample.particle.type); + if(sample.particle.ctype > 0 && sample.particle.ctype < PT_NUM) + { + sampleInfo << " (" << c->ElementResolve(sample.particle.ctype) << ")"; + } + sampleInfo << ", Pressure: " << std::fixed << sample.AirPressure; + sampleInfo << ", Temp: " << std::fixed << sample.particle.temp -273.15f; + sampleInfo << ", Life: " << sample.particle.life; + sampleInfo << ", Temp: " << sample.particle.tmp; + } + else + { + sampleInfo << c->ElementResolve(sample.particle.type) << ", Pressure: " << std::fixed << sample.AirPressure; + sampleInfo << ", Temp: " << std::fixed << sample.particle.temp -273.15f; + } + } else - sampleInfo << "Empty"; - - sampleInfo << ", Pressure: " << std::fixed << sample.AirPressure; + { + sampleInfo << "Empty, 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); + if(showDebug) + { + sampleInfo.str(std::string()); + + if(sample.particle.type) + { + sampleInfo << "#" << sample.ParticleID << ", "; + } + sampleInfo << "X:" << sample.PositionX << " Y:" << sample.PositionY; + + textWidth = Graphics::textwidth((char*)sampleInfo.str().c_str()); + g->fillrect(XRES-20-textWidth, 26, textWidth+8, 15, 0, 0, 0, 255*0.5); + g->drawtext(XRES-16-textWidth, 30, (const char*)sampleInfo.str().c_str(), 255, 255, 255, 255*0.75); + } + //FPS and some version info #ifndef DEBUG //In debug mode, the Engine will draw FPS and other info instead diff --git a/src/game/GameView.h b/src/game/GameView.h index 9fedb1c..4d1683a 100644 --- a/src/game/GameView.h +++ b/src/game/GameView.h @@ -42,6 +42,7 @@ private: bool ctrlBehaviour; bool altBehaviour; bool showHud; + bool showDebug; int introText; std::string introTextMessage; int toolIndex; diff --git a/src/simulation/Sample.h b/src/simulation/Sample.h index bd91d02..0e67331 100644 --- a/src/simulation/Sample.h +++ b/src/simulation/Sample.h @@ -9,6 +9,8 @@ class SimulationSample { public: Particle particle; + int ParticleID; + int PositionX, PositionY; float AirPressure; float AirTemperature; float AirVelocityX; @@ -19,7 +21,7 @@ public: float GravityVelocityX; float GravityVelocityY; - SimulationSample() : particle(), AirPressure(0), AirVelocityX(0), AirVelocityY(0), WallType(0), Gravity(0), GravityVelocityX(0), GravityVelocityY(0), AirTemperature(0) {} + SimulationSample() : PositionX(0), PositionY(0), ParticleID(0), particle(), AirPressure(0), AirVelocityX(0), AirVelocityY(0), WallType(0), Gravity(0), GravityVelocityX(0), GravityVelocityY(0), AirTemperature(0) {} }; #endif
\ No newline at end of file diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 880d2b1..717eb80 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -351,10 +351,18 @@ int Simulation::flood_prop(int x, int y, size_t propoffset, void * propvalue, St SimulationSample Simulation::Get(int x, int y) { SimulationSample sample; + sample.PositionX = x; + sample.PositionY = y; if(pmap[y][x]) + { sample.particle = parts[pmap[y][x]>>8]; - if(photons[y][x]) + sample.ParticleID = pmap[y][x]>>8; + } + else if(photons[y][x]) + { sample.particle = parts[photons[y][x]>>8]; + sample.ParticleID = photons[y][x]>>8; + } sample.AirPressure = pv[y/CELL][x/CELL]; sample.AirTemperature = hv[y/CELL][x/CELL]; sample.AirVelocityX = vx[y/CELL][x/CELL]; |
