@@ -6,6 +6,7 @@ Game.DoFile("system/scripts/guilib.lua")
66Game .DoFile (" system/scripts/death_counter.lua" )
77Game .DoFile (" system/scripts/room_names.lua" )
88Game .DoFile (" system/scripts/disconnect_gui.lua" )
9+ Game .DoFile (" system/scripts/custom_samus_gui.lua" )
910
1011Scenario .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 ()
450492end
451493
452494Scenario .QueuedPopups = Scenario .QueuedPopups or Queue ()
@@ -496,6 +538,29 @@ function Scenario.UpdateRoomName(new_subarea)
496538 RoomNameGui .Update (new_subarea )
497539end
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+
499564function Scenario .UpdateNumTanksMax (num_locs )
500565 -- sets Scenario blackboard NumTanksPickedUpMax to num_locs
501566 Game .LogWarn (0 , " Setting " .. CurrentScenarioID .. " .NumTanksPickedUpMax = " .. num_locs )
0 commit comments