From bbdbb67079159bf2f73b2ab64f68b630b054b144 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sat, 19 Sep 2015 20:01:53 -0400 Subject: [PATCH] fix tpt.brushx returning incorrect value when brush is updated with tpt.brushID --- src/gui/game/GameController.cpp | 10 ---------- src/gui/game/GameController.h | 1 - src/lua/CommandInterface.h | 1 - src/lua/LuaScriptInterface.cpp | 21 ++++----------------- src/lua/LuaScriptInterface.h | 3 +-- 5 files changed, 5 insertions(+), 31 deletions(-) diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index 68e7d303b..1cbbd0928 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -149,7 +149,6 @@ GameController::GameController(): commandInterface = new TPTScriptInterface(this, gameModel); #endif - commandInterface->OnBrushChanged(gameModel->GetBrushID(), gameModel->GetBrush()->GetRadius().X, gameModel->GetBrush()->GetRadius().X); ActiveToolChanged(0, gameModel->GetActiveTool(0)); ActiveToolChanged(1, gameModel->GetActiveTool(1)); ActiveToolChanged(2, gameModel->GetActiveTool(2)); @@ -356,14 +355,11 @@ void GameController::AdjustBrushSize(int direction, bool logarithmic, bool xAxis gameModel->GetBrush()->SetRadius(ui::Point(oldSize.X, newSize.Y)); else gameModel->GetBrush()->SetRadius(newSize); - - BrushChanged(gameModel->GetBrushID(), gameModel->GetBrush()->GetRadius().X, gameModel->GetBrush()->GetRadius().Y); } void GameController::SetBrushSize(ui::Point newSize) { gameModel->GetBrush()->SetRadius(newSize); - BrushChanged(gameModel->GetBrushID(), gameModel->GetBrush()->GetRadius().X, gameModel->GetBrush()->GetRadius().Y); } void GameController::AdjustZoomSize(int direction, bool logarithmic) @@ -576,11 +572,6 @@ bool GameController::MouseMove(int x, int y, int dx, int dy) return commandInterface->OnMouseMove(x, y, dx, dy); } -bool GameController::BrushChanged(int brushType, int rx, int ry) -{ - return commandInterface->OnBrushChanged(brushType, rx, ry); -} - bool GameController::MouseDown(int x, int y, unsigned button) { bool ret = commandInterface->OnMouseDown(x, y, button); @@ -1414,7 +1405,6 @@ void GameController::Vote(int direction) void GameController::ChangeBrush() { gameModel->SetBrushID(gameModel->GetBrushID()+1); - BrushChanged(gameModel->GetBrushID(), gameModel->GetBrush()->GetRadius().X, gameModel->GetBrush()->GetRadius().Y); } void GameController::ClearSim() diff --git a/src/gui/game/GameController.h b/src/gui/game/GameController.h index fa2af8fe3..32ad035a2 100644 --- a/src/gui/game/GameController.h +++ b/src/gui/game/GameController.h @@ -59,7 +59,6 @@ public: GameView * GetView(); sign * GetSignAt(int x, int y); - bool BrushChanged(int brushType, int rx, int ry); bool MouseMove(int x, int y, int dx, int dy); bool MouseDown(int x, int y, unsigned button); bool MouseUp(int x, int y, unsigned button); diff --git a/src/lua/CommandInterface.h b/src/lua/CommandInterface.h index bb715135e..ffcfedd72 100644 --- a/src/lua/CommandInterface.h +++ b/src/lua/CommandInterface.h @@ -21,7 +21,6 @@ public: int GetParticleType(std::string type); void Log(LogType type, std::string message); //void AttachGameModel(GameModel * m); - virtual bool OnBrushChanged(int brushType, int rx, int ry) {return true;} virtual bool OnActiveToolChanged(int toolSelection, Tool * tool) {return true;} virtual bool OnMouseMove(int x, int y, int dx, int dy) {return true;} virtual bool OnMouseDown(int x, int y, unsigned button) {return true;} diff --git a/src/lua/LuaScriptInterface.cpp b/src/lua/LuaScriptInterface.cpp index 263479af0..d0f7ef2cb 100644 --- a/src/lua/LuaScriptInterface.cpp +++ b/src/lua/LuaScriptInterface.cpp @@ -92,8 +92,6 @@ LuaScriptInterface::LuaScriptInterface(GameController * c, GameModel * m): luacon_mousex(0), luacon_mousey(0), luacon_mousebutton(0), - luacon_brushx(0), - luacon_brushy(0), luacon_selectedl(""), luacon_selectedr(""), luacon_selectedalt(""), @@ -380,9 +378,9 @@ int LuaScriptInterface::tpt_index(lua_State *l) if (!key.compare("selectedreplace")) return lua_pushstring(l, luacon_selectedreplace.c_str()), 1; if (!key.compare("brushx")) - return lua_pushnumber(l, luacon_brushx), 1; + return lua_pushnumber(l, m->GetBrush()->GetRadius().X), 1; if (!key.compare("brushy")) - return lua_pushnumber(l, luacon_brushy), 1; + return lua_pushnumber(l, m->GetBrush()->GetRadius().Y), 1; if (!key.compare("brushID")) return lua_pushnumber(l, m->GetBrushID()), 1; @@ -426,14 +424,11 @@ int LuaScriptInterface::tpt_newIndex(lua_State *l) luaL_error(l, "Invalid tool identifier: %s", lua_tostring(l, 3)); } else if (!key.compare("brushx")) - c->SetBrushSize(ui::Point(luaL_checkinteger(l, 3), luacon_brushy)); + c->SetBrushSize(ui::Point(luaL_checkinteger(l, 3), m->GetBrush()->GetRadius().Y)); else if (!key.compare("brushy")) - c->SetBrushSize(ui::Point(luacon_brushx, luaL_checkinteger(l, 3))); + c->SetBrushSize(ui::Point(m->GetBrush()->GetRadius().X, luaL_checkinteger(l, 3))); else if (!key.compare("brushID")) - { m->SetBrushID(luaL_checkinteger(l, 3)); - c->BrushChanged(m->GetBrushID(), luacon_brushx, luacon_brushy); - } else { //if not a special key, set a value in the table @@ -3191,14 +3186,6 @@ int LuaScriptInterface::platform_clipboardPaste(lua_State * l) return 0; } - -bool LuaScriptInterface::OnBrushChanged(int brushType, int rx, int ry) -{ - luacon_brushx = rx; - luacon_brushy = ry; - return true; -} - bool LuaScriptInterface::OnActiveToolChanged(int toolSelection, Tool * tool) { std::string identifier; diff --git a/src/lua/LuaScriptInterface.h b/src/lua/LuaScriptInterface.h index ccd344958..091d8f934 100644 --- a/src/lua/LuaScriptInterface.h +++ b/src/lua/LuaScriptInterface.h @@ -34,7 +34,7 @@ class Tool; class TPTScriptInterface; class LuaScriptInterface: public CommandInterface { - int luacon_mousex, luacon_mousey, luacon_mousebutton, luacon_brushx, luacon_brushy; + int luacon_mousex, luacon_mousey, luacon_mousebutton; std::string luacon_selectedl, luacon_selectedr, luacon_selectedalt, luacon_selectedreplace; bool luacon_mousedown; bool currentCommand; @@ -168,7 +168,6 @@ public: ui::Window * Window; lua_State *l; LuaScriptInterface(GameController * c, GameModel * m); - virtual bool OnBrushChanged(int brushType, int rx, int ry); virtual bool OnActiveToolChanged(int toolSelection, Tool * tool); virtual bool OnMouseMove(int x, int y, int dx, int dy); virtual bool OnMouseDown(int x, int y, unsigned button);