Initial
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
extends CanvasLayer
|
||||
|
||||
@onready var name_label = $Control/HBoxContainer/LeftPanel/CharacterInfo/NameLabel
|
||||
@onready var level_label = $Control/HBoxContainer/LeftPanel/CharacterInfo/LevelLabel
|
||||
@onready var xp_bar = $Control/HBoxContainer/LeftPanel/CharacterInfo/XPBar
|
||||
|
||||
@onready var str_value = $Control/HBoxContainer/LeftPanel/StatsPanel/StrValue
|
||||
@onready var int_value = $Control/HBoxContainer/LeftPanel/StatsPanel/IntValue
|
||||
@onready var wis_value = $Control/HBoxContainer/LeftPanel/StatsPanel/WisValue
|
||||
@onready var end_value = $Control/HBoxContainer/LeftPanel/StatsPanel/EndValue
|
||||
@onready var dex_value = $Control/HBoxContainer/LeftPanel/StatsPanel/DexValue
|
||||
@onready var points_label = $Control/HBoxContainer/LeftPanel/StatsPanel/PointsRemaining
|
||||
|
||||
@onready var enter_btn = $Control/HBoxContainer/RightPanel/EnterDungeonBtn
|
||||
|
||||
var selected_tier: int = 1
|
||||
|
||||
func _ready():
|
||||
enter_btn.pressed.connect(_on_enter_dungeon)
|
||||
|
||||
# Setup tier buttons
|
||||
for i in range(1, 6):
|
||||
var btn_path = "Control/HBoxContainer/RightPanel/TierSelection/Tier%dBtn" % i
|
||||
if has_node(btn_path):
|
||||
var btn = get_node(btn_path)
|
||||
btn.pressed.connect(_on_tier_selected.bind(i))
|
||||
|
||||
# Setup stat buttons
|
||||
for stat in ["Str", "Int", "Wis", "End", "Dex"]:
|
||||
var btn_path = "Control/HBoxContainer/LeftPanel/StatsPanel/%sButton" % stat
|
||||
if has_node(btn_path):
|
||||
var btn = get_node(btn_path)
|
||||
btn.pressed.connect(_on_stat_allocate.bind(stat.to_lower()))
|
||||
|
||||
# Defer GameState connection
|
||||
call_deferred("_connect_gamestate")
|
||||
|
||||
func _connect_gamestate():
|
||||
if GameState:
|
||||
GameState.character_updated.connect(_update_ui)
|
||||
|
||||
func _update_ui():
|
||||
var c = GameState.character
|
||||
name_label.text = c.name
|
||||
level_label.text = "Level %d" % c.level
|
||||
xp_bar.max_value = c.xp_next
|
||||
xp_bar.value = c.xp
|
||||
|
||||
str_value.text = str(c.strength)
|
||||
int_value.text = str(c.intelligence)
|
||||
wis_value.text = str(c.wisdom)
|
||||
end_value.text = str(c.endurance)
|
||||
dex_value.text = str(c.dexterity)
|
||||
|
||||
points_label.text = "Points: %d" % c.unspent_points
|
||||
|
||||
# Enable/disable stat buttons based on available points
|
||||
var has_points = c.unspent_points > 0
|
||||
for stat in ["Str", "Int", "Wis", "End", "Dex"]:
|
||||
var btn_path = "Control/HBoxContainer/LeftPanel/StatsPanel/%sButton" % stat
|
||||
if has_node(btn_path):
|
||||
var btn = get_node(btn_path)
|
||||
btn.disabled = not has_points
|
||||
|
||||
func _on_tier_selected(tier: int):
|
||||
selected_tier = tier
|
||||
# Update button visuals
|
||||
for i in range(1, 6):
|
||||
var btn_path = "Control/HBoxContainer/RightPanel/TierSelection/Tier%dBtn" % i
|
||||
if has_node(btn_path):
|
||||
var btn = get_node(btn_path)
|
||||
btn.button_pressed = (i == tier)
|
||||
|
||||
func _on_stat_allocate(stat: String):
|
||||
if GameState.character.unspent_points > 0:
|
||||
GameState.send_allocate_stat(stat)
|
||||
|
||||
func _on_enter_dungeon():
|
||||
GameState.send_enter_dungeon(selected_tier)
|
||||
Reference in New Issue
Block a user