From dc2388b5800c56e3b0c864ca69d43f12a385888f Mon Sep 17 00:00:00 2001 From: Thanatos <117127188+ThanatosGit@users.noreply.github.com> Date: Tue, 27 Aug 2024 22:28:51 +0200 Subject: [PATCH] Cleanup total dna counter functions (#461) --- .../files/custom/guilib.lua | 29 +++++++++++++++++-- .../files/custom/scenario.lua | 9 +----- .../files/templates/randomizerpowerup.lua | 20 +++---------- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/src/open_samus_returns_rando/files/custom/guilib.lua b/src/open_samus_returns_rando/files/custom/guilib.lua index 15651bb..8c79646 100644 --- a/src/open_samus_returns_rando/files/custom/guilib.lua +++ b/src/open_samus_returns_rando/files/custom/guilib.lua @@ -64,9 +64,19 @@ function GUILib.UpdateDNACounter(currentDNA, maxDNA) end end +function GUILib.GetTotalDNACounter() + return GUI.GetDisplayObject("IngameMenuRoot.IngameMenuComposition.LowerComposition.LowerInfoComposition.DNACounter") +end + function GUILib.UpdateTotalDNAColor() - if Game.GetItemAmount(Game.GetPlayerName(), "ITEM_ADN") < 39 then - local dnaCounter = GUI.GetDisplayObject("IngameMenuRoot.IngameMenuComposition.LowerComposition.LowerInfoComposition.DNACounter") + local dnaCounter = GUILib.GetTotalDNACounter() + if Blackboard.GetProp("GAME", "OBJECTIVE_COMPLETE") then + GUI.SetProperties(dnaCounter, { + ColorR = "0.60392", + ColorG = "0.61569", + ColorB = "0.04314", + }) + else GUI.SetProperties(dnaCounter, { ColorR = "0.68000", ColorG = "0.83000", @@ -75,6 +85,21 @@ function GUILib.UpdateTotalDNAColor() end end +function GUILib.BlinkTotalDNACounter() + local dnaCounter = GUILib.GetTotalDNACounter() + GUI.SetProperties(dnaCounter, { + ColorR = "0.60392", + ColorG = "0.61569", + ColorB = "0.04314", + Blink = "1.00000", + }) +end + +function GUILib.DisableBlinkTotalDNACounter() + local dnaCounter = GUILib.GetTotalDNACounter() + GUI.SetProperties(dnaCounter, { Blink = "0.00000" }) +end + function GUILib.AddMessageBox() local randoUI = GUI.GetDisplayObject("IngameMenuRoot.IngameMenuComposition.USSEF.Outer") if randoUI ~= nil then diff --git a/src/open_samus_returns_rando/files/custom/scenario.lua b/src/open_samus_returns_rando/files/custom/scenario.lua index 0179b26..f0affc3 100644 --- a/src/open_samus_returns_rando/files/custom/scenario.lua +++ b/src/open_samus_returns_rando/files/custom/scenario.lua @@ -88,14 +88,7 @@ function Scenario.UpdateDNACounter() local maxDNA = Init.tDNAPerArea[scenario] or 0 local currentDNA = Blackboard.GetProp("GAME", scenario .."_acquired_dna") or 0 GUILib.UpdateDNACounter(currentDNA, maxDNA) - if Blackboard.GetProp("GAME", "OBJECTIVE_COMPLETE") then - local dnaCounter = GUI.GetDisplayObject("IngameMenuRoot.IngameMenuComposition.LowerComposition.LowerInfoComposition.DNACounter") - GUI.SetProperties(dnaCounter, { - ColorR = "0.60392", - ColorG = "0.61569", - ColorB = "0.04314", - }) - end + GUILib.UpdateTotalDNAColor() end local original_init = Scenario.InitScenario diff --git a/src/open_samus_returns_rando/files/templates/randomizerpowerup.lua b/src/open_samus_returns_rando/files/templates/randomizerpowerup.lua index a43504a..cd6ee1f 100644 --- a/src/open_samus_returns_rando/files/templates/randomizerpowerup.lua +++ b/src/open_samus_returns_rando/files/templates/randomizerpowerup.lua @@ -1,3 +1,5 @@ +Game.ImportLibrary("system/scripts/guilib.lua", false) + RandomizerPowerup = RandomizerPowerup or {} function RandomizerPowerup.main() end @@ -204,8 +206,8 @@ function RandomizerPowerup.ObjectiveComplete() if RandomizerPowerup.GetItemAmount("ITEM_ADN") == required_dna then Blackboard.SetProp("GAME", "OBJECTIVE_COMPLETE", "b", true) Game.HUDIdleScreenLeave() - RandomizerPowerup.UpdateDNACounter() - Game.AddGUISF(3, "RandomizerPowerup.DisableBlink", "") + GUILib.BlinkTotalDNACounter() + Game.AddGUISF(3, "GUILib.DisableBlinkTotalDNACounter", "") -- Assign boss names and areas to each boss local boss = Init.sFinalBoss @@ -241,20 +243,6 @@ function RandomizerPowerup.ObjectiveComplete() end end -function RandomizerPowerup.UpdateDNACounter() - local dnaCounter = GUI.GetDisplayObject("IngameMenuRoot.IngameMenuComposition.LowerComposition.LowerInfoComposition.DNACounter") - GUI.SetProperties(dnaCounter, { - ColorR = "0.60392", - ColorG = "0.61569", - ColorB = "0.04314", - Blink = "1.00000", - }) -end - -function RandomizerPowerup.DisableBlink() - local dnaCounter = GUI.GetDisplayObject("IngameMenuRoot.IngameMenuComposition.LowerComposition.LowerInfoComposition.DNACounter") - GUI.SetProperties(dnaCounter, { Blink = "0.00000" }) -end function RandomizerPowerup.IncreaseMissileCheckValue() -- Update the min missile reserve tank refill value (capped by config)