Prebuilt GUI Contracts
RPGJS prebuilt GUIs are regular GUI entries registered with fixed IDs. You can replace their visual implementation with your own CanvasEngine component by registering a GUI with the same ID. The server API stays the same. For example,player.showText() still opens rpg-dialog, but your component receives the dialog data and decides how to render it.
Register a Replacement
Create a.ce file and register it with the prebuilt ID you want to replace:
.ce replacements; for Vue-specific examples, see Vue.js integration.
Component Interface
CanvasEngine GUI components receive:
For example, this CanvasEngine component can replace the built-in dialog box:
onFinish() when the server is waiting for a final answer, such as a dialog choice. Use onInteraction() for actions that should keep the GUI open, such as buying an item or equipping gear.
Dialog Box
Data:
To return a choice, call
onFinish(index) where index is the selected choice index. For text without choices, call onFinish() when the player dismisses the dialog.
CanvasEngine example:
Main Menu
Data:
Interactions:
The built-in client also applies optimistic updates for
useItem and equipItem. Custom Vue and CanvasEngine replacements can use the same interaction names and still benefit from those reducers.
Shop
Data:
ShopItem includes id, name, description, price, icon, type, optional stats, optional quantity, and equipped.
Interactions:
Save and Load
Data:
Server interactions:
The built-in
save-load.ce also uses SaveClientService directly for local save/load UI flows. A replacement can use either the server interactions above or its own client service flow, depending on the game architecture.
Title Screen
Data:
Interaction:
Game Over
Data:
Interaction:
HUD and Notifications
HudComponent and NotificationComponent are also GUI components, but they are less driven by a server payload than the modal GUIs above.
HUD data:
The HUD reads the current player from the client engine for
hp, sp, max values, and level.
Notifications use PrebuiltGui.Notification / rpg-notification, but the built-in component reads engine.notificationManager.stack() instead of a direct data payload. Custom notification UIs should use the same notification manager if they need the existing player.showNotification() behavior.