[solved]Full screen settings saving

jf_knight

Member
I want to have the user click a settings menu button and toggle through "full screen" and "windowed" settings (everyone is familiar with this common function, right?). I've encountered a problem where I can toggle through the settings but the change wont save (it reverts back to its default setting every time the game starts). I'm using an .ini file to save this settings. Here is what I have...
- in a PERSISTANT object I have pasted on the starting room, in a "create" event...

Code:
ini_open("game_settings.ini");

full = ini_read_real("settings","full",0);

ini_close();
scr_fullscreen();
- on a script, activated when the button is hit, I have...

Code:
if (window_get_fullscreen() == false)
    {
        var fullscreen = 0;
    }
else if (window_get_fullscreen() == true)
    {
        fullscreen = 1;
    }
    
 
    window_set_fullscreen(fullscreen);
    ini_open("game_settings.ini");
    ini_write_real("settings","full",fullscreen);
    scr_fullscreen();
- Finally, in the "scr_fullscreen" script, I have

Code:
if (window_get_fullscreen() == false)
    {
        var full = 1;
    }
else if (window_get_fullscreen() == true)
    {
        full = 0;
    }     

    if (full == 1)
        {
            window_set_fullscreen(true);
            
        }
    else
            window_set_fullscreen(false);
 
Z

zendraw

Guest
why are you overcomplicating things?
var scr=ini_read_real(screen)
if (scr) {if (window_get_fullscreen()==false) {window_set_fullscreen(true)}}
else {if (window_get_fullscreen()==true) {window_set_fullscreen(false)}}
 

jf_knight

Member
why are you overcomplicating things?
var scr=ini_read_real(screen)
if (scr) {if (window_get_fullscreen()==false) {window_set_fullscreen(true)}}
else {if (window_get_fullscreen()==true) {window_set_fullscreen(false)}}
And where, dear sir, shall I place these beautifully crafted lines of code?
 

sylvain_l

Member
you know that your scr_fullscreen is really 💩💩💩💩y (if not fullscreen you declare full as a local var, while if fullscreen; it's instance variable you force to be 0 ) and you use it to switch when pressing the switch button, while in the mean time you try to use it to aplly the settings from your ini file !

edit: ^^" ok you save in the game_settings the opposite of the wanted settings ?! (sounds counter intuitive for me how you handle that) edit2: in fact your scr_fullscreen doesn't care what's in the ini
 
Last edited:

jf_knight

Member
Good news everyone! I managed to fix this myself. Here is how I did it...
I put this in the object;Create...
Code:
ini_open("game_settings.ini");

full = ini_read_real("settings","full",0);

ini_close();

if (full == 1)
    window_set_fullscreen(true);
else
    window_set_fullscreen(false);
   
   
scr_resolution();

And this in the script...
Code:
if (window_get_fullscreen() == false)
    {
        var fullscreen = 1;
       
        window_set_fullscreen(fullscreen);
        ini_open("game_settings.ini");
        ini_write_real("settings","full",fullscreen);
        ini_close();
       
    }
else if (window_get_fullscreen() == true)
    {
        fullscreen = 0;
   
        window_set_fullscreen(fullscreen);
        ini_open("game_settings.ini");
        ini_write_real("settings","full",fullscreen);
        ini_close();
    }
Problem solved. :)
 
Last edited:
Top