Need help making a UI

N

Navimaster

Guest
I've been drawing my UI using the Draw GUI event. I've made multiple buttons in my game which work perfectly. Sometimes it's a pain to get drawn sprites working the way they should, but so far I haven't really had any problems.

My question is ... should I keep using Draw GUI for the layout of my UI? Or should I use objects instead? I'm not 100% sure what the best approach is. Or if I'm even using Draw GUI the way it's intended to.

Edit: video removed.
 
Last edited by a moderator:
A

Aura

Guest
Nobody is going to watch a video to be able to help you. At least I'm not going to.

Coding problems are better explained through text. It is possible that the person watching your video does not understand the message that you want to convey. It is also possible that they miss/don't pay attention to important and crucial points of your issue.

Save videos for situations in which you need to show what is happening (say weird graphical glitches) -- and take some time to type out what you want to do, what you're currently doing and what it is doing, that is, what is happening.
 

jo-thijs

Member
I actually did watch it, but I didn't feel like I was able to give a good response, so I was waiting to see if someone else would give a good response first.
Even though, I feel like text would have been just as good as the video to explain your question.

Anyway, I can just as well comment now.

The progress you've made in your project looks pretty good.
If you're feeling ok continuing programming everything the way you're doing it now,
I would advise continuing the way you're doing it now.

I'm personally not sure how I'd do it.
Sometimes I'm feeling more like using multiple objects and sometimes more like coding everything.
 
N

Navimaster

Guest
Thanks for replying. I'm all up for continuing to draw everything but I don't know if that's a sloppy approach or not.

Basically I want an interactive UI like this



Are objects better than drawn sprites in this situation?

Another question: say, the player hits the "Settings" button, what would be the best way to keep the background and music the same, but get him to the Settings page? (which would have new layout and buttons)
 
Last edited by a moderator:

jo-thijs

Member
If you manage your code well, I don't think it is a sloppy approach.

To go to the settings page, it kind of depends how you everything works exactly,
but I'd probably just create a seperate object for that menu, destroy the instance of the previous menu and create one for the settings menu.
 

K3fka

Member
Adding on to what jo-thijs is saying, you can use objects and position them using code. Have a controller object that creates instances of all of the buttons and stuff you need for the main menu, one that does that for the settings menu, etc. Then you can just create an instance of that object to transition to a different menu screen.
 
S

Samurai

Guest
I've been drawing my UI using the Draw GUI event. I've made multiple buttons in my game which work perfectly. Sometimes it's a pain to get drawn sprites working the way they should, but so far I haven't really had any problems.

My question is ... should I keep using Draw GUI for the layout of my UI? Or should I use objects instead? I'm not 100% sure what the best approach is. Or if I'm even using Draw GUI the way it's intended to.

Edit: video removed.
Anything behavioral use objects. It really depends on how much behavior you are going to have. Looking at the screenshot or just a UI does not really have much behavior except choosing a menu. Since there will be no special view or any physics added in the room then Draw GUI would work best and for HUDs. Is the view going to move around and follow an object? Probably not. The idea for menus is to keep the logic simple so yes Draw GUI would fit well. Just look at what other advanced features will not be in the interactive UI, it's non-trivial.

As for keeping the background music playing when going to settings you probably want to setup any kind of logic to display menu items and keep the current room. For example only showing certain items when in setting or not. It really doesn't matter how it is implemented as long the logic won't be broken because of a lot of if statements.

Just to keep it simple and working well. How I usually create menus is using Draw GUI and draw_sprite function since I want to keep my menus animated in a particular position. In the logic for settings either the current sprite indexes change or different sprite is setup in the same position.
 
N

Navimaster

Guest
Yeah, I've decided to draw the rest of the menu.

What I am having trouble doing now is implementing a way to change the resolution in the settings menu.
Since I'm drawing everything, I thought changing the resolution would be easy...
But apparently not.

Here's my obj_display which controls everything related to the display.

Create event
Code:
global.resolutionwidth = 1920;
global.resolutionheight = 1080;
global.xcenter = global.resolutionwidth/2
global.ycenter = global.resolutionheight/2
window_set_size(global.resolutionwidth,global.resolutionheight);
display_set_gui_size(global.resolutionwidth,global.resolutionheight);
I've made another object called "obj_reskeys" just to change the resolution while in-game and see how well it does it.

obj_reskeys:
D-key
Code:
// lowest res
global.resolutionwidth = 1024;
global.resolutionheight = 576;
view_wport = global.resolutionwidth;
view_hport = global.resolutionheight;
window_set_size(global.resolutionwidth,global.resolutionheight);
F-key
Code:
// medium res
global.resolutionwidth = 1280;
global.resolutionheight = 720;
view_wport = global.resolutionwidth;
view_hport = global.resolutionheight;
window_set_size(global.resolutionheight,global.resolutionheight);
G-key
Code:
// highest res
global.resolutionwidth = 1920;
global.resolutionheight = 1080;
view_wport = global.resolutionwidth;
view_hport = global.resolutionheight;
window_set_size(global.resolutionwidth,global.resolutionheight);

When I press those keys...

Result [gif]

Everything that is already a high-res image looks fine when scaled down. Like the planet and background. They're 3000x1530 png's and they still look good even at 1024x576.

But the blue panel and the text become less detailed as the res gets lower.

It gets to the point where the text isn't even readable at the lowest res (1024x576).

Since I'm using draw_text() to write on top of every button, it sucks to see how poorly text is scaled down.

Any suggestions?
 
Last edited by a moderator:
S

Samurai

Guest
Yeah, I've decided to draw the rest of the menu.

What I am having trouble doing now is implementing a way to change the resolution in the settings menu.
Since I'm drawing everything, I thought changing the resolution would be easy...
But apparently not.

Here's my obj_display which controls everything related to the display.

Create event
Code:
global.resolutionwidth = 1920;
global.resolutionheight = 1080;
global.xcenter = global.resolutionwidth/2
global.ycenter = global.resolutionheight/2
window_set_size(global.resolutionwidth,global.resolutionheight);
display_set_gui_size(global.resolutionwidth,global.resolutionheight);
I've made another object called "obj_reskeys" just to change the resolution while in-game and see how well it does it.

obj_reskeys:
D-key
Code:
// lowest res
global.resolutionwidth = 1024;
global.resolutionheight = 576;
view_wport = global.resolutionwidth;
view_hport = global.resolutionheight;
window_set_size(global.resolutionwidth,global.resolutionheight);
F-key
Code:
// medium res
global.resolutionwidth = 1280;
global.resolutionheight = 720;
view_wport = global.resolutionwidth;
view_hport = global.resolutionheight;
window_set_size(global.resolutionheight,global.resolutionheight);
G-key
Code:
// highest res
global.resolutionwidth = 1920;
global.resolutionheight = 1080;
view_wport = global.resolutionwidth;
view_hport = global.resolutionheight;
window_set_size(global.resolutionwidth,global.resolutionheight);

When I press those keys...



The result? Everything that is already a high-res image looks fine when scaled down. Like the planet and background. They're 3000x1530 png's and they still look good even at 1024x576.

But the blue panel and the text become less detailed as the res gets lower.

It gets to the point where the text isn't even readable at the lowest res (1024x576).

Since I'm using draw_text() to write on top of every button, it sucks to see how poorly text is scaled down.

Any suggestions?
You might want to manage fonts and use draw_set_font on different resolutions.
 
N

Navimaster

Guest
You might want to manage fonts and use draw_set_font on different resolutions.
Hey just wanted to say, that actually worked perfectly.

I set a new variable called GFXres and made a script so every draw_text() event checked GFXres's value first. If it changed, to say, 720, then the script would set the appropriate font beforehand. Same with 1080 (and the 1024x576).

All my text is crisp and readable now, regardless of resolution.
Though now I have to make the buttons a little larger.

By the way, do any of you know how to change res while at fullscreen? I tried using my reskeys in-game while at fullscreen but the res didn't change.

It only changes the res in windowed mode for some reason.
 
Top