summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2013-06-21 00:29:20 (GMT)
committer jacob1 <jfu614@gmail.com>2013-06-21 00:29:20 (GMT)
commit3aac957e501a2fc5fde868f1fe973c523968357e (patch)
tree08653e5d4338f8b1b444eaa6081bcc2ed45f9427 /src/gui
parentfcff2ecc7fdaf93c39086fa52ae6608982fd509c (diff)
downloadpowder-3aac957e501a2fc5fde868f1fe973c523968357e.zip
powder-3aac957e501a2fc5fde868f1fe973c523968357e.tar.gz
HUD displays the correct name of LIFE particles in the HUD, show mouse position in HUD on the edges of the screen
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/game/GameController.cpp22
-rw-r--r--src/gui/game/GameController.h2
-rw-r--r--src/gui/game/GameView.cpp37
3 files changed, 36 insertions, 25 deletions
diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp
index 385abed..0b0c4d6 100644
--- a/src/gui/game/GameController.cpp
+++ b/src/gui/game/GameController.cpp
@@ -834,12 +834,11 @@ void GameController::LoadRenderPreset(int presetNum)
void GameController::Update()
{
ui::Point pos = gameView->GetMousePosition();
- if(pos.X >= 0 && pos.Y >= 0 && pos.X < XRES && pos.Y < YRES)
- {
- gameModel->GetRenderer()->mousePosX = pos.X;
- gameModel->GetRenderer()->mousePosY = pos.Y;
- gameView->SetSample(gameModel->GetSimulation()->Get(pos.X, pos.Y));
- }
+ gameModel->GetRenderer()->mousePos = PointTranslate(pos);
+ if (pos.X < XRES && pos.Y < YRES)
+ gameView->SetSample(gameModel->GetSimulation()->GetSample(PointTranslate(pos).X, PointTranslate(pos).Y));
+ else
+ gameView->SetSample(gameModel->GetSimulation()->GetSample(pos.X, pos.Y));
gameModel->GetSimulation()->update_particles();
if(renderOptions && renderOptions->HasExited)
@@ -1353,10 +1352,15 @@ void GameController::ReloadSim()
}
}
-std::string GameController::ElementResolve(int type)
+std::string GameController::ElementResolve(int type, int ctype)
{
- if(gameModel && gameModel->GetSimulation() && gameModel->GetSimulation()->elements && type >= 0 && type < PT_NUM)
- return std::string(gameModel->GetSimulation()->elements[type].Name);
+ if(gameModel && gameModel->GetSimulation())
+ {
+ if (type == PT_LIFE && ctype >= 0 && ctype < NGOL && gameModel->GetSimulation()->gmenu)
+ return gameModel->GetSimulation()->gmenu[ctype].name;
+ else if (type >= 0 && type < PT_NUM && gameModel->GetSimulation()->elements)
+ return std::string(gameModel->GetSimulation()->elements[type].Name);
+ }
else
return "";
}
diff --git a/src/gui/game/GameController.h b/src/gui/game/GameController.h
index 09a3713..a037e94 100644
--- a/src/gui/game/GameController.h
+++ b/src/gui/game/GameController.h
@@ -135,7 +135,7 @@ public:
void TransformSave(matrix2d transform);
ui::Point PointTranslate(ui::Point point);
ui::Point NormaliseBlockCoord(ui::Point point);
- std::string ElementResolve(int type);
+ std::string ElementResolve(int type, int ctype);
std::string WallName(int type);
void ResetAir();
diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp
index d84bc41..6746de6 100644
--- a/src/gui/game/GameView.cpp
+++ b/src/gui/game/GameView.cpp
@@ -606,7 +606,7 @@ bool GameView::GetDebugHUD()
ui::Point GameView::GetMousePosition()
{
- return mousePosition;
+ return currentMouse;
}
void GameView::NotifyActiveToolsChanged(GameModel * sender)
@@ -2025,21 +2025,22 @@ void GameView::OnDraw()
sampleInfo.precision(2);
if(sample.particle.type)
{
+ int ctype = sample.particle.ctype;
+ if (sample.particle.type == PT_PIPE || sample.particle.type == PT_PPIP)
+ ctype = sample.particle.tmp&0xFF;
if(showDebug)
{
- int ctype = sample.particle.ctype;
- if (sample.particle.type == PT_PIPE || sample.particle.type == PT_PPIP)
- ctype = sample.particle.tmp;
-
if (sample.particle.type == PT_LAVA && ctype > 0 && ctype < PT_NUM)
- sampleInfo << "Molten " << c->ElementResolve(ctype);
- else if((sample.particle.type == PT_PIPE || sample.particle.type == PT_PPIP) && ctype > 0 && ctype < PT_NUM)
- sampleInfo << c->ElementResolve(sample.particle.type) << " with " << c->ElementResolve(ctype);
+ sampleInfo << "Molten " << c->ElementResolve(ctype, -1);
+ else if ((sample.particle.type == PT_PIPE || sample.particle.type == PT_PPIP) && ctype > 0 && ctype < PT_NUM)
+ sampleInfo << c->ElementResolve(sample.particle.type, -1) << " with " << c->ElementResolve(ctype, (int)sample.particle.pavg[1]);
+ else if (sample.particle.type == PT_LIFE)
+ sampleInfo << c->ElementResolve(sample.particle.type, sample.particle.ctype);
else
{
- sampleInfo << c->ElementResolve(sample.particle.type);
+ sampleInfo << c->ElementResolve(sample.particle.type, sample.particle.ctype);
if(ctype > 0 && ctype < PT_NUM)
- sampleInfo << " (" << c->ElementResolve(ctype) << ")";
+ sampleInfo << " (" << c->ElementResolve(ctype, -1) << ")";
else
sampleInfo << " ()";
}
@@ -2051,11 +2052,13 @@ void GameView::OnDraw()
else
{
if (sample.particle.type == PT_LAVA && sample.particle.ctype > 0 && sample.particle.ctype < PT_NUM)
- sampleInfo << "Molten " << c->ElementResolve(sample.particle.ctype);
- else if((sample.particle.type == PT_PIPE || sample.particle.type == PT_PPIP) && sample.particle.tmp > 0 && sample.particle.tmp < PT_NUM)
- sampleInfo << c->ElementResolve(sample.particle.type) << " with " << c->ElementResolve(sample.particle.tmp);
+ sampleInfo << "Molten " << c->ElementResolve(sample.particle.ctype, -1);
+ else if ((sample.particle.type == PT_PIPE || sample.particle.type == PT_PPIP) && ctype > 0 && ctype < PT_NUM)
+ sampleInfo << c->ElementResolve(sample.particle.type, -1) << " with " << c->ElementResolve(ctype, (int)sample.particle.pavg[1]);
+ else if (sample.particle.type == PT_LIFE)
+ sampleInfo << c->ElementResolve(sample.particle.type, sample.particle.ctype);
else
- sampleInfo << c->ElementResolve(sample.particle.type);
+ sampleInfo << c->ElementResolve(sample.particle.type, sample.particle.ctype);
sampleInfo << ", Temp: " << std::fixed << sample.particle.temp -273.15f;
sampleInfo << ", Pressure: " << std::fixed << sample.AirPressure;
}
@@ -2067,10 +2070,14 @@ void GameView::OnDraw()
sampleInfo << c->WallName(sample.WallType);
sampleInfo << ", Pressure: " << std::fixed << sample.AirPressure;
}
- else
+ else if (sample.isMouseInSim)
{
sampleInfo << "Empty, Pressure: " << std::fixed << sample.AirPressure;
}
+ else
+ {
+ sampleInfo << "Empty";
+ }
int textWidth = Graphics::textwidth((char*)sampleInfo.str().c_str());
g->fillrect(XRES-20-textWidth, 12, textWidth+8, 15, 0, 0, 0, 255*0.5);