71 lines
2.3 KiB
GDScript
71 lines
2.3 KiB
GDScript
extends ConfirmationDialog
|
||
## „Neue Map“-Dialog: Name, Größe, Wetter-Preset — bewusst nur 3 Fragen,
|
||
## alles Weitere setzt vernünftige Defaults (Chef-Grundsatz: easy).
|
||
|
||
var name_edit: LineEdit
|
||
var size_option: OptionButton
|
||
var weather_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 = Vector2i(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", 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 = Vector2(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 = Vector2(0, 40)
|
||
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 = Vector2(0, 40)
|
||
vbox.add_child(weather_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
|
||
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_weather() -> String:
|
||
return _weathers[weather_option.selected]
|