fix tpt.selectedl/r/a, but it returns the string identifier now instead of an id
This commit is contained in:
parent
986173af4c
commit
158b054023
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
class GameModel;
|
class GameModel;
|
||||||
class GameController;
|
class GameController;
|
||||||
|
class Tool;
|
||||||
class CommandInterface {
|
class CommandInterface {
|
||||||
protected:
|
protected:
|
||||||
std::string lastError;
|
std::string lastError;
|
||||||
@ -28,6 +29,7 @@ public:
|
|||||||
void Log(LogType type, std::string message);
|
void Log(LogType type, std::string message);
|
||||||
//void AttachGameModel(GameModel * m);
|
//void AttachGameModel(GameModel * m);
|
||||||
virtual bool OnBrushChanged(int brushType, int rx, int ry) {return true;}
|
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 OnMouseMove(int x, int y, int dx, int dy) {return true;}
|
||||||
virtual bool OnMouseDown(int x, int y, unsigned button) {return true;}
|
virtual bool OnMouseDown(int x, int y, unsigned button) {return true;}
|
||||||
virtual bool OnMouseUp(int x, int y, unsigned button) {return true;}
|
virtual bool OnMouseUp(int x, int y, unsigned button) {return true;}
|
||||||
|
@ -535,18 +535,20 @@ int luacon_mouseevent(int mx, int my, int mb, int event, int mouse_wheel){
|
|||||||
return mpcontinue;
|
return mpcontinue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int luacon_step(int mx, int my, int selectl, int selectr, int bsx, int bsy){
|
int luacon_step(int mx, int my, std::string selectl, std::string selectr, std::string selectalt, int bsx, int bsy){
|
||||||
int tempret = 0, tempb, i, callret;
|
int tempret = 0, tempb, i, callret;
|
||||||
lua_pushinteger(luacon_ci->l, bsy);
|
lua_pushinteger(luacon_ci->l, bsy);
|
||||||
lua_pushinteger(luacon_ci->l, bsx);
|
lua_pushinteger(luacon_ci->l, bsx);
|
||||||
lua_pushinteger(luacon_ci->l, selectr);
|
lua_pushstring(luacon_ci->l, selectalt.c_str());
|
||||||
lua_pushinteger(luacon_ci->l, selectl);
|
lua_pushstring(luacon_ci->l, selectr.c_str());
|
||||||
|
lua_pushstring(luacon_ci->l, selectl.c_str());
|
||||||
lua_pushinteger(luacon_ci->l, my);
|
lua_pushinteger(luacon_ci->l, my);
|
||||||
lua_pushinteger(luacon_ci->l, mx);
|
lua_pushinteger(luacon_ci->l, mx);
|
||||||
lua_setfield(luacon_ci->l, tptProperties, "mousex");
|
lua_setfield(luacon_ci->l, tptProperties, "mousex");
|
||||||
lua_setfield(luacon_ci->l, tptProperties, "mousey");
|
lua_setfield(luacon_ci->l, tptProperties, "mousey");
|
||||||
lua_setfield(luacon_ci->l, tptProperties, "selectedl");
|
lua_setfield(luacon_ci->l, tptProperties, "selectedl");
|
||||||
lua_setfield(luacon_ci->l, tptProperties, "selectedr");
|
lua_setfield(luacon_ci->l, tptProperties, "selectedr");
|
||||||
|
lua_setfield(luacon_ci->l, tptProperties, "selecteda");
|
||||||
lua_setfield(luacon_ci->l, tptProperties, "brushx");
|
lua_setfield(luacon_ci->l, tptProperties, "brushx");
|
||||||
lua_setfield(luacon_ci->l, tptProperties, "brushy");
|
lua_setfield(luacon_ci->l, tptProperties, "brushy");
|
||||||
for(i = 0; i<6; i++){
|
for(i = 0; i<6; i++){
|
||||||
|
@ -31,7 +31,7 @@ extern int tptElements; //Table for TPT element names
|
|||||||
extern int tptParts, tptPartsMeta, tptElementTransitions, tptPartsCData, tptPartMeta, tptPart, cIndex;
|
extern int tptParts, tptPartsMeta, tptElementTransitions, tptPartsCData, tptPartMeta, tptPart, cIndex;
|
||||||
|
|
||||||
void luacon_hook(lua_State *L, lua_Debug *ar);
|
void luacon_hook(lua_State *L, lua_Debug *ar);
|
||||||
int luacon_step(int mx, int my, int selectl, int selectr, int bsx, int bsy);
|
int luacon_step(int mx, int my, std::string , std::string selectr, std::string selectedalt, int bsx, int bsy);
|
||||||
int luacon_mouseevent(int mx, int my, int mb, int event, int mouse_wheel);
|
int luacon_mouseevent(int mx, int my, int mb, int event, int mouse_wheel);
|
||||||
int luacon_keyevent(int key, int modifier, int event);
|
int luacon_keyevent(int key, int modifier, int event);
|
||||||
int luacon_eval(char *command);
|
int luacon_eval(char *command);
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "dialogues/ConfirmPrompt.h"
|
#include "dialogues/ConfirmPrompt.h"
|
||||||
#include "simulation/Simulation.h"
|
#include "simulation/Simulation.h"
|
||||||
#include "game/GameModel.h"
|
#include "game/GameModel.h"
|
||||||
|
#include "game/Tool.h"
|
||||||
#include "LuaScriptHelper.h"
|
#include "LuaScriptHelper.h"
|
||||||
#include "client/HTTP.h"
|
#include "client/HTTP.h"
|
||||||
|
|
||||||
@ -78,7 +79,16 @@ int tptParts, tptPartsMeta, tptElementTransitions, tptPartsCData, tptPartMeta, t
|
|||||||
LuaScriptInterface::LuaScriptInterface(GameController * c, GameModel * m):
|
LuaScriptInterface::LuaScriptInterface(GameController * c, GameModel * m):
|
||||||
CommandInterface(c, m),
|
CommandInterface(c, m),
|
||||||
currentCommand(false),
|
currentCommand(false),
|
||||||
legacy(new TPTScriptInterface(c, m))
|
legacy(new TPTScriptInterface(c, m)),
|
||||||
|
luacon_mousex(0),
|
||||||
|
luacon_mousey(0),
|
||||||
|
luacon_mousebutton(0),
|
||||||
|
luacon_brushx(0),
|
||||||
|
luacon_brushy(0),
|
||||||
|
luacon_selectedl(""),
|
||||||
|
luacon_selectedr(""),
|
||||||
|
luacon_selectedalt(""),
|
||||||
|
luacon_mousedown(false)
|
||||||
{
|
{
|
||||||
luacon_model = m;
|
luacon_model = m;
|
||||||
luacon_sim = m->GetSimulation();
|
luacon_sim = m->GetSimulation();
|
||||||
@ -190,10 +200,12 @@ LuaScriptInterface::LuaScriptInterface(GameController * c, GameModel * m):
|
|||||||
lua_setfield(l, tptProperties, "mousex");
|
lua_setfield(l, tptProperties, "mousex");
|
||||||
lua_pushinteger(l, 0);
|
lua_pushinteger(l, 0);
|
||||||
lua_setfield(l, tptProperties, "mousey");
|
lua_setfield(l, tptProperties, "mousey");
|
||||||
lua_pushinteger(l, 0);
|
lua_pushstring(l, "");
|
||||||
lua_setfield(l, tptProperties, "selectedl");
|
lua_setfield(l, tptProperties, "selectedl");
|
||||||
lua_pushinteger(l, 0);
|
lua_pushstring(l, "");
|
||||||
lua_setfield(l, tptProperties, "selectedr");
|
lua_setfield(l, tptProperties, "selectedr");
|
||||||
|
lua_pushstring(l, "");
|
||||||
|
lua_setfield(l, tptProperties, "selecteda");
|
||||||
|
|
||||||
lua_newtable(l);
|
lua_newtable(l);
|
||||||
tptPropertiesVersion = lua_gettop(l);
|
tptPropertiesVersion = lua_gettop(l);
|
||||||
@ -1621,6 +1633,17 @@ bool LuaScriptInterface::OnBrushChanged(int brushType, int rx, int ry)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LuaScriptInterface::OnActiveToolChanged(int toolSelection, Tool * tool)
|
||||||
|
{
|
||||||
|
if (toolSelection == 0)
|
||||||
|
luacon_selectedl = tool->GetIdentifier();
|
||||||
|
else if (toolSelection == 1)
|
||||||
|
luacon_selectedr = tool->GetIdentifier();
|
||||||
|
else if (toolSelection == 2)
|
||||||
|
luacon_selectedalt = tool->GetIdentifier();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool LuaScriptInterface::OnMouseMove(int x, int y, int dx, int dy)
|
bool LuaScriptInterface::OnMouseMove(int x, int y, int dx, int dy)
|
||||||
{
|
{
|
||||||
luacon_mousex = x;
|
luacon_mousex = x;
|
||||||
@ -1675,7 +1698,7 @@ void LuaScriptInterface::OnTick()
|
|||||||
ui::Engine::Ref().LastTick(clock());
|
ui::Engine::Ref().LastTick(clock());
|
||||||
if(luacon_mousedown)
|
if(luacon_mousedown)
|
||||||
luacon_mouseevent(luacon_mousex, luacon_mousey, luacon_mousebutton, LUACON_MPRESS, 0);
|
luacon_mouseevent(luacon_mousex, luacon_mousey, luacon_mousebutton, LUACON_MPRESS, 0);
|
||||||
luacon_step(luacon_mousex, luacon_mousey, luacon_selectedl, luacon_selectedr, luacon_brushx, luacon_brushy);
|
luacon_step(luacon_mousex, luacon_mousey, luacon_selectedl, luacon_selectedr, luacon_selectedalt, luacon_brushx, luacon_brushy);
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaScriptInterface::Command(std::string command)
|
int LuaScriptInterface::Command(std::string command)
|
||||||
|
@ -27,7 +27,7 @@ namespace pim
|
|||||||
{
|
{
|
||||||
class VirtualMachine;
|
class VirtualMachine;
|
||||||
}
|
}
|
||||||
|
class Tool;
|
||||||
|
|
||||||
//Because lua only has bindings for C, we're going to have to go outside "outside" the LuaScriptInterface, this means we can only have one instance :(
|
//Because lua only has bindings for C, we're going to have to go outside "outside" the LuaScriptInterface, this means we can only have one instance :(
|
||||||
|
|
||||||
@ -47,7 +47,8 @@ namespace pim
|
|||||||
class TPTScriptInterface;
|
class TPTScriptInterface;
|
||||||
class LuaScriptInterface: public CommandInterface
|
class LuaScriptInterface: public CommandInterface
|
||||||
{
|
{
|
||||||
int luacon_mousex, luacon_mousey, luacon_selectedl, luacon_selectedr, luacon_mousebutton, luacon_brushx, luacon_brushy;
|
int luacon_mousex, luacon_mousey, luacon_mousebutton, luacon_brushx, luacon_brushy;
|
||||||
|
std::string luacon_selectedl, luacon_selectedr, luacon_selectedalt;
|
||||||
bool luacon_mousedown;
|
bool luacon_mousedown;
|
||||||
bool currentCommand;
|
bool currentCommand;
|
||||||
TPTScriptInterface * legacy;
|
TPTScriptInterface * legacy;
|
||||||
@ -110,6 +111,7 @@ public:
|
|||||||
lua_State *l;
|
lua_State *l;
|
||||||
LuaScriptInterface(GameController * c, GameModel * m);
|
LuaScriptInterface(GameController * c, GameModel * m);
|
||||||
virtual bool OnBrushChanged(int brushType, int rx, int ry);
|
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 OnMouseMove(int x, int y, int dx, int dy);
|
||||||
virtual bool OnMouseDown(int x, int y, unsigned button);
|
virtual bool OnMouseDown(int x, int y, unsigned button);
|
||||||
virtual bool OnMouseUp(int x, int y, unsigned button);
|
virtual bool OnMouseUp(int x, int y, unsigned button);
|
||||||
|
@ -147,6 +147,11 @@ GameController::GameController():
|
|||||||
commandInterface = new LuaScriptInterface(this, gameModel);//new TPTScriptInterface();
|
commandInterface = new LuaScriptInterface(this, gameModel);//new TPTScriptInterface();
|
||||||
((LuaScriptInterface*)commandInterface)->SetWindow(gameView);
|
((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));
|
||||||
|
|
||||||
//sim = new Simulation();
|
//sim = new Simulation();
|
||||||
Client::Ref().AddListener(this);
|
Client::Ref().AddListener(this);
|
||||||
|
|
||||||
@ -917,6 +922,7 @@ void GameController::SetActiveMenu(Menu * menu)
|
|||||||
|
|
||||||
void GameController::SetActiveTool(int toolSelection, Tool * tool)
|
void GameController::SetActiveTool(int toolSelection, Tool * tool)
|
||||||
{
|
{
|
||||||
|
commandInterface->OnActiveToolChanged(toolSelection, tool);
|
||||||
gameModel->SetActiveTool(toolSelection, tool);
|
gameModel->SetActiveTool(toolSelection, tool);
|
||||||
gameModel->GetRenderer()->gravityZonesEnabled = false;
|
gameModel->GetRenderer()->gravityZonesEnabled = false;
|
||||||
gameModel->SetLastTool(tool);
|
gameModel->SetLastTool(tool);
|
||||||
|
Loading…
Reference in New Issue
Block a user