Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENHANCEMENT] Add an option to launch the game in fullscreen #3738

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions source/funkin/Preferences.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions source/funkin/save/Save.hx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class Save
zoomCamera: true,
debugDisplay: false,
autoPause: true,
autoFullscreen: false,
inputOffset: 0,
audioVisualOffset: 0,
unlockedFramerate: false,
Expand Down Expand Up @@ -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`
Expand Down
3 changes: 3 additions & 0 deletions source/funkin/ui/options/PreferencesMenu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ class PreferencesMenu extends Page
createPrefItemCheckbox('Auto Pause', 'If enabled, game automatically pauses when it loses focus.', function(value:Bool):Void {
Preferences.autoPause = value;
}, Preferences.autoPause);
createPrefItemCheckbox('Launch in Fullscreen', 'Automatically launch the game in fullscreen on startup', function(value:Bool):Void {
Preferences.autoFullscreen = value;
}, Preferences.autoFullscreen);

#if web
createPrefItemCheckbox('Unlocked Framerate', 'Enable to unlock the framerate', function(value:Bool):Void {
Expand Down
Loading