Basalt 1.7 Update
- New Objects (Flexbox, Graph, Treeview) - Pluginsystem to add/remove functionality - Reworked the entire Object system, instead of one big Object Class we have multiple classes: Object, VisualObject, ChangeableObject - Instead of one big Frame Class we have multiple Frame Classes: BaseFrame, Frame, MovableFrame, ScrollableFrame, MonitorFrame, Flexbox - Removed the Animation Object, and added a animation plugin instead - Removed the Graphic Object and merged it's functionality with the image object - Updated currently existing objects
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# Basalt
|
||||
|
||||
## autoUpdate
|
||||
|
||||
### Description
|
||||
|
||||
This starts the event and draw handler for you. The listeners will run until you stop them.
|
||||
|
||||
### Parameters
|
||||
@@ -13,6 +13,12 @@ This starts the event and draw handler for you. The listeners will run until you
|
||||
* Enables the basalt listeners, otherwise the screen will not continue to update
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local main = basalt.createFrame()
|
||||
basalt.autoUpdate()
|
||||
basalt.autoUpdate() -- Start the event and draw listeners
|
||||
|
||||
-- Some code here...
|
||||
|
||||
basalt.autoUpdate(false) -- Stop the event and draw listeners
|
||||
```
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
# Basalt
|
||||
|
||||
## createFrame
|
||||
|
||||
Creates a new base-frame, you can have as many base-frames as you want, but only 1 can be active (visible) at the same time.
|
||||
You can always switch between your base frames.
|
||||
### Description
|
||||
|
||||
Only the currently active base-frame listens to incoming events (except for some events like time-events and peripheral-events)
|
||||
Creates a new base frame, which is essentially a frame without a parent. You can have as many base frames as you want, but only one can be active (visible) at a time. You can always switch between your base frames.
|
||||
|
||||
Only the currently active base frame listens to incoming events (except for some events like time-events and peripheral-events).
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `string` id - optional (if you dont set a id it will automatically create a uuid for you)
|
||||
1. `string` id - optional (if you don't set an ID, it will automatically create a UUID for you)
|
||||
|
||||
### Returns
|
||||
|
||||
@@ -24,7 +23,7 @@ local main1 = basalt.createFrame() -- Visible base frame on program start
|
||||
local main2 = basalt.createFrame()
|
||||
local main3 = basalt.createFrame()
|
||||
main1:addButton()
|
||||
:setPosition(2,2)
|
||||
:setPosition(2, 2)
|
||||
:setText("Switch")
|
||||
:onClick(function()
|
||||
main2:show() -- this function automatically "hides" the first one and shows the second one
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
# Basalt
|
||||
|
||||
## debug
|
||||
|
||||
Creates a label with some information on the main frame on the bottom left. When you click on that label it will open a log view for you. See it as the new print for debugging
|
||||
### Description
|
||||
|
||||
You can also edit the default debug Label (change position, change color or whatever you want) by accessing the variable `basalt.debugLabel`
|
||||
which returns the debug Label.
|
||||
Creates a label with some information on the main frame in the bottom left corner. When you click on that label, it will open a log view for you. Think of it as the new print for debugging.
|
||||
|
||||
You can also edit the default debug label (change position, change color, or whatever you want) by accessing the variable `basalt.debugLabel`, which returns the debug label.
|
||||
|
||||
`basalt.debugFrame` and `basalt.debugList` are also available.
|
||||
|
||||
@@ -19,11 +18,4 @@ which returns the debug Label.
|
||||
|
||||
```lua
|
||||
basalt.debug("Hello! ", "^-^")
|
||||
```
|
||||
|
||||
* Changes the debug label's anchor
|
||||
|
||||
```lua
|
||||
basalt.debugLabel:setAnchor("topLeft") -- default anchor is bottomLeft
|
||||
basalt.debug("Hello!")
|
||||
```
|
||||
```
|
||||
@@ -1,7 +1,7 @@
|
||||
# Basalt
|
||||
|
||||
## getActiveFrame
|
||||
|
||||
### Description
|
||||
|
||||
Returns the currently active/visible base frame.
|
||||
|
||||
### Returns
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Basalt
|
||||
|
||||
## getFrame
|
||||
|
||||
### Description
|
||||
|
||||
Returns a base frame by the given id.
|
||||
|
||||
### Parameters
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
# Basalt
|
||||
## getTheme
|
||||
|
||||
## basalt.getTheme
|
||||
### Description
|
||||
|
||||
Returns the current base-theme. This base-theme can be set using setTheme.md.
|
||||
A list of base-theme keys can be found [here](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua).
|
||||
Returns the current base-theme. This base-theme can be set using setTheme.lua.
|
||||
|
||||
### Returns
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Basalt
|
||||
|
||||
## getVariable
|
||||
|
||||
### Description
|
||||
|
||||
Returns a variable defined with [setVariable](objects/Basalt/setVariable)
|
||||
|
||||
### Returns
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Basalt
|
||||
|
||||
## getVersion
|
||||
|
||||
### Description
|
||||
|
||||
Returns the currently active/visible base frame.
|
||||
|
||||
### Returns
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Basalt
|
||||
|
||||
## isKeyDown
|
||||
|
||||
### Description
|
||||
|
||||
Checks if the user is currently holding a key
|
||||
|
||||
### Parameters
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
# Basalt
|
||||
|
||||
## log
|
||||
|
||||
This writes something into a file. The main goal is to make debugging errors easier. Lets say you'r program is crashing and you don't know why, you could use basalt.log The log files will automatically removed after you start your program again.
|
||||
### Description
|
||||
|
||||
Writes a message to the log file. This can be useful for debugging errors or keeping a record of events in your application. Log files are automatically removed when you start your program again.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `string` The text to write into the log file
|
||||
2. `string` - optional (default: "Debug") - the type to write
|
||||
2. `string` - The type or category of the log message
|
||||
|
||||
### Usage
|
||||
|
||||
@@ -17,12 +17,12 @@ This writes something into a file. The main goal is to make debugging errors eas
|
||||
basalt.log("Hello!")
|
||||
```
|
||||
|
||||
This should result in there beeing a file called `basaltLog.txt`. In the file it should say `[Basalt][Debug]: Hello!`.
|
||||
This should result in a file called `basaltLog.txt`. In the file it should say `[Basalt][Debug]: Hello!`.
|
||||
|
||||
* Writes "Config file missing" into the log file, with warning as prefix.
|
||||
* Writes "Config file missing" into the log file, with "WARNING" as the prefix.
|
||||
|
||||
```lua
|
||||
basalt.log("Config file is missing", "WARNING")
|
||||
```
|
||||
|
||||
This should result in there beeing a file called `basaltLog.txt`. In the file it should say `[Basalt][WARNING]: Config file is missing`.
|
||||
This should result in a file called `basaltLog.txt`. In the file, it should say `[Basalt][WARNING]: Config file is missing`.
|
||||
|
||||
18
docs/objects/Basalt/memory.md
Normal file
18
docs/objects/Basalt/memory.md
Normal file
@@ -0,0 +1,18 @@
|
||||
## memory
|
||||
|
||||
### Description
|
||||
|
||||
Returns the amount of memory used by Basalt in bytes. This can be useful for monitoring your application's memory usage and performance.
|
||||
|
||||
### Returns
|
||||
|
||||
1. `number` The amount of memory used by Basalt in bytes.
|
||||
|
||||
### Usage
|
||||
|
||||
* Display the memory usage in the debug console
|
||||
|
||||
```lua
|
||||
local memoryUsage = basalt.memory()
|
||||
basalt.debug("Memory usage: ", memoryUsage, " bytes")
|
||||
```
|
||||
@@ -1,8 +1,8 @@
|
||||
# Basalt
|
||||
|
||||
## onEvent
|
||||
|
||||
This is the top-level method to intercept an event before sending it to the object event handlers. If you use return false, the event is not passed to the event handlers.
|
||||
### Description
|
||||
|
||||
This is the top-level method to intercept an event before sending it to the object event handlers. If you use `return false`, the event is not passed to the event handlers.
|
||||
|
||||
### Parameters
|
||||
|
||||
@@ -10,6 +10,8 @@ This is the top-level method to intercept an event before sending it to the obje
|
||||
|
||||
### Usage
|
||||
|
||||
* Prevents the "terminate" event from stopping the program
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Basalt
|
||||
|
||||
## removeFrame
|
||||
|
||||
### Description
|
||||
|
||||
Removes the base frame by it's id. **This only works for base-frames.**
|
||||
|
||||
### Parameters
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Basalt
|
||||
|
||||
## schedule
|
||||
|
||||
### Description
|
||||
|
||||
Schedules a function which gets called in a coroutine. After the coroutine is finished it will get destroyed immediatly. It's something like threads, but with some limits.
|
||||
**A guide can be found [here](/tips/logic).**
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Basalt
|
||||
|
||||
## setActiveFrame
|
||||
|
||||
Sets what should be the active baseframe.
|
||||
### Description
|
||||
|
||||
Sets the active base frame.
|
||||
|
||||
### Parameters
|
||||
|
||||
@@ -10,4 +10,23 @@ Sets what should be the active baseframe.
|
||||
|
||||
### Usage
|
||||
|
||||
TODO
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local main1 = basalt.createFrame("firstBaseFrame")
|
||||
local main2 = basalt.createFrame("secondBaseFrame")
|
||||
|
||||
main1:addButton()
|
||||
:setText("Switch to main2")
|
||||
:onClick(function()
|
||||
basalt.setActiveFrame(main2)
|
||||
end)
|
||||
|
||||
main2:addButton()
|
||||
:setText("Switch to main1")
|
||||
:onClick(function()
|
||||
basalt.setActiveFrame(main1)
|
||||
end)
|
||||
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
# Basalt
|
||||
|
||||
## setMouseDragThrottle
|
||||
|
||||
### Description
|
||||
|
||||
Changes the drag throttle of all drag events. Default value is 50ms - which is 0.05s.
|
||||
Instead of sending all mouse_drag events to the :onDrag handlers basalt sends every 0.05s (while dragging) the most recent drag event to all
|
||||
drag handlers. If you need all drag events - just change the value to 0.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `number` A number in miliseconds.
|
||||
1. `number` throttle - A number in milliseconds representing the drag throttle.
|
||||
|
||||
### Usage
|
||||
|
||||
* Set the drag throttle to 0, which sends all drag events to the handlers
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
basalt.setMouseDragThrottle(0)
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
# Basalt
|
||||
|
||||
## setMouseMoveThrottle
|
||||
|
||||
### Description
|
||||
|
||||
This feature is only available for [CraftOS-PC](https://www.craftos-pc.cc).
|
||||
|
||||
CraftOS-PC has a builtin mouse_move event, which is disabled by default. By using this method it will also enable the event for you. Remember - basalt does not disable the event after closing the program, which means the event stays active. If you want to disable the event please use config.set("mouse_move_throttle", -1) in your lua prompt or your program.
|
||||
CraftOS-PC has a built-in `mouse_move` event, which is disabled by default. By using this method, it will also enable the event for you. Remember, Basalt does not disable the event after closing the program, which means the event stays active. If you want to disable the event, please use `config.set("mouse_move_throttle", -1)` in your Lua prompt or your program.
|
||||
|
||||
Sidenote: a very low amount can make the program laggy - because it litterally spams the mouse_move event. So use it carefully.
|
||||
Sidenote: A very low amount can make the program laggy because it literally spams the `mouse_move` event. So, use it carefully.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `number` A number in miliseconds.
|
||||
1. `number` throttle - A number in milliseconds representing the mouse move throttle.
|
||||
|
||||
### Usage
|
||||
|
||||
* Set the mouse move throttle to 50 milliseconds
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
basalt.setMouseMoveThrottle(50)
|
||||
|
||||
18
docs/objects/Basalt/setRenderingThrottle.md
Normal file
18
docs/objects/Basalt/setRenderingThrottle.md
Normal file
@@ -0,0 +1,18 @@
|
||||
## setRenderingThrottle
|
||||
|
||||
### Description
|
||||
|
||||
Sets the rendering throttle for Basalt's automatic update process. This determines how often the screen is updated during the auto-update loop. A higher value means the screen updates less frequently, potentially reducing CPU usage and improving performance, while a lower value results in more frequent updates, ensuring smoother animations and responsiveness.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `number` throttle - The throttle value in milliseconds. Default value is 50ms (0.05 seconds).
|
||||
|
||||
### Usage
|
||||
|
||||
* Sets the rendering throttle to 100ms (0.1 seconds).
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
basalt.setMouseMoveThrottle(100)
|
||||
```
|
||||
@@ -1,16 +1,16 @@
|
||||
# Basalt
|
||||
|
||||
## setTheme
|
||||
|
||||
Sets the base theme of the project! Make sure to cover all existing objects, otherwise it will result in errors. A good example is [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua). The theme can also be gotten with [`basalt.getTheme()`](objects/Basalt/getTheme)
|
||||
### Description
|
||||
|
||||
Sets the base theme of the project! Make sure to cover all existing objects, otherwise it will result in errors. A good example is [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua). The theme can also be retrieved with [`basalt.getTheme()`](objects/Basalt/getTheme)
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `table` theme layout look into [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua) for a example
|
||||
1. `table` theme - A table containing the theme layout. Look into [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua) for an example
|
||||
|
||||
### Usage
|
||||
|
||||
* Sets the default theme of basalt.
|
||||
* Sets the default theme of Basalt.
|
||||
|
||||
```lua
|
||||
basalt.setTheme({
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
# Basalt
|
||||
|
||||
## setVariable
|
||||
|
||||
This stores a variable which you're able to access via xml. You are also able to add a function, which then gets called by object events created in XML.
|
||||
### Description
|
||||
|
||||
This method stores a variable that you can access via XML. You can also add a function, which is then called by object events created in XML.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `string` a key name
|
||||
2. `any` any variable
|
||||
1. `string` key - A key name to store the variable.
|
||||
2. `any` value - Any variable to store under the key.
|
||||
|
||||
### Usage
|
||||
|
||||
* Adds a function to basalt.
|
||||
* Adds a reusable function to Basalt.
|
||||
|
||||
```lua
|
||||
basalt.setVariable("clickMe", function()
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
# Basalt
|
||||
|
||||
## stopUpdate / stop
|
||||
|
||||
Stops the automatic draw and event handler which got started by `basalt.autoUpdate()`.
|
||||
`basalt.autoUpdate(false)` also does the same.
|
||||
### Description
|
||||
|
||||
This method stops the automatic draw and event handler that was started by `basalt.autoUpdate()`.
|
||||
`basalt.autoUpdate(false)` achieves the same result.
|
||||
|
||||
### Usage
|
||||
|
||||
* When the quit button is clicked, the button stops basalt's event listeners and draw handlers
|
||||
* When the quit button is clicked, the button stops Basalt's event listeners and draw handlers.
|
||||
|
||||
```lua
|
||||
local main = basalt.createFrame()
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# Basalt
|
||||
|
||||
## update
|
||||
|
||||
Calls the draw and event handler once - this gives more flexibility about which events basalt should process. For example you could filter the terminate event.
|
||||
|
||||
Reference in New Issue
Block a user