player: rename BackpackUI to HUD

This commit is contained in:
Jeremy Baxter 2026-01-22 17:40:18 +13:00 committed by jeremy
parent e616fc4cbb
commit df449af0f3
2 changed files with 14 additions and 14 deletions

View file

@ -16,21 +16,21 @@ var direction = Vector3.ZERO
var target_velocity = Vector3.ZERO var target_velocity = Vector3.ZERO
func resize_ui(): func resize_ui():
var bpui_h = 200 var hud_h = 200
var size = get_viewport().get_visible_rect().size var size = get_viewport().get_visible_rect().size
$Message.size.x = size.x $Message.size.x = size.x
$BackpackUI.size.x = size.x $HUD.size.x = size.x
$BackpackUI.size.y = bpui_h $HUD.size.y = hud_h
$BackpackUI.position.x = 0 $HUD.position.x = 0
$BackpackUI.position.y = size.y - bpui_h $HUD.position.y = size.y - hud_h
func make_backpack_ui(): func make_hud():
var text = "Holding " + $Pivot/Container/Gear.gear_name() var text = "Holding " + $Pivot/Container/Gear.gear_name()
for node in $Backpack.get_children(): for node in $Backpack.get_children():
if not node is Gear: if not node is Gear:
continue continue
text += "\n%s (%s)" % [node.gear_name(), node.name] text += "\n%s (%s)" % [node.gear_name(), node.name]
$BackpackUI.text = text $HUD.text = text
func message(string): func message(string):
$Message.text = string $Message.text = string
@ -40,7 +40,7 @@ func message(string):
func die(): func die():
suspended = true suspended = true
visible = false visible = false
$BackpackUI.visible = false $HUD.visible = false
# strip gears # strip gears
for gear in $Backpack.get_children(): for gear in $Backpack.get_children():
@ -61,8 +61,8 @@ func respawn():
var gear = starting_gear.instantiate() var gear = starting_gear.instantiate()
$Pivot/Container.add_child(gear) $Pivot/Container.add_child(gear)
make_backpack_ui() make_hud()
$BackpackUI.visible = true $HUD.visible = true
# Backpack functions # Backpack functions
@ -87,7 +87,7 @@ func use_backpack_slot(n):
old.reparent($Backpack, false) old.reparent($Backpack, false)
get_node(gear_node).reparent($Pivot/Container, false) get_node(gear_node).reparent($Pivot/Container, false)
get_node("Pivot/Container/" + n).name = "Gear" get_node("Pivot/Container/" + n).name = "Gear"
make_backpack_ui() make_hud()
return return
# couldn't find a free slot, so replace # couldn't find a free slot, so replace
# the new slot with the current gear # the new slot with the current gear
@ -95,7 +95,7 @@ func use_backpack_slot(n):
old.reparent($Backpack, false) old.reparent($Backpack, false)
old.name = n old.name = n
get_node("Pivot/Container/" + n).name = "Gear" get_node("Pivot/Container/" + n).name = "Gear"
make_backpack_ui() make_hud()
return return
func equip(gear: Gear): func equip(gear: Gear):
@ -120,7 +120,7 @@ func equip(gear: Gear):
new_gear = gear.duplicate() new_gear = gear.duplicate()
new_gear.name = "Gear" new_gear.name = "Gear"
$Pivot/Container.add_child(new_gear) $Pivot/Container.add_child(new_gear)
make_backpack_ui() make_hud()
message("You picked up a " + gear_name + "!") message("You picked up a " + gear_name + "!")
return true return true
# if no slots are free # if no slots are free

View file

@ -93,7 +93,7 @@ vertical_alignment = 1
wait_time = 4.0 wait_time = 4.0
one_shot = true one_shot = true
[node name="BackpackUI" type="Label" parent="."] [node name="HUD" type="Label" parent="."]
offset_right = 200.0 offset_right = 200.0
offset_bottom = 200.0 offset_bottom = 200.0
text = "Pictures of you" text = "Pictures of you"