This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a GameMaker UI Prefabs library (@gm-prefabs/UI) that provides reusable UI components for GameMaker projects. It's distributed as a .yymps package file and includes components like buttons, dropdowns, checkboxes, sliders, textboxes, progress bars, and more.
This is a GameMaker Studio project (.yyp format), not a traditional code repository:
.yypfile: The main project file (UI_Prefabs.yyp) - JSON format defining all project resources.yyfiles: Resource definition files (objects, sprites, scripts, etc.) - JSON format.gmlfiles: GameMaker Language code files (event handlers, scripts).yympsfiles: GameMaker package files for distribution
Open UI_Prefabs.yyp in GameMaker Studio IDE (requires GameMaker 2022.0.2 LTS or later).
The package is built through GameMaker IDE's Local Package export feature. The current version is 0.1.5 but the latest .yymps file is io.gamemaker.userinterface-0.1.6.yymps.
When updating the package version:
- Update
versioninpackage.json - Update
filesarray inpackage.jsonto reference the new.yympsfilename - Export the package through GameMaker IDE
This project has a forced dependency on io.gamemaker.sdfshaders-1.0.0 (see ForcedPrefabProjectReferences in .yyp).
The UI system uses a clear object inheritance hierarchy:
oUIParent (base class)
├─ oLocalised (adds localisation support)
│ ├─ Button
│ ├─ CheckBox
│ ├─ DropDown
│ ├─ Slider
│ ├─ Toggle
│ ├─ Textbox
│ ├─ ProgressBar
│ ├─ Spinner
│ └─ Infobox
└─ oSlot
Key base classes:
oUIParent: Root parent withprevent_clickthroughpropertyoLocalised: Adds text localization with properties:text,localisation_string,localisation_lang_override
The project uses FlexPanel layouts with special layer naming convention. All UI layers are prefixed with GMUI_ to ensure uniqueness:
GMUI_MainMenu- Main menu (visible by default)GMUI_Options- Settings menu with controls mapped toglobal.control_*variablesGMUI_Pause- Pause overlay with Resume/Restart/QuitGMUI_Confirmation- Modal dialog with Yes/No buttonsGMUI_Character- Equipment/stats screen withoSlotobjectsGMUI_GameOver- Game over screen
Important: When creating new UI layers, always prefix them with GMUI_ (see commit 94ea50e6).
Layer Management: All layers default to visible: false except MainMenu. Use layer_set_visible() to show/hide, never instance_deactivate.
The localisation system uses:
- CSV file:
datafiles/localisation.csvwith columns:name,en,fr,de - Global structures:
global.language: Current language (default "English")global.languages: Array of available languagesglobal.language_strings: Nested struct of translationsglobal.ui_text: Struct mapping UI text elements to localisation strings
Key functions (in scripts/LocalisationFunctions/LocalisationFunctions.gml):
Localisation_Load(filename): Loads CSV and populatesglobal.language_stringsGetLocalisation(string_name, language): Retrieves translated stringLocalisation_Update_All(): Updates all UI text when language changesGetAllText(): Maps FlexPanel text elements to localisation keys
UI is built using GameMaker's FlexPanel system. Helper functions in scripts/UIFunctions/UIFunctions.gml:
FlexPanel Helpers:
GetInstanceIDFromElement(struct, object_id): Find instance ID from FlexPanel structGetTextElementId(struct): Find text element ID in FlexPanel struct
Layer Management Functions:
HideAllUI(): Hides all GMUI_* layers at onceFindControls(): Maps Options menu controls toglobal.control_*variablesFillOptions(): Populates control values from global settings
Menu Navigation:
OpenOptions(): Opens options menu, calls FindControls/GetAllText/FillOptionsApplyOptions(): Saves settings from controls to globals, updates localisationCancelOptions(): Closes options without savingOpenEquipment()/CloseEquipment(): Character screen managementPause(): Toggles pause state and GMUI_Pause visibilityConfirm(yes_func, no_func): Opens confirmation dialog with custom callbacksCancelConfirmation(): Closes confirmation dialogConfirmQuit(): Opens confirmation before quittingQuit(): Returns to main menuExitGame(): Confirms before callinggame_end()
All components inherit from oLocalised and share common patterns:
Common properties:
- Scale handling:
base_xscale,base_yscale, scale animation on hover/press - Font scaling:
Text_Size,Font, calculatedFont_Scale - Visual customization:
Colour,Icon,Icon_Scale - Interaction:
Sound, callback functions
Component-specific details:
-
Button: Uses
Button_Releasecallback property (function reference), supports icon or text, hasPress_ScaleandHover_Scale. Mouse events: hover (10/11), pressed (4), released (7), no-click (56). -
CheckBox: Simple boolean toggle with
Checkedproperty. Usescheck_sprite(default: Icon_Tick) drawn on top when checked. Mouse events: click (4), release (7), no-click (56). -
DropDown: Methods:
FillList(array),Scroll(amount),ResizeList(). Uses surface rendering for scrollable list. Properties:selected(index),items(array),shown_items(visible count). Auto-detectsdropdown_directionbased on screen position. -
Slider: Methods:
getValue(),setValue(value),getMinValue(),setMinValue(value),getMaxValue(),setMaxValue(value),updateSliderThumbPos(x, y). Supportsnum_stepsfor discrete values orstep_sizefor snapping. Handles drag (50), hover (53), click (4), release (56). -
Toggle: Animated switch using sequence (
qToggle).Checkedproperty toggles state. Color properties for both checked/unchecked states applied to background and/or dot viacolour_areaenum. -
Textbox: Methods:
updateText(text, isLocalised),ParseInput(input). Properties:editable,expected_input("all"/"int"/"real"),overflow_behaviour("wrap"/"scroll"). Handles keyboard input validation in Step_0, focus on click. -
ProgressBar: Methods:
getCurrentValue(),setCurrentValue(value),getMaxValue(),setMaxValue(value). Draws background sprite then scaled foreground sprite based on progress ratio. -
Spinner: Animated loading indicator using sequence (
qSpinner). Control viaspinning(boolean) andanimation_speed(0.1-2). -
Infobox: Tooltip that appears on hover (Mouse_10). Method:
reposition_infobox_to_window()keeps tooltip in bounds. Drawn on GUI layer (Draw_64). Auto-sizes to text content. -
ScrollBar: Methods:
Scroll(amount),SetPosition(position). Auto-detects orientation (horizontal if wider, vertical if taller). Supports mouse wheel (60/61) and gesture drag (3/4). Property:percentage(0-1). -
oSlot: Minimal base object with no events or methods. Extend for inventory/equipment systems.
Recent commits show fixes for:
- Dropdown closing behavior when clicking button vs menu items (fee11615)
- ScrollBar rendering issues (5c4467f2)
- Mouse down event handling (a2fde3c3)
- Spinner sprite rendering (f1eab939)
objects/ - GameMaker objects (UI components, managers)
scripts/ - Reusable GML script files
├─ UIFunctions/ - FlexPanel helpers, control management
└─ LocalisationFunctions/ - Translation system
sprites/ - All sprite assets
├─ 9Sliced/ - Nine-slice scalable sprites
├─ Icons/ - UI icon set (arrows, cog, cross, etc.)
└─ SVG/ - SVG-based sprites
datafiles/ - Data files (localisation.csv, font license)
fonts/ - fUI and fUI_Bold fonts (Open Font License)
rooms/ - Demo/test rooms
roomui/ - FlexPanel UI room layouts
sequences/ - Animation sequences (qSpinner, qToggle)
Always prefix UI layers with GMUI_ for uniqueness in consuming projects.
Most component Create events start with event_inherited() to properly inherit from parent objects.
When adding new UI text:
- Add entries to
datafiles/localisation.csvfor all supported languages - Reference the key via
localisation_stringproperty onoLocalisedobjects - Update
GetAllText()if using FlexPanel text elements
Many UI sprites have _Scalable variants that use 9-slice scaling. Use these for components that need to resize dynamically.
The project uses global variables extensively:
- Settings:
global.volume,global.resolution_w/h,global.fullscreen,global.aa,global.shadows - UI state:
global.paused,global.previous_menu - Controls:
global.control_*for quick access to UI component instances
Comprehensive user documentation is available in notes/README/README.txt. This file contains:
- Complete component API reference with all properties and methods
- Usage examples for each component
- Detailed UI layer documentation (all 6 GMUI_* layers)
- Integration tips and best practices
- Table of contents with anchor links
When making changes to components or layers, update the README to keep documentation in sync.
- Create object inheriting from
oLocalised(for text) oroUIParent(no text) - Add Create event with
event_inherited()first line - Define properties in
.yyfile with descriptivevarDescriptionandvarFriendlyName - Implement mouse events as needed (4=click, 7=release, 10=hover, 11=hover_end, 56=no-click)
- Add to
objects/directory - Update README.txt with component documentation
- Test in UIRoom
- UI layers are defined in
roomui/RoomUI/RoomUI.yy(large JSON file) - Edit in GameMaker IDE Room Editor, not directly in JSON
- Always use FlexPanel for layout
- Ensure layer name starts with
GMUI_ - Set default
visible: false(except MainMenu) - Update helper functions in UIFunctions.gml if adding controls
- Update README.txt layer documentation
- Add row to
datafiles/localisation.csvwith format:key,en_value,fr_value,de_value - If FlexPanel text element, add mapping in
GetAllText()function - If object property, set
localisation_stringproperty to key - Test with language dropdown in Options menu
- Increment version in
package.json - Update
filesarray to reference new.yympsfilename - Export package via GameMaker IDE (Local Package)
- Commit both
package.jsonand new.yympsfile
The demo room (UIRoom) showcases all components and can be used for testing changes. The room includes:
- All 6 UI layers (MainMenu, Pause, Options, Character, Confirmation, GameOver)
oUIManagerinstance that initializesglobal.previous_menu- FlexPanel layouts defined in
roomui/RoomUI/RoomUI.yy
Run the project in GameMaker IDE to test UI components interactively. The room demonstrates:
- Layer visibility management
- Localisation system (EN/FR/DE)
- Settings persistence via global variables
- Component interactions and callbacks