Elemente, Kombos, Fallen, KI mit Vorausschau, Kampagne, Hotseat und Netzwerk, Werkstatt, Erfolge, Tagesaufgaben, Tests und Exporte. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QPgKvy5W9WRNFHjkm5QsHx
122 lines
3.8 KiB
GDScript
122 lines
3.8 KiB
GDScript
class_name SettingsScreen
|
|
extends Control
|
|
|
|
var app
|
|
var volume: HSlider
|
|
var music: HSlider
|
|
var speed: HSlider
|
|
var language: OptionButton
|
|
var music_label: Label
|
|
var anim: CheckButton
|
|
var volume_label: Label
|
|
var speed_label: Label
|
|
|
|
|
|
func _ready() -> void:
|
|
var s: Dictionary = app.profile.settings
|
|
var col := Style.column(self, 700, 50, 24)
|
|
Style.clabel(col, "Einstellungen", 36, Style.GOLD, "center", true)
|
|
Style.spacer(col, 30)
|
|
var grid := GridContainer.new()
|
|
grid.columns = 3
|
|
grid.add_theme_constant_override("h_separation", 24)
|
|
grid.add_theme_constant_override("v_separation", 30)
|
|
col.add_child(grid)
|
|
Style.clabel(grid, "Lautstärke", 20, Style.TEXT, "left", false, 200)
|
|
volume = HSlider.new()
|
|
volume.custom_minimum_size = Vector2(280, 24)
|
|
volume.min_value = 0
|
|
volume.max_value = 1
|
|
volume.step = 0.05
|
|
volume.value = s.volume
|
|
volume.value_changed.connect(_on_volume)
|
|
grid.add_child(volume)
|
|
volume_label = Style.clabel(grid, "", 18, Style.MUTED, "left", false, 100)
|
|
Style.clabel(grid, "Musik", 20, Style.TEXT, "left", false, 200)
|
|
music = HSlider.new()
|
|
music.custom_minimum_size = Vector2(280, 24)
|
|
music.min_value = 0
|
|
music.max_value = 1
|
|
music.step = 0.05
|
|
music.value = s.music
|
|
music.value_changed.connect(_on_music)
|
|
grid.add_child(music)
|
|
music_label = Style.clabel(grid, "", 18, Style.MUTED, "left", false, 100)
|
|
Style.clabel(grid, "KI-Tempo", 20, Style.TEXT, "left", false, 200)
|
|
speed = HSlider.new()
|
|
speed.custom_minimum_size = Vector2(280, 24)
|
|
speed.min_value = 0.5
|
|
speed.max_value = 3.0
|
|
speed.step = 0.25
|
|
speed.value = s.ai_speed
|
|
speed.value_changed.connect(_on_speed)
|
|
grid.add_child(speed)
|
|
speed_label = Style.clabel(grid, "", 18, Style.MUTED, "left", false, 100)
|
|
Style.clabel(grid, "Animationen", 20, Style.TEXT, "left", false, 200)
|
|
anim = CheckButton.new()
|
|
anim.button_pressed = s.animations
|
|
anim.toggled.connect(_on_anim)
|
|
grid.add_child(anim)
|
|
Style.clabel(grid, "", 18, Style.MUTED, "left", false, 100)
|
|
Style.clabel(grid, "Sprache", 20, Style.TEXT, "left", false, 200)
|
|
language = OptionButton.new()
|
|
language.custom_minimum_size = Vector2(280, 36)
|
|
language.add_item("Deutsch", 0)
|
|
language.add_item("English (Oberfläche)", 1)
|
|
language.select(1 if s.language == "en" else 0)
|
|
language.item_selected.connect(_on_language)
|
|
grid.add_child(language)
|
|
Style.clabel(grid, "", 18, Style.MUTED, "left", false, 100)
|
|
Style.spacer(col, 20)
|
|
Style.clabel(col, "Der Spielstand liegt unter %s" % ProjectSettings.globalize_path(Profile.SAVE_PATH), 13, Style.MUTED)
|
|
Style.spacer(col, 60)
|
|
var r := Style.row(col)
|
|
r.alignment = BoxContainer.ALIGNMENT_CENTER
|
|
Style.cbutton(r, "Zurück", Vector2(160, 44), func(): app.show_screen(MenuScreen.new()))
|
|
_labels()
|
|
|
|
|
|
func _labels() -> void:
|
|
volume_label.text = "%d %%" % int(round(volume.value * 100))
|
|
music_label.text = "%d %%" % int(round(music.value * 100))
|
|
speed_label.text = "%.2fx" % speed.value
|
|
|
|
|
|
func _on_music(v: float) -> void:
|
|
app.profile.settings.music = v
|
|
app.sfx.set_music_volume(v)
|
|
app.save()
|
|
_labels()
|
|
|
|
|
|
func _on_language(i: int) -> void:
|
|
var code := "en" if i == 1 else "de"
|
|
app.profile.settings.language = code
|
|
app.save()
|
|
app.set_language(code)
|
|
app.show_screen(SettingsScreen.new())
|
|
|
|
|
|
func _on_volume(v: float) -> void:
|
|
app.profile.settings.volume = v
|
|
app.sfx.set_volume(v)
|
|
app.sfx.play("click")
|
|
app.save()
|
|
_labels()
|
|
|
|
|
|
func _on_speed(v: float) -> void:
|
|
app.profile.settings.ai_speed = v
|
|
app.save()
|
|
_labels()
|
|
|
|
|
|
func _on_anim(on: bool) -> void:
|
|
app.profile.settings.animations = on
|
|
app.save()
|
|
|
|
|
|
func _input(event: InputEvent) -> void:
|
|
if event is InputEventKey and event.pressed and event.keycode == KEY_ESCAPE:
|
|
app.show_screen(MenuScreen.new())
|