This commit is contained in:
team3
2026-09-16 13:21:45 +02:00
parent 8a188c5d5c
commit 49e8f2d95e
27 changed files with 1772 additions and 265 deletions

51
scripts/ui/TooltipView.gd Normal file
View File

@@ -0,0 +1,51 @@
class_name TooltipView
extends Control
## Zeichnet den Einheiten-Tooltip über allen Panels. Die Daten liegen im HudOverlay.
var hud: HudOverlay = null
var _font: Font
func _ready() -> void:
_font = ThemeDB.fallback_font
mouse_filter = Control.MOUSE_FILTER_IGNORE
set_process(true)
func _process(_delta: float) -> void:
queue_redraw()
func _draw() -> void:
if hud == null or hud.tooltip_avatar == null:
return
var a := hud.tooltip_avatar
var st := a.base_stats()
var lines := []
lines.append("%s %d-Star" % [a.display_name(), a.star])
if hud.tooltip_note != "":
lines.append(hud.tooltip_note)
lines.append("Leben %d Angriff %d Rüstung %d%%" % [int(st["hp"]), int(st["atk"]), int(st["armor"] * 100.0)])
var extra := "Tempo %.2f Reichweite %d" % [st["aspd"], st["range"]]
if st["crit"] > 0.0:
extra += " Krit %d%%" % int(st["crit"] * 100.0)
lines.append(extra)
lines.append(a.counter_text())
for l in a.ability_text().split("\n"):
lines.append(l)
var w := 0.0
for l in lines:
w = maxf(w, _font.get_string_size(l, HORIZONTAL_ALIGNMENT_LEFT, -1, 12).x)
w += 20.0
var h := 8.0 + 17.0 * lines.size()
var vp := get_viewport_rect().size
var pos := hud.tooltip_pos + Vector2(16.0, 16.0)
pos.x = clampf(pos.x, 8.0, vp.x - w - 8.0)
pos.y = clampf(pos.y, 8.0, vp.y - h - 8.0)
draw_rect(Rect2(pos, Vector2(w, h)), Color(0.08, 0.09, 0.12, 0.96))
draw_rect(Rect2(pos, Vector2(w, h)), a.color(), false, 2.0)
for i in lines.size():
var col := a.color() if i == 0 else Color(0.9, 0.9, 0.95)
draw_string(_font, pos + Vector2(10.0, 18.0 + 17.0 * float(i)), lines[i],
HORIZONTAL_ALIGNMENT_LEFT, -1, 12, col)