From 1359045b14a455c5ee54a7b066e606a3b76368b0 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Fri, 8 Feb 2013 22:24:34 -0500 Subject: [PATCH] fix tpt.selectedl not updating with sample brush, always put photons[] on top in HUD --- src/game/GameController.cpp | 12 ++++++++---- src/game/GameController.h | 1 + src/game/GameView.cpp | 3 +++ src/game/SampleTool.cpp | 12 ++++++------ src/simulation/Simulation.cpp | 12 ++++++------ 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp index efe37c49d..9e7978b59 100644 --- a/src/game/GameController.cpp +++ b/src/game/GameController.cpp @@ -148,9 +148,9 @@ GameController::GameController(): ((LuaScriptInterface*)commandInterface)->SetWindow(gameView); commandInterface->OnBrushChanged(gameModel->GetBrushID(), gameModel->GetBrush()->GetRadius().X, gameModel->GetBrush()->GetRadius().X); - commandInterface->OnActiveToolChanged(0, gameModel->GetActiveTool(0)); - commandInterface->OnActiveToolChanged(1, gameModel->GetActiveTool(1)); - commandInterface->OnActiveToolChanged(2, gameModel->GetActiveTool(2)); + ActiveToolChanged(0, gameModel->GetActiveTool(0)); + ActiveToolChanged(1, gameModel->GetActiveTool(1)); + ActiveToolChanged(2, gameModel->GetActiveTool(2)); //sim = new Simulation(); Client::Ref().AddListener(this); @@ -930,9 +930,13 @@ std::vector GameController::GetMenuList() return gameModel->GetMenuList(); } -void GameController::SetActiveTool(int toolSelection, Tool * tool) +void GameController::ActiveToolChanged(int toolSelection, Tool *tool) { commandInterface->OnActiveToolChanged(toolSelection, tool); +} + +void GameController::SetActiveTool(int toolSelection, Tool * tool) +{ gameModel->SetActiveTool(toolSelection, tool); gameModel->GetRenderer()->gravityZonesEnabled = false; gameModel->SetLastTool(tool); diff --git a/src/game/GameController.h b/src/game/GameController.h index 4f82243c6..070d39d10 100644 --- a/src/game/GameController.h +++ b/src/game/GameController.h @@ -100,6 +100,7 @@ public: void SetActiveMenu(Menu * menu); std::vector GetMenuList(); void SetActiveTool(int toolSelection, Tool * tool); + void ActiveToolChanged(int toolSelection, Tool *tool); void SetActiveColourPreset(int preset); void SetColour(ui::Colour colour); void SetToolStrength(float value); diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index 5c7d0be6e..3e874e229 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -596,14 +596,17 @@ void GameView::NotifyActiveToolsChanged(GameModel * sender) if(sender->GetActiveTool(0) == tool) { toolButtons[i]->SetSelectionState(0); //Primary + c->ActiveToolChanged(0, tool); } else if(sender->GetActiveTool(1) == tool) { toolButtons[i]->SetSelectionState(1); //Secondary + c->ActiveToolChanged(1, tool); } else if(sender->GetActiveTool(2) == tool) { toolButtons[i]->SetSelectionState(2); //Tertiary + c->ActiveToolChanged(2, tool); } else { diff --git a/src/game/SampleTool.cpp b/src/game/SampleTool.cpp index 296167b3b..bdebee64c 100644 --- a/src/game/SampleTool.cpp +++ b/src/game/SampleTool.cpp @@ -31,16 +31,16 @@ void SampleTool::Draw(Simulation * sim, Brush * brush, ui::Point position) { int particleType = 0; int particleCtype = 0; - if(sim->pmap[position.Y][position.X]) - { - particleType = sim->parts[sim->pmap[position.Y][position.X]>>8].type; - particleCtype = sim->parts[sim->pmap[position.Y][position.X]>>8].ctype; - } - else if(sim->photons[position.Y][position.X]) + if (sim->photons[position.Y][position.X]) { particleType = sim->parts[sim->photons[position.Y][position.X]>>8].type; particleCtype = sim->parts[sim->pmap[position.Y][position.X]>>8].ctype; } + else if (sim->pmap[position.Y][position.X]) + { + particleType = sim->parts[sim->pmap[position.Y][position.X]>>8].type; + particleCtype = sim->parts[sim->pmap[position.Y][position.X]>>8].ctype; + } if(particleType) { diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 1a090f7f9..ad5ed63a3 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -478,16 +478,16 @@ 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]; - sample.ParticleID = pmap[y][x]>>8; - } - else if(photons[y][x]) + if (photons[y][x]) { sample.particle = parts[photons[y][x]>>8]; sample.ParticleID = photons[y][x]>>8; } + else if (pmap[y][x]) + { + sample.particle = parts[pmap[y][x]>>8]; + sample.ParticleID = pmap[y][x]>>8; + } if (bmap[y/CELL][x/CELL]) { sample.WallType = bmap[y/CELL][x/CELL];