fix tpt.brushx returning incorrect value when brush is updated with tpt.brushID

This commit is contained in:
jacob1 2015-09-19 20:01:53 -04:00
parent 53501d90de
commit bbdbb67079
5 changed files with 5 additions and 31 deletions

View File

@ -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()

View File

@ -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);

View File

@ -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;}

View File

@ -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;

View File

@ -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);