Remove PreSave and make OnSave take place before data is saved.

This commit is contained in:
hispidence 2023-01-24 19:42:09 +00:00
parent 409cbf41a1
commit 7f13ac0ccd
5 changed files with 3 additions and 15 deletions

View file

@ -3146,9 +3146,8 @@ namespace TEN::Gui
if (GuiIsSelected()) if (GuiIsSelected())
{ {
SoundEffect(SFX_TR4_MENU_CHOOSE, nullptr, SoundEnvironment::Always); SoundEffect(SFX_TR4_MENU_CHOOSE, nullptr, SoundEnvironment::Always);
g_GameScript->PreSave();
SaveGame::Save(SelectedSaveSlot);
g_GameScript->OnSave(); g_GameScript->OnSave();
SaveGame::Save(SelectedSaveSlot);
return true; return true;
} }

View file

@ -63,7 +63,6 @@ public:
virtual void OnStart() = 0; virtual void OnStart() = 0;
virtual void OnLoad() = 0; virtual void OnLoad() = 0;
virtual void OnControlPhase(float dt) = 0; virtual void OnControlPhase(float dt) = 0;
virtual void PreSave() = 0;
virtual void OnSave() = 0; virtual void OnSave() = 0;
virtual void OnEnd() = 0; virtual void OnEnd() = 0;
virtual void ShortenTENCalls() = 0; virtual void ShortenTENCalls() = 0;

View file

@ -28,7 +28,6 @@ static constexpr char ScriptReserved_LevelFunc[] = "LevelFunc";
// Built-in LevelFuncs // Built-in LevelFuncs
static constexpr char ScriptReserved_OnStart[] = "OnStart"; static constexpr char ScriptReserved_OnStart[] = "OnStart";
static constexpr char ScriptReserved_OnLoad[] = "OnLoad"; static constexpr char ScriptReserved_OnLoad[] = "OnLoad";
static constexpr char ScriptReserved_PreSave[] = "PreSave";
static constexpr char ScriptReserved_OnControlPhase[] = "OnControlPhase"; static constexpr char ScriptReserved_OnControlPhase[] = "OnControlPhase";
static constexpr char ScriptReserved_OnSave[] = "OnSave"; static constexpr char ScriptReserved_OnSave[] = "OnSave";
static constexpr char ScriptReserved_OnEnd[] = "OnEnd"; static constexpr char ScriptReserved_OnEnd[] = "OnEnd";

View file

@ -722,12 +722,6 @@ void LogicHandler::OnControlPhase(float dt)
tryCall(name); tryCall(name);
} }
void LogicHandler::PreSave()
{
if (m_preSave.valid())
doCallback(m_preSave);
}
void LogicHandler::OnSave() void LogicHandler::OnSave()
{ {
if(m_onSave.valid()) if(m_onSave.valid())
@ -836,11 +830,10 @@ __The order of loading is as follows:__
5. The control loop, in which `OnControlPhase` will be called once per frame, begins. 5. The control loop, in which `OnControlPhase` will be called once per frame, begins.
@tfield function OnStart Will be called when a level is entered by completing a previous level or by selecting it in the menu. Will not be called when loaded from a saved game. @tfield function OnStart Will be called when a level is entered by completing a previous level or by selecting it in the menu. Will not be called when loaded from a saved game.
@tfield function OnLoad Will be called whenoa saved game is loaded, just *after* data is loaded @tfield function OnLoad Will be called when a saved game is loaded, just *after* data is loaded
@tfield function(float) OnControlPhase Will be called during the game's update loop, @tfield function(float) OnControlPhase Will be called during the game's update loop,
and provides the delta time (a float representing game time since last call) via its argument. and provides the delta time (a float representing game time since last call) via its argument.
@tfield function PreSave Will be called when the player saves the game, just *before* data is saved @tfield function OnSave Will be called when the player saves the game, just *before* data is saved
@tfield function OnSave Will be called when the player saves the game, just *after* data is saved
@tfield function OnEnd Will be called when leaving a level. This includes finishing it, exiting to the menu, or loading a save in a different level. @tfield function OnEnd Will be called when leaving a level. This includes finishing it, exiting to the menu, or loading a save in a different level.
@table LevelFuncs @table LevelFuncs
*/ */
@ -874,7 +867,6 @@ void LogicHandler::InitCallbacks()
assignCB(m_onStart, ScriptReserved_OnStart); assignCB(m_onStart, ScriptReserved_OnStart);
assignCB(m_onLoad, ScriptReserved_OnLoad); assignCB(m_onLoad, ScriptReserved_OnLoad);
assignCB(m_onControlPhase, ScriptReserved_OnControlPhase); assignCB(m_onControlPhase, ScriptReserved_OnControlPhase);
assignCB(m_preSave, ScriptReserved_PreSave);
assignCB(m_onSave, ScriptReserved_OnSave); assignCB(m_onSave, ScriptReserved_OnSave);
assignCB(m_onEnd, ScriptReserved_OnEnd); assignCB(m_onEnd, ScriptReserved_OnEnd);
} }

View file

@ -100,7 +100,6 @@ public:
void OnStart() override; void OnStart() override;
void OnLoad() override; void OnLoad() override;
void OnControlPhase(float dt) override; void OnControlPhase(float dt) override;
void PreSave() override;
void OnSave() override; void OnSave() override;
void OnEnd() override; void OnEnd() override;
}; };