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

GUI API v2

Started by ViperLordX, 06 May 2015 - 01:57 AM
ViperLordX #1
Posted 06 May 2015 - 03:57 AM
I wrote my own API, and I think it's pretty nice. It only renders buttons, but a cool feature is that it allows you to set up your own function to render the object, and it'll override the default rendering. It lets you create objects on monitors or computers. It gives the control completely to the user, so the user can easily group the objects into tables, create functions to manipulate the GUI, and so on. The only thing I left out is error handling, which I don't really know how to do.

Here's a Pastebin link:
http://pastebin.com/MU1HDnxF
Lyqyd #2
Posted 06 May 2015 - 05:22 AM
Looks like you accidentally hit reply while you were in the Touchpoint topic rather than starting a new topic, so I've split this for you.
Creator #3
Posted 07 May 2015 - 10:32 AM
This is interesting. Ever thought about implementing other objects?
ViperLordX #4
Posted 11 May 2015 - 03:30 AM
This is a GUI API I made which is meant to be used in bulk. If you want to create one button, it's about 20 lines lf code. If you want to create a second button, that's about another 5 lines. My GUI API gives the control completely to the user. You can create and remove buttons as variables, and you can refresh them in whatever order you want. This API is designed to allow the user to manipulate the screen in bulk by creating functions to manage the GUI. It allows you to create objects on the screen and monitors.

Features:
-Allows user to set custom function to be run on left or right click
-Allows user to set a custom function to draw the object
-Automatically centers text
-Easily compatible with almost any program
-Allows for large customization

Notes:
-If you create an object, you must do object.refresh() for it to render.
-For an object to register and handle clicks, you must do object.passEvent(event,a,b,c,d)

Pastebin:
q5uWRKMQ
ViperLordX #5
Posted 11 May 2015 - 03:47 AM
No, I haven't really thought of adding more objects. The API is just meant to create buttons, which is meant to just save a lot of lines of code. Many other objects, such as scroll lists, text boxes, and the sort are easy to create without help from the API. A text box can just use read(), and a scroll list can just render objects by adding a scroll variable to them.

Also, thanks Lua Liquidator.

Sorry it took me so long to respond. Is there any way to enable email notifications?
ViperLordX #6
Posted 11 May 2015 - 03:55 AM
Never mind, I think I got it. It should email me now if someone responds to my thread.
Lyqyd #7
Posted 11 May 2015 - 04:19 AM
Threads merged. Feel free to update the first post and topic title.
ViperLordX #8
Posted 11 May 2015 - 04:27 AM
Actually, could you lock/delete this post, please? I created a second one before seeing that you split this o e.