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

161
scripts/ui/Overlays.gd Normal file
View File

@@ -0,0 +1,161 @@
class_name Overlays
extends Control
## Start-, Pause-, Ausscheide- und Endbildschirm. Meldet Knöpfe per Signal.
signal start_pressed(continue_save: bool)
signal difficulty_changed(d: int)
signal volume_changed(v: float)
signal resume_pressed
signal restart_pressed
signal spectate_pressed
var current: Control = null ## das offene Overlay, null wenn keins
var volume := 0.8
var difficulty := Data.Difficulty.NORMAL
func _ready() -> void:
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
mouse_filter = Control.MOUSE_FILTER_IGNORE
func is_open() -> bool:
return current != null
func kind() -> String:
return current.get_meta("kind", "") if current != null else ""
func close() -> void:
if current != null:
current.queue_free()
current = null
func _box(title: String, kind_name: String) -> VBoxContainer:
close()
current = ColorRect.new()
current.color = Color(0, 0, 0, 0.72)
current.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
current.set_meta("kind", kind_name)
add_child(current)
var v := VBoxContainer.new()
v.position = Vector2(560, 240)
v.custom_minimum_size = Vector2(480, 0)
v.add_theme_constant_override("separation", 12)
current.add_child(v)
v.add_child(UiKit.label(title, 32))
return v
func _volume_row() -> HBoxContainer:
var h := HBoxContainer.new()
h.add_theme_constant_override("separation", 10)
h.add_child(UiKit.label("Lautstärke", 14))
var sl := HSlider.new()
sl.min_value = 0.0
sl.max_value = 1.0
sl.step = 0.05
sl.value = volume
sl.custom_minimum_size = Vector2(220, 20)
sl.focus_mode = Control.FOCUS_NONE
sl.value_changed.connect(func(v):
volume = v
volume_changed.emit(v))
h.add_child(sl)
return h
func _difficulty_row() -> HBoxContainer:
var h := HBoxContainer.new()
h.add_theme_constant_override("separation", 8)
h.add_child(UiKit.label("Bots", 14))
for d in Data.DIFFICULTY_NAMES.size():
var b := UiKit.button(Data.DIFFICULTY_NAMES[d],
Color(0.30, 0.50, 0.38) if d == difficulty else Color(0.25, 0.28, 0.36))
b.custom_minimum_size = Vector2(90, 28)
b.pressed.connect(func():
difficulty = d
difficulty_changed.emit(d))
h.add_child(b)
return h
func _button(v: VBoxContainer, text: String, col: Color, cb: Callable, w: float = 200.0) -> Button:
var b := UiKit.button(text, col)
b.custom_minimum_size = Vector2(w, 36)
b.pressed.connect(cb)
v.add_child(b)
return b
func show_start(has_save: bool) -> void:
var v := _box("Elements Autochess", "start")
v.add_child(UiKit.label("8 Spieler, 100 Leben, Elemente als Traits. Basis wie TFT.", 15,
Color(0.8, 0.85, 0.95)))
v.add_child(UiKit.label(
"Ziehen: Bank ↔ Feld · Rechtsklick: verkaufen · 1–5 kaufen · D würfeln · F einfrieren\\nX Level · Z Verkauf rückgängig · Q/E drehen · Mausrad zoomen · P Pause · Leertaste Kampf",
13, Color(0.7, 0.72, 0.8)))
v.add_child(UiKit.label(
"Konter: Wasser > Feuer > Eis > Wind > Erde > Blitz > Wasser (±20%) · Tank > Schütze > Heiler > Tank (±15%)",
13, Color(1.0, 0.75, 0.9)))
v.add_child(_difficulty_row())
v.add_child(_volume_row())
if has_save:
_button(v, "Weiterspielen", Color(0.28, 0.5, 0.36), func(): start_pressed.emit(true))
_button(v, "Neue Partie", Color(0.25, 0.28, 0.36), func(): start_pressed.emit(false))
else:
_button(v, "Spiel starten", Color(0.28, 0.5, 0.36), func(): start_pressed.emit(false))
func show_pause() -> void:
var v := _box("Pause", "pause")
v.add_child(UiKit.label("Der Spielstand wurde gespeichert.", 13, Color(0.7, 0.72, 0.8)))
v.add_child(_volume_row())
_button(v, "Weiter [P]", Color(0.28, 0.5, 0.36), func(): resume_pressed.emit())
func show_eliminated(placement: int, round_no: int) -> void:
var v := _box("Ausgeschieden", "eliminated")
v.add_child(UiKit.label("Platz %d von 8 nach Runde %d" % [placement, round_no], 20,
Color(0.95, 0.75, 0.6)))
var h := HBoxContainer.new()
h.add_theme_constant_override("separation", 10)
var watch := UiKit.button("Zuschauen", Color(0.25, 0.28, 0.36))
watch.custom_minimum_size = Vector2(160, 36)
watch.pressed.connect(func(): spectate_pressed.emit())
h.add_child(watch)
var again := UiKit.button("Neues Spiel", Color(0.28, 0.5, 0.36))
again.custom_minimum_size = Vector2(160, 36)
again.pressed.connect(func(): restart_pressed.emit())
h.add_child(again)
v.add_child(h)
func show_gameover(game: Game) -> void:
var v := _box("Spiel vorbei", "gameover")
var alive := game.alive_players()
var win: String = alive[0].pname if not alive.is_empty() else "-"
v.add_child(UiKit.label("Sieger: %s" % win, 20, Color(1.0, 0.85, 0.35)))
var p := game.human
var place := p.placement if p.placement > 0 else 1
v.add_child(UiKit.label("Dein Platz: %d von 8" % place, 18,
Color(0.6, 0.95, 0.7) if place <= 4 else Color(0.95, 0.6, 0.6)))
var st := p.stats
var best := "-"
var best_star := 0
for u in p.board_units():
if u.star > best_star:
best_star = u.star
best = u.display_name()
var lines := [
"Runden: %d Siege: %d Niederlagen: %d" % [game.round_no, st["wins"], st["losses"]],
"Gold verdient: %d ausgegeben: %d" % [st["gold_earned"], st["spent"]],
"Höchste Stufe: %d-Star Level: %d" % [st["max_star"], p.level],
"Stärkste Einheit: %s" % best,
]
for l in lines:
v.add_child(UiKit.label(l, 14, Color(0.85, 0.88, 0.95)))
_button(v, "Neues Spiel", Color(0.28, 0.5, 0.36), func(): restart_pressed.emit())