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

GUI API

Started by Niphred, 08 July 2012 - 08:32 PM
Niphred #1
Posted 08 July 2012 - 10:32 PM
This is a beta-ish API to create nice GUIs in Computercraft

Screenshot (code for the screenshot is attatched aswell):
Mendax #2
Posted 09 July 2012 - 02:45 AM
Wow! Amazing job… Although, I'm sort of sad now… You beat me to it :/ :)/>/>
Calculator #3
Posted 12 July 2012 - 10:55 PM
That's really cool! B)/>/>

I've been working on my own class-based GUI framework with automatic element layouts (with no pre-calculated X and Y coordinates). Right now, I'm implementing scrollable menus and text input controls. Your API solves quite a few problems I'm having in interesting ways, so I'm definitely going to look into those and perhaps borrow a few of your ideas - if that's okay with you. :)/>/>
kazagistar #4
Posted 13 July 2012 - 11:45 PM
I will definitely be digging through this code. I'll get back to you at some point.

I feel there is one major issue with GUI systems I have seen so far, which is the fact that they require a program to implement it to work. How about this for an idea: make a box that has the same interface as "term". Then you can create a new environment were term is overwritten, and any programs run using that environment will function like normal, but within the context of the box.
thomas.h #5
Posted 27 July 2012 - 08:33 PM
How do I use this GUI ??
mad-murdock #6
Posted 11 August 2012 - 11:28 PM
looks really good.

unfortuatly, i get a error about keymapper not found.

is it possible, its a feature of computercraft 1.4? i still got 1.33 in tekkit… should be possible to just copy the keymapper though….
mad-murdock #7
Posted 12 August 2012 - 12:07 AM
solved the issue…

used keys api from computercraft 1.4 and changed the corresponding lines in gui sources.

works perfectly well. but dont want to post without permission.

still, what it keymapper and where is it supposed to originate from?
Pharap #8
Posted 14 August 2012 - 07:15 AM
looks really good.

unfortuatly, i get a error about keymapper not found.

is it possible, its a feature of computercraft 1.4? i still got 1.33 in tekkit… should be possible to just copy the keymapper though….

If you download 1.4.1, the keymapper is found lua>roms>apis
It's a file called keys and if you can find a way to shove it into tekkit's CC mod folder, it should be fine
Keys was implemented because its good for beginners (and lazy people who can't be bothered to remember what 255 numbers correspond to.)
Generally, most languages have keys as a constant so the programmer doesn't have to remember the codes, but it's good to at least try to learn some of them just in case.
mad-murdock #9
Posted 14 August 2012 - 07:59 AM
looks really good.

unfortuatly, i get a error about keymapper not found.

is it possible, its a feature of computercraft 1.4? i still got 1.33 in tekkit… should be possible to just copy the keymapper though….

If you download 1.4.1, the keymapper is found lua>roms>apis
It's a file called keys and if you can find a way to shove it into tekkit's CC mod folder, it should be fine
Keys was implemented because its good for beginners (and lazy people who can't be bothered to remember what 255 numbers correspond to.)
Generally, most languages have keys as a constant so the programmer doesn't have to remember the codes, but it's good to at least try to learn some of them just in case.

i absolutly understood this. in fact, they 1.4.1 keys api is the one i used to make this gui lib working on 1.3.
still, this api uses KEYMAPPER, which i couldnt find anywhere at all. also, the constraints used are written different. i.e. keymapper.LEFTCTRL (gui api) vs keys.leftCtrl (1.4.1 api)
maybe i am wrong, and keymapper is somehow resolvable in 1.4.1 and i just missed how by grepping through the lua sources.

yet, with my slight modifications, it works perfectly well on 1.3.3

if clueless ever returns here: good job, sir! i wrote quiet a bit with your gui lib, and usually its just a minimum line of code to make a nice input UI, combined with the usual code you had anyway without the api…
Pharap #10
Posted 14 August 2012 - 08:43 AM
looks really good.

unfortuatly, i get a error about keymapper not found.

is it possible, its a feature of computercraft 1.4? i still got 1.33 in tekkit… should be possible to just copy the keymapper though….

If you download 1.4.1, the keymapper is found lua>roms>apis
It's a file called keys and if you can find a way to shove it into tekkit's CC mod folder, it should be fine
Keys was implemented because its good for beginners (and lazy people who can't be bothered to remember what 255 numbers correspond to.)
Generally, most languages have keys as a constant so the programmer doesn't have to remember the codes, but it's good to at least try to learn some of them just in case.

i absolutly understood this. in fact, they 1.4.1 keys api is the one i used to make this gui lib working on 1.3.
still, this api uses KEYMAPPER, which i couldnt find anywhere at all. also, the constraints used are written different. i.e. keymapper.LEFTCTRL (gui api) vs keys.leftCtrl (1.4.1 api)
maybe i am wrong, and keymapper is somehow resolvable in 1.4.1 and i just missed how by grepping through the lua sources.

yet, with my slight modifications, it works perfectly well on 1.3.3

if clueless ever returns here: good job, sir! i wrote quiet a bit with your gui lib, and usually its just a minimum line of code to make a nice input UI, combined with the usual code you had anyway without the api…

You're making the same mistake I did when I first came here, clueless is the rank you have at less than 50 posts.
If you look at your own name, you're mad-murdock with the rank/status: clueless.
My name is Pharap and my rank/status is coder.
I know what you're thinking, and yes, most people's eyes are drawn straight to the status, but nobody has bothered to ask them to change it.

As for the keymapper, keymappers generally work the same, it's just syntax where they differ. But that's pretty much the story of programming, the biggest difference is usually the syntax.
mad-murdock #11
Posted 14 August 2012 - 05:31 PM
You're making the same mistake I did when I first came here, clueless is the rank you have at less than 50 posts.
If you look at your own name, you're mad-murdock with the rank/status: clueless.
My name is Pharap and my rank/status is coder.
I know what you're thinking, and yes, most people's eyes are drawn straight to the status, but nobody has bothered to ask them to change it.

As for the keymapper, keymappers generally work the same, it's just syntax where they differ. But that's pretty much the story of programming, the biggest difference is usually the syntax.

YIEKS! stupid me…

as for keymappers, as far as i see it, this gui wont work on 1.4 either, since that keymapper class isnt included or linked, am i right there? sure, the change i did wasnt big, but it was important.

@niphred: if you ever return here, i already had to extend your api, since i needed a window:removeChild() call to enable submenus… i hope i get your blessing for this… once my movable-platform-control is done, i have to include your (modified) api anyway - of course linking to this thread in the credits…
with submenu, i mean this btw: http://dl.dropbox.co...14_18.25.31.png - the right menu changes the contents of the left… would be possible with changing root windows, but i prefer a removeChild() in addition to addChild()
edit: i will of course replace the © 2012 by GPL2… for now, its only eye candy
Pharap #12
Posted 14 August 2012 - 06:23 PM
You're making the same mistake I did when I first came here, clueless is the rank you have at less than 50 posts.
If you look at your own name, you're mad-murdock with the rank/status: clueless.
My name is Pharap and my rank/status is coder.
I know what you're thinking, and yes, most people's eyes are drawn straight to the status, but nobody has bothered to ask them to change it.

As for the keymapper, keymappers generally work the same, it's just syntax where they differ. But that's pretty much the story of programming, the biggest difference is usually the syntax.

YIEKS! stupid me…

as for keymappers, as far as i see it, this gui wont work on 1.4 either, since that keymapper class isnt included or linked, am i right there? sure, the change i did wasnt big, but it was important.

@niphred: if you ever return here, i already had to extend your api, since i needed a window:removeChild() call to enable submenus… i hope i get your blessing for this… once my movable-platform-control is done, i have to include your (modified) api anyway - of course linking to this thread in the credits…
with submenu, i mean this btw: http://dl.dropbox.co...14_18.25.31.png - the right menu changes the contents of the left… would be possible with changing root windows, but i prefer a removeChild() in addition to addChild()
edit: i will of course replace the © 2012 by GPL2… for now, its only eye candy

It's a very common mistake.

I think you're right about keymapper though, it would have to be changed to keys unless the user adds their own key constants. Issue their is that you would have to make sure anyone using the API downloaded the key constant file.

I'm currently working on a GUI API of my own. I doubt it will be anywhere near as complicated as this, but I'm probably not going to release it to the community unless there's enough interest in the Beta.
mad-murdock #13
Posted 14 August 2012 - 10:27 PM
I'm currently working on a GUI API of my own. I doubt it will be anywhere near as complicated as this, but I'm probably not going to release it to the community unless there's enough interest in the Beta.

i am always interested in good code. not sure what you mean by complicated though, i kinda like this interface. few lines of code create everything needed. so either you mean, yours got less features, or you mean, yours got a better interface. what ever the case, make sure to let me take a look… always interested. but this lib did the job, when i did a quick search. always happy if i dont have to start from scratch…
Pharap #14
Posted 14 August 2012 - 11:58 PM
I'm currently working on a GUI API of my own. I doubt it will be anywhere near as complicated as this, but I'm probably not going to release it to the community unless there's enough interest in the Beta.

i am always interested in good code. not sure what you mean by complicated though, i kinda like this interface. few lines of code create everything needed. so either you mean, yours got less features, or you mean, yours got a better interface. what ever the case, make sure to let me take a look… always interested. but this lib did the job, when i did a quick search. always happy if i dont have to start from scratch…

No, I mean the actual internal code is complicated, not the interface code.
My internal code is a lot less advanced.
I'm currently getting an attempt to index error anyway, so it's a long way off beta.
mad-murdock #15
Posted 15 August 2012 - 06:24 AM
No, I mean the actual internal code is complicated, not the interface code.
My internal code is a lot less advanced.
I'm currently getting an attempt to index error anyway, so it's a long way off beta.

now i am curious…
GIEF US CODE TO CALM CURIOSITY NAU! WE DEMAND! ^^
but maybe we should continue this conversation via private message to not hijack this thread… are you on irc every now and then?
mad-murdock #16
Posted 15 August 2012 - 07:58 AM
@niphred: windows in windows dont work. i.e. i can add a window inside a window, but the contained labels are rendered wrong. fixing this now…
@Pharap: you are right the internal code is a bit tricky…

edit: actually, i just found a lot of problems in the api that i am fixing right now… they only occur with deeper use (i.e. disable border for root window, have nested windows, disabling focus request for root window).
i will stop to post what i change here now and write a pm to niphred with my email adress to contact me, once he returns
wilcomega #17
Posted 15 August 2012 - 10:24 AM
heey guy,
i am using your api in the next release of BlueTide OS.
if you want any creadits just ask :P/>/>
mad-murdock #18
Posted 15 August 2012 - 01:29 PM
heey guy,
i am using your api in the next release of BlueTide OS.
if you want any creadits just ask :P/>/>

if you use someone elses sources, you always give credit. especially, like in this case, if the sources come bundled with GPL. he didnt put a gpl header in his files, but he did include the gpl in his zip file.

also, i am extending his api currently, since it has some issues that needed fixing. current changes:

changed KEYMAPPER versus 1.4 keys api - runs on 1.3 now
  • added Window:removeChild(child)
  • fixed params.wantsFocus for parent windows, was only used for children
  • edit: given up for now. the window:nextfocus is so much sphaghetti code, it needs a full rewrite… not in the mood right now…
  • changed the window:write, window:setcursorpos method to allow cascaded windows
  • removed debug print from Menu:onKey function, which created buggy output rendering

will probably get more till i am done. i would love to fix the params.border=false and params.wantsFocus - but both require rewriting the unclean code parts (most of his code is really good) - not sure if i got the time for that.
wilcomega #19
Posted 15 August 2012 - 02:05 PM
i also added 2 functions:
Menu:removeItem( name )
Menu:clearItems( )
Pharap #20
Posted 16 August 2012 - 07:57 AM
No, I mean the actual internal code is complicated, not the interface code.
My internal code is a lot less advanced.
I'm currently getting an attempt to index error anyway, so it's a long way off beta.

now i am curious…
GIEF US CODE TO CALM CURIOSITY NAU! WE DEMAND! ^^
but maybe we should continue this conversation via private message to not hijack this thread… are you on irc every now and then?

It's only got 3 working functions at the moment.
If you must know though, I've got write, print and list. I will probably tell you a bit as I get further on, but as I said, it's not even alpha yet, let alone beta.
It's pretty much version 0.0.0.2.
And I am never on IRC. Never… *mysterious ambience*
But you can bug me with messages here, I will get around to them eventually.