feat: Add a setting that automatically launches the game in fullscreen

This commit is contained in:
Abnormal 2024-10-19 20:18:14 -05:00 committed by Eric
parent 7058126e99
commit ee53ccd327
3 changed files with 32 additions and 0 deletions
source/funkin

View file

@ -157,6 +157,25 @@ class Preferences
return value;
}
/**
* If enabled, the game will automatically launch in fullscreen on startup.
* @default `true`
*/
public static var autoFullscreen(get, set):Bool;
static function get_autoFullscreen():Bool
{
return Save?.instance?.options?.autoFullscreen ?? true;
}
static function set_autoFullscreen(value:Bool):Bool
{
var save:Save = Save.instance;
save.options.autoFullscreen = value;
save.flush();
return value;
}
public static var unlockedFramerate(get, set):Bool;
static function get_unlockedFramerate():Bool
@ -211,6 +230,8 @@ class Preferences
#if web
toggleFramerateCap(Preferences.unlockedFramerate);
#end
// Apply the autoFullscreen setting (launches the game in fullscreen automatically)
FlxG.fullscreen = Preferences.autoFullscreen;
}
static function toggleFramerateCap(unlocked:Bool):Void

View file

@ -97,6 +97,7 @@ class Save
zoomCamera: true,
debugDisplay: false,
autoPause: true,
autoFullscreen: false,
inputOffset: 0,
audioVisualOffset: 0,
unlockedFramerate: false,
@ -1339,6 +1340,12 @@ typedef SaveDataOptions =
*/
var autoPause:Bool;
/**
* If enabled, the game will automatically launch in fullscreen on startup.
* @default `true`
*/
var autoFullscreen:Bool;
/**
* Offset the user's inputs by this many ms.
* @default `0`

View file

@ -124,6 +124,10 @@ class PreferencesMenu extends Page
Preferences.framerate = Std.int(value);
}, null, Preferences.framerate, 30, 300, 5, 0);
#end
createPrefItemCheckbox('Launch in Fullscreen', 'Automatically launch the game in fullscreen on startup', function(value:Bool):Void {
Preferences.autoFullscreen = value;
}, Preferences.autoFullscreen);
}
override function update(elapsed:Float):Void