deploy: d55a80dc0e
This commit is contained in:
112
docs/content/BaseElement.md
Normal file
112
docs/content/BaseElement.md
Normal file
@@ -0,0 +1,112 @@
|
||||
# BaseElement
|
||||
The base class for all UI elements in Basalt
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|---|---|---|---|
|
||||
|type|string|BaseElement|The type identifier of the element
|
||||
|eventCallbacks|table|{}|Table containing all registered event callbacks
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[BaseElement.listenTo](#BaseElement.listenTo)|-|
|
||||
|[BaseElement.new](#BaseElement.new)|table|
|
||||
|[BaseElement:fireEvent](#BaseElement:fireEvent)|table|
|
||||
|[BaseElement:init](#BaseElement:init)|table|
|
||||
|[BaseElement:listenEvent](#BaseElement:listenEvent)|table|
|
||||
|[BaseElement:registerCallback](#BaseElement:registerCallback)|table|
|
||||
|[BaseElement:updateRender](#BaseElement:updateRender)|-|
|
||||
|
||||
## BaseElement.listenTo(class, eventName)
|
||||
Registers an event that this class can listen to
|
||||
|
||||
### Parameters
|
||||
* `class` `table` The class to add the event to
|
||||
* `eventName` `string` The name of the event to register
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
BaseElement.listenTo(MyClass, "mouse_click")
|
||||
```
|
||||
|
||||
## BaseElement.new(id, basalt)
|
||||
Creates a new BaseElement instance
|
||||
|
||||
### Parameters
|
||||
* `id` `string` The unique identifier for this element
|
||||
* `basalt` `table` The basalt instance
|
||||
|
||||
### Returns
|
||||
* `table` `The` newly created BaseElement instance
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
local element = BaseElement.new("myId", basalt)
|
||||
```
|
||||
|
||||
## BaseElement:fireEvent(event, ...)
|
||||
Triggers an event and calls all registered callbacks
|
||||
|
||||
### Parameters
|
||||
* `event` `string` The event to fire
|
||||
* `...` `any` Additional arguments to pass to the callbacks
|
||||
|
||||
### Returns
|
||||
* `table` `self` The BaseElement instance
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
element:fireEvent("mouse_click", 1, 2)
|
||||
```
|
||||
|
||||
## BaseElement:init(id, basalt)
|
||||
Initializes the BaseElement instance
|
||||
|
||||
### Parameters
|
||||
* `id` `string` The unique identifier for this element
|
||||
* `basalt` `table` The basalt instance
|
||||
|
||||
### Returns
|
||||
* `table` `self` The initialized instance
|
||||
|
||||
## BaseElement:listenEvent(eventName, enable?)
|
||||
Enables or disables event listening for a specific event
|
||||
|
||||
### Parameters
|
||||
* `eventName` `string` The name of the event to listen for
|
||||
* `enable` *(optional)* `boolean` Whether to enable or disable the event (default: true)
|
||||
|
||||
### Returns
|
||||
* `table` `self` The BaseElement instance
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
element:listenEvent("mouse_click", true)
|
||||
```
|
||||
|
||||
## BaseElement:registerCallback(event, callback)
|
||||
Registers a callback function for an event
|
||||
|
||||
### Parameters
|
||||
* `event` `string` The event to register the callback for
|
||||
* `callback` `function` The callback function to register
|
||||
|
||||
### Returns
|
||||
* `table` `self` The BaseElement instance
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
element:registerCallback("mouse_click", function(self, ...) end)
|
||||
```
|
||||
|
||||
## BaseElement:updateRender()
|
||||
Requests a render update for this element
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
element:updateRender()
|
||||
```
|
||||
|
||||
10
docs/content/BaseFrame.md
Normal file
10
docs/content/BaseFrame.md
Normal file
@@ -0,0 +1,10 @@
|
||||
## BaseFrame.new()
|
||||
@diagnostic disable-next-line: duplicate-set-field
|
||||
|
||||
## BaseFrame:multiBlit()
|
||||
|
||||
## BaseFrame:render()
|
||||
@diagnostic disable-next-line: duplicate-set-field
|
||||
|
||||
## BaseFrame:textFg()
|
||||
|
||||
6
docs/content/Button.md
Normal file
6
docs/content/Button.md
Normal file
@@ -0,0 +1,6 @@
|
||||
## Button.new()
|
||||
@diagnostic disable-next-line: duplicate-set-field
|
||||
|
||||
## Button:render()
|
||||
@diagnostic disable-next-line: duplicate-set-field
|
||||
|
||||
28
docs/content/Container.md
Normal file
28
docs/content/Container.md
Normal file
@@ -0,0 +1,28 @@
|
||||
## Container.new()
|
||||
@diagnostic disable-next-line: duplicate-set-field
|
||||
|
||||
## Container:addChild()
|
||||
|
||||
## Container:handleEvent()
|
||||
|
||||
## Container:multiBlit()
|
||||
|
||||
## Container:registerChildEvent()
|
||||
|
||||
## Container:registerChildrenEvents()
|
||||
|
||||
## Container:removeChild()
|
||||
|
||||
## Container:removeChildrenEvents()
|
||||
|
||||
## Container:render()
|
||||
@diagnostic disable-next-line: duplicate-set-field
|
||||
|
||||
## Container:sortChildren()
|
||||
|
||||
## Container:sortChildrenEvents()
|
||||
|
||||
## Container:textFg()
|
||||
|
||||
## Container:unregisterChildEvent()
|
||||
|
||||
3
docs/content/Frame.md
Normal file
3
docs/content/Frame.md
Normal file
@@ -0,0 +1,3 @@
|
||||
## Frame.new()
|
||||
@diagnostic disable-next-line: duplicate-set-field
|
||||
|
||||
37
docs/content/VisualElement.md
Normal file
37
docs/content/VisualElement.md
Normal file
@@ -0,0 +1,37 @@
|
||||
## VisualElement.new()
|
||||
@diagnostic disable-next-line: duplicate-set-field
|
||||
|
||||
## VisualElement:getAbsolutePosition(x?, y?)
|
||||
Returns the absolute position of the element or the given coordinates.
|
||||
|
||||
### Parameters
|
||||
* `x` *(optional)* `number` -- x position
|
||||
* `y` *(optional)* `number` -- y position
|
||||
|
||||
## VisualElement:getRelativePosition(x?, y?)
|
||||
Returns the relative position of the element or the given coordinates.
|
||||
|
||||
### Parameters
|
||||
* `x` *(optional)* `number` -- x position
|
||||
* `y` *(optional)* `number` -- y position
|
||||
|
||||
### Returns
|
||||
* `nil` `nil` nil
|
||||
|
||||
## VisualElement:handleEvent()
|
||||
|
||||
## VisualElement:isInBounds()
|
||||
|
||||
## VisualElement:mouse_click()
|
||||
|
||||
## VisualElement:mouse_release()
|
||||
|
||||
## VisualElement:mouse_up()
|
||||
|
||||
## VisualElement:multiBlit()
|
||||
|
||||
## VisualElement:render()
|
||||
@diagnostic disable-next-line: duplicate-set-field
|
||||
|
||||
## VisualElement:textFg()
|
||||
|
||||
0
docs/content/colorHex.md
Normal file
0
docs/content/colorHex.md
Normal file
14
docs/content/elementManager.md
Normal file
14
docs/content/elementManager.md
Normal file
@@ -0,0 +1,14 @@
|
||||
## ElementManager.extendMethod()
|
||||
|
||||
## ElementManager.generateId()
|
||||
|
||||
## ElementManager.getElement()
|
||||
|
||||
## ElementManager.getElementList()
|
||||
|
||||
## ElementManager.loadElement()
|
||||
|
||||
## ElementManager.loadPlugin()
|
||||
|
||||
## ElementManager.registerPlugin()
|
||||
|
||||
2
docs/content/errorManager.md
Normal file
2
docs/content/errorManager.md
Normal file
@@ -0,0 +1,2 @@
|
||||
## errorHandler.error()
|
||||
|
||||
1
docs/content/expect.md
Normal file
1
docs/content/expect.md
Normal file
@@ -0,0 +1 @@
|
||||
Simple type checking without stack traces
|
||||
1
docs/content/init.md
Normal file
1
docs/content/init.md
Normal file
@@ -0,0 +1 @@
|
||||
Use xpcall with error handler
|
||||
7
docs/content/log.md
Normal file
7
docs/content/log.md
Normal file
@@ -0,0 +1,7 @@
|
||||
Log levels
|
||||
## Log.error()
|
||||
|
||||
## Log.setEnabled()
|
||||
|
||||
## Log.setLogToFile()
|
||||
|
||||
139
docs/content/main.md
Normal file
139
docs/content/main.md
Normal file
@@ -0,0 +1,139 @@
|
||||
# Basalt
|
||||
This is the UI Manager and the starting point for your project. The following functions allow you to influence the default behavior of Basalt.
|
||||
|
||||
Before you can access Basalt, you need to add the following code on top of your file:
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
```
|
||||
|
||||
What this code does is it loads basalt into the project, and you can access it by using the variable defined as "basalt".
|
||||
|
||||
## Functions
|
||||
|
||||
|Method|Returns|Description|
|
||||
|---|---|---|
|
||||
|[basalt.create](#basalt.create)|table|Creates a new UI element
|
||||
|[basalt.createFrame](#basalt.createFrame)|table|
|
||||
|[basalt.getElementManager](#basalt.getElementManager)|table|
|
||||
|[basalt.getMainFrame](#basalt.getMainFrame)|BaseFrame|
|
||||
|[basalt.removeSchedule](#basalt.removeSchedule)|-|
|
||||
|[basalt.run](#basalt.run)|-|
|
||||
|[basalt.scheduleUpdate](#basalt.scheduleUpdate)|number|
|
||||
|[basalt.setActiveFrame](#basalt.setActiveFrame)|-|
|
||||
|[basalt.stop](#basalt.stop)|-|
|
||||
|[basalt.update](#basalt.update)|-|
|
||||
|
||||
## basalt.create(type, id?)
|
||||
Creates and returns a new UI element of the specified type.
|
||||
|
||||
### Parameters
|
||||
* `type` `string` The type of element to create (e.g. "Button", "Label", "BaseFrame")
|
||||
* `id` *(optional)* `string` Optional unique identifier for the element
|
||||
|
||||
### Returns
|
||||
* `table` `element` The created element instance
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
local button = basalt.create("Button")
|
||||
```
|
||||
|
||||
## basalt.createFrame()
|
||||
Creates and returns a new frame
|
||||
|
||||
### Returns
|
||||
* `table` `BaseFrame` The created frame instance
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
```
|
||||
|
||||
## basalt.getElementManager()
|
||||
Returns the element manager instance
|
||||
|
||||
### Returns
|
||||
* `table` `ElementManager` The element manager
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
local manager = basalt.getElementManager()
|
||||
```
|
||||
|
||||
## basalt.getMainFrame()
|
||||
Gets or creates the main frame
|
||||
|
||||
### Returns
|
||||
* `BaseFrame` `table` The main frame instance
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
local frame = basalt.getMainFrame()
|
||||
```
|
||||
|
||||
## basalt.removeSchedule(id)
|
||||
Removes a scheduled update
|
||||
|
||||
### Parameters
|
||||
* `id` `number` The schedule ID to remove
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
basalt.removeSchedule(scheduleId)
|
||||
```
|
||||
|
||||
## basalt.run(isActive)
|
||||
Starts the Basalt runtime
|
||||
|
||||
### Parameters
|
||||
* `isActive` `boolean` Whether to start active (default: true)
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
basalt.run()
|
||||
basalt.run(false)
|
||||
```
|
||||
|
||||
## basalt.scheduleUpdate(func)
|
||||
Schedules a function to be updated
|
||||
|
||||
### Parameters
|
||||
* `func` `function` The function to schedule
|
||||
|
||||
### Returns
|
||||
* `number` `Id` The schedule ID
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
local id = basalt.scheduleUpdate(myFunction)
|
||||
```
|
||||
|
||||
## basalt.setActiveFrame(frame)
|
||||
Sets the active frame
|
||||
|
||||
### Parameters
|
||||
* `frame` `table` The frame to set as active
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
basalt.setActiveFrame(myFrame)
|
||||
```
|
||||
|
||||
## basalt.stop()
|
||||
Stops the Basalt runtime
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
basalt.stop()
|
||||
```
|
||||
|
||||
## basalt.update()
|
||||
Updates all scheduled functions
|
||||
|
||||
### Usage
|
||||
```lua
|
||||
basalt.update()
|
||||
```
|
||||
|
||||
8
docs/content/propertySystem.md
Normal file
8
docs/content/propertySystem.md
Normal file
@@ -0,0 +1,8 @@
|
||||
## PropertySystem.defineProperty()
|
||||
|
||||
## PropertySystem:__init()
|
||||
|
||||
## PropertySystem:_updateProperty()
|
||||
|
||||
## PropertySystem:observe()
|
||||
|
||||
22
docs/content/render.md
Normal file
22
docs/content/render.md
Normal file
@@ -0,0 +1,22 @@
|
||||
## Render.new()
|
||||
|
||||
## Render:bg()
|
||||
|
||||
## Render:blit()
|
||||
|
||||
## Render:clear()
|
||||
|
||||
## Render:clearArea()
|
||||
|
||||
## Render:fg()
|
||||
|
||||
## Render:getSize()
|
||||
|
||||
## Render:multiBlit()
|
||||
|
||||
## Render:render()
|
||||
|
||||
## Render:text()
|
||||
|
||||
## Render:textFg()
|
||||
|
||||
4
docs/content/utils.md
Normal file
4
docs/content/utils.md
Normal file
@@ -0,0 +1,4 @@
|
||||
## utils.deepCopy()
|
||||
|
||||
## utils.getCenteredPosition()
|
||||
|
||||
Reference in New Issue
Block a user