From 8ddc20683b18379f1f03420c5139b74a0de44058 Mon Sep 17 00:00:00 2001 From: Andre Date: Thu, 19 Mar 2026 22:09:42 +0100 Subject: [PATCH] feat: XP-Leiste unter Aktionsleiste, gleiche Breite, Label zentriert MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - XP-Bar: Anker-basiert (0.5/1.0), gleiche Breite wie Actionbar (468px) - XP-Label zentriert: "Level X — current / max XP" - Actionbar 12px nach oben verschoben für XP-Bar Platz - Level-Label und Gold-Label oben links, kompakter Co-Authored-By: Claude Sonnet 4.6 --- hud.gd | 84 ++++++++++++++++++++++++++++++++++---------------------- hud.tscn | 4 +-- 2 files changed, 53 insertions(+), 35 deletions(-) diff --git a/hud.gd b/hud.gd index 50490ee..753a6b9 100644 --- a/hud.gd +++ b/hud.gd @@ -214,64 +214,79 @@ func set_slot_cooldown(slot_index: int, remaining_time: float): func _create_level_ui(): var control = $Control - # Level Label - level_label = Label.new() - level_label.name = "LevelLabel" - level_label.position = Vector2(20, 55) - level_label.add_theme_font_size_override("font_size", 14) - level_label.text = "Level 1" - control.add_child(level_label) - - # XP Bar - xp_bar = ProgressBar.new() - xp_bar.name = "XPBar" - xp_bar.position = Vector2(80, 55) - xp_bar.size = Vector2(140, 18) - xp_bar.show_percentage = false - xp_bar.value = 0 - - # XP Bar Farbe (blau) - var xp_style = StyleBoxFlat.new() - xp_style.bg_color = Color(0.2, 0.4, 0.9, 1.0) - xp_bar.add_theme_stylebox_override("fill", xp_style) - - control.add_child(xp_bar) - - # Ressourcen-Bar (Mana/Energie/Wut) - unter HP-Bar + # Ressourcen-Bar (Mana/Energie/Wut) - unter HP-Bar, oben links resource_bar = ProgressBar.new() resource_bar.name = "ResourceBar" resource_bar.position = Vector2(20, 50) resource_bar.size = Vector2(200, 18) resource_bar.show_percentage = false resource_bar.value = 0 - resource_bar.visible = false # Nur sichtbar wenn Klasse Ressource hat + resource_bar.visible = false var resource_style = StyleBoxFlat.new() - resource_style.bg_color = Color(0.2, 0.3, 0.9, 1.0) # Blau für Mana (Standard) + resource_style.bg_color = Color(0.2, 0.3, 0.9, 1.0) resource_bar.add_theme_stylebox_override("fill", resource_style) resource_label = Label.new() resource_label.name = "ResourceLabel" - resource_label.size = Vector2(200, 20) + resource_label.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) resource_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER resource_label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER - resource_bar.add_child(resource_label) control.add_child(resource_bar) - # Level/XP etwas runter verschieben wegen Ressourcen-Bar - level_label.position = Vector2(20, 78) - xp_bar.position = Vector2(80, 78) + # Level Label oben links + level_label = Label.new() + level_label.name = "LevelLabel" + level_label.position = Vector2(20, 74) + level_label.add_theme_font_size_override("font_size", 14) + level_label.text = "Level 1" + control.add_child(level_label) - # Gold Label + # Gold Label oben links gold_label = Label.new() gold_label.name = "GoldLabel" - gold_label.position = Vector2(20, 102) + gold_label.position = Vector2(20, 94) gold_label.add_theme_font_size_override("font_size", 14) gold_label.add_theme_color_override("font_color", Color(1, 0.85, 0, 1)) gold_label.text = "0 Gold" control.add_child(gold_label) + # XP Bar — gleiche Breite wie Actionbar (468px), unten mittig, unter der Actionbar + xp_bar = ProgressBar.new() + xp_bar.name = "XPBar" + xp_bar.anchor_left = 0.5 + xp_bar.anchor_top = 1.0 + xp_bar.anchor_right = 0.5 + xp_bar.anchor_bottom = 1.0 + xp_bar.offset_left = -234.0 + xp_bar.offset_right = 234.0 + xp_bar.offset_top = -12.0 + xp_bar.offset_bottom = 0.0 + xp_bar.show_percentage = false + xp_bar.value = 0 + xp_bar.mouse_filter = Control.MOUSE_FILTER_IGNORE + + var xp_style = StyleBoxFlat.new() + xp_style.bg_color = Color(0.15, 0.5, 0.9, 1.0) + xp_bar.add_theme_stylebox_override("fill", xp_style) + + var xp_bg = StyleBoxFlat.new() + xp_bg.bg_color = Color(0.1, 0.1, 0.15, 0.85) + xp_bar.add_theme_stylebox_override("background", xp_bg) + + # XP Label zentriert in der Bar + var xp_label = Label.new() + xp_label.name = "XPLabel" + xp_label.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) + xp_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER + xp_label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER + xp_label.add_theme_font_size_override("font_size", 10) + xp_label.add_theme_color_override("font_color", Color(1, 1, 1, 0.9)) + xp_label.mouse_filter = Control.MOUSE_FILTER_IGNORE + xp_bar.add_child(xp_label) + control.add_child(xp_bar) + # Castbar — direkt über der Aktionsleiste positioniert _create_castbar() @@ -336,6 +351,9 @@ func update_level(level: int, current_xp: int, xp_to_next: int): if xp_bar: xp_bar.max_value = xp_to_next xp_bar.value = current_xp + var xp_label = xp_bar.get_node_or_null("XPLabel") + if xp_label: + xp_label.text = "Level %d — %d / %d XP" % [level, current_xp, xp_to_next] # Aktions-Slot kurz golden hervorheben (0.1s) func set_active_slot(index): diff --git a/hud.tscn b/hud.tscn index 1284e40..506ce2b 100644 --- a/hud.tscn +++ b/hud.tscn @@ -43,9 +43,9 @@ anchor_top = 1.0 anchor_right = 0.5 anchor_bottom = 1.0 offset_left = -234.0 -offset_top = -65.0 +offset_top = -77.0 offset_right = 234.0 -offset_bottom = -10.0 +offset_bottom = -22.0 grow_horizontal = 2 grow_vertical = 0