Dev trick 006 : GUI (Patreon)
Content
Hello there!
Today (and as my PC is currently doing a huge render, I'm taking advantage of it) we're going to talk about GUI.
GUI? What's that? GUI stands for Graphical User Interface. It represents the graphical environment that allows the user and the machine to communicate, i.e. to exchange instructions or information. Basically, it can be summed up as the entire visual display of the application whenever it gives or requests information from/to the user.
Now that we have this foundation, I'm going to talk about the GUI in the context of a game or VN, without going into technical details for the moment. We'll get to that later.
In order for a GUI to be successful, it has to be "user-friendly", i.e. it has to be designed to be as easy to use as possible for the target user. I say this because many developers make mistakes with their GUI because they've mastered it perfectly, but it's incomprehensible to others.
To achieve this goal, you'll need to define a number of elements:
- a graphic charter: this is a set of elements that will be part of your interface, and that you will reuse as often as possible before adding a new element to your graphic charter. This includes icons, images, colors, fonts, font sizes, window borders and backgrounds, etc.
- Flow logic: This is how you want the user to flow through the data you need to display. Will it be based on buttons, menus, scrolling in large windows, swiping from left to right, etc.?
- Functionality: It's silly to say, but if you don't know what you want your GUI to display and do, you won't get very far :)
- The profile of your target users: You won't design the same GUI if your software is aimed at a banker, a nuclear engineer, or a 10-year-old child.
Once you have a basis for each of these requirements, you can start designing.
You'll draw your interface (by hand or in a software program designed for this purpose) and simulate it to see what it looks like: If I want to display this information, what should I do? What happens if I press here? etc.
Once you've completed your designs, you can start looking at the different components that make up your GUI and see what you can group together. Do you often display the same information? Do you want to have an element that is repeated several times in your application? The goal of these groupings is to define the components of your GUI.
Components are elements that you code in a more or less generic way so that you can use them multiple times without having to code them multiple times. For example, in GS, you can display the biography page for each character in the tablet. But I didn't "have fun" coding the page 10 times, just changing the information displayed and the animation (believe me, most VN developers would have done that!). I defined the window only once and used the principle of dynamization (seen in another dev trick).
That's the first thing to do.
Now, depending on the programming language, the next part changes considerably. I'll only talk about Ren'py, the engine I use for GS and which is used for the vast majority of VNs.
In Ren'py, a screen contains a lot of components and sub-components, such as buttons, text, images, and so on.
There are several ways to organize them on a page:
- Either you define the position of each one according to a coordinate system: first text at 10px in X, 15px in Y, etc...
- Use containers: first text, then second text, then third text, etc. For example, vertically or horizontally aligned.
Of course, I recommend the second method. Indeed, if one day you want to change your GUI by adding an element, you can do it easily with the second method, whereas with the first you'll have to readjust everything.
And in ren'py, the most basic containers are the hbox and the vbox (h for horizontal, v for vertical). The idea behind these very efficient containers is that when you create one, it allows you to put all the elements inside it in a logical way, in the order you define them, and align them on the screen.
But, and this is where it gets really powerful, you can put boxes inside boxes! You've divided your screen into three parts: one for an animation, one for text, one for buttons? You put an hbox, then inside that you put the animation, a vbox for text, and a vbox for buttons. And in the text vbox you can put a title, then you put an hbox to put two columns of text, then in this new hbox you put two vboxes, which will be two columns of text: on the left the attribute names, on the right the values of those attributes.
Yes, it can be a bit confusing at first, but the more you divide up your screen like this, the easier it will be to do what you want with it, and above all, to make it evolve!
Of course, this is only a small part of the GUI, but since it's often unique, it's hard to talk about it in detail.
If you have any questions, please don't hesitate to ask! :)
See you soon!
MoonLight