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
activeObject
PropertiesType | Description |
---|---|
UIObject | Object user is currently interacting with |
- Source
defaultButtonColor
PropertiesType | Description |
---|---|
Color | Default button color for UI elements |
- Source
defaultColor
PropertiesType | Description |
---|---|
Color | Default fill color for UI elements |
- Source
defaultCornerRadius
PropertiesType | Description |
---|---|
number | Default rounded rect corner radius for UI elements |
- Source
defaultDisabledColor
PropertiesType | Description |
---|---|
Color | Default color for disabled UI elements |
- Source
defaultFont
PropertiesType | Description |
---|---|
string | Default font for UI elements |
- Source
defaultGradientColor
PropertiesType | Description |
---|---|
Color | Uses a gradient fill combined with color |
- Source
defaultHoverColor
PropertiesType | Description |
---|---|
Color | Default hover color for UI elements |
- Source
defaultLineColor
PropertiesType | Description |
---|---|
Color | Default outline color for UI elements |
- Source
defaultLineWidth
PropertiesType | Description |
---|---|
number | Default line width for UI elements |
- Source
defaultSoundClick
PropertiesType | Description |
---|---|
Sound | Default sound when interactive UI element is clicked |
- Source
defaultSoundPress
PropertiesType | Description |
---|---|
Sound | Default sound when interactive UI element is pressed |
- Source
defaultSoundRelease
PropertiesType | Description |
---|---|
Sound | Default sound when interactive UI element is released |
- Source
defaultTextColor
PropertiesType | Description |
---|---|
Color | Default text color for UI elements |
- Source
defaultTextScale
PropertiesType | Description |
---|---|
number | Default scale to use for fitting text to object |
- Source
hoverObject
PropertiesType | Description |
---|---|
UIObject | Top most object user is over |
- Source
lastHoverObject
PropertiesType | Description |
---|---|
UIObject | Hover object at start of update |
- Source
nativeHeight
PropertiesType | Description |
---|---|
number | If set ui coords will be renormalized to this canvas height |
- Source
uiContext
PropertiesType | Description |
---|---|
CanvasRenderingContext2D | | Context to render UI elements to |
- Source
uiObjects
PropertiesType | 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)
Draw a rectangle to the UI context
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pos | Vector2 | |||
size | Vector2 | |||
color | Color | <optional> | uiSystem.defaultColor | |
lineWidth | number | <optional> | uiSystem.defaultLineWidth | |
lineColor | Color | <optional> | uiSystem.defaultLineColor | |
cornerRadius | number | <optional> | uiSystem.defaultCornerRadius | |
gradientColor | Color | <optional> | uiSystem.defaultGradientColor |
- Source
drawText(text, pos, size, coloropt, lineWidthopt, lineColoropt, alignopt, fontopt, fontStyleopt, applyMaxWidthopt)
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 |
- Source
drawTile(pos, size, tileInfo, coloropt, angleopt, mirroropt)
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 |
- Source
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> | continously when dragging over |
- Source