Constructor
new UISystemPlugin(contextopt)
Create the global UI system object
| Name | Type | Attributes | Description |
|---|---|---|---|
context | CanvasRenderingContext2D | <optional> |
- Source
// create the ui plugin object
new UISystemPlugin;Members
activateOnPress
Properties| Type | Description |
|---|---|
| boolean | Activate when mouse is pressed down instead of clicked |
- Source
activeObject
Properties| Type | Description |
|---|---|
| UIObject | Object user is currently interacting with |
- Source
confirmDialog
Properties| Type | Description |
|---|---|
| UIObject | Current confirm menu being shown |
- Source
defaultButtonColor
Properties| Type | Description |
|---|---|
| Color | Default button color for UI elements |
- Source
defaultColor
Properties| Type | Description |
|---|---|
| Color | Default fill color for UI elements |
- Source
defaultCornerRadius
Properties| Type | Description |
|---|---|
| number | Default rounded rect corner radius for UI elements |
- Source
defaultDisabledColor
Properties| Type | Description |
|---|---|
| Color | Default color for disabled UI elements |
- Source
defaultFont
Properties| Type | Description |
|---|---|
| string | Default font for UI elements |
- Source
defaultGradientColor
Properties| Type | Description |
|---|---|
| Color | Uses a gradient fill combined with color |
- Source
defaultHoverColor
Properties| Type | Description |
|---|---|
| Color | Default hover color for UI elements |
- Source
defaultLineColor
Properties| Type | Description |
|---|---|
| Color | Default outline color for UI elements |
- Source
defaultLineWidth
Properties| Type | Description |
|---|---|
| number | Default line width for UI elements |
- Source
defaultShadowBlur
Properties| Type | Description |
|---|---|
| number | Size of shadow blur |
- Source
defaultShadowColor
Properties| Type | Description |
|---|---|
| Color | Color for shadow |
- Source
defaultShadowOffset
Properties| Type | Description |
|---|---|
| Vector2 | Offset of shadow blur |
- Source
defaultSoundClick
Properties| Type | Description |
|---|---|
| Sound | Default sound when interactive UI element is clicked |
- Source
defaultSoundPress
Properties| Type | Description |
|---|---|
| Sound | Default sound when interactive UI element is pressed |
- Source
defaultSoundRelease
Properties| Type | Description |
|---|---|
| Sound | Default sound when interactive UI element is released |
- Source
defaultTextColor
Properties| Type | Description |
|---|---|
| Color | Default text color for UI elements |
- Source
defaultTextFitScale
Properties| Type | Description |
|---|---|
| number | Default scale to use for fitting text to object |
- Source
hoverObject
Properties| Type | Description |
|---|---|
| UIObject | Top most object user is over |
- Source
lastHoverObject
Properties| Type | Description |
|---|---|
| UIObject | Hover object at start of update |
- Source
nativeHeight
Properties| Type | Description |
|---|---|
| number | If set ui coords will be renormalized to this canvas height |
- Source
navigationDelay
Properties| Type | Description |
|---|---|
| number | Time between navigation inputs in seconds |
- Source
navigationDirection
Properties| Type | Description |
|---|---|
| boolean | should the navigation be horizontal, vertical, or both? |
- Source
navigationMode
Properties| Type | Description |
|---|---|
| boolean | True if user last used navigation instead of mouse |
- Source
navigationObject
Properties| Type | Description |
|---|---|
| UIObject | Object currently selected by navigation (gamepad or keyboard) |
- Source
navigationTimer
Properties| Type | Description |
|---|---|
| Timer | Cooldown timer for navigation inputs |
- Source
uiContext
Properties| Type | Description |
|---|---|
| CanvasRenderingContext2D | | Context to render UI elements to |
- Source
uiObjects
Properties| Type | Description |
|---|---|
| Array.<UIObject> | List of all UI elements |
- Source
Methods
drawLine(posA, posB, lineWidthopt, lineColoropt)
Draw a line to the UI context
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
posA | Vector2 | |||
posB | Vector2 | |||
lineWidth | number | <optional> | uiSystem.defaultLineWidth | |
lineColor | Color | <optional> | uiSystem.defaultLineColor |
- Source
drawRect(pos, size, coloropt, lineWidthopt, lineColoropt, cornerRadiusopt, gradientColoropt, shadowColoropt, shadowBluropt, shadowOffsetopt)
Draw a rectangle to the UI context
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos | Vector2 | |||
size | Vector2 | |||
color | Color | <optional> | ||
lineWidth | number | <optional> | 0 | |
lineColor | Color | <optional> | ||
cornerRadius | number | <optional> | 0 | |
gradientColor | Color | <optional> | ||
shadowColor | Color | <optional> | ||
shadowBlur | number | <optional> | 0 | |
shadowOffset | Color | <optional> |
- Source
drawText(text, pos, size, coloropt, lineWidthopt, lineColoropt, alignopt, fontopt, fontStyleopt, applyMaxWidthopt, textShadowopt, shadowColoropt, shadowBluropt, shadowOffsetopt)
Draw text to the UI context
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
text | string | |||
pos | Vector2 | |||
size | Vector2 | |||
color | Color | <optional> | uiSystem.defaultColor | |
lineWidth | number | <optional> | uiSystem.defaultLineWidth | |
lineColor | Color | <optional> | uiSystem.defaultLineColor | |
align | string | <optional> | center | |
font | string | <optional> | uiSystem.defaultFont | |
fontStyle | string | <optional> | ||
applyMaxWidth | boolean | <optional> | true | |
textShadow | Vector2 | <optional> | ||
shadowColor | Color | <optional> | ||
shadowBlur | number | <optional> | 0 | |
shadowOffset | Color | <optional> |
- Source
drawTile(pos, size, tileInfo, coloropt, angleopt, mirroropt, shadowColoropt, shadowBluropt, shadowOffsetopt)
Draw a tile to the UI context
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos | Vector2 | |||
size | Vector2 | |||
tileInfo | TileInfo | |||
color | Color | <optional> | uiSystem.defaultColor | |
angle | number | <optional> | 0 | |
mirror | boolean | <optional> | false | |
shadowColor | Color | <optional> | ||
shadowBlur | number | <optional> | 0 | |
shadowOffset | Color | <optional> |
- Source
getNavigableObjects() → {Array.<UIObject>}
Get all navigable UI objects sorted by navigationIndex
- Source
- Type:
- Array.<UIObject>
getNavigationDirection() → {number}
Get navigation direction from gamepad or keyboard
- Source
- Type:
- number
getNavigationOtherDirection() → {Vector2}
Get other axis navigation direction from gamepad or keyboard
- Source
- Type:
- Vector2
getNavigationWasPressed() → {boolean}
Get if navigation button was pressed from gamepad or keyboard
- Source
- Type:
- boolean
screenToNative(pos) → {Vector2}
Convert a screen space position to native UI position
| Name | Type | Description |
|---|---|---|
pos | Vector2 |
- Source
- Type:
- Vector2
setupDragAndDrop(onDropopt, onDragEnteropt, onDragLeaveopt, onDragOveropt)
Setup drag and drop event handlers Automatically prevents defaults and calls the given functions
| Name | Type | Attributes | Description |
|---|---|---|---|
onDrop | DragAndDropCallback | <optional> | when a file is dropped |
onDragEnter | DragAndDropCallback | <optional> | when a file is dragged onto the window |
onDragLeave | DragAndDropCallback | <optional> | when a file is dragged off the window |
onDragOver | DragAndDropCallback | <optional> | continuously when dragging over |
- Source
showConfirmDialog(textopt, yesCallbackopt, noCallbackopt, sizeopt, exitKeyopt) → {UIObject}
Show a confirmation dialog with Yes/No buttons Centers the dialog on the screen with darkened background
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
text | string | <optional> | Are you sure? | The message to display |
yesCallback | function | <optional> | Called when Yes is clicked | |
noCallback | function | <optional> | Called when No is clicked | |
size | Vector2 | <optional> | Size of the confirmation dialog | |
exitKey | string | <optional> | Escape | Key that can exit the menu |
- Source
The confirmation menu object
- Type:
- UIObject