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.