Skip to content

Commit

Permalink
fix tpt.brushx returning incorrect value when brush is updated with t…
Browse files Browse the repository at this point in the history
…pt.brushID
  • Loading branch information
jacob1 committed Sep 20, 2015
1 parent 53501d9 commit bbdbb67
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 31 deletions.
10 changes: 0 additions & 10 deletions src/gui/game/GameController.cpp
Expand Up @@ -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));
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion src/gui/game/GameController.h
Expand Up @@ -59,7 +59,6 @@ class GameController: public ClientListener
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);
Expand Down
1 change: 0 additions & 1 deletion src/lua/CommandInterface.h
Expand Up @@ -21,7 +21,6 @@ class CommandInterface {
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;}
Expand Down
21 changes: 4 additions & 17 deletions src/lua/LuaScriptInterface.cpp
Expand Up @@ -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(""),
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/lua/LuaScriptInterface.h
Expand Up @@ -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;
Expand Down Expand Up @@ -168,7 +168,6 @@ class LuaScriptInterface: public CommandInterface
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);
Expand Down

0 comments on commit bbdbb67

Please sign in to comment.