em_settings_generator settings.xml
Using the settings singleton
After you have generated the classes settings.e and shared_settings.e with the EM Settings Generator, you should inherit from SHARED_SETTINGS in every class you would like to access the settings from. When you inherit from SHARED_SETTINGS, you will have the object "settings" available in your class.
Using the Settings class
The values in the settings class are initialized with the default values. The first thing you should do when using the settings is read the user settings with
settings.read_user_settingsYou don't have to care where this file is stored. The default directory for it is taken from EM_USER_DIRECTORY. If desired, you can set the path using
settings.set_user_file
For every setting you specified in your settings.xml (for example: <Setting type="integer" name="volume" default="50"/>), you have the following features in the settings class:
-
Attribute:
Current value of a setting. Example:settings.volume
-
Element Change:
Set the attribute's values. Example:settings.set_volume(75)
-
Default Value:
Example:settings.default_volume
-
Widget:
The widget that belongs to a setting. Example:settings.widget_volume
Using Widgets
If specified in settings.xml, code for widgets that are coupled with the corresponding settings are generated. You have to create these widgets before using them, for example by calling
settings.create_all_widgetsor
settings.create_audio_widgetsAfter that, you can display the widgets anywhere you like.
Important: When changing a setting's value, the corresponding widget won't automatically change, you have to call
settings.reset_*_widgetsfirst. On the other hand, changing a widget doesn't automatically change the setting, you have to call
settings.apply_*_settingsfirst.
You can also free widgets using
settings.free_*_widgets