-
-
Notifications
You must be signed in to change notification settings - Fork 1
[FEATURE] Convert Hard-Coded Globals to Godot Resource #285 #431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
53d14c4
[FEATURE] Convert Hard-Coded Globals to Godot Resource #285
ikostan 1982061
Update game_settings_resource.gd
ikostan 400e78a
Update globals.gd
ikostan e212545
Update game_settings_resource.gd
ikostan 1ca05bd
Constrain current_log_level to valid enum range (0–4).
ikostan f382531
Update scripts/globals.gd
ikostan b6d3623
Merge branch 'convert-hard-coded-globals-to-godot-resource' of https:…
ikostan 968ac38
Update test_globals_resource.gd
ikostan 158f433
Update .deepsource.toml
ikostan ad03e14
Update .deepsource.toml
ikostan 358337e
Update .deepsource.toml
ikostan 23b2b92
Update test_combined_multi_manager_loads.gd
ikostan c5a163c
Update input_remap_button.gd
ikostan 9a00740
Update test_error_edge_cases.gd
ikostan 37889b8
Update input_remap_button.gd
ikostan 2941379
Update input_remap_button.gd
ikostan a8ee991
Update test_input_remap_ec.gd
ikostan 0f4aa3d
Update test_key_mapping_menu.gd
ikostan dbd0e20
Update test_preserve_other_sections.gd
ikostan d2f9a84
Update input_remap_button.gd
ikostan de68efd
Update test_difficulty_integration.gd
ikostan b300599
Update test_options_teardown.gd
ikostan c91143b
Update test_difficulty.gd
ikostan 41fc04c
Update test_load_options_reentrancy.gd
ikostan b384a90
Update test_player.gd
ikostan e810f19
Update test_settings_persistence.gd
ikostan 2a3e3cb
Update test_globals.gd
ikostan 78cd5b4
Update test_globals.gd
ikostan e598dbf
Update test_settings_persistence.gd
ikostan 5a61f35
Update test_load_options_reentrancy.gd
ikostan da96cb4
Update test_player.gd
ikostan 944c4c3
Update test_difficulty.gd
ikostan 883285a
Update test_player.gd
ikostan 9307cbc
Update test_difficulty_integration.gd
ikostan 8e81887
Update test_globals.gd
ikostan 5d528f8
Update test_player.gd
ikostan 20786ce
Update test_settings_persistence.gd
ikostan b62b457
Update .deepsource.toml
ikostan bd36f56
Update .deepsource.toml
ikostan 1d6e00a
Update .deepsource.toml
ikostan b7ec7c3
Update game_settings_resource.gd
ikostan 175cb87
Range-warning logic is unreachable after setter clamping.
ikostan a73fdcf
Update game_settings_resource.gd
ikostan 4056d9b
test_logging_default_level is tautological right now.
ikostan 82a5183
Update test_globals_resource.gd
ikostan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| ## 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 (difficulty, paths, log levels) from logic found in Globals.gd. | ||
| ## By using a Resource instead of hard-coded variables, settings can be swapped at runtime | ||
| ## or modified visually via the Godot Inspector without touching the codebase. | ||
|
|
||
| class_name GameSettingsResource | ||
| extends Resource | ||
|
|
||
| @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 | ||
| @export var enable_debug_logging: bool = false | ||
|
|
||
| @export_group("Gameplay") | ||
| # Multiplier: 1.0=Normal, <1=Easy, >1=Hard | ||
| # In globals.gd, change the difficulty variable in the Resource script: | ||
| # game_settings_resource.gd | ||
| @export var difficulty: float = 1.0: | ||
| set(value): | ||
| if value < 0.5 or value > 2.0: | ||
| Globals.log_message( | ||
| "Invalid difficulty loaded (" + str(value) + ") - clamping to valid range.", | ||
| Globals.LogLevel.WARNING | ||
| ) | ||
| _difficulty = clamp(value, 0.5, 2.0) | ||
| 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") | ||
|
|
||
| var _difficulty: float = 1.0 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| uid://cgtk0ximoo5ty |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| [gd_resource type="Resource" script_class="GameSettingsResource" load_steps=4 format=3 uid="uid://28t4yno1suni"] | ||
|
|
||
| [ext_resource type="PackedScene" uid="uid://dxep4xm1sl8im" path="res://scenes/key_mapping_menu.tscn" id="1_qho2n"] | ||
| [ext_resource type="PackedScene" uid="uid://cl4m4q2eurcn0" path="res://scenes/options_menu.tscn" id="2_b4w4u"] | ||
| [ext_resource type="Script" uid="uid://cgtk0ximoo5ty" path="res://scripts/game_settings_resource.gd" id="3_qb8m4"] | ||
|
|
||
| [resource] | ||
| script = ExtResource("3_qb8m4") | ||
| metadata/_custom_type_script = "uid://cgtk0ximoo5ty" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.