Skip to content

Commit

Permalink
Cleanup total dna counter functions (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThanatosGit authored Aug 27, 2024
1 parent 4923d38 commit dc2388b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 26 deletions.
29 changes: 27 additions & 2 deletions src/open_samus_returns_rando/files/custom/guilib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down
9 changes: 1 addition & 8 deletions src/open_samus_returns_rando/files/custom/scenario.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 4 additions & 16 deletions src/open_samus_returns_rando/files/templates/randomizerpowerup.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Game.ImportLibrary("system/scripts/guilib.lua", false)

RandomizerPowerup = RandomizerPowerup or {}
function RandomizerPowerup.main()
end
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit dc2388b

Please sign in to comment.