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

How to make a simple GUI?

Started by AGiLE-EaGLE1994, 21 April 2017 - 10:04 PM
AGiLE-EaGLE1994 #1
Posted 22 April 2017 - 12:04 AM
I took a class in Small Basic a few semesters ago, and it seems fairly similar to Lua.
So I might be able to understand how a piece of code works, but I don't really know how to write my own.
Same thing with Java, I can read the code but don't know how to write my own.
I would like for someone to explain how to make a simple graphical shell in the style of LCARS from Star Trek.
It looks slightly similar to some of the operating systems I've used that are in the OS forum, but I haven't ever used Lua yet.
I am a visual person, and thus code is hard for me to write, but easy for me to read. If it was a graphical programming language like Kodu, I would probably not need help.
I just want a simple shell in that style with a few "apps" and menus that loads on startup. I know that sounds fairly similar to an OS, but I don't want it to have its own architecture that way it'd still be compatible with CraftOS programs without needing an emulator.
Sort of like Windows 1.0 was for DOS, just a graphical front end for a CLI operating system.
I just want a walkthrough of how to do it or a tutorial on how to learn Lua, so that I'd be able to try it myself and come back here if I need help. I've actually been using ComputerCraft for years, but I only just now got around to making an account because programming goes against my learning style and is thus a lot harder for me to work with, but Lua seems a lot simpler than Java, which I used in making a Flan's mod plane for 1.2.5 back in 2012.
So I am slightly confident that I could learn Lua easier than I would for Java, but it would still not be a cakewalk.
Or if anyone has an OS that's similar to LCARS that they're willing to modify for me, that would be good too.
Am I asking too much? Feel free to lock this if I am.
KingofGamesYami #2
Posted 22 April 2017 - 02:46 PM
Graphics give me trouble too. I would suggest using a user-made framework like Titanium or Surface (would link if I wasn't on a phone). As for learning Lua, it is really simple compared to Java. I'd start with some simple programs, breaking them down into the most basic functions, and googling it.

If you know something in Java but not Lua, feel free to ask here. There are several members who know both (myself included).
AGiLE-EaGLE1994 #3
Posted 22 April 2017 - 08:56 PM
Thank you for that. I appreciate. I remember a bit of Small Basic which is very similar to Lua so hopefully I'll be able to learn it easier.
But programming in general is hard for me because I picture things as a graphical object, not as text on a screen.
D3matt #4
Posted 23 April 2017 - 07:47 AM
Thank you for that. I appreciate. I remember a bit of Small Basic which is very similar to Lua so hopefully I'll be able to learn it easier.
But programming in general is hard for me because I picture things as a graphical object, not as text on a screen.
A program is really just a flow of events and commands. Just imagine a visual workflow of what the program needs to do and then just look up what command will do that.
hbomb79 #5
Posted 23 April 2017 - 08:52 AM
Link to Titanium
Link to Surface

Surface is more of a graphics library, whereas Titanium is a GUI framework (ie: Surface is for manual creation of GUIs, and Titanium provides the elements [buttons, inputs, etc..] by default). The easiest path would be Titanium, but if you feel like manually engineering all the base elements Surface is what you want. However, Titanium does still provide the ability to create your own elements via its class system.

There are some other frameworks available (Flare, Sheets, Bedrock, libAAF), but I have little to no experience with them.

But programming in general is hard for me because I picture things as a graphical object, not as text on a screen.

I made Titanium, so I can try my best to explain the flow of events in a Titanium application (it is pretty similar for all frameworks, but Surface is not at all the same, it doesn't have 'elements' in the same way). Essentially, ComputerCraft emits events depending on user action – Titanium listens for these (such as mouse clicks, scrolls and button presses). When an event is 'caught', it is given to all the parts of your application and each part can react differently (a button may perform an action, an input box might display some text). Each part of the application is just some function calls – a button isn't really a 'thing', but the button draws a box and some text on the screen, the application doesn't associate that part of the canvas to an object, but the object just dumps some stuff there. However, Titanium uses classes so that graphical objects actually are objects allowing for much easier interpretation of the application 'flow'.

Let me know if you need help understanding Titanium, or graphical systems in general.
Edited on 23 April 2017 - 07:01 AM
AGiLE-EaGLE1994 #6
Posted 23 April 2017 - 06:36 PM
So, basically, I should imagine the program as a flowchart instead of a screenshot of the finished product? That helps a lot in making me understand how it works.
I've heard Lua is easy to learn, so maybe it won't be too difficult for me.
Basically, I want something like the GUI in this: https://www.youtube.com/watch?v=NkEnsHK8r6U Except with basic OS type buttons instead of the Holodeck room buttons.
Maybe a text editor, a calculator or a clock?
hbomb79 #7
Posted 26 April 2017 - 04:05 AM
Basically, I want something like the GUI in this: https://www.youtube....h?v=NkEnsHK8r6U Except with basic OS type buttons instead of the Holodeck room buttons.
Maybe a text editor, a calculator or a clock?

Well, Titanium provides monitor support and a wide variety of on screen nodes (Button, text inputs, dropdown, scrolling containers, etc…) – You can also create your own nodes. You can easily specify your layout for the computer and monitor using an XML syntax.

If you want help using Titanium, you can ask here
AGiLE-EaGLE1994 #8
Posted 29 April 2017 - 12:15 AM
Basically, I want something like the GUI in this: https://www.youtube....h?v=NkEnsHK8r6U Except with basic OS type buttons instead of the Holodeck room buttons.
Maybe a text editor, a calculator or a clock?

Well, Titanium provides monitor support and a wide variety of on screen nodes (Button, text inputs, dropdown, scrolling containers, etc…) – You can also create your own nodes. You can easily specify your layout for the computer and monitor using an XML syntax.

If you want help using Titanium, you can ask here
I've used XML before! That could make things quite a bit easier! Thanks for recommending me that.
But what in all is it capable of doing?
hbomb79 #9
Posted 29 April 2017 - 02:12 AM
I've used XML before! That could make things quite a bit easier! Thanks for recommending me that.
But what in all is it capable of doing?

Well the forum post I linked lists the key features, and provides a GIF of the example application (basically the application I use for testing new features).

Titanium also comes with monitor support natively, so you can link monitors to certain aspects of the application and 'mirror' them to the monitor (ie: Titanium can show the part on the monitor AND the computer, or just the monitor). I have a small, WIP website that might give you some more information (features, documentation and download instructions). The forum post also provides the link to a Gitter chatroom where you can ask as many questions regarding Titanium as you like (this guide will help you get started with Titanium).

Titanium is certainly up to the task of creating a basic GUI for you, and I am available to help you out. The aim is for the website to teach people how to use Titanium properly via guides and documentation, however as I mentioned earlier, the site is still a WIP.

Maybe a text editor, a calculator or a clock?

Titanium does support a multi-line text editor (comes default), and because Titanium is object oriented (using a class system) you can create your own nodes, using the base nodes to help you (extension). I am planning on users being able to distribute their own classes using 'class packs', but that is not a reality just yet.

The forum post is packed with information regarding the XML markup, Theme files (think XML versions of CSS files), animations, dynamic values, nodes (elements) and distribution of your programs.

Good luck, and god speed.
Edited on 29 April 2017 - 08:43 PM
AGiLE-EaGLE1994 #10
Posted 04 May 2017 - 08:17 PM
That's probably what I'll use then. Thanks for the help c:
Can an admin lock this? If I need more help, I'll ask for it to be reopened.
Bomb Bloke #11
Posted 04 May 2017 - 10:37 PM
There's no reason to lock this. If you need more help, just keep posting in it.