mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-28 15:57:59 +03:00
Enforce proper convention for the few Lua table constants that didn't use it yet
This commit is contained in:
parent
89d5b74298
commit
acb1bb1518
3 changed files with 85 additions and 63 deletions
|
@ -180,29 +180,29 @@ designer to add calls to <code>OnStart</code>, <code>OnLoad</code>, etc. in thei
|
|||
|
||||
<p>Possible values for <code>point</code>:</p>
|
||||
<pre class="example"><span class="comment">-- These take functions which accept no arguments
|
||||
</span>PRESTART <span class="comment">-- will be called immediately before OnStart
|
||||
</span>POSTSTART <span class="comment">-- will be called immediately after OnStart
|
||||
</span>PRE_START <span class="comment">-- will be called immediately before OnStart
|
||||
</span>POST_START <span class="comment">-- will be called immediately after OnStart
|
||||
</span>
|
||||
PRESAVE <span class="comment">-- will be called immediately before OnSave
|
||||
</span>POSTSAVE <span class="comment">-- will be called immediately after OnSave
|
||||
PRE_SAVE <span class="comment">-- will be called immediately before OnSave
|
||||
</span>POST_SAVE <span class="comment">-- will be called immediately after OnSave
|
||||
</span>
|
||||
PRELOAD <span class="comment">-- will be called immediately before OnLoad
|
||||
</span>POSTLOAD <span class="comment">-- will be called immediately after OnLoad
|
||||
PRE_LOAD <span class="comment">-- will be called immediately before OnLoad
|
||||
</span>POST_LOAD <span class="comment">-- will be called immediately after OnLoad
|
||||
</span>
|
||||
PREFREEZE <span class="comment">-- will be called before entering freeze mode
|
||||
</span>POSTFREEZE <span class="comment">-- will be called immediately after exiting freeze mode
|
||||
PRE_FREEZE <span class="comment">-- will be called before entering freeze mode
|
||||
</span>POST_FREEZE <span class="comment">-- will be called immediately after exiting freeze mode
|
||||
</span>
|
||||
<span class="comment">-- These take a LevelEndReason arg, like OnEnd
|
||||
</span>PREEND <span class="comment">-- will be called immediately before OnEnd
|
||||
</span>POSTEND <span class="comment">-- will be called immediately after OnEnd
|
||||
</span>PRE_END <span class="comment">-- will be called immediately before OnEnd
|
||||
</span>POST_END <span class="comment">-- will be called immediately after OnEnd
|
||||
</span>
|
||||
<span class="comment">-- These take functions which accepts a deltaTime argument
|
||||
</span>PRELOOP <span class="comment">-- will be called in the beginning of game loop
|
||||
</span>POSTLOOP <span class="comment">-- will be called at the end of game loop
|
||||
</span>PRE_LOOP <span class="comment">-- will be called in the beginning of game loop
|
||||
</span>POST_LOOP <span class="comment">-- will be called at the end of game loop
|
||||
</span>
|
||||
<span class="comment">-- These take functions which accepts an objectNumber argument, like OnUseItem
|
||||
</span>PREUSEITEM <span class="comment">-- will be called immediately before OnUseItem
|
||||
</span>POSTUSEITEM <span class="comment">-- will be called immediately after OnUseItem
|
||||
</span>PRE_USE_ITEM <span class="comment">-- will be called immediately before OnUseItem
|
||||
</span>POST_USE_ITEM <span class="comment">-- will be called immediately after OnUseItem
|
||||
</span></pre>
|
||||
<p>The order in which two functions with the same CallbackPoint are called is undefined.
|
||||
i.e. if you register <code>MyFunc</code> and <code>MyFunc2</code> with <code>PRELOOP</code>, both will be called in the beginning of game loop, but there is no guarantee that <code>MyFunc</code> will be called before <code>MyFunc2</code>, or vice-versa.</p>
|
||||
|
@ -279,7 +279,7 @@ SAVE
|
|||
START
|
||||
END
|
||||
LOOP
|
||||
USEITEM
|
||||
USE_ITEM
|
||||
MENU</pre>
|
||||
|
||||
|
||||
|
@ -509,9 +509,9 @@ and provides the delta time (a float representing game time since last call) via
|
|||
|
||||
<p>(EndReason) Will be called when leaving a level. This includes finishing it, exiting to the menu, or loading a save in a different level. It can take an <code>EndReason</code> arg:</p>
|
||||
|
||||
<pre><code>EXITTOTITLE
|
||||
LEVELCOMPLETE
|
||||
LOADGAME
|
||||
<pre><code>EXIT_TO_TITLE
|
||||
LEVEL_COMPLETE
|
||||
LOAD_GAME
|
||||
DEATH
|
||||
OTHER
|
||||
</code></pre>
|
||||
|
|
|
@ -60,35 +60,32 @@ static constexpr char ScriptReserved_DisplayStringSetScale[] = "SetScale";
|
|||
static constexpr char ScriptReserved_DisplayStringSetColor[] = "SetColor";
|
||||
static constexpr char ScriptReserved_DisplaySpriteDraw[] = "Draw";
|
||||
|
||||
static constexpr char ScriptReserved_EndReasonExitToTitle[] = "EXITTOTITLE";
|
||||
static constexpr char ScriptReserved_EndReasonLevelComplete[] = "LEVELCOMPLETE";
|
||||
static constexpr char ScriptReserved_EndReasonLoadGame[] = "LOADGAME";
|
||||
static constexpr char ScriptReserved_EndReasonDeath[] = "DEATH";
|
||||
static constexpr char ScriptReserved_EndReasonExitToTitle[] = "EXIT_TO_TITLE";
|
||||
static constexpr char ScriptReserved_EndReasonLevelComplete[] = "LEVEL_COMPLETE";
|
||||
static constexpr char ScriptReserved_EndReasonLoadGame[] = "LOAD_GAME";
|
||||
static constexpr char ScriptReserved_EndReasonOther[] = "OTHER";
|
||||
|
||||
// Callback points
|
||||
static constexpr char ScriptReserved_PreStart[] = "PRESTART";
|
||||
static constexpr char ScriptReserved_PostStart[] = "POSTSTART";
|
||||
static constexpr char ScriptReserved_PreEnd[] = "PREEND";
|
||||
static constexpr char ScriptReserved_PostEnd[] = "POSTEND";
|
||||
static constexpr char ScriptReserved_PreSave[] = "PRESAVE";
|
||||
static constexpr char ScriptReserved_PostSave[] = "POSTSAVE";
|
||||
static constexpr char ScriptReserved_PreLoad[] = "PRELOAD";
|
||||
static constexpr char ScriptReserved_PostLoad[] = "POSTLOAD";
|
||||
static constexpr char ScriptReserved_PreControlPhase[] = "PRECONTROLPHASE"; // DEPRECATED
|
||||
static constexpr char ScriptReserved_PostControlPhase[] = "POSTCONTROLPHASE"; // DEPRECATED
|
||||
static constexpr char ScriptReserved_PreLoop[] = "PRELOOP";
|
||||
static constexpr char ScriptReserved_PostLoop[] = "POSTLOOP";
|
||||
static constexpr char ScriptReserved_PreUseItem[] = "PREUSEITEM";
|
||||
static constexpr char ScriptReserved_PostUseItem[] = "POSTUSEITEM";
|
||||
static constexpr char ScriptReserved_PreFreeze[] = "PREFREEZE";
|
||||
static constexpr char ScriptReserved_PostFreeze[] = "POSTFREEZE";
|
||||
static constexpr char ScriptReserved_PreStart[] = "PRE_START";
|
||||
static constexpr char ScriptReserved_PostStart[] = "POST_START";
|
||||
static constexpr char ScriptReserved_PreEnd[] = "PRE_END";
|
||||
static constexpr char ScriptReserved_PostEnd[] = "POST_END";
|
||||
static constexpr char ScriptReserved_PreSave[] = "PRE_SAVE";
|
||||
static constexpr char ScriptReserved_PostSave[] = "POST_SAVE";
|
||||
static constexpr char ScriptReserved_PreLoad[] = "PRE_LOAD";
|
||||
static constexpr char ScriptReserved_PostLoad[] = "POST_LOAD";
|
||||
static constexpr char ScriptReserved_PreLoop[] = "PRE_LOOP";
|
||||
static constexpr char ScriptReserved_PostLoop[] = "POST_LOOP";
|
||||
static constexpr char ScriptReserved_PreUseItem[] = "PRE_USE_ITEM";
|
||||
static constexpr char ScriptReserved_PostUseItem[] = "POST_USE_ITEM";
|
||||
static constexpr char ScriptReserved_PreFreeze[] = "PRE_FREEZE";
|
||||
static constexpr char ScriptReserved_PostFreeze[] = "POST_FREEZE";
|
||||
|
||||
// Built-in LevelFuncs
|
||||
static constexpr char ScriptReserved_OnStart[] = "OnStart";
|
||||
static constexpr char ScriptReserved_OnLoad[] = "OnLoad";
|
||||
static constexpr char ScriptReserved_OnLoop[] = "OnLoop";
|
||||
static constexpr char ScriptReserved_OnControlPhase[] = "OnControlPhase"; // DEPRECATED
|
||||
static constexpr char ScriptReserved_OnSave[] = "OnSave";
|
||||
static constexpr char ScriptReserved_OnEnd[] = "OnEnd";
|
||||
static constexpr char ScriptReserved_OnUseItem[] = "OnUseItem";
|
||||
|
@ -103,7 +100,7 @@ static constexpr char ScriptReserved_EventOnLoad[] = "LOAD";
|
|||
static constexpr char ScriptReserved_EventOnLoop[] = "LOOP";
|
||||
static constexpr char ScriptReserved_EventOnSave[] = "SAVE";
|
||||
static constexpr char ScriptReserved_EventOnEnd[] = "END";
|
||||
static constexpr char ScriptReserved_EventOnUseItem[] = "USEITEM";
|
||||
static constexpr char ScriptReserved_EventOnUseItem[] = "USE_ITEM";
|
||||
static constexpr char ScriptReserved_EventOnFreeze[] = "FREEZE";
|
||||
|
||||
// Member functions
|
||||
|
|
|
@ -60,8 +60,6 @@ static const auto CALLBACK_POINTS = std::unordered_map<std::string, CallbackPoin
|
|||
{ ScriptReserved_PostLoad, CallbackPoint::PostLoad },
|
||||
{ ScriptReserved_PreLoop, CallbackPoint::PreLoop },
|
||||
{ ScriptReserved_PostLoop, CallbackPoint::PostLoop },
|
||||
{ ScriptReserved_PreControlPhase, CallbackPoint::PreLoop }, // DEPRECATED
|
||||
{ ScriptReserved_PostControlPhase, CallbackPoint::PostLoop }, // DEPRECATED
|
||||
{ ScriptReserved_PreSave, CallbackPoint::PreSave },
|
||||
{ ScriptReserved_PostSave, CallbackPoint::PostSave },
|
||||
{ ScriptReserved_PreEnd, CallbackPoint::PreEnd },
|
||||
|
@ -69,7 +67,24 @@ static const auto CALLBACK_POINTS = std::unordered_map<std::string, CallbackPoin
|
|||
{ ScriptReserved_PreUseItem, CallbackPoint::PreUseItem },
|
||||
{ ScriptReserved_PostUseItem, CallbackPoint::PostUseItem },
|
||||
{ ScriptReserved_PreFreeze, CallbackPoint::PreFreeze },
|
||||
{ ScriptReserved_PostFreeze, CallbackPoint::PostFreeze }
|
||||
{ ScriptReserved_PostFreeze, CallbackPoint::PostFreeze },
|
||||
|
||||
// COMPATIBILITY
|
||||
{ "POSTSTART", CallbackPoint::PostStart },
|
||||
{ "PRELOAD", CallbackPoint::PreLoad },
|
||||
{ "POSTLOAD", CallbackPoint::PostLoad },
|
||||
{ "PRELOOP", CallbackPoint::PreLoop },
|
||||
{ "POSTLOOP", CallbackPoint::PostLoop },
|
||||
{ "PRESAVE", CallbackPoint::PreSave },
|
||||
{ "POSTSAVE", CallbackPoint::PostSave },
|
||||
{ "PREEND", CallbackPoint::PreEnd },
|
||||
{ "POSTEND", CallbackPoint::PostEnd },
|
||||
{ "PREUSEITEM", CallbackPoint::PreUseItem },
|
||||
{ "POSTUSEITEM", CallbackPoint::PostUseItem },
|
||||
{ "PREFREEZE", CallbackPoint::PreFreeze },
|
||||
{ "POSTFREEZE", CallbackPoint::PostFreeze },
|
||||
{ "PRECONTROLPHASE", CallbackPoint::PreLoop },
|
||||
{ "POSTCONTROLPHASE", CallbackPoint::PostLoop }
|
||||
};
|
||||
|
||||
static const auto EVENT_TYPES = std::unordered_map<std::string, EventType>
|
||||
|
@ -83,7 +98,10 @@ static const auto EVENT_TYPES = std::unordered_map<std::string, EventType>
|
|||
{ ScriptReserved_EventOnStart, EventType::Start },
|
||||
{ ScriptReserved_EventOnEnd, EventType::End },
|
||||
{ ScriptReserved_EventOnUseItem, EventType::UseItem },
|
||||
{ ScriptReserved_EventOnFreeze, EventType::Freeze }
|
||||
{ ScriptReserved_EventOnFreeze, EventType::Freeze },
|
||||
|
||||
// COMPATIBILITY
|
||||
{ "USEITEM", EventType::UseItem }
|
||||
};
|
||||
|
||||
static const auto LEVEL_END_REASONS = std::unordered_map<std::string, LevelEndReason>
|
||||
|
@ -92,7 +110,12 @@ static const auto LEVEL_END_REASONS = std::unordered_map<std::string, LevelEndRe
|
|||
{ ScriptReserved_EndReasonLoadGame, LevelEndReason::LoadGame },
|
||||
{ ScriptReserved_EndReasonExitToTitle, LevelEndReason::ExitToTitle },
|
||||
{ ScriptReserved_EndReasonDeath, LevelEndReason::Death },
|
||||
{ ScriptReserved_EndReasonOther, LevelEndReason::Other }
|
||||
{ ScriptReserved_EndReasonOther, LevelEndReason::Other },
|
||||
|
||||
// COMPATIBILITY
|
||||
{ "LEVELCOMPLETE", LevelEndReason::LevelComplete },
|
||||
{ "LOADGAME", LevelEndReason::LoadGame },
|
||||
{ "LEVELCOMPLETE", LevelEndReason::ExitToTitle }
|
||||
};
|
||||
|
||||
static constexpr char const* strKey = "__internal_name";
|
||||
|
@ -225,29 +248,29 @@ designer to add calls to `OnStart`, `OnLoad`, etc. in their level script.
|
|||
|
||||
Possible values for `point`:
|
||||
-- These take functions which accept no arguments
|
||||
PRESTART -- will be called immediately before OnStart
|
||||
POSTSTART -- will be called immediately after OnStart
|
||||
PRE_START -- will be called immediately before OnStart
|
||||
POST_START -- will be called immediately after OnStart
|
||||
|
||||
PRESAVE -- will be called immediately before OnSave
|
||||
POSTSAVE -- will be called immediately after OnSave
|
||||
PRE_SAVE -- will be called immediately before OnSave
|
||||
POST_SAVE -- will be called immediately after OnSave
|
||||
|
||||
PRELOAD -- will be called immediately before OnLoad
|
||||
POSTLOAD -- will be called immediately after OnLoad
|
||||
PRE_LOAD -- will be called immediately before OnLoad
|
||||
POST_LOAD -- will be called immediately after OnLoad
|
||||
|
||||
PREFREEZE -- will be called before entering freeze mode
|
||||
POSTFREEZE -- will be called immediately after exiting freeze mode
|
||||
PRE_FREEZE -- will be called before entering freeze mode
|
||||
POST_FREEZE -- will be called immediately after exiting freeze mode
|
||||
|
||||
-- These take a LevelEndReason arg, like OnEnd
|
||||
PREEND -- will be called immediately before OnEnd
|
||||
POSTEND -- will be called immediately after OnEnd
|
||||
PRE_END -- will be called immediately before OnEnd
|
||||
POST_END -- will be called immediately after OnEnd
|
||||
|
||||
-- These take functions which accepts a deltaTime argument
|
||||
PRELOOP -- will be called in the beginning of game loop
|
||||
POSTLOOP -- will be called at the end of game loop
|
||||
PRE_LOOP -- will be called in the beginning of game loop
|
||||
POST_LOOP -- will be called at the end of game loop
|
||||
|
||||
-- These take functions which accepts an objectNumber argument, like OnUseItem
|
||||
PREUSEITEM -- will be called immediately before OnUseItem
|
||||
POSTUSEITEM -- will be called immediately after OnUseItem
|
||||
PRE_USE_ITEM -- will be called immediately before OnUseItem
|
||||
POST_USE_ITEM -- will be called immediately after OnUseItem
|
||||
|
||||
The order in which two functions with the same CallbackPoint are called is undefined.
|
||||
i.e. if you register `MyFunc` and `MyFunc2` with `PRELOOP`, both will be called in the beginning of game loop, but there is no guarantee that `MyFunc` will be called before `MyFunc2`, or vice-versa.
|
||||
|
@ -314,7 +337,7 @@ Possible event type values:
|
|||
START
|
||||
END
|
||||
LOOP
|
||||
USEITEM
|
||||
USE_ITEM
|
||||
MENU
|
||||
|
||||
@function HandleEvent
|
||||
|
@ -1182,9 +1205,9 @@ and provides the delta time (a float representing game time since last call) via
|
|||
@tfield function OnSave Will be called when the player saves the game, just *before* data is saved
|
||||
@tfield function OnEnd(EndReason) Will be called when leaving a level. This includes finishing it, exiting to the menu, or loading a save in a different level. It can take an `EndReason` arg:
|
||||
|
||||
EXITTOTITLE
|
||||
LEVELCOMPLETE
|
||||
LOADGAME
|
||||
EXIT_TO_TITLE
|
||||
LEVEL_COMPLETE
|
||||
LOAD_GAME
|
||||
DEATH
|
||||
OTHER
|
||||
|
||||
|
@ -1221,10 +1244,12 @@ void LogicHandler::InitCallbacks()
|
|||
|
||||
assignCB(m_onStart, ScriptReserved_OnStart);
|
||||
assignCB(m_onLoad, ScriptReserved_OnLoad);
|
||||
assignCB(m_onLoop, ScriptReserved_OnControlPhase);
|
||||
assignCB(m_onLoop, ScriptReserved_OnLoop);
|
||||
assignCB(m_onSave, ScriptReserved_OnSave);
|
||||
assignCB(m_onEnd, ScriptReserved_OnEnd);
|
||||
assignCB(m_onUseItem, ScriptReserved_OnUseItem);
|
||||
assignCB(m_onBreak, ScriptReserved_OnFreeze);
|
||||
|
||||
// COMPATIBILITY
|
||||
assignCB(m_onLoop, "OnControlPhase");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue