-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame_settings_resource.gd
More file actions
58 lines (52 loc) · 2.12 KB
/
game_settings_resource.gd
File metadata and controls
58 lines (52 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
## Copyright (C) 2026 Egor Kostan
## SPDX-License-Identifier: GPL-3.0-or-later
## game_settings_resource.gd
##
## DATA CONTAINER: This Resource serves as the central "Source of Truth" for game configuration.
## It decouples static data from logic found in Globals.gd.
class_name GameSettingsResource
extends Resource
## SIGNAL: setting_changed(setting_name: String, new_value: Variant)
##
## This signal is the core of the Observer Pattern for game settings.
## It is automatically emitted by property setters whenever a value is updated.
## This allows external systems (like Globals.gd) to react to data changes
## without the UI having to explicitly call persistence or logging methods.
signal setting_changed(setting_name: String, new_value: Variant)
@export_group("Logging")
# Current log level: 0=DEBUG, 1=INFO, 2=WARNING, 3=ERROR, 4=NONE
@export_range(0, 4, 1) var current_log_level: int = 1:
set(value):
var new_value: int = clampi(value, 0, 4)
if _current_log_level == new_value:
return
_current_log_level = new_value
setting_changed.emit("current_log_level", new_value)
get:
return _current_log_level
@export var enable_debug_logging: bool = false:
set(value):
_enable_debug_logging = value
setting_changed.emit("enable_debug_logging", value)
get:
return _enable_debug_logging
@export_group("Gameplay")
# Multiplier: 1.0=Normal, <1=Easy, >1=Hard
@export var difficulty: float = 1.0:
set(value):
var new_val: float = clamp(value, 0.5, 2.0)
if _difficulty == new_val:
return # Break the recursion here
_difficulty = new_val
setting_changed.emit("difficulty", _difficulty)
get:
return _difficulty
@export_group("UI & Scenes")
@export var remap_prompt_keyboard: String = "Press a key..."
@export var remap_prompt_gamepad: String = "Press a gamepad button/axis..."
@export var key_mapping_scene: PackedScene = preload("res://scenes/key_mapping_menu.tscn")
@export var options_scene: PackedScene = preload("res://scenes/options_menu.tscn")
# Private member variables moved to bottom to satisfy class-definitions-order
var _current_log_level: int = 1
var _difficulty: float = 1.0
var _enable_debug_logging: bool = false