summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-07-24 13:58:39 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-07-24 13:58:39 (GMT)
commit603cf3149df2fc788303207162bf29e05bd29816 (patch)
tree1e2f9c7ddf3c01a67bc50426806e598a595a1e40 /src
parente65e222f2ccbf60a4c224bbe29884ebb1001cfd7 (diff)
downloadpowder-603cf3149df2fc788303207162bf29e05bd29816.zip
powder-603cf3149df2fc788303207162bf29e05bd29816.tar.gz
HUD improvements
Diffstat (limited to 'src')
-rw-r--r--src/game/GameView.cpp30
-rw-r--r--src/game/GameView.h4
-rw-r--r--src/interface/Engine.cpp2
-rw-r--r--src/interface/Engine.h1
-rw-r--r--src/simulation/Sample.h25
-rw-r--r--src/simulation/Simulation.cpp20
-rw-r--r--src/simulation/Simulation.h3
7 files changed, 72 insertions, 13 deletions
diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp
index ac718c3..6b50d31 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.ctype<PT_NUM)
- sampleInfo << ", Ctype: " << c->ElementResolve(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 4a841c1..ad9e095 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 5f237a9..07c4203 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 9acba62..824f968 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 0000000..bd91d02
--- /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 4a7bede..9aece76 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 d4f43f2..0e6c66f 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);