From b16524292e2d8c640e0e4e0801d5cb4e512e4707 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Fri, 31 May 2013 19:53:32 -0400 Subject: [PATCH] fix bug where you had to start using a tool before setting it's strength --- src/cat/LuaScriptInterface.cpp | 2 +- src/gui/game/GameModel.cpp | 13 +++++---- src/gui/game/GameView.cpp | 48 ++++++++++++++++++---------------- src/gui/game/GameView.h | 1 + 4 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index cea5e76c9..452a14c9e 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -1473,7 +1473,7 @@ int LuaScriptInterface::simulation_ambientAirTemp(lua_State * l) lua_pushnumber(l, luacon_sim->air->ambientAirTemp); return 1; } - int ambientAirTemp = luaL_optint(l, 1, -1); + int ambientAirTemp = luaL_optint(l, 1, 295.15f); luacon_sim->air->ambientAirTemp = ambientAirTemp; return 0; } diff --git a/src/gui/game/GameModel.cpp b/src/gui/game/GameModel.cpp index 59250791d..363f275f7 100644 --- a/src/gui/game/GameModel.cpp +++ b/src/gui/game/GameModel.cpp @@ -304,19 +304,18 @@ void GameModel::BuildMenus() //sim->wtypes[i] } - //Add special sign and prop tools - menuList[SC_TOOL]->AddTool(new SampleTool(this)); - menuList[SC_TOOL]->AddTool(new SignTool()); - menuList[SC_TOOL]->AddTool(new PropertyTool()); - menuList[SC_TOOL]->AddTool(new WindTool(0, "WIND", "Create air movement", 64, 64, 64, "DEFAULT_UI_WIND")); - - //Build menu for simtools + //Build menu for tools for(int i = 0; i < sim->tools.size(); i++) { Tool * tempTool; tempTool = new Tool(i, sim->tools[i]->Name, sim->tools[i]->Description, PIXR(sim->tools[i]->Colour), PIXG(sim->tools[i]->Colour), PIXB(sim->tools[i]->Colour), sim->tools[i]->Identifier); menuList[SC_TOOL]->AddTool(tempTool); } + //Add special sign and prop tools + menuList[SC_TOOL]->AddTool(new WindTool(0, "WIND", "Create air movement", 64, 64, 64, "DEFAULT_UI_WIND")); + menuList[SC_TOOL]->AddTool(new PropertyTool()); + menuList[SC_TOOL]->AddTool(new SignTool()); + menuList[SC_TOOL]->AddTool(new SampleTool(this)); //Add decoration tools to menu menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendAdd, "ADD", "Colour blending: Add", 0, 0, 0, "DEFAULT_DECOR_ADD")); diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index 204455384..6a37551b3 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -182,6 +182,7 @@ GameView::GameView(): introText(2048), introTextMessage(introTextData), wallBrush(false), + toolBrush(false), doScreenshot(false), recording(false), screenshotIndex(0), @@ -642,13 +643,14 @@ void GameView::NotifyActiveToolsChanged(GameModel * sender) void GameView::NotifyLastToolChanged(GameModel * sender) { if(sender->GetLastTool() && sender->GetLastTool()->GetResolution() == CELL) - { wallBrush = true; - } else - { wallBrush = false; - } + + if (sender->GetLastTool() && sender->GetLastTool()->GetIdentifier().find("DEFAULT_TOOL_") != sender->GetLastTool()->GetIdentifier().npos) + toolBrush = true; + else + toolBrush = false; } void GameView::NotifyToolListChanged(GameModel * sender) @@ -1280,10 +1282,13 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool drawModeReset = false; else drawPoint1 = currentMouse; - if(shift) - drawMode = DrawFill; - else - drawMode = DrawRect; + if (!toolBrush) + { + if(shift) + drawMode = DrawFill; + else + drawMode = DrawRect; + } } enableCtrlBehaviour(); break; @@ -1294,10 +1299,13 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool drawModeReset = false; else drawPoint1 = currentMouse; - if(ctrl) - drawMode = DrawFill; - else - drawMode = DrawLine; + if (!toolBrush) + { + if(ctrl) + drawMode = DrawFill; + else + drawMode = DrawLine; + } } enableShiftBehaviour(); break; @@ -1758,10 +1766,7 @@ void GameView::enableShiftBehaviour() if(!shiftBehaviour) { shiftBehaviour = true; - if(isMouseDown) - { - c->SetToolStrength(10.0f); - } + c->SetToolStrength(10.0f); } } @@ -1806,13 +1811,10 @@ void GameView::enableCtrlBehaviour() searchButton->Appearance.TextInactive = searchButton->Appearance.TextHover = ui::Colour(0, 0, 0); if (currentSaveType == 2) ((SplitButton*)saveSimulationButton)->SetShowSplit(true); - if(isMouseDown) - { - if(!shiftBehaviour) - c->SetToolStrength(.1f); - else - c->SetToolStrength(10.0f); - } + if(!shiftBehaviour) + c->SetToolStrength(.1f); + else + c->SetToolStrength(10.0f); } } diff --git a/src/gui/game/GameView.h b/src/gui/game/GameView.h index 08709df2e..a34729721 100644 --- a/src/gui/game/GameView.h +++ b/src/gui/game/GameView.h @@ -50,6 +50,7 @@ private: bool showHud; bool showDebug; bool wallBrush; + bool toolBrush; int introText; std::string introTextMessage; int toolIndex;