diff --git a/scenes/ui/main_menu.tscn b/scenes/ui/main_menu.tscn index 4ba64a2..fa52a0b 100644 --- a/scenes/ui/main_menu.tscn +++ b/scenes/ui/main_menu.tscn @@ -57,6 +57,11 @@ custom_minimum_size = Vector2(260, 48) layout_mode = 2 text = "Permadeath: AN" +[node name="ExplicitButton" type="Button" parent="CenterContainer/VBoxContainer"] +custom_minimum_size = Vector2(260, 48) +layout_mode = 2 +text = "Explizite Inhalte: AUS" + [node name="QuitButton" type="Button" parent="CenterContainer/VBoxContainer"] custom_minimum_size = Vector2(260, 48) layout_mode = 2 diff --git a/scenes/ui/mature_gate.tscn b/scenes/ui/mature_gate.tscn new file mode 100644 index 0000000..f8cbd4b --- /dev/null +++ b/scenes/ui/mature_gate.tscn @@ -0,0 +1,61 @@ +[gd_scene load_steps=2 format=3] + +[ext_resource type="Script" path="res://scripts/ui/mature_gate.gd" id="1_gate"] + +[node name="MatureGate" type="CanvasLayer"] +layer = 10 +script = ExtResource("1_gate") + +[node name="Root" type="ColorRect" parent="."] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0.05, 0.06, 0.08, 1) + +[node name="Panel" type="PanelContainer" parent="Root"] +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -320.0 +offset_top = -190.0 +offset_right = 320.0 +offset_bottom = 190.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Margin" type="MarginContainer" parent="Root/Panel"] +theme_override_constants/margin_left = 24 +theme_override_constants/margin_top = 20 +theme_override_constants/margin_right = 24 +theme_override_constants/margin_bottom = 20 + +[node name="Content" type="VBoxContainer" parent="Root/Panel/Margin"] +theme_override_constants/separation = 14 + +[node name="TitleLabel" type="Label" parent="Root/Panel/Margin/Content"] +theme_override_font_sizes/font_size = 34 +text = "Windgeschworen — ab 18 Jahren" +horizontal_alignment = 1 + +[node name="WarningLabel" type="Label" parent="Root/Panel/Margin/Content"] +size_flags_vertical = 3 +theme_override_font_sizes/font_size = 17 +text = "Dieses Spiel enthält Darstellungen von Gewalt, Tod und Krieg sowie Themen wie Verlust, Trauer und Bedrohung. Optionale explizite Inhalte sind standardmäßig deaktiviert und lassen sich im Hauptmenü zuschalten. + +Bitte bestätige, dass du mindestens 18 Jahre alt bist." +autowrap_mode = 3 + +[node name="Buttons" type="HBoxContainer" parent="Root/Panel/Margin/Content"] +theme_override_constants/separation = 12 +alignment = 1 + +[node name="ConfirmButton" type="Button" parent="Root/Panel/Margin/Content/Buttons"] +custom_minimum_size = Vector2(260, 46) +text = "Ich bin 18 oder älter" + +[node name="QuitButton" type="Button" parent="Root/Panel/Margin/Content/Buttons"] +custom_minimum_size = Vector2(160, 46) +text = "Beenden" diff --git a/scripts/autoloads/dialogue_system.gd b/scripts/autoloads/dialogue_system.gd index 0b9886b..9bb88ca 100644 --- a/scripts/autoloads/dialogue_system.gd +++ b/scripts/autoloads/dialogue_system.gd @@ -131,12 +131,24 @@ func _run_dialogue(data: Dictionary) -> void: _end_dialogue(str(data["id"]), was_aborted) +## Liefert den anzuzeigenden Text eines Knotens: Standard ist "text" +## (Fade-to-Black-Variante); trägt der Knoten ein optionales Feld +## "explicit_text" UND ist der Mature-Toggle aktiv, wird stattdessen die +## explizite Variante gezeigt (Romantik-Weiche, SPEC Abschnitt 6 — die +## expliziten Texte pflegt ausschließlich der Nutzer in den +## Dialog-Dateien, dieses Projekt liefert nur das Format). +func _node_text(node: Dictionary) -> String: + if MatureContentGate.is_explicit_enabled and node.has("explicit_text"): + return str(node["explicit_text"]) + return str(node.get("text", "")) + + ## Zeigt eine Zeile ohne Optionen in Box und Sprechblase; die Blase (oder ## ein Fallback-Timer) bestimmt die Anzeigedauer. Liefert die ID des ## Folge-Knotens. func _play_line(node: Dictionary) -> String: var speaker_id := str(node.get("speaker", "")) - var text := str(node.get("text", "")) + var text := _node_text(node) _get_box().show_line(_display_name(speaker_id), text) var bubble := _bubble_for(speaker_id) if bubble != null: @@ -168,7 +180,7 @@ func _wait_for_line(bubble: Node) -> void: ## die ID des Folge-Knotens. func _play_choice(node: Dictionary, options: Array) -> String: var speaker_id := str(node.get("speaker", "")) - var text := str(node.get("text", "")) + var text := _node_text(node) _get_box().show_line(_display_name(speaker_id), text) var bubble := _bubble_for(speaker_id) if bubble != null: diff --git a/scripts/autoloads/game_state.gd b/scripts/autoloads/game_state.gd index 918d726..afbec80 100644 --- a/scripts/autoloads/game_state.gd +++ b/scripts/autoloads/game_state.gd @@ -25,6 +25,12 @@ const DEFAULT_STRENGTH := 35 const DEFAULT_AGILITY := 35 const DEFAULT_INTELLECT := 15 +## Debug-Schalter für reine Test-Hilfsmittel (Tab-Save, F9/F10 fürs +## Fraktions-Standing). Zum Umschalten diese Zeile editieren: true beim +## Testen, false im Release-Kontext. Reguläres Speichern (Schlafsaal, +## Dreschen-Autosave) bleibt davon unberührt. Wird nicht gespeichert. +var is_debug_mode := true + var strength := DEFAULT_STRENGTH var agility := DEFAULT_AGILITY var intellect := DEFAULT_INTELLECT diff --git a/scripts/autoloads/mature_content_gate.gd b/scripts/autoloads/mature_content_gate.gd index 2dd3ffb..fa2d168 100644 --- a/scripts/autoloads/mature_content_gate.gd +++ b/scripts/autoloads/mature_content_gate.gd @@ -1,8 +1,64 @@ extends Node ## Mature-Content-Gate (Autoload, SPEC.md Abschnitte 6 und 8). ## -## Verwaltet ab Phase 6 das 18+-Gate beim ersten Start, die Content-Warnung -## und den Options-Toggle (Default AUS). Schaltet Romantik-Szenen zweigleisig: -## Fade-to-Black (Default) oder explizite Textvarianten aus gegateten -## Datendateien, die ausschließlich vom Nutzer gepflegt werden. Phase 0: -## leeres Skelett ohne Logik. +## Verwaltet die einmalige 18+-Bestätigung beim ersten Programmstart und +## den Options-Toggle "Explizite Inhalte" (Default AUS). Beides liegt +## persistent in user://settings.json — bewusst getrennt vom Spielstand, +## weil es installations- statt durchlaufbezogen ist. Romantik-Szenen- +## Weiche: Dialog-Knoten dürfen ein optionales Feld "explicit_text" +## tragen; das DialogueSystem zeigt es nur bei aktivem Toggle statt +## "text" an (Fade-to-Black-Variante bleibt der Standardtext). Explizite +## Textvarianten pflegt laut SPEC ausschließlich der Nutzer in gegateten +## Datendateien — dieses Projekt legt nur Format und Weiche an. + +const SETTINGS_PATH := "user://settings.json" + +var is_age_confirmed := false +var is_explicit_enabled := false + + +## Lädt die persistenten Einstellungen beim Start. +func _ready() -> void: + _load_settings() + + +## Bestätigt die 18+-Abfrage dauerhaft (Gate erscheint danach nie wieder). +func confirm_age() -> void: + is_age_confirmed = true + _save_settings() + + +## Schaltet explizite Inhalte um und speichert die Wahl persistent. +func set_explicit_enabled(is_enabled: bool) -> void: + is_explicit_enabled = is_enabled + _save_settings() + + +## Liest user://settings.json; fehlende Datei bedeutet Erststart. +func _load_settings() -> void: + if not FileAccess.file_exists(SETTINGS_PATH): + return + var file := FileAccess.open(SETTINGS_PATH, FileAccess.READ) + if file == null: + push_warning("Einstellungen nicht lesbar: %s" % SETTINGS_PATH) + return + var parsed: Variant = JSON.parse_string(file.get_as_text()) + file.close() + if not (parsed is Dictionary): + push_warning("Einstellungen beschädigt: %s" % SETTINGS_PATH) + return + is_age_confirmed = bool(parsed.get("is_age_confirmed", false)) + is_explicit_enabled = bool(parsed.get("is_explicit_enabled", false)) + + +## Schreibt die Einstellungen nach user://settings.json. +func _save_settings() -> void: + var file := FileAccess.open(SETTINGS_PATH, FileAccess.WRITE) + if file == null: + push_error("Einstellungen nicht schreibbar: %s" % error_string(FileAccess.get_open_error())) + return + file.store_string(JSON.stringify({ + "is_age_confirmed": is_age_confirmed, + "is_explicit_enabled": is_explicit_enabled, + }, "\t")) + file.close() diff --git a/scripts/gameplay/hub_room.gd b/scripts/gameplay/hub_room.gd index 9247b1d..9351faa 100644 --- a/scripts/gameplay/hub_room.gd +++ b/scripts/gameplay/hub_room.gd @@ -28,8 +28,12 @@ func _ready() -> void: player.global_position = spawn.global_position -## Speichert bei menu und wechselt zurück ins Hauptmenü. +## Debug-Hilfe: Speichert bei menu und wechselt zurück ins Hauptmenü — +## nur im Debug-Modus (GameState.is_debug_mode); regulär wird im +## Schlafsaal gespeichert. func _unhandled_input(event: InputEvent) -> void: + if not GameState.is_debug_mode: + return if event.is_action_pressed("menu"): SaveSystem.save_game() get_tree().change_scene_to_file(MAIN_MENU_SCENE) diff --git a/scripts/gameplay/sleep_trigger.gd b/scripts/gameplay/sleep_trigger.gd index 9ccdc33..f43e5e6 100644 --- a/scripts/gameplay/sleep_trigger.gd +++ b/scripts/gameplay/sleep_trigger.gd @@ -12,9 +12,12 @@ func _ready() -> void: body_entered.connect(_on_body_entered) -## Beendet den Tag, sobald der Spieler den Schlafbereich betritt. +## Beendet den Tag und speichert regulär, sobald der Spieler den +## Schlafbereich betritt — der Schlafsaal ist der reguläre Speicherpunkt +## des Spiels (unabhängig vom Debug-Modus). func _on_body_entered(body: Node3D) -> void: if not body.is_in_group("player"): return TimeSystem.end_day() - print("Geschlafen — Tag %d, %s." % [TimeSystem.day_count, TimeSystem.get_slot_name()]) + SaveSystem.save_game() + print("Geschlafen und gespeichert — Tag %d, %s." % [TimeSystem.day_count, TimeSystem.get_slot_name()]) diff --git a/scripts/gameplay/test_ground.gd b/scripts/gameplay/test_ground.gd index d1a422b..07225da 100644 --- a/scripts/gameplay/test_ground.gd +++ b/scripts/gameplay/test_ground.gd @@ -8,8 +8,11 @@ extends Node3D const MAIN_MENU_SCENE := "res://scenes/ui/main_menu.tscn" -## Speichert bei menu und wechselt zurück ins Hauptmenü. +## Debug-Hilfe: Speichert bei menu und wechselt zurück ins Hauptmenü — +## nur im Debug-Modus (GameState.is_debug_mode). func _unhandled_input(event: InputEvent) -> void: + if not GameState.is_debug_mode: + return if event.is_action_pressed("menu"): SaveSystem.save_game() get_tree().change_scene_to_file(MAIN_MENU_SCENE) diff --git a/scripts/ui/debug_overlay.gd b/scripts/ui/debug_overlay.gd index 5329675..11a9e56 100644 --- a/scripts/ui/debug_overlay.gd +++ b/scripts/ui/debug_overlay.gd @@ -51,7 +51,7 @@ func _on_dialogue_finished(_dialogue_id: String) -> void: ## verschieben testweise das Gezeichneten-Standing (reine Debug-Hilfe des ## Overlays, bewusst ohne Input-Action — fliegt mit dem Overlay raus). func _input(event: InputEvent) -> void: - if event is InputEventKey and event.pressed and not event.echo: + if GameState.is_debug_mode and event is InputEventKey and event.pressed and not event.echo: if event.physical_keycode == KEY_F9: FactionSystem.adjust_standing(FactionSystem.MARKED_FACTION_ID, -5) elif event.physical_keycode == KEY_F10: diff --git a/scripts/ui/main_menu.gd b/scripts/ui/main_menu.gd index 8633f1d..a501b61 100644 --- a/scripts/ui/main_menu.gd +++ b/scripts/ui/main_menu.gd @@ -12,10 +12,12 @@ extends Control const NEW_GAME_SCENE := "res://scenes/viaduct/viaduct.tscn" const CONTINUE_SCENE := "res://scenes/hub/rider_quadrant.tscn" +const MATURE_GATE_SCENE := preload("res://scenes/ui/mature_gate.tscn") @onready var _start_button: Button = $CenterContainer/VBoxContainer/StartButton @onready var _continue_button: Button = $CenterContainer/VBoxContainer/ContinueButton @onready var _permadeath_button: Button = $CenterContainer/VBoxContainer/PermadeathButton +@onready var _explicit_button: Button = $CenterContainer/VBoxContainer/ExplicitButton @onready var _quit_button: Button = $CenterContainer/VBoxContainer/QuitButton @@ -27,8 +29,15 @@ func _ready() -> void: _start_button.pressed.connect(_on_start_pressed) _continue_button.pressed.connect(_on_continue_pressed) _permadeath_button.pressed.connect(_on_permadeath_pressed) + _explicit_button.pressed.connect(_on_explicit_pressed) _quit_button.pressed.connect(_on_quit_pressed) _update_permadeath_text() + _update_explicit_text() + if not MatureContentGate.is_age_confirmed: + var gate := MATURE_GATE_SCENE.instantiate() + add_child(gate) + gate.confirmed.connect(func() -> void: _start_button.grab_focus()) + return _start_button.grab_focus.call_deferred() @@ -87,6 +96,18 @@ func _on_quit_pressed() -> void: get_tree().quit() +## Schaltet explizite Inhalte um (SPEC Abschnitt 6, Default AUS); die +## Wahl liegt persistent in user://settings.json (MatureContentGate). +func _on_explicit_pressed() -> void: + MatureContentGate.set_explicit_enabled(not MatureContentGate.is_explicit_enabled) + _update_explicit_text() + + ## Hält den Toggle-Text synchron zum GameState. func _update_permadeath_text() -> void: _permadeath_button.text = "Permadeath: %s" % ("AN" if GameState.is_permadeath_enabled else "AUS") + + +## Hält den Explizit-Toggle-Text synchron zum MatureContentGate. +func _update_explicit_text() -> void: + _explicit_button.text = "Explizite Inhalte: %s" % ("AN" if MatureContentGate.is_explicit_enabled else "AUS") diff --git a/scripts/ui/mature_gate.gd b/scripts/ui/mature_gate.gd new file mode 100644 index 0000000..eaf80c2 --- /dev/null +++ b/scripts/ui/mature_gate.gd @@ -0,0 +1,49 @@ +extends CanvasLayer +## 18+-Bestätigungs-Screen mit Content-Warnung (Phase 6a, SPEC.md +## Abschnitt 6). +## +## Erscheint als Overlay über dem Hauptmenü, nur beim allerersten +## Programmstart (MatureContentGate.is_age_confirmed). Fokus-navigierbar +## mit Tastatur und Controller nach dem confirm-Muster des Hauptmenüs; +## cancel springt auf Beenden. Bestätigen speichert dauerhaft und gibt +## das Menü frei, Beenden schließt das Spiel. + +signal confirmed + +@onready var _confirm_button: Button = $Root/Panel/Margin/Content/Buttons/ConfirmButton +@onready var _quit_button: Button = $Root/Panel/Margin/Content/Buttons/QuitButton + + +## Verbindet die Buttons und setzt den Start-Fokus. +func _ready() -> void: + _confirm_button.pressed.connect(_on_confirm_pressed) + _quit_button.pressed.connect(_on_quit_pressed) + _confirm_button.grab_focus.call_deferred() + + +## Aktiviert mit confirm den fokussierten Button (Controller-Pfad ohne +## ui_accept-Doppelung); cancel springt auf Beenden. +func _unhandled_input(event: InputEvent) -> void: + if event.is_action_pressed("cancel"): + _quit_button.grab_focus() + return + if not event.is_action_pressed("confirm"): + return + if event.is_action("ui_accept"): + return + var focused := get_viewport().gui_get_focus_owner() + var button := focused as BaseButton + if button != null and not button.disabled: + button.pressed.emit() + + +## Bestätigt dauerhaft und gibt das Hauptmenü frei. +func _on_confirm_pressed() -> void: + MatureContentGate.confirm_age() + confirmed.emit() + queue_free() + + +## Beendet das Spiel ohne Bestätigung. +func _on_quit_pressed() -> void: + get_tree().quit() diff --git a/scripts/ui/mature_gate.gd.uid b/scripts/ui/mature_gate.gd.uid new file mode 100644 index 0000000..665aef4 --- /dev/null +++ b/scripts/ui/mature_gate.gd.uid @@ -0,0 +1 @@ +uid://srhc5to3e5c4