class_name SettingsScreen extends Control var app var volume: HSlider var music: HSlider var speed: HSlider var language: OptionButton var music_label: Label var big_font: CheckButton var confirm: Control 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, "Große Schrift", 20, Style.TEXT, "left", false, 200) big_font = CheckButton.new() big_font.button_pressed = bool(s.get("big_font", false)) big_font.toggled.connect(_on_big_font) grid.add_child(big_font) 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, 30) var r := Style.row(col, 16) r.alignment = BoxContainer.ALIGNMENT_CENTER Style.cbutton(r, "Profil zurücksetzen", Vector2(200, 44), func(): confirm.visible = true, Color("5a2828")) Style.cbutton(r, "Zurück", Vector2(160, 44), func(): app.show_screen(MenuScreen.new())) confirm = Control.new() confirm.set_anchors_preset(Control.PRESET_FULL_RECT) confirm.visible = false var dark := ColorRect.new() dark.color = Color(0, 0, 0, 0.67) dark.set_anchors_preset(Control.PRESET_FULL_RECT) dark.mouse_filter = Control.MOUSE_FILTER_STOP confirm.add_child(dark) Style.panel(confirm, Rect2(340, 290, 600, 200), Style.PANEL, 10, Style.RED, 2) Style.label(confirm, "Profil wirklich zurücksetzen?", 26, Style.TEXT, Rect2(340, 312, 600, 40), "center", true) Style.label(confirm, "Sammlung, Decks, Münzen und Fortschritt gehen verloren.", 16, Style.MUTED, Rect2(340, 360, 600, 24), "center") Style.button(confirm, "Ja, zurücksetzen", Rect2(380, 420, 240, 46), _reset, Color("5a2828")) Style.button(confirm, "Abbrechen", Rect2(660, 420, 240, 46), func(): confirm.visible = false) add_child(confirm) _labels() func _reset() -> void: app.reset_profile() app.show_screen(MenuScreen.new()) func _on_big_font(on: bool) -> void: app.profile.settings.big_font = on app.save() app.apply_settings() app.show_screen(SettingsScreen.new()) 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())