From 308af270ebcd630767a8b561d828f6fc12563f29 Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Fri, 12 Apr 2024 12:14:51 +0200 Subject: [PATCH] Small Improvements --- source/funkin/backend/assets/Paths.hx | 4 -- source/funkin/backend/chart/Chart.hx | 2 +- source/funkin/game/PlayState.hx | 42 ++++++++++--------- .../funkin/menus/credits/CreditsCodename.hx | 4 +- source/funkin/menus/credits/CreditsMain.hx | 8 ++-- 5 files changed, 29 insertions(+), 31 deletions(-) diff --git a/source/funkin/backend/assets/Paths.hx b/source/funkin/backend/assets/Paths.hx index aac40ad5..125d4d93 100644 --- a/source/funkin/backend/assets/Paths.hx +++ b/source/funkin/backend/assets/Paths.hx @@ -2,15 +2,11 @@ package funkin.backend.assets; import flixel.graphics.FlxGraphic; import flixel.graphics.frames.FlxAtlasFrames; -import flixel.graphics.frames.FlxAtlasFrames; import flixel.graphics.frames.FlxFramesCollection; -import flixel.system.FlxAssets.FlxGraphicAsset; -import funkin.backend.assets.LimeLibrarySymbol; import funkin.backend.assets.ModsFolder; import funkin.backend.scripting.Script; import haxe.io.Path; import lime.utils.AssetLibrary; -import openfl.utils.AssetType; import openfl.utils.Assets as OpenFlAssets; using StringTools; diff --git a/source/funkin/backend/chart/Chart.hx b/source/funkin/backend/chart/Chart.hx index 0ff0634c..87302b71 100644 --- a/source/funkin/backend/chart/Chart.hx +++ b/source/funkin/backend/chart/Chart.hx @@ -65,7 +65,7 @@ class Chart { data.setFieldDefault("parsedColor", data.color.getColorFromDynamic().getDefault(defaultColor)); if (data.difficulties.length <= 0) { - data.difficulties = [for(f in Paths.getFolderContent('songs/${songName.toLowerCase()}/charts/', false, !fromMods)) if (Path.extension(f = f.toUpperCase()) == "JSON") Path.withoutExtension(f)]; + data.difficulties = [for(f in Paths.getFolderContent('songs/${songName.toLowerCase()}/charts/', false, fromMods ? MODS : SOURCE)) if (Path.extension(f = f.toUpperCase()) == "JSON") Path.withoutExtension(f)]; if (data.difficulties.length == 3) { var hasHard = false, hasNormal = false, hasEasy = false; for(d in data.difficulties) { diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index c4022b10..ee8203ee 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -577,7 +577,7 @@ class PlayState extends MusicBeatState for(folder in scriptsFolders) { for(file in Paths.getFolderContent(folder, true, fromMods ? MODS : BOTH)) { if (folder == 'data/charts/') - Logs.trace('data/charts/ is deprecrated and will be removed in the future. Please move script $file to songs/', WARNING, DARKYELLOW); + Logs.trace('[PlayState] data/charts/ is deprecrated and will be removed in the future. Please move script $file to songs/', WARNING, DARKYELLOW); addScript(file); } @@ -600,7 +600,7 @@ class PlayState extends MusicBeatState // PRECACHING #if REGION - for(content in Paths.getFolderContent('images/game/score/', true, true)) + for(content in Paths.getFolderContent('images/game/score/', true, BOTH)) graphicCache.cache(Paths.getPath(content)); for(i in 1...4) { @@ -758,7 +758,7 @@ class PlayState extends MusicBeatState SaveWarning.warningFunc = saveWarn; SaveWarning.saveFunc = () -> { @:privateAccess Chart.save('${Paths.getAssetsRoot()}/songs/${Charter.__song.toLowerCase()}', - PlayState.SONG, Charter.__diff.toLowerCase(), {saveMetaInChart: false, prettyPrint: Options.editorPrettyPrint}); + SONG, Charter.__diff.toLowerCase(), {saveMetaInChart: false, prettyPrint: Options.editorPrettyPrint}); } } } @@ -799,13 +799,15 @@ class PlayState extends MusicBeatState return; } + var songName = SONG.meta.name.toLowerCase(); + if (cutsceneScriptPath == null) - cutsceneScriptPath = Paths.script('songs/${SONG.meta.name.toLowerCase()}/${prefix}cutscene'); + cutsceneScriptPath = Paths.script('songs/$songName/${prefix}cutscene'); inCutscene = true; - var videoCutscene = Paths.video('${PlayState.SONG.meta.name.toLowerCase()}-${prefix}cutscene'); - var videoCutsceneAlt = Paths.file('songs/${PlayState.SONG.meta.name.toLowerCase()}/${prefix}cutscene.mp4'); - var dialogue = Paths.file('songs/${PlayState.SONG.meta.name.toLowerCase()}/${prefix}dialogue.xml'); + var videoCutscene = Paths.video('$songName-${prefix}cutscene'); + var videoCutsceneAlt = Paths.file('songs/$songName/${prefix}cutscene.mp4'); + var dialogue = Paths.file('songs/$songName/${prefix}dialogue.xml'); persistentUpdate = true; var toCall:Void->Void = function() { if(checkSeen) seenCutscene = true; @@ -1224,9 +1226,9 @@ class PlayState extends MusicBeatState FlxG.switchState(new funkin.editors.charter.Charter(SONG.meta.name, difficulty, false)); } if (FlxG.keys.justPressed.F5) { - Logs.trace('Reloading scripts...', WARNING, YELLOW); + Logs.trace('[PlayState] Reloading scripts...', WARNING, YELLOW); scripts.reload(); - Logs.trace('Song scripts successfully reloaded.', WARNING, GREEN); + Logs.trace('[PlayState] Song scripts successfully reloaded.', WARNING, GREEN); } } @@ -1486,14 +1488,14 @@ class PlayState extends MusicBeatState } else { - trace('LOADING NEXT SONG'); - trace(PlayState.storyPlaylist[0].toLowerCase(), difficulty); + // TODO: make this colored + Logs.trace('[PlayState] Loading next song (${storyPlaylist[0].toLowerCase()}/$difficulty)', VERBOSE); registerSmoothTransition(); FlxG.sound.music.stop(); - PlayState.__loadSong(PlayState.storyPlaylist[0].toLowerCase(), difficulty); + __loadSong(storyPlaylist[0].toLowerCase(), difficulty); FlxG.switchState(new PlayState()); } @@ -1883,12 +1885,12 @@ class PlayState extends MusicBeatState * @param opponentMode Whenever opponent mode is on * @param coopMode Whenever co-op mode is on. */ - public static function loadSong(name:String, difficulty:String = "normal", opponentMode:Bool = false, coopMode:Bool = false) { + public static function loadSong(_name:String, _difficulty:String = "normal", _opponentMode:Bool = false, _coopMode:Bool = false) { isStoryMode = false; - PlayState.opponentMode = opponentMode; + opponentMode = _opponentMode; chartingMode = false; - PlayState.coopMode = coopMode; - __loadSong(name, difficulty); + coopMode = _coopMode; + __loadSong(_name, _difficulty); } /** @@ -1896,11 +1898,11 @@ class PlayState extends MusicBeatState * @param name Song name * @param difficulty Song difficulty */ - public static function __loadSong(name:String, difficulty:String) { - PlayState.difficulty = difficulty; + public static function __loadSong(_name:String, _difficulty:String) { + difficulty = _difficulty; - PlayState.SONG = Chart.parse(name, difficulty); - PlayState.fromMods = PlayState.SONG.fromMods; + SONG = Chart.parse(_name, _difficulty); + fromMods = SONG.fromMods; } } diff --git a/source/funkin/menus/credits/CreditsCodename.hx b/source/funkin/menus/credits/CreditsCodename.hx index 54071446..3e09c990 100644 --- a/source/funkin/menus/credits/CreditsCodename.hx +++ b/source/funkin/menus/credits/CreditsCodename.hx @@ -78,7 +78,7 @@ class CreditsCodename extends funkin.options.OptionsScreen { }); if(error) return false; Options.contributors = idk; - trace('Contributors list Updated!'); + Logs.trace('[CreditsCodename] Contributors list Updated!', VERBOSE); var errorOnMain:Bool = false; var idk2 = GitHub.getOrganizationMembers(author, function(e) { @@ -89,7 +89,7 @@ class CreditsCodename extends funkin.options.OptionsScreen { }); if(!errorOnMain) { Options.mainDevs = [for(m in idk2) m.id]; - trace('Main Devs list Updated!'); + Logs.trace('[CreditsCodename] Main Devs list Updated!', VERBOSE); } return true; diff --git a/source/funkin/menus/credits/CreditsMain.hx b/source/funkin/menus/credits/CreditsMain.hx index 7a6e8d9c..5295b6ed 100644 --- a/source/funkin/menus/credits/CreditsMain.hx +++ b/source/funkin/menus/credits/CreditsMain.hx @@ -26,7 +26,7 @@ class CreditsMain extends TreeMenu { try { access = new Access(Xml.parse(Paths.assetsTree.getSpecificAsset(xmlPath, "TEXT", source))); } catch(e) { - Logs.trace('Error while parsing credits.xml: ${Std.string(e)}', ERROR); + Logs.trace('[CreditsMain] Error while parsing credits.xml: ${Std.string(e)}', ERROR); } if (access != null) @@ -50,7 +50,7 @@ class CreditsMain extends TreeMenu { /** * XML STUFF */ - public function parseCreditsFromXML(xml:Access, source:Bool):Array { + public function parseCreditsFromXML(xml:Access, source:funkin.backend.assets.AssetsLibraryList.AssetSource):Array { var credsMenus:Array = []; for(node in xml.elements) { @@ -58,7 +58,7 @@ class CreditsMain extends TreeMenu { if (node.name == "github") { if (!node.has.user) { - Logs.trace("A github node requires a user attribute.", WARNING); + Logs.trace("[CreditsMain] A github node requires a user attribute.", WARNING); continue; } @@ -75,7 +75,7 @@ class CreditsMain extends TreeMenu { )); } else { if (!node.has.name) { - Logs.trace("A credit node requires a name attribute.", WARNING); + Logs.trace("[CreditsMain] A credit node requires a name attribute.", WARNING); continue; } var name = node.getAtt("name");