Closed Drathal closed 10 months ago
Shouldn't the config manager be a singleton? I guess it would be easier to access. Also you can use the following to do something before the game quits
func _notification(what: int) -> void:
if what == NOTIFICATION_WM_CLOSE_REQUEST:
# Do stuff
get_tree().quit()
Ahhhh thanks for the code snippet. I will take a look.
@MrEliptik i worked on the _notification stuff for a while.
To get the NOTIFICATION_WM_CLOSE_REQUEST or other window events like resize, you have to do some ugly stuff. https://github.com/godotengine/godot/issues/79336 I did that but it has some other problems down the road. When we use that i would also just emit some global game events from the signal_bus.
When using the GameSettingsManager as a Singleton without functionality change. We would change the usage from:
# Init
@onready var game_config_manager := GameConfigManager.new(self)
# save (on esc key)
game_config_manager.save_config()
to
# save (on esc key)
GameConfigManager.save_config()
Thats great, but i cant reuse the config_manager
So its more effort for one line less.
I also played around with saving the windows position / size, without any implementation from the game itseelf. Thats possible but needs of course even more implementation if we want it robust.
Conclusion
If i had a wish :D I would like to merge that PR as is. And then i create follow up tickets:
GameConfigManager.save_config({ gamedata: 2, another: 'yes' })
. The data can be injected to the game on start and whenever GameConfigManager.load_config()
is calledLong story short: I would love to iterate over it and not have one big PR.
I'm not sure what you mean by ugly stuff? I just tried getting the NOTIFICATION_WM_CLOSE_REQUEST
notification in the main branch and it worked fine?
In the end it's just one line less but I feel like it makes for sense in terms of architecture. Do you agree?
I agree, let's merge that and make other issues to tackle specific problems or improvements. I'll let you create the issues?
this closes #56
A simple way to save settings for every game and the games launcher.
config.cfg
file.I tried to save settings when the windows is moved, resized or closed with events but could not find the right events. So I added a line so save the settings when the esc key is hit.