mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-03-15 03:39:56 +01:00
Add sim.historyRestore and sim.historyForward
This commit is contained in:
parent
81bd1fd9e7
commit
952c3a6975
@ -164,11 +164,11 @@ GameController::~GameController()
|
||||
}
|
||||
}
|
||||
|
||||
void GameController::HistoryRestore()
|
||||
bool GameController::HistoryRestore()
|
||||
{
|
||||
if (!gameModel->HistoryCanRestore())
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
// * When undoing for the first time since the last call to HistorySnapshot, save the current state.
|
||||
// Ctrl+Y needs this in order to bring you back to the point right before your last Ctrl+Z, because
|
||||
@ -182,6 +182,8 @@ void GameController::HistoryRestore()
|
||||
auto ¤t = *gameModel->HistoryCurrent();
|
||||
gameModel->GetSimulation()->Restore(current);
|
||||
Client::Ref().OverwriteAuthorInfo(current.Authors);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GameController::HistorySnapshot()
|
||||
@ -192,11 +194,11 @@ void GameController::HistorySnapshot()
|
||||
gameModel->HistoryPush(gameModel->GetSimulation()->CreateSnapshot());
|
||||
}
|
||||
|
||||
void GameController::HistoryForward()
|
||||
bool GameController::HistoryForward()
|
||||
{
|
||||
if (!gameModel->HistoryCanForward())
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
gameModel->HistoryForward();
|
||||
// * If gameModel has nothing more to give, we've Ctrl+Y'd our way back to the original
|
||||
@ -208,6 +210,8 @@ void GameController::HistoryForward()
|
||||
{
|
||||
beforeRestore.reset();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
GameView * GameController::GetView()
|
||||
|
@ -87,9 +87,9 @@ public:
|
||||
|
||||
void Install();
|
||||
|
||||
void HistoryRestore();
|
||||
bool HistoryRestore();
|
||||
void HistorySnapshot();
|
||||
void HistoryForward();
|
||||
bool HistoryForward();
|
||||
|
||||
void AdjustGridSize(int direction);
|
||||
void InvertAirSim();
|
||||
|
@ -935,6 +935,8 @@ void LuaScriptInterface::initSimulationAPI()
|
||||
{"framerender", simulation_framerender},
|
||||
{"gspeed", simulation_gspeed},
|
||||
{"takeSnapshot", simulation_takeSnapshot},
|
||||
{"historyRestore", simulation_historyRestore},
|
||||
{"historyForward", simulation_historyForward},
|
||||
{"replaceModeFlags", simulation_replaceModeFlags},
|
||||
{"listCustomGol", simulation_listCustomGol},
|
||||
{"addCustomGol", simulation_addCustomGol},
|
||||
@ -2399,6 +2401,21 @@ int LuaScriptInterface::simulation_takeSnapshot(lua_State * l)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int LuaScriptInterface::simulation_historyRestore(lua_State *l)
|
||||
{
|
||||
bool successful = luacon_controller->HistoryRestore();
|
||||
lua_pushboolean(l, successful);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int LuaScriptInterface::simulation_historyForward(lua_State *l)
|
||||
{
|
||||
bool successful = luacon_controller->HistoryForward();
|
||||
lua_pushboolean(l, successful);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int LuaScriptInterface::simulation_replaceModeFlags(lua_State *l)
|
||||
{
|
||||
if (lua_gettop(l) == 0)
|
||||
|
@ -115,6 +115,8 @@ class LuaScriptInterface: public CommandInterface
|
||||
static int simulation_framerender(lua_State * l);
|
||||
static int simulation_gspeed(lua_State * l);
|
||||
static int simulation_takeSnapshot(lua_State *l);
|
||||
static int simulation_historyRestore(lua_State *l);
|
||||
static int simulation_historyForward(lua_State *l);
|
||||
static int simulation_replaceModeFlags(lua_State *l);
|
||||
static int simulation_listCustomGol(lua_State *l);
|
||||
static int simulation_addCustomGol(lua_State *l);
|
||||
|
Loading…
x
Reference in New Issue
Block a user