diff --git a/source/Cache.hx b/source/Cache.hx deleted file mode 100644 index 83c9b61..0000000 --- a/source/Cache.hx +++ /dev/null @@ -1,109 +0,0 @@ -package; - -import openfl.Assets; -import flixel.FlxG; - -using StringTools; - -// No this isn't gonna be a super complex cache system class, im way too dumb and lazy to do that - -class Cache -{ - inline public static function remove(path:String, library:Libraries):Void - { - final graphic = FlxG.bitmap.get(Paths.image(path, Std.string(library))); - - if (graphic != null) - FlxG.bitmap.remove(graphic); - else - trace('$path is null!'); - } - - inline public static function uncachCharacters():Void - { - var characters:Int = 0; - - @:privateAccess - for (key => i in FlxG.bitmap._cache) - { - // trace(key, key.contains('characters')); - - if (!key.contains('characters')) - continue; - else - characters++; - - final graphic = FlxG.bitmap.get(key); - - if (graphic != null) - { - if (graphic.persist) - continue; - - FlxG.bitmap.remove(graphic); - } - else - trace('$key is null!'); - } - - if (characters > 0) trace('Cleaned $characters character sprites from the cache.'); - } - - inline public static function check():Void - { - /* - @:privateAccess - for (key => i in FlxG.bitmap._cache) - { - trace("Cache key: " + key); - } - */ - } - - inline public static function length():Void - { - var length:Int = 0; - - @:privateAccess - for (key => i in FlxG.bitmap._cache) - { - length++; - } - - trace('Cached assets: $length.'); - } - - inline public static function clear():Void - { - check(); - - var lol = false; - if (lol) - { - length(); - - @:privateAccess - for (key => i in FlxG.bitmap._cache) - { - final graphic = FlxG.bitmap.get(key); - - if (graphic != null) - { - // if (!graphic.persist && graphic.destroyOnNoUse) - FlxG.bitmap.remove(graphic); - } - else - trace('$key is null!'); - } - - length(); - } - } -} - -enum Libraries -{ - DEFAULT; - PRELOAD; - SHARED; -} \ No newline at end of file diff --git a/source/CoolUtil.hx b/source/CoolUtil.hx index b036c43..a23b239 100644 --- a/source/CoolUtil.hx +++ b/source/CoolUtil.hx @@ -1,8 +1,17 @@ package; +import lime.app.Application; +import flixel.FlxSprite; +import openfl.filters.GlowFilter; +import Discord.DiscordClient; +import flixel.graphics.frames.FlxFilterFrames; +import data.GlobalData; import flixel.FlxG; import flixel.math.FlxMath; import states.PlayState; +import haxe.DynamicAccess; +import flixel.util.FlxAxes; + using StringTools; class CoolUtil @@ -14,10 +23,9 @@ class CoolUtil return Language.get('Difficulties', '$difficulty'); } - //Psych Engine inline public static function boundTo(value:Float, min:Float = 0, max:Float = 1):Float { - return Math.max(min, Math.min(max, value)); + return FlxMath.bound(value, min, max); } public static function getDialogue(?fromSection:String):Array @@ -26,22 +34,23 @@ class CoolUtil if (fromSection != null) { - var langDialogue:haxe.DynamicAccess = Language.getSection(fromSection); + var langDialogue:DynamicAccess = Language.getSection(fromSection); for (idx => val in langDialogue) { dialogue[Std.parseInt(idx)] = val; } + return dialogue; } - var song = states.PlayState.SONG.song; + var song = PlayState.SONG.song; var suffix:String = ''; - if ((!data.KadeEngineData.settings.data.mechanics || PlayState.storyDifficulty == 0) && Reflect.fields(Language.getSection('${song}_Dialogue_ALT')).length > 0) + if ((!GlobalData.settings.mechanicsEnabled || PlayState.storyDifficulty == 0) && Reflect.fields(Language.getSection('${song}_Dialogue_ALT')).length > 0) suffix = '_ALT'; // omg im so fucking smart - var langDialogue:haxe.DynamicAccess = Language.getSection('${song}_Dialogue' + suffix); + var langDialogue:DynamicAccess = Language.getSection('${song}_Dialogue' + suffix); for (idx => val in langDialogue) { dialogue[Std.parseInt(idx)] = val; @@ -50,50 +59,50 @@ class CoolUtil return dialogue; } - inline static public function sound(sound:String, library:String = '', volume:Float = 1) + static public function sound(sound:String, library:String = '', volume:Float = 1) { - flixel.FlxG.sound.play(Paths.sound(sound, library), volume); + FlxG.sound.play(Paths.sound(sound, library), volume); } /** - * Function that changes the `Discord Rich Presence`. - * @param state The second line in the presence (use it for misses). - * @param details The first line in the presence (use for current state and song details). - * @param hasStartTimestamp Time left indicator (ignore). - * @param endTimestamp End time indicator (ignore). - * @param smallImageKey The small image name. + * Function that changes the `Discord Rich Presence`. + * @param state The second line in the presence (use it for misses). + * @param details The first line in the presence (use for current state and song details). + * @param hasStartTimestamp Time left indicator (ignore). + * @param endTimestamp End time indicator (ignore). + * @param smallImageKey The small image name. **/ public static function presence(state:String, details:String, ?hasStartTimestamp:Bool, ?endTimestamp:Float, smallImageKey:String, addLittleIcon:Bool = false) { - Discord.DiscordClient.changePresence(state, details, hasStartTimestamp, endTimestamp, smallImageKey, addLittleIcon); + DiscordClient.changePresence(state, details, hasStartTimestamp, endTimestamp, smallImageKey, addLittleIcon); } public static function firstLetterUpperCase(string:String):String - { - //way shorter 😍 - return (string.charAt(0).toUpperCase() + string.substring(1, string.length)).replace('-', ' '); - } + { + // way shorter 😍 - yeah galo from the past you fucking love one-liners you stupid fuck 😍 + return (string.charAt(0).toUpperCase() + string.substring(1, string.length)).replace('-', ' '); + } public static function title(state:String, deleteAppTitle:Bool = false) { var daTitle:String = ""; if (!deleteAppTitle) - daTitle = Main.appTitle; + daTitle = 'Funkergarten' /* Main.appTitle */; if (state != null && state != "") daTitle = ('$daTitle - $state'); - lime.app.Application.current.window.title = daTitle; + Application.current.window.title = daTitle; } - public static function glow(sprite:flixel.FlxSprite, blurX:Int = 50, blurY = 50, color:Int = 0x000000):Void + public static function glow(sprite:FlxSprite, blurX:Int = 50, blurY = 50, color:Int = 0x000000):Void { - //long ass code for glow effect. Got it from https://haxeflixel.com/demos/FlxSpriteFilters - flixel.graphics.frames.FlxFilterFrames.fromFrames(sprite.frames, blurX, blurY, [new openfl.filters.GlowFilter(color, sprite.alpha, blurX, blurY, 3)]).applyToSprite(sprite, false, true); + // long ass code for glow effect. Got it from https://haxeflixel.com/demos/FlxSpriteFilters + FlxFilterFrames.fromFrames(sprite.frames, blurX, blurY, [new GlowFilter(color, sprite.alpha, blurX, blurY, 3)]).applyToSprite(sprite, false, true); } - public static function middleSprite(staticSprite:flixel.FlxSprite, toMoveSprite:flixel.FlxSprite, axes:flixel.util.FlxAxes):Void + public static function middleSprite(staticSprite:FlxSprite, toMoveSprite:FlxSprite, axes:FlxAxes):Void { var x = (staticSprite.x + (staticSprite.width / 2)) - (toMoveSprite.width / 2); var y = (staticSprite.y + (staticSprite.height / 2)) - (toMoveSprite.height / 2); @@ -103,7 +112,7 @@ class CoolUtil else if (axes == XY) toMoveSprite.setPosition(x, y); } - public static function size(sprite:flixel.FlxSprite, mult:Float, updateHitbox:Bool = true, height:Bool = false):Void + public static function size(sprite:FlxSprite, mult:Float, updateHitbox:Bool = true, height:Bool = false):Void { if (!height) sprite.setGraphicSize(Std.int(sprite.width * mult)); @@ -123,7 +132,7 @@ class CoolUtil public static function overlaps(spr:flixel.FlxSprite):Bool { // I spent hours trying to make this work, but thanks to ✦ Sword ✦ (swordcube) from the official Haxe Discord server it works now!!! - return spr.overlapsPoint(flixel.FlxG.mouse.getWorldPosition(spr.camera), true, spr.camera); + return spr.overlapsPoint(FlxG.mouse.getWorldPosition(spr.camera), true, spr.camera); } public inline static function normalize(path:String):String @@ -131,21 +140,6 @@ class CoolUtil return StringTools.replace(path, " ", "-").toLowerCase(); } - /* - public inline static function setFont():String - { - final language = cast (KadeEngineData.settings.data.language, String); - var font:String; - - if (language == 'en_US') - font = Paths.font('Crayawn-v58y.ttf'); - else - font = Paths.font("vcr.ttf"); - - return font; - } - */ - public static inline function convertVolume(oldValue:Float):Float { oldValue = FlxMath.bound(oldValue, 0, 100); @@ -171,6 +165,39 @@ class CoolUtil FlxG.sound.volume = CoolUtil.convertVolume(CoolUtil.volume); Main.tray.show(); } + + public static function uncachCharacters():Void + { + var characters:Int = 0; + var names:Array = []; + + @:privateAccess + for (key => i in FlxG.bitmap._cache) + { + // trace(key, key.contains('characters')); + + if (!key.contains('characters')) + continue; + + final graphic = FlxG.bitmap.get(key); + + if (graphic != null) + { + if (graphic.persist) + continue; + + characters++; + + var path:Array = key.split('/'); + names.push(path.pop()); + + FlxG.bitmap.remove(graphic); + } + } + + if (characters > 0) + trace('Cleaned $characters character sprites from the cache. ($names)'); + } } diff --git a/source/Language.hx b/source/Language.hx index fd21d60..8a522a8 100644 --- a/source/Language.hx +++ b/source/Language.hx @@ -7,7 +7,7 @@ package; it has a simpler syntax (.ini) and not the old horrible one (.xml) which can be hell sometimes (no autocompletion!!!) */ -import lime.utils.AssetType; +import data.GlobalData; import openfl.utils.Assets; import SSIni; using StringTools; @@ -25,7 +25,7 @@ class Language @:noCompletion private static function get_curLang() { - var saveLang:String = data.KadeEngineData.settings.data.language; + var saveLang:String = GlobalData.settings.language; return (saveLang != null ? saveLang : 'en_US'); } diff --git a/source/Main.hx b/source/Main.hx index 7db7072..daa4da4 100644 --- a/source/Main.hx +++ b/source/Main.hx @@ -1,44 +1,59 @@ package; +import openfl.events.UncaughtErrorEvent; +import Discord.DiscordClient; +import sys.FileSystem; +import sys.io.File; +import haxe.CallStack; +import substates.Start; +import funkin.FunkinGame; +import openfl.Lib; +import data.GlobalData; import objects.SoundTray.VolumeTray; import openfl.events.Event; import openfl.ui.Keyboard; import openfl.events.KeyboardEvent; +import openfl.display.Sprite; import flixel.FlxG; +import objects.Counter; using StringTools; -class Main extends openfl.display.Sprite +class Main extends Sprite { - private var counter:objects.Counter; - private var gamepadText:objects.Counter.GamepadText; + private var counter:Counter; + private var gamepadText:GamepadText; public static var currentClass:String = ''; - public static var characters = ['bf', 'bf-pixel', 'bf-alt', 'nugget', 'monty', 'cindy', 'lily', 'monster', 'protagonist', 'bf-dead', 'bf-pixel-dead', 'protagonist-pixel', 'janitor', 'principal', 'polla' //characters - //stage sprites - ]; - - public static var appTitle:String = "Funkergarten"; public static var tray:VolumeTray; public static function main():Void { - openfl.Lib.current.addChild(new Main()); + trace('does main call first or new?'); + + Lib.current.addChild(new Main()); } public function new() { + trace('does new call first or main?'); + super(); if (stage != null) + { init(); + } else - addEventListener(openfl.events.Event.ADDED_TO_STAGE, init); + { + addEventListener(Event.ADDED_TO_STAGE, init); + } } - private function init(?E:openfl.events.Event):Void + + private function init(?_):Void { - if (hasEventListener(openfl.events.Event.ADDED_TO_STAGE)) - removeEventListener(openfl.events.Event.ADDED_TO_STAGE, init); + if (hasEventListener(Event.ADDED_TO_STAGE)) + removeEventListener(Event.ADDED_TO_STAGE, init); setupGame(); } @@ -48,8 +63,8 @@ class Main extends openfl.display.Sprite var gameWidth:Int = 1280; var gameHeight:Int = 720; - var stageWidth:Int = openfl.Lib.current.stage.stageWidth; - var stageHeight:Int = openfl.Lib.current.stage.stageHeight; + var stageWidth:Int = Lib.current.stage.stageWidth; + var stageHeight:Int = Lib.current.stage.stageHeight; var ratioX:Float = stageWidth / gameWidth; var ratioY:Float = stageHeight / gameHeight; @@ -57,37 +72,33 @@ class Main extends openfl.display.Sprite gameWidth = Math.ceil(stageWidth / Math.min(ratioX, ratioY)); gameHeight = Math.ceil(stageHeight / Math.min(ratioX, ratioY)); - #if cpp - // cpp.NativeGc.enable(true); - #end - FlxG.save.bind('other', 'funkergarten'); - data.KadeEngineData.bind(); - addChild(new funkin.FunkinGame(gameWidth, gameHeight, substates.Start, 120, 120, true, false)); + addChild(new FunkinGame(gameWidth, gameHeight, Start, 60, 60, true, false)); - tray = new objects.SoundTray.VolumeTray(); + tray = new VolumeTray(); addChild(tray); #if debug flixel.addons.studio.FlxStudio.create(); #end - counter = new objects.Counter(); + counter = new Counter(); counter.width = gameWidth; addChild(counter); - toggleFPS(data.KadeEngineData.settings.data.fps); + toggleFPS(GlobalData.settings.showFPS); + + addChild(gamepadText = new GamepadText(gameWidth, gameHeight)); - addChild(gamepadText = new objects.Counter.GamepadText(gameWidth, gameHeight)); - openfl.Lib.current.stage.addEventListener(KeyboardEvent.KEY_DOWN, gamepadEvent); + FlxG.stage.addEventListener(KeyboardEvent.KEY_DOWN, gamepadEvent); #if FLX_KEYBOARD FlxG.stage.addEventListener(Event.ENTER_FRAME, handleVolume); #end #if sys - openfl.Lib.current.loaderInfo.uncaughtErrorEvents.addEventListener(openfl.events.UncaughtErrorEvent.UNCAUGHT_ERROR, onCrash); + Lib.current.loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onCrash); #end } @@ -96,7 +107,8 @@ class Main extends openfl.display.Sprite counter.visible = fpsEnabled; } - public inline function updateClassIndicator():Void{ + public inline function updateClassIndicator():Void + { #if debug try { @@ -126,13 +138,13 @@ class Main extends openfl.display.Sprite // Code was entirely made by sqirra-rng for their fnf engine named "Izzy Engine", big props to them!!! #if sys - function onCrash(e:openfl.events.UncaughtErrorEvent):Void + function onCrash(e:UncaughtErrorEvent):Void { - funkin.FunkinGame.crashed = true; + FunkinGame.crashed = true; var errMsg:String = ""; var path:String; - var callStack:Array = haxe.CallStack.exceptionStack(true); + var callStack:Array = CallStack.exceptionStack(true); var dateNow:String = Date.now().toString(); dateNow = dateNow.replace(" ", "_"); @@ -155,18 +167,21 @@ class Main extends openfl.display.Sprite + e.error + "\nPlease report this error in Funkergarten's Gamebanana page\n\n\n> Crash Handler written by: sqirra-rng"; - if (!sys.FileSystem.exists("./crash/")) - sys.FileSystem.createDirectory("./crash/"); + if (!FileSystem.exists("./crash/")) + FileSystem.createDirectory("./crash/"); - sys.io.File.saveContent(path, errMsg + "\n"); + File.saveContent(path, errMsg + "\n"); Sys.println(errMsg); Sys.println("Crash dump saved in " + haxe.io.Path.normalize(path)); - if (!FlxG.fullscreen) lime.app.Application.current.window.alert(errMsg, "Error!"); - #if cpp - Discord.DiscordClient.shutdown(); - #end + if (!FlxG.fullscreen) + { + FlxG.stage.window.alert(errMsg, "Error!"); + } + + DiscordClient.shutdown(); + Sys.exit(1); } #end @@ -183,7 +198,7 @@ class Main extends openfl.display.Sprite gamepadText = null; } - removeEventListener(KeyboardEvent.KEY_DOWN, gamepadEvent); + FlxG.stage.removeEventListener(KeyboardEvent.KEY_DOWN, gamepadEvent); } private function handleVolume(_):Void diff --git a/source/Paths.hx b/source/Paths.hx index bd871fb..2a9c081 100644 --- a/source/Paths.hx +++ b/source/Paths.hx @@ -1,5 +1,6 @@ package; +import data.GlobalData; import flixel.FlxG; import flixel.graphics.frames.FlxAtlasFrames; import openfl.utils.AssetType; @@ -76,7 +77,7 @@ class Paths { var songLowercase = CoolUtil.normalize(song); - if (songLowercase != 'nugget-de-polla' && songLowercase != 'expelled-v0') + if (!GlobalData.secretSongs.contains(song)) return 'songs:assets/songs/$songLowercase/Voices.$SOUND_EXT'; else return 'shit:assets/shit/songs/$songLowercase/Voices.$SOUND_EXT'; @@ -86,7 +87,7 @@ class Paths { var songLowercase = CoolUtil.normalize(song); - if (songLowercase != 'nugget-de-polla' && songLowercase != 'expelled-v0') + if (!GlobalData.secretSongs.contains(song)) return 'songs:assets/songs/${songLowercase}/Inst.$SOUND_EXT'; else return 'shit:assets/shit/songs/$songLowercase/Inst.$SOUND_EXT'; diff --git a/source/data/Controls.hx b/source/data/Controls.hx index 918f4f9..55f4a33 100644 --- a/source/data/Controls.hx +++ b/source/data/Controls.hx @@ -180,7 +180,7 @@ class Controls extends FlxActionSet for (action in digitalActions) byName[action.name] = action; - setKeyboardScheme(scheme, false); + loadKeyBinds(); } override function update() @@ -360,23 +360,14 @@ class Controls extends FlxActionSet } } - public function setKeyboardScheme(scheme:KeyboardScheme, reset = true) - { - loadKeyBinds(); - } - public function loadKeyBinds() { - - //trace(FlxKey.fromString(data.KadeEngineData.controls.data.upBind)); - removeKeyboard(); - data.KeyBinds.keyCheck(); - inline bindKeys(Control.UP, [FlxKey.fromString(data.KadeEngineData.controls.data.upBind), FlxKey.UP]); - inline bindKeys(Control.DOWN, [FlxKey.fromString(data.KadeEngineData.controls.data.downBind), FlxKey.DOWN]); - inline bindKeys(Control.LEFT, [FlxKey.fromString(data.KadeEngineData.controls.data.leftBind), FlxKey.LEFT]); - inline bindKeys(Control.RIGHT, [FlxKey.fromString(data.KadeEngineData.controls.data.rightBind), FlxKey.RIGHT]); + inline bindKeys(Control.UP, [FlxKey.fromString(GlobalData.controls.upBind), FlxKey.UP]); + inline bindKeys(Control.DOWN, [FlxKey.fromString(GlobalData.controls.downBind), FlxKey.DOWN]); + inline bindKeys(Control.LEFT, [FlxKey.fromString(GlobalData.controls.leftBind), FlxKey.LEFT]); + inline bindKeys(Control.RIGHT, [FlxKey.fromString(GlobalData.controls.rightBind), FlxKey.RIGHT]); inline bindKeys(Control.ACCEPT, [Z, SPACE, ENTER]); inline bindKeys(Control.BACK, [BACKSPACE, ESCAPE]); inline bindKeys(Control.PAUSE, [P, ENTER, ESCAPE]); @@ -417,7 +408,7 @@ class Controls extends FlxActionSet switch (device) { case Keys: - setKeyboardScheme(None); + loadKeyBinds(); } } diff --git a/source/data/FCs.hx b/source/data/FCs.hx index 7510224..ada35cd 100644 --- a/source/data/FCs.hx +++ b/source/data/FCs.hx @@ -9,7 +9,7 @@ class FCs public static inline function save():Void { - if (PlayState.storyDifficulty != 2 || KadeEngineData.botplay || KadeEngineData.practice) + if (PlayState.storyDifficulty != 2 || GlobalData.botplay || GlobalData.practice) return; final song = CoolUtil.normalize(PlayState.SONG.song); @@ -54,8 +54,8 @@ class FCs } } - KadeEngineData.other.data.fcedSongs = fcedSongs; - KadeEngineData.flush(); + GlobalData.other.fcedSongs = fcedSongs; + GlobalData.flush(); } public static inline function check(song:String):Bool @@ -70,16 +70,15 @@ class FCs public static inline function init():Void { - if (KadeEngineData.other.data.fcedSongs != null) - fcedSongs = KadeEngineData.other.data.fcedSongs; + if (GlobalData.other.fcedSongs != null) + fcedSongs = GlobalData.other.fcedSongs; } public static function fullFC():Bool { - if (!KadeEngineData.other.data.beatedMod || KadeEngineData.other.data.fcedSongs == null) + if (!GlobalData.other.beatenStoryMode || GlobalData.other.fcedSongs == null) return false; - final songs:Array = ['monday', 'nugget', 'staff-only', 'cash-grab', 'expelled', 'monday-encore', 'nugget-de-polla']; final dumbSongs:Array = []; for (key => i in fcedSongs) @@ -94,8 +93,10 @@ class FCs } } - for (song in songs) + for (song in GlobalData.allSongs) { + song = CoolUtil.normalize(song); + if (!dumbSongs.contains(song)) { return false; diff --git a/source/data/GlobalData.hx b/source/data/GlobalData.hx new file mode 100644 index 0000000..54e466b --- /dev/null +++ b/source/data/GlobalData.hx @@ -0,0 +1,346 @@ +package data; + +import flixel.math.FlxMath; +import flixel.util.FlxSave; +import funkin.Conductor; +import flixel.FlxSprite; + +using StringTools; + +class GlobalData +{ + public static final allCharacters:Array = ['bf', 'bf-pixel', 'bf-alt', 'bf-dead', 'bf-pixel-dead', 'protagonist', 'nugget', 'janitor', 'monty', 'principal', 'protagonist-pixel', 'cindy', 'lily', 'monster', 'polla']; + public static final allSongs:Array = ['Monday', 'Nugget', 'Staff Only', 'Cash Grab', 'Expelled', 'Nugget de Polla', 'Petty Petals']; + public static final storySongs:Array = ['Monday', 'Nugget', 'Staff Only', 'Cash Grab', 'Expelled']; + public static final secretSongs:Array = ['Nugget de Polla', 'Expelled V0']; + public static final allowedMenuCharacters:Array = ['protagonist', 'nugget', 'monty', 'janitor', 'principal', 'cindy', 'lily', 'monster', 'polla']; + + public static var other:OtherData; + public static var settings:SettingsData; + public static var controls:ControlsData; + + public static var other_save = new FlxSave(); + public static var settings_save = new FlxSave(); + public static var controls_save = new FlxSave(); + public static var chart_autosave = new FlxSave(); + + public static var showHelp:Bool = true; + public static var botplay:Bool = false; + public static var practice:Bool = false; + + public static function initSave() + { + GlobalData.bind(); + + #if debug + chart_autosave.data.chart ??= {}; + #end + + initSettings(); + initOther(); + initControls(); + + flush(); + + trace(controls_save.data, controls); + + FlxSprite.defaultAntialiasing = settings.antialiasingEnabled; + + Conductor.recalculateTimings(); + + PlayerSettings.init(); + PlayerSettings.player1.controls.loadKeyBinds(); + + Main.changeFPS(settings.fpsCap); + } + + public static function resetData() + { + other = + { + mondays: defaultOther.mondays, + menuCharacters: defaultOther.menuCharacters, + beatenStoryMode: defaultOther.beatenStoryMode, + beatenSongs: defaultOther.beatenSongs, + gotSkin: defaultOther.gotSkin, + metNugget: defaultOther.metNugget, + seenCredits: defaultOther.seenCredits, + didPolla: defaultOther.didPolla, + sawAdvice: defaultOther.sawAdvice, + usingSkin: defaultOther.usingSkin, + didV0: defaultOther.didV0, + songScores: defaultOther.songScores, + fcedSongs: defaultOther.fcedSongs, + songCombos: defaultOther.songCombos + } + + setDataOf(other_save, other, DATABASE_TO_FLXSAVE); + + Highscore.load(); + FCs.init(); + + flush(); + } + + public static function initSettings():Void + { + settings = + { + downscroll: false, + showFPS: false, + mechanicsEnabled: true, + antialiasingEnabled: true, + singCamMoveEnabled: true, + fullscreen: false, + middlescroll: false, + lowQuality: false, + flashingLights: true, + shadersEnabled: true, + ghostTapping: true, + colorblindType: 'No filter', + camZoomsEnabled: true, + fpsCap: 60, + changedHit: false, + changedHitX: -1, + changedHitY: -1, + language: null + } + + setDataOf(settings_save, settings, FLXSAVE_TO_DATABASE); + + settings.fpsCap = Std.int(FlxMath.bound(settings.fpsCap, 60, 240)); + + if (settings.changedHit == null) + { + settings.changedHitX = settings.changedHitY = -1; + settings.changedHit = false; + } + + setDataOf(settings_save, settings, DATABASE_TO_FLXSAVE); + } + + private static function initOther():Void + { + other = + { + mondays: defaultOther.mondays, + menuCharacters: defaultOther.menuCharacters, + beatenStoryMode: defaultOther.beatenStoryMode, + beatenSongs: defaultOther.beatenSongs, + gotSkin: defaultOther.gotSkin, + metNugget: defaultOther.metNugget, + seenCredits: defaultOther.seenCredits, + didPolla: defaultOther.didPolla, + sawAdvice: defaultOther.sawAdvice, + usingSkin: defaultOther.usingSkin, + didV0: defaultOther.didV0, + songScores: defaultOther.songScores, + fcedSongs: defaultOther.fcedSongs, + songCombos: defaultOther.songCombos + } + + setDataOf(other_save, other, FLXSAVE_TO_DATABASE); + + if (other.mondays < 0) + other.mondays = 0; + + setDataOf(other_save, other, DATABASE_TO_FLXSAVE); + } + + public static function initControls():Void + { + controls = + { + leftBind: 'A', + downBind: 'S', + upBind: 'W', + rightBind: 'D' + } + + setDataOf(controls_save, controls, FLXSAVE_TO_DATABASE); + + if (controls.leftBind.contains("NUMPAD")) + controls.leftBind = "A"; + if (controls.downBind.contains("NUMPAD")) + controls.downBind = "S"; + if (controls.upBind.contains("NUMPAD")) + controls.upBind = "W"; + if (controls.rightBind.contains("NUMPAD")) + controls.rightBind = "D"; + + setDataOf(controls_save, controls, DATABASE_TO_FLXSAVE); + + trace('KEYBINDS: [${controls.leftBind} - ${controls.downBind} - ${controls.upBind} - ${controls.rightBind}].'); + } + + public static function bind():Void + { + trace("Creating/reconnecting data!"); + + other_save.bind('other', 'funkergarten'); + settings_save.bind('settings', 'funkergarten'); + controls_save.bind('controls', 'funkergarten'); + + #if debug + chart_autosave.bind('chart_autosave', 'funkergarten'); + #end + } + + public static function flush():Void + { + trace("Saving data!"); + + setDataOf(other_save, other, DATABASE_TO_FLXSAVE); + setDataOf(settings_save, settings, DATABASE_TO_FLXSAVE); + setDataOf(controls_save, controls, DATABASE_TO_FLXSAVE); + + other_save.flush(); + settings_save.flush(); + controls_save.flush(); + } + + public static function autoUnlock():Void + { + #if debug + other.mondays = 999; + other.menuCharacters = GlobalData.allowedMenuCharacters; + other.beatenStoryMode = true; + other.beatenSongs = GlobalData.allSongs; + other.gotSkin = true; + other.metNugget = true; + other.seenCredits = true; + other.didPolla = true; + other.sawAdvice = true; + other.didV0 = true; + + flush(); + #else + trace('CHEATER'); + #end + } + + private static final defaultOther:OtherData = + { + mondays: 0, + menuCharacters: ['protagonist'], + beatenStoryMode: false, + beatenSongs: [], + gotSkin: false, + metNugget: false, + seenCredits: false, + didPolla: false, + sawAdvice: false, + usingSkin: false, + didV0: false, + songScores: null, + fcedSongs: null, + songCombos: null + } + + private static function setDataOf(save:FlxSave, dataBase:T, type:DataSettingType):Void + { + if (type == FLXSAVE_TO_DATABASE) + { + var otherDataFields:Array = Reflect.fields(save.data); + + for (i in 0...otherDataFields.length) + { + var curField:String = otherDataFields[i]; + var curValue:Dynamic = Reflect.field(save.data, curField); + + if (curValue != null) + { + Reflect.setField(dataBase, curField, curValue); // if the value of the flxsave's field isnt null, set it in the data typedef + } + else + { + var defaultValue:Dynamic = Reflect.field(dataBase, curField); + + Reflect.setField(save.data, curField, defaultValue); // if the value of the flxsave's field IS null, replace it by the default value of that field (the one in the typedef) + } + } + } + else if (type == DATABASE_TO_FLXSAVE) + { + var otherDataFields:Array = Reflect.fields(dataBase); + + for (i in 0...otherDataFields.length) + { + var curField:String = otherDataFields[i]; + var curValue:Dynamic = Reflect.field(dataBase, curField); + + if (curValue != null) + { + Reflect.setField(save.data, curField, curValue); // if the value of the data typedef's field isnt null, set it in the flxsave instance + } + else + { + var defaultValue:Dynamic = Reflect.field(save.data, curField); + + Reflect.setField(dataBase, curField, defaultValue); // if the value of the data typedef's field IS null, replace it by the default value of that field + } + } + } + } +} + +private typedef OtherData = +{ + var mondays:Int; + var menuCharacters:Array; + var beatenStoryMode:Bool; + var beatenSongs:Array; + var gotSkin:Bool; + var metNugget:Bool; + var seenCredits:Bool; + var didPolla:Bool; + var sawAdvice:Bool; + var usingSkin:Bool; + var didV0:Bool; + var songScores:Map; + var fcedSongs:Map; + var songCombos:Map; +} + +private typedef SettingsData = +{ + var downscroll:Bool; + var showFPS:Bool; + var mechanicsEnabled:Bool; + var antialiasingEnabled:Bool; + var singCamMoveEnabled:Bool; + var fullscreen:Bool; + var middlescroll:Bool; + var lowQuality:Bool; + var flashingLights:Bool; + var shadersEnabled:Bool; + var ghostTapping:Bool; + var colorblindType:String; + var camZoomsEnabled:Bool; + var fpsCap:Int; + var changedHit:Null; + var changedHitX:Float; + var changedHitY:Float; + var language:String; +} + +private typedef ControlsData = +{ + var leftBind:String; + var downBind:String; + var upBind:String; + var rightBind:String; + + /* maybe??? + var appleBind:String; + var volUpBind:String; + var volDownBind:String; + var pauseBind:String; + */ +} + +enum DataSettingType +{ + FLXSAVE_TO_DATABASE; + DATABASE_TO_FLXSAVE; +} \ No newline at end of file diff --git a/source/data/Highscore.hx b/source/data/Highscore.hx index a050da8..dbae385 100644 --- a/source/data/Highscore.hx +++ b/source/data/Highscore.hx @@ -1,6 +1,7 @@ package data; import flixel.FlxG; + using StringTools; class Highscore @@ -12,7 +13,7 @@ class Highscore { var daSong:String = formatSong(song, diff); - if(!data.KadeEngineData.botplay) + if(!GlobalData.botplay) { if (songScores.exists(daSong)) { @@ -29,7 +30,7 @@ class Highscore var daSong:String = formatSong(song, diff); var finalCombo:String = combo.split(')')[0].replace('(', ''); - if(!data.KadeEngineData.botplay) + if(!GlobalData.botplay) { if (songCombos.exists(daSong)) { @@ -48,16 +49,16 @@ class Highscore { // Reminder that I don't need to format this song, it should come formatted! songScores.set(song, score); - data.KadeEngineData.other.data.songScores = songScores; - data.KadeEngineData.flush(); + GlobalData.other.songScores = songScores; + GlobalData.flush(); } static function setCombo(song:String, combo:String):Void { // Reminder that I don't need to format this song, it should come formatted! songCombos.set(song, combo); - data.KadeEngineData.other.data.songCombos = songCombos; - data.KadeEngineData.flush(); + GlobalData.other.songCombos = songCombos; + GlobalData.flush(); } public static function formatSong(song:String, diff:Int):String @@ -109,15 +110,15 @@ class Highscore public static function load():Void { - if (data.KadeEngineData.other.data.songScores != null) - songScores = data.KadeEngineData.other.data.songScores; - if (data.KadeEngineData.other.data.songCombos != null) - songCombos = data.KadeEngineData.other.data.songCombos; + if (GlobalData.other.songScores != null) + songScores = GlobalData.other.songScores; + if (GlobalData.other.songCombos != null) + songCombos = GlobalData.other.songCombos; } public static function convertScore(noteDiff:Float):Int { - var daRating:String = data.Ratings.CalculateRating(noteDiff, 166); + var daRating:String = Ratings.CalculateRating(noteDiff, 166); switch(daRating) { diff --git a/source/data/KadeEngineData.hx b/source/data/KadeEngineData.hx deleted file mode 100644 index 6bffe4b..0000000 --- a/source/data/KadeEngineData.hx +++ /dev/null @@ -1,174 +0,0 @@ -package data; - -import states.MainMenuState; -import funkin.Conductor; -import flixel.FlxSprite; -import flixel.FlxG; - -class KadeEngineData -{ - public static var other = new flixel.util.FlxSave(); - public static var settings = new flixel.util.FlxSave(); - public static var controls = new flixel.util.FlxSave(); - public static var chart_autosave = new flixel.util.FlxSave(); - - public static var showHelp:Bool = true; - public static var botplay:Bool = false; - public static var practice:Bool = false; - - public static function initSave() - { - initSettings(); - - #if debug - other.data.compiles ??= 0; - - chart_autosave.data.chart ??= {}; - #end - - other.data.mondays ??= 0; - other.data.showCharacters ??= ['protagonist']; - other.data.beatedMod ??= false; // typo :sob: - other.data.beatedSongs ??= []; // typo :sob: - other.data.gotSkin ??= false; - other.data.talkedNugget ??= false; - other.data.seenCredits ??= false; - other.data.polla ??= false; - other.data.sawAdvice ??= false; - other.data.usingSkin ??= false; - other.data.didV0 ??= false; - - FlxSprite.defaultAntialiasing = settings.data.antialiasing; - - Conductor.recalculateTimings(); - PlayerSettings.player1.controls.loadKeyBinds(); - keyCheck(); - - Main.changeFPS(settings.data.fpsCap); - } - - public static function resetData() - { - //#if debug return; #end // hehe - other.data.mondays = 0; - other.data.showCharacters = ['protagonist']; - other.data.beatedMod = false; - other.data.talkedNugget = false; - other.data.gotSkin = false; - other.data.beatedSongs = []; - other.data.polla = false; - other.data.usingSkin = false; - other.data.songScores = null; - other.data.fcedSongs = null; - other.data.didV0 = false; - Highscore.load(); - FCs.init(); - - flush(); - } - - public static function initSettings():Void - { - settings.data.downscroll ??= false; - settings.data.fps ??= false; - settings.data.mechanics ??= true; - settings.data.antialiasing ??= true; - settings.data.camMove ??= true; - settings.data.fullscreen ??= false; - settings.data.middlescroll ??= false; - settings.data.lowQuality ??= false; - settings.data.flashing ??= true; - settings.data.shaders ??= true; - settings.data.ghostTap ??= true; - settings.data.colorblind ??= 'No filter'; - settings.data.zooms ??= true; - settings.data.fpsCap ??= 60; - - if (settings.data.fpsCap > 240 || settings.data.fpsCap < 60) - settings.data.fpsCap = 60; - - if (settings.data.changedHit == null) - { - settings.data.changedHitX = settings.data.changedHitY = -1; - settings.data.changedHit = false; - } - } - - public static function resetBinds():Void - { - controls.data.upBind = "W"; - controls.data.downBind = "S"; - controls.data.leftBind = "A"; - controls.data.rightBind = "D"; - - PlayerSettings.player1.controls.loadKeyBinds(); - } - - public static function keyCheck():Void - { - controls.data.upBind ??= "W"; - - if (StringTools.contains(controls.data.upBind, "NUMPAD")) - controls.data.upBind = "W"; - - controls.data.downBind ??= "S"; - - if (StringTools.contains(controls.data.downBind, "NUMPAD")) - controls.data.downBind = "S"; - - controls.data.leftBind ??= "A"; - - if (StringTools.contains(controls.data.leftBind, "NUMPAD")) - controls.data.leftBind = "A"; - - controls.data.rightBind ??= "D"; - - if (StringTools.contains(controls.data.rightBind, "NUMPAD")) - controls.data.rightBind = "D"; - - trace('KEYBINDS: [${controls.data.leftBind} - ${controls.data.downBind} - ${controls.data.upBind} - ${controls.data.rightBind}].'); - } - - public static function bind():Void - { - trace("Creating/reconnecting data!"); - - other.bind('other', 'funkergarten'); - settings.bind('settings', 'funkergarten'); - controls.bind('controls', 'funkergarten'); - - #if debug - chart_autosave.bind('chart_autosave', 'funkergarten'); - #end - } - - public static function flush():Void - { - trace("Saving data!"); - - other.flush(); - settings.flush(); - controls.flush(); - } - - public static function autoUnlock():Void - { - #if debug - other.data.mondays = 999; - other.data.showCharacters = MainMenuState.allowedCharacters; - other.data.beatedMod = true; // typo :sob: - other.data.beatedSongs = ['Monday', 'Nugget', 'Staff Only', 'Cash Grab', 'Expelled', 'Nugget de Polla', 'Petty Petals']; // typo :sob: - other.data.gotSkin = true; - other.data.talkedNugget = true; - other.data.seenCredits = true; - other.data.polla = true; - other.data.sawAdvice = true; - other.data.usingSkin = false; - other.data.didV0 = true; - - KadeEngineData.flush(); - #else - trace('CHEATER'); - #end - } -} \ No newline at end of file diff --git a/source/data/KeyBinds.hx b/source/data/KeyBinds.hx deleted file mode 100644 index 8b6ab56..0000000 --- a/source/data/KeyBinds.hx +++ /dev/null @@ -1,40 +0,0 @@ -package data; - -class KeyBinds -{ - public static function resetBinds():Void - { - KadeEngineData.controls.data.upBind = "W"; - KadeEngineData.controls.data.downBind = "S"; - KadeEngineData.controls.data.leftBind = "A"; - KadeEngineData.controls.data.rightBind = "D"; - - data.PlayerSettings.player1.controls.loadKeyBinds(); - } - - public static function keyCheck():Void - { - KadeEngineData.controls.data.upBind ??= "W"; - - if (StringTools.contains(KadeEngineData.controls.data.upBind, "NUMPAD")) - KadeEngineData.controls.data.upBind = "W"; - - KadeEngineData.controls.data.downBind ??= "S"; - - if (StringTools.contains(KadeEngineData.controls.data.downBind, "NUMPAD")) - KadeEngineData.controls.data.downBind = "S"; - - KadeEngineData.controls.data.leftBind ??= "A"; - - if (StringTools.contains(KadeEngineData.controls.data.leftBind, "NUMPAD")) - KadeEngineData.controls.data.leftBind = "A"; - - KadeEngineData.controls.data.rightBind ??= "D"; - - if (StringTools.contains(KadeEngineData.controls.data.rightBind, "NUMPAD")) - KadeEngineData.controls.data.rightBind = "D"; - - trace('KEYBINDS: [${KadeEngineData.controls.data.leftBind} - ${KadeEngineData.controls.data.downBind} - ${KadeEngineData.controls.data.upBind} - ${KadeEngineData.controls.data.rightBind}].'); - } - -} \ No newline at end of file diff --git a/source/data/PlayerSettings.hx b/source/data/PlayerSettings.hx index 04df707..254b50c 100644 --- a/source/data/PlayerSettings.hx +++ b/source/data/PlayerSettings.hx @@ -38,11 +38,6 @@ class PlayerSettings this.controls = new data.Controls('player$id', scheme); } - public function setKeyboardScheme(scheme) - { - controls.setKeyboardScheme(scheme); - } - static public function init():Void { if (player1 == null) diff --git a/source/data/Ratings.hx b/source/data/Ratings.hx index 5cc57ef..770c20d 100644 --- a/source/data/Ratings.hx +++ b/source/data/Ratings.hx @@ -12,7 +12,7 @@ class Ratings { var ranking:String = "N/A"; - if(KadeEngineData.botplay) + if(GlobalData.botplay) ranking = "BotPlay"; if (PlayState.scoreData.misses == 0 && PlayState.scoreData.bads == 0 && PlayState.scoreData.shits == 0 && PlayState.scoreData.goods == 0) // Marvelous (SICK) Full Combo @@ -92,7 +92,7 @@ class Ratings if (accuracy == 0) ranking = "N/A"; - else if(KadeEngineData.botplay) + else if (GlobalData.botplay) ranking = "BotPlay"; return ranking; @@ -100,7 +100,7 @@ class Ratings inline public static function CalculateRating(noteDiff:Float, ?customSafeZone:Float):String // Generate a judgement through some timing shit { - if (KadeEngineData.botplay) + if (GlobalData.botplay) return "sick"; // FUNNY return checkRating(noteDiff, (customSafeZone != null) ? customSafeZone / 166 : Conductor.timeScale); @@ -133,15 +133,15 @@ class Ratings // cleaned it up for you since you wouldnt actually want to clean all of this inline public static function CalculateRanking(score:Int, scoreDef:Int, accuracy:Float):String { - var scoreStr:String = Language.get('Ratings', 'score') + " " + (KadeEngineData.practice ? '???' : (funkin.Conductor.safeFrames != 10 ? '$score ($scoreDef)' : '$score')); + var scoreStr:String = Language.get('Ratings', 'score') + " " + (GlobalData.practice ? '???' : (funkin.Conductor.safeFrames != 10 ? '$score ($scoreDef)' : '$score')); var missStr:String = Language.get('Ratings', 'misses') + " " + '${PlayState.scoreData.misses}'; - var retAcc:String = (KadeEngineData.botplay ? "N/A" : '${CoolUtil.truncateFloat(accuracy, 2)}%'); + var retAcc:String = (GlobalData.botplay ? "N/A" : '${CoolUtil.truncateFloat(accuracy, 2)}%'); var accStr:String = Language.get('Ratings', 'accuracy') + " " + retAcc; var endString:String = scoreStr + ' | $missStr | $accStr | ${GenerateLetterRank(accuracy)}'; - return (!KadeEngineData.botplay ? endString : ""); + return (!GlobalData.botplay ? endString : ""); } } diff --git a/source/debug/AnimationDebug.hx b/source/debug/AnimationDebug.hx index 483d90a..be4b295 100644 --- a/source/debug/AnimationDebug.hx +++ b/source/debug/AnimationDebug.hx @@ -1,28 +1,17 @@ package debug; -import flixel.util.FlxCollision; -import lime.app.Application; import flixel.FlxG; +import data.GlobalData; import flixel.FlxObject; import flixel.FlxSprite; -import flixel.FlxState; import flixel.addons.display.FlxGridOverlay; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.text.FlxText; import flixel.util.FlxColor; -import openfl.events.Event; -import openfl.events.IOErrorEvent; -import openfl.net.FileReference; -import flixel.addons.ui.FlxInputText; -import flixel.addons.ui.FlxUI9SliceSprite; import flixel.addons.ui.FlxUI; -import flixel.addons.ui.FlxUIState; -import flixel.addons.ui.FlxUICheckBox; import flixel.addons.ui.FlxUIDropDownMenu; -import flixel.addons.ui.FlxUIInputText; import flixel.addons.ui.FlxUINumericStepper; import flixel.addons.ui.FlxUITabMenu; -import flixel.addons.ui.FlxUITooltip.FlxUITooltipStyle; /** *DEBUG MODE @@ -96,7 +85,7 @@ class AnimationDebug extends funkin.MusicBeatState addHelpText(); - characters = Main.characters; + characters = GlobalData.allCharacters; characters.remove('polla'); var tabs = [{name: "Offsets", label: 'Offset menu'},]; @@ -334,9 +323,9 @@ class AnimationDebug extends funkin.MusicBeatState } if (FlxG.keys.justPressed.F1) - data.KadeEngineData.showHelp = !data.KadeEngineData.showHelp; + GlobalData.showHelp = !GlobalData.showHelp; - helpText.text = (data.KadeEngineData.showHelp ? "Help:\nQ/E : Zoom in and out\nF : Flip\nI/J/K/L : Move Camera\nW/S : Change Animation\nArrows : Set Animation Offset\nShift-Arrows : Set Animation Offset x10\nSpace : Replay Animation\nEnter/ESC : Exit\nPress F1 to hide/show this!\n" : "F1 - help"); + helpText.text = (GlobalData.showHelp ? "Help:\nQ/E : Zoom in and out\nF : Flip\nI/J/K/L : Move Camera\nW/S : Change Animation\nArrows : Set Animation Offset\nShift-Arrows : Set Animation Offset x10\nSpace : Replay Animation\nEnter/ESC : Exit\nPress F1 to hide/show this!\n" : "F1 - help"); super.update(elapsed); } diff --git a/source/debug/CameraDebug.hx b/source/debug/CameraDebug.hx index b01f4ee..430d22c 100644 --- a/source/debug/CameraDebug.hx +++ b/source/debug/CameraDebug.hx @@ -93,7 +93,7 @@ class CameraDebug extends funkin.MusicBeatState add(strumLine); - if (data.KadeEngineData.settings.data.downscroll) + if (GlobalData.settings.downscroll) strumLine.y = FlxG.height - 165; strumLineNotes = new FlxTypedGroup(); @@ -237,7 +237,7 @@ class CameraDebug extends funkin.MusicBeatState } if (FlxG.keys.justPressed.F1) - data.KadeEngineData.showHelp = !data.KadeEngineData.showHelp; + GlobalData.showHelp = !GlobalData.showHelp; super.update(elapsed); } diff --git a/source/funkin/Conductor.hx b/source/funkin/Conductor.hx index b32b54f..43f58e0 100644 --- a/source/funkin/Conductor.hx +++ b/source/funkin/Conductor.hx @@ -27,15 +27,15 @@ class Conductor public static var safeFrames:Int = 10; public static var safeZoneOffset:Float = Math.floor((safeFrames / 60) * 1000); // is calculated in create(), is safeFrames in milliseconds - public static var timeScale:Float = funkin.Conductor.safeZoneOffset / 166; + public static var timeScale:Float = Conductor.safeZoneOffset / 166; public static var bpmChangeMap:Array = []; public inline static function recalculateTimings() { - funkin.Conductor.safeFrames = 10; - funkin.Conductor.safeZoneOffset = Math.floor((funkin.Conductor.safeFrames / 60) * 1000); - funkin.Conductor.timeScale = funkin.Conductor.safeZoneOffset / 166; + Conductor.safeFrames = 10; + Conductor.safeZoneOffset = Math.floor((Conductor.safeFrames / 60) * 1000); + Conductor.timeScale = Conductor.safeZoneOffset / 166; } public inline static function mapBPMChanges(song:SwagSong) diff --git a/source/funkin/MusicBeatState.hx b/source/funkin/MusicBeatState.hx index add1ec5..c4843b0 100644 --- a/source/funkin/MusicBeatState.hx +++ b/source/funkin/MusicBeatState.hx @@ -1,5 +1,12 @@ package funkin; +import data.Highscore; +import data.GlobalData; +import data.PlayerSettings; +import data.Controls; +import funkin.Section.SwagSection; +import substates.CustomFadeTransition; +import states.PlayState; import flixel.FlxState; import funkin.Conductor.BPMChangeEvent; import flixel.FlxG; @@ -13,20 +20,20 @@ class MusicBeatState extends FlxUIState private var curStep:Int = 0; private var curBeat:Int = 0; - private var daSection:funkin.Section.SwagSection = null; // holy shit dont name this "curSection" - private var controls(get, never):data.Controls; + private var daSection:SwagSection = null; // holy shit dont name this "curSection" + private var controls(get, never):Controls; - inline function get_controls():data.Controls - return data.PlayerSettings.player1.controls; + inline function get_controls():Controls + return PlayerSettings.player1.controls; override function create() { if (!FlxTransitionableState.skipNextTransOut) - openSubState(new substates.CustomFadeTransition(0.7, true)); + openSubState(new CustomFadeTransition(0.7, true)); FlxTransitionableState.skipNextTransOut = false; - Main.changeFPS(data.KadeEngineData.settings.data.fpsCap); + Main.changeFPS(GlobalData.settings.fpsCap); super.create(); } @@ -61,13 +68,13 @@ class MusicBeatState extends FlxUIState songTime: 0, bpm: 0 } - for (i in 0...funkin.Conductor.bpmChangeMap.length) + for (i in 0...Conductor.bpmChangeMap.length) { - if (funkin.Conductor.songPosition >= funkin.Conductor.bpmChangeMap[i].songTime) - lastChange = funkin.Conductor.bpmChangeMap[i]; + if (Conductor.songPosition >= Conductor.bpmChangeMap[i].songTime) + lastChange = Conductor.bpmChangeMap[i]; } - curStep = lastChange.stepTime + Math.floor((funkin.Conductor.songPosition - lastChange.songTime) / funkin.Conductor.stepCrochet); + curStep = lastChange.stepTime + Math.floor((Conductor.songPosition - lastChange.songTime) / Conductor.stepCrochet); } public function stepHit():Void @@ -80,10 +87,10 @@ class MusicBeatState extends FlxUIState public function sectionHit():Void { - if (states.PlayState.SONG != null) - if (states.PlayState.SONG.notes != null) - if (states.PlayState.SONG.notes[Std.int(curStep / 16)] != null) - daSection = states.PlayState.SONG.notes[Std.int(curStep / 16)]; + if (PlayState.SONG != null) + if (PlayState.SONG.notes != null) + if (PlayState.SONG.notes[Std.int(curStep / 16)] != null) + daSection = PlayState.SONG.notes[Std.int(curStep / 16)]; } public function fancyOpenURL(schmancy:String) @@ -98,13 +105,13 @@ class MusicBeatState extends FlxUIState public static function switchState(nextState:FlxState, stopMusic:Bool = false) { var curState:Dynamic = FlxG.state; - var leState:funkin.MusicBeatState = curState; + var leState:MusicBeatState = curState; if (!FlxTransitionableState.skipNextTransIn) { - leState.openSubState(new substates.CustomFadeTransition(0.6, false)); + leState.openSubState(new CustomFadeTransition(0.6, false)); - substates.CustomFadeTransition.finishCallback = function() + CustomFadeTransition.finishCallback = function() { if (nextState == FlxG.state) { @@ -132,17 +139,17 @@ class MusicBeatState extends FlxUIState if (difficulty < 0) difficulty = 0; - var poop:String = data.Highscore.formatSong(song, difficulty); + var poop:String = Highscore.formatSong(song, difficulty); - states.PlayState.SONG = funkin.Song.loadFromJson(poop, song, true); - states.PlayState.storyDifficulty = difficulty; - states.PlayState.scoreData.sicks = 0; - states.PlayState.scoreData.bads = 0; - states.PlayState.scoreData.shits = 0; - states.PlayState.scoreData.goods = 0; - states.PlayState.tries = 0; + PlayState.SONG = Song.loadFromJson(poop, song, true); + PlayState.storyDifficulty = difficulty; + PlayState.scoreData.sicks = 0; + PlayState.scoreData.bads = 0; + PlayState.scoreData.shits = 0; + PlayState.scoreData.goods = 0; + PlayState.tries = 0; - switchState(new states.PlayState(), true); + switchState(new PlayState(), true); } /** @@ -155,10 +162,11 @@ class MusicBeatState extends FlxUIState { var time:Float = switch (value) { - case STEPS: funkin.Conductor.stepCrochet / 1000; - case BEATS: funkin.Conductor.crochet / 1000; - case SECTIONS: (funkin.Conductor.stepCrochet / 1000) * 16; + case STEPS: Conductor.stepCrochet / 1000; + case BEATS: Conductor.crochet / 1000; + case SECTIONS: (Conductor.stepCrochet / 1000) * 16; } + time *= howMany; if (time > 0) @@ -172,7 +180,7 @@ class MusicBeatState extends FlxUIState enum FlxBeats { - STEPS; - BEATS; - SECTIONS; + STEPS; + BEATS; + SECTIONS; } \ No newline at end of file diff --git a/source/funkin/SongEvents.hx b/source/funkin/SongEvents.hx index 2c0f380..9cc543c 100644 --- a/source/funkin/SongEvents.hx +++ b/source/funkin/SongEvents.hx @@ -1,5 +1,7 @@ package funkin; +import states.PlayState; +import data.GlobalData; import haxe.Json; import lime.utils.Assets; @@ -19,7 +21,7 @@ class SongEvents { var eventList:Array = []; var path:String = ''; - if (['Nugget de Polla', 'Expelled V0'].contains(states.PlayState.SONG.song)) + if (GlobalData.secretSongs.contains(PlayState.SONG.song)) path = Paths.json('songs/$song/events', 'shit'); else path = Paths.json('$song/events', 'songs'); diff --git a/source/objects/Character.hx b/source/objects/Character.hx index fe17e30..c36efa0 100644 --- a/source/objects/Character.hx +++ b/source/objects/Character.hx @@ -4,6 +4,8 @@ import flixel.FlxG; import funkin.Conductor; import flixel.FlxSprite; import flixel.math.FlxPoint; +import data.GlobalData; + using StringTools; class Character extends FlxSprite @@ -140,7 +142,7 @@ class Character extends FlxSprite playAnim(altAnimSuffix + singDirections[direction] + (miss ? 'miss' : ''), true); var anim:String = singDirections[direction] + altAnimSuffix; - if (data.KadeEngineData.settings.data.camMove && !data.KadeEngineData.settings.data.lowQuality) + if (GlobalData.settings.singCamMoveEnabled && !GlobalData.settings.lowQuality) { switch (direction) { @@ -201,7 +203,7 @@ class Character extends FlxSprite addAnim(anim.frameIndices != null, anim.name, anim.prefix, anim.frameIndices, anim.looped, anim.offsets); } - charData.antialiasing ??= data.KadeEngineData.settings.data.antialiasing; + charData.antialiasing ??= GlobalData.settings.antialiasingEnabled; charData.sizeMult ??= [1, 1]; curColor = charData.color; antialiasing = charData.antialiasing; diff --git a/source/objects/Note.hx b/source/objects/Note.hx index 5cf4e42..fd70689 100644 --- a/source/objects/Note.hx +++ b/source/objects/Note.hx @@ -1,6 +1,6 @@ package objects; -import data.KadeEngineData; +import data.GlobalData; import flixel.math.FlxRect; import funkin.Conductor; import states.PlayState; @@ -96,7 +96,7 @@ class Note extends flixel.FlxSprite animation.play('${dir[noteData]}holdend'); updateHitbox(); - flipY = data.KadeEngineData.settings.data.downscroll; + flipY = GlobalData.settings.downscroll; offsetX -= width / 2; if (prevNote.isSustainNote) @@ -199,7 +199,7 @@ class Note extends flixel.FlxSprite // is calling FlxRect's `new` function every frame stupid? public inline function updateRect(center:Float):Void { - if (KadeEngineData.settings.data.downscroll) + if (GlobalData.settings.downscroll) { swagRect.set(0, 0, frameWidth, (center - y) / scale.y); swagRect.y = frameHeight - swagRect.height; diff --git a/source/objects/Objects.hx b/source/objects/Objects.hx index a195d7b..588b582 100644 --- a/source/objects/Objects.hx +++ b/source/objects/Objects.hx @@ -3,7 +3,7 @@ package objects; import objects.Character.CharData; import states.PlayState; import funkin.Conductor; -import data.KadeEngineData; +import data.GlobalData; import flixel.tweens.FlxTween; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.math.FlxMath; @@ -353,8 +353,8 @@ class Rating extends FlxSprite flixel.tweens.FlxTween.cancelTweensOf(this); alpha = 1; - if (data.KadeEngineData.settings.data.changedHit) - setPosition(data.KadeEngineData.settings.data.changedHitX, data.KadeEngineData.settings.data.changedHitY); + if (GlobalData.settings.changedHit) + setPosition(GlobalData.settings.changedHitX, GlobalData.settings.changedHitY); else { screenCenter(Y); @@ -449,12 +449,12 @@ class Clock extends FlxTypedGroup clock.animation.addByIndices('ring', 'alarm', [2, 3, 4, 5, 6, 7, 8], '', 24, false); clock.animation.addByIndices('ringing', 'alarm', [9, 10, 11, 12], '', 24, true); clock.animation.play('idle'); - if (KadeEngineData.settings.data.middlescroll) + if (GlobalData.settings.middlescroll) clock.x = FlxG.width - clock.width - 10; else clock.screenCenter(X); clock.x += 34; - clock.y = (KadeEngineData.settings.data.downscroll ? FlxG.height - clock.height - 5 : 5); + clock.y = (GlobalData.settings.downscroll ? FlxG.height - clock.height - 5 : 5); minuteHand = new FlxSprite(clock.x + (clock.width + stuff.width) / 2 - stuff.offsetX, clock.y + clock.height / 2 + stuff.offsetY).makeGraphic(stuff.width, stuff.height, FlxColor.BLACK); minuteHand.active = false; diff --git a/source/objects/Stage.hx b/source/objects/Stage.hx index 6a5fed6..d72cd0a 100644 --- a/source/objects/Stage.hx +++ b/source/objects/Stage.hx @@ -1,7 +1,7 @@ package objects; import states.PlayState; -import data.KadeEngineData; +import data.GlobalData; import flixel.FlxG; import flixel.FlxSprite; import flixel.group.FlxGroup.FlxTypedGroup; @@ -236,7 +236,7 @@ class Stage extends funkin.MusicBeatState if (PlayState.SONG.player1 != 'bf-pixel') { bfY += 35; - if (KadeEngineData.other.data.usingSkin) + if (GlobalData.other.usingSkin) { bfX += 19 / 2; bfY += 72; diff --git a/source/objects/Strum.hx b/source/objects/Strum.hx index dee8b9f..2ac93f1 100644 --- a/source/objects/Strum.hx +++ b/source/objects/Strum.hx @@ -3,7 +3,7 @@ package objects; import states.PlayState; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; -import data.KadeEngineData; +import data.GlobalData; import flixel.FlxG; class Strum extends flixel.FlxSprite @@ -12,7 +12,7 @@ class Strum extends flixel.FlxSprite public function new(i:Int, num:Int) { - super(0, (KadeEngineData.settings.data.downscroll ? FlxG.height - Note.swagWidth - 40 : 40)); + super(0, (GlobalData.settings.downscroll ? FlxG.height - Note.swagWidth - 40 : 40)); isPlayer = (num != 0); ID = i; @@ -20,7 +20,7 @@ class Strum extends flixel.FlxSprite loadSprite(i); scrollFactor.set(); alpha = 0; - FlxTween.tween(this, {y: y + 10 * (KadeEngineData.settings.data.downscroll ? -1 : 1), alpha: 1}, 1, {ease: FlxEase.circOut, startDelay: 1 + (0.2 * i)}); + FlxTween.tween(this, {y: y + 10 * (GlobalData.settings.downscroll ? -1 : 1), alpha: 1}, 1, {ease: FlxEase.circOut, startDelay: 1 + (0.2 * i)}); centerX(i); } @@ -61,7 +61,7 @@ class Strum extends flixel.FlxSprite { final groupWidth:Float = 494.2; - if (KadeEngineData.settings.data.middlescroll) + if (GlobalData.settings.middlescroll) { if (isPlayer) x = (FlxG.width - groupWidth) / 2; diff --git a/source/objects/Yoyo.hx b/source/objects/Yoyo.hx index 8545efa..41d85a6 100644 --- a/source/objects/Yoyo.hx +++ b/source/objects/Yoyo.hx @@ -5,7 +5,7 @@ package objects; import flixel.util.FlxTimer; import flixel.math.FlxPoint; import flixel.math.FlxMath; -import data.KadeEngineData; +import data.GlobalData; import flixel.tweens.FlxEase; import flixel.FlxG; import flixel.group.FlxGroup.FlxTypedGroup; @@ -83,7 +83,7 @@ class Yoyo extends FlxTypedSpriteGroup string.scale.y = (yoyo.y + yoyo.height / 2) * 2; string.setPosition(yoyo.x + yoyo.width / 2 - 5, -1); - if (KadeEngineData.botplay) + if (GlobalData.botplay) { yoyo.alpha = 1; } @@ -113,7 +113,7 @@ class Yoyo extends FlxTypedSpriteGroup FlxTween.tween(yoyo, {y: targetY}, 0.5, {ease: FlxEase.bounceOut, onComplete: function(_) { moveY(); - if (KadeEngineData.botplay) + if (GlobalData.botplay) { new FlxTimer().start(1.2, function (_) { @@ -132,7 +132,7 @@ class Yoyo extends FlxTypedSpriteGroup spinning = true; direction = !direction; - FlxTween.tween(yoyo, {y: targetY + (direction ? 0 : (KadeEngineData.settings.data.downscroll ? -400 : 400))}, 1, {ease: FlxEase.backOut, onComplete: function(_) + FlxTween.tween(yoyo, {y: targetY + (direction ? 0 : (GlobalData.settings.downscroll ? -400 : 400))}, 1, {ease: FlxEase.backOut, onComplete: function(_) { moveY(); }}); diff --git a/source/options/ColorblindMenu.hx b/source/options/ColorblindMenu.hx index 9807066..4f44b6c 100644 --- a/source/options/ColorblindMenu.hx +++ b/source/options/ColorblindMenu.hx @@ -1,6 +1,6 @@ package options; -import data.KadeEngineData; +import data.GlobalData; import openfl.filters.ColorMatrixFilter; import funkin.MusicBeatState; import flixel.tweens.FlxEase; @@ -182,8 +182,8 @@ class ColorblindMenu extends MusicBeatState CoolUtil.sound('cancelMenu', 'preload', 0.5); leaving = true; - KadeEngineData.settings.data.colorblind = typesArray[curSelected]; - KadeEngineData.flush(); + GlobalData.settings.colorblindType = typesArray[curSelected]; + GlobalData.flush(); MusicBeatState.switchState(new MiscOptions(new KindergartenOptions(null))); } @@ -240,7 +240,7 @@ class ColorblindMenu extends MusicBeatState private inline function init():Void { - curSelected = typesArray.indexOf(KadeEngineData.settings.data.colorblind); + curSelected = typesArray.indexOf(GlobalData.settings.colorblindType); text.text = Language.get('Colorblind_Types', typesArray[curSelected]); CoolUtil.sound('scrollMenu', 'preload', 0.7); diff --git a/source/options/GameplayCustomizeState.hx b/source/options/GameplayCustomizeState.hx index 5af83e7..26ab761 100644 --- a/source/options/GameplayCustomizeState.hx +++ b/source/options/GameplayCustomizeState.hx @@ -1,5 +1,6 @@ package options; +import data.GlobalData; import objects.Objects.Clock; import flixel.FlxBasic; import flixel.tweens.FlxEase; @@ -7,9 +8,6 @@ import flixel.tweens.FlxTween; import flixel.util.FlxColor; import flixel.math.FlxMath; import flixel.FlxCamera; -#if cpp -import sys.thread.Thread; -#end import flixel.FlxSprite; import flixel.FlxG; @@ -48,14 +46,14 @@ class GameplayCustomizeState extends funkin.MusicBeatState defaultY = sick.y; - if (!data.KadeEngineData.settings.data.changedHit) + if (!GlobalData.settings.changedHit) { - data.KadeEngineData.settings.data.changedHitX = defaultX; - data.KadeEngineData.settings.data.changedHitY = defaultY; - data.KadeEngineData.flush(); + GlobalData.settings.changedHitX = defaultX; + GlobalData.settings.changedHitY = defaultY; + GlobalData.flush(); } - sick.setPosition(data.KadeEngineData.settings.data.changedHitX, data.KadeEngineData.settings.data.changedHitY); + sick.setPosition(GlobalData.settings.changedHitX, GlobalData.settings.changedHitY); generateStaticArrows(); add(sick); @@ -149,12 +147,12 @@ class GameplayCustomizeState extends funkin.MusicBeatState if (FlxG.keys.justPressed.R) { sick.setPosition(defaultX, defaultY); - data.KadeEngineData.settings.data.changedHit = false; + GlobalData.settings.changedHit = false; } - data.KadeEngineData.settings.data.changedHitX = sick.x; - data.KadeEngineData.settings.data.changedHitY = sick.y; - data.KadeEngineData.settings.data.changedHit = true; + GlobalData.settings.changedHitX = sick.x; + GlobalData.settings.changedHitY = sick.y; + GlobalData.settings.changedHit = true; } private function input():Void @@ -163,7 +161,7 @@ class GameplayCustomizeState extends funkin.MusicBeatState if (controls.BACK) { - data.KadeEngineData.flush(); + GlobalData.flush(); CoolUtil.sound('cancelMenu', 'preload', 0.5); diff --git a/source/options/OptionsMenuBase.hx b/source/options/OptionsMenuBase.hx index 7431c23..3594c81 100644 --- a/source/options/OptionsMenuBase.hx +++ b/source/options/OptionsMenuBase.hx @@ -1,7 +1,7 @@ package options; import funkin.MusicBeatState; -import data.KadeEngineData; +import data.GlobalData; import flixel.FlxState; import objects.Objects.KinderButton; import flixel.group.FlxGroup.FlxTypedGroup; @@ -68,7 +68,7 @@ class OptionsMenuBase extends MusicBeatState canDoSomething = false; buttons.active = false; - KadeEngineData.flush(); + GlobalData.flush(); MusicBeatState.switchState(state); } } @@ -102,6 +102,6 @@ class OptionsMenuBase extends MusicBeatState private inline function data():Dynamic { - return KadeEngineData.settings.data; + return GlobalData.settings; } } diff --git a/source/states/CreditsState.hx b/source/states/CreditsState.hx index b40723c..617ea04 100644 --- a/source/states/CreditsState.hx +++ b/source/states/CreditsState.hx @@ -21,8 +21,6 @@ class CreditsState extends funkin.MusicBeatState private var grpCredits:Array = []; - private var iconArray:Array = []; - private var saul:FlxSprite; var descText:FlxText; var socialBlock:FlxSprite; // this reminds me of my history classes diff --git a/source/states/FreeplayState.hx b/source/states/FreeplayState.hx index 7cf640a..44a6480 100644 --- a/source/states/FreeplayState.hx +++ b/source/states/FreeplayState.hx @@ -1,10 +1,15 @@ package states; -import flixel.tweens.FlxTween; +import funkin.Song; +import data.Highscore; +import flixel.FlxObject; +import funkin.Conductor; +import objects.DialogueBox.IconBox; +import flixel.math.FlxMath; +import data.GlobalData; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import funkin.MusicBeatState; -import data.FCs; import flixel.FlxSprite; import flixel.util.FlxColor; import flixel.text.FlxText; @@ -12,7 +17,7 @@ import flixel.FlxG; import states.PlayState; import substates.LockedSongSubstate; -class FreeplayState extends funkin.MusicBeatState +class FreeplayState extends MusicBeatState { // if you dont want a dedicated file for it, just make a custom struct array lol var songData:Array<{song:String, icon:String}> = [ @@ -63,20 +68,18 @@ class FreeplayState extends funkin.MusicBeatState private static var curSelected:Int = 0; public static var curDifficulty:Int = 2; - var scoreText:flixel.text.FlxText; + var scoreText:FlxText; var lerpScore:Int = 0; var intendedScore:Int = 0; var combo:String = ''; - private var boxes:Array = []; - private var camFollow:flixel.FlxObject; + private var boxes:Array = []; + private var camFollow:FlxObject; private var daY:Float; override function create() { - Cache.clear(); - - camFollow = new flixel.FlxObject(0, 0, 1, 1); + camFollow = new FlxObject(0, 0, 1, 1); camFollow.screenCenter(X); camFollow.active = false; @@ -98,14 +101,14 @@ class FreeplayState extends funkin.MusicBeatState slac wanted to be here too - sanco */ - var beatedSongs:Array = cast data.KadeEngineData.other.data.beatedSongs; + var beatedSongs:Array = GlobalData.other.beatenSongs; // lmfao for (entry in songData) { final condition:Null = switch(entry.song) { - case 'Nugget de Polla': data.KadeEngineData.other.data.polla; + case 'Nugget de Polla': GlobalData.other.didPolla; case 'Monday Encore': beatedSongs.contains('Monday'); default: beatedSongs.contains(entry.song); }; @@ -114,7 +117,7 @@ class FreeplayState extends funkin.MusicBeatState addSong(entry.song, entry.icon, condition); } - var bg = new flixel.FlxSprite().loadGraphic(Paths.image('bg/classroom', 'shared')); + var bg = new FlxSprite().loadGraphic(Paths.image('bg/classroom', 'shared')); bg.active = false; CoolUtil.size(bg, 0.6, true, true); bg.screenCenter(); @@ -123,7 +126,7 @@ class FreeplayState extends funkin.MusicBeatState for (i in 0...songs.length) { - var sprite = new objects.DialogueBox.IconBox(songs[i].songName, songs[i].songCharacter, 0, true, songs[i].unlocked); + var sprite = new IconBox(songs[i].songName, songs[i].songCharacter, 0, true, songs[i].unlocked); sprite.y += 50 + ((sprite.height + 70) * i); boxes.push(sprite); add(sprite); @@ -155,22 +158,22 @@ class FreeplayState extends funkin.MusicBeatState override function update(elapsed:Float) { if (FlxG.sound.music != null) - funkin.Conductor.songPosition = FlxG.sound.music.time; + Conductor.songPosition = FlxG.sound.music.time; super.update(elapsed); - lerpScore = Math.floor(flixel.math.FlxMath.lerp(lerpScore, intendedScore, 0.4 * (elapsed * 30))); + lerpScore = Math.floor(FlxMath.lerp(lerpScore, intendedScore, 0.4 * (elapsed * 30))); if (Math.abs(lerpScore - intendedScore) <= 10) lerpScore = intendedScore; for (i in 0...boxes.length) if (i != curSelected) - boxes[i].x = flixel.math.FlxMath.lerp(objects.DialogueBox.IconBox.daX, boxes[i].x, 0.3 * (elapsed * 30)); + boxes[i].x = FlxMath.lerp(IconBox.daX, boxes[i].x, 0.3 * (elapsed * 30)); scoreText.text = '${Language.get('FreeplayState', 'score_text')}$lerpScore\n${CoolUtil.difficultyFromInt(curDifficulty).toUpperCase()} $combo'; - camFollow.y = flixel.math.FlxMath.lerp(camFollow.y, daY, 0.5 * (elapsed * 30)); + camFollow.y = FlxMath.lerp(camFollow.y, daY, 0.5 * (elapsed * 30)); FlxG.camera.focusOn(camFollow.getPosition()); input(); @@ -200,8 +203,8 @@ class FreeplayState extends funkin.MusicBeatState scoreText.color = [0xefb058, 0x5083fc, 0x9d1137][curDifficulty]; var songHighscore = StringTools.replace(songs[curSelected].songName, " ", "-"); - intendedScore = data.Highscore.getScore(songHighscore, curDifficulty); - combo = data.Highscore.getCombo(songHighscore, curDifficulty); + intendedScore = Highscore.getScore(songHighscore, curDifficulty); + combo = Highscore.getCombo(songHighscore, curDifficulty); bounceText(); } @@ -225,8 +228,8 @@ class FreeplayState extends funkin.MusicBeatState curSelected = 0; var songHighscore = StringTools.replace(songs[curSelected].songName, " ", "-"); - intendedScore = data.Highscore.getScore(songHighscore, curDifficulty); - combo = data.Highscore.getCombo(songHighscore, curDifficulty); + intendedScore = Highscore.getScore(songHighscore, curDifficulty); + combo = Highscore.getCombo(songHighscore, curDifficulty); for (i in 0...boxes.length) { @@ -234,7 +237,7 @@ class FreeplayState extends funkin.MusicBeatState if (i == curSelected) { spr.iconBop(); - spr.box.color = flixel.util.FlxColor.YELLOW; + spr.box.color = FlxColor.YELLOW; spr.x = 120; daY = spr.box.y + spr.box.height / 2; } @@ -272,7 +275,7 @@ class FreeplayState extends funkin.MusicBeatState if (controls.BACK) { - funkin.MusicBeatState.switchState(new MainMenuState()); + MusicBeatState.switchState(new MainMenuState()); CoolUtil.sound('cancelMenu', 'preload', 0.5); } @@ -287,7 +290,7 @@ class FreeplayState extends funkin.MusicBeatState if (songs[curSelected].songName != 'Expelled') { var songFormat = StringTools.replace(songs[curSelected].songName, " ", "-"); - PlayState.SONG = funkin.Song.loadFromJson(data.Highscore.formatSong(songFormat, curDifficulty), songs[curSelected].songName, songs[curSelected].songName == 'Nugget de Polla'); + PlayState.SONG = Song.loadFromJson(Highscore.formatSong(songFormat, curDifficulty), songs[curSelected].songName, songs[curSelected].songName == 'Nugget de Polla'); PlayState.isStoryMode = false; PlayState.storyDifficulty = curDifficulty; PlayState.tries = 0; diff --git a/source/states/KeyBindMenu.hx b/source/states/KeyBindMenu.hx index 742ac3c..2afb0e0 100644 --- a/source/states/KeyBindMenu.hx +++ b/source/states/KeyBindMenu.hx @@ -36,10 +36,10 @@ class KeyBindMenu extends FlxSubState private final defaultKeys:Array = ["A", "S", "W", "D", "R"]; private var keys:Array = [ - KadeEngineData.controls.data.leftBind, - KadeEngineData.controls.data.downBind, - KadeEngineData.controls.data.upBind, - KadeEngineData.controls.data.rightBind + GlobalData.controls.leftBind, + GlobalData.controls.downBind, + GlobalData.controls.upBind, + GlobalData.controls.rightBind ]; override function create() @@ -138,12 +138,12 @@ class KeyBindMenu extends FlxSubState private function save() { - KadeEngineData.controls.data.upBind = keys[2]; - KadeEngineData.controls.data.downBind = keys[1]; - KadeEngineData.controls.data.leftBind = keys[0]; - KadeEngineData.controls.data.rightBind = keys[3]; + GlobalData.controls.upBind = keys[2]; + GlobalData.controls.downBind = keys[1]; + GlobalData.controls.leftBind = keys[0]; + GlobalData.controls.rightBind = keys[3]; - KadeEngineData.flush(); + GlobalData.flush(); PlayerSettings.player1.controls.loadKeyBinds(); } diff --git a/source/states/LanguageState.hx b/source/states/LanguageState.hx index 2046f2f..802451b 100644 --- a/source/states/LanguageState.hx +++ b/source/states/LanguageState.hx @@ -1,5 +1,6 @@ package states; +import data.GlobalData; import flixel.group.FlxSpriteGroup; import funkin.MusicBeatState; import openfl.Assets; @@ -98,12 +99,12 @@ class LanguageState extends funkin.MusicBeatState selectedSomething = canAccept = false; protagonist.animation.play('walk'); - if (data.KadeEngineData.settings.data.flashing) FlxG.camera.flash(); + if (GlobalData.settings.flashingLights) FlxG.camera.flash(); CoolUtil.sound('confirmMenu', 'preload', 0.7); for (spr in books) if (spr.selected) - data.KadeEngineData.settings.data.language = options[books.indexOf(spr)]; + GlobalData.settings.language = options[books.indexOf(spr)]; Language.populate(); protagonist.velocity.x = (protagonist.flipX ? 600 : -600); diff --git a/source/states/MainMenuState.hx b/source/states/MainMenuState.hx index 03db635..c85cbb7 100644 --- a/source/states/MainMenuState.hx +++ b/source/states/MainMenuState.hx @@ -8,7 +8,7 @@ import flixel.input.mouse.FlxMouseEventManager; import flixel.input.mouse.FlxMouseEvent; import substates.DifficultySubstate; import substates.OptionsAdviceSubstate; -import data.KadeEngineData; +import data.GlobalData; import flixel.math.FlxMath; import flixel.util.FlxTimer; import flixel.FlxG; @@ -18,8 +18,6 @@ import substates.SelectSkinSubstate; class MainMenuState extends funkin.MusicBeatState { - public static final allowedCharacters:Array = ['protagonist', 'nugget', 'janitor', 'monty', 'cindy', 'lily', 'monster', 'principal', 'polla']; - private var bg:FlxBackdrop; private var character:objects.Character; private var logo:FlxSprite; @@ -30,8 +28,6 @@ class MainMenuState extends funkin.MusicBeatState override function create() { - Cache.clear(); - CoolUtil.title('Main Menu'); CoolUtil.presence(null, Language.get('Discord_Presence', 'main_menu'), false, 0, null); @@ -74,7 +70,7 @@ class MainMenuState extends funkin.MusicBeatState notepad.updateHitbox(); add(notepad); - if (!KadeEngineData.other.data.seenCredits) + if (!GlobalData.other.seenCredits) FlxTween.color(notepad, 1, FlxColor.WHITE, 0xffff9393, {type: PINGPONG}); logo = new FlxSprite(0, 10).loadGraphic(Paths.image('menu/logo', 'preload')); @@ -84,14 +80,14 @@ class MainMenuState extends funkin.MusicBeatState logo.scale.set(daScale, daScale); add(logo); - var savedChars:Array = cast(data.KadeEngineData.other.data.showCharacters, Array); - var charsList:Array = cast savedChars.copy(); + var savedChars:Array = GlobalData.other.menuCharacters; + var charsList:Array = savedChars.copy(); charsList.remove('protagonist-pixel'); for (i in charsList) { - if (!allowedCharacters.contains(i)) + if (!GlobalData.allowedMenuCharacters.contains(i)) charsList.remove(i); } @@ -116,7 +112,7 @@ class MainMenuState extends funkin.MusicBeatState icon.frames = Paths.getSparrowAtlas('menu/extras', 'preload'); icon.animation.addByIndices('disabled', 'bf-icon', [0], '', 0, false); icon.animation.addByIndices('enabled', 'bf-icon', [1], '', 0, false); - if (KadeEngineData.other.data.gotSkin) + if (GlobalData.other.gotSkin) icon.animation.play('enabled'); else icon.animation.play('disabled'); @@ -127,7 +123,7 @@ class MainMenuState extends funkin.MusicBeatState FlxMouseEvent.add(icon, function onMouseDown(sprite) { - if (KadeEngineData.other.data.gotSkin) + if (GlobalData.other.gotSkin) openSubState(new SelectSkinSubstate()); else { @@ -148,7 +144,7 @@ class MainMenuState extends funkin.MusicBeatState add(star); } - if (KadeEngineData.other.data.sawAdvice) + if (GlobalData.other.sawAdvice) selectedSomethin = false; else { @@ -170,7 +166,7 @@ class MainMenuState extends funkin.MusicBeatState override function update(elapsed:Float) { - if (FlxG.keys.justPressed.ANY && !data.KadeEngineData.other.data.polla && !selectedSomethin) + if (FlxG.keys.justPressed.ANY && !GlobalData.other.didPolla && !selectedSomethin) { checkPolla(); } @@ -253,10 +249,10 @@ class MainMenuState extends funkin.MusicBeatState case 'Credits': funkin.MusicBeatState.switchState(new states.CreditsState()); - if (!KadeEngineData.other.data.seenCredits) + if (!GlobalData.other.seenCredits) { - KadeEngineData.other.data.seenCredits = true; - KadeEngineData.flush(); + GlobalData.other.seenCredits = true; + GlobalData.flush(); } default: selectedSomethin = false; @@ -282,8 +278,8 @@ class MainMenuState extends funkin.MusicBeatState if (code.length <= 0) { - data.KadeEngineData.other.data.polla = true; - data.KadeEngineData.flush(); + GlobalData.other.didPolla = true; + GlobalData.flush(); selectedSomethin = true; var polla = new FlxSprite().loadGraphic(Paths.image('characters/nugget', 'shit')); diff --git a/source/states/PlayState.hx b/source/states/PlayState.hx index 84367c0..9893345 100644 --- a/source/states/PlayState.hx +++ b/source/states/PlayState.hx @@ -28,7 +28,7 @@ import substates.CustomFadeTransition; import data.FCs; import data.Ratings; -import data.KadeEngineData; +import data.GlobalData; import funkin.*; import funkin.Song.SwagSong; @@ -101,6 +101,7 @@ class PlayState extends MusicBeatState private var chromTween:FlxTween; // --- [ Gameplay stuff] + private var mechanicsOn(get, default):Bool; private var health:Float = 1; private var lerpHealth:Float = 1; // From the actual full-ass game!!! private var totalNotesHit:Float = 0; @@ -194,13 +195,12 @@ class PlayState extends MusicBeatState { instance = this; - Cache.clear(); CoolUtil.title('Loading...'); CoolUtil.presence(null, Language.get('Discord_Presence', 'loading_menu'), false, 0, null); FlxG.mouse.visible = false; - if (storyDifficulty == 3 || KadeEngineData.botplay) - KadeEngineData.practice = false; + if (storyDifficulty == 3 || GlobalData.botplay) + GlobalData.practice = false; if (FlxG.sound.music != null || FlxG.sound.music.playing) FlxG.sound.music.stop(); @@ -233,11 +233,11 @@ class PlayState extends MusicBeatState add(clock = new Clock(camHUD)); add(numbersGroup = new FlxTypedGroup()); - if (!KadeEngineData.botplay) + if (!GlobalData.botplay) { add(ratingsGroup = new FlxTypedGroup()); ratingsGroup.cameras = [camHUD]; - if (KadeEngineData.settings.data.lowQuality) + if (GlobalData.settings.lowQuality) ratingsGroup.maxSize = 1; ratingsGroup.add(new Rating()).kill(); @@ -251,7 +251,7 @@ class PlayState extends MusicBeatState for (i in 0...4) splashGroup.add(new NoteSplash()).kill(); - if (KadeEngineData.settings.data.lowQuality) + if (GlobalData.settings.lowQuality) { numbersGroup.maxSize = 3; splashGroup.maxSize = 4; @@ -275,9 +275,9 @@ class PlayState extends MusicBeatState camGame.zoom = defaultCamZoom; camGame.focusOn(camPoint); - var healthBarBG = new FlxSprite(0, (KadeEngineData.settings.data.downscroll ? 50 : FlxG.height * 0.9)); + var healthBarBG = new FlxSprite(0, (GlobalData.settings.downscroll ? 50 : FlxG.height * 0.9)); - if (!KadeEngineData.botplay && !KadeEngineData.practice) + if (!GlobalData.botplay && !GlobalData.practice) { healthBarBG.makeGraphic(1, 1, FlxColor.BLACK); healthBarBG.scale.set(601, 19); @@ -296,15 +296,15 @@ class PlayState extends MusicBeatState healthBar.active = false; add(healthBar); - if (KadeEngineData.botplay || KadeEngineData.practice) + if (GlobalData.botplay || GlobalData.practice) { healthBar.visible = false; healthBar.alpha = 0; } - var daY = healthBarBG.y + (KadeEngineData.settings.data.downscroll ? 100 : -100); + var daY = healthBarBG.y + (GlobalData.settings.downscroll ? 100 : -100); // Literally copy-paste of the above, fu - if(KadeEngineData.botplay) + if (GlobalData.botplay) { var botPlayState = new FlxText(0, daY, FlxG.width, (storyDifficulty == 3 ? "YOU SUCK": "BOTPLAY"), 20); botPlayState.autoSize = false; @@ -324,7 +324,7 @@ class PlayState extends MusicBeatState iconP2.y = healthBar.y - (iconP2.height / 2); add(iconP2); - if (KadeEngineData.botplay || KadeEngineData.practice) + if (GlobalData.botplay || GlobalData.practice) { iconP1.screenCenter(X); iconP2.screenCenter(X); @@ -332,7 +332,7 @@ class PlayState extends MusicBeatState iconP2.x -= iconP2.width / 1.5; } - if (KadeEngineData.settings.data.lowQuality) + if (GlobalData.settings.lowQuality) { lerpHealth = health; healthBar.update(FlxG.elapsed); @@ -359,7 +359,7 @@ class PlayState extends MusicBeatState setupSpotlights(); - if (!KadeEngineData.settings.data.lowQuality) + if (!GlobalData.settings.lowQuality) { pollaBlock = new FlxSprite().makeGraphic(1, 1, FlxColor.WHITE); pollaBlock.scale.set(FlxG.width * 2, FlxG.height * 2); @@ -383,7 +383,7 @@ class PlayState extends MusicBeatState playerStrums.cameras = cpuStrums.cameras = splashGroup.cameras = numbersGroup.cameras = notes.cameras = healthBar.cameras = healthBarBG.cameras = iconP1.cameras = iconP2.cameras = scoreTxt.cameras = [camHUD]; - if (KadeEngineData.botplay || KadeEngineData.practice) + if (GlobalData.botplay || GlobalData.practice) { healthBarBG.destroy(); healthBarBG = null; @@ -406,7 +406,7 @@ class PlayState extends MusicBeatState var spr = new Apple(0, 0); spr.cameras = [camHUD]; spr.x = spr.width * i; - spr.y = (KadeEngineData.settings.data.downscroll ? 1 : FlxG.height - spr.height - 1); + spr.y = (GlobalData.settings.downscroll ? 1 : FlxG.height - spr.height - 1); spr.ID = i + 1; spr.alpha = 0; // apparently setting alpha to 0 is better than setting visible to false because it prevents the sprite from calling `draw` - no dumbass both do that spr.active = false; @@ -421,10 +421,10 @@ class PlayState extends MusicBeatState pollasGroup.camera = camHUD; pollaJumpscare().kill(); - if (!cast (KadeEngineData.other.data.showCharacters, Array).contains(dad.curCharacter)) + if (!GlobalData.other.menuCharacters.contains(dad.curCharacter)) { - cast (KadeEngineData.other.data.showCharacters, Array).push(dad.curCharacter); - KadeEngineData.flush(); + GlobalData.other.menuCharacters.push(dad.curCharacter); + GlobalData.flush(); } if (SONG.song == 'Nugget') boyfriend.camPos[1] -= 200; @@ -466,16 +466,16 @@ class PlayState extends MusicBeatState var previousFrameTime:Int = 0; var songTime:Float = 0; - var binds:Array = [KadeEngineData.controls.data.leftBind.toLowerCase(), - KadeEngineData.controls.data.downBind.toLowerCase(), - KadeEngineData.controls.data.upBind.toLowerCase(), - KadeEngineData.controls.data.rightBind.toLowerCase()]; + var binds:Array = [GlobalData.controls.leftBind.toLowerCase(), + GlobalData.controls.downBind.toLowerCase(), + GlobalData.controls.upBind.toLowerCase(), + GlobalData.controls.rightBind.toLowerCase()]; var keys = [false, false, false, false]; // kind of rewritten the input ig private function handleInput(evt:KeyboardEvent):Void { // this actually handles press inputs - if (KadeEngineData.botplay || paused) + if (GlobalData.botplay || paused) return; // first convert it from openfl to a flixel key code @@ -546,7 +546,7 @@ class PlayState extends MusicBeatState goodNoteHit(coolNote); } } - else if (!KadeEngineData.settings.data.ghostTap) + else if (!GlobalData.settings.ghostTapping) { noteMissPress(data); } @@ -653,12 +653,10 @@ class PlayState extends MusicBeatState var oldNote:Note = (unspawnNotes.length > 0 ? unspawnNotes[Std.int(unspawnNotes.length - 1)] : null); var susLength:Float = songNotes[2] / Conductor.stepCrochet; - final mechanics:Bool = cast KadeEngineData.settings.data.mechanics && storyDifficulty != 0; - // dont create the special note if mechanics are disabled if (daNoteStyle != null && daNoteStyle != 'n') { - if (!mechanics) + if (!mechanicsOn) continue; else susLength = 0; @@ -670,7 +668,7 @@ class PlayState extends MusicBeatState swagNote.scrollFactor.set(); unspawnNotes.push(swagNote); - if (mechanics && SONG.song == 'Specimen' && dad.curCharacter == 'monster') + if (mechanicsOn && SONG.song == 'Specimen' && dad.curCharacter == 'monster') { var curSpeed:Float = difficultiesStuff.get('specimenNoteSpeed')[storyDifficulty]; @@ -876,7 +874,7 @@ class PlayState extends MusicBeatState 'bf fade', 'blackout', 'arrow flip', 'traductor', 'blackscreen', "cindy move" ]; - if (excludeEvents.contains(daEvent) && KadeEngineData.settings.data.lowQuality) + if (excludeEvents.contains(daEvent) && GlobalData.settings.lowQuality) { trace('Can\'t trigger $daEvent event, low quality option is enabled.'); return; @@ -897,15 +895,15 @@ class PlayState extends MusicBeatState camHUD.zoom += 0.12; case "zoom change": - if (KadeEngineData.settings.data.zooms) + if (GlobalData.settings.camZoomsEnabled) defaultCamZoom += Std.parseFloat(event.value); case "camera zoom": - if (KadeEngineData.settings.data.zooms) + if (GlobalData.settings.camZoomsEnabled) defaultCamZoom = stage.camZoom * Std.parseFloat(event.value); case "flash camera" | "flash white" | "camera flash": - if (KadeEngineData.settings.data.flashing) camGame.flash(FlxColor.WHITE, Std.parseFloat(event.value)); + if (GlobalData.settings.flashingLights) camGame.flash(FlxColor.WHITE, Std.parseFloat(event.value)); case "turn pixel": turnPixel(!isExpellinTime); @@ -924,16 +922,16 @@ class PlayState extends MusicBeatState case "shot": dad.playSpecialAnim('shooting'); - if (!KadeEngineData.settings.data.lowQuality) + if (!GlobalData.settings.lowQuality) { camGame.zoom += 0.08; camHUD.zoom += 0.24; camGame.shake(0.007, 2); } chromatic(0.05, 0, true, 0, 0.5); - if (KadeEngineData.settings.data.flashing && !KadeEngineData.settings.data.lowQuality) camGame.flash(0x7effffff, 0.5); + if (GlobalData.settings.flashingLights && !GlobalData.settings.lowQuality) camGame.flash(0x7effffff, 0.5); - if (storyDifficulty == 0 || !KadeEngineData.settings.data.mechanics) + if (!mechanicsOn) boyfriend.playSpecialAnim('dodge'); case "alt": @@ -1107,7 +1105,7 @@ class PlayState extends MusicBeatState iconP2.animation.play('cindy-bloody'); healthBar.createFilledBar(FlxColor.fromRGB(114, 0, 25, 255), FlxColor.fromString(boyfriend.curColor)); - if (!KadeEngineData.settings.data.lowQuality) + if (!GlobalData.settings.lowQuality) { dad.playSpecialAnim('scared'); gf.forceWhat = true; @@ -1188,7 +1186,7 @@ class PlayState extends MusicBeatState yoyo.die(); clock.ring(); - if (!KadeEngineData.practice && !KadeEngineData.botplay) + if (!GlobalData.practice && !GlobalData.botplay) { var songHighscore = StringTools.replace(states.PlayState.SONG.song, " ", "-"); @@ -1201,10 +1199,10 @@ class PlayState extends MusicBeatState { if (isStoryMode) { - if (!KadeEngineData.botplay && !cast(KadeEngineData.other.data.beatedSongs, Array).contains(SONG.song)) - cast(KadeEngineData.other.data.beatedSongs, Array).push(SONG.song); + if (!GlobalData.botplay && !GlobalData.other.beatenSongs.contains(SONG.song)) + GlobalData.other.beatenSongs.push(SONG.song); - KadeEngineData.flush(); + GlobalData.flush(); storyPlaylist.shift(); @@ -1213,10 +1211,10 @@ class PlayState extends MusicBeatState transIn = FlxTransitionableState.defaultTransIn; transOut = FlxTransitionableState.defaultTransOut; - if (!KadeEngineData.botplay && cast(KadeEngineData.other.data.beatedSongs, Array).contains('Expelled')) + if (!GlobalData.botplay && GlobalData.other.beatenSongs.contains('Expelled')) { - KadeEngineData.other.data.beatedMod = true; - KadeEngineData.flush(); + GlobalData.other.beatenStoryMode = true; + GlobalData.flush(); } FlxG.sound.playMusic(Paths.music('freakyMenu', 'preload'), 0.7); @@ -1292,7 +1290,7 @@ class PlayState extends MusicBeatState var pressArray:Array = [controls.LEFT_P, controls.DOWN_P, controls.UP_P, controls.RIGHT_P]; var releaseArray:Array = [controls.LEFT_R, controls.DOWN_R, controls.UP_R, controls.RIGHT_R]; - if (KadeEngineData.botplay) + if (GlobalData.botplay) { holdArray = [false, false, false, false]; pressArray = [false, false, false, false]; @@ -1311,8 +1309,7 @@ class PlayState extends MusicBeatState }; } - - if (KadeEngineData.botplay) + if (GlobalData.botplay) { for (daNote in notes.members) { @@ -1326,13 +1323,13 @@ class PlayState extends MusicBeatState }; } - if (boyfriend.holdTimer >= boyfriend.getHoldTime() && (!holdArray.contains(true) || KadeEngineData.botplay)) + if (boyfriend.holdTimer >= boyfriend.getHoldTime() && (!holdArray.contains(true) || GlobalData.botplay)) { if (boyfriend.animation.curAnim.name.startsWith('sing') && !boyfriend.animation.curAnim.name.endsWith('miss')) boyfriend.dance(); } - if (!KadeEngineData.botplay) + if (!GlobalData.botplay) { for (spr in playerStrums.members) { @@ -1348,7 +1345,7 @@ class PlayState extends MusicBeatState { if (inCutscene || songFinished) return; - if (FlxG.keys.justPressed.ANY && SONG.song.contains('Expelled') && !KadeEngineData.other.data.didV0) + if (FlxG.keys.justPressed.ANY && SONG.song.contains('Expelled') && !GlobalData.other.didV0) expelledCode(); keyShit(); @@ -1411,7 +1408,7 @@ class PlayState extends MusicBeatState debugEditors(); #end - if (FlxG.keys.justPressed.SPACE && !KadeEngineData.botplay) + if (FlxG.keys.justPressed.SPACE && !GlobalData.botplay) eatApple(true); if (FlxG.keys.justPressed.NINE) @@ -1528,7 +1525,7 @@ class PlayState extends MusicBeatState switch (note.noteStyle) { case 'nuggetP': - if (KadeEngineData.botplay) + if (GlobalData.botplay) return; else { @@ -1588,7 +1585,7 @@ class PlayState extends MusicBeatState { if (Math.abs(note.noteData) == spr.ID && cantPressArray[spr.ID]) { - if (KadeEngineData.botplay) spr.playAnim('confirm', true); + if (GlobalData.botplay) spr.playAnim('confirm', true); else spr.animation.play('confirm', true); } }; @@ -1654,12 +1651,12 @@ class PlayState extends MusicBeatState { if (yoyo != null && curBeat % difficultiesStuff["yoyoFrequency"][storyDifficulty] == 0) yoyo.play(); - if (SONG.song == "Nugget de Polla" && !KadeEngineData.settings.data.lowQuality) + if (SONG.song == "Nugget de Polla" && !GlobalData.settings.lowQuality) { if (curBeat >= 8 && pollaBlock.ID == -1){ pollaBlock.visible = false; pollaBlock.ID = 0; - if (KadeEngineData.settings.data.flashing) FlxG.cameras.flash(); + if (GlobalData.settings.flashingLights) FlxG.cameras.flash(); } if (curBeat >= 8 && traductor != null) @@ -1670,7 +1667,7 @@ class PlayState extends MusicBeatState } } - if (storyDifficulty != 0 && KadeEngineData.settings.data.mechanics && SONG.song == 'Staff Only') //if mechanics are enabled and its janitor song + if (mechanicsOn && SONG.song == 'Staff Only') //if mechanics are enabled and its janitor song { final isAttackTime:Bool = curBeat % difficultiesStuff["janitorHits"][storyDifficulty] == 0; final badAccuracy:Bool = scoreData.accuracy < difficultiesStuff['janitorAccuracy'][storyDifficulty]; @@ -1687,7 +1684,7 @@ class PlayState extends MusicBeatState } if (generatedMusic) - notes.sort(FlxSort.byY, (KadeEngineData.settings.data.downscroll ? FlxSort.ASCENDING : FlxSort.DESCENDING)); + notes.sort(FlxSort.byY, (GlobalData.settings.downscroll ? FlxSort.ASCENDING : FlxSort.DESCENDING)); if (daSection != null && daSection.changeBPM) { @@ -1716,14 +1713,14 @@ class PlayState extends MusicBeatState add(creditPage); } - if (curSong == 'Monday' && KadeEngineData.settings.data.mechanics && storyDifficulty != 0) + if (curSong == 'Monday' && mechanicsOn) { if (curBeat == 32) { - var text:String = (KadeEngineData.settings.data.downscroll ? '' : '<--') + Language.get('Global', 'apples_advice'); + var text:String = (GlobalData.settings.downscroll ? '' : '<--') + Language.get('Global', 'apples_advice'); var page = new PageSprite(text, false, getTimeFromBeats(SECTIONS, 1.5)); page.cameras = [camHUD]; - if (!KadeEngineData.settings.data.downscroll) page.x -= 150; + if (!GlobalData.settings.downscroll) page.x -= 150; add(page); } } @@ -1731,7 +1728,7 @@ class PlayState extends MusicBeatState function bop(force:Bool = false):Void { - if (!KadeEngineData.settings.data.lowQuality && cameraBopBeat < 99) + if (!GlobalData.settings.lowQuality && cameraBopBeat < 99) { if (force || curBeat % cameraBopBeat == 0) { @@ -1797,7 +1794,7 @@ class PlayState extends MusicBeatState vocals.pause(); vocals.stop(); - if (!KadeEngineData.settings.data.lowQuality && SONG.song == 'Specimen' && dad.curCharacter == 'monster') + if (!GlobalData.settings.lowQuality && SONG.song == 'Specimen' && dad.curCharacter == 'monster') { monsterDeath(); return; @@ -1843,7 +1840,7 @@ class PlayState extends MusicBeatState { if (curAnim == anim) { - if (KadeEngineData.settings.data.flashing && KadeEngineData.settings.data.shaders) + if (GlobalData.settings.flashingLights && GlobalData.settings.shadersEnabled) { var shader = new Aberration2(0); add(shader); @@ -1886,7 +1883,7 @@ class PlayState extends MusicBeatState function doNoteSplash(daNote:Note, daRating:String = ""):Void { - if (KadeEngineData.settings.data.lowQuality || (daNote.noteStyle == 'nuggetP' && KadeEngineData.botplay) || daRating != 'sick') + if (GlobalData.settings.lowQuality || (daNote.noteStyle == 'nuggetP' && GlobalData.botplay) || daRating != 'sick') return; var sploosh = splashGroup.recycle(NoteSplash.new); @@ -1896,7 +1893,7 @@ class PlayState extends MusicBeatState function gumNoteMechanic(daNote:Note):Void { - if (!KadeEngineData.settings.data.mechanics || KadeEngineData.botplay || storyDifficulty == 0) + if (!mechanicsOn || GlobalData.botplay) return; if (!cantPressArray[daNote.noteData]) @@ -1949,11 +1946,11 @@ class PlayState extends MusicBeatState function chromatic(value:Float = 0.0025, shakeValue:Float = 0.005, tween:Bool = true, toValue:Float = 0, time:Float = 0.3):Void { - if (!KadeEngineData.settings.data.flashing || !KadeEngineData.settings.data.shaders) - { - trace("woops, no shaders"); - return; - } + if (!GlobalData.settings.flashingLights || !GlobalData.settings.shadersEnabled) + { + trace("woops, no shaders"); + return; + } camGame.shake(shakeValue); @@ -2068,7 +2065,7 @@ class PlayState extends MusicBeatState //idea from impostor v4 BUT, in a different way because the way they made it in impostor v4 sucks (love u clowfoe) - alr this was way better before in terms of performance but now its better in visual terms function trail(char:Character, howManyNotes:Int):Ghost { - if (KadeEngineData.settings.data.lowQuality || didDamage || dad.animation.curAnim.name == 'attack') return null; + if (GlobalData.settings.lowQuality || didDamage || dad.animation.curAnim.name == 'attack') return null; // trace('Applying trail $howManyNotes times.'); var ghost = ghostsGroup.recycle(Ghost.new); @@ -2100,7 +2097,7 @@ class PlayState extends MusicBeatState canPause = true; scoreTxt.visible = false; - if (KadeEngineData.settings.data.flashing && SONG.song != 'Expelled V1') FlxG.cameras.flash(); + if (GlobalData.settings.flashingLights && SONG.song != 'Expelled V1') FlxG.cameras.flash(); }}, function(v) { @@ -2139,12 +2136,12 @@ class PlayState extends MusicBeatState { health = 2; } - else if (health <= 0 && !KadeEngineData.practice && !KadeEngineData.botplay) + else if (health <= 0 && !GlobalData.practice && !GlobalData.botplay) { die(); return; } - else if (health <= 0 && (KadeEngineData.practice || KadeEngineData.botplay)) + else if (health <= 0 && (GlobalData.practice || GlobalData.botplay)) { health = 0.001; } @@ -2155,7 +2152,7 @@ class PlayState extends MusicBeatState return; } - if (KadeEngineData.settings.data.lowQuality) + if (GlobalData.settings.lowQuality) { lerpHealth = health; healthBar.update(FlxG.elapsed); @@ -2206,7 +2203,7 @@ class PlayState extends MusicBeatState if (songFinished) return; - if (!KadeEngineData.settings.data.lowQuality) + if (!GlobalData.settings.lowQuality) { var mult:Float = FlxMath.lerp(1, iconP1.scale.x, CoolUtil.boundTo(1 - (elapsed * 9))); @@ -2233,7 +2230,7 @@ class PlayState extends MusicBeatState if (generatedMusic) { - var downMult:Int = (!KadeEngineData.settings.data.downscroll ? 1 : -1); + var downMult:Int = (!GlobalData.settings.downscroll ? 1 : -1); for (daNote in notes.members) { @@ -2270,7 +2267,7 @@ class PlayState extends MusicBeatState if (daNote.animation.curAnim.name.endsWith('end') && daNote.prevNote != null) { daNote.y -= ((daNote.prevNote.height / 2) * downMult); - if (KadeEngineData.settings.data.downscroll) + if (GlobalData.settings.downscroll) { daNote.y += (daNote.height * 2); @@ -2284,17 +2281,17 @@ class PlayState extends MusicBeatState } } - if (KadeEngineData.settings.data.downscroll) + if (GlobalData.settings.downscroll) { //daNote.flipY = true; - if ((daNote.parent != null && daNote.parent.wasGoodHit) && daNote.y - daNote.offset.y * daNote.scale.y + daNote.height >= center && (KadeEngineData.botplay || (daNote.wasGoodHit || (daNote.prevNote.wasGoodHit && !daNote.canBeHit)))) + if ((daNote.parent != null && daNote.parent.wasGoodHit) && daNote.y - daNote.offset.y * daNote.scale.y + daNote.height >= center && (GlobalData.botplay || (daNote.wasGoodHit || (daNote.prevNote.wasGoodHit && !daNote.canBeHit)))) { daNote.updateRect(center); } } else { - if ((daNote.parent != null && daNote.parent.wasGoodHit) && daNote.y + daNote.offset.y * daNote.scale.y <= center && (KadeEngineData.botplay || (daNote.wasGoodHit || (daNote.prevNote.wasGoodHit && !daNote.canBeHit)))) + if ((daNote.parent != null && daNote.parent.wasGoodHit) && daNote.y + daNote.offset.y * daNote.scale.y <= center && (GlobalData.botplay || (daNote.wasGoodHit || (daNote.prevNote.wasGoodHit && !daNote.canBeHit)))) { daNote.updateRect(center); } @@ -2306,7 +2303,7 @@ class PlayState extends MusicBeatState { dad.sing(daNote.noteData); - if (SONG.song == 'Specimen' && dad.curCharacter == 'monster' && KadeEngineData.settings.data.mechanics && storyDifficulty != 0) + if (SONG.song == 'Specimen' && dad.curCharacter == 'monster' && mechanicsOn) { health -= difficultiesStuff.get('monsterDrain')[storyDifficulty]; @@ -2334,7 +2331,7 @@ class PlayState extends MusicBeatState destroyNote(daNote); } - if ((daNote.mustPress && daNote.tooLate && !KadeEngineData.settings.data.downscroll || daNote.mustPress && daNote.tooLate && KadeEngineData.settings.data.downscroll) && daNote.mustPress) + if ((daNote.mustPress && daNote.tooLate && !GlobalData.settings.downscroll || daNote.mustPress && daNote.tooLate && GlobalData.settings.downscroll) && daNote.mustPress) { if (!daNote.isSustainNote || !daNote.wasGoodHit) noteMiss(daNote.noteData, daNote); @@ -2396,7 +2393,7 @@ class PlayState extends MusicBeatState if (songFinished) return; - if (storyDifficulty != 0 && KadeEngineData.settings.data.mechanics && SONG.song == 'Staff Only') //if mechanics are enabled and its janitor song + if (mechanicsOn && SONG.song == 'Staff Only') //if mechanics are enabled and its janitor song { if (dad.animation.curAnim.name == 'attack' && dad.animation.curAnim.curFrame >= 18 && !didDamage) { @@ -2420,10 +2417,10 @@ class PlayState extends MusicBeatState var offsetX:Float = 480; var offsetY:Float = 270; - if (KadeEngineData.settings.data.changedHit) + if (GlobalData.settings.changedHit) { - offsetX = KadeEngineData.settings.data.changedHitX; - offsetY = KadeEngineData.settings.data.changedHitY; + offsetX = GlobalData.settings.changedHitX; + offsetY = GlobalData.settings.changedHitY; } var seperatedScore:Array = []; @@ -2441,7 +2438,7 @@ class PlayState extends MusicBeatState numbersGroup.add(numScore); } - if(!KadeEngineData.botplay) + if (!GlobalData.botplay) { var rating = ratingsGroup.recycle(Rating.new); rating.play(daRating); @@ -2458,8 +2455,8 @@ class PlayState extends MusicBeatState { // LMFAO NICE TRY MODIFYING FILE'S SHIT LOSER - nvm you still can fuck up the game playing around with the chart files - if (KadeEngineData.other.data.beatedMod && KadeEngineData.other.data.gotSkin) - SONG.player1 = (KadeEngineData.other.data.usingSkin ? 'bf-alt' : 'bf'); + if (GlobalData.other.beatenStoryMode && GlobalData.other.gotSkin) + SONG.player1 = (GlobalData.other.usingSkin ? 'bf-alt' : 'bf'); else SONG.player1 = 'bf'; @@ -2509,7 +2506,7 @@ class PlayState extends MusicBeatState deadBF.graphic.persist = true; } - if (!KadeEngineData.settings.data.lowQuality) + if (!GlobalData.settings.lowQuality) trail(dad, 0).kill(); stage.backgroundSprites.forEach(function(i:BGSprite) @@ -2527,7 +2524,7 @@ class PlayState extends MusicBeatState private inline function dumbIcons():Void { - if (KadeEngineData.botplay || KadeEngineData.practice) + if (GlobalData.botplay || GlobalData.practice) return; //icons shit @@ -2660,7 +2657,7 @@ class PlayState extends MusicBeatState private function addYoyo():Void { - if (SONG.song != 'Cash Grab' || !KadeEngineData.settings.data.mechanics || storyDifficulty == 0) + if (SONG.song != 'Cash Grab' || !mechanicsOn) return; add(yoyo = new Yoyo(playerStrums, camHUD, difficultiesStuff['montyYoyo'][storyDifficulty])); @@ -2669,7 +2666,7 @@ class PlayState extends MusicBeatState private inline function setChrome(daChrome:Float):Void { - if (!['Expelled', 'Expelled V1', 'Expelled V2', 'Nugget de Polla'].contains(SONG.song) || !KadeEngineData.settings.data.flashing || !KadeEngineData.settings.data.shaders) + if (!['Expelled', 'Expelled V1', 'Expelled V2', 'Nugget de Polla'].contains(SONG.song) || !GlobalData.settings.flashingLights || !GlobalData.settings.shadersEnabled) return; if (daChrome == chromVal && daChrome > 0) @@ -2696,12 +2693,12 @@ class PlayState extends MusicBeatState camHUD.filters = []; FlxG.cameras.add(camHUD, false); - if (['Expelled', 'Expelled V1', 'Expelled V2', 'Nugget de Polla'].contains(SONG.song) && KadeEngineData.settings.data.flashing && KadeEngineData.settings.data.shaders) + if (['Expelled', 'Expelled V1', 'Expelled V2', 'Nugget de Polla'].contains(SONG.song) && GlobalData.settings.flashingLights && GlobalData.settings.shadersEnabled) { camHUD.filters = camGame.filters = [ChromaHandler.chromaticAberration]; } - if ((['Expelled V1', 'Expelled V2'].contains(SONG.song) && KadeEngineData.settings.data.mechanics && storyDifficulty != 0) || SONG.song == 'Expelled V0') + if ((['Expelled V1', 'Expelled V2'].contains(SONG.song) && mechanicsOn) || SONG.song == 'Expelled V0') { trace('pedazo de mierda'); pixelShit = new MosaicEffect(); @@ -2774,7 +2771,7 @@ class PlayState extends MusicBeatState // Original from Psych Engine private function setupSpotlights():Void { - if (SONG.song != 'Nugget de Polla' || KadeEngineData.settings.data.lowQuality) + if (SONG.song != 'Nugget de Polla' || GlobalData.settings.lowQuality) return; spotlightBlack = new FlxSprite().makeGraphic(1, 1); @@ -2822,7 +2819,7 @@ class PlayState extends MusicBeatState // Original from Psych Engine private function doSpotlights(event:EpicEvent):Void { - if (SONG.song != 'Nugget de Polla' || KadeEngineData.settings.data.lowQuality) + if (SONG.song != 'Nugget de Polla' || GlobalData.settings.lowQuality) return; var val:Null = Std.parseInt(event.value); @@ -2865,8 +2862,8 @@ class PlayState extends MusicBeatState if (daExpelledCode.length <= 0) { - KadeEngineData.other.data.didV0 = true; - KadeEngineData.flush(); + GlobalData.other.didV0 = true; + GlobalData.flush(); clearNotes(); @@ -2893,4 +2890,9 @@ class PlayState extends MusicBeatState }); } } + + function get_mechanicsOn():Bool + { + return GlobalData.settings.mechanicsEnabled && storyDifficulty != 0; // mechanics are enabled if the setting is set to ON and the difficulty isn't easy + } } \ No newline at end of file diff --git a/source/states/TitleState.hx b/source/states/TitleState.hx index aa2a16d..3f634ca 100644 --- a/source/states/TitleState.hx +++ b/source/states/TitleState.hx @@ -1,5 +1,6 @@ package states; +import data.GlobalData; import flixel.math.FlxMath; import funkin.Conductor; import openfl.Assets; @@ -10,7 +11,6 @@ import flixel.FlxG; import flixel.FlxSprite; import flixel.util.FlxColor; import flixel.util.FlxTimer; -import data.KadeEngineData; class TitleState extends MusicBeatState { @@ -26,8 +26,6 @@ class TitleState extends MusicBeatState { super.create(); - controls.setKeyboardScheme(data.Controls.KeyboardScheme.Duo(true), true); - CoolUtil.title("Main Menu"); CoolUtil.presence(null, Language.get('Discord_Presence', 'title_menu'), false, 0, null); @@ -68,10 +66,10 @@ class TitleState extends MusicBeatState new FlxTimer().start(1, function(_) { - KadeEngineData.flush(); // save fullscreen preference + GlobalData.flush(); // save fullscreen preference - if (KadeEngineData.settings.data.language == null) - funkin.MusicBeatState.switchState(new LanguageState()); + if (GlobalData.settings.language == null) + MusicBeatState.switchState(new LanguageState()); else { Language.populate(); @@ -100,7 +98,7 @@ class TitleState extends MusicBeatState canPressSomething = false; FlxG.fullscreen = !FlxG.fullscreen; - KadeEngineData.settings.data.fullscreen = FlxG.fullscreen; + GlobalData.settings.fullscreen = FlxG.fullscreen; new FlxTimer().start(0.1, function(_) canPressSomething = true); } @@ -183,7 +181,7 @@ class TitleState extends MusicBeatState screen.animation.addByIndices('truetrue', 'screen', [1], "", 0, false); screen.animation.addByIndices('falsefalse', 'screen', [2], "", 0, false); screen.animation.addByIndices('falsetrue', 'screen', [3], "", 0, false); - screen.animation.play((KadeEngineData.settings.data.fullscreen ? 'truefalse' : 'falsefalse')); + screen.animation.play((GlobalData.settings.fullscreen ? 'truefalse' : 'falsefalse')); screen.active = false; add(screen); } diff --git a/source/substates/AntiLeaks.hx b/source/substates/AntiLeaks.hx index 47e9711..d56b0bc 100644 --- a/source/substates/AntiLeaks.hx +++ b/source/substates/AntiLeaks.hx @@ -32,7 +32,7 @@ class AntiLeaks extends funkin.MusicBeatState //I think i have to add this becau { trace("nice"); canPress = false; - if (data.KadeEngineData.settings.data.flashing) FlxG.camera.flash(); + if (GlobalData.settings.flashingLights) FlxG.camera.flash(); new FlxTimer().start(1, function(_) { diff --git a/source/substates/Caching.hx b/source/substates/Caching.hx index abbd190..9960f68 100644 --- a/source/substates/Caching.hx +++ b/source/substates/Caching.hx @@ -48,7 +48,17 @@ class Caching extends MusicBeatState // Thanks Shubs -sqirra FlxGraphic.defaultPersist = true; - Cache.length(); + function bitmapsLength():Void + { + var length:Int = 0; + @:privateAccess + for (key => i in FlxG.bitmap._cache) + length++; + + trace('Cached assets: $length.'); + } + + bitmapsLength(); cacheImage("gameplay/notes/noteSplashes"); cacheImage("gameplay/pixel/noteSplashes"); @@ -64,11 +74,9 @@ class Caching extends MusicBeatState i.destroyOnNoUse = false; } - Cache.length(); - FlxGraphic.defaultPersist = false; - Cache.length(); + bitmapsLength(); #if SKIP_TO_CHARTINGSTATE PlayState.SONG = Song.loadFromJson(Highscore.formatSong('nugget', 2), 'nugget', false); diff --git a/source/substates/ChartingState.hx b/source/substates/ChartingState.hx index 83fdac2..706629d 100644 --- a/source/substates/ChartingState.hx +++ b/source/substates/ChartingState.hx @@ -1,6 +1,6 @@ package substates; -import data.KadeEngineData; +import data.GlobalData; import funkin.MusicBeatState; import openfl.desktop.Clipboard; import flixel.util.FlxStringUtil; @@ -721,20 +721,20 @@ class ChartingState extends funkin.MusicBeatState private function loadAutosave():Void { - KadeEngineData.chart_autosave.flush(); + GlobalData.chart_autosave.flush(); - PlayState.SONG = Song.parseJSONshit(KadeEngineData.chart_autosave.data.chart); + PlayState.SONG = Song.parseJSONshit(GlobalData.chart_autosave.data.chart); MusicBeatState.switchState(new ChartingState()); } private function autosaveSong():Void { - KadeEngineData.chart_autosave.data.chart = Json.stringify({ + GlobalData.chart_autosave.data.chart = Json.stringify({ "song": _song }); // data SHOULD be saved when the game is closed so there's no need to save it everytime you place a note because that increases memory usage - // KadeEngineData.chart_autosave.flush(); + // GlobalData.chart_autosave.flush(); } private function saveLevel() diff --git a/source/substates/EraseData.hx b/source/substates/EraseData.hx index 1ccc0df..65c9be2 100644 --- a/source/substates/EraseData.hx +++ b/source/substates/EraseData.hx @@ -1,5 +1,6 @@ package substates; +import data.GlobalData; import flixel.tweens.FlxEase; import objects.Objects.KinderButton; import flixel.text.FlxText; @@ -88,7 +89,7 @@ class EraseData extends flixel.FlxSubState } else { - data.KadeEngineData.resetData(); + GlobalData.resetData(); close(); } } diff --git a/source/substates/ExpelledSubState.hx b/source/substates/ExpelledSubState.hx index 92bb268..f52a53b 100644 --- a/source/substates/ExpelledSubState.hx +++ b/source/substates/ExpelledSubState.hx @@ -1,6 +1,8 @@ package substates; -import data.KadeEngineData; +import flixel.util.FlxColor; +import data.FCs; +import data.GlobalData; import funkin.MusicBeatState; import states.FreeplayState; import states.PlayState; @@ -44,9 +46,14 @@ class ExpelledSubState extends flixel.FlxSubState text.setFormat(flixel.system.FlxAssets.FONT_DEFAULT, 42, flixel.util.FlxColor.WHITE, CENTER, OUTLINE, flixel.util.FlxColor.BLACK); text.scrollFactor.set(); text.active = false; - if (i == 0 && !KadeEngineData.other.data.didV0) text.visible = false; + if (i == 0 && !GlobalData.other.didV0) text.visible = false; text.ID = i; versions.add(text); + + + if (FCs.check('Expelled' + (i == 3 ? '' : ' ${xd[i]}'))) + text.color = FlxColor.YELLOW; + flixel.tweens.FlxTween.tween(text, {y: FlxG.height / 2 - 70 + (100 * i)}, 1, {ease: flixel.tweens.FlxEase.sineOut}); } diff --git a/source/substates/GameOverSubstate.hx b/source/substates/GameOverSubstate.hx index e4cfe1b..9473ad1 100644 --- a/source/substates/GameOverSubstate.hx +++ b/source/substates/GameOverSubstate.hx @@ -60,7 +60,7 @@ class GameOverSubstate extends funkin.MusicBeatSubstate FlxG.camera.scroll.set(); FlxG.camera.target = null; - bf.playAnim('firstDeath'); + bf.playAnim('firstDeath', true); } override function update(elapsed:Float) @@ -99,7 +99,7 @@ class GameOverSubstate extends funkin.MusicBeatSubstate { new flixel.util.FlxTimer().start(0.5, function(_) //DO I REALLY HAVE TO DO THIS SO THE FUCKING MUSIC DOESNT FADE OUT BECAUSE OF THE DIALOGUE BOX END? { - bf.playAnim('deathLoop'); + bf.playAnim('deathLoop', true); FlxG.sound.playMusic(Paths.music('gameOver', 'shared')); canDoShit = true; }); @@ -118,7 +118,7 @@ class GameOverSubstate extends funkin.MusicBeatSubstate if (!isJanitor && bf.animation.curAnim.name == 'firstDeath' && bf.animation.curAnim.finished) { - bf.playAnim('deathLoop'); + bf.playAnim('deathLoop', true); FlxG.sound.playMusic(Paths.music('gameOver', 'shared')); } diff --git a/source/substates/OptionsAdviceSubstate.hx b/source/substates/OptionsAdviceSubstate.hx index 7332414..24f0f5c 100644 --- a/source/substates/OptionsAdviceSubstate.hx +++ b/source/substates/OptionsAdviceSubstate.hx @@ -1,6 +1,6 @@ package substates; -import data.KadeEngineData; +import data.GlobalData; import options.KindergartenOptions; import funkin.MusicBeatState; import flixel.FlxSubState; @@ -18,8 +18,8 @@ class OptionsAdviceSubstate extends FlxSubState override public function create() { - KadeEngineData.other.data.sawAdvice = true; - KadeEngineData.flush(); + GlobalData.other.sawAdvice = true; + GlobalData.flush(); var bg2 = new FlxSprite().makeGraphic(1, 1, FlxColor.BLACK); bg2.scale.set(FlxG.width, FlxG.height); diff --git a/source/substates/PauseSubState.hx b/source/substates/PauseSubState.hx index 5c4b64a..5660faf 100644 --- a/source/substates/PauseSubState.hx +++ b/source/substates/PauseSubState.hx @@ -7,6 +7,7 @@ import objects.Objects.KinderButton; import flixel.FlxG; import flixel.FlxSprite; import flixel.util.FlxColor; +import data.GlobalData; class PauseSubState extends funkin.MusicBeatSubstate { @@ -54,8 +55,8 @@ class PauseSubState extends funkin.MusicBeatSubstate var menuItems:Array = [ Language.get('PauseScreen', 'resume'), Language.get('PauseScreen', 'restart'), - Language.get('PauseScreen', 'botplay_${data.KadeEngineData.botplay}'), - Language.get('PauseScreen', 'practice_${data.KadeEngineData.practice}'), + Language.get('PauseScreen', 'botplay_${GlobalData.botplay}'), + Language.get('PauseScreen', 'practice_${GlobalData.practice}'), Language.get('PauseScreen', 'options'), Language.get('PauseScreen', 'exit'), ]; @@ -126,10 +127,10 @@ class PauseSubState extends funkin.MusicBeatSubstate case RESTART: MusicBeatState.switchState(new states.PlayState()); case BOTPLAY: - data.KadeEngineData.botplay = !data.KadeEngineData.botplay; + GlobalData.botplay = !GlobalData.botplay; MusicBeatState.switchState(new states.PlayState()); case PRACTICE: - data.KadeEngineData.practice = !data.KadeEngineData.practice; + GlobalData.practice = !GlobalData.practice; MusicBeatState.switchState(new states.PlayState()); case OPTIONS: options = true; diff --git a/source/substates/SelectSkinSubstate.hx b/source/substates/SelectSkinSubstate.hx index 5ddc072..4428e7f 100644 --- a/source/substates/SelectSkinSubstate.hx +++ b/source/substates/SelectSkinSubstate.hx @@ -1,6 +1,6 @@ package substates; -import data.KadeEngineData; +import data.GlobalData; import flixel.FlxG; import flixel.FlxSprite; import flixel.FlxSubState; @@ -72,8 +72,8 @@ class SelectSkinSubstate extends FlxSubState if (FlxG.mouse.justPressed || FlxG.mouse.justPressedRight) { CoolUtil.sound('confirmMenu', 'preload', 0.7); - KadeEngineData.other.data.usingSkin = false; - KadeEngineData.flush(); + GlobalData.other.usingSkin = false; + GlobalData.flush(); close(); } } @@ -89,8 +89,8 @@ class SelectSkinSubstate extends FlxSubState if (FlxG.mouse.justPressed || FlxG.mouse.justPressedRight) { CoolUtil.sound('confirmMenu', 'preload', 0.7); - KadeEngineData.other.data.usingSkin = true; - KadeEngineData.flush(); + GlobalData.other.usingSkin = true; + GlobalData.flush(); close(); } } diff --git a/source/substates/Start.hx b/source/substates/Start.hx index 464e578..26a44c6 100644 --- a/source/substates/Start.hx +++ b/source/substates/Start.hx @@ -1,18 +1,21 @@ package substates; +import Discord.DiscordClient; +import lime.app.Application; import openfl.filters.ColorMatrixFilter; import options.ColorblindMenu; -import data.KadeEngineData; import flixel.FlxG; +import funkin.MusicBeatState; +import data.*; -class Start extends funkin.MusicBeatState +class Start extends MusicBeatState { override function create() { initShit(); - // funkin.MusicBeatState.switchState(new substates.AntiLeaks()); - funkin.MusicBeatState.switchState(new substates.Caching()); + // MusicBeatState.switchState(new substates.AntiLeaks()); + MusicBeatState.switchState(new substates.Caching()); super.create(); } @@ -21,9 +24,7 @@ class Start extends funkin.MusicBeatState { CoolUtil.title('Loading...'); - #if windows - Discord.DiscordClient.initialize(); - #end + DiscordClient.initialize(); dataShit(); settingsShit(); @@ -33,22 +34,16 @@ class Start extends funkin.MusicBeatState private function dataShit() { - data.PlayerSettings.init(); - data.KadeEngineData.initSave(); - data.Highscore.load(); - data.FCs.init(); + GlobalData.initSave(); + Highscore.load(); + FCs.init(); Language.populate(); #if debug - KadeEngineData.autoUnlock(); + GlobalData.autoUnlock(); #end - #if debug - data.KadeEngineData.other.data.compiles++; - trace("TIMES COMPILED: " + data.KadeEngineData.other.data.compiles); - #end - - data.KadeEngineData.flush(); + GlobalData.flush(); } private function settingsShit() @@ -64,49 +59,48 @@ class Start extends funkin.MusicBeatState FlxG.game.focusLostFramerate = 30; - FlxG.signals.preStateSwitch.add(function () { + FlxG.signals.preStateSwitch.add(function () + { FlxG.bitmap.dumpCache(); - // gc(); FlxG.mouse.visible = true; }); FlxG.signals.preStateCreate.add(function (_) { - Cache.uncachCharacters(); + CoolUtil.uncachCharacters(); }); - FlxG.signals.postStateSwitch.add(function () { - // gc(); + FlxG.signals.postStateSwitch.add(function () + { FlxG.mouse.visible = true; (cast (openfl.Lib.current.getChildAt(0), Main)).updateClassIndicator(); - - // Cache.check(); - // Cache.uncachCharacters(); }); - lime.app.Application.current.onExit.add(function(exitCode) - { - #if debug - data.KadeEngineData.chart_autosave.flush(); - #end + Application.current.onExit.add(function(exitCode) + { + #if debug + GlobalData.chart_autosave.flush(); + #end - data.KadeEngineData.flush(); - #if sys - Sys.exit(0); - #end - }); + GlobalData.flush(); - final type = KadeEngineData.settings.data.colorblind; + #if sys + Sys.exit(0); + #end + }); + + final type = GlobalData.settings.colorblindType; if (type == 'No filter') FlxG.game.setFilters([]); else FlxG.game.setFilters([new ColorMatrixFilter(ColorblindMenu.typesMap.get(type))]); - FlxG.fullscreen = KadeEngineData.settings.data.fullscreen; + FlxG.fullscreen = GlobalData.settings.fullscreen; } - private function gc() { + private function gc() + { #if cpp cpp.vm.Gc.run(true); #else diff --git a/source/world/BackyardState.hx b/source/world/BackyardState.hx index bc1f0ae..b081336 100644 --- a/source/world/BackyardState.hx +++ b/source/world/BackyardState.hx @@ -2,7 +2,7 @@ package world; import substates.SkinSubstate; import flixel.FlxSubState; -import data.KadeEngineData; +import data.GlobalData; import flixel.util.FlxColor; import flixel.FlxCamera; import flixel.FlxG; @@ -139,8 +139,8 @@ class BackyardState extends funkin.MusicBeatState if (line == 0) { bf.canMove = false; - KadeEngineData.other.data.gotSkin = true; - KadeEngineData.flush(); + GlobalData.other.gotSkin = true; + GlobalData.flush(); substate.closeCallback = function() { @@ -227,9 +227,9 @@ class BackyardState extends funkin.MusicBeatState private inline function getNuggetLine():Int { - // why not just var data:Dynamic = KadeEngineData.other.data; - sanco + // why not just var data:Dynamic = GlobalData.other; - sanco inline function data():Dynamic // shortcut - return KadeEngineData.other.data; + return GlobalData.other; var nuggetLines:Array = [for (i in 0...11) i]; @@ -237,7 +237,7 @@ class BackyardState extends funkin.MusicBeatState { data().talkedNugget = true; nuggetLines = [3]; // Nugget can't recognize you. - KadeEngineData.flush(); + GlobalData.flush(); } else nuggetLines.remove(3); // Nugget can't recognize you. @@ -250,7 +250,7 @@ class BackyardState extends funkin.MusicBeatState if (data().polla) nuggetLines.remove(1); // Nugget thinks you should type NUGGET in the main menu. - if (!cast(data().beatedSongs, Array).contains('Nugget')) + if (!data().beatedSongs.contains('Nugget')) nuggetLines.remove(6); // Nugget thinks you are trustworthy. Trust is a rare nugget. trace('Locked lines: ${11 - nuggetLines.length} (${[for (i in 0...11) if (!nuggetLines.contains(i)) i]})'); diff --git a/source/world/RoomState.hx b/source/world/RoomState.hx index e9d7243..141d3df 100644 --- a/source/world/RoomState.hx +++ b/source/world/RoomState.hx @@ -1,5 +1,13 @@ package world; +import flixel.util.FlxSort; +import states.MainMenuState; +import funkin.Conductor; +import funkin.Song; +import data.GlobalData; +import data.GlobalData; +import data.Highscore; +import states.PlayState; import funkin.MusicBeatState; import flixel.util.FlxCollision; import flixel.text.FlxText; @@ -11,11 +19,11 @@ import flixel.FlxG; import objects.Kid; import flixel.FlxSprite; -class RoomState extends funkin.MusicBeatState +class RoomState extends MusicBeatState { var background:FlxSprite; var bf:KidBoyfriend; - var protagonist:objects.Kid; + var protagonist:Kid; var hitbox:FlxSprite; var indicator:Indicator; var camara:FlxCamera; @@ -50,7 +58,7 @@ class RoomState extends funkin.MusicBeatState add(group); - protagonist = new objects.Kid(600, 435, 'protagonist'); + protagonist = new Kid(600, 435, 'protagonist'); group.add(protagonist); bf = new KidBoyfriend(1020, 315); @@ -120,18 +128,18 @@ class RoomState extends funkin.MusicBeatState screenFade.active = false; add(screenFade); - states.PlayState.storyPlaylist = ['Monday', 'Nugget', 'Staff Only', 'Cash Grab', 'Expelled']; - var songFormat = StringTools.replace(states.PlayState.storyPlaylist[0], " ", "-"); - var poop:String = data.Highscore.formatSong(songFormat, states.PlayState.storyDifficulty); - trace(poop); - states.PlayState.isStoryMode = true; - states.PlayState.SONG = funkin.Song.loadFromJson(poop, states.PlayState.storyPlaylist[0].toLowerCase()); - states.PlayState.tries = 0; + PlayState.storyPlaylist = ['Monday', 'Nugget', 'Staff Only', 'Cash Grab', 'Expelled']; + var songFormat = StringTools.replace(PlayState.storyPlaylist[0], " ", "-"); + var poop:String = Highscore.formatSong(songFormat, PlayState.storyDifficulty); + + PlayState.isStoryMode = true; + PlayState.SONG = Song.loadFromJson(poop, PlayState.storyPlaylist[0].toLowerCase()); + PlayState.tries = 0; FlxTween.tween(screenFade, {alpha: 1}, 0.5); new FlxTimer().start(0.5, function(_) { - MusicBeatState.switchState(new states.PlayState(), true); + MusicBeatState.switchState(new PlayState(), true); }); } } @@ -142,7 +150,7 @@ class RoomState extends funkin.MusicBeatState { transitioning = true; bf.canMove = false; - funkin.MusicBeatState.switchState(new BackyardState()); + MusicBeatState.switchState(new BackyardState()); } if (FlxG.keys.anyJustPressed([ESCAPE, BACKSPACE])) @@ -152,14 +160,14 @@ class RoomState extends funkin.MusicBeatState bf.animation.play('idle'); FlxG.sound.music.stop(); FlxG.sound.playMusic(Paths.music('freakyMenu', 'preload'), 0.7); - funkin.Conductor.changeBPM(91 * 2); - funkin.MusicBeatState.switchState(new states.MainMenuState()); + Conductor.changeBPM(91 * 2); + MusicBeatState.switchState(new MainMenuState()); } super.update(elapsed); screenCollision(); - group.sort(flixel.util.FlxSort.byY); + group.sort(FlxSort.byY); // FlxG.collide(bf, hitbox); } @@ -201,8 +209,8 @@ class RoomState extends funkin.MusicBeatState function MondayShit():Void { - data.KadeEngineData.other.data.mondays++; - data.KadeEngineData.flush(); + GlobalData.other.mondays++; + GlobalData.flush(); #if debug var isTuesday:Bool = FlxG.random.bool(35); @@ -232,8 +240,8 @@ class RoomState extends funkin.MusicBeatState if (!isTuesday) { var text:String = Language.get('Room', 'again_text'); - - switch(data.KadeEngineData.other.data.mondays) + + switch (GlobalData.other.mondays) { case -1: times.text = "El pepe"; @@ -242,14 +250,13 @@ class RoomState extends funkin.MusicBeatState case 2: times.text = "(" + text + ")"; default: - times.text = "(" + text + " x " + data.KadeEngineData.other.data.mondays + ")"; - + times.text = "(" + text + " x " + GlobalData.other.mondays + ")"; } if (Date.now().getDay() == 1) //psych engine lol { - if (data.KadeEngineData.other.data.mondays >= 2) - times.text = '($literally x ' + data.KadeEngineData.other.data.mondays + ")"; + if (GlobalData.other.mondays >= 2) + times.text = '($literally x ' + GlobalData.other.mondays + ")"; else times.text = '($literally)'; }