Theme Configuration

Since RetroHub gives near complete freedom to theme developers on how games are presented and selected, it’s very likely that you’ll have behaviors that users will want to customize.

Use RetroHubConfig’s theme_config methods and signals to access and modify these settings:

var dark_mode := false

func _ready():
        RetroHubConfig.theme_config_ready.connect(_on_theme_config_ready)
        RetroHubConfig.theme_config_updated.connect(_on_theme_config_updated)

func _on_theme_config_ready():
        dark_mode = RetroHubConfig.get_theme_config("dark_mode", false)

func _on_theme_config_updated(key, old_value, new_value):
        if key == "dark_mode":
                dark_mode = new_value
                print("Dark mode changed from %s to %s" % [old_value, new_value])

Theme configurations are stored internally in a JSON file, and work as key/value pairs. Theoretically you can use any Godot’s Variant, but it’s recommended to stick to regular variable types, such as bool, int, float, String, Vector2, Color, etc…

When reading settings, you need to specify a default value in case that setting doesn’t exist yet. To update settings, you only need to call set_theme_config, and RetroHub will internally save it.

Showing configuration

You have two main options for this:

Note

These options are not mutually exclusive. You can use both if you want.

In-theme menu

Themes have a special input action available: rh_theme_menu (action-key: rh_theme_menu/action-joy: rh_theme_menu by default). You can use this to implement a configuration UI from within your theme.

Warning

You will have to manually save this configuration by calling save_theme_config.

In-app menu

If you want to integrate the configuration UI better in the app, you can also specify a scene for RetroHub to load and add to the configuration menu. This will be displayed under the “Theme” section. To do this, set a Custom Configuration Scene in the theme helper addon’s configuration.

../../_images/custom_config_scene.png

Note

When using this approach, RetroHub will automatically save theme configuration when the theme is unloaded, so you don’t need to do it manually.