Skip to content

Commit fe8154d

Browse files
Merge pull request #413 from ArcanoxDragon/feature/gui-additions
Numerous in-game UI improvements
2 parents 74a3634 + e5b9d81 commit fe8154d

File tree

19 files changed

+478
-16
lines changed

19 files changed

+478
-16
lines changed

icons/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
# Icons
2-
unplug by tezar tantular from [Noun Project](https://thenounproject.com/browse/icons/term/unplug/) (CC BY 3.0)
2+
unplug by tezar tantular from [Noun Project](https://thenounproject.com/browse/icons/term/unplug/) (CC BY 3.0)
3+
4+
skull from [Font Awesome Free](https://fontawesome.com/icons/skull?f=classic&s=solid) (CC BY 4.0)

icons/skull-solid-full.svg

Lines changed: 1 addition & 0 deletions
Loading

src/open_dread_rando/dread_patcher.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,14 @@ def chunks(array, n):
118118
"energy_per_tank": energy_per_tank,
119119
"energy_per_part": energy_per_part,
120120
"immediate_energy_parts": configuration["immediate_energy_parts"],
121+
"has_flash_upgrades": configuration["has_flash_upgrades"],
122+
"has_speed_upgrades": configuration["has_speed_upgrades"],
121123
"default_x_released": configuration.get("game_patches", {}).get("default_x_released", False),
122124
"linear_damage_runs": configuration.get("linear_damage_runs"),
123125
"linear_dps": configuration.get("linear_dps"),
124126
"configuration_identifier": lua_util.wrap_string(configuration_identifier),
125127
"required_artifacts": configuration["objective"]["required_artifacts"],
128+
"show_dna_in_hud": cosmetic_options["show_dna_in_hud"],
126129
"enable_death_counter": cosmetic_options["enable_death_counter"],
127130
"enable_room_ids": False if cosmetic_options["enable_room_name_display"] == "NEVER" else True,
128131
"room_id_fade_time": FadeTimes.NO_FADE.value if (

src/open_dread_rando/files/custom_scenario.lua

Lines changed: 70 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Game.DoFile("system/scripts/guilib.lua")
66
Game.DoFile("system/scripts/death_counter.lua")
77
Game.DoFile("system/scripts/room_names.lua")
88
Game.DoFile("system/scripts/disconnect_gui.lua")
9+
Game.DoFile("system/scripts/custom_samus_gui.lua")
910

1011
Scenario.tRandoHintPropIDs = {
1112
CAVE_1 = Blackboard.RegisterLUAProp("HINT_CAVE_1", "bool"),
@@ -306,7 +307,13 @@ function Scenario.OnLoadScenarioFinished()
306307
Scenario.checkConnectionSFID = Game.AddGUISF(2, "Scenario.CheckConnectionState", "")
307308
end
308309

309-
Scenario.InitGui()
310+
local guiSuccess, guiError = pcall(Scenario.InitGui)
311+
312+
if not guiSuccess then
313+
Game.LogWarn(0, "Failed to initialize GUI:")
314+
Game.LogWarn(0, tostring(guiError))
315+
end
316+
310317
Scenario.ShowingPopup = false
311318
Scenario.ShowNextAsyncPopup()
312319

@@ -426,18 +433,51 @@ function Scenario.InitGui()
426433

427434
-- Grab references to the individual objects
428435
Scenario.PopupLabel = Scenario.RandoUI:FindDescendant("PopupPanel.PopupLabel")
429-
Scenario.DeathCounterPanel = Scenario.RandoUI:FindDescendant("DeathCounterPanel")
436+
Scenario.ExtraInfoPanel = Scenario.RandoUI:FindDescendant("ExtraInfoPanel")
437+
Scenario.DnaCountLabel = Scenario.RandoUI:FindDescendant("ExtraInfoPanel.DNA_Label")
430438
Scenario.RoomNamesPanel = Scenario.RandoUI:FindDescendant("RoomNamesPanel")
431439
Scenario.DisconnectPanel = Scenario.RandoUI:FindDescendant("DisconnectPanel")
432440

433441
-- Set initial UI state
442+
local showDnaInHud = Init.bShowDnaInHud and Init.iNumRequiredArtifacts > 0
443+
local showDeathCounter = Init.bEnableDeathCounter
444+
local showExtraInfo = showDnaInHud or showDeathCounter
445+
434446
GUI.SetProperties(Scenario.PopupLabel, { Visible = false })
435-
GUI.SetProperties(Scenario.DeathCounterPanel, { Visible = false })
447+
GUI.SetProperties(Scenario.ExtraInfoPanel, { Visible = showExtraInfo })
436448
GUI.SetProperties(Scenario.RoomNamesPanel, { Visible = false })
437449
GUI.SetProperties(Scenario.DisconnectPanel, { Visible = false })
438450

439-
if Init.bEnableDeathCounter then
440-
DeathCounter.Init(Scenario.DeathCounterPanel)
451+
if showDeathCounter then
452+
DeathCounter.Init(Scenario.ExtraInfoPanel)
453+
454+
if not showDnaInHud then
455+
-- Need to move the death counter icon and label up to where the DNA would normally be shown
456+
local dnaIconY = Scenario.ExtraInfoPanel:FindChild("DNA_Icon"):_Y_GetterFunction()
457+
local dnaLabelY = Scenario.ExtraInfoPanel:FindChild("DNA_Label"):_CenterY_GetterFunction()
458+
459+
GUI.SetProperties(Scenario.ExtraInfoPanel:FindChild("DeathCounter_Icon"), { Y = dnaIconY })
460+
GUI.SetProperties(Scenario.ExtraInfoPanel:FindChild("DeathCounter_Label"), { CenterY = dnaLabelY })
461+
end
462+
else
463+
GUI.SetProperties(Scenario.ExtraInfoPanel:FindChild("DeathCounter_Icon"), { Visible = false })
464+
GUI.SetProperties(Scenario.ExtraInfoPanel:FindChild("DeathCounter_Label"), { Visible = false })
465+
end
466+
467+
if showDnaInHud then
468+
Scenario.UpdateHudDnaCount()
469+
else
470+
GUI.SetProperties(Scenario.ExtraInfoPanel:FindChild("DNA_Icon"), { Visible = false })
471+
GUI.SetProperties(Scenario.ExtraInfoPanel:FindChild("DNA_Label"), { Visible = false })
472+
end
473+
474+
if not showDeathCounter or not showDnaInHud then
475+
-- Toggle the "extra info" panel to the short version
476+
GUI.SetProperties(Scenario.ExtraInfoPanel:FindChild("Background"), { Visible = false })
477+
GUI.SetProperties(Scenario.ExtraInfoPanel:FindChild("Line_Left"), { Visible = false })
478+
479+
GUI.SetProperties(Scenario.ExtraInfoPanel:FindChild("Background_Short"), { Visible = true })
480+
GUI.SetProperties(Scenario.ExtraInfoPanel:FindChild("Line_Left_Short"), { Visible = true })
441481
end
442482

443483
if Init.bEnableRoomIds then
@@ -447,6 +487,8 @@ function Scenario.InitGui()
447487
if Init.sLayoutUUID ~= Scenario.INVALID_UUID then
448488
DisconnectGui.Init(Scenario.DisconnectPanel)
449489
end
490+
491+
RandoSamusGui.Init()
450492
end
451493

452494
Scenario.QueuedPopups = Scenario.QueuedPopups or Queue()
@@ -496,6 +538,29 @@ function Scenario.UpdateRoomName(new_subarea)
496538
RoomNameGui.Update(new_subarea)
497539
end
498540

541+
function Scenario.UpdateHudDnaCount()
542+
local currentDnaCount = 0
543+
local requiredDnaCount = Init.iNumRequiredArtifacts
544+
545+
for i = 1, Init.iNumRequiredArtifacts do
546+
if RandomizerPowerup.GetItemAmount("ITEM_RANDO_ARTIFACT_" .. i) > 0 then
547+
currentDnaCount = currentDnaCount + 1
548+
end
549+
end
550+
551+
local dnaText = ("%d / %d"):format(currentDnaCount, requiredDnaCount)
552+
local haveAllDna = currentDnaCount >= requiredDnaCount
553+
554+
-- Text is light red when all DNA are acquired
555+
GUI.SetProperties(Scenario.DnaCountLabel, {
556+
ColorR = "1.0",
557+
ColorG = haveAllDna and "0.5" or "1.0",
558+
ColorB = haveAllDna and "0.5" or "1.0",
559+
})
560+
GUI.SetLabelText(Scenario.DnaCountLabel, dnaText)
561+
Scenario.DnaCountLabel:ForceRedraw()
562+
end
563+
499564
function Scenario.UpdateNumTanksMax(num_locs)
500565
-- sets Scenario blackboard NumTanksPickedUpMax to num_locs
501566
Game.LogWarn(0, "Setting " .. CurrentScenarioID .. ".NumTanksPickedUpMax = " .. num_locs)

0 commit comments

Comments
 (0)