Posted 05 April 2015 - 02:33 AM
This is my GUI API. I made it so that making GUI's could be done fast without sacrificing quality. It comes with very many useful functions. It has an OOP design to it with regards to the way it handles buttons.
I also included a GUIBuilder Program that helps in creating GUI's. It is taken from my [post='http://www.computercraft.info/forums2/index.php?/topic/21610-goldslide-v10-keynotepowerpoint-in-minecraft-wip/']GoldSlide[/post] program. It displays the x,y,w,h variables for creating buttons. This saves lots of time.
Global Functions
The text variable is the text to be edited (if you are just using it as a read function just put "").
The variable maxL is what separates this function from the regular read function. It limits the end of the visible input so you create little text boxes.
The variable bgColor is the background color.
The variable character is optional. It is the same as read("*"). It is mainly for creating password text boxes.
This function returns a button table object and draws it on the screen.
The variables x and y are the x and y coordinates of the top left hand corner of the button.
The title variable is for use with the waitForButtons function IT IS NOT PRINTED ON THE SCREEN.
The display variable is optional and is used to change the display screen (for example a monitor).
It returns the title of the button pressed.
It takes button objects as arguments (as many as you like).
The startY argument is optional. It is used for customizing the start Y coordinate of the printing (if nil then startY equals 3).
fixedW is optional. It is used for customizing the end X coordinate of the printing (if nil then fixedW equals the x value of term.getSize()
Pastebin
GUI Builder Program
I also included a GUIBuilder Program that helps in creating GUI's. It is taken from my [post='http://www.computercraft.info/forums2/index.php?/topic/21610-goldslide-v10-keynotepowerpoint-in-minecraft-wip/']GoldSlide[/post] program. It displays the x,y,w,h variables for creating buttons. This saves lots of time.
Global Functions
Spoiler
function clear()
Spoiler
This is a very self explanatory and basic clear function. It is common practice to never use shell.run("clear") to clear the terminalfunction inputFeild(x,y,text,maxL,bgColor,character)
Spoiler
This is a very useful advanced read function. The x and y variables are the x and y coordinates of the input field.The text variable is the text to be edited (if you are just using it as a read function just put "").
The variable maxL is what separates this function from the regular read function. It limits the end of the visible input so you create little text boxes.
The variable bgColor is the background color.
The variable character is optional. It is the same as read("*"). It is mainly for creating password text boxes.
function newButton(x,y,w,h,title,color,display)
Spoiler
This is the main reason I created this API.This function returns a button table object and draws it on the screen.
The variables x and y are the x and y coordinates of the top left hand corner of the button.
The title variable is for use with the waitForButtons function IT IS NOT PRINTED ON THE SCREEN.
The display variable is optional and is used to change the display screen (for example a monitor).
function waitForButtons(...)
Spoiler
This is the event handler for button objects.It returns the title of the button pressed.
It takes button objects as arguments (as many as you like).
function checkInArray(x,a)
Spoiler
Searches for x in array a.function checkIn2DArray(x,y,a)
Spoiler
Searches a 2D Array. It searches for x in a[1] and y in a[1]. (this function is mainly for use with button event handling)function drawArray(a,startY,fixedW)
Spoiler
This another interesting function. It takes an string array argument a. It creates an array of buttons then prints it to the screen then waits for the user input. It returns the name of the button pressed.The startY argument is optional. It is used for customizing the start Y coordinate of the printing (if nil then startY equals 3).
fixedW is optional. It is used for customizing the end X coordinate of the printing (if nil then fixedW equals the x value of term.getSize()
Pastebin
Spoiler
pastebin get HyLWHseV gui
GUI Builder Program
Spoiler
pastebin get 2tc6q18p GUIBuilder
Edited on 05 April 2015 - 12:39 AM