diff --git a/src/cat/CommandInterface.cpp b/src/cat/CommandInterface.cpp index 256414173..7c6dd83a0 100644 --- a/src/cat/CommandInterface.cpp +++ b/src/cat/CommandInterface.cpp @@ -11,9 +11,11 @@ #include #include "CommandInterface.h" #include "game/GameModel.h" +#include "game/GameController.h" -CommandInterface::CommandInterface(GameModel * m) { +CommandInterface::CommandInterface(GameController * c, GameModel * m) { this->m = m; + this->c = c; } /*void CommandInterface::AttachGameModel(GameModel * m) diff --git a/src/cat/CommandInterface.h b/src/cat/CommandInterface.h index e89632efd..e6119d3f1 100644 --- a/src/cat/CommandInterface.h +++ b/src/cat/CommandInterface.h @@ -13,14 +13,16 @@ //#include "game/GameModel.h" class GameModel; +class GameController; class CommandInterface { protected: std::string lastError; GameModel * m; + GameController * c; public: enum LogType { LogError, LogWarning, LogNotice }; enum FormatType { FormatInt, FormatString, FormatChar, FormatFloat }; - CommandInterface(GameModel * m); + CommandInterface(GameController * c, GameModel * m); int GetPropertyOffset(std::string key_, FormatType & format); int GetParticleType(std::string type); void Log(LogType type, std::string message); diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index 54e229217..18a988613 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -37,10 +37,10 @@ #endif #include -LuaScriptInterface::LuaScriptInterface(GameModel * m): - CommandInterface(m), +LuaScriptInterface::LuaScriptInterface(GameController * c, GameModel * m): + CommandInterface(c, m), currentCommand(false), - legacy(new TPTScriptInterface(m)) + legacy(new TPTScriptInterface(c, m)) { luacon_model = m; luacon_sim = m->GetSimulation(); diff --git a/src/cat/LuaScriptInterface.h b/src/cat/LuaScriptInterface.h index 37adc6514..b6ebcfe13 100644 --- a/src/cat/LuaScriptInterface.h +++ b/src/cat/LuaScriptInterface.h @@ -67,7 +67,7 @@ class LuaScriptInterface: public CommandInterface { public: ui::Window * Window; lua_State *l; - LuaScriptInterface(GameModel * m); + LuaScriptInterface(GameController * c, GameModel * m); virtual bool OnBrushChanged(int brushType, int rx, int ry); virtual bool OnMouseMove(int x, int y, int dx, int dy); virtual bool OnMouseDown(int x, int y, unsigned button); diff --git a/src/cat/TPTScriptInterface.cpp b/src/cat/TPTScriptInterface.cpp index dc466dbb9..ce7128ff5 100644 --- a/src/cat/TPTScriptInterface.cpp +++ b/src/cat/TPTScriptInterface.cpp @@ -15,7 +15,7 @@ #include "game/GameModel.h" #include "simulation/Air.h" -TPTScriptInterface::TPTScriptInterface(GameModel * m): CommandInterface(m) +TPTScriptInterface::TPTScriptInterface(GameController * c, GameModel * m): CommandInterface(c, m) { } @@ -365,7 +365,7 @@ AnyType TPTScriptInterface::tptS_load(std::deque * words) //Arguments from stack NumberType saveID = eval(words); - throw GeneralException("Function not implemented"); + c->OpenSavePreview(saveID.Value(), 0); return NumberType(0); } diff --git a/src/cat/TPTScriptInterface.h b/src/cat/TPTScriptInterface.h index d451a6cd2..ba37fcddd 100644 --- a/src/cat/TPTScriptInterface.h +++ b/src/cat/TPTScriptInterface.h @@ -22,7 +22,7 @@ protected: AnyType tptS_bubble(std::deque * words); ValueType testType(std::string word); public: - TPTScriptInterface(GameModel * m); + TPTScriptInterface(GameController * c, GameModel * m); virtual void Tick() {} virtual int Command(std::string command); virtual std::string FormatCommand(std::string command); diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp index 910673efa..2c98f877d 100644 --- a/src/game/GameController.cpp +++ b/src/game/GameController.cpp @@ -150,7 +150,7 @@ GameController::GameController(): gameView->AttachController(this); gameModel->AddObserver(gameView); - commandInterface = new LuaScriptInterface(gameModel);//new TPTScriptInterface(); + commandInterface = new LuaScriptInterface(this, gameModel);//new TPTScriptInterface(); ((LuaScriptInterface*)commandInterface)->SetWindow(gameView); //sim = new Simulation();