2023-10-17 00:38:28 -04:00
|
|
|
package funkin;
|
|
|
|
|
|
|
|
import funkin.save.Save;
|
|
|
|
|
|
|
|
/**
|
2023-11-07 04:04:22 -05:00
|
|
|
* A core class which provides a store of user-configurable, globally relevant values.
|
2023-10-17 00:38:28 -04:00
|
|
|
*/
|
|
|
|
class Preferences
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Whether some particularly fowl language is displayed.
|
|
|
|
* @default `true`
|
|
|
|
*/
|
|
|
|
public static var naughtyness(get, set):Bool;
|
|
|
|
|
|
|
|
static function get_naughtyness():Bool
|
|
|
|
{
|
2024-04-30 19:30:11 -04:00
|
|
|
return Save?.instance?.options?.naughtyness;
|
2023-10-17 00:38:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static function set_naughtyness(value:Bool):Bool
|
|
|
|
{
|
2024-03-16 22:20:22 -04:00
|
|
|
var save:Save = Save.instance;
|
2024-02-15 21:34:24 -05:00
|
|
|
save.options.naughtyness = value;
|
|
|
|
save.flush();
|
|
|
|
return value;
|
2023-10-17 00:38:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If enabled, the strumline is at the bottom of the screen rather than the top.
|
|
|
|
* @default `false`
|
|
|
|
*/
|
|
|
|
public static var downscroll(get, set):Bool;
|
|
|
|
|
|
|
|
static function get_downscroll():Bool
|
|
|
|
{
|
2024-04-30 19:30:11 -04:00
|
|
|
return Save?.instance?.options?.downscroll;
|
2023-10-17 00:38:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static function set_downscroll(value:Bool):Bool
|
|
|
|
{
|
2024-03-16 22:20:22 -04:00
|
|
|
var save:Save = Save.instance;
|
2024-02-15 21:34:24 -05:00
|
|
|
save.options.downscroll = value;
|
|
|
|
save.flush();
|
|
|
|
return value;
|
2023-10-17 00:38:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If disabled, flashing lights in the main menu and other areas will be less intense.
|
|
|
|
* @default `true`
|
|
|
|
*/
|
|
|
|
public static var flashingLights(get, set):Bool;
|
|
|
|
|
|
|
|
static function get_flashingLights():Bool
|
|
|
|
{
|
2024-04-29 19:28:47 -04:00
|
|
|
return Save?.instance?.options?.flashingLights ?? true;
|
2023-10-17 00:38:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static function set_flashingLights(value:Bool):Bool
|
|
|
|
{
|
2024-03-16 22:20:22 -04:00
|
|
|
var save:Save = Save.instance;
|
2024-02-15 21:34:24 -05:00
|
|
|
save.options.flashingLights = value;
|
|
|
|
save.flush();
|
|
|
|
return value;
|
2023-10-17 00:38:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If disabled, the camera bump synchronized to the beat.
|
|
|
|
* @default `false`
|
|
|
|
*/
|
|
|
|
public static var zoomCamera(get, set):Bool;
|
|
|
|
|
|
|
|
static function get_zoomCamera():Bool
|
|
|
|
{
|
2024-03-04 16:37:42 -05:00
|
|
|
return Save.instance.options.zoomCamera;
|
2023-10-17 00:38:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static function set_zoomCamera(value:Bool):Bool
|
|
|
|
{
|
2024-03-16 22:20:22 -04:00
|
|
|
var save:Save = Save.instance;
|
2024-02-15 21:34:24 -05:00
|
|
|
save.options.zoomCamera = value;
|
|
|
|
save.flush();
|
|
|
|
return value;
|
2023-10-17 00:38:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If enabled, an FPS and memory counter will be displayed even if this is not a debug build.
|
|
|
|
* @default `false`
|
|
|
|
*/
|
|
|
|
public static var debugDisplay(get, set):Bool;
|
|
|
|
|
|
|
|
static function get_debugDisplay():Bool
|
|
|
|
{
|
2024-04-30 19:30:11 -04:00
|
|
|
return Save?.instance?.options?.debugDisplay;
|
2023-10-17 00:38:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static function set_debugDisplay(value:Bool):Bool
|
|
|
|
{
|
2024-03-04 16:37:42 -05:00
|
|
|
if (value != Save.instance.options.debugDisplay)
|
2023-10-17 00:38:28 -04:00
|
|
|
{
|
|
|
|
toggleDebugDisplay(value);
|
|
|
|
}
|
|
|
|
|
2024-03-04 16:37:42 -05:00
|
|
|
var save = Save.instance;
|
2024-02-15 21:34:24 -05:00
|
|
|
save.options.debugDisplay = value;
|
|
|
|
save.flush();
|
|
|
|
return value;
|
2023-10-17 00:38:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If enabled, the game will automatically pause when tabbing out.
|
|
|
|
* @default `true`
|
|
|
|
*/
|
|
|
|
public static var autoPause(get, set):Bool;
|
|
|
|
|
|
|
|
static function get_autoPause():Bool
|
|
|
|
{
|
2024-04-30 08:13:39 -04:00
|
|
|
return Save?.instance?.options?.autoPause ?? true;
|
2023-10-17 00:38:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static function set_autoPause(value:Bool):Bool
|
|
|
|
{
|
2024-03-04 16:37:42 -05:00
|
|
|
if (value != Save.instance.options.autoPause) FlxG.autoPause = value;
|
2023-10-17 00:38:28 -04:00
|
|
|
|
2024-03-16 22:20:22 -04:00
|
|
|
var save:Save = Save.instance;
|
2024-02-15 21:34:24 -05:00
|
|
|
save.options.autoPause = value;
|
|
|
|
save.flush();
|
|
|
|
return value;
|
2023-10-17 00:38:28 -04:00
|
|
|
}
|
|
|
|
|
2024-03-16 22:20:22 -04:00
|
|
|
/**
|
|
|
|
* Loads the user's preferences from the save data and apply them.
|
|
|
|
*/
|
2023-10-17 00:38:28 -04:00
|
|
|
public static function init():Void
|
|
|
|
{
|
2024-03-16 22:20:22 -04:00
|
|
|
// Apply the autoPause setting (enables automatic pausing on focus lost).
|
2023-10-17 00:38:28 -04:00
|
|
|
FlxG.autoPause = Preferences.autoPause;
|
2024-03-16 22:20:22 -04:00
|
|
|
// Apply the debugDisplay setting (enables the FPS and RAM display).
|
2023-10-17 00:38:28 -04:00
|
|
|
toggleDebugDisplay(Preferences.debugDisplay);
|
|
|
|
}
|
|
|
|
|
|
|
|
static function toggleDebugDisplay(show:Bool):Void
|
|
|
|
{
|
|
|
|
if (show)
|
|
|
|
{
|
|
|
|
// Enable the debug display.
|
|
|
|
FlxG.stage.addChild(Main.fpsCounter);
|
|
|
|
#if !html5
|
|
|
|
FlxG.stage.addChild(Main.memoryCounter);
|
|
|
|
#end
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Disable the debug display.
|
|
|
|
FlxG.stage.removeChild(Main.fpsCounter);
|
|
|
|
#if !html5
|
|
|
|
FlxG.stage.removeChild(Main.memoryCounter);
|
|
|
|
#end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|