Add comprehensive UI system with action bar, unit frame, and character sheet
- Created UI system in level/ui/ folder - Action bar with 12 ability slots (Attack, Block, Dash, Jump + 8 expansion slots) - Unit frame showing player portrait with health bar - Character sheet/spellbook (toggle with Tab) displaying stats, weapons, and abilities - Tab hint indicator showing how to open character sheet - Custom theme with golden borders and dark backgrounds - UI Components: - HUD Manager autoload handles all UI initialization and player connections - Ability buttons with cooldown overlay and keybind display - Real-time health and cooldown tracking via signals - Scrollable character sheet with two-page layout - Player Integration: - Added UI signals: dash_cooldown_updated, attack_cooldown_updated, weapon_equipped_changed - Mouse capture system (Escape to toggle, click to recapture) - Synced attack cooldown from weapons to player for UI tracking - Updated level.gd to connect local player to HUD Manager - Updated CLAUDE.md with git commit guidelines
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
extends Control
|
||||
class_name ResourceBars
|
||||
## Resource bars (Health, Stamina, etc.) displayed above the action bar
|
||||
|
||||
# Health bar references
|
||||
@onready var health_bg: ColorRect = $VBoxContainer/HealthBar/Background
|
||||
@onready var health_fill: ColorRect = $VBoxContainer/HealthBar/Background/Fill
|
||||
@onready var health_text: Label = $VBoxContainer/HealthBar/HealthText
|
||||
|
||||
# Future: Stamina bar references
|
||||
# @onready var stamina_bg: ColorRect = $VBoxContainer/StaminaBar/Background
|
||||
# @onready var stamina_fill: ColorRect = $VBoxContainer/StaminaBar/Background/Fill
|
||||
|
||||
# Player reference
|
||||
var player: Character = null
|
||||
|
||||
# Smoothing
|
||||
var target_health_width: float = 0.0
|
||||
var current_health_width: float = 0.0
|
||||
const HEALTH_LERP_SPEED: float = 10.0
|
||||
|
||||
# Colors
|
||||
const COLOR_HEALTH_HIGH = Color(0.0, 0.8, 0.0, 1.0) # Green (>60%)
|
||||
const COLOR_HEALTH_MID = Color(1.0, 0.8, 0.0, 1.0) # Yellow (30-60%)
|
||||
const COLOR_HEALTH_LOW = Color(0.8, 0.0, 0.0, 1.0) # Red (<30%)
|
||||
|
||||
func _ready():
|
||||
# Initialize bars
|
||||
if health_fill:
|
||||
current_health_width = health_fill.size.x
|
||||
target_health_width = health_fill.size.x
|
||||
|
||||
print("[ResourceBars] Resource bars initialized")
|
||||
|
||||
func _process(delta):
|
||||
# Smooth health bar animation
|
||||
if health_fill and abs(current_health_width - target_health_width) > 0.1:
|
||||
current_health_width = lerp(current_health_width, target_health_width, HEALTH_LERP_SPEED * delta)
|
||||
health_fill.size.x = current_health_width
|
||||
|
||||
## Set player reference
|
||||
func set_player(p: Character):
|
||||
player = p
|
||||
if player:
|
||||
update_health(player.current_health, player.max_health)
|
||||
|
||||
## Update health bar display
|
||||
func update_health(current: float, maximum: float):
|
||||
if not health_fill or not health_bg or not health_text:
|
||||
return
|
||||
|
||||
var health_percent = current / maximum if maximum > 0 else 0.0
|
||||
health_percent = clamp(health_percent, 0.0, 1.0)
|
||||
|
||||
# Update fill width
|
||||
var max_width = health_bg.size.x
|
||||
target_health_width = max_width * health_percent
|
||||
|
||||
# Update color based on health percentage
|
||||
if health_percent > 0.6:
|
||||
health_fill.color = COLOR_HEALTH_HIGH
|
||||
elif health_percent > 0.3:
|
||||
health_fill.color = COLOR_HEALTH_MID
|
||||
else:
|
||||
health_fill.color = COLOR_HEALTH_LOW
|
||||
|
||||
# Update text
|
||||
health_text.text = "%d / %d HP" % [int(current), int(maximum)]
|
||||
|
||||
## Update stamina bar (for future use)
|
||||
func update_stamina(current: float, maximum: float):
|
||||
# TODO: Implement when stamina system is added
|
||||
pass
|
||||
Reference in New Issue
Block a user