Skip to content

Commit

Permalink
auto fullscreen option
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesisfeline committed Oct 20, 2024
1 parent 714e9bd commit 612e0ff
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
25 changes: 24 additions & 1 deletion source/funkin/Preferences.hx
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,27 @@ class Preferences
return value;
}

/**
* If enabled, the game will automatically launch in fullscreen on startup.
*
* This does not apply on mobile devices.
* @default `false`
*/
public static var autoFullscreen(get, set):Bool;

static function get_autoFullscreen():Bool
{
return Save?.instance?.options?.autoFullscreen ?? false;
}

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
Expand Down Expand Up @@ -458,14 +479,16 @@ class Preferences
*/
public static function init():Void
{
// Apply the autoPause setting (enables automatic pausing on focus lost).
// Apply the autoPause setting (enables automatic pausing when losing focus).
FlxG.autoPause = Preferences.autoPause;
flixel.FlxSprite.defaultAntialiasing = Preferences.antialiasing;
// Apply the debugDisplay setting (enables the FPS and RAM display).
toggleDebugDisplay(Preferences.debugDisplay);
#if web
toggleFramerateCap(Preferences.unlockedFramerate);
#end
// Apply the autoFullscreen setting (launches the game in fullscreen automatically)
FlxG.fullscreen = Preferences.autoFullscreen;
#if mobile
// Apply the allowScreenTimeout setting (enables screen timeout).
lime.system.System.allowScreenTimeout = Preferences.screenTimeout;
Expand Down
9 changes: 9 additions & 0 deletions source/funkin/save/Save.hx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class Save
showTimings: true,
debugDisplay: true,
autoPause: true,
autoFullscreen: false,
laneAlpha: 0,
strumAlpha: 100,
badsShitsCauseMiss: false,
Expand Down Expand Up @@ -1396,6 +1397,14 @@ typedef SaveDataOptions =
*/
var autoPause:Bool;

/**
* If enabled, the game will automatically launch in fullscreen on startup.
*
* This does not apply to mobile devices, obviously, hence why it only shows up on `desktop` and `web` platforms.
* @default `false`
*/
var autoFullscreen:Bool;

/**
* How transparent should the black underlay be under the lanes?
*
Expand Down
7 changes: 6 additions & 1 deletion source/funkin/ui/options/PreferencesMenu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ class PreferencesMenu extends Page
Preferences.judgeCounter = value;
yeahBf(value);
}, Preferences.judgeCounter);
#if (desktop || web)
createPrefItemCheckbox('Launch in Fullscreen', 'Enable to automatically launch the game in fullscreen on startup', function(value:Bool):Void {
Preferences.autoFullscreen = value;
}, Preferences.autoFullscreen);
#end
#if web
createPrefItemCheckbox('Unlocked Framerate', 'Enable to unlock the framerate', function(value:Bool):Void {
Preferences.unlockedFramerate = value;
Expand All @@ -253,7 +258,7 @@ class PreferencesMenu extends Page
else
FlxG.game.focusLostFramerate = Preferences.framerate;
yeahBf(false);
}, null, Preferences.framerate, #if mobile 60 #else 24 #end, 960, 1, 0);
}, null, Preferences.framerate, #if mobile 60 #else 24 #end, 360, 1, 0);
#end
createPrefHeader('Miscellaneous');
createPrefItemCheckbox('Naughtiness', 'Enable so your mom won\'t scream at ya, right now it doesn\'t do much', function(value:Bool):Void {
Expand Down

0 comments on commit 612e0ff

Please sign in to comment.