mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-14 19:25:16 -05:00
Merge branch 'lemz1/fps-setting' into rewrite/master
This commit is contained in:
commit
4af4c2defc
4 changed files with 42 additions and 8 deletions
|
@ -2,6 +2,7 @@ package;
|
|||
|
||||
import flixel.FlxGame;
|
||||
import flixel.FlxState;
|
||||
import funkin.Preferences;
|
||||
import funkin.util.logging.CrashHandler;
|
||||
import funkin.ui.debug.MemoryCounter;
|
||||
import funkin.save.Save;
|
||||
|
@ -22,12 +23,6 @@ class Main extends Sprite
|
|||
var gameHeight:Int = 720; // Height of the game in pixels (might be less / more in actual pixels depending on your zoom).
|
||||
var initialState:Class<FlxState> = funkin.InitState; // The FlxState the game starts with.
|
||||
var zoom:Float = -1; // If -1, zoom is automatically calculated to fit the window dimensions.
|
||||
#if (web || CHEEMS)
|
||||
var framerate:Int = 60; // How many frames per second the game should run at.
|
||||
#else
|
||||
// TODO: This should probably be in the options menu?
|
||||
var framerate:Int = 144; // How many frames per second the game should run at.
|
||||
#end
|
||||
var skipSplash:Bool = true; // Whether to skip the flixel splash screen that appears in release mode.
|
||||
var startFullscreen:Bool = false; // Whether to start the game in fullscreen on desktop targets
|
||||
|
||||
|
@ -109,7 +104,7 @@ class Main extends Sprite
|
|||
|
||||
// George recommends binding the save before FlxGame is created.
|
||||
Save.load();
|
||||
var game:FlxGame = new FlxGame(gameWidth, gameHeight, initialState, framerate, framerate, skipSplash, startFullscreen);
|
||||
var game:FlxGame = new FlxGame(gameWidth, gameHeight, initialState, Preferences.framerate, Preferences.framerate, skipSplash, startFullscreen);
|
||||
|
||||
// FlxG.game._customSoundTray wants just the class, it calls new from
|
||||
// create() in there, which gets called when it's added to stage
|
||||
|
|
|
@ -7,6 +7,35 @@ import funkin.save.Save;
|
|||
*/
|
||||
class Preferences
|
||||
{
|
||||
/**
|
||||
* FPS
|
||||
* @default `60`
|
||||
*/
|
||||
public static var framerate(get, set):Int;
|
||||
|
||||
static function get_framerate():Int
|
||||
{
|
||||
#if web
|
||||
return 60;
|
||||
#else
|
||||
return Save?.instance?.options?.framerate ?? 60;
|
||||
#end
|
||||
}
|
||||
|
||||
static function set_framerate(value:Int):Int
|
||||
{
|
||||
#if web
|
||||
return 60;
|
||||
#else
|
||||
var save:Save = Save.instance;
|
||||
save.options.framerate = value;
|
||||
save.flush();
|
||||
FlxG.updateFramerate = value;
|
||||
FlxG.drawFramerate = value;
|
||||
return value;
|
||||
#end
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether some particularly fowl language is displayed.
|
||||
* @default `true`
|
||||
|
|
|
@ -91,6 +91,7 @@ class Save
|
|||
options:
|
||||
{
|
||||
// Reasonable defaults.
|
||||
framerate: 60,
|
||||
naughtyness: true,
|
||||
downscroll: false,
|
||||
flashingLights: true,
|
||||
|
@ -1141,6 +1142,12 @@ typedef SaveScoreTallyData =
|
|||
*/
|
||||
typedef SaveDataOptions =
|
||||
{
|
||||
/**
|
||||
* FPS
|
||||
* @default `60`
|
||||
*/
|
||||
var framerate:Int;
|
||||
|
||||
/**
|
||||
* Whether some particularly fowl language is displayed.
|
||||
* @default `true`
|
||||
|
|
|
@ -77,6 +77,10 @@ class PreferencesMenu extends Page
|
|||
createPrefItemCheckbox('Unlocked Framerate', 'Enable to unlock the framerate', function(value:Bool):Void {
|
||||
Preferences.unlockedFramerate = value;
|
||||
}, Preferences.unlockedFramerate);
|
||||
#else
|
||||
createPrefItemNumber('FPS', 'The maximum framerate that the game targets', function(value:Float) {
|
||||
Preferences.framerate = Std.int(value);
|
||||
}, null, Preferences.framerate, 30, 300, 5, 0);
|
||||
#end
|
||||
}
|
||||
|
||||
|
@ -87,7 +91,6 @@ class PreferencesMenu extends Page
|
|||
// Indent the selected item.
|
||||
items.forEach(function(daItem:TextMenuItem) {
|
||||
var thyOffset:Int = 0;
|
||||
|
||||
// Initializing thy text width (if thou text present)
|
||||
var thyTextWidth:Int = 0;
|
||||
if (Std.isOfType(daItem, EnumPreferenceItem)) thyTextWidth = cast(daItem, EnumPreferenceItem).lefthandText.getWidth();
|
||||
|
|
Loading…
Reference in a new issue