diff --git a/source/Data.hx b/source/Data.hx index 07607c9..cab450f 100644 --- a/source/Data.hx +++ b/source/Data.hx @@ -6,10 +6,10 @@ import flixel.input.keyboard.FlxKey; import flixel.graphics.FlxGraphic; import Controls; -// There must be all data about engine vars... There is only one at the moment -w-" - Xale class EngineData { public static var modEngineVersion:String = 'b0.0.3.2'; + public static var isCachingEnabled:Bool = true; // Note: Cache won't work if you run game with debug - Xale } class ClientPrefs { @@ -27,9 +27,9 @@ class ClientPrefs { public static var hideHud:Bool = false; public static var noteOffset:Int = 0; public static var arrowHSV:Array> = [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]; - public static var imagesPersist:Bool = false; public static var ghostTapping:Bool = true; public static var hideTime:Bool = false; + public static var caching:Bool = true; public static var defaultKeys:Array = [ A, LEFT, //Note Left @@ -82,15 +82,20 @@ class ClientPrefs { FlxG.save.data.noteOffset = noteOffset; FlxG.save.data.hideHud = hideHud; FlxG.save.data.arrowHSV = arrowHSV; - FlxG.save.data.imagesPersist = imagesPersist; FlxG.save.data.ghostTapping = ghostTapping; FlxG.save.data.hideTime = hideTime; + FlxG.save.data.caching = caching; + //caching = FlxG.save.data.caching; var save:FlxSave = new FlxSave(); save.bind('controls', 'xale'); //Placing this in a separate save so that it can be manually deleted without removing your Score and stuff save.data.customControls = lastControls; save.flush(); FlxG.log.add("Settings saved!"); + + if(FlxG.save.data.caching != null) + trace('That is ok'); + trace(caching); } public static function loadPrefs() { @@ -140,16 +145,15 @@ class ClientPrefs { if(FlxG.save.data.arrowHSV != null) { arrowHSV = FlxG.save.data.arrowHSV; } - if(FlxG.save.data.imagesPersist != null) { - imagesPersist = FlxG.save.data.imagesPersist; - FlxGraphic.defaultPersist = ClientPrefs.imagesPersist; - } if(FlxG.save.data.ghostTapping != null) { ghostTapping = FlxG.save.data.ghostTapping; } if(FlxG.save.data.hideTime != null) { hideTime = FlxG.save.data.hideTime; } + if(FlxG.save.data.caching != null) { + caching = FlxG.save.data.caching; + } var save:FlxSave = new FlxSave(); save.bind('controls', 'xale'); @@ -192,6 +196,13 @@ class ClientPrefs { } } } + + public static function getCaching() + { + caching = FlxG.save.data.caching; + return caching; + } + } class WeekData { diff --git a/source/GameMenuState.hx b/source/GameMenuState.hx index 82a767f..2b8aa42 100644 --- a/source/GameMenuState.hx +++ b/source/GameMenuState.hx @@ -58,9 +58,11 @@ class MainMenuState extends MusicBeatState public static var camFollow:FlxObject; public static var camFollowPos:FlxObject; - + public static var caching:Bool; + override function create() { + trace(caching); TitleState.isLogoLoaded = false; #if desktop DiscordClient.changePresence("In the Menu", null); @@ -1194,7 +1196,7 @@ class OptionsState extends MusicBeatState override function create() { #if desktop - DiscordClient.changePresence("Options Menu", null); + DiscordClient.changePresence("In the Options Menu", null); #end @@ -1839,14 +1841,15 @@ class PreferencesSubstate extends MusicBeatSubstate 'Note Delay' ]; - static var options:Array = [ + static var options:Array = [ 'GRAPHICS', 'Low Quality', 'Anti-Aliasing', - 'Persistent Cached Data', + #if !html5 'Framerate', //Apparently 120FPS isn't correctly supported on Browser? Probably it has some V-Sync shit enabled by default, idk #end + 'GAMEPLAY', 'Downscroll', 'Ghost Tapping', @@ -1855,6 +1858,7 @@ class PreferencesSubstate extends MusicBeatSubstate 'Hide HUD', 'Flashing Lights', 'Camera Zooms' + #if !mobile ,'FPS Counter' #end @@ -1872,6 +1876,31 @@ class PreferencesSubstate extends MusicBeatSubstate public function new() { + if(EngineData.isCachingEnabled) + options = [ + 'GAMEPLAY', + 'Data Cache', + 'Downscroll', + 'Ghost Tapping', + 'Note Delay', + 'Note Splashes', + 'Hide HUD', + 'Flashing Lights', + 'Camera Zooms', + + #if !mobile + 'FPS Counter', + #end + + 'GRAPHICS', + 'Low Quality', + 'Anti-Aliasing', + + #if !html5 + 'Framerate', + #end + ]; + super(); characterLayer = new FlxTypedGroup(); add(characterLayer); @@ -2023,7 +2052,7 @@ class PreferencesSubstate extends MusicBeatSubstate case 'Middlescroll': ClientPrefs.middleScroll = !ClientPrefs.middleScroll; - case 'Ghost Tapping': + case 'Ghost Tapping': ClientPrefs.ghostTapping = !ClientPrefs.ghostTapping; case 'Camera Zooms': @@ -2032,9 +2061,8 @@ class PreferencesSubstate extends MusicBeatSubstate case 'Hide HUD': ClientPrefs.hideHud = !ClientPrefs.hideHud; - case 'Persistent Cached Data': - ClientPrefs.imagesPersist = !ClientPrefs.imagesPersist; - FlxGraphic.defaultPersist = ClientPrefs.imagesPersist; + case 'Data Cache': + ClientPrefs.caching = !ClientPrefs.caching; } FlxG.sound.play(Paths.sound('scrollMenu')); reloadValues(); @@ -2104,15 +2132,15 @@ class PreferencesSubstate extends MusicBeatSubstate daText = "If unchecked, hides FPS Counter."; case 'Low Quality': daText = "If checked, disables some background details,\ndecreases loading times and improves performance."; - case 'Persistent Cached Data': - daText = "If checked, images loaded will stay in memory\nuntil the game is closed, this increases memory usage,\nbut basically makes reloading times instant."; + case 'Data Cache': + daText = "If checked, loaded images will stay in memory.\nThis will make all loadings faster"; case 'Anti-Aliasing': daText = "If unchecked, disables anti-aliasing, increases performance\nat the cost of the graphics not looking as smooth."; case 'Downscroll': daText = "If checked, notes go Down instead of Up, simple enough."; case 'Middlescroll': daText = "If checked, hides Opponent's notes and your notes get centered."; - case 'Ghost Tapping': + case 'Ghost Tapping': daText = "If checked, you won't get misses from pressing keys\nwhile there are no notes able to be hit."; case 'Swearing': daText = "If unchecked, your mom won't be angry at you."; @@ -2214,8 +2242,8 @@ class PreferencesSubstate extends MusicBeatSubstate daValue = ClientPrefs.camZooms; case 'Hide HUD': daValue = ClientPrefs.hideHud; - case 'Persistent Cached Data': - daValue = ClientPrefs.imagesPersist; + case 'Data Cache': + daValue = ClientPrefs.caching; } checkbox.daValue = daValue; } diff --git a/source/LoaderState.hx b/source/LoaderState.hx new file mode 100644 index 0000000..247ff0a --- /dev/null +++ b/source/LoaderState.hx @@ -0,0 +1,149 @@ +package; + +import Data; +import flixel.FlxState; +import flixel.FlxG; +import GameMenuState; +import flixel.util.FlxSave; + +class FakeData { + public static var downScroll:Bool = false; + public static var middleScroll:Bool = false; + public static var showFPS:Bool = true; + public static var flashing:Bool = true; + public static var globalAntialiasing:Bool = true; + public static var noteSplashes:Bool = true; + public static var lowQuality:Bool = false; + public static var framerate:Int = 60; + public static var cursing:Bool = true; + public static var violence:Bool = true; + public static var camZooms:Bool = true; + public static var hideHud:Bool = false; + public static var noteOffset:Int = 0; + public static var arrowHSV:Array> = [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]; + public static var ghostTapping:Bool = true; + public static var hideTime:Bool = false; + public static var caching:Bool = true; + + public static function saveSettings() { + FlxG.save.data.downScroll = downScroll; + FlxG.save.data.middleScroll = middleScroll; + FlxG.save.data.showFPS = showFPS; + FlxG.save.data.flashing = flashing; + FlxG.save.data.globalAntialiasing = globalAntialiasing; + FlxG.save.data.noteSplashes = noteSplashes; + FlxG.save.data.lowQuality = lowQuality; + FlxG.save.data.framerate = framerate; + FlxG.save.data.cursing = cursing; + FlxG.save.data.violence = violence; + FlxG.save.data.camZooms = camZooms; + FlxG.save.data.noteOffset = noteOffset; + FlxG.save.data.hideHud = hideHud; + FlxG.save.data.arrowHSV = arrowHSV; + FlxG.save.data.ghostTapping = ghostTapping; + FlxG.save.data.hideTime = hideTime; + FlxG.save.data.caching = caching; + //caching = FlxG.save.data.caching; + + var save:FlxSave = new FlxSave(); + save.bind('controls', 'xale'); //Placing this in a separate save so that it can be manually deleted without removing your Score and stuff + save.flush(); + FlxG.log.add("Settings saved!"); + + if(FlxG.save.data.caching != null) + trace('That is ok'); + trace(caching); + } + + public static function loadPrefs() { + if(FlxG.save.data.downScroll != null) { + downScroll = FlxG.save.data.downScroll; + } + if(FlxG.save.data.middleScroll != null) { + middleScroll = FlxG.save.data.middleScroll; + } + if(FlxG.save.data.showFPS != null) { + showFPS = FlxG.save.data.showFPS; + if(Main.fpsVar != null) { + Main.fpsVar.visible = showFPS; + } + } + if(FlxG.save.data.flashing != null) { + flashing = FlxG.save.data.flashing; + } + if(FlxG.save.data.globalAntialiasing != null) { + globalAntialiasing = FlxG.save.data.globalAntialiasing; + } + if(FlxG.save.data.noteSplashes != null) { + noteSplashes = FlxG.save.data.noteSplashes; + } + if(FlxG.save.data.lowQuality != null) { + lowQuality = FlxG.save.data.lowQuality; + } + if(FlxG.save.data.framerate != null) { + framerate = FlxG.save.data.framerate; + if(framerate > FlxG.drawFramerate) { + FlxG.updateFramerate = framerate; + FlxG.drawFramerate = framerate; + } else { + FlxG.drawFramerate = framerate; + FlxG.updateFramerate = framerate; + } + } + if(FlxG.save.data.camZooms != null) { + camZooms = FlxG.save.data.camZooms; + } + if(FlxG.save.data.hideHud != null) { + hideHud = FlxG.save.data.hideHud; + } + if(FlxG.save.data.noteOffset != null) { + noteOffset = FlxG.save.data.noteOffset; + } + if(FlxG.save.data.arrowHSV != null) { + arrowHSV = FlxG.save.data.arrowHSV; + } + if(FlxG.save.data.ghostTapping != null) { + ghostTapping = FlxG.save.data.ghostTapping; + } + if(FlxG.save.data.hideTime != null) { + hideTime = FlxG.save.data.hideTime; + } + if(FlxG.save.data.caching != null) { + caching = FlxG.save.data.caching; + } + + var save:FlxSave = new FlxSave(); + save.bind('controls', 'xale'); + } + + public static function getCaching() + { + caching = FlxG.save.data.caching; + return caching; + } +} + +class LoaderState extends MusicBeatState +{ + var caching = FakeData.caching; + override function create() + { + ClientPrefs.saveSettings(); + trace(caching); + trace(EngineData.isCachingEnabled); + + trace('It is working'); + #if debug + FlxG.switchState(new TitleState()); + #end + + #if !debug + if(EngineData.isCachingEnabled && caching) + FlxG.switchState(new Caching()); + else + FlxG.switchState(new TitleState()); + #end + + super.create(); + } +} diff --git a/source/Main.hx b/source/Main.hx index 2a1a043..ba1551e 100644 --- a/source/Main.hx +++ b/source/Main.hx @@ -10,6 +10,7 @@ import openfl.display.Sprite; import openfl.events.Event; import Data; import VideoState; +import LoaderState; #if cpp import webm.WebmPlayer; @@ -19,7 +20,9 @@ class Main extends Sprite { var gameWidth:Int = 1280; // Width of the game in pixels (might be less / more in actual pixels depending on your zoom). var gameHeight:Int = 720; // Height of the game in pixels (might be less / more in actual pixels depending on your zoom). - var initialState:Class = Caching; // The FlxState the game starts with. + + var initialState:Class = LoaderState; + var zoom:Float = -1; // If -1, zoom is automatically calculated to fit the window dimensions. var framerate:Int = 60; // How many frames per second the game should run at. var skipSplash:Bool = true; // Whether to skip the flixel splash screen that appears in release mode. @@ -71,15 +74,11 @@ class Main extends Sprite gameHeight = Math.ceil(stageHeight / zoom); } - #if !debug - initialState = TitleState; - #end - #if !mobile addChild(new FPS(10, 3, 0xFFFFFF)); #end - addChild(new FlxGame(gameWidth, gameHeight, initialState, zoom, framerate, framerate, skipSplash, startFullscreen)); + addChild(new FlxGame(gameWidth, gameHeight, LoaderState, zoom, framerate, framerate, skipSplash, startFullscreen)); var ourSource:String = "assets/videos/daWeirdVid/dontDelete.webm"; diff --git a/source/MusicBeatState.hx b/source/MusicBeatState.hx index fd0878d..7e5b531 100644 --- a/source/MusicBeatState.hx +++ b/source/MusicBeatState.hx @@ -28,11 +28,6 @@ class MusicBeatState extends FlxUIState return PlayerSettings.player1.controls; override function create() { - #if MODS_ALLOWED - if(!ClientPrefs.imagesPersist) { - Paths.customImagesLoaded.clear(); - } - #end super.create(); // Custom made Trans out diff --git a/source/TitleState.hx b/source/TitleState.hx index e771b9c..47f1034 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -73,6 +73,7 @@ class TitleState extends MusicBeatState } } #end + FlxG.game.focusLostFramerate = 60; FlxG.sound.muteKeys = muteKeys; FlxG.sound.volumeDownKeys = volumeDownKeys;