This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ThePH's profile picture

flexibleUI v3 API - simple to use UI API

Started by ThePH, 19 March 2013 - 07:00 AM
ThePH #1
Posted 19 March 2013 - 08:00 AM
ThePH's UI API: flexibleUI v3


Now with cyclers and progress bars

Early version (when it wasn't using OOP) :
SpoilerThis is a really simple to use UI API for ComputerCraft's advanced computer.
I'm gonna ask you to bare with me since I haven't finished the doc, but i will soon.

What it does:

[indent=1](This description was for the first version, but applies to the new one as well) :[/indent]
[indent=1]My API is mainly for easing the process of making a UI, it uses a list for each UI, which contains clickable UI elements and shapes.[/indent]
[indent=1]To use it refer to the section below and while waiting for a proper doc, use the example that I provided and which uses most of the functions.[/indent]
[indent=1]As you will probably notice, the example is rather short for what it does, and that is why I have made this API, the use of list makes it[/indent]
[indent=1]a lot more customizable. One of the advantages is that you won't have the constraint of using an event handler that you did not make, this is where[/indent]
[indent=1]mouse() comes in handy. One of the other advantages, is that you can use as many different UIs as you please, since it uses lists.[/indent]



Overview of the main functions :



[indent=1]uiList is the list being using to store the UI elements[/indent]
[indent=1]suffix -int is the type of data asked[/indent]
[indent=1]pages for addUI and addShape are the pages the element will display on, for draw and mouse, its the current pages displayed.[/indent]
[indent=1]- reset(uiList-list) : makes the list the right 'format'[/indent]
[indent=1]- addUI(uiList-list, unique indentifier-string, x-int, y-int, text-string, text color-int, back color-int, action-string, pages-list, display-list, [enabled-boolean, visible-boolean])[/indent]
[indent=1]adds a UI element, action is return when using mouse() function, pages is for flexible displaying, display is for peripheral and terminal displaying[/indent]
[indent=1]- addShape(uiList-list, unique indentifier-string, shape-string, x-int, y-int, param1-int, param2-int, param3-int, color-int, pages-list, display-list, [enabled-boolean])[/indent]
[indent=1]shape is {'line','outline','box'}[/indent]
[indent=1]- editUI(uiList-list, key-string, identifier-string, value)[/indent]
[indent=1]edit the ui list, identifier must be of {'x','y','text','fg','bg','action','pages','output','enabled','visible'}[/indent]
[indent=1]- draw(listUI-list, pages-list, defaultFG-int, defaultBG-int) - no 'doc' use the example[/indent]
[indent=1]- mouse(listUI-list, x-int, y-int, pages-list, target-list) - no 'doc' use the example[/indent]

Links:



[indent=1]The api itself: http://pastebin.com/RA6hUgt5[/indent]
[indent=1]The example: http://pastebin.com/PpUKUctZ[/indent]


What's new:

[indent=1]v3.1:[/indent]
  • Checkboxes and radios can have more than one indicator, colours everywhere, and use regEx (%I%) to tell where the indicator(s) are. (see screenshots)
[indent=1]v3.0:[/indent]
  • Added multiple colours for one the same element, used as so: %[fb][0123456789abcdef]
  • Added cyclers, used to cycle throught a list (see docs when updated)
  • Added progress bar
[indent=1]v2.1:[/indent]
  • Fixed checkboxes
  • Fixed tags not affecting the draw function
  • Fixed label tags not setting properly
[indent=1]v2 :[/indent]
  • Recoded the API from scratch to make it use OOP, which is way easier to use for the user.
  • Possibility to add actions as string, table or boolean which will be returned.
  • Possibility to add action as function, which will be executed when clicked.
  • Items are now sorted alphabetically by key, meaning the first will be drawn first etc.
  • Text, for buttons or labels can be a table containing the lines and will be adjusted

Docs :

[indent=1]Can be found here, if you need more details, ask :)/>[/indent]
[indent=1]For v2.x : http://pastebin.com/eiP96r3e[/indent]


Bugs :

[indent=1]Theres are currently no bug if you use it as it is sayed you should (right types of arguments etc) except:[/indent]
  • Nothing

Todo :
  • Make container containable ?
  • Make inputboxes
  • Suggestions ?

Add-on scripts :

[indent=1]Numpad v1[/indent]
[indent=1]
Spoiler[/indent]
[indent=1]A numpad system that returns a nil or 1 to 5 digit input, input can be masked (just like read :D/> )[/indent]
[indent=1]Use : inputCode(x, y [, mask])[/indent]
[indent=1]Pastebin : http://pastebin.com/yvqHiKBv[/indent]
[indent=1][/indent]
[indent=1]
[/indent]


Download :

[indent=1]v3.0 : http://pastebin.com/VkJrkxDU[/indent]
[indent=1]v2.x : http://pastebin.com/CDykN1ki[/indent]


Screenshots :

SpoilerHere is the reason I made this API:
I made a program to monitor players, and i non coder friend wanted to easily tweak it, so i made the first version not using OOP.
There is the actual version :









Silly code to show off some of the features: (can be posted on request)









Any suggestion/critics are welcome and appreciated, please enjoy my API :)/>
Edited on 04 April 2013 - 03:49 AM
superaxander #2
Posted 23 March 2013 - 03:41 AM
Cool!
ThePH #3
Posted 29 March 2013 - 02:35 PM
Updated to v2:
  • Recoded the API from scratch to make it use OOP, which is way easier to use for the user.
  • Possibility to add actions as string, table or boolean which will be returned.
  • Possibility to add action as function, which will be executed when clicked.
  • Items are now sorted alphabetically by key, meaning the first will be drawn first etc.
  • Text, for buttons or labels can be a table containing the lines and will be adjusted
Docs are being made ATM
I will be posting sample codes and addons using this API that can be used and modified as wished (again, i'm open to any suggestion, may it be code ideas, or code)
ThePH #4
Posted 30 March 2013 - 06:11 AM
Update v2.1 : Minor bugfixes, cf. OP
ThePH #5
Posted 04 April 2013 - 02:12 AM
Update v3; cyclers, prgress bars and more colours, doc is on its way
Zudo #6
Posted 04 April 2013 - 03:17 AM
I would like to see screenshots :)/>
ThePH #7
Posted 04 April 2013 - 04:53 AM
Sure thing, i totally forgot about thoses ^^

EDIT: There, some screen shots added

EDIT 2:

Made some bugfixes, added more screens, release v3.1, checkboxes and radios colours fixed.
mzxs #8
Posted 05 April 2013 - 09:43 PM
ok i still dont under stand what this does
ThePH #9
Posted 10 April 2013 - 04:39 AM
The API helps you create and manage a GUI, and all of it using one object per GUI