diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index ac718c3ec..6b50d3190 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -375,7 +375,7 @@ void GameView::NotifyMenuListChanged(GameModel * sender) } } -void GameView::SetSample(Particle sample) +void GameView::SetSample(SimulationSample sample) { this->sample = sample; } @@ -1251,18 +1251,36 @@ void GameView::OnDraw() } } + //Draw info about simulation under cursor std::stringstream sampleInfo; sampleInfo.precision(2); - if(sample.type) - sampleInfo << c->ElementResolve(sample.type) << ", Temp: " << std::fixed << sample.temp -273.15f; + if(sample.particle.type) + sampleInfo << c->ElementResolve(sample.particle.type) << ", Temp: " << std::fixed << sample.particle.temp -273.15f; else sampleInfo << "Empty"; - if(sample.ctype && sample.ctype>0 && sample.ctypeElementResolve(sample.ctype); + sampleInfo << ", Pressure: " << std::fixed << sample.AirPressure; - g->drawtext(XRES+BARSIZE-(10+Graphics::textwidth((char*)sampleInfo.str().c_str())), 10, (const char*)sampleInfo.str().c_str(), 255, 255, 255, 255); + 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 +#ifndef DEBUG //In debug mode, the Engine will draw FPS and other info instead + std::stringstream fpsInfo; + fpsInfo.precision(2); +#ifdef SNAPSHOT + fpsInfo << "Snapshot " << SNAPSHOT_ID << ". "; +#endif + fpsInfo << "FPS: " << std::fixed << ui::Engine::Ref().GetFps(); +#endif + + 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); + + //Tooltips if(infoTipPresence) { int infoTipAlpha = (infoTipPresence>50?50:infoTipPresence)*5; diff --git a/src/game/GameView.h b/src/game/GameView.h index 4a841c151..ad9e0951e 100644 --- a/src/game/GameView.h +++ b/src/game/GameView.h @@ -87,7 +87,7 @@ private: Thumbnail * placeSaveThumb; - Particle sample; + SimulationSample sample; int lastOffset; void setToolButtonOffset(int offset); @@ -99,7 +99,7 @@ public: //Breaks MVC, but any other way is going to be more of a mess. ui::Point GetMousePosition(); - void SetSample(Particle sample); + void SetSample(SimulationSample sample); void AttachController(GameController * _c){ c = _c; } void NotifyRendererChanged(GameModel * sender); diff --git a/src/interface/Engine.cpp b/src/interface/Engine.cpp index 5f237a9fd..07c420361 100644 --- a/src/interface/Engine.cpp +++ b/src/interface/Engine.cpp @@ -182,9 +182,11 @@ void Engine::Draw() if(state_) state_->DoDraw(); +#ifdef DEBUG char fpsText[512]; sprintf(fpsText, "FPS: %.2f, Delta: %.3f", fps, dt); ui::Engine::Ref().g->drawtext(10, 10, fpsText, 255, 255, 255, 255); +#endif g->Finalise(); FrameIndex++; FrameIndex %= 7200; diff --git a/src/interface/Engine.h b/src/interface/Engine.h index 9acba620c..824f968d6 100644 --- a/src/interface/Engine.h +++ b/src/interface/Engine.h @@ -41,6 +41,7 @@ namespace ui void Draw(); void SetFps(float fps); + inline float GetFps() { return fps; }; inline int GetMouseX() { return mousex_; } inline int GetMouseY() { return mousey_; } diff --git a/src/simulation/Sample.h b/src/simulation/Sample.h new file mode 100644 index 000000000..bd91d0214 --- /dev/null +++ b/src/simulation/Sample.h @@ -0,0 +1,25 @@ + + +#ifndef The_Powder_Toy_Sample_h +#define The_Powder_Toy_Sample_h + +#include "Particle.h" + +class SimulationSample +{ +public: + Particle particle; + float AirPressure; + float AirTemperature; + float AirVelocityX; + float AirVelocityY; + + int WallType; + float Gravity; + float GravityVelocityX; + float GravityVelocityY; + + SimulationSample() : 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 4a7bede0e..9aece761d 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -340,13 +340,25 @@ int Simulation::flood_prop(int x, int y, size_t propoffset, void * propvalue, St return 0; } -Particle Simulation::Get(int x, int y) +SimulationSample Simulation::Get(int x, int y) { + SimulationSample sample; if(pmap[y][x]) - return parts[pmap[y][x]>>8]; + sample.particle = parts[pmap[y][x]>>8]; if(photons[y][x]) - return parts[photons[y][x]>>8]; - return Particle(); + sample.particle = parts[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]; + sample.AirVelocityY = vy[y/CELL][x/CELL]; + + if(grav->ngrav_enable) + { + sample.Gravity = gravp[(y/CELL)*(XRES/CELL)+(x/CELL)]; + sample.GravityVelocityX = gravx[(y/CELL)*(XRES/CELL)+(x/CELL)]; + sample.GravityVelocityY = gravy[(y/CELL)*(XRES/CELL)+(x/CELL)]; + } + return sample; } #define PMAP_CMP_CONDUCTIVE(pmap, t) (((pmap)&0xFF)==(t) || (((pmap)&0xFF)==PT_SPRK && parts[(pmap)>>8].ctype==(t))) diff --git a/src/simulation/Simulation.h b/src/simulation/Simulation.h index d4f43f2d9..0e6c66f5c 100644 --- a/src/simulation/Simulation.h +++ b/src/simulation/Simulation.h @@ -26,6 +26,7 @@ #include "GOLMenu.h" #include "MenuSection.h" #include "client/GameSave.h" +#include "Sample.h" #define CHANNELS ((int)(MAX_TEMP-73)/100+2) @@ -117,7 +118,7 @@ public: int Load(int x, int y, GameSave * save); GameSave * Save(); GameSave * Save(int x1, int y1, int x2, int y2); - Particle Get(int x, int y); + SimulationSample Get(int x, int y); inline int is_blocking(int t, int x, int y); inline int is_boundary(int pt, int x, int y); inline int find_next_boundary(int pt, int *x, int *y, int dm, int *em);