From fb3d27fcfec5f801e3bede82aba6a34de0c1ed48 Mon Sep 17 00:00:00 2001 From: fgenesis Date: Sun, 17 Jul 2022 17:56:26 +0200 Subject: [PATCH] Remove Lua functions: - toggleVersionLabel() - setVersionLabelText() + Implement compat function entity_flipHToAvatar() properly --- Aquaria/Game.cpp | 9 ++++++--- Aquaria/ScriptInterface.cpp | 17 ----------------- files/scripts/compat/default.lua | 1 + files/scripts/compat/forward-compatible.lua | 2 -- .../scripts/compat/internal/oldfunctions.lua | 19 +++++++++++++++---- files/scripts/maps/node_title.lua | 10 ---------- 6 files changed, 22 insertions(+), 36 deletions(-) diff --git a/Aquaria/Game.cpp b/Aquaria/Game.cpp index e7b634e..0222b63 100644 --- a/Aquaria/Game.cpp +++ b/Aquaria/Game.cpp @@ -2576,16 +2576,19 @@ void Game::applyState() dsq->returnToScene = ""; + bool versionlabel = false; + // new place where mods get stopped! // this lets recaching work // (presumably because there has been time for the garbage to be cleared) - if (sceneToLoad == "title" && dsq->mod.isShuttingDown()) + if (sceneToLoad == "title") { - if (dsq->mod.isActive()) + if (dsq->mod.isActive() && dsq->mod.isShuttingDown()) { dsq->mod.stop(); dsq->continuity.reset(); } + versionlabel = true; } dsq->collectScriptGarbage(); @@ -2602,7 +2605,7 @@ void Game::applyState() AquariaGuiElement::canDirMoveGlobal = true; - dsq->toggleVersionLabel(false); + dsq->toggleVersionLabel(versionlabel); activation = true; diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index 3e4a347..fe5e033 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -7888,21 +7888,6 @@ luaFunc(findWall) luaReturnNum(wall); } -luaFunc(toggleVersionLabel) -{ - bool on = getBool(L, 1); - - dsq->toggleVersionLabel(on); - - luaReturnBool(on); -} - -luaFunc(setVersionLabelText) -{ - dsq->setVersionLabelText(); - luaReturnNil(); -} - luaFunc(setCutscene) { dsq->setCutscene(getBool(L, 1), getBool(L, 2)); @@ -10699,8 +10684,6 @@ static const struct { luaRegister(node_getShape), luaRegister(toggleSteam), - luaRegister(toggleVersionLabel), - luaRegister(setVersionLabelText), luaRegister(appendUserDataPath), diff --git a/files/scripts/compat/default.lua b/files/scripts/compat/default.lua index f3dd87e..81592ed 100644 --- a/files/scripts/compat/default.lua +++ b/files/scripts/compat/default.lua @@ -3,3 +3,4 @@ -- (In this case and for 1.1.x/Steam compatibility, use "legacy" or "legacy-strict") dofile("scripts/compat/internal/osestubs.lua") +dofile("scripts/compat/internal/oldfunctions.lua") diff --git a/files/scripts/compat/forward-compatible.lua b/files/scripts/compat/forward-compatible.lua index 2c0e60c..88aa5e2 100644 --- a/files/scripts/compat/forward-compatible.lua +++ b/files/scripts/compat/forward-compatible.lua @@ -10,8 +10,6 @@ decrFlag = nil entity_sound = nil entity_toggleBone = nil isPlat = nil -- should not matter on the Lua side what the platform is -toggleVersionLabel = nil -setVersionLabelText = nil quit = nil -- mods should not do this ever doModSelect = nil doLoadMenu = nil diff --git a/files/scripts/compat/internal/oldfunctions.lua b/files/scripts/compat/internal/oldfunctions.lua index 07359ea..cff98ce 100644 --- a/files/scripts/compat/internal/oldfunctions.lua +++ b/files/scripts/compat/internal/oldfunctions.lua @@ -34,7 +34,7 @@ local WARN_FUNCTIONS_VAL = isInDialog = false, } --- These had no function and we can just ignore the call +-- These had no effective function and we can just ignore the call local DUMMY_FUNCTIONS = { entity_setCollideWithAvatar = true, @@ -44,7 +44,6 @@ local DUMMY_FUNCTIONS = entity_addGroupVel = true, entity_avgVel = true, entity_fireAtTarget = true, - entity_flipHToAvatar = true, entity_getBehaviorType = true, entity_isSaying = true, entity_moveTowardsGroupCenter = true, @@ -68,6 +67,8 @@ local DUMMY_FUNCTIONS = entity_stopTimer = true, setEntityScript = true, streamSfx = true, + toggleVersionLabel = true, + setVersionLabelText = true, } -- Deprecated stuff from v1.1's scripts/entities/entityinclude.lua @@ -85,6 +86,12 @@ local function entity_watchSwimToEntitySide(ent1, ent2) entity_flipToEntity(ent2, ent1) end +-- Removed unused functions but re-implemented in Lua + +local function entity_flipHToAvatar(me) + return entity_flipToEntity(me, getNaija()) +end + -- Duplicated and renamed functions local REPLACED_FUNCTIONS = @@ -103,16 +110,20 @@ local REPLACED_FUNCTIONS = inp = toggleInput, isPlayingVoice = isStreamingVoice, playVoice = voice, - + -- These are unfortunately broken and can't be fixed. -- They are interface function names and the first loaded script would grab them, -- thinking an interface function with that name was provided by whichever script was just loaded. + -- (This happens to be Li if he's available, or any other entity if he's not spawned) -- So we ignore these and hope nobody misses them. --msg = screenMessage, --castSong = singSong, - + -- entityinclude functions entity_watchSwimToEntitySide = entity_watchSwimToEntitySide, + + -- removed from C++ but implemented in Lua + entity_flipHToAvatar = entity_flipHToAvatar, } diff --git a/files/scripts/maps/node_title.lua b/files/scripts/maps/node_title.lua index 6d01252..945d371 100644 --- a/files/scripts/maps/node_title.lua +++ b/files/scripts/maps/node_title.lua @@ -24,7 +24,6 @@ if not AQUARIA_VERSION then dofile("scripts/entities/entityinclude.lua") end v.n = 0 v.mbDown = false -v.labelTimer = 0 function init(me) --stopAllVoice() @@ -65,18 +64,9 @@ function init(me) fade(1, 0) fade(0, 1) fade2(0, 2, 1, 1, 1) - - setVersionLabelText() - toggleVersionLabel(1) - - v.labelTimer = 0 end function update(me, dt) - v.labelTimer = v.labelTimer + dt - if v.labelTimer > 0.5 then - setVersionLabelText() - end cam_setPosition(node_x(me), node_y(me)) if isInputEnabled() then debugLog("calling disable input")