Finishing the Settings Menu


The following is part of a bi-weekly update we would be required to do as we worked on our final projects. Some things may require context that is not included or some original post content may be excluded.


This week I managed to finish my settings menu.

I updated my settings menu to have its own settings variables to act as the saved settings value for when the player applies settings and/or cancels settings, while the SettingsHandler's variables are the ones that can changed (as the settings are saved through it).


The save_settings function in SettingsHandler.

As you can see through the save_settings function, I call set_value through the inputted ConfigFile. The set_value function takes the section name, the key name, and the value to save in the INI-style file. I made the section and key names into constants so that I can easily change them if needed. The values are member variables of the SettingsHandler node, which are then changed through SettingsMenu.


The function connected to when the apply button is pressed in the settings menu.


The _load_settings_into_saved function that is called after save_settings in the _on_apply_button_pressed function.

When the Apply button is pressed in the settings menu, assuming getting the settings config file does not fail, the variables in the SettingsHandler are saved to the settings config file and then the saved variables in SettingsMenu are updated.

As mentioned earlier, this is important for when the player decides to cancel any potential changes they make after saving the settings.


The function that's called when the cancel button is pressed.

The cancel button only calls the _update_all_settings function, which is also called in _load_settings_into_saved.


The _update_all_settings function.

That's because the _update_all_settings function uses the saved settings variables within SettingsMenu to update the settings menu UI, which also changes the variables within SettingsHandler.


One of the settings functions. This one in particular is called when the value of the Master Volume slider is changed, whether through the UI or in-code.

As you can see through the function above, the corresponding variable in SettingsHandler is updated when the function is called and then the actual component for the game is updated after.


The update_audio_settings function in SettingsHandler.

Moving forward, I'd like to add more SFX to my game and start on the main menu for the game. I might not have a lot of time to get a lot done for the remaining of this week so I'm really just trying to see what I can do in the time I have.

Get ECO-Keeper