Docs 1.6
Accidentally uploaded outdated 1.6 docs
This commit is contained in:
@@ -1,26 +1,19 @@
|
||||
# Welcome to The old Basalt Wiki!
|
||||
# Welcome to The Basalt Wiki
|
||||
|
||||
This Basalt Wiki is outdated!
|
||||
|
||||
*Note: The Basalt Wiki is a work in progress. Please treat Wiki errors the same as bugs and report them accordingly.*
|
||||
*Note: The Basalt Wiki is a work in progress. Please treat wiki errors the same as bugs and report them accordingly.*
|
||||
|
||||
Here you can find information about how to use Basalt as well as examples of functional Basalt code. The aim of Basalt is to improve user interaction through visual display.
|
||||
|
||||
## About Basalt
|
||||
|
||||
Basalt is intended to be an easy-to-understand UI Framework designed for CC:Tweaked (Also know as "ComputerCraft: Tweaked") - a popular minecraft mod. For more information about CC:Tweaked, checkout the project's [wiki](https://tweaked.cc/) or [download](https://www.curseforge.com/minecraft/mc-mods/cc-tweaked).
|
||||
Basalt is intended to be an easy-to-understand UI Framework designed for CC:Tweaked (Also known as "ComputerCraft: Tweaked") - a popular minecraft mod. For more information about CC:Tweaked, checkout the project's [wiki](https://tweaked.cc/) or [download](https://modrinth.com/mod/cc-tweaked).
|
||||
|
||||
## Quick Demo
|
||||
<img src="https://raw.githubusercontent.com/Pyroxenium/Basalt/master/docs/_media/basaltPreview2.gif" width="600">
|
||||
|
||||

|
||||
|
||||
## Questions & Bugs
|
||||
|
||||
Obviously NyoriE has implemented some easter eggs, *some people* call them "bugs". If you happen to discover one of these just make a new <a href="https://github.com/Pyroxenium/Basalt/issues">issue</a>.
|
||||
Obviously NyoriE has implemented some easter eggs, *some people* call them "bugs". If you happen to discover one of these just make a new [Github Issue](https://github.com/Pyroxenium/Basalt/issues)
|
||||
|
||||
Additionally, if you have questions about Basalt or how to make use of it, feel free to create a new discussion on <a href="https://github.com/Pyroxenium/Basalt/discussions">Basalt's Discussion Board</a>, or ask in our [discord](https://discord.gg/yNNnmBVBpE).
|
||||
|
||||
---
|
||||
|
||||
Feel free to join our [discord](https://discord.gg/yNNnmBVBpE)!
|
||||
|
||||
<br><br>
|
||||
Additionally, if you have questions about Basalt or how to make use of it, feel free to create a new discussion on [Basalt's Discussion Board (Github)](https://github.com/Pyroxenium/Basalt/discussions), or ask in our [discord](https://discord.gg/yNNnmBVBpE).
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
Thanks for checking out our wiki, join our discord for more help: [discord.gg/yM7kndJdJJ](discord.gg/yM7kndJdJJ)
|
||||
---
|
||||
|
||||
Thanks for checking out our wiki, join our discord for more help: [discord.gg/yM7kndJdJJ](discord.gg/yNNnmBVBpE)
|
||||
|
||||
BIN
docs/docs1_6/_media/dynamic-frames.mp4
Normal file
BIN
docs/docs1_6/_media/dynamic-frames.mp4
Normal file
Binary file not shown.
BIN
docs/docs1_6/_media/frames-with-menubars.mp4
Normal file
BIN
docs/docs1_6/_media/frames-with-menubars.mp4
Normal file
Binary file not shown.
BIN
docs/docs1_6/_media/frames-with-sidebar.mp4
Normal file
BIN
docs/docs1_6/_media/frames-with-sidebar.mp4
Normal file
Binary file not shown.
BIN
docs/docs1_6/_media/pane-example-1.png
Normal file
BIN
docs/docs1_6/_media/pane-example-1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
BIN
docs/docs1_6/_media/pane-example-2.png
Normal file
BIN
docs/docs1_6/_media/pane-example-2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 717 B |
BIN
docs/docs1_6/_media/resizable-frames.mp4
Normal file
BIN
docs/docs1_6/_media/resizable-frames.mp4
Normal file
Binary file not shown.
BIN
docs/docs1_6/_media/scrollable-frames.mp4
Normal file
BIN
docs/docs1_6/_media/scrollable-frames.mp4
Normal file
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
- Getting Started
|
||||
- [Home](Home.md)
|
||||
- [Quick Start](home/Quick-Start.md)
|
||||
- [Installer](home/installer)
|
||||
- [Home](Home)
|
||||
- [How To](home/How-To)
|
||||
- [Download](home/download)
|
||||
|
||||
@@ -1,35 +1,32 @@
|
||||
- About
|
||||
- [Home](Home.md)
|
||||
- [Quick Start](home/Quick-Start.md)
|
||||
- [Installer](home/installer)
|
||||
- [Home](home)
|
||||
- [How To](home/How-To)
|
||||
- [Download](home/download)
|
||||
- Objects
|
||||
- [Basalt](objects/Basalt)
|
||||
- [Object](objects/Object)
|
||||
- [Button](objects/Button)
|
||||
- [Checkbox](objects/Checkbox)
|
||||
- [Dropdown](objects/Dropdown)
|
||||
- [Frame](objects/Frame)
|
||||
- [Image](objects/Image)
|
||||
- [Input](objects/Input)
|
||||
- [Label](objects/Label)
|
||||
- [List](objects/List)
|
||||
- [Menubar](objects/Menubar)
|
||||
- [Pane](objects/Pane)
|
||||
- [Program](objects/Program)
|
||||
- [Progressbar](objects/Progressbar)
|
||||
- [Radio](objects/Radio)
|
||||
- [Scrollbar](objects/Scrollbar)
|
||||
- [Slider](objects/Slider)
|
||||
- [Textfield](objects/Textfield)
|
||||
- [Animation](objects/Animation.md)
|
||||
- [Thread](objects/Thread)
|
||||
- [Timer](objects/Timer)
|
||||
- Events
|
||||
- [Mouse Events](events/mouseEvents.md)
|
||||
- [Keyboard Events](events/keyEvents.md)
|
||||
- [Other Events](events/otherEvents.md)
|
||||
- [Basalt](objects/Basalt.md)
|
||||
- [Object](objects/Object.md)
|
||||
- [Button](objects/Button.md)
|
||||
- [Checkbox](objects/Checkbox.md)
|
||||
- [Dropdown](objects/Dropdown.md)
|
||||
- [Frame](objects/Frame.md)
|
||||
- [Image](objects/Image.md)
|
||||
- [Input](objects/Input.md)
|
||||
- [Label](objects/Label.md)
|
||||
- [List](objects/List.md)
|
||||
- [Menubar](objects/Menubar.md)
|
||||
- [Pane](objects/Pane.md)
|
||||
- [Program](objects/Program.md)
|
||||
- [Progressbar](objects/Progressbar.md)
|
||||
- [Radio](objects/Radio.md)
|
||||
- [Scrollbar](objects/Scrollbar.md)
|
||||
- [Slider](objects/Slider.md)
|
||||
- [Textfield](objects/Textfield.md)
|
||||
- [Animation](objects/Animation.md)
|
||||
- [Thread](objects/Thread.md)
|
||||
- [Timer](objects/Timer.md)
|
||||
- Tips & Tricks
|
||||
- [Component Logic](tips/logic)
|
||||
- [Changing Button Color](tips/buttons)
|
||||
- [Advanced usage of Events](tips/events.md)
|
||||
- [Example Designs](tips/design.md)
|
||||
- [Your Logic](tips/logic.md)
|
||||
- [Button coloring](tips/buttonColoring.md)
|
||||
- [Designing/Animating](tips/design.md)
|
||||
- [Dynamic Values](tips/dynamicvalues.md)
|
||||
- [XML](tips/xml.md)
|
||||
|
||||
61
docs/docs1_6/home/How-To.md
Normal file
61
docs/docs1_6/home/How-To.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# How-To
|
||||
|
||||
After downloading the project you can finally start creating your own program and use basalt. The first thing you want to use in your program is always:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
```
|
||||
|
||||
It doesn't matter if you're using the source folder or the minified/packed version of basalt. Both can be found by using require("basalt") without .lua.
|
||||
|
||||
Also to really run basalt you should use
|
||||
|
||||
```lua
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
|
||||
somewhere on the bottom of your program. basalt.autoUpdate() starts the event listener and the draw handler.
|
||||
|
||||
## Example
|
||||
|
||||
Here is a fully working example of how a program could look like:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt") --> Load the basalt framework into the variable called "basalt"
|
||||
|
||||
--> Now we want to create a base frame, we call the variable "main" - by default everything you create is visible. (you don't need to use :show())
|
||||
local main = basalt.createFrame()
|
||||
|
||||
local button = main:addButton() --> Here we add our first button
|
||||
button:setPosition(4, 4) -- of course we want to change the default position of our button
|
||||
button:setSize(16, 3) -- and the default size.
|
||||
button:setText("Click me!") --> This method displays what the text of our button should look like
|
||||
|
||||
local function buttonClick() --> Let us create a function we want to call when the button gets clicked
|
||||
basalt.debug("I got clicked!")
|
||||
end
|
||||
|
||||
-- Now we just need to register the function to the buttons onClick event handlers, this is how we can achieve that:
|
||||
button:onClick(buttonClick)
|
||||
|
||||
|
||||
basalt.autoUpdate() -- As soon as we call basalt.autoUpdate, the event and draw handlers will listen to any incomming events (and draw if necessary)
|
||||
```
|
||||
|
||||
If you're like us and strive for succinct and beautiful code, here is a cleaner implementation of the code above:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local main = basalt.createFrame()
|
||||
local button = main --> Basalt returns an instance of the object on most methods, to make use of "call-chaining"
|
||||
:addButton() --> This is an example of call chaining
|
||||
:setPosition(4,4)
|
||||
:setText("Click me!")
|
||||
:onClick(
|
||||
function()
|
||||
basalt.debug("I got clicked!")
|
||||
end)
|
||||
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
@@ -1,92 +0,0 @@
|
||||
## HowTo Use
|
||||
|
||||
To load the framework into your project, make use of the following code on top of your code.
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
```
|
||||
|
||||
It does not matter if you have installed the single file version or the full folder project. <br>
|
||||
Both versions can be loaded by using `require("Basalt")`, you dont need to add `.lua`.
|
||||
|
||||
## Download
|
||||
|
||||
### Download the folder version
|
||||
This version is for people who'd like to work with Basalt, change something in Basalt or checkout the project.<br>
|
||||
But you are also able to just use it to create your own UI.<br>
|
||||
|
||||
To install the full project to your CC:Tweaked Computer, use the following command on your CC:Tweaked shell:
|
||||
|
||||
`pastebin run ESs1mg7P`
|
||||
|
||||
This will download the project as a folder called "Basalt". You are immediatly after the download is done able to use it in your projects.
|
||||
|
||||
### Download the single file version
|
||||
This is the version you should use if you're done with programming. It is a little bit faster and it is also minified, which makes the project smaller.
|
||||
To install the single filed project to your CC:Tweaked Computer, use the following command on your CC:Tweaked shell:
|
||||
|
||||
`pastebin run ESs1mg7P packed`
|
||||
|
||||
This will download the project as a single file called "basalt.lua". You are immediatly after the download is done able to use it in your projects.
|
||||
|
||||
### Basalt Package Manager
|
||||
|
||||
The Basalt Package Manager is still in alpha!<br><br>
|
||||
The Basalt Package Manager is a visual installer, you are able to change some settings, also to choose which objects are necessary for your projects and which are not.
|
||||
|
||||
To install the BPM (Basalt Package Manager) use the following command on your CC:Tweaked shell:
|
||||
|
||||
`pastebin run ESs1mg7P bpm true`
|
||||
|
||||
The true keyword in the end is optional and would simply start BPM immediately.
|
||||
|
||||
## Example
|
||||
Here is a fully functioning example of Basalt code
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt") --> Load the Basalt framework
|
||||
|
||||
--> Create the first frame. Please note that Basalt needs at least one active "non-parent" frame to properly supply events
|
||||
--> When Basalt#createFrame makes use of unique identifiers (commonly referred to as UIDs), meaning that the supplied value must be UNIQUE
|
||||
local mainFrame = basalt.createFrame("mainFrame")
|
||||
|
||||
--> Show the frame to the user
|
||||
mainFrame:show()
|
||||
|
||||
local button = mainFrame:addButton("clickableButton") --> Add a button to the mainFrame (With a unique identifier)
|
||||
|
||||
--> Set the position of the button, Button#setPosition follows an x, y pattern.
|
||||
--> The x value is how far right the object should be from its anchor (negative values from an anchor will travel left)
|
||||
--> The y value is how far down the object should be from its anchor (negative values from an anchor will travel up)
|
||||
button:setPosition(4, 4)
|
||||
|
||||
button:setText("Click me!") --> Set the text of our button
|
||||
|
||||
local function buttonClick() --> This function serves as our click logic
|
||||
basalt.debug("I got clicked!")
|
||||
end
|
||||
|
||||
--> Remember! You cannot supply buttonClick(), that will only supply the result of the function
|
||||
--> Make sure the button knows which function to call when it's clicked
|
||||
button:onClick(buttonClick)
|
||||
|
||||
button:show() --> Make the button visible, so the user can click it
|
||||
|
||||
basalt.autoUpdate() --> Basalt#autoUpdate starts the event listener to detect user input
|
||||
```
|
||||
If you're like us and strive for succinct and beautiful code, here is a cleaner implementation of the code above:
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame("mainFrame"):show()
|
||||
local button = mainFrame --> Basalt returns an instance of the object on most methods, to make use of "call-chaining"
|
||||
:addButton("clickableButton") --> This is an example of call chaining
|
||||
:setPosition(4,4)
|
||||
:setText("Click me!")
|
||||
:onClick(
|
||||
function()
|
||||
basalt.debug("I got clicked!")
|
||||
end)
|
||||
:show()
|
||||
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
36
docs/docs1_6/home/download.md
Normal file
36
docs/docs1_6/home/download.md
Normal file
@@ -0,0 +1,36 @@
|
||||
Basalt provides multiple unique versions. A source version, a minified version and a web version.
|
||||
|
||||
## Source
|
||||
|
||||
This version is, like the name already says, the source code of basalt. If you want to dig into the code, add additional content or just prefer to use the source, then you should aim for the source-version.
|
||||
|
||||
The following command allows you to download the source-version on your computer:
|
||||
|
||||
`wget run https://basalt.madefor.cc/install.lua source [foldername] [branch]`
|
||||
|
||||
The first optional argument is the folder name you wish that basalt should be installed into, by default the folder is called basalt.
|
||||
The second optional argument is the branch you want to use. If you don't know what this means please ignore it (the 2 options are master and dev)
|
||||
|
||||
## Minified / Packed
|
||||
|
||||
This version is the minified version, i also call it the packed version. There are 2 changes, the first one is that the code will be shown minified which makes the size much smaller, the second change is that you will recieve a file instead of a folder.
|
||||
|
||||
The following command allows you to download the packed-version on your computer:
|
||||
|
||||
`wget run https://basalt.madefor.cc/install.lua packed [filename] [branch]`
|
||||
|
||||
The first optional argument is the file name you wish that the installer should use, by default the file is called basalt.lua.
|
||||
The second optional argument is the branch you want to use. If you don't know what this means please ignore it (the 2 options are master and dev)
|
||||
|
||||
## Web
|
||||
|
||||
The web version is a special version, used if your goal is to keep your project's size as small as possible. I suggest you to use the web version only if you don't restart your program over and over again. For example if you designed your program to reboot after the user made a bad choice (leads into a error or something like that) it is better to use the minified/source version.
|
||||
|
||||
The following command allows you to download the web-version on your computer:
|
||||
|
||||
`wget run https://basalt.madefor.cc/install.lua web [version] [filename]`
|
||||
|
||||
By default the first argument is the latest version of basalt's releases. [Here](https://github.com/Pyroxenium/Basalt/tree/master/docs/versions) you can see which versions are available to use.
|
||||
For example: wget run https://basalt.madefor.cc/install.lua web basalt-1.6.3.lua - the second argument is just the file name, default is basaltWeb.lua.
|
||||
|
||||
Remember to rename `local basalt = require("basalt")` into `local basalt = require("basaltWeb")` if you want to use the web-version
|
||||
@@ -1,74 +0,0 @@
|
||||
# Installer
|
||||
|
||||
This is just a script which helps you to setup your program to automatically install the Basalt UI Framework, if it doesn't exists. Means, you create your program (which requires basalt) and add this on the top of your program. Now, everytime you execute your program it checks if basalt.lua (or your custom filepath) exists or not, if not it installs it, or if you are using the advanced installer, it asks the user if the program is allowed to install basalt for you.
|
||||
|
||||
## Basic Installer
|
||||
Here is a very basic one which just installs basalt.lua if don't exist:
|
||||
```lua
|
||||
--Basalt configurated installer
|
||||
local filePath = "basalt.lua" --here you can change the file path default: basalt
|
||||
if not(fs.exists(filePath))then
|
||||
shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", "")) -- this is an alternative to the wget command
|
||||
end
|
||||
local basalt = require(filePath:gsub(".lua", "")) -- here you can change the variablename in any variablename you want default: basalt
|
||||
```
|
||||
|
||||
## Advanced Installer
|
||||
This is a visual version, it asks the user if he wants to install basalt.lua (if not found)<br>
|
||||

|
||||
```lua
|
||||
--Basalt configurated installer
|
||||
local filePath = "basalt.lua" --here you can change the file path default: basalt
|
||||
if not(fs.exists(filePath))then
|
||||
local w,h = term.getSize()
|
||||
term.clear()
|
||||
local _installerWindow = window.create(term.current(),w/2-8,h/2-3,18,6)
|
||||
_installerWindow.setBackgroundColor(colors.gray)
|
||||
_installerWindow.setTextColor(colors.black)
|
||||
_installerWindow.write(" Basalt Installer ")
|
||||
_installerWindow.setBackgroundColor(colors.lightGray)
|
||||
for line=2,6,1 do
|
||||
_installerWindow.setCursorPos(1,line)
|
||||
if(line==3)then
|
||||
_installerWindow.write(" No Basalt found! ")
|
||||
elseif(line==4)then
|
||||
_installerWindow.write(" Install it? ")
|
||||
elseif(line==6)then
|
||||
_installerWindow.setTextColor(colors.black)
|
||||
_installerWindow.setBackgroundColor(colors.gray)
|
||||
_installerWindow.write("Install")
|
||||
_installerWindow.setBackgroundColor(colors.lightGray)
|
||||
_installerWindow.write(string.rep(" ",5))
|
||||
_installerWindow.setBackgroundColor(colors.red)
|
||||
_installerWindow.write("Cancel")
|
||||
else
|
||||
_installerWindow.write(string.rep(" ",18))
|
||||
end
|
||||
end
|
||||
_installerWindow.setVisible(true)
|
||||
_installerWindow.redraw()
|
||||
while(not(fs.exists(filePath))) do
|
||||
local event, p1,p2,p3,p4 = os.pullEvent()
|
||||
if(event=="mouse_click")then
|
||||
if(p3==math.floor(h/2+2))and(p2>=w/2-8)and(p2<=w/2-2)then
|
||||
shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", ""))
|
||||
_installerWindow.setVisible(false)
|
||||
term.clear()
|
||||
break
|
||||
end
|
||||
if(p3==math.floor(h/2+2))and(p2<=w/2+9)and(p2>=w/2+4)then
|
||||
_installerWindow.clear()
|
||||
_installerWindow.setVisible(false)
|
||||
term.setCursorPos(1,1)
|
||||
term.clear()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
term.setCursorPos(1,1)
|
||||
term.clear()
|
||||
end
|
||||
|
||||
local basalt = require(filePath:gsub(".lua", "")) -- here you can change the variablename in any variablename you want default: basalt
|
||||
------------------------------
|
||||
```
|
||||
@@ -33,22 +33,39 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">Did you know: Basalt is a Pyroxene?></div>
|
||||
<script src="//cdn.jsdelivr.net/npm/docsify-edit-on-github"></script>
|
||||
<script>
|
||||
window.$docsify = {
|
||||
logo: '/_media/logo.png',
|
||||
loadNavbar: true,
|
||||
loadSidebar: true,
|
||||
loadFooter: '_footer.md',
|
||||
autoHeader: true,
|
||||
subMaxLevel: 1,
|
||||
homepage: 'Home.md',
|
||||
name: 'Basalt',
|
||||
repo: 'https://github.com/Pyroxenium/Basalt',
|
||||
auto2top: true
|
||||
auto2top: true,
|
||||
search: {
|
||||
maxAge: 86400000, // Expiration time, the default one day
|
||||
paths: 'auto',
|
||||
placeholder: 'Type to search',
|
||||
noData: 'No Results!',
|
||||
// Headline depth, 1 - 6
|
||||
depth: 2,
|
||||
hideOtherSidebarContent: false, // whether or not to hide other sidebar content
|
||||
},
|
||||
plugins: [
|
||||
EditOnGithubPlugin.create("https://github.com/Pyroxenium/Basalt/blob/master/docs/", null, "Edit on Github")
|
||||
]
|
||||
}
|
||||
</script>
|
||||
<!-- Docsify v4 -->
|
||||
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/js/docsify-themeable.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/prismjs@1.28.0/components/prism-lua.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/@alertbox/docsify-footer/dist/docsify-footer.min.js"></script>
|
||||
<script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/docsify-copy-code/dist/docsify-copy-code.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/zoom-image.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,303 +1,32 @@
|
||||
With animations, you can create a beautiful experience for users while interacting with objects.<br>
|
||||
For now the animation class is very basic, it will be expanded in the future, but we have to say you can already do almost everything you can imagine!
|
||||
With animations, you can create a beautiful experience for users while interacting with your program.
|
||||
There are 2 types of animations, predefined animations and custom animations. By using add and wait you can create custom
|
||||
animations (calls). Pre-defined methods are for example move, offset, size, changeText,...
|
||||
|
||||
Right now animation is a class which makes use of the timer event.<br>
|
||||
You can find more information below:
|
||||
:setObject always sets the object on what pre-defined methods should apply on.
|
||||
|
||||
`The animation object is still a WIP and the way you use it right now could change in the future!`
|
||||
|
||||
## add
|
||||
Adds a new function to an animation
|
||||
#### Parameters:
|
||||
1. `function` The function containing animation logic
|
||||
|
||||
#### Returns:
|
||||
1. `animation` Animation in use
|
||||
When calling a pre-defined animation it will check what is safed as object (:setObject) and will calculate the animation methods based on that which means you won't
|
||||
be able to change the object on the fly - you will always have to recreate the animation itself
|
||||
|
||||
|
||||
#### Usage:
|
||||
* This will set the button position to 3,3, waits 1 second, then sets position to 4,4, waits 2 seconds, and then sets the position to 5,5
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton()
|
||||
local aAnimation = mainFrame:addAnimation():add(function() testButton:setPosition(3,3) end):wait(1):add(function() testButton:setPosition(1,1,"r") end):wait(2):add(function() testButton:setPosition(1,1,"r") end)
|
||||
aAnimation:play()
|
||||
```
|
||||
|
||||
## wait
|
||||
Sets a wait timer for the next function after the previous function got executed, no wait timer calls the next function immediately
|
||||
#### Parameters:
|
||||
1. `number` The length of delay between the functions _(in seconds)_
|
||||
|
||||
#### Returns:
|
||||
1. `animation` Animation in use
|
||||
|
||||
#### Usage:
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton()
|
||||
local aAnimation = mainFrame:addAnimation():add(function() testButton:setPosition(3,3) end):wait(1):add(function() testButton:setPosition(1,1,"r") end):wait(2):add(function() testButton:setPosition(1,1,"r") end)
|
||||
|
||||
aAnimation:play()
|
||||
```
|
||||
|
||||
## play
|
||||
Plays the animation
|
||||
#### Parameters:
|
||||
1. `boolean` Whether it will loop forever, will most likely be replaced with a count in the future
|
||||
|
||||
#### Returns:
|
||||
1. `animation` Animation in use
|
||||
|
||||
#### Usage:
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton()
|
||||
local aAnimation = mainFrame:addAnimation():add(function() testButton:setBackground(colors.black) end):wait(1):add(function() testButton:setBackground(colors.gray) end):wait(1):add(function() testButton:setBackground(colors.lightGray) end)
|
||||
|
||||
aAnimation:play() -- changes the background color of that button from black to gray and then to lightGray
|
||||
```
|
||||
|
||||
## cancel
|
||||
Cancels the animation
|
||||
|
||||
#### Returns:
|
||||
1. `animation` Animation in use
|
||||
|
||||
#### Usage:
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton()
|
||||
local aAnimation = mainFrame:addAnimation():add(function() testButton:setBackground(colors.black) end):wait(1):add(function() aAnimation:cancel() end):wait(1):add(function() testButton:setBackground(colors.lightGray) end)
|
||||
|
||||
aAnimation:play()
|
||||
```
|
||||
|
||||
|
||||
## setObject
|
||||
Sets the object which the animation should reposition/resize
|
||||
|
||||
#### Parameters:
|
||||
1. `table` object
|
||||
|
||||
#### Returns:
|
||||
1. `animation` Animation in use
|
||||
|
||||
#### Usage:
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton()
|
||||
local aAnimation = mainFrame:addAnimation():setObject(testButton)
|
||||
```
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton("buttonToAnimate")
|
||||
```
|
||||
```xml
|
||||
<animation object="buttonToAnimate" />
|
||||
```
|
||||
|
||||
## move
|
||||
Moves the object which got defined by setObject
|
||||
|
||||
#### Parameters:
|
||||
1. `number` x coordinate
|
||||
2. `number` y coordinate
|
||||
3. `number` duration in seconds
|
||||
4. `number` time - time when this part should begin (offset to when the animation starts - default 0)
|
||||
5. `table` object - optional, you could also define the object here
|
||||
|
||||
#### Returns:
|
||||
1. `animation` Animation in use
|
||||
|
||||
#### Usage:
|
||||
* Takes 2 seconds to move the object from its current position to x15 y3
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton("buttonToAnimate")
|
||||
local aAnimation = mainFrame:addAnimation():setObject(testButton):move(15,3,2):play()
|
||||
```
|
||||
```xml
|
||||
<animation object="buttonToAnimate" play="true">
|
||||
<move><x>15</x><y>6</y><duration>2</duration></move>
|
||||
</animation>
|
||||
```
|
||||
|
||||
## offset
|
||||
Changes the offset on the object which got defined by setObject
|
||||
|
||||
#### Parameters:
|
||||
1. `number` x offset
|
||||
2. `number` y offset
|
||||
3. `number` duration in seconds
|
||||
4. `number` time - time when this part should begin (offset to when the animation starts - default 0)
|
||||
5. `table` object - optional, you could also define the object here
|
||||
|
||||
#### Returns:
|
||||
1. `animation` Animation in use
|
||||
|
||||
#### Usage:
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local subFrame = mainFrame:addFrame("frameToAnimate")
|
||||
local aAnimation = mainFrame:addAnimation():setObject(subFrame):offset(1,12,1):play()
|
||||
```
|
||||
```xml
|
||||
<animation object="frameToAnimate" play="true">
|
||||
<offset><x>1</x><y>12</y><duration>1</duration></offset>
|
||||
</animation>
|
||||
```
|
||||
|
||||
## size
|
||||
Changes the size on the object which got defined by setObject
|
||||
|
||||
#### Parameters:
|
||||
1. `number` width
|
||||
2. `number` height
|
||||
3. `number` duration in seconds
|
||||
4. `number` time - time when this part should begin (offset to when the animation starts - default 0)
|
||||
5. `table` object - optional, you could also define the object here
|
||||
|
||||
#### Returns:
|
||||
1. `animation` Animation in use
|
||||
|
||||
#### Usage:
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton("buttonToAnimate")
|
||||
local aAnimation = mainFrame:addAnimation():setObject(testButton):size(15,3,1):play()
|
||||
```
|
||||
```xml
|
||||
<animation object="buttonToAnimate" play="true">
|
||||
<offset><w>15</w><h>3</h><duration>1</duration></offset>
|
||||
</animation>
|
||||
```
|
||||
|
||||
## changeText
|
||||
Changes the text while animation is running
|
||||
|
||||
#### Parameters:
|
||||
1. `table` multiple text strings - example: {"i", "am", "groot"}
|
||||
2. `number` duration in seconds
|
||||
3. `number` time - time when this part should begin (offset to when the animation starts - default 0)
|
||||
|
||||
#### Returns:
|
||||
1. `animation` Animation in use
|
||||
|
||||
#### Usage:
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton("buttonToAnimate")
|
||||
local aAnimation = mainFrame:addAnimation():setObject(testButton):changeText({"i", "am", "groot"}, 2):play()
|
||||
```
|
||||
```xml
|
||||
<animation object="buttonToAnimate" play="true">
|
||||
<text>
|
||||
<text>i</text>
|
||||
<text>am</text>
|
||||
<text>groot</text>
|
||||
<duration>2</duration>
|
||||
</text>
|
||||
</animation>
|
||||
```
|
||||
|
||||
## changeTextColor
|
||||
Changes the text color while the animation is running
|
||||
|
||||
#### Parameters:
|
||||
1. `table` multiple color numbers - example: {colors.red, colors.yellow, colors.green}
|
||||
2. `number` duration in seconds
|
||||
3. `number` time - time when this part should begin (offset to when the animation starts - default 0)
|
||||
|
||||
#### Returns:
|
||||
1. `animation` Animation in use
|
||||
|
||||
#### Usage:
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton("buttonToAnimate")
|
||||
local aAnimation = mainFrame:addAnimation():setObject(testButton):changeTextColor({colors.red, colors.yellow, colors.green}, 2):play()
|
||||
```
|
||||
```xml
|
||||
<animation object="buttonToAnimate" play="true">
|
||||
<textColor>
|
||||
<color>red</color>
|
||||
<color>yellow</color>
|
||||
<color>green</color>
|
||||
<duration>2</duration>
|
||||
</textColor>
|
||||
</animation>
|
||||
```
|
||||
|
||||
## changeBackground
|
||||
Changes the background color while the animation is running
|
||||
|
||||
#### Parameters:
|
||||
1. `table` multiple color numbers - example: {colors.red, colors.yellow, colors.green}
|
||||
2. `number` duration in seconds
|
||||
3. `number` time - time when this part should begin (offset to when the animation starts - default 0)
|
||||
|
||||
#### Returns:
|
||||
1. `animation` Animation in use
|
||||
|
||||
#### Usage:
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton("buttonToAnimate")
|
||||
local aAnimation = mainFrame:addAnimation():setObject(testButton):changeTextColor({colors.red, colors.yellow, colors.green}, 2):play()
|
||||
```
|
||||
```xml
|
||||
<animation object="buttonToAnimate" play="true">
|
||||
<background>
|
||||
<color>red</color>
|
||||
<color>yellow</color>
|
||||
<color>green</color>
|
||||
<duration>2</duration>
|
||||
</background>
|
||||
</animation>
|
||||
```
|
||||
| | |
|
||||
|---|---|
|
||||
|[add](objects/Animation/add.md)|Adds a new custom function to call at the current time
|
||||
|[wait](objects/Animation/wait.md)|Adds a amount to the animation time
|
||||
|[play](objects/Animation/play.md)|Plays the animation
|
||||
|[cancel](objects/Animation/cancel.md)|Cancels the animation
|
||||
|[addMode](objects/Animation/addMode.md)|Adds custom easings
|
||||
|[setMode](objects/Animation/setMode.md)|Changes the current easing-calculation
|
||||
|[setObject](objects/Animation/setObject.md)|Sets an object on which predefined animations should work on
|
||||
|[move](objects/Animation/move.md)|Predefined animation: moves the object to a new position
|
||||
|[offset](objects/Animation/offset.md)|Predefined animation: Changes the offset of that object
|
||||
|[size](objects/Animation/size.md)|Predefined animation: Changes the size on a object
|
||||
|[changeText](objects/Animation/changeText.md)|Predefined animation: Changes the text (object needs a setText method)
|
||||
|[changeTextColor](objects/Animation/changeTextColor.md)|Predefined animation: changes the foreground/textcolor on a object
|
||||
|[changeBackground](objects/Animation/changeBackground.md)|Predefined animation: changes the background on a object
|
||||
|
||||
# Events
|
||||
|
||||
## onDone
|
||||
`onDone(self)`<br>
|
||||
This is a event which gets fired as soon as the animation has finished.
|
||||
|
||||
```lua
|
||||
local basalt = require("Basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton("buttonToAnimate")
|
||||
local aAnimation = mainFrame:addAnimation():setObject(testButton):changeTextColor({colors.red, colors.yellow, colors.green}, 2):play()
|
||||
aAnimation:onDone(function()
|
||||
basalt.debug("The animation is done")
|
||||
end)
|
||||
```
|
||||
|
||||
In XML you are also able to queue multiple animations, like this:
|
||||
|
||||
```xml
|
||||
<animation id="anim2" object="buttonToAnimate">
|
||||
<textColor>
|
||||
<color>red</color>
|
||||
<color>yellow</color>
|
||||
<color>green</color>
|
||||
<duration>2</duration>
|
||||
</textColor>
|
||||
</animation>
|
||||
<animation onDone="#anim2" object="buttonToAnimate" play="true">
|
||||
<background>
|
||||
<color>red</color>
|
||||
<color>yellow</color>
|
||||
<color>green</color>
|
||||
<duration>2</duration>
|
||||
</background>
|
||||
</animation>
|
||||
```
|
||||
| | |
|
||||
|---|---|
|
||||
|[onStart](objects/Animation/onStart.md)|Gets called as soon as the animation is started
|
||||
|[onDone](objects/Animation/onDone.md)|Gets called as soon as the animation has finished
|
||||
|
||||
17
docs/docs1_6/objects/Animation/add.md
Normal file
17
docs/docs1_6/objects/Animation/add.md
Normal file
@@ -0,0 +1,17 @@
|
||||
## add
|
||||
Adds a new function to an animation
|
||||
#### Parameters:
|
||||
1. `function` The function containing animation logic
|
||||
|
||||
#### Returns:
|
||||
1. `animation` Animation in use
|
||||
|
||||
|
||||
#### Usage:
|
||||
* This will set the button position to 3,3, waits 1 second, then sets position to 4,4, waits 2 seconds, and then sets the position to 5,5
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton()
|
||||
local aAnimation = mainFrame:addAnimation():add(function() testButton:setPosition(3,3) end):wait(1):add(function() testButton:setPosition(1,1,"r") end):wait(2):add(function() testButton:setPosition(1,1,"r") end)
|
||||
aAnimation:play()
|
||||
```
|
||||
30
docs/docs1_6/objects/Animation/addMode.md
Normal file
30
docs/docs1_6/objects/Animation/addMode.md
Normal file
@@ -0,0 +1,30 @@
|
||||
## addMode
|
||||
Adds a new easing curve into the available easing list. Checkout the animation object if you want to know how this works.
|
||||
|
||||
#### Parameters:
|
||||
|
||||
1. `string` - The name of the curve you want to use.
|
||||
2. `functon` - The function to call
|
||||
|
||||
#### Returns:
|
||||
|
||||
1. `animation` Animation in use
|
||||
|
||||
#### Usage:
|
||||
|
||||
* Creates a new curve
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton("buttonToAnimate")
|
||||
local aAnimation = mainFrame:addAnimation():setObject(testButton)
|
||||
|
||||
local function easeInBack(t) -- t is the time from 0 to 1
|
||||
local c1 = 1.70158;
|
||||
local c3 = c1 + 1
|
||||
return c3*t^3-c1*t^2
|
||||
end
|
||||
|
||||
aAnimation:addMode("coolEaseInBack", easeInBack)
|
||||
aAnimation:setMode("coolEaseInBack"):move(15,3,2):play()
|
||||
```
|
||||
15
docs/docs1_6/objects/Animation/cancel.md
Normal file
15
docs/docs1_6/objects/Animation/cancel.md
Normal file
@@ -0,0 +1,15 @@
|
||||
## cancel
|
||||
Cancels the animation
|
||||
|
||||
#### Returns:
|
||||
1. `animation` Animation in use
|
||||
|
||||
#### Usage:
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton()
|
||||
local aAnimation = mainFrame:addAnimation():add(function() testButton:setBackground(colors.black) end):wait(1):add(function() aAnimation:cancel() end):wait(1):add(function() testButton:setBackground(colors.lightGray) end)
|
||||
|
||||
aAnimation:play()
|
||||
```
|
||||
28
docs/docs1_6/objects/Animation/changeBackground.md
Normal file
28
docs/docs1_6/objects/Animation/changeBackground.md
Normal file
@@ -0,0 +1,28 @@
|
||||
## changeBackground
|
||||
Changes the background color while the animation is running
|
||||
|
||||
#### Parameters:
|
||||
1. `number` duration in seconds
|
||||
2. `number` time - time when this part should begin (offset to when the animation starts - default 0)
|
||||
3. `...` multiple color numbers - example: colors.red, colors.yellow, colors.green
|
||||
|
||||
#### Returns:
|
||||
1. `animation` Animation in use
|
||||
|
||||
#### Usage:
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton("buttonToAnimate")
|
||||
local aAnimation = mainFrame:addAnimation():setObject(testButton):changeTextColor(2, 0, colors.red, colors.yellow, colors.green):play()
|
||||
```
|
||||
```xml
|
||||
<animation object="buttonToAnimate" play="true">
|
||||
<background>
|
||||
<color>red</color>
|
||||
<color>yellow</color>
|
||||
<color>green</color>
|
||||
<duration>2</duration>
|
||||
</background>
|
||||
</animation>
|
||||
```
|
||||
30
docs/docs1_6/objects/Animation/changeText.md
Normal file
30
docs/docs1_6/objects/Animation/changeText.md
Normal file
@@ -0,0 +1,30 @@
|
||||
## changeText
|
||||
Changes the text while animation is running
|
||||
|
||||
#### Parameters:
|
||||
1. `table` multiple text strings - example: {"i", "am", "groot"}
|
||||
1. `number` duration in seconds
|
||||
2. `number` time - time when this part should begin (offset to when the animation starts - default 0)
|
||||
3. `...` multiple text strings - example: "i", "am", "groot"
|
||||
|
||||
|
||||
#### Returns:
|
||||
1. `animation` Animation in use
|
||||
|
||||
#### Usage:
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton("buttonToAnimate")
|
||||
local aAnimation = mainFrame:addAnimation():setObject(testButton):changeText(2, 0, "i", "am", "groot"):play()
|
||||
```
|
||||
```xml
|
||||
<animation object="buttonToAnimate" play="true">
|
||||
<text>
|
||||
<text>i</text>
|
||||
<text>am</text>
|
||||
<text>groot</text>
|
||||
<duration>2</duration>
|
||||
</text>
|
||||
</animation>
|
||||
```
|
||||
28
docs/docs1_6/objects/Animation/changeTextColor.md
Normal file
28
docs/docs1_6/objects/Animation/changeTextColor.md
Normal file
@@ -0,0 +1,28 @@
|
||||
## changeTextColor
|
||||
Changes the text color while the animation is running
|
||||
|
||||
#### Parameters:
|
||||
1. `number` duration in seconds
|
||||
2. `number` time - time when this part should begin (offset to when the animation starts - default 0)
|
||||
1. `...` multiple color numbers - example: colors.red, colors.yellow, colors.green
|
||||
|
||||
#### Returns:
|
||||
1. `animation` Animation in use
|
||||
|
||||
#### Usage:
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton("buttonToAnimate")
|
||||
local aAnimation = mainFrame:addAnimation():setObject(testButton):changeTextColor(2, 0, colors.red, colors.yellow, colors.green):play()
|
||||
```
|
||||
```xml
|
||||
<animation object="buttonToAnimate" play="true">
|
||||
<textColor>
|
||||
<color>red</color>
|
||||
<color>yellow</color>
|
||||
<color>green</color>
|
||||
<duration>2</duration>
|
||||
</textColor>
|
||||
</animation>
|
||||
```
|
||||
25
docs/docs1_6/objects/Animation/move.md
Normal file
25
docs/docs1_6/objects/Animation/move.md
Normal file
@@ -0,0 +1,25 @@
|
||||
## move
|
||||
Moves the object which got defined by setObject
|
||||
|
||||
#### Parameters:
|
||||
1. `number` x coordinate
|
||||
2. `number` y coordinate
|
||||
3. `number` duration in seconds
|
||||
4. `number` time - time when this part should begin (offset to when the animation starts - default 0)
|
||||
5. `table` object - optional, you could also define the object here
|
||||
|
||||
#### Returns:
|
||||
1. `animation` Animation in use
|
||||
|
||||
#### Usage:
|
||||
* Takes 2 seconds to move the object from its current position to x15 y3
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton("buttonToAnimate")
|
||||
local aAnimation = mainFrame:addAnimation():setObject(testButton):move(15,3,2):play()
|
||||
```
|
||||
```xml
|
||||
<animation object="buttonToAnimate" play="true">
|
||||
<move><x>15</x><y>6</y><duration>2</duration></move>
|
||||
</animation>
|
||||
```
|
||||
25
docs/docs1_6/objects/Animation/offset.md
Normal file
25
docs/docs1_6/objects/Animation/offset.md
Normal file
@@ -0,0 +1,25 @@
|
||||
## offset
|
||||
Changes the offset on the object which got defined by setObject
|
||||
|
||||
#### Parameters:
|
||||
1. `number` x offset
|
||||
2. `number` y offset
|
||||
3. `number` duration in seconds
|
||||
4. `number` time - time when this part should begin (offset to when the animation starts - default 0)
|
||||
5. `table` object - optional, you could also define the object here
|
||||
|
||||
#### Returns:
|
||||
1. `animation` Animation in use
|
||||
|
||||
#### Usage:
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local subFrame = mainFrame:addFrame("frameToAnimate")
|
||||
local aAnimation = mainFrame:addAnimation():setObject(subFrame):offset(1,12,1):play()
|
||||
```
|
||||
```xml
|
||||
<animation object="frameToAnimate" play="true">
|
||||
<offset><x>1</x><y>12</y><duration>1</duration></offset>
|
||||
</animation>
|
||||
```
|
||||
35
docs/docs1_6/objects/Animation/onDone.md
Normal file
35
docs/docs1_6/objects/Animation/onDone.md
Normal file
@@ -0,0 +1,35 @@
|
||||
## onDone
|
||||
`onDone(self)`<br>
|
||||
This is a event which gets fired as soon as the animation has finished.
|
||||
|
||||
```lua
|
||||
local basalt = require("Basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton("buttonToAnimate")
|
||||
local aAnimation = mainFrame:addAnimation():setObject(testButton):changeTextColor({colors.red, colors.yellow, colors.green}, 2):play()
|
||||
aAnimation:onDone(function()
|
||||
basalt.debug("The animation is done")
|
||||
end)
|
||||
```
|
||||
|
||||
In XML you are also able to queue multiple animations, like this:
|
||||
|
||||
```xml
|
||||
<animation id="anim2" object="buttonToAnimate">
|
||||
<textColor>
|
||||
<color>red</color>
|
||||
<color>yellow</color>
|
||||
<color>green</color>
|
||||
<duration>2</duration>
|
||||
</textColor>
|
||||
</animation>
|
||||
<animation onDone="#anim2" object="buttonToAnimate" play="true">
|
||||
<background>
|
||||
<color>red</color>
|
||||
<color>yellow</color>
|
||||
<color>green</color>
|
||||
<duration>2</duration>
|
||||
</background>
|
||||
</animation>
|
||||
```
|
||||
16
docs/docs1_6/objects/Animation/onStart.md
Normal file
16
docs/docs1_6/objects/Animation/onStart.md
Normal file
@@ -0,0 +1,16 @@
|
||||
## onStart
|
||||
`onStart(self)`<br>
|
||||
This is a event which gets fired as soon as the animation is started.
|
||||
|
||||
```lua
|
||||
local basalt = require("Basalt")
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton("buttonToAnimate")
|
||||
local aAnimation = mainFrame:addAnimation():setObject(testButton):changeTextColor({colors.red, colors.yellow, colors.green}, 2)
|
||||
aAnimation:onStart(function()
|
||||
basalt.debug("The animation is started")
|
||||
end)
|
||||
|
||||
aAnimation:play()
|
||||
```
|
||||
16
docs/docs1_6/objects/Animation/play.md
Normal file
16
docs/docs1_6/objects/Animation/play.md
Normal file
@@ -0,0 +1,16 @@
|
||||
## play
|
||||
Plays the animation
|
||||
#### Parameters:
|
||||
1. `boolean` Whether it will loop forever, will most likely be replaced with a count in the future
|
||||
|
||||
#### Returns:
|
||||
1. `animation` Animation in use
|
||||
|
||||
#### Usage:
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton()
|
||||
local aAnimation = mainFrame:addAnimation():add(function() testButton:setBackground(colors.black) end):wait(1):add(function() testButton:setBackground(colors.gray) end):wait(1):add(function() testButton:setBackground(colors.lightGray) end)
|
||||
|
||||
aAnimation:play() -- changes the background color of that button from black to gray and then to lightGray
|
||||
```
|
||||
36
docs/docs1_6/objects/Animation/setMode.md
Normal file
36
docs/docs1_6/objects/Animation/setMode.md
Normal file
@@ -0,0 +1,36 @@
|
||||
## setMode
|
||||
Changes the easing curve. If you want to test them, here is a interesting website: https://easings.co
|
||||
|
||||
#### Parameters:
|
||||
1. `string` - The name of the curve you want to use.
|
||||
|
||||
#### Returns:
|
||||
1. `animation` Animation in use
|
||||
|
||||
#### Usage:
|
||||
* Takes 2 seconds to move the object from its current position to x15 y3
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton("buttonToAnimate")
|
||||
local aAnimation = mainFrame:addAnimation():setObject(testButton):setMode("easeInBounce"):move(15,3,2):play()
|
||||
```
|
||||
|
||||
## Easing Curve List
|
||||
|
||||
Here is a list of all available easing curves:
|
||||
|
||||
| | | |
|
||||
|---|---|---|
|
||||
|linear||
|
||||
|easIn|easeOut|easeInOut
|
||||
|easeInSine|easeOutSine|easeInOutSine
|
||||
|easeInBack|easeOutBack|easeInOutBack
|
||||
|easeInCubic|easeOutCubic|easeInOutCubic
|
||||
|easeInElastic|easeOutElastic|easeInOutElastic
|
||||
|easeInExpo|easeOutExpo|easeInOutExpo
|
||||
|easeInBack|easeOutBack|easeInOutBack
|
||||
|easeInQuad|easeOutQuad|easeInOutQuad
|
||||
|easeInQuint|easeOutQuint|easeInOutQuint
|
||||
|easeInQuart|easeOutQuart|easeInOutQuart
|
||||
|easeInCirc|easeOutCirc|easeInOutCirc
|
||||
|easeInBounce|easeOutBounce|easeInOutBounce
|
||||
24
docs/docs1_6/objects/Animation/setObject.md
Normal file
24
docs/docs1_6/objects/Animation/setObject.md
Normal file
@@ -0,0 +1,24 @@
|
||||
## setObject
|
||||
Sets the object which the animation should reposition/resize
|
||||
|
||||
#### Parameters:
|
||||
1. `table` object
|
||||
|
||||
#### Returns:
|
||||
1. `animation` Animation in use
|
||||
|
||||
#### Usage:
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton()
|
||||
local aAnimation = mainFrame:addAnimation():setObject(testButton)
|
||||
```
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton("buttonToAnimate")
|
||||
```
|
||||
```xml
|
||||
<animation object="buttonToAnimate" />
|
||||
```
|
||||
24
docs/docs1_6/objects/Animation/size.md
Normal file
24
docs/docs1_6/objects/Animation/size.md
Normal file
@@ -0,0 +1,24 @@
|
||||
## size
|
||||
Changes the size on the object which got defined by setObject
|
||||
|
||||
#### Parameters:
|
||||
1. `number` width
|
||||
2. `number` height
|
||||
3. `number` duration in seconds
|
||||
4. `number` time - time when this part should begin (offset to when the animation starts - default 0)
|
||||
5. `table` object - optional, you could also define the object here
|
||||
|
||||
#### Returns:
|
||||
1. `animation` Animation in use
|
||||
|
||||
#### Usage:
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton("buttonToAnimate")
|
||||
local aAnimation = mainFrame:addAnimation():setObject(testButton):size(15,3,1):play()
|
||||
```
|
||||
```xml
|
||||
<animation object="buttonToAnimate" play="true">
|
||||
<offset><w>15</w><h>3</h><duration>1</duration></offset>
|
||||
</animation>
|
||||
```
|
||||
16
docs/docs1_6/objects/Animation/wait.md
Normal file
16
docs/docs1_6/objects/Animation/wait.md
Normal file
@@ -0,0 +1,16 @@
|
||||
## wait
|
||||
Sets a wait timer for the next function after the previous function got executed, no wait timer calls the next function immediately
|
||||
#### Parameters:
|
||||
1. `number` The length of delay between the functions _(in seconds)_
|
||||
|
||||
#### Returns:
|
||||
1. `animation` Animation in use
|
||||
|
||||
#### Usage:
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local testButton = mainFrame:addButton()
|
||||
local aAnimation = mainFrame:addAnimation():add(function() testButton:setPosition(3,3) end):wait(1):add(function() testButton:setPosition(1,1,"r") end):wait(2):add(function() testButton:setPosition(1,1,"r") end)
|
||||
|
||||
aAnimation:play()
|
||||
```
|
||||
@@ -1,201 +1,48 @@
|
||||
# Basalt
|
||||
|
||||
This is the UI Manager and the first thing you want to access.
|
||||
Before you can access Basalt, you need to add the following code on top of your file:
|
||||
|
||||
`local basalt = require("Basalt")`
|
||||
|
||||
Now you are able to access the following methods:
|
||||
|
||||
## basalt.createFrame
|
||||
Create a base-frame (main frame)
|
||||
#### Parameters:
|
||||
1. `string` name
|
||||
|
||||
#### Returns:
|
||||
1. `frame` object
|
||||
|
||||
#### Usage:
|
||||
* Create and show a frame with id "myFirstFrame"
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame("myFirstFrame")
|
||||
local basalt = require("basalt")
|
||||
```
|
||||
|
||||
## basalt.removeFrame
|
||||
Removes a base frame
|
||||
What this code does is it loads basalt into the basalt variable.
|
||||
You are now able to access the following list of methods:
|
||||
|
||||
#### Parameters:
|
||||
1. `string` name
|
||||
| | |
|
||||
|---|---|
|
||||
|[autoUpdate](objects/Basalt/autoUpdate.md)|Starts the event and draw listener
|
||||
|[createFrame](objects/Basalt/createFrame.md)|Creates a new base frame
|
||||
|[debug](objects/Basalt/debug.md)|Writes something into the debug console
|
||||
|[getFrame](objects/Basalt/getFrame.md)|Returns a frame object by it's id
|
||||
|[getActiveFrame](objects/Basalt/getActiveFrame.md)|Returns the currently active base frame
|
||||
|[getTheme](objects/Basalt/getTheme.md)|Returns the currently active theme
|
||||
|[getVariable](objects/Basalt/getVariable.md)|Returns a variable defined with setVariable
|
||||
|[getVersion](objects/Basalt/getVersion.md)|Returns the Basalt version
|
||||
|[isKeyDown](objects/Basalt/isKeyDown.md)|Returns if the key is held down
|
||||
|[log](objects/Basalt/log.md)|Writes something into the log file
|
||||
|[onEvent](objects/Basalt/onEvent.md)|Event listener
|
||||
|[removeFrame](objects/Basalt/removeFrame.md)|Removes a previously created base frame
|
||||
|[schedule](objects/Basalt/schedule.md)|Schedules a new task
|
||||
|[setActiveFrame](objects/Basalt/setActiveFrame.md)|Sets the active frame
|
||||
|[setTheme](objects/Basalt/setTheme.md)|Changes the base theme of basalt
|
||||
|[setMouseDragThrottle](objects/Basalt/setMouseDragThrottle.md)|Changes the mouse drag throttle amount
|
||||
|[setMouseMoveThrottle](objects/Basalt/setMouseMoveThrottle.md)|CraftOS-PC: Changes the mouse move throttle amount
|
||||
|[setVariable](objects/Basalt/setVariable.md)|Sets a variable which you can access via XML
|
||||
|[stopUpdate / stop](objects/Basalt/stopUpdate.md)|Stops the currently active event and draw listener
|
||||
|[update](objects/Basalt/update.md)|Starts the event and draw listener once
|
||||
|
||||
## Examples
|
||||
|
||||
Here is a lua example on how to create a empty base frame and start basalt's listener.
|
||||
|
||||
#### Usage:
|
||||
* Removes the previously created frame with id "myFirstFrame"
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame("myFirstFrame")
|
||||
basalt.removeFrame("myFirstFrame")
|
||||
```
|
||||
|
||||
## basalt.getFrame
|
||||
Returns a base frame with the given name
|
||||
#### Parameters:
|
||||
1. `string` name
|
||||
|
||||
#### Returns:
|
||||
1. `frame` object
|
||||
|
||||
#### Usage:
|
||||
* Creates, fetches and shows the "myFirstFrame" object
|
||||
```lua
|
||||
basalt.createFrame("myFirstFrame"):hide()
|
||||
basalt.getFrame("myFirstFrame"):show()
|
||||
```
|
||||
|
||||
## basalt.getActiveFrame
|
||||
Returns the currently active base frame
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The current frame
|
||||
|
||||
#### Usage:
|
||||
* Displays the active frame name in the debug console
|
||||
```lua
|
||||
basalt.createFrame()
|
||||
basalt.debug(basalt.getActiveFrame():getName()) -- returns the uuid
|
||||
```
|
||||
|
||||
## basalt.autoUpdate
|
||||
Starts the draw and event handler until basalt.stopUpdate() is called
|
||||
|
||||
#### Usage:
|
||||
* Enable the basalt updates, otherwise the screen will not continue to update
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
|
||||
## 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.
|
||||
|
||||
#### Parameters:
|
||||
1. `string` The event to be received
|
||||
2. `...` Additional event variables to capture
|
||||
|
||||
#### Usage:
|
||||
* Creates and starts a custom update cycle
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aButton = mainFrame:addButton():setPosition(2,2)
|
||||
while true do
|
||||
basalt.update(os.pullEventRaw())
|
||||
end
|
||||
```
|
||||
|
||||
## basalt.stopUpdate
|
||||
Stops the automatic draw and event handler which got started by basalt.autoUpdate()
|
||||
|
||||
#### Usage:
|
||||
* When the quit button is clicked, the button stops basalt auto updates
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aButton = mainFrame:addButton():setPosition(2,2):setText("Stop Basalt!")
|
||||
aButton:onClick(function()
|
||||
basalt.stopUpdate()
|
||||
end)
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
|
||||
## basalt.isKeyDown
|
||||
Checks if the user is currently holding a key
|
||||
|
||||
#### Parameters:
|
||||
1. `number` key code (use the keys table for that)
|
||||
|
||||
#### Returns:
|
||||
1. `boolean` true or false
|
||||
|
||||
#### Usage:
|
||||
* Shows a debug message with true or false if the left ctrl key is down, as soon as you click on the button.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aButton = mainFrame:addButton():setPosition(2,2):setText("Check Ctrl")
|
||||
aButton:onClick(function()
|
||||
basalt.debug(basalt.isKeyDown(keys.leftCtrl))
|
||||
end)
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
|
||||
## basalt.debug
|
||||
creates a label with some information on the main frame on the bottom left, if you click on that label it will open a log view for you. See 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.
|
||||
|
||||
Also basalt.debugFrame and basalt.debugList are available.
|
||||
|
||||
#### Parameters:
|
||||
1. `...` (multiple parameters are possible, like print does)
|
||||
|
||||
#### Usage:
|
||||
* Prints "Hello! ^-^" to the debug console
|
||||
```lua
|
||||
basalt.debug("Hello! ", "^-^")
|
||||
```
|
||||
|
||||
## 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)
|
||||
|
||||
#### Parameters:
|
||||
1. `table` theme layout look into [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua) for a example
|
||||
|
||||
#### Usage:
|
||||
* Sets the default theme of basalt.
|
||||
```lua
|
||||
basalt.setTheme({
|
||||
ButtonBG = colors.yellow,
|
||||
ButtonText = colors.red,
|
||||
...,
|
||||
})
|
||||
```
|
||||
|
||||
## 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.
|
||||
|
||||
#### Parameters:
|
||||
1. `string` a key name
|
||||
1. `any` any variable
|
||||
|
||||
#### Usage:
|
||||
* Adds a function to basalt.
|
||||
```lua
|
||||
basalt.setVariable("clickMe", function()
|
||||
basalt.debug("I got clicked")
|
||||
end)
|
||||
```
|
||||
```xml
|
||||
<button onClick="clickMe" text="Click me" />
|
||||
```
|
||||
|
||||
## basalt.schedule
|
||||
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.
|
||||
|
||||
#### Parameters:
|
||||
1. `function` a function which should get executed
|
||||
|
||||
#### Returns:
|
||||
1. `function` it returns the function which you have to execute in order to start the coroutine
|
||||
|
||||
#### Usage:
|
||||
* Creates a schedule which switches the color between red and gray
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aButton = mainFrame:addButton():setText("Click me")
|
||||
aButton:onClick(basalt.schedule(function(self)
|
||||
self:setBackground(colors.red)
|
||||
os.sleep(0.1)
|
||||
self:setBackground(colors.gray)
|
||||
os.sleep(0.1)
|
||||
self:setBackground(colors.red)
|
||||
os.sleep(0.1)
|
||||
self:setBackground(colors.gray)
|
||||
os.sleep(0.1)
|
||||
self:setBackground(colors.red)
|
||||
os.sleep(0.1)
|
||||
self:setBackground(colors.gray)
|
||||
end))
|
||||
local basalt = require("basalt") -- Loads Basalt into our project
|
||||
|
||||
local main = basalt.createFrame() -- Creates a base frame. On that frame we are able to add object's
|
||||
|
||||
-- Here we would add additional object's
|
||||
|
||||
basalt.autoUpdate() -- Starts listening to incoming events and draw stuff on the screen. This should nearly always be the last line.
|
||||
```
|
||||
|
||||
18
docs/docs1_6/objects/Basalt/autoUpdate.md
Normal file
18
docs/docs1_6/objects/Basalt/autoUpdate.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Basalt
|
||||
|
||||
## autoUpdate
|
||||
|
||||
This starts the event and draw handler for you. The listeners will run until you stop them.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `boolean` optional - if you use false as the first parameter it would stop the listeners. Using false is a synonym for [`basalt.stopUpdate()`](objects/Basalt/stopUpdate.md).
|
||||
|
||||
### Usage
|
||||
|
||||
* Enables the basalt listeners, otherwise the screen will not continue to update
|
||||
|
||||
```lua
|
||||
local main = basalt.createFrame()
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
35
docs/docs1_6/objects/Basalt/createFrame.md
Normal file
35
docs/docs1_6/objects/Basalt/createFrame.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# 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.
|
||||
|
||||
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)
|
||||
|
||||
### Returns
|
||||
|
||||
1. `frame` object
|
||||
|
||||
### Usage
|
||||
|
||||
* How to use multiple base frames:
|
||||
|
||||
```lua
|
||||
local main1 = basalt.createFrame() -- Visible base frame on program start
|
||||
local main2 = basalt.createFrame()
|
||||
local main3 = basalt.createFrame()
|
||||
main1:addButton()
|
||||
:setPosition(2,2)
|
||||
:setText("Switch")
|
||||
:onClick(function()
|
||||
main2:show() -- this function automatically "hides" the first one and shows the second one
|
||||
end)
|
||||
main2:addLabel()
|
||||
:setText("We are currently on main2")
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
29
docs/docs1_6/objects/Basalt/debug.md
Normal file
29
docs/docs1_6/objects/Basalt/debug.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# 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
|
||||
|
||||
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.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `...` (multiple parameters are possible, like print does)
|
||||
|
||||
### Usage
|
||||
|
||||
* Prints "Hello! ^-^" to the debug console
|
||||
|
||||
```lua
|
||||
basalt.debug("Hello! ", "^-^")
|
||||
```
|
||||
|
||||
* Changes the debug label's anchor
|
||||
|
||||
```lua
|
||||
basalt.debugLabel:setAnchor("topLeft") -- default anchor is bottomLeft
|
||||
basalt.debug("Hello!")
|
||||
```
|
||||
18
docs/docs1_6/objects/Basalt/getActiveFrame.md
Normal file
18
docs/docs1_6/objects/Basalt/getActiveFrame.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Basalt
|
||||
|
||||
## getActiveFrame
|
||||
|
||||
Returns the currently active/visible base frame.
|
||||
|
||||
### Returns
|
||||
|
||||
1. `frame` The current frame
|
||||
|
||||
### Usage
|
||||
|
||||
* Displays the active frame name in the debug console
|
||||
|
||||
```lua
|
||||
local main = basalt.createFrame()
|
||||
basalt.debug(basalt.getActiveFrame():getName()) -- returns the id
|
||||
```
|
||||
31
docs/docs1_6/objects/Basalt/getFrame.md
Normal file
31
docs/docs1_6/objects/Basalt/getFrame.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# Basalt
|
||||
|
||||
## getFrame
|
||||
|
||||
Returns a base frame by the given id.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `string` id
|
||||
|
||||
### Returns
|
||||
|
||||
1. `frame` The frame with the supplied id.
|
||||
|
||||
### Usage
|
||||
|
||||
* Creates, fetches and shows the "myFirstFrame" object
|
||||
|
||||
```lua
|
||||
local main = basalt.createFrame("firstBaseFrame")
|
||||
local main2 = basalt.createFrame("secondBaseFrame")
|
||||
main:addButton()
|
||||
:setText("Show")
|
||||
:onClick(function()
|
||||
local frame2 = basalt.getFrame("secondBaseFrame")
|
||||
if(frame2 ~= nil)then
|
||||
frame2:show()
|
||||
end
|
||||
end)
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
18
docs/docs1_6/objects/Basalt/getTheme.md
Normal file
18
docs/docs1_6/objects/Basalt/getTheme.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Basalt
|
||||
|
||||
## basalt.getTheme
|
||||
|
||||
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
|
||||
|
||||
1. `number` The color of the requested base-theme key.
|
||||
|
||||
### Usage
|
||||
|
||||
* Displays the color of the main background in the debug console
|
||||
|
||||
```lua
|
||||
basalt.debug(basalt.getTheme("BasaltBG"))
|
||||
```
|
||||
26
docs/docs1_6/objects/Basalt/getVariable.md
Normal file
26
docs/docs1_6/objects/Basalt/getVariable.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# Basalt
|
||||
|
||||
## getVariable
|
||||
|
||||
Returns a variable defined with [setVariable](objects/Basalt/setVariable)
|
||||
|
||||
### Returns
|
||||
|
||||
1. `variable` The variable stored
|
||||
|
||||
### Usage
|
||||
|
||||
* Displays the stored variable in the debug console
|
||||
|
||||
```lua
|
||||
basalt.setVariable("abc", function()
|
||||
basalt.debug("I got clicked")
|
||||
return 1
|
||||
end)
|
||||
|
||||
basalt.debug(basalt.getVariable("abc")()) -- Should debug log "I got clicked" and debug log 1 (which was returned from the function)
|
||||
```
|
||||
|
||||
```xml
|
||||
<button onClick="abc" text="Click me" />
|
||||
```
|
||||
17
docs/docs1_6/objects/Basalt/getVersion.md
Normal file
17
docs/docs1_6/objects/Basalt/getVersion.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Basalt
|
||||
|
||||
## getVersion
|
||||
|
||||
Returns the currently active/visible base frame.
|
||||
|
||||
### Returns
|
||||
|
||||
1. `string` The current version of Basalt
|
||||
|
||||
### Usage
|
||||
|
||||
* Displays the version of Basalt in the debug console
|
||||
|
||||
```lua
|
||||
basalt.debug(basalt.getVersion()) -- Example: 1.6.2
|
||||
```
|
||||
28
docs/docs1_6/objects/Basalt/isKeyDown.md
Normal file
28
docs/docs1_6/objects/Basalt/isKeyDown.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# Basalt
|
||||
|
||||
## isKeyDown
|
||||
|
||||
Checks if the user is currently holding a key
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `number` key code (use the [keys table](https://tweaked.cc/module/keys.html) for that)
|
||||
|
||||
### Returns
|
||||
|
||||
1. `boolean` true or false
|
||||
|
||||
### Usage
|
||||
|
||||
* Shows a debug message with true or false if the left ctrl key is down, as soon as you click on the button.
|
||||
|
||||
```lua
|
||||
local main = basalt.createFrame()
|
||||
local aButton = mainFrame:addButton()
|
||||
:setPosition(2,2)
|
||||
:setText("Check Ctrl")
|
||||
:onClick(function()
|
||||
basalt.debug(basalt.isKeyDown(keys.leftCtrl))
|
||||
end)
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
28
docs/docs1_6/objects/Basalt/log.md
Normal file
28
docs/docs1_6/objects/Basalt/log.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# 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.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `string` The text to write into the log file
|
||||
2. `string` - optional (default: "Debug") - the type to write
|
||||
|
||||
### Usage
|
||||
|
||||
* Writes "Hello!" into the log file
|
||||
|
||||
```lua
|
||||
basalt.log("Hello!")
|
||||
```
|
||||
|
||||
This should result in there beeing 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.
|
||||
|
||||
```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`.
|
||||
21
docs/docs1_6/objects/Basalt/onEvent.md
Normal file
21
docs/docs1_6/objects/Basalt/onEvent.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# 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.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `function` The function which should be called
|
||||
|
||||
### Usage
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
basalt.onEvent(function(event)
|
||||
if(event=="terminate")then
|
||||
return false
|
||||
end
|
||||
end)
|
||||
```
|
||||
37
docs/docs1_6/objects/Basalt/removeFrame.md
Normal file
37
docs/docs1_6/objects/Basalt/removeFrame.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# Basalt
|
||||
|
||||
## removeFrame
|
||||
|
||||
Removes the base frame by it's id. **This only works for base-frames.**
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `string` id - ID of the base-frame.
|
||||
|
||||
### Usage
|
||||
|
||||
* Removes the previously created frame with id "secondBaseFrame"
|
||||
The frame id is gotten from a frame variable's `:getName()`
|
||||
|
||||
```lua
|
||||
local main = basalt.createFrame("firstBaseFrame")
|
||||
local main2 = basalt.createFrame("secondBaseFrame")
|
||||
main:addButton()
|
||||
:setText("Remove")
|
||||
:onClick(function()
|
||||
basalt.removeFrame(main2:getName())
|
||||
end)
|
||||
```
|
||||
|
||||
* Removes the previously created frame with id "secondBaseFrame", without frame stored in variable
|
||||
The frame id is the frame's name
|
||||
|
||||
```lua
|
||||
local main = basalt.createFrame("firstBaseFrame")
|
||||
local main2 = basalt.createFrame("secondBaseFrame")
|
||||
main:addButton()
|
||||
:setText("Remove")
|
||||
:onClick(function()
|
||||
basalt.removeFrame("secondBaseFrame")
|
||||
end)
|
||||
```
|
||||
36
docs/docs1_6/objects/Basalt/schedule.md
Normal file
36
docs/docs1_6/objects/Basalt/schedule.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# Basalt
|
||||
|
||||
## schedule
|
||||
|
||||
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).**
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `function` a function which should get executed
|
||||
|
||||
### Returns
|
||||
|
||||
1. `function` it returns the function which you have to execute in order to start the coroutine
|
||||
|
||||
### Usage
|
||||
|
||||
* Creates a schedule which switches the color between red and gray
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aButton = mainFrame:addButton():setText("Click me")
|
||||
aButton:onClick(basalt.schedule(function(self)
|
||||
self:setBackground(colors.red)
|
||||
os.sleep(0.1)
|
||||
self:setBackground(colors.gray)
|
||||
os.sleep(0.1)
|
||||
self:setBackground(colors.red)
|
||||
os.sleep(0.1)
|
||||
self:setBackground(colors.gray)
|
||||
os.sleep(0.1)
|
||||
self:setBackground(colors.red)
|
||||
os.sleep(0.1)
|
||||
self:setBackground(colors.gray)
|
||||
end))
|
||||
```
|
||||
13
docs/docs1_6/objects/Basalt/setActiveFrame.md
Normal file
13
docs/docs1_6/objects/Basalt/setActiveFrame.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# Basalt
|
||||
|
||||
## setActiveFrame
|
||||
|
||||
Sets what should be the active baseframe.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `frame` frame - The frame that should be the active base-frame.
|
||||
|
||||
### Usage
|
||||
|
||||
TODO
|
||||
18
docs/docs1_6/objects/Basalt/setMouseDragThrottle.md
Normal file
18
docs/docs1_6/objects/Basalt/setMouseDragThrottle.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Basalt
|
||||
|
||||
## setMouseDragThrottle
|
||||
|
||||
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.
|
||||
|
||||
### Usage
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
basalt.setMouseDragThrottle(0)
|
||||
```
|
||||
20
docs/docs1_6/objects/Basalt/setMouseMoveThrottle.md
Normal file
20
docs/docs1_6/objects/Basalt/setMouseMoveThrottle.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Basalt
|
||||
|
||||
## setMouseMoveThrottle
|
||||
|
||||
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.
|
||||
|
||||
Sidenote: a very low amount can make the program laggy - because it litterally spams the mouse_move event. So use it carefully.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `number` A number in miliseconds.
|
||||
|
||||
### Usage
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
basalt.setMouseMoveThrottle(50)
|
||||
```
|
||||
21
docs/docs1_6/objects/Basalt/setTheme.md
Normal file
21
docs/docs1_6/objects/Basalt/setTheme.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# 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)
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `table` theme layout look into [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua) for a example
|
||||
|
||||
### Usage
|
||||
|
||||
* Sets the default theme of basalt.
|
||||
|
||||
```lua
|
||||
basalt.setTheme({
|
||||
ButtonBG = colors.yellow,
|
||||
ButtonText = colors.red,
|
||||
...,
|
||||
})
|
||||
```
|
||||
25
docs/docs1_6/objects/Basalt/setVariable.md
Normal file
25
docs/docs1_6/objects/Basalt/setVariable.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# 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.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `string` a key name
|
||||
2. `any` any variable
|
||||
|
||||
### Usage
|
||||
|
||||
* Adds a function to basalt.
|
||||
|
||||
```lua
|
||||
basalt.setVariable("clickMe", function()
|
||||
basalt.debug("I got clicked")
|
||||
end)
|
||||
|
||||
```
|
||||
|
||||
```xml
|
||||
<button onClick="clickMe" text="Click me" />
|
||||
```
|
||||
21
docs/docs1_6/objects/Basalt/stopUpdate.md
Normal file
21
docs/docs1_6/objects/Basalt/stopUpdate.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Basalt
|
||||
|
||||
## stopUpdate / stop
|
||||
|
||||
Stops the automatic draw and event handler which got started by `basalt.autoUpdate()`.
|
||||
`basalt.autoUpdate(false)` also does the same.
|
||||
|
||||
### Usage
|
||||
|
||||
* When the quit button is clicked, the button stops basalt's event listeners and draw handlers
|
||||
|
||||
```lua
|
||||
local main = basalt.createFrame()
|
||||
main:addButton()
|
||||
:setPosition(2,2)
|
||||
:setText("Stop Basalt!")
|
||||
:onClick(function()
|
||||
basalt.stopUpdate()
|
||||
end)
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
24
docs/docs1_6/objects/Basalt/update.md
Normal file
24
docs/docs1_6/objects/Basalt/update.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# 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.
|
||||
Which means you have to pass the events into basalt.update.
|
||||
|
||||
### Parameters
|
||||
|
||||
1. `string` The event to be received
|
||||
2. `...` Additional event variables to capture
|
||||
|
||||
### Usage
|
||||
|
||||
* Creates and starts a custom update cycle
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
mainFrame:addButton():setPosition(2,2)
|
||||
while true do
|
||||
local ev = table.pack(os.pullEventRaw())
|
||||
basalt.update(table.unpack(ev))
|
||||
end
|
||||
```
|
||||
@@ -1,73 +1,19 @@
|
||||
Buttons are objects, which execute something by clicking on them.<br>
|
||||
The button object is for creating buttons If you click on them, they should execute something. You decide what should happen when clicking on them.
|
||||
|
||||
Remember button also inherits from [Object](objects/Object.md)
|
||||
[Object](objects/Object.md) methods also apply for buttons.
|
||||
|
||||
## setText
|
||||
Sets the displayed button text
|
||||
#### Parameters:
|
||||
1. `string` the text the button should show
|
||||
| | |
|
||||
|---|---|
|
||||
|[setText](objects/Button/setText.md)|Changes the button text
|
||||
|[setHorizontalAlign](objects/Button/setHorizontalAlign.md)|Changes the horizontal text position
|
||||
|[setVerticalAlign](objects/Button/setVerticalAlign.md)|Changes the vertical text position
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Creates a button with "Click me!" as text.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local button = mainFrame:addButton():setText("Click me!")
|
||||
```
|
||||
```xml
|
||||
<button text="Click me!" />
|
||||
```
|
||||
|
||||
## setHorizontalAlign
|
||||
Sets the horizontal align of the button text
|
||||
|
||||
#### Parameters:
|
||||
1. `string` the position as string ("left", "center", "right") - default is center.
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Sets the button's horizontal text align to right.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local button = mainFrame:addButton()
|
||||
:setText("Click me!")
|
||||
:setHorizontalAlign("right")
|
||||
```
|
||||
```xml
|
||||
<button text="Click me!" horizontalAlign="right" />
|
||||
```
|
||||
|
||||
## setVerticalAlign
|
||||
Sets the vertical align of the button text
|
||||
|
||||
#### Parameters:
|
||||
1. `string` the position as string ("top", "center", "bottom") - default is center.
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Sets the button's horizontal text align to right and the vertical text align to bottom.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local button = mainFrame:addButton()
|
||||
:setText("Click me!")
|
||||
:setHorizontalAlign("right")
|
||||
:setVerticalAlign("bottom")
|
||||
```
|
||||
```xml
|
||||
<button text="Click me!" horizontalAlign="right" verticalAlign="bottom" />
|
||||
```
|
||||
|
||||
# Example
|
||||
This is a example on how you would create a fully working button:
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aButton = mainFrame:addButton():setText("Click")
|
||||
local main = basalt.createFrame()
|
||||
local aButton = main:addButton():setText("Click")
|
||||
|
||||
aButton:onClick(function(self,event,button,x,y)
|
||||
if(event=="mouse_click")and(button==1)then
|
||||
@@ -76,15 +22,15 @@ aButton:onClick(function(self,event,button,x,y)
|
||||
end)
|
||||
```
|
||||
|
||||
and this would be the xml way to do it:
|
||||
and this would be the xml way:
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame():addLayout("example.xml")
|
||||
|
||||
basalt.setVariable("buttonClick", function(self,event,button,x,y)
|
||||
if(event=="mouse_click")and(button==1)then
|
||||
basalt.debug("Left mousebutton got clicked!")
|
||||
end
|
||||
end)
|
||||
|
||||
local main = basalt.createFrame():addLayout("example.xml")
|
||||
```
|
||||
```xml
|
||||
<button onClick="buttonClick" text="Click" />
|
||||
|
||||
20
docs/docs1_6/objects/Button/setHorizontalAlign.md
Normal file
20
docs/docs1_6/objects/Button/setHorizontalAlign.md
Normal file
@@ -0,0 +1,20 @@
|
||||
## setHorizontalAlign
|
||||
Sets the horizontal align of the button text
|
||||
|
||||
#### Parameters:
|
||||
1. `string` the position as string ("left", "center", "right") - default is center.
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Sets the button's horizontal text align to right.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local button = mainFrame:addButton()
|
||||
:setText("Click me!")
|
||||
:setHorizontalAlign("right")
|
||||
```
|
||||
```xml
|
||||
<button text="Click me!" horizontalAlign="right" />
|
||||
```
|
||||
17
docs/docs1_6/objects/Button/setText.md
Normal file
17
docs/docs1_6/objects/Button/setText.md
Normal file
@@ -0,0 +1,17 @@
|
||||
## setText
|
||||
Sets the displayed button text
|
||||
#### Parameters:
|
||||
1. `string` the text the button should show
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Creates a button with "Click me!" as text.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local button = mainFrame:addButton():setText("Click me!")
|
||||
```
|
||||
```xml
|
||||
<button text="Click me!" />
|
||||
```
|
||||
21
docs/docs1_6/objects/Button/setVerticalAlign.md
Normal file
21
docs/docs1_6/objects/Button/setVerticalAlign.md
Normal file
@@ -0,0 +1,21 @@
|
||||
## setVerticalAlign
|
||||
Sets the vertical align of the button text
|
||||
|
||||
#### Parameters:
|
||||
1. `string` the position as string ("top", "center", "bottom") - default is center.
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Sets the button's horizontal text align to right and the vertical text align to bottom.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local button = mainFrame:addButton()
|
||||
:setText("Click me!")
|
||||
:setHorizontalAlign("right")
|
||||
:setVerticalAlign("bottom")
|
||||
```
|
||||
```xml
|
||||
<button text="Click me!" horizontalAlign="right" verticalAlign="bottom" />
|
||||
```
|
||||
@@ -1,14 +1,17 @@
|
||||
With checkbox objects the user can set a bool to true or false
|
||||
With checkboxes the user can set a boolean to true or false by clicking on them.
|
||||
|
||||
Remember checkbox also inherits from [Object](objects/Object.md)
|
||||
[Object](objects/Object.md) methods also apply for checkboxes.
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
|[setSymbol](objects/Checkbox/setSymbol.md)|Changes the symbol when checkbox is checked
|
||||
|
||||
A checkbox does not have any custom methods. All required methods are provided by the base [object](objects/Object.md) class.
|
||||
|
||||
# Example
|
||||
This is how you would create a event which gets fired as soon as the value gets changed:
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aCheckbox = mainFrame:addCheckbox()
|
||||
local main = basalt.createFrame()
|
||||
local aCheckbox = main:addCheckbox()
|
||||
|
||||
local function checkboxChange(self)
|
||||
local checked = self:getValue()
|
||||
@@ -19,7 +22,7 @@ aCheckbox:onChange(checkboxChange)
|
||||
|
||||
also possible via xml:
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame():addLayout("example.xml")
|
||||
local main = basalt.createFrame():addLayout("example.xml")
|
||||
|
||||
basalt.setVariable("checkboxChange", function(self)
|
||||
local checked = self:getValue()
|
||||
|
||||
18
docs/docs1_6/objects/Checkbox/setSymbol.md
Normal file
18
docs/docs1_6/objects/Checkbox/setSymbol.md
Normal file
@@ -0,0 +1,18 @@
|
||||
## setSymbol
|
||||
Changes the checkbox symbol, default is "\42"
|
||||
|
||||
#### Parameters:
|
||||
1. `string` symbol
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Creates a new checkbox and changes the symbol to o
|
||||
```lua
|
||||
local main = basalt.createFrame()
|
||||
local checkbox = main:addCheckbox():setSymbol("o")
|
||||
```
|
||||
```xml
|
||||
<checkbox symbol="o" />
|
||||
```
|
||||
@@ -1,307 +1,31 @@
|
||||
Dropdowns are objects where the user can click on a button, this will open a list where the user can choose from.
|
||||
|
||||
If you want to access values inside items this is how the table for single items is made (just a example):
|
||||
[Object](objects/Object.md) methods also apply for dropdowns.
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
|[addItem](objects/Dropdown/addItem.md)|Adds a new item into the list
|
||||
|[removeItem](objects/Dropdown/removeItem.md)|Removes a item from the list
|
||||
|[editItem](objects/Dropdown/editItem.md)|Changes a already existing item in the list
|
||||
|[getItem](objects/Dropdown/getItem.md)|Returns a item by its index
|
||||
|[getItemCount](objects/Dropdown/getItemCount.md)|Returns the item count
|
||||
|[getAll](objects/Dropdown/getAll.md)|Returns the entire list as a table
|
||||
|[selectItem](objects/Dropdown/selectItem.md)|Selects a item
|
||||
|[clear](objects/Dropdown/clear.md)|Makes the entire list empty
|
||||
|[getItemIndex](objects/Dropdown/getItemIndex.md)|Returns the currently active item index
|
||||
|[setSelectedItem](objects/Dropdown/setSelectedItem.md)|Changes the default bg and fg, when the user selects a item
|
||||
|[setOffset](objects/Dropdown/setOffset.md)|Changes the list offset
|
||||
|[getOffset](objects/Dropdown/getOffset.md)|Returns the current offset
|
||||
|[setDropdownSize](objects/Dropdown/setDropdownSize.md)|Changes the dropdown size
|
||||
|
||||
|
||||
A item-table in dropdowns looks like the following example:
|
||||
|
||||
```lua
|
||||
item = {
|
||||
text="1. Entry",
|
||||
bgCol=colors.black,
|
||||
fgCol=colors.white
|
||||
args = {}
|
||||
text="1. Entry", -- the text its showing
|
||||
bgCol=colors.black, -- the background color
|
||||
fgCol=colors.white -- the foreground color
|
||||
args = {} -- custom args you want to pass, which you will be able to access in for example onChange events
|
||||
}
|
||||
```
|
||||
|
||||
Remember Dropdown also inherits from [Object](objects/Object.md)
|
||||
|
||||
## addItem
|
||||
Adds a item into the dropdown
|
||||
|
||||
#### Parameters:
|
||||
1. `string` The entry name
|
||||
2. `number|color` unique default background color - optional
|
||||
3. `number|color` unique default text color - optional
|
||||
4. `any` any value - you could access this later in a :onChange() event (you need to use :getValue()) - optional
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Creates a default dropdown with 3 entries
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown()
|
||||
aDropdown:addItem("1. Entry")
|
||||
aDropdown:addItem("2. Entry",colors.yellow)
|
||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||
```
|
||||
```xml
|
||||
<dropdown>
|
||||
<item><text>1. Entry</text></item>
|
||||
<item><text>2. Entry</text><bg>yellow</bg></item>
|
||||
<item><text>3. Entry</text><bg>yellow</bg><fg>green</fg></item>
|
||||
</dropdown>
|
||||
```
|
||||
|
||||
## removeItem
|
||||
Removes a item from the dropdown
|
||||
|
||||
#### Parameters:
|
||||
1. `number` The index which should get removed
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Creates a default dropdown with 3 entries and removes the second one.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown()
|
||||
aDropdown:addItem("1. Entry")
|
||||
aDropdown:addItem("2. Entry",colors.yellow)
|
||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||
aDropdown:removeItem(2)
|
||||
```
|
||||
|
||||
## editItem
|
||||
Edits a item from the dropdown
|
||||
|
||||
#### Parameters:
|
||||
1. `number` The index which should be edited
|
||||
2. `string` The new item name
|
||||
3. `number` the new item background color - optional
|
||||
4. `number` The new item text color - optional
|
||||
5. `any` New additional information - optional
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Creates a default dropdown with 3 entries and edits the second one.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown()
|
||||
aDropdown:addItem("1. Entry")
|
||||
aDropdown:addItem("2. Entry",colors.yellow)
|
||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||
aDropdown:editItem(2, "Still 2. Entry", colors.red)
|
||||
```
|
||||
|
||||
## getItem
|
||||
Returns a item by index
|
||||
|
||||
#### Parameters:
|
||||
1. `number` The index which should be returned
|
||||
|
||||
#### Returns:
|
||||
1. `table` The item table example: {text="1. Entry", bgCol=colors.black, fgCol=colors.white}
|
||||
|
||||
#### Usage:
|
||||
* Creates a default dropdown with 3 entries and edits the second one.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown()
|
||||
aDropdown:addItem("1. Entry")
|
||||
aDropdown:addItem("2. Entry",colors.yellow)
|
||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||
basalt.debug(aDropdown:getItem(2).text)
|
||||
```
|
||||
|
||||
## getItemCount
|
||||
Returns the current item count
|
||||
|
||||
#### Returns:
|
||||
1. `number` The item list count
|
||||
|
||||
#### Usage:
|
||||
* Creates a default dropdown with 3 entries and prints the current item count.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown()
|
||||
aDropdown:addItem("1. Entry")
|
||||
aDropdown:addItem("2. Entry",colors.yellow)
|
||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||
basalt.debug(aDropdown:getItemCount())
|
||||
```
|
||||
|
||||
## getAll
|
||||
Returns all items as table
|
||||
|
||||
#### Returns:
|
||||
1. `table` All items
|
||||
|
||||
#### Usage:
|
||||
* Creates a default menubar with 3 entries and prints a table.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown()
|
||||
aDropdown:addItem("1. Entry")
|
||||
aDropdown:addItem("2. Entry",colors.yellow)
|
||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||
basalt.debug(aDropdown:getAll())
|
||||
```
|
||||
|
||||
## selectItem
|
||||
selects a item in the dropdown (same as a player would click on a item)
|
||||
|
||||
#### Parameters:
|
||||
1. `number` The index which should get selected
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Creates a default dropdown with 3 entries and selects the second entry.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown()
|
||||
aDropdown:addItem("1. Entry")
|
||||
aDropdown:addItem("2. Entry",colors.yellow)
|
||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||
aDropdown:selectItem(2)
|
||||
```
|
||||
|
||||
## clear
|
||||
Removes all items.
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Creates a default dropdown with 3 entries and removes them immediatley. Which makes no sense.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown()
|
||||
aDropdown:addItem("1. Entry")
|
||||
aDropdown:addItem("2. Entry",colors.yellow)
|
||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||
aDropdown:clear()
|
||||
```
|
||||
|
||||
## getItemIndex
|
||||
returns the item index of the currently selected item
|
||||
|
||||
#### Returns:
|
||||
1. `number` The current index
|
||||
|
||||
#### Usage:
|
||||
* Creates a default dropdown with 3 entries selects the second entry and prints the currently selected index.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown()
|
||||
aDropdown:addItem("1. Entry")
|
||||
aDropdown:addItem("2. Entry",colors.yellow)
|
||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||
aDropdown:selectItem(2)
|
||||
basalt.debug(aDropdown:getItemIndex())
|
||||
```
|
||||
|
||||
## setSelectedItem
|
||||
Sets the background and the foreground of the item which is currently selected
|
||||
|
||||
#### Parameters:
|
||||
1. `number|color` The background color which should be used
|
||||
2. `number|color` The text color which should be used
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Creates a default dropdown with 4 entries and sets the selection background color to green.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown()
|
||||
aDropdown:addItem("1. Entry")
|
||||
aDropdown:addItem("2. Entry",colors.yellow)
|
||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||
aDropdown:addItem("4. Entry")
|
||||
aDropdown:setSelectedItem(colors.green, colors.red)
|
||||
```
|
||||
```xml
|
||||
<dropdown selectionBG="green" selectionFG="red">
|
||||
<item><text>1. Entry</text></item>
|
||||
<item><text>2. Entry</text><bg>yellow</bg></item>
|
||||
<item><text>2. Entry</text><bg>yellow</bg><fg>green</fg></item>
|
||||
</dropdown>
|
||||
```
|
||||
|
||||
## setOffset
|
||||
Sets the offset of the dropdown (the same as you would scroll) - default is 0
|
||||
|
||||
#### Parameters:
|
||||
1. `number` The offset value
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Creates a default dropdown with 6 entries and sets the offset to 3.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown()
|
||||
:addItem("1. Entry")
|
||||
:addItem("2. Entry")
|
||||
:addItem("3. Entry")
|
||||
:addItem("4. Entry")
|
||||
:addItem("5. Entry")
|
||||
:addItem("6. Entry")
|
||||
:setOffset(3)
|
||||
```
|
||||
```xml
|
||||
<dropdown offset="3">
|
||||
<item><text>1. Entry</text></item>
|
||||
<item><text>2. Entry</text></item>
|
||||
<item><text>3. Entry</text></item>
|
||||
<item><text>4. Entry</text></item>
|
||||
<item><text>5. Entry</text></item>
|
||||
<item><text>6. Entry</text></item>
|
||||
</dropdown>
|
||||
```
|
||||
|
||||
## getOffset
|
||||
Returns the current index offset
|
||||
|
||||
#### Returns:
|
||||
1. `number` offset value
|
||||
|
||||
#### Usage:
|
||||
* Creates a default dropdown with 6 entries and sets the offset to 3, also prints the current offset.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown()
|
||||
:addItem("1. Entry")
|
||||
:addItem("2. Entry")
|
||||
:addItem("3. Entry")
|
||||
:addItem("4. Entry")
|
||||
:addItem("5. Entry")
|
||||
:addItem("6. Entry")
|
||||
:setOffset(3)
|
||||
basalt.debug(aDropdown:getOffset())
|
||||
```
|
||||
|
||||
## setDropdownSize
|
||||
Sets the size of the opened dropdown
|
||||
|
||||
#### Parameters:
|
||||
1. `number` The width value
|
||||
2. `number` The height value
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Creates a default dropdown, adds 3 entries and sets the dropdown size to 15w, 8h
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown():setDropdownSize(15,8)
|
||||
aDropdown:addItem("1. Entry")
|
||||
aDropdown:addItem("2. Entry")
|
||||
aDropdown:addItem("3. Entry")
|
||||
```
|
||||
```xml
|
||||
<dropdown dropdownWidth="15" dropdownHeight="8">
|
||||
<item><text>1. Entry</text></item>
|
||||
<item><text>2. Entry</text></item>
|
||||
<item><text>3. Entry</text></item>
|
||||
</dropdown>
|
||||
```
|
||||
|
||||
```
|
||||
28
docs/docs1_6/objects/Dropdown/addItem.md
Normal file
28
docs/docs1_6/objects/Dropdown/addItem.md
Normal file
@@ -0,0 +1,28 @@
|
||||
## addItem
|
||||
Adds a item into the dropdown
|
||||
|
||||
#### Parameters:
|
||||
1. `string` The entry name
|
||||
2. `number|color` unique default background color - optional
|
||||
3. `number|color` unique default text color - optional
|
||||
4. `any` any value - you could access this later in a :onChange() event (you need to use :getValue()) - optional
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Creates a default dropdown with 3 entries
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown()
|
||||
aDropdown:addItem("1. Entry")
|
||||
aDropdown:addItem("2. Entry",colors.yellow)
|
||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||
```
|
||||
```xml
|
||||
<dropdown>
|
||||
<item><text>1. Entry</text></item>
|
||||
<item><text>2. Entry</text><bg>yellow</bg></item>
|
||||
<item><text>3. Entry</text><bg>yellow</bg><fg>green</fg></item>
|
||||
</dropdown>
|
||||
```
|
||||
16
docs/docs1_6/objects/Dropdown/clear.md
Normal file
16
docs/docs1_6/objects/Dropdown/clear.md
Normal file
@@ -0,0 +1,16 @@
|
||||
## clear
|
||||
Removes all items.
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Creates a default dropdown with 3 entries and removes them immediatley. Which makes no sense.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown()
|
||||
aDropdown:addItem("1. Entry")
|
||||
aDropdown:addItem("2. Entry",colors.yellow)
|
||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||
aDropdown:clear()
|
||||
```
|
||||
23
docs/docs1_6/objects/Dropdown/editItem.md
Normal file
23
docs/docs1_6/objects/Dropdown/editItem.md
Normal file
@@ -0,0 +1,23 @@
|
||||
## editItem
|
||||
Edits a item from the dropdown
|
||||
|
||||
#### Parameters:
|
||||
1. `number` The index which should be edited
|
||||
2. `string` The new item name
|
||||
3. `number` the new item background color - optional
|
||||
4. `number` The new item text color - optional
|
||||
5. `any` New additional information - optional
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Creates a default dropdown with 3 entries and edits the second one.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown()
|
||||
aDropdown:addItem("1. Entry")
|
||||
aDropdown:addItem("2. Entry",colors.yellow)
|
||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||
aDropdown:editItem(2, "Still 2. Entry", colors.red)
|
||||
```
|
||||
16
docs/docs1_6/objects/Dropdown/getAll.md
Normal file
16
docs/docs1_6/objects/Dropdown/getAll.md
Normal file
@@ -0,0 +1,16 @@
|
||||
## getAll
|
||||
Returns all items as table
|
||||
|
||||
#### Returns:
|
||||
1. `table` All items
|
||||
|
||||
#### Usage:
|
||||
* Creates a default menubar with 3 entries and prints a table.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown()
|
||||
aDropdown:addItem("1. Entry")
|
||||
aDropdown:addItem("2. Entry",colors.yellow)
|
||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||
basalt.debug(aDropdown:getAll())
|
||||
```
|
||||
19
docs/docs1_6/objects/Dropdown/getItem.md
Normal file
19
docs/docs1_6/objects/Dropdown/getItem.md
Normal file
@@ -0,0 +1,19 @@
|
||||
## getItem
|
||||
Returns a item by index
|
||||
|
||||
#### Parameters:
|
||||
1. `number` The index which should be returned
|
||||
|
||||
#### Returns:
|
||||
1. `table` The item table example: {text="1. Entry", bgCol=colors.black, fgCol=colors.white}
|
||||
|
||||
#### Usage:
|
||||
* Creates a default dropdown with 3 entries and edits the second one.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown()
|
||||
aDropdown:addItem("1. Entry")
|
||||
aDropdown:addItem("2. Entry",colors.yellow)
|
||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||
basalt.debug(aDropdown:getItem(2).text)
|
||||
```
|
||||
16
docs/docs1_6/objects/Dropdown/getItemCount.md
Normal file
16
docs/docs1_6/objects/Dropdown/getItemCount.md
Normal file
@@ -0,0 +1,16 @@
|
||||
## getItemCount
|
||||
Returns the current item count
|
||||
|
||||
#### Returns:
|
||||
1. `number` The item list count
|
||||
|
||||
#### Usage:
|
||||
* Creates a default dropdown with 3 entries and prints the current item count.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown()
|
||||
aDropdown:addItem("1. Entry")
|
||||
aDropdown:addItem("2. Entry",colors.yellow)
|
||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||
basalt.debug(aDropdown:getItemCount())
|
||||
```
|
||||
17
docs/docs1_6/objects/Dropdown/getItemIndex.md
Normal file
17
docs/docs1_6/objects/Dropdown/getItemIndex.md
Normal file
@@ -0,0 +1,17 @@
|
||||
## getItemIndex
|
||||
returns the item index of the currently selected item
|
||||
|
||||
#### Returns:
|
||||
1. `number` The current index
|
||||
|
||||
#### Usage:
|
||||
* Creates a default dropdown with 3 entries selects the second entry and prints the currently selected index.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown()
|
||||
aDropdown:addItem("1. Entry")
|
||||
aDropdown:addItem("2. Entry",colors.yellow)
|
||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||
aDropdown:selectItem(2)
|
||||
basalt.debug(aDropdown:getItemIndex())
|
||||
```
|
||||
20
docs/docs1_6/objects/Dropdown/getOffset.md
Normal file
20
docs/docs1_6/objects/Dropdown/getOffset.md
Normal file
@@ -0,0 +1,20 @@
|
||||
## getOffset
|
||||
Returns the current index offset
|
||||
|
||||
#### Returns:
|
||||
1. `number` offset value
|
||||
|
||||
#### Usage:
|
||||
* Creates a default dropdown with 6 entries and sets the offset to 3, also prints the current offset.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown()
|
||||
:addItem("1. Entry")
|
||||
:addItem("2. Entry")
|
||||
:addItem("3. Entry")
|
||||
:addItem("4. Entry")
|
||||
:addItem("5. Entry")
|
||||
:addItem("6. Entry")
|
||||
:setOffset(3)
|
||||
basalt.debug(aDropdown:getOffset())
|
||||
```
|
||||
19
docs/docs1_6/objects/Dropdown/removeItem.md
Normal file
19
docs/docs1_6/objects/Dropdown/removeItem.md
Normal file
@@ -0,0 +1,19 @@
|
||||
## removeItem
|
||||
Removes a item from the dropdown
|
||||
|
||||
#### Parameters:
|
||||
1. `number` The index which should get removed
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Creates a default dropdown with 3 entries and removes the second one.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown()
|
||||
aDropdown:addItem("1. Entry")
|
||||
aDropdown:addItem("2. Entry",colors.yellow)
|
||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||
aDropdown:removeItem(2)
|
||||
```
|
||||
19
docs/docs1_6/objects/Dropdown/selectItem.md
Normal file
19
docs/docs1_6/objects/Dropdown/selectItem.md
Normal file
@@ -0,0 +1,19 @@
|
||||
## selectItem
|
||||
selects a item in the dropdown (same as a player would click on a item)
|
||||
|
||||
#### Parameters:
|
||||
1. `number` The index which should get selected
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Creates a default dropdown with 3 entries and selects the second entry.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown()
|
||||
aDropdown:addItem("1. Entry")
|
||||
aDropdown:addItem("2. Entry",colors.yellow)
|
||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||
aDropdown:selectItem(2)
|
||||
```
|
||||
26
docs/docs1_6/objects/Dropdown/setDropdownSize.md
Normal file
26
docs/docs1_6/objects/Dropdown/setDropdownSize.md
Normal file
@@ -0,0 +1,26 @@
|
||||
## setDropdownSize
|
||||
Sets the size of the opened dropdown
|
||||
|
||||
#### Parameters:
|
||||
1. `number` The width value
|
||||
2. `number` The height value
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Creates a default dropdown, adds 3 entries and sets the dropdown size to 15w, 8h
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown():setDropdownSize(15,8)
|
||||
aDropdown:addItem("1. Entry")
|
||||
aDropdown:addItem("2. Entry")
|
||||
aDropdown:addItem("3. Entry")
|
||||
```
|
||||
```xml
|
||||
<dropdown dropdownWidth="15" dropdownHeight="8">
|
||||
<item><text>1. Entry</text></item>
|
||||
<item><text>2. Entry</text></item>
|
||||
<item><text>3. Entry</text></item>
|
||||
</dropdown>
|
||||
```
|
||||
32
docs/docs1_6/objects/Dropdown/setOffset.md
Normal file
32
docs/docs1_6/objects/Dropdown/setOffset.md
Normal file
@@ -0,0 +1,32 @@
|
||||
## setOffset
|
||||
Sets the offset of the dropdown (the same as you would scroll) - default is 0
|
||||
|
||||
#### Parameters:
|
||||
1. `number` The offset value
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Creates a default dropdown with 6 entries and sets the offset to 3.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown()
|
||||
:addItem("1. Entry")
|
||||
:addItem("2. Entry")
|
||||
:addItem("3. Entry")
|
||||
:addItem("4. Entry")
|
||||
:addItem("5. Entry")
|
||||
:addItem("6. Entry")
|
||||
:setOffset(3)
|
||||
```
|
||||
```xml
|
||||
<dropdown offset="3">
|
||||
<item><text>1. Entry</text></item>
|
||||
<item><text>2. Entry</text></item>
|
||||
<item><text>3. Entry</text></item>
|
||||
<item><text>4. Entry</text></item>
|
||||
<item><text>5. Entry</text></item>
|
||||
<item><text>6. Entry</text></item>
|
||||
</dropdown>
|
||||
```
|
||||
28
docs/docs1_6/objects/Dropdown/setSelectedItem.md
Normal file
28
docs/docs1_6/objects/Dropdown/setSelectedItem.md
Normal file
@@ -0,0 +1,28 @@
|
||||
## setSelectedItem
|
||||
Sets the background and the foreground of the item which is currently selected
|
||||
|
||||
#### Parameters:
|
||||
1. `number|color` The background color which should be used
|
||||
2. `number|color` The text color which should be used
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Creates a default dropdown with 4 entries and sets the selection background color to green.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aDropdown = mainFrame:addDropdown()
|
||||
aDropdown:addItem("1. Entry")
|
||||
aDropdown:addItem("2. Entry",colors.yellow)
|
||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||
aDropdown:addItem("4. Entry")
|
||||
aDropdown:setSelectedItem(colors.green, colors.red)
|
||||
```
|
||||
```xml
|
||||
<dropdown selectionBG="green" selectionFG="red">
|
||||
<item><text>1. Entry</text></item>
|
||||
<item><text>2. Entry</text><bg>yellow</bg></item>
|
||||
<item><text>2. Entry</text><bg>yellow</bg><fg>green</fg></item>
|
||||
</dropdown>
|
||||
```
|
||||
@@ -1,402 +1,34 @@
|
||||
<a href="https://i.imgur.com/aikc0K1.png"><img src="https://i.imgur.com/aikc0K1.png" height="500" /></a>
|
||||
Frames are like groups or windows. You can add objects on them and if you move the frame, all its children objects will also be moved. Frames also have
|
||||
some special functionality to create very advanced programs.
|
||||
|
||||
[Object](objects/Object.md) methods also apply for frames.
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
|[addObject](objects/Frame/addObject.md)|Adds a new object
|
||||
|[setBar](objects/Frame/setBar.md)|Sets the top bar text and colors - deprecated
|
||||
|[setBarTextAlign](objects/Frame/setBarTextAlign.md)|Sets the top bars text align - deprecated
|
||||
|[showBar](objects/Frame/showBar.md)|Shows the top bar - deprecated
|
||||
|[setMonitor](objects/Frame/setMonitor.md)|Sets the frame to be a monitor frame (only for base frames)
|
||||
|[setMonitorScale](objects/Frame/setMonitorScale.md)|Sets the monitor scale (same as monitor.setTextScale)
|
||||
|[setMirror](objects/Frame/setMirror.md)|Sets the frame to mirror onto a monitor (only for base frames)
|
||||
|[getObject](objects/Frame/getObject.md)|Returns the object by its name (or id)
|
||||
|[removeObject](objects/Frame/removeObject.md)|Removes the object by its name (or id)
|
||||
|[setFocusedObject](objects/Frame/setFocusedObject.md)|Sets the currently focused object by this frame
|
||||
|[removeFocusedObject](objects/Frame/removeFocusedObject.md)|Removes the currenlty focused object (it only removes beeing focused)
|
||||
|[getFocusedObject](objects/Frame/getFocusedObject.md)|Returns the currently focused object
|
||||
|[setMovable](objects/Frame/setMovable.md)|Makes the frame movable (only for sub frames)
|
||||
|[setOffset](objects/Frame/setOffset.md)|Sets the frames offset (will be added to the childrens x and y positions)
|
||||
|[getOffset](objects/Frame/getOffset.md)|Returns the current x and y offset
|
||||
|[addLayout](objects/Frame/addLayout.md)|Adds a new XML Layout into the frame
|
||||
|[addLayoutFromString](objects/Frame/addLayoutFromString.md)|Adds a new XML Layout via string into the frame
|
||||
|[getLastLayout](objects/Frame/getLastLayout.md)|Returns a table of all objects generated by the last addLayout/FromString method
|
||||
|[setTheme](objects/Frame/setTheme.md)|Sets the theme of that frame and all its childrens
|
||||
|[setScrollable](objects/Frame/setScrollable.md)|Makes the frame scrollable via mousewheel (internally this uses setOffset)
|
||||
|[setScrollAmount](objects/Frame/setScrollAmount.md)|Sets how far the user is allowed to scroll
|
||||
|
||||
This is how you would implement frames via xml:
|
||||
|
||||
Frames are like containers, but are also normal objects.
|
||||
In other words, you can add other objects _(even frames)_ to a frame; if the frame itself is visible
|
||||
all sub-objects _(if they are set as visible)_ are also visible. A better description will follow.
|
||||
|
||||
## basalt.createFrame
|
||||
Creates a new non-parent frame - in most cases it is the first thing you'll need.
|
||||
|
||||
#### Parameters:
|
||||
1. `string` name (should be unique)
|
||||
|
||||
#### Returns:
|
||||
1. `frame | nil` The frame created by createFrame, or `nil` if there is already a frame with the given name.
|
||||
|
||||
#### Usage:
|
||||
* Create a frame with an id "myFirstFrame", stored in a variable named frame
|
||||
```lua
|
||||
local myFrame = basalt.createFrame("myFirstFrame")
|
||||
```
|
||||
|
||||
## addFrame
|
||||
Creates a child frame on the frame, the same as [basalt.createFrame](https://github.com/Pyroxenium/Basalt/wiki/Frame#basaltcreateframe) except the frames are given a parent-child relationship automatically
|
||||
|
||||
#### Parameters:
|
||||
1. `string` name (should be unique)
|
||||
|
||||
#### Returns:
|
||||
1. `frame | nil` The frame created by addFrame, or `nil` if there is already a child frame with the given name.<br>
|
||||
|
||||
#### Usage:
|
||||
* Create a new main frame and adds a child frame to it
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local myFrame = mainFrame:addFrame()
|
||||
```
|
||||
```xml
|
||||
<frame></frame>
|
||||
```
|
||||
|
||||
## setBar
|
||||
Sets the text, background, and foreground of the upper bar of the frame, accordingly.
|
||||
|
||||
#### Parameters:
|
||||
1. `string` The title text to set the bar to
|
||||
2. `number` The background color
|
||||
2. `number` The foreground color
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Set the title to "My first frame!", with a background of black and a foreground of light gray.
|
||||
```lua
|
||||
frame:setBar("My first Frame!", colors.black, colors.lightGray)
|
||||
```
|
||||
* Store the frame, use the named frame variable after assigning.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local myFrame = MainFrame:addFrame()
|
||||
myFrame:setBar("My first Frame!")
|
||||
```
|
||||
* This abuses the call-chaining that Basalt uses.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local myFrame = mainFrame:addFrame():setBar("My first Frame!")
|
||||
```
|
||||
```xml
|
||||
<frame barText="My first Frame!" barBG="black" barFG="lightGray"></frame>
|
||||
```
|
||||
|
||||
## setBarTextAlign
|
||||
Sets the frame's bar-text alignment
|
||||
|
||||
#### Parameters:
|
||||
1. `string` Can be supplied with "left", "center", or "right"
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Set the title of myFrame to "My first frame!", and align it to the right.
|
||||
```lua
|
||||
myFrame:setBar("My first Frame!"):setBarTextAlign("right")
|
||||
```
|
||||
```xml
|
||||
<frame barAlign="right"></frame>
|
||||
```
|
||||
|
||||
## showBar
|
||||
Toggles the frame's upper bar
|
||||
|
||||
#### Parameters:
|
||||
1. `boolean | nil` Whether the frame's bar is visible or if supplied `nil`, is automatically visible
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Sets myFrame to have a bar titled "Hello World!" and subsequently displays it.
|
||||
```lua
|
||||
myFrame:setBar("Hello World!"):showBar()
|
||||
```
|
||||
```xml
|
||||
<frame bar="true"></frame>
|
||||
```
|
||||
|
||||
|
||||
## setMonitor
|
||||
Sets this frame as a monitor frame
|
||||
|
||||
#### Parameters:
|
||||
1. `string` The monitor name ("right", "left",... "monitor_1", "monitor_2",...)
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Creates a new monitor frame, you can use to show objects on a monitor.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local monitorFrame = basalt.createFrame():setMonitor("right")
|
||||
monitorFrame:setBar("Monitor 1"):showBar()
|
||||
```
|
||||
```xml
|
||||
<frame monitor="right"></frame>
|
||||
```
|
||||
|
||||
## setMirror
|
||||
mirrors this frame to another peripheral monitor object.
|
||||
|
||||
#### Parameters:
|
||||
1. `string` The monitor name ("right", "left",... "monitor_1", "monitor_2",...)
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Creates mirror of your main frame to a monitor on the left side.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame():setMirror("left")
|
||||
```
|
||||
```xml
|
||||
<frame mirror="left"></frame>
|
||||
```
|
||||
|
||||
## getObject
|
||||
Returns a child object of the frame
|
||||
|
||||
#### Parameters:
|
||||
1. `string` The name of the child object
|
||||
|
||||
#### Returns:
|
||||
1. `object | nil` The object with the supplied name, or `nil` if there is no object present with the given name
|
||||
|
||||
#### Usage:
|
||||
* Adds a button with id "myFirstButton", then retrieves it again through the frame object
|
||||
```lua
|
||||
myFrame:addButton("myFirstButton")
|
||||
local aButton = myFrame:getObject("myFirstButton")
|
||||
```
|
||||
|
||||
## removeObject
|
||||
Removes a child object from the frame
|
||||
|
||||
#### Parameters:
|
||||
1. `string` The name of the child object
|
||||
|
||||
#### Returns:
|
||||
1. `boolean` Whether the object with the given name was properly removed
|
||||
|
||||
#### Usage:
|
||||
* Adds a button with the id "myFirstButton", then removes it with the aforementioned id
|
||||
```lua
|
||||
myFrame:addButton("myFirstButton")
|
||||
myFrame:removeObject("myFirstButton")
|
||||
```
|
||||
|
||||
## setFocusedObject
|
||||
Sets the currently focused object
|
||||
|
||||
#### Parameters:
|
||||
1. `object` The child object to focus on
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Creates a new button, sets the focused object to the previously mentioned button
|
||||
```lua
|
||||
local aButton = myFrame:addButton()
|
||||
myFrame:setFocusedObject(aButton)
|
||||
```
|
||||
|
||||
## removeFocusedObject
|
||||
Removes the focus of the supplied object
|
||||
|
||||
#### Parameters:
|
||||
1. `object` The child object to remove focus from
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Creates a new button then removes the focus from that button when clicking on it
|
||||
```lua
|
||||
local aButton = myFrame:addButton():setFocus():onClick(function()
|
||||
myFrame:removeFocusedObject(aButton)
|
||||
end)
|
||||
```
|
||||
|
||||
## getFocusedObject
|
||||
Gets the currently focused object
|
||||
|
||||
#### Returns:
|
||||
1. `object` The currently focused object
|
||||
|
||||
#### Usage:
|
||||
* Gets the currently focused object from the frame, storing it in a variable
|
||||
```lua
|
||||
local focusedObject = myFrame:getFocusedObject()
|
||||
```
|
||||
|
||||
## setMovable
|
||||
Sets whether the frame can be moved. _In order to move the frame click and drag the upper bar of the frame_
|
||||
|
||||
#### Parameters:
|
||||
1. `boolean` Whether the object is movable
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Creates a frame with id "myFirstFrame" and makes it movable
|
||||
```lua
|
||||
local myFrame = basalt.createFrame():setMovable(true)
|
||||
```
|
||||
```xml
|
||||
<frame moveable="true"></frame>
|
||||
```
|
||||
|
||||
## setOffset
|
||||
Sets the frame's coordinate offset. The frame's child objects will receive the frame's coordinate offset. For example, when using a scrollbar, if you use its value to add an offset to a frame, you will get a scrollable frame.
|
||||
Objects are also able to ignore the offset by using :ignoreOffset() (For example, you may want to ignore the offset on the scrollbar itself)
|
||||
|
||||
The function can also be supplied with negative values
|
||||
|
||||
#### Parameters:
|
||||
1. `number` The x direction offset (+/-)
|
||||
2. `number` The y direction offset (+/-)
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Creates a new base frame with x offset of 5 and a y offset of 3
|
||||
```lua
|
||||
local myFrame = basalt.createFrame():setOffset(5, 3)
|
||||
```
|
||||
* Creates with x offset of 5 and a y offset of -5 (Meaning if you added a button with y position 5, it would be at y position 0)
|
||||
```lua
|
||||
local myFrame = basalt.createFrame():setOffset(5, -5)
|
||||
```
|
||||
```xml
|
||||
<frame xOffset="5" yOffset="-5"></frame>
|
||||
```
|
||||
|
||||
## addLayout
|
||||
Adds a new XML Layout into your frame.
|
||||
|
||||
#### Parameters:
|
||||
1. `string` Path to your layout
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Creates a new base frame and adds the mainframe.xml layout
|
||||
```lua
|
||||
local myFrame = basalt.createFrame():addLayout("mainframe.xml")
|
||||
```
|
||||
```xml
|
||||
<frame layout="mainframe.xml"></frame>
|
||||
```
|
||||
|
||||
## addLayoutFromString
|
||||
Adds a new XML Layout as string into your frame.
|
||||
|
||||
#### Parameters:
|
||||
1. `string` xml
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Creates a new base frame and adds the mainframe.xml layout
|
||||
```lua
|
||||
local myFrame = basalt.createFrame():addLayoutFromString("<button x='12' y='5' bg='black' />")
|
||||
```
|
||||
|
||||
## getLastLayout
|
||||
returns a table of all objects this frame has created via xml (useful if you'd like to access all of them for some reason)
|
||||
|
||||
#### Returns:
|
||||
1. `table` table with objects
|
||||
|
||||
## setTheme
|
||||
Sets the default theme of that frame children objects always try to get the theme of its parent frame, if it does not exist it goes to its parent parent frame, and so on until it reaches the basalt managers theme - which is sotred in theme.lua (Please checkout [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua) for how it could look like.
|
||||
|
||||
#### Parameters:
|
||||
1. `table` theme layout look into [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua) for a example
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Creates a new base frame and adds a new theme which only changes the default color of buttons.
|
||||
```lua
|
||||
local myFrame = basalt.createFrame():setTheme({
|
||||
ButtonBG = colors.yellow,
|
||||
ButtonText = colors.red,
|
||||
})
|
||||
```
|
||||
|
||||
## setScrollable
|
||||
Makes the frame scrollable with mousewheel.
|
||||
|
||||
#### Parameters:
|
||||
1. `bool` scrollable or not
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Creates a new base frame and makes it scrollable
|
||||
```lua
|
||||
local myFrame = basalt.createFrame():setScrollable()
|
||||
```
|
||||
```xml
|
||||
<frame scrollable="true"></frame>
|
||||
```
|
||||
|
||||
## setMinScroll
|
||||
Sets the minimum offset it is allowed to scroll (default 0)
|
||||
|
||||
#### Parameters:
|
||||
1. `number` minimum y offset
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Creates a new base frame and makes it scrollable and sets the minimum amount to -5
|
||||
```lua
|
||||
local myFrame = basalt.createFrame():setScrollable():setMinScroll(-5)
|
||||
```
|
||||
```xml
|
||||
<frame minScroll="-5"></frame>
|
||||
```
|
||||
|
||||
## setMaxScroll
|
||||
Sets the maximum offset it is allowed to scroll (default 10)
|
||||
|
||||
#### Parameters:
|
||||
1. `number` maximum y offset
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Creates a new base frame and makes it scrollable and sets the maximum amount to 25
|
||||
```lua
|
||||
local myFrame = basalt.createFrame():setScrollable():setMaxScroll(25)
|
||||
```
|
||||
```xml
|
||||
<frame maxScroll="25"></frame>
|
||||
```
|
||||
|
||||
## setImportantScroll
|
||||
By default if you hovering your mouse over children objects, you wont scroll the frame, if you set this to true the frame scrolling becomes more important
|
||||
|
||||
#### Parameters:
|
||||
1. `bool` important or not
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Creates a new base frame and makes it scrollable and defines it as important
|
||||
```lua
|
||||
local myFrame = basalt.createFrame():setScrollable():setImportantScroll(true)
|
||||
```
|
||||
```xml
|
||||
<frame importantScroll="true"></frame>
|
||||
```
|
||||
|
||||
# XML Example
|
||||
|
||||
*This is how you would implement frames via xml:
|
||||
```xml
|
||||
<frame>
|
||||
<frame width="parent.w * 0.5" bg="red">
|
||||
@@ -407,3 +39,296 @@ local myFrame = basalt.createFrame():setScrollable():setImportantScroll(true)
|
||||
</frame>
|
||||
</frame>
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
Here are some examples on how you can use frames to create very advanced programs. Because of the screen size limitation of CC:Tweaked frames can become very useful in almost every scenario. You will find some examples here on how you could implement them.
|
||||
|
||||
### Menubar for switching frames
|
||||
|
||||
This is a example on how you can create a menubar which switches your frames (without animation).
|
||||
|
||||
<details>
|
||||
<summary>Click here to show code</summary>
|
||||
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt") -- we need basalt here
|
||||
|
||||
local main = basalt.createFrame():setTheme({FrameBG = colors.lightGray, FrameFG = colors.black}) -- we change the default bg and fg color for frames
|
||||
|
||||
local sub = { -- here we create a table where we gonna add some frames
|
||||
main:addFrame():setPosition(1, 2):setSize("parent.w", "parent.h - 1"), -- obviously the first one should be shown on program start
|
||||
main:addFrame():setPosition(1, 2):setSize("parent.w", "parent.h - 1"):hide(),
|
||||
main:addFrame():setPosition(1, 2):setSize("parent.w", "parent.h - 1"):hide(),
|
||||
}
|
||||
|
||||
local function openSubFrame(id) -- we create a function which switches the frame for us
|
||||
if(sub[id]~=nil)then
|
||||
for k,v in pairs(sub)do
|
||||
v:hide()
|
||||
end
|
||||
sub[id]:show()
|
||||
end
|
||||
end
|
||||
|
||||
local menubar = main:addMenubar():setScrollable() -- we create a menubar in our main frame.
|
||||
:setSize("parent.w")
|
||||
:onChange(function(self, val)
|
||||
openSubFrame(self:getItemIndex()) -- here we open the sub frame based on the table index
|
||||
end)
|
||||
:addItem("Example 1")
|
||||
:addItem("Example 2")
|
||||
:addItem("Example 3")
|
||||
|
||||
-- Now we can change our sub frames, if you want to access a sub frame just use sub[subid], some examples:
|
||||
sub[1]:addButton():setPosition(2, 2)
|
||||
|
||||
sub[2]:addLabel():setText("Hello World!"):setPosition(2, 2)
|
||||
|
||||
sub[3]:addLabel():setText("Now we're on example 3!"):setPosition(2, 2)
|
||||
sub[3]:addButton():setText("No functionality"):setPosition(2, 4):setSize(18, 3)
|
||||
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
|
||||
</details>
|
||||
<br>
|
||||
<video width="600" controls autoplay loop muted>
|
||||
<source src="./_media/frames-with-menubars.mp4" type="video/mp4">
|
||||
</video>
|
||||
|
||||
### Sidebar with buttons to switch frames
|
||||
|
||||
Here we will find out how to create a sidebar (which are also just frames) - the sidebar should have buttons to opens the frames for us.
|
||||
|
||||
<details>
|
||||
<summary>Click here to show code</summary>
|
||||
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt") -- we need basalt here
|
||||
|
||||
local main = basalt.createFrame():setTheme({FrameBG = colors.lightGray, FrameFG = colors.black})
|
||||
|
||||
--[[
|
||||
Here we create the sidebar, on focus it should change the position to parent.w - (self.w-1) which "opens the frame"
|
||||
when the focus gets lost we simply change the position to "parent.w"
|
||||
As you can see we add :setZIndex(25) - this makes sure the sidebar frame is always more important than our normal sub frames.
|
||||
:setScrollable just makes the sidebar frame scrollable (in case you're adding more frames)
|
||||
]]
|
||||
local sidebar = main:addFrame():setBackground(colors.gray):setPosition("parent.w", 1):setSize(15, "parent.h"):setZIndex(25):setScrollable()
|
||||
:onGetFocus(function(self)
|
||||
self:setPosition("parent.w - (self.w-1)")
|
||||
end)
|
||||
:onLoseFocus(function(self)
|
||||
self:setPosition("parent.w")
|
||||
end)
|
||||
|
||||
-- Once again we add 3 frames, the first one should be immediatly visible
|
||||
local sub = {
|
||||
main:addFrame():setPosition(1, 1):setSize("parent.w", "parent.h"),
|
||||
main:addFrame():setPosition(1, 1):setSize("parent.w", "parent.h"):hide(),
|
||||
main:addFrame():setPosition(1, 1):setSize("parent.w", "parent.h"):hide(),
|
||||
}
|
||||
|
||||
--This part of the code adds buttons based on the sub table.
|
||||
local y = 2
|
||||
for k,v in pairs(sub)do
|
||||
sidebar:addButton():setText("Example "..k) -- creating the button and adding a name k is just the index
|
||||
:setBackground(colors.black)
|
||||
:setForeground(colors.lightGray)
|
||||
:setSize("parent.w - 2", 3)
|
||||
:setPosition(2, y)
|
||||
:onClick(function() -- here we create a on click event which hides ALL sub frames and then shows the one which is linked to the button
|
||||
for a, b in pairs(sub)do
|
||||
b:hide()
|
||||
v:show()
|
||||
end
|
||||
end)
|
||||
y = y + 4
|
||||
end
|
||||
|
||||
sub[1]:addButton():setPosition(2, 2)
|
||||
|
||||
sub[2]:addLabel():setText("Hello World!"):setPosition(2, 2)
|
||||
|
||||
sub[3]:addLabel():setText("Now we're on example 3!"):setPosition(2, 2)
|
||||
sub[3]:addButton():setText("No functionality"):setPosition(2, 4):setSize(18, 3)
|
||||
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
|
||||
</details>
|
||||
<br>
|
||||
<video width="600" controls autoplay loop muted>
|
||||
<source src="./_media/frames-with-sidebar.mp4" type="video/mp4">
|
||||
</video>
|
||||
|
||||
### Movable frames with a program object
|
||||
|
||||
In this example you will see how you can add movable frames with a program object in it. It also shows you how you dynamically add new frames.
|
||||
|
||||
<details>
|
||||
<summary>Click here to show code</summary>
|
||||
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local main = basalt.createFrame():setTheme({FrameBG = colors.lightGray, FrameFG = colors.black})
|
||||
|
||||
local id = 1
|
||||
local processes = {}
|
||||
|
||||
local function openProgram(path, title, x, y, w, h)
|
||||
local pId = id
|
||||
id = id + 1
|
||||
local f = main:addFrame()
|
||||
:setMovable()
|
||||
:setSize(w or 30, h or 12)
|
||||
:setPosition(x or math.random(2, 12), y or math.random(2, 8))
|
||||
|
||||
f:addLabel()
|
||||
:setSize("parent.w", 1)
|
||||
:setBackground(colors.black)
|
||||
:setForeground(colors.lightGray)
|
||||
:setText(title or "New Program")
|
||||
|
||||
f:addProgram()
|
||||
:setSize("parent.w", "parent.h - 1")
|
||||
:setPosition(1, 2)
|
||||
:execute(path or "rom/programs/shell.lua")
|
||||
|
||||
f:addButton()
|
||||
:setSize(1, 1)
|
||||
:setText("X")
|
||||
:setBackground(colors.black)
|
||||
:setForeground(colors.red)
|
||||
:setPosition("parent.w", 1)
|
||||
:onClick(function()
|
||||
f:remove()
|
||||
processes[pId] = nil
|
||||
end)
|
||||
processes[pId] = f
|
||||
return f
|
||||
end
|
||||
|
||||
openProgram("rom/programs/fun/worm.lua")
|
||||
|
||||
main:addButton():setPosition("parent.w - 16", 2):setText("Open"):onClick(function()
|
||||
openProgram()
|
||||
end)
|
||||
|
||||
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
|
||||
</details>
|
||||
<br>
|
||||
<video width="600" controls autoplay loop muted>
|
||||
<source src="./_media/dynamic-frames.mp4" type="video/mp4">
|
||||
</video>
|
||||
|
||||
|
||||
### Resizable frames
|
||||
|
||||
If you want to make your frames resizeable, there is no way offered by basalt - so you would have to do it yourself. However such a implementation is very simple as you can see here.
|
||||
|
||||
<details>
|
||||
<summary>Click here to show code</summary>
|
||||
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local main = basalt.createFrame():setTheme({FrameBG = colors.black, FrameFG = colors.lightGray})
|
||||
|
||||
local sub = main:addFrame():setSize(25, 12):setPosition(3, 3)
|
||||
|
||||
local function makeResizeable(frame, minW, minH, maxW, maxH)
|
||||
minW = minW or 4
|
||||
minH = minH or 4
|
||||
maxW = maxW or 99
|
||||
maxH = maxH or 99
|
||||
local btn = frame:addButton()
|
||||
:setPosition("parent.w", "parent.h")
|
||||
:setSize(1, 1)
|
||||
:setText("/")
|
||||
:setForeground(colors.blue)
|
||||
:setBackground(colors.black)
|
||||
:onDrag(function(self, event, btn, xOffset, yOffset)
|
||||
local w, h = frame:getSize()
|
||||
local wOff, hOff = w, h
|
||||
if(w+xOffset-1>=minW)and(w+xOffset-1<=maxW)then
|
||||
wOff = w+xOffset-1
|
||||
end
|
||||
if(h+yOffset-1>=minH)and(h+yOffset-1<=maxH)then
|
||||
hOff = h+yOffset-1
|
||||
end
|
||||
frame:setSize(wOff, hOff)
|
||||
end)
|
||||
end
|
||||
|
||||
makeResizeable(sub, 8, 4)
|
||||
|
||||
sub:addLabel():setText("Hello World")
|
||||
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
|
||||
</details>
|
||||
<br>
|
||||
<video width="600" controls autoplay loop muted>
|
||||
<source src="./_media/resizable-frames.mp4" type="video/mp4">
|
||||
</video>
|
||||
|
||||
### Scrollable frames
|
||||
|
||||
Another important feature of frames is the possibility to make them scrollable. Basalt only provides vertical scrolling for frames. If you want to make horizontal scrolling possible, you need to do it yourself. Also, if you're using :setScrollable() the amount to scroll is based on the object's y-position + height - you can change this by using :setScrollAmount(amount). Only count's for the basalt implementation of scrollable frames.
|
||||
|
||||
<details>
|
||||
<summary>Click here to show code</summary>
|
||||
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local main = basalt.createFrame():setTheme({FrameBG = colors.black, FrameFG = colors.lightGray})
|
||||
|
||||
-- Vertical scrolling is pretty simple, as you can tell:
|
||||
local sub1 = main:addFrame():setScrollable():setSize(20, 15):setPosition(2, 2)
|
||||
|
||||
sub1:addLabel():setPosition(3, 2):setText("Scrollable")
|
||||
sub1:addLabel():setPosition(3, 12):setText("Inside")
|
||||
sub1:addLabel():setPosition(3, 20):setText("Outside")
|
||||
|
||||
-- Here we create a custom scroll event as you can see we dont add a :setScrollable() method to our frame, instead we add a custom scroll event
|
||||
local objects = {}
|
||||
|
||||
local sub2 = main:addFrame():setPosition(23, 2):setSize(25, 5):onScroll(function(self, event, dir)
|
||||
local maxScroll = 0
|
||||
for k,v in pairs(objects)do -- here we iterate trough every object and get their x position + width this way we can find out what's the maximum allowed value to scroll
|
||||
local x = v:getX()
|
||||
local w = v:getWidth()
|
||||
maxScroll = x + w > maxScroll and x + w or maxScroll -- if you don't understand this line, http://lua-users.org/wiki/TernaryOperator
|
||||
end
|
||||
local xOffset = self:getOffset()
|
||||
if(xOffset+dir>=0 and xOffset+dir<=maxScroll-self:getWidth())then
|
||||
self:setOffset(xOffset+dir, 0)
|
||||
end
|
||||
end)
|
||||
|
||||
-- Because we need to iterate the objects, we add them into a table.
|
||||
table.insert(objects, sub2:addButton():setPosition(2, 2):setText("Scrollable"))
|
||||
table.insert(objects, sub2:addButton():setPosition(16, 2):setText("Inside"))
|
||||
table.insert(objects, sub2:addButton():setPosition(30, 2):setText("Outside"))
|
||||
|
||||
basalt.autoUpdate()
|
||||
```
|
||||
|
||||
</details>
|
||||
<br>
|
||||
<video width="600" controls autoplay loop muted>
|
||||
<source src="./_media/scrollable-frames.mp4" type="video/mp4">
|
||||
</video>
|
||||
|
||||
17
docs/docs1_6/objects/Frame/addLayout.md
Normal file
17
docs/docs1_6/objects/Frame/addLayout.md
Normal file
@@ -0,0 +1,17 @@
|
||||
## addLayout
|
||||
Adds a new XML Layout into your frame.
|
||||
|
||||
#### Parameters:
|
||||
1. `string` Path to your layout
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Creates a new base frame and adds the mainframe.xml layout
|
||||
```lua
|
||||
local myFrame = basalt.createFrame():addLayout("mainframe.xml")
|
||||
```
|
||||
```xml
|
||||
<frame layout="mainframe.xml"></frame>
|
||||
```
|
||||
14
docs/docs1_6/objects/Frame/addLayoutFromString.md
Normal file
14
docs/docs1_6/objects/Frame/addLayoutFromString.md
Normal file
@@ -0,0 +1,14 @@
|
||||
## addLayoutFromString
|
||||
Adds a new XML Layout as string into your frame.
|
||||
|
||||
#### Parameters:
|
||||
1. `string` xml
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Creates a new base frame and adds the mainframe.xml layout
|
||||
```lua
|
||||
local myFrame = basalt.createFrame():addLayoutFromString("<button x='12' y='5' bg='black' />")
|
||||
```
|
||||
18
docs/docs1_6/objects/Frame/addObject.md
Normal file
18
docs/docs1_6/objects/Frame/addObject.md
Normal file
@@ -0,0 +1,18 @@
|
||||
## add<Object>
|
||||
Adds a new object. Don't use add<Object> please use addTheObjectYouNeed For example if you want a new Frame, use
|
||||
addFrame, if you want to add a button, use addButton
|
||||
|
||||
#### Parameters:
|
||||
1. `string` optional - the id if you don't add a id it will autimatically generate one for you
|
||||
|
||||
#### Returns:
|
||||
1. `object` The new object you've created
|
||||
|
||||
#### Usage:
|
||||
* Creates some example objects
|
||||
```lua
|
||||
local main = basalt.createFrame()
|
||||
local button = main:addButton()
|
||||
local label = main:addLabel()
|
||||
local frame = main:addFrame()
|
||||
```
|
||||
11
docs/docs1_6/objects/Frame/getFocusedObject.md
Normal file
11
docs/docs1_6/objects/Frame/getFocusedObject.md
Normal file
@@ -0,0 +1,11 @@
|
||||
## getFocusedObject
|
||||
Gets the currently focused object
|
||||
|
||||
#### Returns:
|
||||
1. `object` The currently focused object
|
||||
|
||||
#### Usage:
|
||||
* Gets the currently focused object from the frame, storing it in a variable
|
||||
```lua
|
||||
local focusedObject = myFrame:getFocusedObject()
|
||||
```
|
||||
5
docs/docs1_6/objects/Frame/getLastLayout.md
Normal file
5
docs/docs1_6/objects/Frame/getLastLayout.md
Normal file
@@ -0,0 +1,5 @@
|
||||
## getLastLayout
|
||||
returns a table of all objects this frame has created via xml (useful if you'd like to access all of them for some reason)
|
||||
|
||||
#### Returns:
|
||||
1. `table` table with objects
|
||||
15
docs/docs1_6/objects/Frame/getObject.md
Normal file
15
docs/docs1_6/objects/Frame/getObject.md
Normal file
@@ -0,0 +1,15 @@
|
||||
## getObject
|
||||
Returns a child object of the frame
|
||||
|
||||
#### Parameters:
|
||||
1. `string` The name of the child object
|
||||
|
||||
#### Returns:
|
||||
1. `object | nil` The object with the supplied name, or `nil` if there is no object present with the given name
|
||||
|
||||
#### Usage:
|
||||
* Adds a button with id "myFirstButton", then retrieves it again through the frame object
|
||||
```lua
|
||||
myFrame:addButton("myFirstButton")
|
||||
local aButton = myFrame:getObject("myFirstButton")
|
||||
```
|
||||
0
docs/docs1_6/objects/Frame/getOffset.md
Normal file
0
docs/docs1_6/objects/Frame/getOffset.md
Normal file
15
docs/docs1_6/objects/Frame/removeFocusedObject.md
Normal file
15
docs/docs1_6/objects/Frame/removeFocusedObject.md
Normal file
@@ -0,0 +1,15 @@
|
||||
## removeFocusedObject
|
||||
Removes the currently focused object of that frame
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Creates a new button then removes the focus from that button when clicking on it
|
||||
```lua
|
||||
local main = basalt.createFrame()
|
||||
local input = main:addInput():setFocus()
|
||||
local aButton = main:addButton():onClick(function()
|
||||
main:removeFocusedObject()
|
||||
end)
|
||||
```
|
||||
18
docs/docs1_6/objects/Frame/removeObject.md
Normal file
18
docs/docs1_6/objects/Frame/removeObject.md
Normal file
@@ -0,0 +1,18 @@
|
||||
## removeObject
|
||||
Removes a child object from the frame
|
||||
|
||||
#### Parameters:
|
||||
1. `string|object` The name of the child object or the object itself
|
||||
|
||||
#### Returns:
|
||||
1. `boolean` Whether the object with the given name was properly removed
|
||||
|
||||
#### Usage:
|
||||
* Adds a button with the id "myFirstButton", then removes it with the aforementioned id
|
||||
```lua
|
||||
local main = basalt.createFrame()
|
||||
main:addButton("myFirstButton"):setText("Close")
|
||||
:onClick(function(self)
|
||||
main:removeObject("myFirstButton") -- or main:removeObject(self)
|
||||
end)
|
||||
```
|
||||
30
docs/docs1_6/objects/Frame/setBar.md
Normal file
30
docs/docs1_6/objects/Frame/setBar.md
Normal file
@@ -0,0 +1,30 @@
|
||||
## setBar
|
||||
Sets the text, background, and foreground of the upper bar of the frame, accordingly.
|
||||
|
||||
#### Parameters:
|
||||
1. `string` The title text to set the bar to
|
||||
2. `number` The background color
|
||||
2. `number` The foreground color
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Set the title to "My first frame!", with a background of black and a foreground of light gray.
|
||||
```lua
|
||||
frame:setBar("My first Frame!", colors.black, colors.lightGray)
|
||||
```
|
||||
* Store the frame, use the named frame variable after assigning.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local myFrame = MainFrame:addFrame()
|
||||
myFrame:setBar("My first Frame!")
|
||||
```
|
||||
* This abuses the call-chaining that Basalt uses.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local myFrame = mainFrame:addFrame():setBar("My first Frame!")
|
||||
```
|
||||
```xml
|
||||
<frame barText="My first Frame!" barBG="black" barFG="lightGray"></frame>
|
||||
```
|
||||
17
docs/docs1_6/objects/Frame/setBarTextAlign.md
Normal file
17
docs/docs1_6/objects/Frame/setBarTextAlign.md
Normal file
@@ -0,0 +1,17 @@
|
||||
## setBarTextAlign
|
||||
Sets the frame's bar-text alignment
|
||||
|
||||
#### Parameters:
|
||||
1. `string` Can be supplied with "left", "center", or "right"
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Set the title of myFrame to "My first frame!", and align it to the right.
|
||||
```lua
|
||||
myFrame:setBar("My first Frame!"):setBarTextAlign("right")
|
||||
```
|
||||
```xml
|
||||
<frame barAlign="right"></frame>
|
||||
```
|
||||
15
docs/docs1_6/objects/Frame/setFocusedObject.md
Normal file
15
docs/docs1_6/objects/Frame/setFocusedObject.md
Normal file
@@ -0,0 +1,15 @@
|
||||
## setFocusedObject
|
||||
Sets the currently focused object
|
||||
|
||||
#### Parameters:
|
||||
1. `object` The child object to focus on
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Creates a new button, sets the focused object to the previously mentioned button
|
||||
```lua
|
||||
local aButton = myFrame:addButton()
|
||||
myFrame:setFocusedObject(aButton)
|
||||
```
|
||||
17
docs/docs1_6/objects/Frame/setMirror.md
Normal file
17
docs/docs1_6/objects/Frame/setMirror.md
Normal file
@@ -0,0 +1,17 @@
|
||||
## setMirror
|
||||
mirrors this frame to another peripheral monitor object.
|
||||
|
||||
#### Parameters:
|
||||
1. `string` The monitor name ("right", "left",... "monitor_1", "monitor_2",...)
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Creates mirror of your main frame to a monitor on the left side.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame():setMirror("left")
|
||||
```
|
||||
```xml
|
||||
<frame mirror="left"></frame>
|
||||
```
|
||||
41
docs/docs1_6/objects/Frame/setMonitor.md
Normal file
41
docs/docs1_6/objects/Frame/setMonitor.md
Normal file
@@ -0,0 +1,41 @@
|
||||
## setMonitor
|
||||
You can set base frames as monitor frames, don't try to use setMonitor on sub frames
|
||||
|
||||
#### Parameters:
|
||||
1. `string|table` The monitor name ("right", "left",... "monitor_1", "monitor_2",...) OR a table to create multi-monitors (see example)
|
||||
2. `number` optional - a number between 0.5 to 5 which sets the monitor scale
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Creates a new monitor frame, you can use to show objects on a monitor.
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local monitorFrame = basalt.createFrame():setMonitor("right")
|
||||
monitorFrame:addLabel():setText("Hellooo!")
|
||||
```
|
||||
```xml
|
||||
<frame monitor="right"></frame>
|
||||
```
|
||||
|
||||
* Here is a example on how to create mutlimonitors. You always have to start on the top left of your screen and go to the bottom right, which means in this example
|
||||
monitor_1 is always your most top left monitor while monitor_6 is your most bottom right monitor.
|
||||
|
||||
Table structure:
|
||||
local monitors = {
|
||||
[y1] = {x1,x2,x3},
|
||||
[y2] = {x1,x2,x3}
|
||||
...
|
||||
}
|
||||
|
||||
```lua
|
||||
local monitors = {
|
||||
{"monitor_1", "monitor_2", "monitor_3"},
|
||||
{"monitor_4", "monitor_5", "monitor_6"}
|
||||
}
|
||||
|
||||
local mainFrame = basalt.createFrame()
|
||||
local monitorFrame = basalt.createFrame():setMonitor(monitors)
|
||||
monitorFrame:addLabel():setText("Hellooo!")
|
||||
```
|
||||
15
docs/docs1_6/objects/Frame/setMonitorScale.md
Normal file
15
docs/docs1_6/objects/Frame/setMonitorScale.md
Normal file
@@ -0,0 +1,15 @@
|
||||
## setMonitorScale
|
||||
Changes the scale on the the monitor which the frame is attached to
|
||||
|
||||
#### Parameters:
|
||||
1. `number` A number from 0.5 to 5
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Creates a new base frame, sets the frame as a monitor frame and changes the monitor scale
|
||||
```lua
|
||||
local myFrame = basalt.createFrame()setMonitor("left"):setMonitorScale(2)
|
||||
myFrame:addLabel("Monitor scale is bigger")
|
||||
```
|
||||
17
docs/docs1_6/objects/Frame/setMovable.md
Normal file
17
docs/docs1_6/objects/Frame/setMovable.md
Normal file
@@ -0,0 +1,17 @@
|
||||
## setMovable
|
||||
Sets whether the frame can be moved. _In order to move the frame click and drag the upper bar of the frame_
|
||||
|
||||
#### Parameters:
|
||||
1. `boolean` Whether the object is movable
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Creates a frame with id "myFirstFrame" and makes it movable
|
||||
```lua
|
||||
local myFrame = basalt.createFrame():setMovable(true)
|
||||
```
|
||||
```xml
|
||||
<frame moveable="true"></frame>
|
||||
```
|
||||
25
docs/docs1_6/objects/Frame/setOffset.md
Normal file
25
docs/docs1_6/objects/Frame/setOffset.md
Normal file
@@ -0,0 +1,25 @@
|
||||
## setOffset
|
||||
Sets the frame's coordinate offset. The frame's child objects will receive the frame's coordinate offset. For example, when using a scrollbar, if you use its value to add an offset to a frame, you will get a scrollable frame.
|
||||
Objects are also able to ignore the offset by using :ignoreOffset() (For example, you may want to ignore the offset on the scrollbar itself)
|
||||
|
||||
The function can also be supplied with negative values
|
||||
|
||||
#### Parameters:
|
||||
1. `number` The x direction offset (+/-)
|
||||
2. `number` The y direction offset (+/-)
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Creates a new base frame with x offset of 5 and a y offset of 3
|
||||
```lua
|
||||
local myFrame = basalt.createFrame():setOffset(5, 3)
|
||||
```
|
||||
* Creates with x offset of 5 and a y offset of -5 (Meaning if you added a button with y position 5, it would be at y position 0)
|
||||
```lua
|
||||
local myFrame = basalt.createFrame():setOffset(5, -5)
|
||||
```
|
||||
```xml
|
||||
<frame xOffset="5" yOffset="-5"></frame>
|
||||
```
|
||||
17
docs/docs1_6/objects/Frame/setScrollAmount.md
Normal file
17
docs/docs1_6/objects/Frame/setScrollAmount.md
Normal file
@@ -0,0 +1,17 @@
|
||||
## setScrollAmount
|
||||
Sets the maximum offset it is allowed to scroll
|
||||
|
||||
#### Parameters:
|
||||
1. `number` maximum y offset
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Creates a new base frame and makes it scrollable and sets the maximum amount to 25
|
||||
```lua
|
||||
local myFrame = basalt.createFrame():setScrollable():setScrollAmount(25)
|
||||
```
|
||||
```xml
|
||||
<frame scrollAmount="25"></frame>
|
||||
```
|
||||
17
docs/docs1_6/objects/Frame/setScrollable.md
Normal file
17
docs/docs1_6/objects/Frame/setScrollable.md
Normal file
@@ -0,0 +1,17 @@
|
||||
## setScrollable
|
||||
Makes the frame scrollable with mousewheel.
|
||||
|
||||
#### Parameters:
|
||||
1. `bool` scrollable or not
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Creates a new base frame and makes it scrollable
|
||||
```lua
|
||||
local myFrame = basalt.createFrame():setScrollable()
|
||||
```
|
||||
```xml
|
||||
<frame scrollable="true"></frame>
|
||||
```
|
||||
22
docs/docs1_6/objects/Frame/setTheme.md
Normal file
22
docs/docs1_6/objects/Frame/setTheme.md
Normal file
@@ -0,0 +1,22 @@
|
||||
## setTheme
|
||||
|
||||
Sets the default theme, of that frame children objects always try to get the theme of its parent frame, if it does not exist it goes to its parent parent frame, and so on until it reaches the basalt manager's theme - which is stored in theme.lua (Please checkout [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua) for how it could look like.
|
||||
|
||||
#### Parameters:
|
||||
|
||||
1. `table` theme layout look into [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua) for a example
|
||||
|
||||
#### Returns:
|
||||
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
|
||||
- Creates a new base frame and adds a new theme which only changes the default color of buttons.
|
||||
|
||||
```lua
|
||||
local myFrame = basalt.createFrame():setTheme({
|
||||
ButtonBG = colors.yellow,
|
||||
ButtonText = colors.red,
|
||||
})
|
||||
```
|
||||
17
docs/docs1_6/objects/Frame/showBar.md
Normal file
17
docs/docs1_6/objects/Frame/showBar.md
Normal file
@@ -0,0 +1,17 @@
|
||||
## showBar
|
||||
Toggles the frame's upper bar
|
||||
|
||||
#### Parameters:
|
||||
1. `boolean | nil` Whether the frame's bar is visible or if supplied `nil`, is automatically visible
|
||||
|
||||
#### Returns:
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### Usage:
|
||||
* Sets myFrame to have a bar titled "Hello World!" and subsequently displays it.
|
||||
```lua
|
||||
myFrame:setBar("Hello World!"):showBar()
|
||||
```
|
||||
```xml
|
||||
<frame bar="true"></frame>
|
||||
```
|
||||
@@ -1,41 +1,18 @@
|
||||
The image object is for adding more advanced backgrounds.
|
||||
It also provides a :shrink() function, where you can shrink the images to smaller ones. This functionallity is fully provided by the blittle library created by Bomb Bloke. I did not ask for permission to add it into the framework. If the creator wants me to remove the blittle part, just text me on discord!
|
||||
The image object is for adding more advanced backgrounds to your interface. It supports the loading of .nfp and .bimg images.
|
||||
|
||||
The image object is still not done. in the future i will provide more image formats.
|
||||
[Object](objects/Object.md) methods also apply for images.
|
||||
|
||||
Remember image inherits from [Object](objects/Object.md)
|
||||
| | |
|
||||
|---|---|
|
||||
|[loadImage](objects/Image/loadImage.md)|Loads an image from the specified file path
|
||||
|[setImage](objects/Image/setImage.md)|Set's a new image
|
||||
|[usePalette](objects/Image/usePalette.md)|Changes the used palette to the image prefered palette
|
||||
|[play](objects/Image/play.md)|Plays an animated image
|
||||
|[selectFrame](objects/Image/selectFrame.md)|Selects a specific frame in an animated image
|
||||
|[getMetadata](objects/Image/getMetadata.md)|Returns the metadata of the image
|
||||
|[getImageSize](objects/Image/getImageSize.md)|Returns the width and height of the image
|
||||
|[resizeImage](objects/Image/resizeImage.md)|Resizes the image to the specified dimensions
|
||||
|
||||
## loadImage
|
||||
loads a default .nfp file into the object.
|
||||
# About Bimg
|
||||
|
||||
#### Parameters:
|
||||
1. `string` the absolute file path
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Creates a default image and loads a test.nfp file
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame():show()
|
||||
local aImage = mainFrame:addImage():loadImage("test.nfp")
|
||||
```
|
||||
```xml
|
||||
<image path="test.nfp" />
|
||||
```
|
||||
|
||||
## shrink
|
||||
Shrinks the current image into a blittle image.
|
||||
|
||||
#### Returns:
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
* Creates a default image and loads a test.nfp file
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aImage = mainFrame:addImage():loadImage("test.nfp"):shrink()
|
||||
```
|
||||
```xml
|
||||
<image path="test.nfp" shrink="true" />
|
||||
```
|
||||
Bimg is a custom image format that can be used in place of .nfp, it is a table which can store multiple frames and metadata. The frames can store text, background and foreground, which makes it possible to create any image you'd like. The image format is made by people from the Minecraft Computercraft Mods - Discord. Here's a Github page which explains how the Bimg format works: [bimg](https://github.com/SkyTheCodeMaster/bimg)
|
||||
|
||||
6
docs/docs1_6/objects/Image/getImageSize.md
Normal file
6
docs/docs1_6/objects/Image/getImageSize.md
Normal file
@@ -0,0 +1,6 @@
|
||||
## getImageSize
|
||||
Returns the current image size
|
||||
|
||||
#### Returns:
|
||||
1. `number` width
|
||||
2. `number` height
|
||||
9
docs/docs1_6/objects/Image/getMetadata.md
Normal file
9
docs/docs1_6/objects/Image/getMetadata.md
Normal file
@@ -0,0 +1,9 @@
|
||||
## getMetadata
|
||||
Returns the metadata set in the image
|
||||
|
||||
#### Parameter:
|
||||
|
||||
1. `string` the metadata key (for example: title, description, author, creator, data, width, height,...)
|
||||
|
||||
#### Returns:
|
||||
1. `any` metadata value
|
||||
23
docs/docs1_6/objects/Image/loadImage.md
Normal file
23
docs/docs1_6/objects/Image/loadImage.md
Normal file
@@ -0,0 +1,23 @@
|
||||
## loadImage
|
||||
This method is used to load an image file into the image object.
|
||||
|
||||
#### Parameters:
|
||||
|
||||
1. `path` the absolute file path
|
||||
|
||||
#### Returns:
|
||||
|
||||
1. `object` The object in use
|
||||
|
||||
#### Usage:
|
||||
|
||||
* Creates a default image and loads a test.nfp file
|
||||
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aImage = mainFrame:addImage():loadImage("test.nfp")
|
||||
```
|
||||
|
||||
```xml
|
||||
<image path="test.nfp" />
|
||||
```
|
||||
10
docs/docs1_6/objects/Image/play.md
Normal file
10
docs/docs1_6/objects/Image/play.md
Normal file
@@ -0,0 +1,10 @@
|
||||
## play
|
||||
Plays a bimg animation. This can only work if the bimg has more than 1 frame.
|
||||
|
||||
#### Parameters:
|
||||
|
||||
1. `boolean` If the image animation should play
|
||||
|
||||
#### Returns:
|
||||
|
||||
1. `object` The object in use
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user