Windows Gui not drawing Properly on a full screen

B

BingleBop27

Guest
When i draw a gui, while i draw it at the starting gui size of 768, 1024, the gui will draw correctly, or rather at all, but when i go into full screen, at a size of 2160, 3840 it doesnt draw at all, or not where its supposed to,
//create event:
gui_width = display_get_gui_width();
gui_height = display_get_gui_height();
gui_margin = gui_height / 5;
menu_x = gui_width + 400;
menu_y = gui_height - gui_margin;
menu_x_target = gui_width / 2;
menu_speed = 25;
menu_font = Fon_MMenu;
menu_itemheight = font_get_size(menu_font);
menu_committed = -1;
menu_control = true;
menu[2] = "Continue";
menu[1] = "New Game";
menu[0] = "Quit";
menu_items = array_length_1d(menu);
menu_cursor = 2;
new_save = false;
//draw gui event:
DrawText(menu_font, c_white, fa_center , fa_bottom);
for( var i = 0; i < menu_items; i++)
{
var offset = 2
var txt = menu;
if(menu_cursor == i)
{
txt = string_insert("> ", txt, 0);
var col = c_white;
}
else var col = c_gray;

var xx = menu_x;
var yy = menu_y - (menu_itemheight * i * 1.5);
draw_set_color(c_black);
draw_text(xx-offset ,yy, txt);
draw_text(xx+offset,yy,txt);
draw_text(xx,yy-offset,txt);
draw_text(xx,yy-offset,txt);
draw_set_color(col);
draw_text(xx,yy,txt);

}
draw_set_color(c_black);
draw_rectangle(gui_width, 0, gui_width+1000, gui_height, false)
draw_rectangle(0, 0, -1000, gui_height, false)
 
B

BingleBop27

Guest
When you go into full screen use the command display_set_gui_maximize();
when i do that the gui appears at it original cords(ie 600, 300 ish), and the text does not change size, i guess i could change that, but theres also a black box on the screen. before hand it worked just fine, and put them where it should be ie(1500 ish, 1300 ish) but then wouldnt appear when i restarted the game in full screen
https://cdn.discordapp.com/attachments/378413211453620227/542550049373028362/unknown.png
should be this:
https://cdn.discordapp.com/attachments/378413211453620227/542550460892971018/unknown.png
also it would be rather difficult to change the size and location for every gui menu
 
Last edited by a moderator:
Ok, it looks like you're scaling your screen. Look up the display_set_gui_maximise in the manual, it has arguments you can optionally supply that allow you to scale the GUI. You should be able to get it to scale the amount you want using those. If you can't, you might have to use display_set_gui_size(width,height), setting the width and height to the scaled width and height you want. The black box is being caused by your draw_rectangle command at the end of the code you posted.
 
B

BingleBop27

Guest
Ok, it looks like you're scaling your screen. Look up the display_set_gui_maximise in the manual, it has arguments you can optionally supply that allow you to scale the GUI. You should be able to get it to scale the amount you want using those. If you can't, you might have to use display_set_gui_size(width,height), setting the width and height to the scaled width and height you want. The black box is being caused by your draw_rectangle command at the end of the code you posted.
it kind of works but is still more broken than originally, game starts off like so:
https://media.discordapp.net/attachments/378413211453620227/542557679420440624/unknown.png
go to full screen just fine
https://cdn.discordapp.com/attachments/378413211453620227/542557795531227146/unknown.png
press R to restart and a black box for fading does not appear properly
https://cdn.discordapp.com/attachments/378413211453620227/542557902481915904/unknown.png
game restarted
https://media.discordapp.net/attachments/378413211453620227/542557956173201408/unknown.png?width=2356&height=1325
exit full screen
https://cdn.discordapp.com/attachments/378413211453620227/542558017388937227/unknown.png
restart small screen
https://cdn.discordapp.com/attachments/378413211453620227/542558085231673348/unknown.png

so for all the linked pictures but it was the easiest way to show this that i could think of, but before i used the gui maximise function it was working almost perfectly except the gui didnt appear where it should/ or at all, and with the gui Maximise the rectangles i draw dont appear where they should/ at all
 
The whole issue is that each time you do one of those things you are changing the dimensions of the window, perhaps resetting them, perhaps recalculating them. Each time you do that, you need to do the same thing to the GUI. It's impossible to know exactly without looking at the code you have now. Also, put your code inside the [ code][/code] tags without the space.
 
B

BingleBop27

Guest
The whole issue is that each time you do one of those things you are changing the dimensions of the window, perhaps resetting them, perhaps recalculating them. Each time you do that, you need to do the same thing to the GUI. It's impossible to know exactly without looking at the code you have now. Also, put your code inside the [ code][/code] tags without the space.
ok
on pressing 2:
Code:
if(!window_get_fullscreen())
{
    window_set_fullscreen(true);
    display_set_gui_maximize(4, 3, 1, 1);
}
else
{
    window_set_fullscreen(false);
    display_set_gui_maximize(1, 1, 0, 0);
 
}
pressing R
Code:
if(!window_get_fullscreen())
{
    Transition(Trans_Mode.RESTART);
    display_set_gui_maximize(4, 3, 1, 1);
}
else
{
    Transition(Trans_Mode.RESTART);
    display_set_gui_maximize(1, 1, 0, 0);
  
}
menu create event
Code:
gui_width = display_get_gui_width();
gui_height = display_get_gui_height();
gui_margin = gui_height / 5;
menu_x = gui_width + 400;
menu_y = gui_height - gui_margin;
menu_x_target = gui_width / 2;
menu_speed = 25;
menu_font = Fon_MMenu;
menu_itemheight = font_get_size(menu_font);
menu_committed = -1;
menu_control = true;
menu[2] = "Continue";
menu[1] = "New Game";
menu[0] = "Quit";
menu_items = array_length_1d(menu);
menu_cursor = 2;
new_save = false;
menu step event
Code:
//item eases in
menu_x += (menu_x_target - menu_x) / menu_speed;
// keyboard control
if(menu_control)
{
    if(keyboard_check_pressed(vk_up) || keyboard_check_pressed(ord("W")))
    {
        menu_cursor++
        if(menu_cursor >= menu_items) menu_cursor = 0;
    }
    if(keyboard_check_pressed(vk_down) || keyboard_check_pressed(ord("S")))
    {
        menu_cursor--
        if(menu_cursor < 0) menu_cursor = menu_items - 1;
    }
    if(keyboard_check_pressed(vk_enter))
    {
        menu_x_target = - 400;
        menu_committed = menu_cursor;
        ScreenShake(3, 1)
        menu_control = false;
     
    }
}
if((menu_x < 0) && (menu_committed != -1))
{
    switch (menu_committed)
    {
        case 1:
        {
            new_save = true
            if(new_save)//file1 new game
            {
                Data.SaveFile = "File1.dat";
                game_save(Data.SaveFile);
                Transition(Trans_Mode.GOTO, room0_0, true);
                break;
            }
        }
        case 2:
        {
            //file 1 load
                if(file_exists("File1.dat"))
                {
                    Data.SaveFile = "File1.dat";
                    Transition(Trans_Mode.load);
                 
                    break;
                }
                else Transition(Trans_Mode.RESTART); break;
            }
        case 0: game_end(); break;
    }
 
 
}
menu draw gui event
Code:
DrawText(menu_font, c_white, fa_center , fa_bottom);
for( var i = 0; i < menu_items; i++)
{
    var offset = 2
    var txt = menu[i];
    if(menu_cursor == i)
    {
        txt = string_insert("> ", txt, 0);
        var col = c_white;
    }
    else var col = c_gray;
 
    var xx = menu_x;
    var yy = menu_y - (menu_itemheight * i * 1.5);
    draw_set_color(c_black);
    draw_text(xx-offset ,yy, txt);
    draw_text(xx+offset,yy,txt);
    draw_text(xx,yy-offset,txt);
    draw_text(xx,yy-offset,txt);
    draw_set_color(col);
    draw_text(xx,yy,txt);
 
}
draw_set_color(c_black);
draw_rectangle(gui_width, 0, gui_width+1000, gui_height, false)
draw_rectangle(0, 0, -1000, gui_height, false)
edit: accidentally had the wrong R press code in
 
Last edited by a moderator:
Top