RetroHubUI

This class exposes some UI actions and data for themes.

Constants

Type

Name

Color

color_theme_accent

Color

color_success

Color

color_warning

Color

color_error

Color

color_pending

Color

color_unavailable

int

max_popupmenu_height


Color color_theme_accent

Color used for “accent” elements on RetroHub’s interface.


Color color_success

Color used for success messages.


Color color_warning

Color used for warning messages.


Color color_error

Color used for error messages.


Color color_pending

Color used for pending operations.


Color color_unavailable

Color used for unavailable objects.


int max_popupmenu_height

Maximum size, in pixels, for PopupMenu elements. Use this value in your themes to have consistent sizes with RetroHub’s defaults.

Enumerations

enum AudioKeys:

  • ACTIVATED - Button activated.

  • CHECK_BUTTON_OFF - Check button toggled off.

  • CHECK_BUTTON_ON - Check button toggled on.

  • KEYBOARD_TYPE - Virtual keyboard inputs.

  • MENU_ENTER - Menu opened.

  • MENU_IN - Popup opened.

  • MENU_OUT - Popup/menu closed.

  • NAVIGATION - UI navigation.

  • SLIDE - Sliding tabs.

  • SLIDER_TICK - Value change ticks.


enum Icons:

  • DOWNLOADING - Downloading icon.

  • ERROR - Error icon.

  • FAILURE - Failure icon.

  • IMAGE_DOWNLOADING - Image downloading icon.

  • LOAD - Load file/directory icon.

  • LOADING - Loading icon.

  • SUCCESS - Success icon.

  • VISIBILITY_HIDDEN - Hidden visibility icon.

  • VISIBILITY_VISIBLE - Visible visibility icon.

  • WARNING - Warning icon.


enum ConfigTabs:

  • QUIT - Quit tab.

  • GAME - Game metadata editor tab.

  • SCRAPER - Scraper tab.

  • THEME - Theme settings tab.

  • SETTINGS_GENERAL - General settings tab.

  • SETTINGS_INPUT - Input settings tab.

  • SETTINGS_REGION - Region settings tab.

  • SETTINGS_SYSTEMS - Systems settings tab.

  • SETTINGS_EMULATORS - Emulators settings tab.

  • SETTINGS_ABOUT - About tab.

Signals

path_selected (file: String)

Emitted when a path is selected in the file/directory dialog. Used for request_file_load/request_folder_load. file is the path selected, or "" if nothing was selected.

Methods

Type

Name

void

filesystem_filters

void

request_file_load

void

request_folder_load

Texture

load_app_icon

void

show_virtual_keyboard

bool

is_virtual_keyboard_visible

bool

is_event_from_virtual_keyboard

void

hide_virtual_keyboard

void

open_app_config

void

show_warning

Window

get_focused_window

Control

get_true_focused_control

void

play_sound


void filesystem_filters (filters: Array)

Set file filters for the file/directory dialog. Works exactly the same as Godot’s FileDialog.filters.

# Only show supported image files
filesystem_filters([["*.png, *.jpg, *.jpeg ; Supported Images"]])

void request_file_load (base_path: String)

Request a file load. The file dialog will be opened and the user will be able to select a file. base_path indicates what folder path to start on initially. Call filesystem_filters before to set desired file filters.

When a file is selected, the path_selected signal will be emitted with the path to the file. If the user cancels the dialog, the signal will be emitted with an empty string.

# Example to load a single PNG file
RetroHubUI.filesystem_filters(["*.png ; PNG Images"])
RetroHubUI.request_file_load(FileUtils.get_home_dir())
var path : String = yield(RetroHubUI, "path_selected")
        if not path.empty():
                print("File selected: " + path)
        else:
                print("No file selected")

void request_folder_load (base_path: String)

Request a folder load. The file dialog will be opened and the user will be able to select a folder. base_path indicates what folder path to start on initially.

When a folder is selected the path_selected signal will be emitted with the path to the folder. If the user cancels the dialog, the signal will be emitted with an empty string.

# Example to load a folder
RetroHubUI.request_folder_load(FileUtils.get_home_dir())
var path : String = yield(RetroHubUI, "path_selected")
        if not path.empty():
                print("Folder selected: " + path)
        else:
                print("No folder selected")

Texture load_app_icon (icon: Icons)

Load an app-default icon.


void show_virtual_keyboard ()

Asks RetroHub to show the virtual keyboard. The node you want to receive key events must be focused (Control.grab_focus()) before calling this method. The virtual keyboard will then send raw InputEventKey events to the focused node.

Note

RetroHub automatically opens the virtual keyboard for LineEdit and TextEdit nodes. This method is only needed if you want to show the virtual keyboard for other nodes.


bool is_virtual_keyboard_visible ()

Returns true if the virtual keyboard is currently visible.


bool is_event_from_virtual_keyboard ()

Returns true if the current input event is coming from the virtual keyboard.

func _input(event):
        if RetroHubUI.is_event_from_virtual_keyboard():
                # From virtual keyboard
                ...
        else:
                # From actual user input
                ...

void hide_virtual_keyboard ()

Hides the virtual keyboard.


void open_app_config (tab : ConfigTabs = -1)

Opens RetroHub’s app configuration UI. If -1 is specified, the app will stay on the currently selected tab.

Warning

Opening the app configuration UI will steal focus from the theme until the user closes it.


void show_warning (text: String)

Shows a warning to the user. Use this for warnings that are at the application level, and not specific to your theme.


Window get_focused_window ()

Returns the currently focused Window across the entire application.


Control get_true_focused_control ()

Returns the currently focused Control by also taking into account the currently focused Window.


void play_sound (key: AudioKeys, override: bool = true)

Plays a UI sound from one of the existing sound keys. If override is true, the sound will replace any current sound; otherwise, it may be played in parallel to other sounds.