Skip to content

Commit

Permalink
Add custom DNA counter
Browse files Browse the repository at this point in the history
  • Loading branch information
ThanatosGit committed Nov 2, 2023
1 parent 0d37994 commit 22e8da3
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 1 deletion.
5 changes: 5 additions & 0 deletions open_samus_returns_rando/files/custom_scenario.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Game.ImportLibrary("system/scripts/scenario_original.lua")
Game.DoFile("system/scripts/guilib.lua")

Scenario = Scenario or {}
setmetatable(Scenario, {__index = _G})
Expand Down Expand Up @@ -78,3 +79,7 @@ function Scenario.SetMetroidSpawngroupOnCurrentScenario(created_actor, group_nam
CurrentScenario.isMultiGamma = is_multi or false
end
end

function Scenario.InitGUI()
GUILib.AddDNACounter()
end
79 changes: 79 additions & 0 deletions open_samus_returns_rando/files/guilib.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@

GUILib = GUILib or {}

function GUILib.AddDNACounter()
local randoUI = GUI.GetDisplayObject("IngameMenuRoot.IngameMenuComposition.LowerComposition.LowerInfoComposition.DNAMechIconRando")
if randoUI ~= nil then
return
end

local lowerInfo = GUI.GetDisplayObject("IngameMenuRoot.IngameMenuComposition.LowerComposition.LowerInfoComposition")
lowerInfo:AddChild((GUI.CreateDisplayObjectEx("DNAMechIconRando", "CSprite", {
X = "0.17188",
Y = "0.02500",
SizeX = "0.06562",
SizeY = "0.09166",
ScaleX = "1.00000",
ScaleY = "1.00000",
Angle = "0.00000",
FlipX = false,
FlipY = false,
Enabled = true,
Visible = true,
SkinItemType = "",
Autosize = false,
SpriteSheetItem = "IconL_MetroidDNAData",
BlendMode = "AlphaBlend",
USelMode = "Scale",
VSelMode = "Scale"
})))
lowerInfo:AddChild((GUI.CreateDisplayObjectEx("DNAMechCounterRando", "CText", {
X = "0.24688",
Y = "0.02500",
SizeX = "0.12499",
SizeY = "0.05833",
ScaleX = "1.00000",
ScaleY = "1.00000",
Angle = "0.00000",
FlipX = false,
FlipY = false,
ColorR = "0.68000",
ColorG = "0.83000",
ColorB = "0.93000",
ColorA = "1.00000",
Enabled = true,
Visible = true,
SkinItemType = "",
Text = "10 / 10",
Font = "digital_hefty",
TextAlignment = "Left",
Autosize = true,
Outline = true,
EmbeddedSpritesSuffix = "",
BlinkColorR = "1.00000",
BlinkColorG = "1.00000",
BlinkColorB = "1.00000",
BlinkAlpha = "1.00000",
Blink = "-1.00000"
})))
local dnaCounterVanilla = GUI.GetDisplayObject("IngameMenuRoot.IngameMenuComposition.LowerComposition.LowerInfoComposition.DNAMechCounter")
local dnaIconVanilla = GUI.GetDisplayObject("IngameMenuRoot.IngameMenuComposition.LowerComposition.LowerInfoComposition.DNAMechIcon")
GUI.SetProperties(dnaCounterVanilla, {
Enabled = false,
Visible = false
})
GUI.SetProperties(dnaIconVanilla, {
Enabled = false,
Visible = false
})
GUILib.UpdateDNACounter(2, 5)
end


function GUILib.UpdateDNACounter(currentDNA, maxDNA)
local dna = GUI.GetDisplayObject("IngameMenuRoot.IngameMenuComposition.LowerComposition.LowerInfoComposition.DNAMechCounterRando")
if dna ~= nil then
GUI.SetTextText(dna, tostring(currentDNA) .. " / " .. tostring(maxDNA))
dna:ForceRedraw()
end
end
3 changes: 2 additions & 1 deletion open_samus_returns_rando/files/levels/s000_surface.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ function s000_surface.OnShipStartPointTeleport(_ARG_0_, _ARG_1_)
end
end
function s000_surface.InitFromBlackboard()
Scenario.InitGUI()
if Scenario.ReadFromBlackboard("LarvaPresentationPlayed", false) then
Game.DisableTrigger("TG_Intro_MetroidSurface")
else
Expand Down Expand Up @@ -504,7 +505,7 @@ function s000_surface.OnSkipPlanetArrival()
end
function s000_surface.LaunchFirstTimeDNAStatuePresentation()
Scenario.WriteToBlackboard("FirstTimeDNAStatuePlayed", "b", true)
Game.OnDNAMechApproached("LE_ChozoUnlockAreaDNA", 1)
-- Game.OnDNAMechApproached("LE_ChozoUnlockAreaDNA", 1)
Game.GetEntity("LE_ChozoUnlockAreaDNA").USABLE:SetHintUseDNAExecuted()
-- Game.LaunchCutscene("cutscenes/introdnastatue/takes/01/introdnastatue01.bmscu")
if Game.GetEntity("TG_Intro_DNAStatue") ~= nil then
Expand Down
5 changes: 5 additions & 0 deletions open_samus_returns_rando/lua_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ def save_modifications(self, editor: PatcherEditor):
final_metroid_script = lua_util.replace_lua_template("metroid_template.lua", {"mapping": self._metroid_dict})
final_chozo_seal_script = lua_util.replace_lua_template("chozoseal_template.lua", {"mapping": self._hint_dict})

editor.add_new_asset(
"system/scripts/guilib.lc",
files_path().joinpath("guilib.lua").read_bytes(),
[]
)
editor.replace_asset("actors/items/randomizer_powerup/scripts/randomizer_powerup.lc", self._powerup_script)
editor.replace_asset("actors/scripts/metroid.lc", final_metroid_script.encode("utf-8"))
editor.replace_asset("actors/props/chozoseal/scripts/chozoseal.lc", final_chozo_seal_script.encode("utf-8"))
Expand Down

0 comments on commit 22e8da3

Please sign in to comment.