Skip to content

Commit

Permalink
Merge pull request #29 from miketvo/p0ng-patch-1.1.2
Browse files Browse the repository at this point in the history
Added ability for GameConfig to update metadata if needed
  • Loading branch information
miketvo authored Mar 21, 2024
2 parents 8e2e6b3 + 967b301 commit 8b9ab5a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion p0ng/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ config_version=5
[application]

config/name="p0ng"
config/version="1.1.1"
config/version="1.1.2"
run/main_scene="res://scenes/main.tscn"
config/use_custom_user_dir=true
config/custom_user_dir_name="ambientlamp/p0ng"
Expand Down
30 changes: 26 additions & 4 deletions p0ng/scripts/util/game_config.gd
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,21 @@ const VOLUME_SLIDER_TICK_COUNT: int = 10
## See [method reset_config] for sections, section keys, and their default
## values.
var config: Dictionary
var _original_config: Dictionary

#endregion
# ============================================================================ #


# ============================================================================ #
#region Private variables
var _original_config: Dictionary
var _game_version: String = ProjectSettings.get_setting("application/config/version")
var _engine_version: String = "Godot %s" % Engine.get_version_info().string
var _engine_git_commit_hash: String = Engine.get_version_info().hash
#endregion
# ============================================================================ #


# ============================================================================ #
#region Godot builtins
func _ready() -> void:
Expand All @@ -61,6 +70,19 @@ func _ready() -> void:
if first_play:
self._save()
self._load()

var metadata_updated: bool = false
if config.metadata.game_version != _game_version:
config.metadata.game_version = _game_version
metadata_updated = true
if config.metadata.engine_version != _engine_version:
config.metadata.engine_version = _game_version
metadata_updated = true
if config.metadata.engine_git_commit_hash != _engine_git_commit_hash:
config.metadata.engine_git_commit_hash = _engine_git_commit_hash
metadata_updated = true
if metadata_updated:
self._save()
#endregion
# ============================================================================ #

Expand All @@ -77,9 +99,9 @@ func _ready() -> void:
func reset_config() -> void:
config = {
"metadata": {
"game_version": ProjectSettings.get_setting("application/config/version"),
"engine_version": "Godot %s" % Engine.get_version_info().string,
"engine_git_commit_hash": Engine.get_version_info().hash
"game_version": _game_version,
"engine_version": _engine_version,
"engine_git_commit_hash": _engine_git_commit_hash
},
"graphics": {
"resolution": _get_best_resolution(),
Expand Down

0 comments on commit 8b9ab5a

Please sign in to comment.