From 44a5f4b1beab4de5059e9443d4a53dd39be52154 Mon Sep 17 00:00:00 2001 From: Yoshman29 Date: Sun, 9 Oct 2022 03:46:07 +0200 Subject: [PATCH] HTML5 stuff, now going to sleep gn yall --- source/ChartingState.hx | 16 +++++++++------- source/LoadingState.hx | 5 ----- source/funkin/game/GameOverSubstate.hx | 2 +- source/funkin/game/PlayState.hx | 2 +- source/funkin/macros/BuildCounterMacro.hx | 2 ++ source/funkin/menus/FreeplayState.hx | 6 +++--- source/funkin/menus/StoryMenuState.hx | 2 +- source/funkin/mods/ModsAssetLibrary.hx | 7 +++++-- source/funkin/mods/ModsFolder.hx | 2 ++ source/funkin/system/Paths.hx | 19 +++++++++++++++---- 10 files changed, 39 insertions(+), 24 deletions(-) diff --git a/source/ChartingState.hx b/source/ChartingState.hx index f6a7ec38..96334f10 100644 --- a/source/ChartingState.hx +++ b/source/ChartingState.hx @@ -27,6 +27,7 @@ import flixel.ui.FlxButton; import flixel.ui.FlxSpriteButton; import flixel.util.FlxColor; import haxe.Json; +import haxe.io.Path; import lime.utils.Assets; import openfl.events.Event; import openfl.events.IOErrorEvent; @@ -79,6 +80,8 @@ class ChartingState extends MusicBeatState **/ var curSelectedNote:Array; + var characterList:Array; + var tempBpm:Int = 0; var vocals:FlxSound; @@ -89,6 +92,7 @@ class ChartingState extends MusicBeatState override function create() { curSection = lastSection; + characterList = [for(e in Paths.getFolderContent('data/characters/')) if (Path.extension(e).toLowerCase() == "xml") e.substr(0, e.length-4)]; gridBG = FlxGridOverlay.create(GRID_SIZE, GRID_SIZE, GRID_SIZE * 8, GRID_SIZE * 16); add(gridBG); @@ -176,7 +180,7 @@ class ChartingState extends MusicBeatState add(curRenderedNotes); add(curRenderedSustains); - trace(Paths.getFolderContent('data/characters/')); + super.create(); } @@ -231,17 +235,15 @@ class ChartingState extends MusicBeatState stepperBPM.value = Conductor.bpm; stepperBPM.name = 'song_bpm'; - var characters:Array = CoolUtil.coolTextFile(Paths.txt('characterList')); - - var player1DropDown = new FlxUIDropDownMenu(10, 100, FlxUIDropDownMenu.makeStrIdLabelArray(characters, true), function(character:String) + var player1DropDown = new FlxUIDropDownMenu(10, 100, FlxUIDropDownMenu.makeStrIdLabelArray(characterList, true), function(character:String) { - _song.player1 = characters[Std.parseInt(character)]; + _song.player1 = characterList[Std.parseInt(character)]; }); player1DropDown.selectedLabel = _song.player1; - var player2DropDown = new FlxUIDropDownMenu(140, 100, FlxUIDropDownMenu.makeStrIdLabelArray(characters, true), function(character:String) + var player2DropDown = new FlxUIDropDownMenu(140, 100, FlxUIDropDownMenu.makeStrIdLabelArray(characterList, true), function(character:String) { - _song.player2 = characters[Std.parseInt(character)]; + _song.player2 = characterList[Std.parseInt(character)]; }); player2DropDown.selectedLabel = _song.player2; diff --git a/source/LoadingState.hx b/source/LoadingState.hx index 91f2fb5e..8859ce1b 100644 --- a/source/LoadingState.hx +++ b/source/LoadingState.hx @@ -144,11 +144,6 @@ class LoadingState extends MusicBeatState return Paths.voices(PlayState.SONG.song); } - inline static public function loadAndSwitchState(target:FlxState, stopMusic = false) - { - FlxG.switchState(getNextState(target, stopMusic)); - } - static function getNextState(target:FlxState, stopMusic = false):FlxState { #if NO_PRELOAD_ALL diff --git a/source/funkin/game/GameOverSubstate.hx b/source/funkin/game/GameOverSubstate.hx index a059128e..4af8e8d1 100644 --- a/source/funkin/game/GameOverSubstate.hx +++ b/source/funkin/game/GameOverSubstate.hx @@ -118,7 +118,7 @@ class GameOverSubstate extends MusicBeatSubstate { FlxG.camera.fade(FlxColor.BLACK, 2, false, function() { - LoadingState.loadAndSwitchState(new PlayState()); + FlxG.switchState(new PlayState()); }); }); } diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index cacf8ecd..fb245381 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -1076,7 +1076,7 @@ class PlayState extends MusicBeatState PlayState.SONG = Song.loadFromJson(PlayState.storyPlaylist[0].toLowerCase(), difficulty); FlxG.sound.music.stop(); - LoadingState.loadAndSwitchState(new PlayState()); + FlxG.switchState(new PlayState()); } } else diff --git a/source/funkin/macros/BuildCounterMacro.hx b/source/funkin/macros/BuildCounterMacro.hx index a5178ae5..caf6e2d6 100644 --- a/source/funkin/macros/BuildCounterMacro.hx +++ b/source/funkin/macros/BuildCounterMacro.hx @@ -2,7 +2,9 @@ package funkin.macros; import haxe.macro.Expr.Field; import haxe.macro.Context; +#if sys import sys.io.File; +#end class BuildCounterMacro { // non functional diff --git a/source/funkin/menus/FreeplayState.hx b/source/funkin/menus/FreeplayState.hx index 7dedd698..ba478448 100644 --- a/source/funkin/menus/FreeplayState.hx +++ b/source/funkin/menus/FreeplayState.hx @@ -220,7 +220,7 @@ class FreeplayState extends MusicBeatState // PlayState.storyWeek = songs[curSelected].week; trace('CUR WEEK' + PlayState.storyWeek); - LoadingState.loadAndSwitchState(new PlayState()); + FlxG.switchState(new PlayState()); } } @@ -277,7 +277,7 @@ class FreeplayState extends MusicBeatState for (i in 0...iconArray.length) { - iconArray[i].alpha = lerp(iconArray[i].alpha, songInstPlaying ? 0.45 : 0.6, 0.25); + iconArray[i].alpha = lerp(iconArray[i].alpha, #if PRELOAD_ALL songInstPlaying ? 0.45 : #end 0.6, 0.25); } iconArray[curSelected].alpha = 1; @@ -287,7 +287,7 @@ class FreeplayState extends MusicBeatState item.targetY = bullShit - curSelected; bullShit++; - item.alpha = lerp(item.alpha, songInstPlaying ? 0.45 : 0.6, 0.25); + item.alpha = lerp(item.alpha, #if PRELOAD_ALL songInstPlaying ? 0.45 : #end 0.6, 0.25); // item.setGraphicSize(Std.int(item.width * 0.8)); if (item.targetY == 0) diff --git a/source/funkin/menus/StoryMenuState.hx b/source/funkin/menus/StoryMenuState.hx index 938195e3..5976d089 100644 --- a/source/funkin/menus/StoryMenuState.hx +++ b/source/funkin/menus/StoryMenuState.hx @@ -326,7 +326,7 @@ class StoryMenuState extends MusicBeatState PlayState.campaignScore = 0; new FlxTimer().start(1, function(tmr:FlxTimer) { - LoadingState.loadAndSwitchState(new PlayState(), true); + FlxG.switchState(new PlayState()); }); } } diff --git a/source/funkin/mods/ModsAssetLibrary.hx b/source/funkin/mods/ModsAssetLibrary.hx index 11c32e5b..2b40cb18 100644 --- a/source/funkin/mods/ModsAssetLibrary.hx +++ b/source/funkin/mods/ModsAssetLibrary.hx @@ -1,8 +1,6 @@ package funkin.mods; import lime.utils.Log; -import sys.FileStat; -import sys.FileSystem; import lime.utils.AssetLibrary; import lime.utils.AssetManifest; @@ -17,6 +15,11 @@ import lime.text.Font; import lime.utils.AssetType; import lime.utils.Bytes; +#if sys +import sys.FileStat; +import sys.FileSystem; +#end + using StringTools; class ModsAssetLibrary extends AssetLibrary { diff --git a/source/funkin/mods/ModsFolder.hx b/source/funkin/mods/ModsFolder.hx index ab6514e1..406b67b2 100644 --- a/source/funkin/mods/ModsFolder.hx +++ b/source/funkin/mods/ModsFolder.hx @@ -87,6 +87,7 @@ class ModsFolder { * @param addRoot Whenever the root should be added to the paths. Defaults to false */ public static function getAssetFiles(assets:Array, rootPath:String, path:String, libraryName:String, prefix:String = "", addRoot:Bool = false) { + #if sys for(f in FileSystem.readDirectory('$rootPath$path')) { if (FileSystem.isDirectory('$rootPath$path$f')) { // fuck you git @@ -117,6 +118,7 @@ class ModsFolder { }); } } + #end } public static function checkForOutdatedAssets(assets:ModsAssetLibrary) { diff --git a/source/funkin/system/Paths.hx b/source/funkin/system/Paths.hx index 3cf2ec5b..d03c8cec 100644 --- a/source/funkin/system/Paths.hx +++ b/source/funkin/system/Paths.hx @@ -86,12 +86,12 @@ class Paths inline static public function voices(song:String) { - return getPath('songs/${song.toLowerCase()}/Voices.ogg', MUSIC, null); + return getPath('songs/${song.toLowerCase()}/Voices.$SOUND_EXT', MUSIC, null); } inline static public function inst(song:String) { - return getPath('songs/${song.toLowerCase()}/Inst.ogg', MUSIC, null); + return getPath('songs/${song.toLowerCase()}/Inst.$SOUND_EXT', MUSIC, null); } inline static public function image(key:String, ?library:String) @@ -166,12 +166,23 @@ class Paths } var content:Array = []; + #if sys if (library is funkin.mods.ModsAssetLibrary) { // easy task, can immediatly scan for files! var lib = cast(library, funkin.mods.ModsAssetLibrary); content = lib.getFiles(libThing.symbolName); - } else { - // TODO!! + } else + #end + if (library is lime.utils.AssetLibrary) { + var lib = cast(library, lime.utils.AssetLibrary); + @:privateAccess + for(k=>e in lib.paths) { + if (k.startsWith(libThing.symbolName)) { + var barebonesFileName = k.substr(libThing.symbolName.length); + if (!barebonesFileName.contains("/")) + content.push(barebonesFileName); + } + } } if (includeSource) {