-
Notifications
You must be signed in to change notification settings - Fork 18
UIElements
UI in this game is built from elements - each element containing its own defined behaviour. They're internally called UIElements, and this is the name they'll be referenced by from now on. UIElements can be created either by defining them in a menu's .txt file (found in /gd3ds/romfs/menus/) or by calling their appropriate ui_create function.
UIElements can be referenced by optional tags - think of them like HTML classes if you've worked with web development.
You can directly access a UIElement in code by defining a static UIElement *variable and setting it to the pointer of your target with the ui_get_element_by_tag function. They can also be modified in bulk by calling ui_run_func_on_tag, which allows you to run any function with the structure of func(UIElement *element) (plus a few default functions), on all elements with the provided tag. One element may have multiple tags, separated by a comma.
ui_get_element_by_tag(UIScreen *screen, char *tag) - returns a pointer to the first found UIElement with matching tag. if none are found, returns NULL. ui_run_func_on_tag(UIScreen *screen, char *tag, void function) - runs a function of your choice on every element with provided tag. ui_disable_element(UIElement *element) - disables provided element. ui_enable_element(UIElement *element) - re-enables provided element.
This is the base template upon which all other elements are built. The UIElement struct contains all of the core initialisation, updating, drawing and destructing logic + properties that other elements share and build upon.
[NOT APPLICABLE]
Basic rectangle. Often used as a background for list element entries.
rectangle x=? y=? w=? h=? tag="???" tint=??????
ui_create_rectangle(*screen) - creates a UIRectangle struct and returns its pointer.
ui_rectangle_set_color(*UIRectangle, u32 color) - tints rectangle to provided C2D_Color32.
Background gradient. Stretches across the entire screen, is used as the background in most fullscreen menus. If servers are set to the 1.9 GDPS, the texture changes to the one from their client.
bggradient tint=??????? tag="???"
ui_create_bg_gradient(UIScreen *screen) - creates and returns a UIBackgroundGradient struct.
ui_gradient_set_tint(UIBackgroundGradient *bggradient, u32 color) - sets background gradient's tint to provided C2D_Color32.
The shadow layer behind most popups - black rectangle with a customisable opacity and fade duration. If desired, position and dimensions can be customised.
darken x=? y=? w=? h=? opacity=? darkenTime=?
ui_create_darken(UIScreen *screen) - creates a UIDarken struct and returns its pointer.
ui_darken_set_opacity(UIDarken *darken, float opacity) - instantly sets a darken's opacity to provided value.
ui_darken_reset_opacity(UIDarken *darken) - resets darken's opacity to 1.
Basic image element. Displays the image at an index of your choosing, with adjustable scale and tint. The displayed image can be changed at any time by modifying its sprite index and/or spritesheet index. Base dimensions are identical to that of the image at the provided index.
image x=? y=? id=? sheet=? scale=? sx=? sy=? tint=?
ui_create_image(UIScreen *screen) - creates a UIImage struct and returns a pointer to it.
ui_image_set_tint(UIImage *image, u32 color) - sets the provided UIImage's tint to provided C2D_Color32.
ui_image_clear_tint(UIImage *image) - resets the image's tint.
ui_image_set_image(UIImage *image, int sprite_index, int sheet) - sets the element's image to the one corresponding to provided index and spritesheet.
Draws a window (9 slice) of target style at target position with target dimensions. Can be tinted to any colour and opacity. The style can also be changed at any time by modifying the window's atlas.
windows x=? y=? w=? h=? style=? tint=??????
ui_create_window(UIScreen *screen) - Creates a UIWindow struct and returns its pointer.
ui_window_set_tint(UIWindow *window, u32 color) - Sets window's tint to provided C2D_Color32.
ui_window_set_atlas(UIWindow *window, int index) - Sets atlas (style) of the target window. For a table of currently existing ones, click here.
Interactive UIImage which can be assigned keybinds, a set of actions, display text of your choosing at a scale of your choosing, and can carry custom data. Buttons can choose from a set of two hover animations: scaling up and sliding downwards. They can also be assigned custom userdata - which is available in their properties once loaded.
button x=? y=? id=? sheet=? scale=? sx=? sy=? keyBinds=?,? actions=“???”,”???” text=“???” textScale=? custom=[variablename=???]
ui_button_set_image(UIButton *button, int sprite_index, int sheet) - sets the image of target button to the one under the provided index and spritesheet
ui_button_set_text(UIButton *button, char *text) - sets the text of a button to provided string.
Interactive UIWindow which can be assigned keybinds, a set of actions, display text of your choosing at a scale of your choosing, and can carry custom data. Buttons can be assigned custom userdata - which is available in their properties once loaded.
windowbutton x=? y=? style=? w=? h=? keyBinds=?,? actions=“???”,”???” text=“???” textScale=? custom=[variablename=???]
ui_button_set_image(UIButton *button, int sprite_index, int sheet) - sets the image of target button to the one under the provided index and spritesheet.
ui_button_set_text(UIButton *button, char *text) - sets the text of a button to provided string.
UIButton which can be checked/unchecked. Executes a chosen action upon use.
checkbox x=? y=? tag=“???” scale=? sx=? sy=? actions=“???”
ui_checkbox_set_checked(UICheckbox *checkbox, bool checked) - sets the state of the checkbox. ui_checkbox_create(UIContext *ctx) - creates a UICheckbox struct and returns its pointer.
UIButton which displays the color at index of your choice. Used exclusively in the icon kit.
colorbutton x=? y=? scale=? sx=? sy=? actions=“???”,”???”
ui_color_button_set_index(UIColor *e, int index, int color_index) - sets color button to target color index.
ui_create_color_button(UIContext *ctx) - creates UIColor struct and returns its pointer.
General purpose text element. Displays text of your choice with font and alignment of your choice. If a width is defined, the displayed text will automatically be scaled to fit within it.
label x=? y=? w=? scale=? sx=? sy=? tag=“???” text=“???” font=?
ui_label_set_text(UILabel *label, char *text) - sets label’s text to that of the provided char.
ui_create_label(UIContext *ctx) - creates UILabel struct and returns its pointer.
Text input field. Brings up the 3DS’ system keyboard upon activation, input length limit and placeholder message can be customised. Typed text also scales to fit the element’s width.
textbox x=? y=? w=? limit=? title=“???” tag=“???” actions="???”
ui_create_textbox(UIContext *ctx) - creates UITextbox struct and returns its pointer.
Vertically scrollable list element. All subelements of a list are treated as its entries, each one being positioned immediately after the previous. The list’s background color can also be set to any value of your choice.
ui_create_list(UIContext *ctx) - creates UIList struct and returns its pointer
ui_reset_list(UIList *list) - destroys all current list entries.
ui_list_add(UIList* list, UIElement* entry) - adds target UIElement to UIList.
Player icon element. Used in the icon kit as well as in official server comments. Can display any 1.0-2.2 player icon with or without glow, in every color, in every gamemode. Can also display a selection IDs of the target icons match that of actual gd, colors don’t. To convert a Geometry Dash color index to a GD3DS one, use the gd_to_gd3ds_color_table LUT located within the palette_kit.c menu file.
icon x=? y=? scale=? gamemode=? id=? hoverFactor=? p1_color=?????? p2_color=?????? glow_color=?????? glow=true/false
ui_icon_set_selected(UIIcon *icon, bool selected) - sets the icons ‘selected’ status.
ui_icon_set_gamemode_index(UIIcon *icon, int gamemode, int index) - sets the gamemode and icon index of an UIIcon
ui_icon_set_p1(UIIcon *icon, u32 color) - sets the color of the UIIcon’s p1 layer.
ui_icon_set_p2(UIIcon *icon, u32 color) - sets the color of the UIIcon’s p2 layer.
ui_icon_set_glow(UIIcon *icon, u32 color) - sets the color of the UIIcon’s glow layer.
Progress bar. Has several border styles to choose from as well as a customisable main bar color.
progressbar x=? y=? scale=? max_value=? style=? tag="???"
ui_create_progress_bar(UIScreen *screen) - creates UIProgressBar struct and returns its pointer.
UIProgressBar with added slider functionality.
slider x=? y=? scale=? max_value=? style=? tag="???"
ui_create_slider(UIScreen *screen) - creates UISlider struct and returns its pointer.
ui_slider_get_percent(UISlider *e) - [float] returns current value of slider.
ui_slider_set_value(UISlider *e, float value) - sets slider to target value.
Spinning UIImage with optional blending and customizable rotation speed (measured in pixels/second).
spinner x=? y=? id=? sheet=? scale=? sx=? sy=? tint=? blending=true/false speed=?
ui_create_spinner(UIScreen *screen) - creates UISpinner struct and returns its pointer.
Element which acts as a layer on which you can spawn particles. Doesn’t do anything by itself, has to be accessed later in code.
particle tag=“???”
Element which acts as a layer on which you can spawn circle effects. Doesn’t do anything by itself, has to be accessed later in code.
useeffect tag=“???”
- x - [float] element's horizontal position. counted from the left, in pixels.
- y - [float] element's vertical position. counted from the top, in pixels.
- w - [float] element's width, in pixels.
- h - [float] element's width, in pixels.
- scale - [float] element's combined x and y scale.
- sx - [float] element's horizontal scale.
- sy - [float] element's vertical scale.
- userdata - custom data is stored here. the specifics of custom properties are explained here.
- tag - [char] tag by which an element can be accessed from later in code. separate multiple tags using commas.
- tint - [char] color to which the element should be tinted. can be provided in the following formats: #RRGGBB, #RRGGBBAA, rr,gg,bb and rr,gg,bb,aa.
- opacity - [float] element' target opacity.
- darkenTime - [float] how long it takes a UIDarken to reach its target opacity, measured in seconds.
- id: [int] index of target image in its corresponding spritesheet. you can check an image's index by copying its name from the gfx folder and checking what (line number - 2) said name is located at in the appropriate spritesheet's .t3s file.
- sheet: [int] index of your desired spritesheet.
- style - [int] index of a window's style.
- keyBinds - one or multiple physical keys to trigger this button, separated by commas.
- actions - one or multiple actions that should be executed upon activation. quotes are optional, separate multiple actions with commas.
- custom - one or multiple custom variables which can be accessed inside the element’s properties. variables are always strings, if a different variable type is desired, you’ll have to convert them manually.
- text - [char] text to be displayed by an element.
- textScale - [float] scale of buttons text, if left unset / equal to 0, text will be shrunk to fit automatically.
- gamemode - [int] index of the target player icon's gamemode. same as in actual Geometry Dash.
- id (icon) - [int] index of the target player icon. same as in actual Geometry Dash.
- p1_color - [int] id of the target icon's player 1 color. to convert a Geometry Dash color index to a GD3DS one, use the
gd_to_gd3ds_color_table[]LUT from/menus/icon_kit.h - p2_color - [int] id of the target icon's player 2 color. to convert a Geometry Dash color index to a GD3DS one, use the
gd_to_gd3ds_color_table[]LUT from/menus/icon_kit.h - glow_color - [int] id of the target icon's glow color. to convert a Geometry Dash color index to a GD3DS one, use the
gd_to_gd3ds_color_table[]LUT from/menus/icon_kit.h - glow - [bool] if target icon should have glow.
- hoverFactor - [float] what scale the element should approach if hovered
- max_value - [float] value which a progress bar should approach.
- color - element's target color.
- blending - [bool] if element should have blending.
(TO BE ADDED)