diff --git a/docs/Home.md b/docs/Home.md index 7066497..52cb1ea 100644 --- a/docs/Home.md +++ b/docs/Home.md @@ -1,24 +1,24 @@ -# Welcome to The Basalt Wiki!
+# Welcome to The Basalt Wiki! -_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 (AKA Computer Craft: Tweaked) - a popular minecraft mod. For more information about CC:Tweaked, checkout the project's home page. -

+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). ## Quick Demo ![Preview](https://media0.giphy.com/media/fvmNPshXKeU7FFA9iA/giphy.gif) -

## Questions & Bugs -Obviously I've implemented some easter eggs, _some people_ call them "bugs". If you happen to discover one of these just make a new issue. +Obviously NyoriE has implemented some easter eggs, *some people* call them "bugs". If you happen to discover one of these just make a new issue. -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. +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, or ask in our [discord](https://discord.gg/yNNnmBVBpE). -You may also message me on Discord: NyoriE#8206 +--- + +Feel free to join our [discord](https://discord.gg/yNNnmBVBpE)!

\ No newline at end of file diff --git a/docs/_media/installer.png b/docs/_media/installer.png new file mode 100644 index 0000000..dcdd535 Binary files /dev/null and b/docs/_media/installer.png differ diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 277d1f4..67de1ec 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -3,7 +3,7 @@ - [Quick Start](home/Quick-Start.md) - [Installer](home/installer) - Objects -- - [Object](objects/Object) + - [Object](objects/Object) - [Basalt](objects/Basalt) - [Button](objects/Button) - [Checkbox](objects/Checkbox) @@ -28,4 +28,4 @@ - Tips & Tricks - [Component Logic](tips/logic) - [Changing Button Color](tips/buttons) - - [Design Tips](tips/design.md) + - [Advanced usage of Events](tips/events.md) diff --git a/docs/events/mouseEvents.md b/docs/events/mouseEvents.md index e69de29..d113114 100644 --- a/docs/events/mouseEvents.md +++ b/docs/events/mouseEvents.md @@ -0,0 +1,63 @@ +Here we will talk about mouse events and how you can manipulate them. There are 2 possible mouse events you can add to almost every visual object. + +# onClick +`onClick(self, button, x, y)`
+The computercraft event which triggers this method is `mouse_click` and `monitor_touch`. +Any visual object can register onClick events. + +Here is a example on how to add a onClick event to your button: + +```lua +local basalt = dofile("basalt.lua") + +local mainFrame = basalt.createFrame("myMainFrame"):show() +local button = mainFrame:addButton("myButton"):setPosition(3,3):setSize(12,3):setText("Click"):show() + +function buttonOnClick() + basalt.debug("Button got clicked!") +end +button:onClick(buttonOnClick()) +``` + +# onClickUp +`onClickUp(self, button, x, y)`
+The computercraft event which triggers this method is `mouse_up`. +Any visual object can register onClickUp events. + +Here is a example on how to add a onClickUp event to your button: + +```lua +local basalt = dofile("basalt.lua") + +local mainFrame = basalt.createFrame("myMainFrame"):show() +local button = mainFrame:addButton("myButton"):setPosition(3,3):setSize(12,3):setText("Click"):show() + +function buttonOnClick() + basalt.debug("Button got clicked!") +end +button:onClick(buttonOnClick) + +function buttonOnRelease() + basalt.debug("Button got released!") +end +button:onClickUp(buttonOnRelease) +``` + +# onScroll +`onScroll(self, direction, x, y)`
+The computercraft event which triggers this method is `mouse_scroll`. +Any visual object can register a onScroll events. + +Here is a example on how to add a onScroll event to your button: + +```lua +local basalt = dofile("basalt.lua") + +local mainFrame = basalt.createFrame("myMainFrame"):show() +local button = mainFrame:addButton("myButton"):setPosition(3,3):setSize(12,3):setText("Click"):show() + +function buttonOnScroll() + basalt.debug("Someone scrolls on me!") +end +button:onScroll(buttonOnScroll) +``` diff --git a/docs/favicon-16x16.png b/docs/favicon-16x16.png new file mode 100644 index 0000000..222b2e0 Binary files /dev/null and b/docs/favicon-16x16.png differ diff --git a/docs/favicon-32x32.png b/docs/favicon-32x32.png new file mode 100644 index 0000000..64a8256 Binary files /dev/null and b/docs/favicon-32x32.png differ diff --git a/docs/favicon.ico b/docs/favicon.ico new file mode 100644 index 0000000..c45aaee Binary files /dev/null and b/docs/favicon.ico differ diff --git a/docs/home/gettingStarted.md b/docs/home/gettingStarted.md deleted file mode 100644 index b470a31..0000000 --- a/docs/home/gettingStarted.md +++ /dev/null @@ -1,71 +0,0 @@ -# Getting Started! - -Basalt aims to be a relatively small, easy to use framework. - -Accordingly, we have provided an installation script. - - -Just use the following command in any CC:Tweaked shell: - -`wget https://github.com/Pyroxenium/Basalt/raw/master/basalt.lua basalt.lua` - -This will download `basalt.lua` to your local directory. - -To load the framework, make use of the following snippet: -````lua ---> For those who are unfamiliar with lua, dofile executes the code in the referenced file -local basalt = dofile("basalt.lua") -```` - - -Here is a fully functioning example of Basalt code: - -````lua -local basalt = dofile("basalt.lua") --> 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 ---> If the supplied UID is ambiguous, Basalt#createFrame returns a nil value -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 = dofile("basalt.lua") - -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() -```` diff --git a/docs/home/installer.md b/docs/home/installer.md index 168c44e..f344470 100644 --- a/docs/home/installer.md +++ b/docs/home/installer.md @@ -15,7 +15,7 @@ local basalt = dofile(filePath) -- here you can change the variablename in any v ## Advanced Installer This is a visual version, it asks the user if he wants to install basalt.lua (if not found)
-![](https://i.imgur.com/b4Ys7FB.png) +![](https://raw.githubusercontent.com/Pyroxenium/Basalt/master/docs/_media/installer.png) ````lua --Basalt configurated installer local filePath = "basalt.lua" --here you can change the file path default: basalt.lua @@ -51,12 +51,12 @@ if not(fs.exists(filePath))then 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 "..filePath) -- this is an alternative to the wget command + shell.run("pastebin run ESs1mg7P "..filePath) _installerWindow.setVisible(false) term.clear() break end - if(p3==h/2+2)and(p2<=w/2+9)and(p2>=w/2+4)then + 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) @@ -70,4 +70,5 @@ if not(fs.exists(filePath))then end local basalt = dofile(filePath) -- here you can change the variablename in any variablename you want default: basalt +------------------------------ ```` diff --git a/docs/index.html b/docs/index.html index a36b1f7..72b8ab9 100644 --- a/docs/index.html +++ b/docs/index.html @@ -8,6 +8,8 @@ + +