For such menu there are usually two functions doing the work, something like load_from_settings()
and save_to_settings()
. I guess you need the former.
Your menu might revert back to its default state if you destroyed and re-instanced it, or if you restarted the game. So when it is _ready()
, or when it is shown (NOTIFICATION_VISIBILITY_CHANGED
), you need to update all its controls according to the actual settings you loaded from the file.
This can be done case by case: for example, if you have a Slider
for volume, you would set it like this, assuming settings
is what you loaded from the config file:
get_node("VolumeSlider").ratio = settings.volume_linear
Or if you have a checkbox for particle effects:
get_node("ParticleEffects").pressed = settings.particle_effects_enabled
Alternatively, there are some settings that you can get directly from the engine. For example, volume can be retrieved from the main audio bus:
get_node("VolumeSlider").ratio = db2linear(AudioServer.get_bus_volume_db(0))
One twist you need to care about is that when you set controls values like this, it may trigger modification signals. If you have code connected to them, they would be called as if the user changed the settings. It should be fine most of the time, but it's good to be aware of this.