scopedvr-map-editor/src/ui/new_map_dialog.gd

94 lines
3.5 KiB
GDScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

extends ConfirmationDialog
## „Neue Map“-Dialog: Name, Größe, Wetter-Preset — bewusst nur 3 Fragen,
## alles Weitere setzt vernünftige Defaults (Chef-Grundsatz: easy).
const UIScale := preload("res://src/ui/ui_scale.gd") # Karte t_297221b5
var name_edit: LineEdit
var size_option: OptionButton
var weather_option: OptionButton
var mode_option: OptionButton
var _sizes: Array[float] = [512.0, 1024.0, 2048.0]
var _size_labels := ["Klein — 512 × 512 m", "Mittel — 1024 × 1024 m", "Groß — 2048 × 2048 m"]
var _weathers := ["mittag", "abend", "regen", "nacht"]
var _weather_labels := ["Mittag (sonnig, klar)", "Abend (warmes Licht)", "Regen (grau, kühl)", "Nacht (dunkel)"]
func _init() -> void:
title = "Neue Map"
ok_button_text = "Map erstellen"
cancel_button_text = "Abbrechen"
min_size = UIScale.v2i(460, 0)
var vbox := VBoxContainer.new()
vbox.anchors_preset = Control.PRESET_FULL_RECT
vbox.set_anchors_preset(Control.PRESET_FULL_RECT)
vbox.add_theme_constant_override("separation", UIScale.px(12))
add_child(vbox)
vbox.add_child(_make_label("Wie soll die Map heißen?"))
name_edit = LineEdit.new()
name_edit.text = "Neue Map"
name_edit.max_length = 64
name_edit.custom_minimum_size = UIScale.v2(0, 40)
vbox.add_child(name_edit)
vbox.add_child(_make_label("Wie groß soll das Gelände sein?"))
size_option = OptionButton.new()
for label in _size_labels:
size_option.add_item(label)
size_option.select(1) # Mittel als Default
size_option.custom_minimum_size = UIScale.v2(0, 40)
# U7: Klartext-Tooltips (Karte t_2336c58e).
size_option.tooltip_text = "Kantenlänge des Geländes — größer = mehr Platz zum Bauen"
vbox.add_child(size_option)
vbox.add_child(_make_label("Welches Wetter soll die Map haben?"))
weather_option = OptionButton.new()
for label in _weather_labels:
weather_option.add_item(label)
weather_option.custom_minimum_size = UIScale.v2(0, 40)
weather_option.tooltip_text = "Licht und Stimmung der Karte (Tag/Abend/Regen/Nacht)"
vbox.add_child(weather_option)
vbox.add_child(_make_label("Welchen Spielmodus soll die Map haben?"))
mode_option = OptionButton.new()
for m in ModusKatalog.MODES:
mode_option.add_item(ModusKatalog.MODE_LABELS[m])
mode_option.custom_minimum_size = UIScale.v2(0, 40)
mode_option.tooltip_text = "Team-Deathmatch: Kills zählen. Conquest: Teams nehmen mehrere Zonen ein. King of the Hill: ein Hill, der wandert. Deathmatch: alle gegen alle. Lässt sich später im Map-Tab ändern."
vbox.add_child(mode_option)
var hint := _make_label("Die Map startet leer mit 4 Spawn-Punkten pro Team\n(Blau im Westen, Rot im Osten) — beides lässt sich später ändern.")
hint.modulate = Color(1, 1, 1, 0.7)
vbox.add_child(hint)
func _make_label(text: String) -> Label:
var label := Label.new()
label.text = text
label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
# FIX 20.10.: autowrap-Label ohne Mindestbreite meldet vor dem ersten
# Layout eine explosionsartige Mindesthöhe (Probe: Fenster 4781 px hoch
# statt ~390) — Popup-Größe wird daraus einmalig übernommen. Mindestbreite
# ~ Dialogbreite verankert den Umbruch an der echten Breite.
label.custom_minimum_size = Vector2(UIScale.px(440), 0)
return label
func get_map_name() -> String:
var n := name_edit.text.strip_edges()
return n if not n.is_empty() else "Neue Map"
func get_size_m() -> float:
return _sizes[size_option.selected]
func get_game_mode() -> String:
return ModusKatalog.MODES[mode_option.selected]
func get_weather() -> String:
return _weathers[weather_option.selected]