From f6cdd0227026bc004cb9585e5d99cd455b3dff1a Mon Sep 17 00:00:00 2001 From: Robert Jelic <36573031+NoryiE@users.noreply.github.com> Date: Sun, 17 Jul 2022 19:24:58 +0200 Subject: [PATCH 1/4] Delete Lerp.lua --- Basalt/libraries/Lerp.lua | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 Basalt/libraries/Lerp.lua diff --git a/Basalt/libraries/Lerp.lua b/Basalt/libraries/Lerp.lua deleted file mode 100644 index eaaeee5..0000000 --- a/Basalt/libraries/Lerp.lua +++ /dev/null @@ -1,27 +0,0 @@ -local lerp = function(s, e, pct) - return s + (e - s) * pct -end - -local flip = function (x) - return 1 - x -end - -local easeIn = function (t) - return t * t * t -end - -local easeOut = function(t) - return flip(easeIn(flip(t))) -end - -return { - lerp = lerp, - flip = flip, - easeIn = easeIn, - easeOut = easeOut, - - easeInOut = function(t) - return lerp(easeIn(t), easeOut(t), t) - end - -} \ No newline at end of file From 8242f7868dc7adf31f513a70ad4acc9334f22fae Mon Sep 17 00:00:00 2001 From: Robert Jelic <36573031+NoryiE@users.noreply.github.com> Date: Sun, 17 Jul 2022 19:25:17 +0200 Subject: [PATCH 2/4] Delete geometric.lua --- Basalt/libraries/geometric.lua | 88 ---------------------------------- 1 file changed, 88 deletions(-) delete mode 100644 Basalt/libraries/geometric.lua diff --git a/Basalt/libraries/geometric.lua b/Basalt/libraries/geometric.lua deleted file mode 100644 index 88facc2..0000000 --- a/Basalt/libraries/geometric.lua +++ /dev/null @@ -1,88 +0,0 @@ -local function filledRectangle(x1,y1,x2,y2) - -end - -local function filledCircle(xC, yC, r) - local points = {} - for x=-r, r+1 do - local dy = math.floor(math.sqrt(r*r - x*x)) - for y=-dy, dy+1 do - table.insert(points, {x=xC+x, y=yC+y}) - end - end - return points -end - -local function elipse(xC, yC, r1, r2, filled) - local rx,ry = math.ceil(math.floor(r1-0.5)/2),math.ceil(math.floor(r2-0.5)/2) - local x,y=0,ry - local d1 = ((ry * ry) - (rx * rx * ry) + (0.25 * rx * rx)) - local dx = 2*ry^2*x - local dy = 2*rx^2*y - local points = {} - while dx < dy do - table.insert(points,{x=x+xC,y=y+yC}) - table.insert(points,{x=-x+xC,y=y+yC}) - table.insert(points,{x=x+xC,y=-y+yC}) - table.insert(points,{x=-x+xC,y=-y+yC}) - if filled then - for y=-y+yC+1,y+yC-1 do - table.insert(points,{x=x+xC,y=y}) - table.insert(points,{x=-x+xC,y=y}) - end - end - if d1 < 0 then - x = x + 1 - dx = dx + 2*ry^2 - d1 = d1 + dx + ry^2 - else - x,y = x+1,y-1 - dx = dx + 2*ry^2 - dy = dy - 2*rx^2 - d1 = d1 + dx - dy + ry^2 - end - end - local d2 = (((ry * ry) * ((x + 0.5) * (x + 0.5))) + ((rx * rx) * ((y - 1) * (y - 1))) - (rx * rx * ry * ry)) - while y >= 0 do - table.insert(points,{x=x+xC,y=y+yC}) - table.insert(points,{x=-x+xC,y=y+yC}) - table.insert(points,{x=x+xC,y=-y+yC}) - table.insert(points,{x=-x+xC,y=-y+yC}) - if filled then - for y=-y+yC,y+yC do - table.insert(points,{x=x+xC,y=y}) - table.insert(points,{x=-x+xC,y=y}) - end - end - if d2 > 0 then - y = y - 1 - dy = dy - 2*rx^2 - d2 = d2 + rx^2 - dy - else - y = y - 1 - x = x + 1 - dy = dy - 2*rx^2 - dx = dx + 2*ry^2 - d2 = d2 + dx - dy + rx^2 - end - end - return points -end - -local function circle(xC, yC, r, filled) - return elipse(xC, yC, r, r, filled) -end - -return { -circle = function(x, y, radius, filled) - return circle(x, y, radius, filled) -end, - -rectangle = function(x1,y1,x2, y2, filled) - local positions = {} -end, - -elipse = function(xCenter, yCenter, radius1, radius2, filled) - return elipse(xCenter, yCenter, radius1, radius2, filled) -end -} \ No newline at end of file From 3819c14c081a0a3ee13d3a10d5ceec5e011f5e63 Mon Sep 17 00:00:00 2001 From: Robert Jelic <36573031+NoryiE@users.noreply.github.com> Date: Sun, 17 Jul 2022 19:33:13 +0200 Subject: [PATCH 3/4] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index dd9152a..51b0ba9 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,14 @@ If you have questions, feel free to join the discord server: [https://discord.gg ## Changelogs From now on we will add changes: +#### Version 4: +- You can now mirror a frame to a monitor by using :setMirror(side) +- with dynamic values you are able to use percentage values and even functions which get called everytime we need the size of that object +- XML got added to make design and logic seperate (you don't have to) - you are now able to use xml to create your UI design. +- Animations are now more advanced and provide many features to do cool stuff. They are also very easy to use now! +- Also some smaller bugfixes +- new bugs to explore + #### Version 3: - fixed monitor support - added :setIndex() for scrollbars From 3107a7adb81fb9e66ee65c5e3edefa368a7be80c Mon Sep 17 00:00:00 2001 From: Robert Jelic <36573031+NoryiE@users.noreply.github.com> Date: Sun, 17 Jul 2022 20:24:09 +0200 Subject: [PATCH 4/4] Update Frame.md --- docs/objects/Frame.md | 261 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 237 insertions(+), 24 deletions(-) diff --git a/docs/objects/Frame.md b/docs/objects/Frame.md index 3c652fc..9b509a0 100644 --- a/docs/objects/Frame.md +++ b/docs/objects/Frame.md @@ -29,10 +29,15 @@ Creates a child frame on the frame, the same as [basalt.createFrame](https://git 1. `frame | nil` The frame created by addFrame, or `nil` if there is already a child frame with the given name.
#### Usage: -* Create a frame with id "myFirstFrame" then create a child of that frame, named "myFirstSubFrame" +* Create a new main frame and adds a child frame to it ```lua -local mainFrame = basalt.createFrame("myFirstFrame") -local myFrame = mainFrame:addFrame("myFirstSubFrame") +local mainFrame = basalt.createFrame() +local myFrame = mainFrame:addFrame() +``` + +#### XML: +```xml + ``` ## setBar @@ -53,15 +58,19 @@ frame:setBar("My first Frame!", colors.black, colors.lightGray) ``` * Store the frame, use the named frame variable after assigning. ```lua -local mainFrame = basalt.createFrame("myFirstFrame"):show() -local myFrame = MainFrame:addFrame("myFirstSubFrame") +local mainFrame = basalt.createFrame() +local myFrame = MainFrame:addFrame() myFrame:setBar("My first Frame!") -myFrame:show() ``` * This abuses the call-chaining that Basalt uses. ```lua -local mainFrame = basalt.createFrame("myFirstFrame"):show() -local myFrame = mainFrame:addFrame("myFirstSubFrame"):setBar("My first Frame!"):show() +local mainFrame = basalt.createFrame() +local myFrame = mainFrame:addFrame():setBar("My first Frame!") +``` + +#### XML: +```xml + ``` ## setBarTextAlign @@ -76,7 +85,12 @@ Sets the frame's bar-text alignment #### Usage: * Set the title of myFrame to "My first frame!", and align it to the right. ```lua -local mainFrame = myFrame:setBar("My first Frame!"):setBarTextAlign("right") +myFrame:setBar("My first Frame!"):setBarTextAlign("right") +``` + +#### XML: +```xml + ``` ## showBar @@ -91,9 +105,15 @@ Toggles the frame's upper bar #### Usage: * Sets myFrame to have a bar titled "Hello World!" and subsequently displays it. ```lua -local mainFrame = myFrame:setBar("Hello World!"):showBar() +myFrame:setBar("Hello World!"):showBar() ``` +#### XML: +```xml + +``` + + ## setMonitor Sets this frame as a monitor frame @@ -106,10 +126,36 @@ Sets this frame as a monitor frame #### Usage: * Creates a new monitor frame, you can use to show objects on a monitor. ```lua -local mainFrame = basalt.createFrame("mainFrame"):show() -local monitorFrame = basalt.createFrame("mainFrame"):setMonitor("right"):show() +local mainFrame = basalt.createFrame() +local monitorFrame = basalt.createFrame():setMonitor("right") monitorFrame:setBar("Monitor 1"):showBar() ``` + +#### XML: +```xml + +``` + +## 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: +```xml + +``` + ## getObject Returns a child object of the frame @@ -152,11 +198,12 @@ Sets the currently focused object 1. `frame` The frame being used #### Usage: -* Creates button with id "myFirstButton", sets the focused object to the previously mentioned button +* Creates a new button, sets the focused object to the previously mentioned button ```lua -local aButton = myFrame:addButton("myFirstButton") +local aButton = myFrame:addButton() myFrame:setFocusedObject(aButton) ``` + ## removeFocusedObject Removes the focus of the supplied object @@ -167,14 +214,16 @@ Removes the focus of the supplied object 1. `frame` The frame being used #### Usage: -* Creates a button with id "myFirstButton", then removes the focus from that button +* Creates a new button then removes the focus from that button when clicking on it ```lua -local aButton = myFrame:addButton("myFirstButton") -myFrame:removeFocusedObject(aButton) +local aButton = myFrame:addButton():setFocus():onClick(function() + myFrame:removeFocusedObject(aButton) +end) ``` ## getFocusedObject Gets the currently focused object + #### Returns: 1. `object` The currently focused object @@ -183,9 +232,10 @@ Gets the currently focused object ```lua local focusedObject = myFrame:getFocusedObject() ``` -## setMovable +## 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 @@ -195,14 +245,19 @@ Sets whether the frame can be moved. _In order to move the frame click and drag #### Usage: * Creates a frame with id "myFirstFrame" and makes it movable ```lua -local myFrame = basalt.createFrame("myFirstFrame"):setMovable(true) +local myFrame = basalt.createFrame():setMovable(true) +``` + +#### XML: +```xml + ``` ## 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 be supplied negative offsets +The function can also be supplied with negative values #### Parameters: 1. `number` The x direction offset (+/-) @@ -212,11 +267,169 @@ The function can be supplied negative offsets 1. `frame` The frame being used #### Usage: -* Creates "myFirstFrame" with an x offset of 5 and a y offset of 3 +* Creates a new base frame with x offset of 5 and a y offset of 3 ```lua -local myFrame = basalt.createFrame("myFirstFrame"):setOffset(5, 3) +local myFrame = basalt.createFrame():setOffset(5, 3) ``` -* Creates "myFirstFrame" with an 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) +* 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("myFirstFrame"):setOffset(5, -5) +local myFrame = basalt.createFrame():setOffset(5, -5) +``` + +#### XML: +```xml + +``` + +## 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: +```xml + +``` + +## 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("