From 404b2b648ec4ce3c3825621cbb39c3889204af65 Mon Sep 17 00:00:00 2001 From: Eric Myllyoja Date: Tue, 8 Mar 2022 03:13:53 -0500 Subject: [PATCH] Modified every file in the codebase to solve a single bug. --- Project.xml | 23 +- .../{assets/preload => }/data/introText.txt | 0 .../preload => }/images/gfDanceTitle.png | Bin source/BGSprite.hx | 64 -- source/BackgroundGirls.hx | 41 - source/Main.hx | 6 +- Preloader.hx => source/Preloader.hx | 0 source/{ => funkin}/Alphabet.hx | 2 +- source/{ => funkin}/Boyfriend.hx | 2 +- source/{ => funkin}/ButtonRemapSubstate.hx | 2 +- source/{ => funkin}/Character.hx | 9 +- source/{ => funkin}/ComboCounter.hx | 2 +- source/{ => funkin}/Conductor.hx | 4 +- source/{ => funkin}/Controls.hx | 2 +- source/{ => funkin}/CoolUtil.hx | 5 +- source/{ => funkin}/CutsceneAnimTestState.hx | 2 +- source/{ => funkin}/CutsceneCharacter.hx | 2 +- source/{ => funkin}/DialogueBox.hx | 3 +- source/{ => funkin}/Discord.hx | 184 +-- source/{ => funkin}/FlxSwf.hx | 2 +- source/{ => funkin}/FlxVideo.hx | 2 +- source/{ => funkin}/FreeplayState.hx | 19 +- source/{ => funkin}/GameOverSubstate.hx | 7 +- source/{ => funkin}/GitarooPause.hx | 3 +- source/{ => funkin}/HealthIcon.hx | 3 +- source/{ => funkin}/Highscore.hx | 2 +- source/{ => funkin}/InitState.hx | 15 +- source/{ => funkin}/InputFormatter.hx | 4 +- source/{ => funkin}/LatencyState.hx | 2 +- source/{ => funkin}/LoadingState.hx | 3 +- source/{ => funkin}/MainMenuState.hx | 18 +- source/{ => funkin}/MemoryCounter.hx | 2 + source/{ => funkin}/MenuCharacter.hx | 2 +- source/{ => funkin}/MenuItem.hx | 2 +- source/{ => funkin}/MusicBeatState.hx | 4 +- source/{ => funkin}/MusicBeatSubstate.hx | 4 +- source/{ => funkin}/NGio.hx | 2 +- source/{ => funkin}/Note.hx | 7 +- source/{ => funkin}/NoteSplash.hx | 5 +- source/{ => funkin}/Options.hx | 2 +- source/{ => funkin}/OutdatedSubState.hx | 4 +- source/{ => funkin}/Paths.hx | 2 +- source/{ => funkin}/PauseSubState.hx | 5 +- source/{ => funkin}/PlayerSettings.hx | 4 +- source/{ => funkin}/Section.hx | 4 +- source/{ => funkin}/SongLoad.hx | 6 +- source/{ => funkin}/StoryMenuState.hx | 3 +- source/{ => funkin}/SwagCamera.hx | 2 +- source/{ => funkin}/TankCutscene.hx | 2 +- source/{ => funkin}/TitleState.hx | 12 +- source/{ => funkin}/VideoState.hx | 2 +- source/{ => funkin}/VoicesGroup.hx | 2 + source/{ => funkin}/animate/AnimTestStage.hx | 2 +- .../{ => funkin}/animate/AnimateTimeline.hx | 4 +- source/{ => funkin}/animate/FlxAnimate.hx | 10 +- source/{ => funkin}/animate/FlxSymbol.hx | 16 +- source/{ => funkin}/animate/ParseAnimate.hx | 2 +- source/{ => funkin}/animate/TimelineFrame.hx | 4 +- source/{ => funkin}/audiovis/ABotVis.hx | 6 +- .../audiovis/PolygonSpectogram.hx | 6 +- .../{ => funkin}/audiovis/SpectogramSprite.hx | 8 +- source/{ => funkin}/audiovis/VisShit.hx | 4 +- source/{ => funkin}/audiovis/dsp/Complex.hx | 2 +- source/{ => funkin}/audiovis/dsp/FFT.hx | 8 +- .../{ => funkin}/audiovis/dsp/OffsetArray.hx | 2 +- source/{ => funkin}/audiovis/dsp/Signal.hx | 2 +- source/{ => funkin}/charting/ChartingState.hx | 19 +- .../freeplayStuff/BGScrollingText.hx | 2 +- .../{ => funkin}/freeplayStuff/DJBoyfriend.hx | 2 +- .../freeplayStuff/FreeplayScore.hx | 4 +- .../freeplayStuff/SongMenuItem.hx | 2 +- source/{ => funkin}/i18n/FireTongueHandler.hx | 2 +- source/{ => funkin}/i18n/README.md | 0 source/{ => funkin}/import.hx | 2 +- source/{ => funkin}/modding/IHook.hx | 26 +- .../modding/PolymodErrorHandler.hx | 2 +- source/{ => funkin}/modding/PolymodHandler.hx | 331 +++--- source/{ => funkin}/modding/base/README.md | 0 .../modding/base/ScriptedFlxSprite.hx | 4 +- .../modding/base/ScriptedFlxSpriteGroup.hx | 4 +- source/{ => funkin}/play/Fighter.hx | 2 +- source/{ => funkin}/play/PicoFight.hx | 6 +- source/{ => funkin/play}/PlayState.hx | 36 +- .../{ => funkin}/play/character/Character.hx | 18 +- source/{ => funkin}/play/stage/Bopper.hx | 2 +- .../{ => funkin}/play/stage/ScriptedBopper.hx | 4 +- .../{ => funkin}/play/stage/ScriptedStage.hx | 18 +- source/{ => funkin}/play/stage/Stage.hx | 10 +- source/{ => funkin}/play/stage/StageData.hx | 1018 ++++++++--------- source/{ => funkin}/rendering/MeshRender.hx | 2 +- source/{ => funkin}/shaderslmfao/AngleMask.hx | 2 +- .../shaderslmfao}/BlendModeEffect.hx | 2 +- .../shaderslmfao/BuildingShaders.hx | 2 +- source/{ => funkin}/shaderslmfao/ColorSwap.hx | 2 +- .../shaderslmfao/MultiplyShader.hx | 4 +- .../{ => funkin}/shaderslmfao/OverlayBlend.hx | 3 +- source/{ => funkin}/shaderslmfao/PureColor.hx | 2 +- .../shaderslmfao/ScreenWipeShader.hx | 2 +- .../{ => funkin}/shaderslmfao/StrokeShader.hx | 2 +- .../{ => funkin}/shaderslmfao/TitleOutline.hx | 2 +- .../{ => funkin}/shaderslmfao/WaveShader.hx | 2 +- .../{ => funkin}/shaderslmfao/WiggleEffect.hx | 2 +- source/{ => funkin}/ui/AtlasMenuList.hx | 36 +- source/{ => funkin}/ui/AtlasText.hx | 147 +-- source/{ => funkin}/ui/ColorsMenu.hx | 5 +- source/{ => funkin}/ui/ControlsMenu.hx | 12 +- source/{ => funkin}/ui/MenuList.hx | 2 +- source/{ => funkin}/ui/ModMenu.hx | 7 +- source/{ => funkin}/ui/NgPrompt.hx | 95 +- source/{ => funkin}/ui/OptionsState.hx | 4 +- source/{ => funkin}/ui/PopUpStuff.hx | 3 +- source/{ => funkin}/ui/PreferencesMenu.hx | 11 +- source/{ => funkin}/ui/Prompt.hx | 6 +- source/{ => funkin}/ui/TextMenuList.hx | 6 +- .../ui/animDebugShit/DebugBoundingState.hx | 2 +- .../ui/stageBuildShit/CharStage.hx | 2 +- .../ui/stageBuildShit/SprStage.hx | 2 +- .../ui/stageBuildShit/StageBuilderState.hx | 2 +- .../ui/stageBuildShit/StagetoolBar.hx | 2 +- source/{ => funkin}/util/SortUtil.hx | 2 +- source/{ => funkin}/util/assets/DataAssets.hx | 60 +- source/{ => funkin}/util/macro/FlxMacro.hx | 2 +- source/{ => funkin}/util/macro/MacroUtil.hx | 24 +- 123 files changed, 1254 insertions(+), 1308 deletions(-) rename example_mods/introMod/{assets/preload => }/data/introText.txt (100%) rename example_mods/introMod/{assets/preload => }/images/gfDanceTitle.png (100%) delete mode 100644 source/BGSprite.hx delete mode 100644 source/BackgroundGirls.hx rename Preloader.hx => source/Preloader.hx (100%) rename source/{ => funkin}/Alphabet.hx (99%) rename source/{ => funkin}/Boyfriend.hx (98%) rename source/{ => funkin}/ButtonRemapSubstate.hx (88%) rename source/{ => funkin}/Character.hx (99%) rename source/{ => funkin}/ComboCounter.hx (99%) rename source/{ => funkin}/Conductor.hx (96%) rename source/{ => funkin}/Controls.hx (99%) rename source/{ => funkin}/CoolUtil.hx (97%) rename source/{ => funkin}/CutsceneAnimTestState.hx (99%) rename source/{ => funkin}/CutsceneCharacter.hx (99%) rename source/{ => funkin}/DialogueBox.hx (99%) rename source/{ => funkin}/Discord.hx (94%) rename source/{ => funkin}/FlxSwf.hx (97%) rename source/{ => funkin}/FlxVideo.hx (98%) rename source/{ => funkin}/FreeplayState.hx (97%) rename source/{ => funkin}/GameOverSubstate.hx (97%) rename source/{ => funkin}/GitarooPause.hx (97%) rename source/{ => funkin}/HealthIcon.hx (97%) rename source/{ => funkin}/Highscore.hx (99%) rename source/{ => funkin}/InitState.hx (95%) rename source/{ => funkin}/InputFormatter.hx (99%) rename source/{ => funkin}/LatencyState.hx (98%) rename source/{ => funkin}/LoadingState.hx (99%) rename source/{ => funkin}/MainMenuState.hx (96%) rename source/{ => funkin}/MemoryCounter.hx (98%) rename source/{ => funkin}/MenuCharacter.hx (98%) rename source/{ => funkin}/MenuItem.hx (98%) rename source/{ => funkin}/MusicBeatState.hx (96%) rename source/{ => funkin}/MusicBeatSubstate.hx (95%) rename source/{ => funkin}/NGio.hx (99%) rename source/{ => funkin}/Note.hx (98%) rename source/{ => funkin}/NoteSplash.hx (94%) rename source/{ => funkin}/Options.hx (79%) rename source/{ => funkin}/OutdatedSubState.hx (96%) rename source/{ => funkin}/Paths.hx (99%) rename source/{ => funkin}/PauseSubState.hx (98%) rename source/{ => funkin}/PlayerSettings.hx (99%) rename source/{ => funkin}/Section.hx (92%) rename source/{ => funkin}/SongLoad.hx (98%) rename source/{ => funkin}/StoryMenuState.hx (99%) rename source/{ => funkin}/SwagCamera.hx (99%) rename source/{ => funkin}/TankCutscene.hx (96%) rename source/{ => funkin}/TitleState.hx (98%) rename source/{ => funkin}/VideoState.hx (99%) rename source/{ => funkin}/VoicesGroup.hx (99%) rename source/{ => funkin}/animate/AnimTestStage.hx (96%) rename source/{ => funkin}/animate/AnimateTimeline.hx (94%) rename source/{ => funkin}/animate/FlxAnimate.hx (97%) rename source/{ => funkin}/animate/FlxSymbol.hx (84%) rename source/{ => funkin}/animate/ParseAnimate.hx (99%) rename source/{ => funkin}/animate/TimelineFrame.hx (94%) rename source/{ => funkin}/audiovis/ABotVis.hx (97%) rename source/{ => funkin}/audiovis/PolygonSpectogram.hx (96%) rename source/{ => funkin}/audiovis/SpectogramSprite.hx (98%) rename source/{ => funkin}/audiovis/VisShit.hx (98%) rename source/{ => funkin}/audiovis/dsp/Complex.hx (98%) rename source/{ => funkin}/audiovis/dsp/FFT.hx (97%) rename source/{ => funkin}/audiovis/dsp/OffsetArray.hx (98%) rename source/{ => funkin}/audiovis/dsp/Signal.hx (98%) rename source/{ => funkin}/charting/ChartingState.hx (99%) rename source/{ => funkin}/freeplayStuff/BGScrollingText.hx (98%) rename source/{ => funkin}/freeplayStuff/DJBoyfriend.hx (97%) rename source/{ => funkin}/freeplayStuff/FreeplayScore.hx (96%) rename source/{ => funkin}/freeplayStuff/SongMenuItem.hx (98%) rename source/{ => funkin}/i18n/FireTongueHandler.hx (99%) rename source/{ => funkin}/i18n/README.md (100%) rename source/{ => funkin}/import.hx (88%) rename source/{ => funkin}/modding/IHook.hx (92%) rename source/{ => funkin}/modding/PolymodErrorHandler.hx (98%) rename source/{ => funkin}/modding/PolymodHandler.hx (85%) rename source/{ => funkin}/modding/base/README.md (100%) rename source/{ => funkin}/modding/base/ScriptedFlxSprite.hx (72%) rename source/{ => funkin}/modding/base/ScriptedFlxSpriteGroup.hx (75%) rename source/{ => funkin}/play/Fighter.hx (97%) rename source/{ => funkin}/play/PicoFight.hx (98%) rename source/{ => funkin/play}/PlayState.hx (98%) rename source/{ => funkin}/play/character/Character.hx (59%) rename source/{ => funkin}/play/stage/Bopper.hx (98%) rename source/{ => funkin}/play/stage/ScriptedBopper.hx (69%) rename source/{ => funkin}/play/stage/ScriptedStage.hx (68%) rename source/{ => funkin}/play/stage/Stage.hx (98%) rename source/{ => funkin}/play/stage/StageData.hx (95%) rename source/{ => funkin}/rendering/MeshRender.hx (98%) rename source/{ => funkin}/shaderslmfao/AngleMask.hx (96%) rename source/{ => funkin/shaderslmfao}/BlendModeEffect.hx (96%) rename source/{ => funkin}/shaderslmfao/BuildingShaders.hx (96%) rename source/{ => funkin}/shaderslmfao/ColorSwap.hx (99%) rename source/{ => funkin}/shaderslmfao/MultiplyShader.hx (95%) rename source/{ => funkin}/shaderslmfao/OverlayBlend.hx (97%) rename source/{ => funkin}/shaderslmfao/PureColor.hx (96%) rename source/{ => funkin}/shaderslmfao/ScreenWipeShader.hx (98%) rename source/{ => funkin}/shaderslmfao/StrokeShader.hx (98%) rename source/{ => funkin}/shaderslmfao/TitleOutline.hx (98%) rename source/{ => funkin}/shaderslmfao/WaveShader.hx (91%) rename source/{ => funkin}/shaderslmfao/WiggleEffect.hx (99%) rename source/{ => funkin}/ui/AtlasMenuList.hx (86%) rename source/{ => funkin}/ui/AtlasText.hx (80%) rename source/{ => funkin}/ui/ColorsMenu.hx (94%) rename source/{ => funkin}/ui/ControlsMenu.hx (97%) rename source/{ => funkin}/ui/MenuList.hx (99%) rename source/{ => funkin}/ui/ModMenu.hx (95%) rename source/{ => funkin}/ui/NgPrompt.hx (52%) rename source/{ => funkin}/ui/OptionsState.hx (98%) rename source/{ => funkin}/ui/PopUpStuff.hx (98%) rename source/{ => funkin}/ui/PreferencesMenu.hx (96%) rename source/{ => funkin}/ui/Prompt.hx (97%) rename source/{ => funkin}/ui/TextMenuList.hx (94%) rename source/{ => funkin}/ui/animDebugShit/DebugBoundingState.hx (99%) rename source/{ => funkin}/ui/stageBuildShit/CharStage.hx (80%) rename source/{ => funkin}/ui/stageBuildShit/SprStage.hx (96%) rename source/{ => funkin}/ui/stageBuildShit/StageBuilderState.hx (99%) rename source/{ => funkin}/ui/stageBuildShit/StagetoolBar.hx (91%) rename source/{ => funkin}/util/SortUtil.hx (95%) rename source/{ => funkin}/util/assets/DataAssets.hx (92%) rename source/{ => funkin}/util/macro/FlxMacro.hx (97%) rename source/{ => funkin}/util/macro/MacroUtil.hx (88%) diff --git a/Project.xml b/Project.xml index bb17c848d..1382f5f71 100644 --- a/Project.xml +++ b/Project.xml @@ -2,7 +2,7 @@ - + @@ -181,13 +181,23 @@ + + + + - + + + + + - + + + @@ -196,13 +206,6 @@ - - - - diff --git a/example_mods/introMod/assets/preload/data/introText.txt b/example_mods/introMod/data/introText.txt similarity index 100% rename from example_mods/introMod/assets/preload/data/introText.txt rename to example_mods/introMod/data/introText.txt diff --git a/example_mods/introMod/assets/preload/images/gfDanceTitle.png b/example_mods/introMod/images/gfDanceTitle.png similarity index 100% rename from example_mods/introMod/assets/preload/images/gfDanceTitle.png rename to example_mods/introMod/images/gfDanceTitle.png diff --git a/source/BGSprite.hx b/source/BGSprite.hx deleted file mode 100644 index 45894efa6..000000000 --- a/source/BGSprite.hx +++ /dev/null @@ -1,64 +0,0 @@ -package; - -import flixel.FlxSprite; - -class BGSprite extends FlxSprite -{ - /** - Cool lil utility thing just so that it can easy do antialiasing and scrollfactor bullshit - */ - public var idleAnim:String; - - /** - * NOTE: loadOldWay param is just for current backward compatibility! Will be moved later! - */ - public function new(image:String, x:Float = 0, y:Float = 0, parX:Float = 1, parY:Float = 1, ?daAnimations:Array, ?loopingAnim:Bool = false, - ?loadOldWay:Bool = true) - { - super(x, y); - - if (loadOldWay) - { - if (daAnimations != null) - { - setupSparrow(image, daAnimations, loopingAnim); - } - else - { - justLoadImage(image); - } - } - - scrollFactor.set(parX, parY); - antialiasing = true; - } - - public function setupSparrow(image:String, daAnimations:Array, ?loopingAnim:Bool = false) - { - frames = Paths.getSparrowAtlas(image); - for (anims in daAnimations) - { - var daLoop:Bool = loopingAnim; - if (loopingAnim == null) - daLoop = false; - - animation.addByPrefix(anims, anims, 24, daLoop); - animation.play(anims); - - if (idleAnim == null) - idleAnim = anims; - } - } - - public function justLoadImage(image:String) - { - loadGraphic(Paths.image(image)); - active = false; - } - - public function dance():Void - { - if (idleAnim != null) - animation.play(idleAnim); - } -} diff --git a/source/BackgroundGirls.hx b/source/BackgroundGirls.hx deleted file mode 100644 index 1a6030362..000000000 --- a/source/BackgroundGirls.hx +++ /dev/null @@ -1,41 +0,0 @@ -package; - -import flixel.FlxSprite; -import flixel.graphics.frames.FlxAtlasFrames; - -class BackgroundGirls extends FlxSprite -{ - public function new(x:Float, y:Float) - { - super(x, y); - - // BG fangirls dissuaded - frames = Paths.getSparrowAtlas('weeb/bgFreaks'); - - animation.addByIndices('danceLeft', 'BG girls group', CoolUtil.numberArray(14), "", 24, false); - animation.addByIndices('danceRight', 'BG girls group', CoolUtil.numberArray(30, 15), "", 24, false); - - animation.play('danceLeft'); - animation.finish(); - } - - var danceDir:Bool = false; - - public function getScared():Void - { - animation.addByIndices('danceLeft', 'BG fangirls dissuaded', CoolUtil.numberArray(14), "", 24, false); - animation.addByIndices('danceRight', 'BG fangirls dissuaded', CoolUtil.numberArray(30, 15), "", 24, false); - dance(); - animation.finish(); - } - - public function dance():Void - { - danceDir = !danceDir; - - if (danceDir) - animation.play('danceRight', true); - else - animation.play('danceLeft', true); - } -} diff --git a/source/Main.hx b/source/Main.hx index 1a36a0f03..fb2a01a69 100644 --- a/source/Main.hx +++ b/source/Main.hx @@ -1,5 +1,7 @@ package; +import funkin.InitState; +import funkin.MemoryCounter; import flixel.FlxGame; import flixel.FlxState; import openfl.Lib; @@ -42,9 +44,9 @@ class Main extends Sprite // A design similar to that of Minecraft resource packs would be intuitive. // 3. The interface should save (to the save file) and output an ordered array of mod IDs. // 4. Replace the call to PolymodHandler.loadAllMods() with a call to PolymodHandler.loadModsById(ids:Array). - modding.PolymodHandler.loadAllMods(); + funkin.modding.PolymodHandler.loadAllMods(); - i18n.FireTongueHandler.init(); + funkin.i18n.FireTongueHandler.init(); if (stage != null) { diff --git a/Preloader.hx b/source/Preloader.hx similarity index 100% rename from Preloader.hx rename to source/Preloader.hx diff --git a/source/Alphabet.hx b/source/funkin/Alphabet.hx similarity index 99% rename from source/Alphabet.hx rename to source/funkin/Alphabet.hx index 5caaccbf4..018882e0c 100644 --- a/source/Alphabet.hx +++ b/source/funkin/Alphabet.hx @@ -1,4 +1,4 @@ -package; +package funkin; import flixel.FlxSprite; import flixel.graphics.frames.FlxAtlasFrames; diff --git a/source/Boyfriend.hx b/source/funkin/Boyfriend.hx similarity index 98% rename from source/Boyfriend.hx rename to source/funkin/Boyfriend.hx index d407ae8ab..12bf7553e 100644 --- a/source/Boyfriend.hx +++ b/source/funkin/Boyfriend.hx @@ -1,4 +1,4 @@ -package; +package funkin; import flixel.FlxSprite; import flixel.graphics.frames.FlxAtlasFrames; diff --git a/source/ButtonRemapSubstate.hx b/source/funkin/ButtonRemapSubstate.hx similarity index 88% rename from source/ButtonRemapSubstate.hx rename to source/funkin/ButtonRemapSubstate.hx index 64ff07948..35c7a1476 100644 --- a/source/ButtonRemapSubstate.hx +++ b/source/funkin/ButtonRemapSubstate.hx @@ -1,4 +1,4 @@ -package; +package funkin; import flixel.FlxSubState; diff --git a/source/Character.hx b/source/funkin/Character.hx similarity index 99% rename from source/Character.hx rename to source/funkin/Character.hx index 94c8dedf6..5c266078a 100644 --- a/source/Character.hx +++ b/source/funkin/Character.hx @@ -1,13 +1,14 @@ -package; +package funkin; -import Note.NoteData; -import SongLoad.SwagSong; -import Section.SwagSection; +import funkin.Note.NoteData; +import funkin.SongLoad.SwagSong; +import funkin.Section.SwagSection; import flixel.FlxSprite; import flixel.animation.FlxBaseAnimation; import flixel.graphics.frames.FlxAtlasFrames; import flixel.util.FlxSort; import haxe.io.Path; +import funkin.play.PlayState; using StringTools; diff --git a/source/ComboCounter.hx b/source/funkin/ComboCounter.hx similarity index 99% rename from source/ComboCounter.hx rename to source/funkin/ComboCounter.hx index a7f9c921f..a5f8b71b5 100644 --- a/source/ComboCounter.hx +++ b/source/funkin/ComboCounter.hx @@ -1,4 +1,4 @@ -package; +package funkin; import flixel.FlxSprite; import flixel.group.FlxGroup.FlxTypedGroup; diff --git a/source/Conductor.hx b/source/funkin/Conductor.hx similarity index 96% rename from source/Conductor.hx rename to source/funkin/Conductor.hx index a1a010ef7..765686740 100644 --- a/source/Conductor.hx +++ b/source/funkin/Conductor.hx @@ -1,6 +1,6 @@ -package; +package funkin; -import SongLoad.SwagSong; +import funkin.SongLoad.SwagSong; /** * ... diff --git a/source/Controls.hx b/source/funkin/Controls.hx similarity index 99% rename from source/Controls.hx rename to source/funkin/Controls.hx index 82a44af0f..31b2933f2 100644 --- a/source/Controls.hx +++ b/source/funkin/Controls.hx @@ -1,4 +1,4 @@ -package; +package funkin; import flixel.FlxObject; import flixel.input.FlxInput; diff --git a/source/CoolUtil.hx b/source/funkin/CoolUtil.hx similarity index 97% rename from source/CoolUtil.hx rename to source/funkin/CoolUtil.hx index d548ab7b8..60e12f343 100644 --- a/source/CoolUtil.hx +++ b/source/funkin/CoolUtil.hx @@ -1,4 +1,4 @@ -package; +package funkin; import flixel.FlxSprite; import flixel.FlxState; @@ -15,7 +15,8 @@ import haxe.format.JsonParser; import lime.math.Rectangle; import lime.utils.Assets; import openfl.filters.ShaderFilter; -import shaderslmfao.ScreenWipeShader; +import funkin.play.PlayState; +import funkin.shaderslmfao.ScreenWipeShader; using StringTools; diff --git a/source/CutsceneAnimTestState.hx b/source/funkin/CutsceneAnimTestState.hx similarity index 99% rename from source/CutsceneAnimTestState.hx rename to source/funkin/CutsceneAnimTestState.hx index eddbfe62e..ae2a0b80f 100644 --- a/source/CutsceneAnimTestState.hx +++ b/source/funkin/CutsceneAnimTestState.hx @@ -1,4 +1,4 @@ -package; +package funkin; import flixel.FlxSprite; import flixel.FlxState; diff --git a/source/CutsceneCharacter.hx b/source/funkin/CutsceneCharacter.hx similarity index 99% rename from source/CutsceneCharacter.hx rename to source/funkin/CutsceneCharacter.hx index c85d53b92..cf2caa870 100644 --- a/source/CutsceneCharacter.hx +++ b/source/funkin/CutsceneCharacter.hx @@ -1,4 +1,4 @@ -package; +package funkin; import flixel.FlxSprite; import flixel.group.FlxGroup.FlxTypedGroup; diff --git a/source/DialogueBox.hx b/source/funkin/DialogueBox.hx similarity index 99% rename from source/DialogueBox.hx rename to source/funkin/DialogueBox.hx index 75b9ea30d..cc582cc84 100644 --- a/source/DialogueBox.hx +++ b/source/funkin/DialogueBox.hx @@ -1,4 +1,4 @@ -package; +package funkin; import flixel.FlxSprite; import flixel.addons.text.FlxTypeText; @@ -8,6 +8,7 @@ import flixel.input.FlxKeyManager; import flixel.text.FlxText; import flixel.util.FlxColor; import flixel.util.FlxTimer; +import funkin.play.PlayState; using StringTools; diff --git a/source/Discord.hx b/source/funkin/Discord.hx similarity index 94% rename from source/Discord.hx rename to source/funkin/Discord.hx index 04e9ebfa1..34fce44ed 100644 --- a/source/Discord.hx +++ b/source/funkin/Discord.hx @@ -1,92 +1,92 @@ -package; - -import Sys.sleep; - -using StringTools; - -#if discord_rpc -import discord_rpc.DiscordRpc; -#end - -class DiscordClient -{ - #if discord_rpc - public function new() - { - trace("Discord Client starting..."); - DiscordRpc.start({ - clientID: "814588678700924999", - onReady: onReady, - onError: onError, - onDisconnected: onDisconnected - }); - trace("Discord Client started."); - - while (true) - { - DiscordRpc.process(); - sleep(2); - // trace("Discord Client Update"); - } - - DiscordRpc.shutdown(); - } - - public static function shutdown() - { - DiscordRpc.shutdown(); - } - - static function onReady() - { - DiscordRpc.presence({ - details: "In the Menus", - state: null, - largeImageKey: 'icon', - largeImageText: "Friday Night Funkin'" - }); - } - - static function onError(_code:Int, _message:String) - { - trace('Error! $_code : $_message'); - } - - static function onDisconnected(_code:Int, _message:String) - { - trace('Disconnected! $_code : $_message'); - } - - public static function initialize() - { - var DiscordDaemon = sys.thread.Thread.create(() -> - { - new DiscordClient(); - }); - trace("Discord Client initialized"); - } - - public static function changePresence(details:String, state:Null, ?smallImageKey:String, ?hasStartTimestamp:Bool, ?endTimestamp:Float) - { - var startTimestamp:Float = if (hasStartTimestamp) Date.now().getTime() else 0; - - if (endTimestamp > 0) - { - endTimestamp = startTimestamp + endTimestamp; - } - - DiscordRpc.presence({ - details: details, - state: state, - largeImageKey: 'icon', - largeImageText: "Friday Night Funkin'", - smallImageKey: smallImageKey, - // Obtained times are in milliseconds so they are divided so Discord can use it - startTimestamp: Std.int(startTimestamp / 1000), - endTimestamp: Std.int(endTimestamp / 1000) - }); - - // trace('Discord RPC Updated. Arguments: $details, $state, $smallImageKey, $hasStartTimestamp, $endTimestamp'); - } - #end -} +package funkin; + +import Sys.sleep; + +using StringTools; + +#if discord_rpc +import discord_rpc.DiscordRpc; +#end + +class DiscordClient +{ + #if discord_rpc + public function new() + { + trace("Discord Client starting..."); + DiscordRpc.start({ + clientID: "814588678700924999", + onReady: onReady, + onError: onError, + onDisconnected: onDisconnected + }); + trace("Discord Client started."); + + while (true) + { + DiscordRpc.process(); + sleep(2); + // trace("Discord Client Update"); + } + + DiscordRpc.shutdown(); + } + + public static function shutdown() + { + DiscordRpc.shutdown(); + } + + static function onReady() + { + DiscordRpc.presence({ + details: "In the Menus", + state: null, + largeImageKey: 'icon', + largeImageText: "Friday Night Funkin'" + }); + } + + static function onError(_code:Int, _message:String) + { + trace('Error! $_code : $_message'); + } + + static function onDisconnected(_code:Int, _message:String) + { + trace('Disconnected! $_code : $_message'); + } + + public static function initialize() + { + var DiscordDaemon = sys.thread.Thread.create(() -> + { + new DiscordClient(); + }); + trace("Discord Client initialized"); + } + + public static function changePresence(details:String, state:Null, ?smallImageKey:String, ?hasStartTimestamp:Bool, ?endTimestamp:Float) + { + var startTimestamp:Float = if (hasStartTimestamp) Date.now().getTime() else 0; + + if (endTimestamp > 0) + { + endTimestamp = startTimestamp + endTimestamp; + } + + DiscordRpc.presence({ + details: details, + state: state, + largeImageKey: 'icon', + largeImageText: "Friday Night Funkin'", + smallImageKey: smallImageKey, + // Obtained times are in milliseconds so they are divided so Discord can use it + startTimestamp: Std.int(startTimestamp / 1000), + endTimestamp: Std.int(endTimestamp / 1000) + }); + + // trace('Discord RPC Updated. Arguments: $details, $state, $smallImageKey, $hasStartTimestamp, $endTimestamp'); + } + #end +} diff --git a/source/FlxSwf.hx b/source/funkin/FlxSwf.hx similarity index 97% rename from source/FlxSwf.hx rename to source/funkin/FlxSwf.hx index 48d0eff11..87d106c0e 100644 --- a/source/FlxSwf.hx +++ b/source/funkin/FlxSwf.hx @@ -1,4 +1,4 @@ -package; +package funkin; import flixel.FlxCamera; import flixel.FlxSprite; diff --git a/source/FlxVideo.hx b/source/funkin/FlxVideo.hx similarity index 98% rename from source/FlxVideo.hx rename to source/funkin/FlxVideo.hx index 7b9fa5702..82e7c366c 100644 --- a/source/FlxVideo.hx +++ b/source/funkin/FlxVideo.hx @@ -1,4 +1,4 @@ -package; +package funkin; import flixel.FlxBasic; import flixel.FlxSprite; diff --git a/source/FreeplayState.hx b/source/funkin/FreeplayState.hx similarity index 97% rename from source/FreeplayState.hx rename to source/funkin/FreeplayState.hx index b56f9fc95..c309ec5e0 100644 --- a/source/FreeplayState.hx +++ b/source/funkin/FreeplayState.hx @@ -1,6 +1,6 @@ -package; +package funkin; -import Controls.Control; +import funkin.Controls.Control; import flash.text.TextField; import flixel.FlxCamera; import flixel.FlxGame; @@ -21,15 +21,16 @@ import flixel.tweens.FlxTween; import flixel.util.FlxColor; import flixel.util.FlxSpriteUtil; import flixel.util.FlxTimer; -import freeplayStuff.BGScrollingText; -import freeplayStuff.DJBoyfriend; -import freeplayStuff.FreeplayScore; -import freeplayStuff.SongMenuItem; +import funkin.freeplayStuff.BGScrollingText; +import funkin.freeplayStuff.DJBoyfriend; +import funkin.freeplayStuff.FreeplayScore; +import funkin.freeplayStuff.SongMenuItem; import lime.app.Future; import lime.utils.Assets; -import shaderslmfao.AngleMask; -import shaderslmfao.PureColor; -import shaderslmfao.StrokeShader; +import funkin.shaderslmfao.AngleMask; +import funkin.shaderslmfao.PureColor; +import funkin.shaderslmfao.StrokeShader; +import funkin.play.PlayState; using StringTools; diff --git a/source/GameOverSubstate.hx b/source/funkin/GameOverSubstate.hx similarity index 97% rename from source/GameOverSubstate.hx rename to source/funkin/GameOverSubstate.hx index c7de6e688..f35d5f094 100644 --- a/source/GameOverSubstate.hx +++ b/source/funkin/GameOverSubstate.hx @@ -1,4 +1,4 @@ -package; +package funkin; import flixel.FlxObject; import flixel.FlxSubState; @@ -6,8 +6,9 @@ import flixel.math.FlxPoint; import flixel.system.FlxSound; import flixel.util.FlxColor; import flixel.util.FlxTimer; -import haxe.display.Display.Package; -import ui.PreferencesMenu; +import haxe.display.Display; +import funkin.ui.PreferencesMenu; +import funkin.play.PlayState; class GameOverSubstate extends MusicBeatSubstate { diff --git a/source/GitarooPause.hx b/source/funkin/GitarooPause.hx similarity index 97% rename from source/GitarooPause.hx rename to source/funkin/GitarooPause.hx index 61d431de1..d22620a46 100644 --- a/source/GitarooPause.hx +++ b/source/funkin/GitarooPause.hx @@ -1,7 +1,8 @@ -package; +package funkin; import flixel.FlxSprite; import flixel.graphics.frames.FlxAtlasFrames; +import funkin.play.PlayState; class GitarooPause extends MusicBeatState { diff --git a/source/HealthIcon.hx b/source/funkin/HealthIcon.hx similarity index 97% rename from source/HealthIcon.hx rename to source/funkin/HealthIcon.hx index a11251de7..e3b48a153 100644 --- a/source/HealthIcon.hx +++ b/source/funkin/HealthIcon.hx @@ -1,7 +1,8 @@ -package; +package funkin; import flixel.FlxSprite; import openfl.utils.Assets; +import funkin.play.PlayState; using StringTools; diff --git a/source/Highscore.hx b/source/funkin/Highscore.hx similarity index 99% rename from source/Highscore.hx rename to source/funkin/Highscore.hx index 9618114de..45a115075 100644 --- a/source/Highscore.hx +++ b/source/funkin/Highscore.hx @@ -1,4 +1,4 @@ -package; +package funkin; class Highscore { diff --git a/source/InitState.hx b/source/funkin/InitState.hx similarity index 95% rename from source/InitState.hx rename to source/funkin/InitState.hx index 7be00f074..812df1b51 100644 --- a/source/InitState.hx +++ b/source/funkin/InitState.hx @@ -1,7 +1,7 @@ -package; +package funkin; -import play.stage.StageData; -import charting.ChartingState; +import funkin.play.stage.StageData; +import funkin.charting.ChartingState; import flixel.addons.transition.FlxTransitionSprite.GraphicTransTileDiamond; import flixel.addons.transition.FlxTransitionableState; import flixel.addons.transition.TransitionData; @@ -10,10 +10,11 @@ import flixel.math.FlxPoint; import flixel.math.FlxRect; import flixel.util.FlxColor; import openfl.display.BitmapData; -import play.PicoFight; -import ui.PreferencesMenu; -import ui.stageBuildShit.StageBuilderState; -import util.macro.MacroUtil; +import funkin.play.PicoFight; +import funkin.ui.PreferencesMenu; +import funkin.ui.stageBuildShit.StageBuilderState; +import funkin.util.macro.MacroUtil; +import funkin.play.PlayState; using StringTools; diff --git a/source/InputFormatter.hx b/source/funkin/InputFormatter.hx similarity index 99% rename from source/InputFormatter.hx rename to source/funkin/InputFormatter.hx index 30c10ae44..b2d3f596a 100644 --- a/source/InputFormatter.hx +++ b/source/funkin/InputFormatter.hx @@ -1,6 +1,6 @@ -package; +package funkin; -import Controls; +import funkin.Controls; import flixel.input.gamepad.FlxGamepad; import flixel.input.gamepad.FlxGamepadInputID; import flixel.input.keyboard.FlxKey; diff --git a/source/LatencyState.hx b/source/funkin/LatencyState.hx similarity index 98% rename from source/LatencyState.hx rename to source/funkin/LatencyState.hx index e4214577d..4e0ca07af 100644 --- a/source/LatencyState.hx +++ b/source/funkin/LatencyState.hx @@ -1,4 +1,4 @@ -package; +package funkin; import flixel.FlxSprite; import flixel.FlxState; diff --git a/source/LoadingState.hx b/source/funkin/LoadingState.hx similarity index 99% rename from source/LoadingState.hx rename to source/funkin/LoadingState.hx index 263aa3fcb..3b9d88b4f 100644 --- a/source/LoadingState.hx +++ b/source/funkin/LoadingState.hx @@ -1,4 +1,4 @@ -package; +package funkin; import flixel.FlxSprite; import flixel.FlxState; @@ -12,6 +12,7 @@ import lime.utils.AssetLibrary; import lime.utils.AssetManifest; import lime.utils.Assets as LimeAssets; import openfl.utils.Assets; +import funkin.play.PlayState; class LoadingState extends MusicBeatState { diff --git a/source/MainMenuState.hx b/source/funkin/MainMenuState.hx similarity index 96% rename from source/MainMenuState.hx rename to source/funkin/MainMenuState.hx index 5a7dc505a..f85c2a3c3 100644 --- a/source/MainMenuState.hx +++ b/source/funkin/MainMenuState.hx @@ -1,6 +1,6 @@ -package; +package funkin; -import NGio; +import funkin.NGio; import flixel.FlxObject; import flixel.FlxSprite; import flixel.FlxState; @@ -17,12 +17,12 @@ import flixel.util.FlxColor; import flixel.util.FlxTimer; import lime.app.Application; import openfl.filters.ShaderFilter; -import shaderslmfao.ScreenWipeShader; -import ui.AtlasMenuList; -import ui.MenuList; -import ui.OptionsState; -import ui.PreferencesMenu; -import ui.Prompt; +import funkin.shaderslmfao.ScreenWipeShader; +import funkin.ui.AtlasMenuList; +import funkin.ui.MenuList; +import funkin.ui.OptionsState; +import funkin.ui.PreferencesMenu; +import funkin.ui.Prompt; using StringTools; @@ -31,7 +31,7 @@ import Discord.DiscordClient; #end #if newgrounds import io.newgrounds.NG; -import ui.NgPrompt; +import funkin.ui.NgPrompt; #end class MainMenuState extends MusicBeatState diff --git a/source/MemoryCounter.hx b/source/funkin/MemoryCounter.hx similarity index 98% rename from source/MemoryCounter.hx rename to source/funkin/MemoryCounter.hx index 2772ada77..8ce1f47f8 100644 --- a/source/MemoryCounter.hx +++ b/source/funkin/MemoryCounter.hx @@ -1,3 +1,5 @@ +package funkin; + import openfl.text.TextFormat; import openfl.system.System; import openfl.text.TextField; diff --git a/source/MenuCharacter.hx b/source/funkin/MenuCharacter.hx similarity index 98% rename from source/MenuCharacter.hx rename to source/funkin/MenuCharacter.hx index 5403478e1..14cc4e05f 100644 --- a/source/MenuCharacter.hx +++ b/source/funkin/MenuCharacter.hx @@ -1,4 +1,4 @@ -package; +package funkin; import flixel.FlxSprite; import flixel.graphics.frames.FlxAtlasFrames; diff --git a/source/MenuItem.hx b/source/funkin/MenuItem.hx similarity index 98% rename from source/MenuItem.hx rename to source/funkin/MenuItem.hx index 98b08f87d..de03c5b69 100644 --- a/source/MenuItem.hx +++ b/source/funkin/MenuItem.hx @@ -1,4 +1,4 @@ -package; +package funkin; import flixel.FlxSprite; import flixel.graphics.frames.FlxAtlasFrames; diff --git a/source/MusicBeatState.hx b/source/funkin/MusicBeatState.hx similarity index 96% rename from source/MusicBeatState.hx rename to source/funkin/MusicBeatState.hx index 5a5d1e18f..570c0c677 100644 --- a/source/MusicBeatState.hx +++ b/source/funkin/MusicBeatState.hx @@ -1,6 +1,6 @@ -package; +package funkin; -import Conductor.BPMChangeEvent; +import funkin.Conductor.BPMChangeEvent; import flixel.FlxGame; import flixel.addons.transition.FlxTransitionableState; import flixel.addons.ui.FlxUIState; diff --git a/source/MusicBeatSubstate.hx b/source/funkin/MusicBeatSubstate.hx similarity index 95% rename from source/MusicBeatSubstate.hx rename to source/funkin/MusicBeatSubstate.hx index add132693..8374848e4 100644 --- a/source/MusicBeatSubstate.hx +++ b/source/funkin/MusicBeatSubstate.hx @@ -1,6 +1,6 @@ -package; +package funkin; -import Conductor.BPMChangeEvent; +import funkin.Conductor.BPMChangeEvent; import flixel.FlxSubState; class MusicBeatSubstate extends FlxSubState diff --git a/source/NGio.hx b/source/funkin/NGio.hx similarity index 99% rename from source/NGio.hx rename to source/funkin/NGio.hx index 2b30865bb..b0b429f6c 100644 --- a/source/NGio.hx +++ b/source/funkin/NGio.hx @@ -1,4 +1,4 @@ -package; +package funkin; #if newgrounds import flixel.util.FlxSignal; diff --git a/source/Note.hx b/source/funkin/Note.hx similarity index 98% rename from source/Note.hx rename to source/funkin/Note.hx index 529b020e9..290fea0b6 100644 --- a/source/Note.hx +++ b/source/funkin/Note.hx @@ -1,9 +1,10 @@ -package; +package funkin; import flixel.FlxSprite; import flixel.math.FlxMath; -import shaderslmfao.ColorSwap; -import ui.PreferencesMenu; +import funkin.shaderslmfao.ColorSwap; +import funkin.ui.PreferencesMenu; +import funkin.play.PlayState; using StringTools; diff --git a/source/NoteSplash.hx b/source/funkin/NoteSplash.hx similarity index 94% rename from source/NoteSplash.hx rename to source/funkin/NoteSplash.hx index 36acc86a0..64169c48b 100644 --- a/source/NoteSplash.hx +++ b/source/funkin/NoteSplash.hx @@ -1,4 +1,4 @@ -package; +package funkin; import flixel.FlxSprite; import haxe.io.Path; @@ -32,7 +32,8 @@ class NoteSplash extends FlxSprite animation.play('note' + noteData + '-' + FlxG.random.int(0, 1), true); animation.curAnim.frameRate = 24 + FlxG.random.int(-2, 2); - animation.finishCallback = function(name){ + animation.finishCallback = function(name) + { kill(); }; updateHitbox(); diff --git a/source/Options.hx b/source/funkin/Options.hx similarity index 79% rename from source/Options.hx rename to source/funkin/Options.hx index f392a8b1e..7edaa25af 100644 --- a/source/Options.hx +++ b/source/funkin/Options.hx @@ -1,4 +1,4 @@ -package; +package funkin; class Options { diff --git a/source/OutdatedSubState.hx b/source/funkin/OutdatedSubState.hx similarity index 96% rename from source/OutdatedSubState.hx rename to source/funkin/OutdatedSubState.hx index 1af9eb614..32792032e 100644 --- a/source/OutdatedSubState.hx +++ b/source/funkin/OutdatedSubState.hx @@ -1,4 +1,4 @@ -package; +package funkin; import flixel.FlxSprite; import flixel.FlxSubState; @@ -6,6 +6,7 @@ import flixel.text.FlxText; import flixel.util.FlxColor; import lime.app.Application; +#if newgrounds class OutdatedSubState extends MusicBeatState { public static var leftState:Bool = false; @@ -42,3 +43,4 @@ class OutdatedSubState extends MusicBeatState super.update(elapsed); } } +#end diff --git a/source/Paths.hx b/source/funkin/Paths.hx similarity index 99% rename from source/Paths.hx rename to source/funkin/Paths.hx index e1b42b901..03a90ff9a 100644 --- a/source/Paths.hx +++ b/source/funkin/Paths.hx @@ -1,4 +1,4 @@ -package; +package funkin; import flixel.graphics.frames.FlxAtlasFrames; import openfl.utils.AssetType; diff --git a/source/PauseSubState.hx b/source/funkin/PauseSubState.hx similarity index 98% rename from source/PauseSubState.hx rename to source/funkin/PauseSubState.hx index f2ee9c60f..14cbb63a8 100644 --- a/source/PauseSubState.hx +++ b/source/funkin/PauseSubState.hx @@ -1,6 +1,6 @@ -package; +package funkin; -import Controls.Control; +import funkin.Controls.Control; import flixel.FlxSprite; import flixel.FlxSubState; import flixel.addons.transition.FlxTransitionableState; @@ -11,6 +11,7 @@ import flixel.text.FlxText; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import flixel.util.FlxColor; +import funkin.play.PlayState; class PauseSubState extends MusicBeatSubstate { diff --git a/source/PlayerSettings.hx b/source/funkin/PlayerSettings.hx similarity index 99% rename from source/PlayerSettings.hx rename to source/funkin/PlayerSettings.hx index 1b9681579..ab5d9e689 100644 --- a/source/PlayerSettings.hx +++ b/source/funkin/PlayerSettings.hx @@ -1,6 +1,6 @@ -package; +package funkin; -import Controls; +import funkin.Controls; import flixel.FlxCamera; import flixel.input.actions.FlxActionInput; import flixel.input.gamepad.FlxGamepad; diff --git a/source/Section.hx b/source/funkin/Section.hx similarity index 92% rename from source/Section.hx rename to source/funkin/Section.hx index e1fc84f5e..cc0931acb 100644 --- a/source/Section.hx +++ b/source/funkin/Section.hx @@ -1,6 +1,6 @@ -package; +package funkin; -import Note.NoteData; +import funkin.Note.NoteData; typedef SwagSection = { diff --git a/source/SongLoad.hx b/source/funkin/SongLoad.hx similarity index 98% rename from source/SongLoad.hx rename to source/funkin/SongLoad.hx index 842cadf2e..770795602 100644 --- a/source/SongLoad.hx +++ b/source/funkin/SongLoad.hx @@ -1,7 +1,7 @@ -package; +package funkin; -import Note.NoteData; -import Section.SwagSection; +import funkin.Note.NoteData; +import funkin.Section.SwagSection; import haxe.Json; import haxe.format.JsonParser; import lime.utils.Assets; diff --git a/source/StoryMenuState.hx b/source/funkin/StoryMenuState.hx similarity index 99% rename from source/StoryMenuState.hx rename to source/funkin/StoryMenuState.hx index 5e2c3367f..00e482a8a 100644 --- a/source/StoryMenuState.hx +++ b/source/funkin/StoryMenuState.hx @@ -1,4 +1,4 @@ -package; +package funkin; #if discord_rpc import Discord.DiscordClient; @@ -14,6 +14,7 @@ import flixel.tweens.FlxTween; import flixel.util.FlxColor; import flixel.util.FlxTimer; import lime.net.curl.CURLCode; +import funkin.play.PlayState; using StringTools; diff --git a/source/SwagCamera.hx b/source/funkin/SwagCamera.hx similarity index 99% rename from source/SwagCamera.hx rename to source/funkin/SwagCamera.hx index 4903b0e07..7184601b9 100644 --- a/source/SwagCamera.hx +++ b/source/funkin/SwagCamera.hx @@ -1,4 +1,4 @@ -package; +package funkin; import flixel.FlxCamera; import flixel.FlxSprite; diff --git a/source/TankCutscene.hx b/source/funkin/TankCutscene.hx similarity index 96% rename from source/TankCutscene.hx rename to source/funkin/TankCutscene.hx index a8a18321c..a144b16fe 100644 --- a/source/TankCutscene.hx +++ b/source/funkin/TankCutscene.hx @@ -1,4 +1,4 @@ -package; +package funkin; import flixel.FlxSprite; import flixel.system.FlxSound; diff --git a/source/TitleState.hx b/source/funkin/TitleState.hx similarity index 98% rename from source/TitleState.hx rename to source/funkin/TitleState.hx index af3b00257..f54bfbd3c 100644 --- a/source/TitleState.hx +++ b/source/funkin/TitleState.hx @@ -1,6 +1,6 @@ -package; +package funkin; -import audiovis.SpectogramSprite; +import funkin.audiovis.SpectogramSprite; import flixel.FlxObject; import flixel.FlxSprite; import flixel.FlxState; @@ -29,10 +29,10 @@ import openfl.events.NetStatusEvent; import openfl.media.Video; import openfl.net.NetConnection; import openfl.net.NetStream; -import shaderslmfao.BuildingShaders; -import shaderslmfao.ColorSwap; -import shaderslmfao.TitleOutline; -import ui.PreferencesMenu; +import funkin.shaderslmfao.BuildingShaders; +import funkin.shaderslmfao.ColorSwap; +import funkin.shaderslmfao.TitleOutline; +import funkin.ui.PreferencesMenu; using StringTools; diff --git a/source/VideoState.hx b/source/funkin/VideoState.hx similarity index 99% rename from source/VideoState.hx rename to source/funkin/VideoState.hx index 5130cc223..d5954ccda 100644 --- a/source/VideoState.hx +++ b/source/funkin/VideoState.hx @@ -1,4 +1,4 @@ -package; +package funkin; import openfl.display.Sprite; import openfl.events.AsyncErrorEvent; diff --git a/source/VoicesGroup.hx b/source/funkin/VoicesGroup.hx similarity index 99% rename from source/VoicesGroup.hx rename to source/funkin/VoicesGroup.hx index 459b952da..bb9dd419f 100644 --- a/source/VoicesGroup.hx +++ b/source/funkin/VoicesGroup.hx @@ -1,3 +1,5 @@ +package funkin; + import flixel.group.FlxGroup.FlxTypedGroup; import flixel.system.FlxSound; diff --git a/source/animate/AnimTestStage.hx b/source/funkin/animate/AnimTestStage.hx similarity index 96% rename from source/animate/AnimTestStage.hx rename to source/funkin/animate/AnimTestStage.hx index eb7a2b38b..26e1fceb2 100644 --- a/source/animate/AnimTestStage.hx +++ b/source/funkin/animate/AnimTestStage.hx @@ -1,4 +1,4 @@ -package animate; +package funkin.animate; import flixel.FlxSprite; import flixel.FlxState; diff --git a/source/animate/AnimateTimeline.hx b/source/funkin/animate/AnimateTimeline.hx similarity index 94% rename from source/animate/AnimateTimeline.hx rename to source/funkin/animate/AnimateTimeline.hx index 70fc3f5a7..27f70f7ae 100644 --- a/source/animate/AnimateTimeline.hx +++ b/source/funkin/animate/AnimateTimeline.hx @@ -1,7 +1,5 @@ -package animate; +package funkin.animate; -// import animate.FlxSymbol.Parsed; -// import animate.FlxSymbol.Timeline; import flixel.FlxCamera; import flixel.FlxSprite; import flixel.group.FlxGroup.FlxTypedGroup; diff --git a/source/animate/FlxAnimate.hx b/source/funkin/animate/FlxAnimate.hx similarity index 97% rename from source/animate/FlxAnimate.hx rename to source/funkin/animate/FlxAnimate.hx index 60408697a..607776275 100644 --- a/source/animate/FlxAnimate.hx +++ b/source/funkin/animate/FlxAnimate.hx @@ -1,10 +1,8 @@ -package animate; +package funkin.animate; -// import animateAtlasPlayer.assets.AssetManager; -// import animateAtlasPlayer.core.Animation; -import animate.ParseAnimate.AnimJson; -import animate.ParseAnimate.Sprite; -import animate.ParseAnimate.Spritemap; +import funkin.animate.ParseAnimate.AnimJson; +import funkin.animate.ParseAnimate.Sprite; +import funkin.animate.ParseAnimate.Spritemap; import flixel.FlxCamera; import flixel.FlxSprite; import flixel.graphics.FlxGraphic; diff --git a/source/animate/FlxSymbol.hx b/source/funkin/animate/FlxSymbol.hx similarity index 84% rename from source/animate/FlxSymbol.hx rename to source/funkin/animate/FlxSymbol.hx index bb995057b..3e2fffd84 100644 --- a/source/animate/FlxSymbol.hx +++ b/source/funkin/animate/FlxSymbol.hx @@ -1,12 +1,12 @@ -package animate; +package funkin.animate; -import animate.ParseAnimate.AnimJson; -import animate.ParseAnimate.Animation; -import animate.ParseAnimate.Frame; -import animate.ParseAnimate.Sprite; -import animate.ParseAnimate.Spritemap; -import animate.ParseAnimate.SymbolDictionary; -import animate.ParseAnimate.Timeline; +import funkin.animate.ParseAnimate.AnimJson; +import funkin.animate.ParseAnimate.Animation; +import funkin.animate.ParseAnimate.Frame; +import funkin.animate.ParseAnimate.Sprite; +import funkin.animate.ParseAnimate.Spritemap; +import funkin.animate.ParseAnimate.SymbolDictionary; +import funkin.animate.ParseAnimate.Timeline; import flixel.FlxCamera; import flixel.FlxSprite; import flixel.graphics.frames.FlxFrame.FlxFrameAngle; diff --git a/source/animate/ParseAnimate.hx b/source/funkin/animate/ParseAnimate.hx similarity index 99% rename from source/animate/ParseAnimate.hx rename to source/funkin/animate/ParseAnimate.hx index 673cbcce1..9c2fa17a4 100644 --- a/source/animate/ParseAnimate.hx +++ b/source/funkin/animate/ParseAnimate.hx @@ -1,4 +1,4 @@ -package animate; +package funkin.animate; import haxe.format.JsonParser; import openfl.Assets; diff --git a/source/animate/TimelineFrame.hx b/source/funkin/animate/TimelineFrame.hx similarity index 94% rename from source/animate/TimelineFrame.hx rename to source/funkin/animate/TimelineFrame.hx index 629e91f62..dbd5bfc7a 100644 --- a/source/animate/TimelineFrame.hx +++ b/source/funkin/animate/TimelineFrame.hx @@ -1,6 +1,6 @@ -package animate; +package funkin.animate; -import animate.FlxSymbol.Frame; +import funkin.animate.ParseAnimate.Frame; import flixel.FlxSprite; import flixel.input.mouse.FlxMouseEventManager; import flixel.util.FlxColor; diff --git a/source/audiovis/ABotVis.hx b/source/funkin/audiovis/ABotVis.hx similarity index 97% rename from source/audiovis/ABotVis.hx rename to source/funkin/audiovis/ABotVis.hx index c6411c4d8..a05238e9f 100644 --- a/source/audiovis/ABotVis.hx +++ b/source/funkin/audiovis/ABotVis.hx @@ -1,13 +1,13 @@ -package audiovis; +package funkin.audiovis; -import audiovis.dsp.FFT; +import funkin.audiovis.dsp.FFT; import flixel.FlxSprite; import flixel.addons.plugin.taskManager.FlxTask; import flixel.graphics.frames.FlxAtlasFrames; import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup; import flixel.math.FlxMath; import flixel.system.FlxSound; -import ui.PreferencesMenu.CheckboxThingie; +import funkin.ui.PreferencesMenu.CheckboxThingie; using Lambda; diff --git a/source/audiovis/PolygonSpectogram.hx b/source/funkin/audiovis/PolygonSpectogram.hx similarity index 96% rename from source/audiovis/PolygonSpectogram.hx rename to source/funkin/audiovis/PolygonSpectogram.hx index 31409c45f..d8af4e07d 100644 --- a/source/audiovis/PolygonSpectogram.hx +++ b/source/funkin/audiovis/PolygonSpectogram.hx @@ -1,12 +1,12 @@ -package audiovis; +package funkin.audiovis; -import audiovis.VisShit.CurAudioInfo; +import funkin.audiovis.VisShit.CurAudioInfo; import flixel.math.FlxMath; import flixel.math.FlxPoint; import flixel.system.FlxSound; import flixel.util.FlxColor; import lime.utils.Int16Array; -import rendering.MeshRender; +import funkin.rendering.MeshRender; class PolygonSpectogram extends MeshRender { diff --git a/source/audiovis/SpectogramSprite.hx b/source/funkin/audiovis/SpectogramSprite.hx similarity index 98% rename from source/audiovis/SpectogramSprite.hx rename to source/funkin/audiovis/SpectogramSprite.hx index 394bfadf6..b3cb6ff62 100644 --- a/source/audiovis/SpectogramSprite.hx +++ b/source/funkin/audiovis/SpectogramSprite.hx @@ -1,8 +1,8 @@ -package audiovis; +package funkin.audiovis; -import audiovis.PolygonSpectogram.VISTYPE; -import audiovis.VisShit.CurAudioInfo; -import audiovis.dsp.FFT; +import funkin.audiovis.PolygonSpectogram.VISTYPE; +import funkin.audiovis.VisShit.CurAudioInfo; +import funkin.audiovis.dsp.FFT; import flixel.FlxSprite; import flixel.group.FlxGroup; import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup; diff --git a/source/audiovis/VisShit.hx b/source/funkin/audiovis/VisShit.hx similarity index 98% rename from source/audiovis/VisShit.hx rename to source/funkin/audiovis/VisShit.hx index 819a76e59..232d060a5 100644 --- a/source/audiovis/VisShit.hx +++ b/source/funkin/audiovis/VisShit.hx @@ -1,6 +1,6 @@ -package audiovis; +package funkin.audiovis; -import audiovis.dsp.FFT; +import funkin.audiovis.dsp.FFT; import flixel.math.FlxMath; import flixel.system.FlxSound; import lime.utils.Int16Array; diff --git a/source/audiovis/dsp/Complex.hx b/source/funkin/audiovis/dsp/Complex.hx similarity index 98% rename from source/audiovis/dsp/Complex.hx rename to source/funkin/audiovis/dsp/Complex.hx index 8dc8c9b7a..eeff9679f 100644 --- a/source/audiovis/dsp/Complex.hx +++ b/source/funkin/audiovis/dsp/Complex.hx @@ -1,4 +1,4 @@ -package audiovis.dsp; +package funkin.audiovis.dsp; /** Complex number representation. diff --git a/source/audiovis/dsp/FFT.hx b/source/funkin/audiovis/dsp/FFT.hx similarity index 97% rename from source/audiovis/dsp/FFT.hx rename to source/funkin/audiovis/dsp/FFT.hx index d46c8ffa1..7929c0f0a 100644 --- a/source/audiovis/dsp/FFT.hx +++ b/source/funkin/audiovis/dsp/FFT.hx @@ -1,9 +1,9 @@ -package audiovis.dsp; +package funkin.audiovis.dsp; -import audiovis.dsp.Complex; +import funkin.audiovis.dsp.Complex; -using audiovis.dsp.OffsetArray; -using audiovis.dsp.Signal; +using funkin.audiovis.dsp.OffsetArray; +using funkin.audiovis.dsp.Signal; // these are only used for testing, down in FFT.main() diff --git a/source/audiovis/dsp/OffsetArray.hx b/source/funkin/audiovis/dsp/OffsetArray.hx similarity index 98% rename from source/audiovis/dsp/OffsetArray.hx rename to source/funkin/audiovis/dsp/OffsetArray.hx index ec5ddf539..db06ce40f 100644 --- a/source/audiovis/dsp/OffsetArray.hx +++ b/source/funkin/audiovis/dsp/OffsetArray.hx @@ -1,4 +1,4 @@ -package audiovis.dsp; +package funkin.audiovis.dsp; /** A view into an Array with an indexing offset. diff --git a/source/audiovis/dsp/Signal.hx b/source/funkin/audiovis/dsp/Signal.hx similarity index 98% rename from source/audiovis/dsp/Signal.hx rename to source/funkin/audiovis/dsp/Signal.hx index 7c5631c21..aeb6c3f91 100644 --- a/source/audiovis/dsp/Signal.hx +++ b/source/funkin/audiovis/dsp/Signal.hx @@ -1,4 +1,4 @@ -package audiovis.dsp; +package funkin.audiovis.dsp; using Lambda; diff --git a/source/charting/ChartingState.hx b/source/funkin/charting/ChartingState.hx similarity index 99% rename from source/charting/ChartingState.hx rename to source/funkin/charting/ChartingState.hx index 2559be86f..16e5e38e4 100644 --- a/source/charting/ChartingState.hx +++ b/source/funkin/charting/ChartingState.hx @@ -1,12 +1,12 @@ -package charting; +package funkin.charting; -import Conductor.BPMChangeEvent; -import Note.NoteData; -import Section.SwagSection; -import SongLoad.SwagSong; -import audiovis.ABotVis; -import audiovis.PolygonSpectogram; -import audiovis.SpectogramSprite; +import funkin.Conductor.BPMChangeEvent; +import funkin.Note.NoteData; +import funkin.Section.SwagSection; +import funkin.SongLoad.SwagSong; +import funkin.audiovis.ABotVis; +import funkin.audiovis.PolygonSpectogram; +import funkin.audiovis.SpectogramSprite; import flixel.FlxSprite; import flixel.addons.display.FlxGridOverlay; import flixel.addons.transition.FlxTransitionableState; @@ -29,7 +29,8 @@ import lime.utils.Assets; import openfl.events.Event; import openfl.events.IOErrorEvent; import openfl.net.FileReference; -import rendering.MeshRender; +import funkin.rendering.MeshRender; +import funkin.play.PlayState; using Lambda; using StringTools; diff --git a/source/freeplayStuff/BGScrollingText.hx b/source/funkin/freeplayStuff/BGScrollingText.hx similarity index 98% rename from source/freeplayStuff/BGScrollingText.hx rename to source/funkin/freeplayStuff/BGScrollingText.hx index f25b8c82e..39837e031 100644 --- a/source/freeplayStuff/BGScrollingText.hx +++ b/source/funkin/freeplayStuff/BGScrollingText.hx @@ -1,4 +1,4 @@ -package freeplayStuff; +package funkin.freeplayStuff; import flixel.FlxObject; import flixel.group.FlxGroup.FlxTypedGroup; diff --git a/source/freeplayStuff/DJBoyfriend.hx b/source/funkin/freeplayStuff/DJBoyfriend.hx similarity index 97% rename from source/freeplayStuff/DJBoyfriend.hx rename to source/funkin/freeplayStuff/DJBoyfriend.hx index 25c725b11..8ea52370d 100644 --- a/source/freeplayStuff/DJBoyfriend.hx +++ b/source/funkin/freeplayStuff/DJBoyfriend.hx @@ -1,4 +1,4 @@ -package freeplayStuff; +package funkin.freeplayStuff; import flixel.FlxSprite; import flixel.util.FlxSignal; diff --git a/source/freeplayStuff/FreeplayScore.hx b/source/funkin/freeplayStuff/FreeplayScore.hx similarity index 96% rename from source/freeplayStuff/FreeplayScore.hx rename to source/funkin/freeplayStuff/FreeplayScore.hx index 315f881ea..cef363cd0 100644 --- a/source/freeplayStuff/FreeplayScore.hx +++ b/source/funkin/freeplayStuff/FreeplayScore.hx @@ -1,4 +1,4 @@ -package freeplayStuff; +package funkin.freeplayStuff; import flixel.FlxSprite; import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup; @@ -11,6 +11,8 @@ class FreeplayScore extends FlxTypedSpriteGroup function set_scoreShit(val):Int { + if (group == null || group.members == null) + return val; var loopNum:Int = group.members.length - 1; var dumbNumb = Std.parseInt(Std.string(val)); var prevNum:ScoreNum; diff --git a/source/freeplayStuff/SongMenuItem.hx b/source/funkin/freeplayStuff/SongMenuItem.hx similarity index 98% rename from source/freeplayStuff/SongMenuItem.hx rename to source/funkin/freeplayStuff/SongMenuItem.hx index cf9935ee2..7eb862bef 100644 --- a/source/freeplayStuff/SongMenuItem.hx +++ b/source/funkin/freeplayStuff/SongMenuItem.hx @@ -1,4 +1,4 @@ -package freeplayStuff; +package funkin.freeplayStuff; import flixel.FlxSprite; import flixel.graphics.frames.FlxAtlasFrames; diff --git a/source/i18n/FireTongueHandler.hx b/source/funkin/i18n/FireTongueHandler.hx similarity index 99% rename from source/i18n/FireTongueHandler.hx rename to source/funkin/i18n/FireTongueHandler.hx index 53a16059d..fdb13e41c 100644 --- a/source/i18n/FireTongueHandler.hx +++ b/source/funkin/i18n/FireTongueHandler.hx @@ -1,4 +1,4 @@ -package i18n; +package funkin.i18n; import firetongue.FireTongue; diff --git a/source/i18n/README.md b/source/funkin/i18n/README.md similarity index 100% rename from source/i18n/README.md rename to source/funkin/i18n/README.md diff --git a/source/import.hx b/source/funkin/import.hx similarity index 88% rename from source/import.hx rename to source/funkin/import.hx index 13736ea5e..67be91c51 100644 --- a/source/import.hx +++ b/source/funkin/import.hx @@ -1,6 +1,6 @@ #if !macro // Only import these when we aren't in a macro. -import Paths; +import funkin.Paths; import flixel.FlxG; // This one in particular causes a compile error if you're using macros. #end diff --git a/source/modding/IHook.hx b/source/funkin/modding/IHook.hx similarity index 92% rename from source/modding/IHook.hx rename to source/funkin/modding/IHook.hx index a1a75d08d..fdcf9da27 100644 --- a/source/modding/IHook.hx +++ b/source/funkin/modding/IHook.hx @@ -1,13 +1,13 @@ -package modding; - -import polymod.hscript.HScriptable; - -/** - * Add this interface to a class to make it a scriptable object. - * Functions annotated with @:hscript will call the relevant script. - */ -@:hscript({ - // ALL of these values are added to ALL scripts in the child classes. - context: [FlxG, FlxSprite, Math, Paths, Std] -}) -interface IHook extends HScriptable {} +package funkin.modding; + +import polymod.hscript.HScriptable; + +/** + * Add this interface to a class to make it a scriptable object. + * Functions annotated with @:hscript will call the relevant script. + */ +@:hscript({ + // ALL of these values are added to ALL scripts in the child classes. + context: [FlxG, FlxSprite, Math, Paths, Std] +}) +interface IHook extends HScriptable {} diff --git a/source/modding/PolymodErrorHandler.hx b/source/funkin/modding/PolymodErrorHandler.hx similarity index 98% rename from source/modding/PolymodErrorHandler.hx rename to source/funkin/modding/PolymodErrorHandler.hx index e5a1c65a4..c0616dfb5 100644 --- a/source/modding/PolymodErrorHandler.hx +++ b/source/funkin/modding/PolymodErrorHandler.hx @@ -1,4 +1,4 @@ -package modding; +package funkin.modding; import polymod.Polymod; diff --git a/source/modding/PolymodHandler.hx b/source/funkin/modding/PolymodHandler.hx similarity index 85% rename from source/modding/PolymodHandler.hx rename to source/funkin/modding/PolymodHandler.hx index efd4f0509..1f6d149cb 100644 --- a/source/modding/PolymodHandler.hx +++ b/source/funkin/modding/PolymodHandler.hx @@ -1,163 +1,168 @@ -package modding; - -import polymod.Polymod.ModMetadata; -import polymod.Polymod; -import polymod.backends.OpenFLBackend; -import polymod.backends.PolymodAssets.PolymodAssetType; -import polymod.format.ParseRules.LinesParseFormat; -import polymod.format.ParseRules.TextFileFormat; - -class PolymodHandler -{ - /** - * The API version that mods should comply with. - * Format this with Semantic Versioning; ... - * Bug fixes increment the patch version, new features increment the minor version. - * Changes that break old mods increment the major version. - */ - static final API_VERSION = "0.1.0"; - - /** - * Where relative to the executable that mods are located. - */ - static final MOD_FOLDER = "mods"; - - /** - * Loads the game with ALL mods enabled with Polymod. - */ - public static function loadAllMods() - { - trace("Initializing Polymod (using all mods)..."); - loadModsById(getAllModIds()); - } - - /** - * Loads the game without any mods enabled with Polymod. - */ - public static function loadNoMods() - { - // We still need to configure the debug print calls etc. - trace("Initializing Polymod (using no mods)..."); - loadModsById([]); - } - - public static function loadModsById(ids:Array) - { - if (ids.length == 0) - { - trace('You attempted to load zero mods.'); - } - else - { - trace('Attempting to load ${ids.length} mods...'); - } - var loadedModList = polymod.Polymod.init({ - // Root directory for all mods. - modRoot: MOD_FOLDER, - // The directories for one or more mods to load. - dirs: ids, - // Framework being used to load assets. - framework: OPENFL, - // The current version of our API. - apiVersion: API_VERSION, - // Call this function any time an error occurs. - errorCallback: PolymodErrorHandler.onPolymodError, - // Enforce semantic version patterns for each mod. - // modVersions: null, - // A map telling Polymod what the asset type is for unfamiliar file extensions. - // extensionMap: [], - - frameworkParams: buildFrameworkParams(), - - // List of filenames to ignore in mods. Use the default list to ignore the metadata file, etc. - ignoredFiles: Polymod.getDefaultIgnoreList(), - - // Parsing rules for various data formats. - parseRules: buildParseRules(), - - // Parse hxc files and register the scripted classes in them. - useScriptedClasses: true, - }); - - if (loadedModList == null) - { - trace('[POLYMOD] An error occurred! Failed when loading mods!'); - } - else - { - if (loadedModList.length == 0) - { - trace('[POLYMOD] Mod loading complete. We loaded no mods / ${ids.length} mods.'); - } - else - { - trace('[POLYMOD] Mod loading complete. We loaded ${loadedModList.length} / ${ids.length} mods.'); - } - } - - for (mod in loadedModList) - { - trace(' * ${mod.title} v${mod.modVersion} [${mod.id}]'); - } - - #if debug - var fileList = Polymod.listModFiles("IMAGE"); - trace('[POLYMOD] Installed mods have replaced ${fileList.length} images.'); - for (item in fileList) - trace(' * $item'); - - fileList = Polymod.listModFiles("TEXT"); - trace('[POLYMOD] Installed mods have replaced ${fileList.length} text files.'); - for (item in fileList) - trace(' * $item'); - - fileList = Polymod.listModFiles("MUSIC"); - trace('[POLYMOD] Installed mods have replaced ${fileList.length} music files.'); - for (item in fileList) - trace(' * $item'); - - fileList = Polymod.listModFiles("SOUND"); - trace('[POLYMOD] Installed mods have replaced ${fileList.length} sound files.'); - for (item in fileList) - trace(' * $item'); - #end - } - - static function buildParseRules():polymod.format.ParseRules - { - var output = polymod.format.ParseRules.getDefault(); - // Ensure TXT files have merge support. - output.addType("txt", TextFileFormat.LINES); - // Ensure script files have merge support. - output.addType("hscript", TextFileFormat.PLAINTEXT); - output.addType("hxs", TextFileFormat.PLAINTEXT); - - // You can specify the format of a specific file, with file extension. - // output.addFile("data/introText.txt", TextFileFormat.LINES) - return output; - } - - static inline function buildFrameworkParams():polymod.Polymod.FrameworkParams - { - return { - assetLibraryPaths: [ - "songs" => "./songs", "shared" => "./", "tutorial" => "./tutorial", "scripts" => "./scripts", "week1" => "./week1", "week2" => "./week2", - "week3" => "./week3", "week4" => "./week4", "week5" => "./week5", "week6" => "./week6", "week7" => "./week7", "week8" => "./week8", - ] - } - } - - public static function getAllMods():Array - { - trace('Scanning the mods folder...'); - var modMetadata = Polymod.scan(MOD_FOLDER); - trace('Found ${modMetadata.length} mods when scanning.'); - return modMetadata; - } - - public static function getAllModIds():Array - { - var modIds = [for (i in getAllMods()) i.id]; - return modIds; - } -} +package funkin.modding; + +import polymod.Polymod.ModMetadata; +import polymod.Polymod; +import polymod.backends.OpenFLBackend; +import polymod.backends.PolymodAssets.PolymodAssetType; +import polymod.format.ParseRules.LinesParseFormat; +import polymod.format.ParseRules.TextFileFormat; + +class PolymodHandler +{ + /** + * The API version that mods should comply with. + * Format this with Semantic Versioning; ... + * Bug fixes increment the patch version, new features increment the minor version. + * Changes that break old mods increment the major version. + */ + static final API_VERSION = "0.1.0"; + + /** + * Where relative to the executable that mods are located. + */ + static final MOD_FOLDER = "mods"; + + /** + * Loads the game with ALL mods enabled with Polymod. + */ + public static function loadAllMods() + { + trace("Initializing Polymod (using all mods)..."); + loadModsById(getAllModIds()); + } + + /** + * Loads the game without any mods enabled with Polymod. + */ + public static function loadNoMods() + { + // We still need to configure the debug print calls etc. + trace("Initializing Polymod (using no mods)..."); + loadModsById([]); + } + + public static function loadModsById(ids:Array) + { + if (ids.length == 0) + { + trace('You attempted to load zero mods.'); + } + else + { + trace('Attempting to load ${ids.length} mods...'); + } + var loadedModList = polymod.Polymod.init({ + // Root directory for all mods. + modRoot: MOD_FOLDER, + // The directories for one or more mods to load. + dirs: ids, + // Framework being used to load assets. + framework: OPENFL, + // The current version of our API. + apiVersion: API_VERSION, + // Call this function any time an error occurs. + errorCallback: PolymodErrorHandler.onPolymodError, + // Enforce semantic version patterns for each mod. + // modVersions: null, + // A map telling Polymod what the asset type is for unfamiliar file extensions. + // extensionMap: [], + + frameworkParams: buildFrameworkParams(), + + // List of filenames to ignore in mods. Use the default list to ignore the metadata file, etc. + ignoredFiles: Polymod.getDefaultIgnoreList(), + + // Parsing rules for various data formats. + parseRules: buildParseRules(), + + // Parse hxc files and register the scripted classes in them. + useScriptedClasses: true, + }); + + if (loadedModList == null) + { + trace('[POLYMOD] An error occurred! Failed when loading mods!'); + } + else + { + if (loadedModList.length == 0) + { + trace('[POLYMOD] Mod loading complete. We loaded no mods / ${ids.length} mods.'); + } + else + { + trace('[POLYMOD] Mod loading complete. We loaded ${loadedModList.length} / ${ids.length} mods.'); + } + } + + for (mod in loadedModList) + { + trace(' * ${mod.title} v${mod.modVersion} [${mod.id}]'); + } + + #if debug + var fileList = Polymod.listModFiles(PolymodAssetType.IMAGE); + trace('[POLYMOD] Installed mods have replaced ${fileList.length} images.'); + for (item in fileList) + trace(' * $item'); + + fileList = Polymod.listModFiles(PolymodAssetType.TEXT); + trace('[POLYMOD] Installed mods have replaced ${fileList.length} text files.'); + for (item in fileList) + trace(' * $item'); + + fileList = Polymod.listModFiles(PolymodAssetType.AUDIO_MUSIC); + trace('[POLYMOD] Installed mods have replaced ${fileList.length} music files.'); + for (item in fileList) + trace(' * $item'); + + fileList = Polymod.listModFiles(PolymodAssetType.AUDIO_SOUND); + trace('[POLYMOD] Installed mods have replaced ${fileList.length} sound files.'); + for (item in fileList) + trace(' * $item'); + + fileList = Polymod.listModFiles(PolymodAssetType.AUDIO_GENERIC); + trace('[POLYMOD] Installed mods have replaced ${fileList.length} generic audio files.'); + for (item in fileList) + trace(' * $item'); + #end + } + + static function buildParseRules():polymod.format.ParseRules + { + var output = polymod.format.ParseRules.getDefault(); + // Ensure TXT files have merge support. + output.addType("txt", TextFileFormat.LINES); + // Ensure script files have merge support. + output.addType("hscript", TextFileFormat.PLAINTEXT); + output.addType("hxs", TextFileFormat.PLAINTEXT); + + // You can specify the format of a specific file, with file extension. + // output.addFile("data/introText.txt", TextFileFormat.LINES) + return output; + } + + static inline function buildFrameworkParams():polymod.Polymod.FrameworkParams + { + return { + assetLibraryPaths: [ + "songs" => "songs", "shared" => "", "tutorial" => "tutorial", "scripts" => "scripts", "week1" => "week1", "week2" => "week2", + "week3" => "week3", "week4" => "week4", "week5" => "week5", "week6" => "week6", "week7" => "week7", "week8" => "week8", + ] + } + } + + public static function getAllMods():Array + { + trace('Scanning the mods folder...'); + var modMetadata = Polymod.scan(MOD_FOLDER); + trace('Found ${modMetadata.length} mods when scanning.'); + return modMetadata; + } + + public static function getAllModIds():Array + { + var modIds = [for (i in getAllMods()) i.id]; + return modIds; + } +} diff --git a/source/modding/base/README.md b/source/funkin/modding/base/README.md similarity index 100% rename from source/modding/base/README.md rename to source/funkin/modding/base/README.md diff --git a/source/modding/base/ScriptedFlxSprite.hx b/source/funkin/modding/base/ScriptedFlxSprite.hx similarity index 72% rename from source/modding/base/ScriptedFlxSprite.hx rename to source/funkin/modding/base/ScriptedFlxSprite.hx index 7ab33abfd..9bccdc778 100644 --- a/source/modding/base/ScriptedFlxSprite.hx +++ b/source/funkin/modding/base/ScriptedFlxSprite.hx @@ -1,7 +1,7 @@ -package modding.base; +package funkin.modding.base; import flixel.FlxSprite; -import modding.IHook; +import funkin.modding.IHook; @:hscriptClass class ScriptedFlxSprite extends FlxSprite implements IHook diff --git a/source/modding/base/ScriptedFlxSpriteGroup.hx b/source/funkin/modding/base/ScriptedFlxSpriteGroup.hx similarity index 75% rename from source/modding/base/ScriptedFlxSpriteGroup.hx rename to source/funkin/modding/base/ScriptedFlxSpriteGroup.hx index bc9734987..a60dfdad3 100644 --- a/source/modding/base/ScriptedFlxSpriteGroup.hx +++ b/source/funkin/modding/base/ScriptedFlxSpriteGroup.hx @@ -1,7 +1,7 @@ -package modding.base; +package funkin.modding.base; import flixel.group.FlxSpriteGroup; -import modding.IHook; +import funkin.modding.IHook; @:hscriptClass class ScriptedFlxSpriteGroup extends FlxSpriteGroup implements IHook diff --git a/source/play/Fighter.hx b/source/funkin/play/Fighter.hx similarity index 97% rename from source/play/Fighter.hx rename to source/funkin/play/Fighter.hx index cde3c1f30..fa17b6bd7 100644 --- a/source/play/Fighter.hx +++ b/source/funkin/play/Fighter.hx @@ -1,4 +1,4 @@ -package play; +package funkin.play; import flixel.FlxSprite; diff --git a/source/play/PicoFight.hx b/source/funkin/play/PicoFight.hx similarity index 98% rename from source/play/PicoFight.hx rename to source/funkin/play/PicoFight.hx index 576d8b4f8..1ef8a1fa2 100644 --- a/source/play/PicoFight.hx +++ b/source/funkin/play/PicoFight.hx @@ -1,7 +1,7 @@ -package play; +package funkin.play; -import Note.NoteData; -import audiovis.PolygonSpectogram; +import funkin.Note.NoteData; +import funkin.audiovis.PolygonSpectogram; import flixel.FlxObject; import flixel.FlxSprite; import flixel.addons.effects.FlxTrail; diff --git a/source/PlayState.hx b/source/funkin/play/PlayState.hx similarity index 98% rename from source/PlayState.hx rename to source/funkin/play/PlayState.hx index 07b35cce3..f776cdfd9 100644 --- a/source/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -1,6 +1,6 @@ -package; +package funkin.play; -import charting.ChartingState; +import funkin.charting.ChartingState; import flixel.addons.effects.FlxTrail; import flixel.addons.transition.FlxTransitionableState; import flixel.FlxCamera; @@ -22,14 +22,14 @@ import flixel.util.FlxTimer; import haxe.Json; import lime.ui.Haptic; import lime.utils.Assets; -import Note; -import play.stage.Stage; -import play.stage.StageData; -import Section.SwagSection; -import shaderslmfao.ColorSwap; -import SongLoad.SwagSong; -import ui.PopUpStuff; -import ui.PreferencesMenu; +import funkin.Note; +import funkin.play.stage.Stage; +import funkin.play.stage.StageData; +import funkin.Section.SwagSection; +import funkin.shaderslmfao.ColorSwap; +import funkin.SongLoad.SwagSong; +import funkin.ui.PopUpStuff; +import funkin.ui.PreferencesMenu; using StringTools; @@ -39,6 +39,7 @@ import Discord.DiscordClient; class PlayState extends MusicBeatState { + // TODO: Reorganize these variables (maybe there should be a separate class like Conductor just to hold them?) public static var curStageId:String = ''; public static var SONG:SwagSong; public static var isStoryMode:Bool = false; @@ -71,6 +72,11 @@ class PlayState extends MusicBeatState private var strumLineNotes:FlxTypedGroup; + /** + * The currently active PlayState. + */ + public static var instance:PlayState = null; + /** * Strumline for player */ @@ -134,6 +140,8 @@ class PlayState extends MusicBeatState override public function create() { + instance = this; + initCameras(); // Starting health. @@ -1688,7 +1696,7 @@ class PlayState extends MusicBeatState scoreTxt.text = "Score:" + songScore; if (FlxG.keys.justPressed.EIGHT) - FlxG.switchState(new ui.animDebugShit.DebugBoundingState()); + FlxG.switchState(new funkin.ui.animDebugShit.DebugBoundingState()); if (FlxG.keys.justPressed.F5) debug_refreshStages(); @@ -2391,14 +2399,20 @@ class PlayState extends MusicBeatState function performCleanup() { + // Uncache the song. openfl.utils.Assets.cache.clear(Paths.inst(SONG.song)); openfl.utils.Assets.cache.clear(Paths.voices(SONG.song)); + + // Remove reference to stage and remove sprites from it to save memory. if (curStage != null) { remove(curStage); curStage.kill(); curStage = null; } + + // Clear the static reference to this state. + instance = null; } /** diff --git a/source/play/character/Character.hx b/source/funkin/play/character/Character.hx similarity index 59% rename from source/play/character/Character.hx rename to source/funkin/play/character/Character.hx index b4ee9bb03..c5ae1014a 100644 --- a/source/play/character/Character.hx +++ b/source/funkin/play/character/Character.hx @@ -1,9 +1,9 @@ -package play.character; - -enum CharacterType -{ - BF; - GF; - DAD; - OTHER; -} +package funkin.play.character; + +enum CharacterType +{ + BF; + GF; + DAD; + OTHER; +} diff --git a/source/play/stage/Bopper.hx b/source/funkin/play/stage/Bopper.hx similarity index 98% rename from source/play/stage/Bopper.hx rename to source/funkin/play/stage/Bopper.hx index c020e9975..3105847b2 100644 --- a/source/play/stage/Bopper.hx +++ b/source/funkin/play/stage/Bopper.hx @@ -1,4 +1,4 @@ -package play.stage; +package funkin.play.stage; import flixel.FlxSprite; diff --git a/source/play/stage/ScriptedBopper.hx b/source/funkin/play/stage/ScriptedBopper.hx similarity index 69% rename from source/play/stage/ScriptedBopper.hx rename to source/funkin/play/stage/ScriptedBopper.hx index 411adecfa..a344b0428 100644 --- a/source/play/stage/ScriptedBopper.hx +++ b/source/funkin/play/stage/ScriptedBopper.hx @@ -1,6 +1,6 @@ -package play.stage; +package funkin.play.stage; -import modding.IHook; +import funkin.modding.IHook; @:hscriptClass @:keep diff --git a/source/play/stage/ScriptedStage.hx b/source/funkin/play/stage/ScriptedStage.hx similarity index 68% rename from source/play/stage/ScriptedStage.hx rename to source/funkin/play/stage/ScriptedStage.hx index 792bf011d..114afb1d5 100644 --- a/source/play/stage/ScriptedStage.hx +++ b/source/funkin/play/stage/ScriptedStage.hx @@ -1,9 +1,9 @@ -package play.stage; - -import modding.IHook; - -@:hscriptClass -class ScriptedStage extends Stage implements IHook -{ - // No body needed for this class, it's magic ;) -} +package funkin.play.stage; + +import funkin.modding.IHook; + +@:hscriptClass +class ScriptedStage extends Stage implements IHook +{ + // No body needed for this class, it's magic ;) +} diff --git a/source/play/stage/Stage.hx b/source/funkin/play/stage/Stage.hx similarity index 98% rename from source/play/stage/Stage.hx rename to source/funkin/play/stage/Stage.hx index 829376b0a..6a5b2b0ad 100644 --- a/source/play/stage/Stage.hx +++ b/source/funkin/play/stage/Stage.hx @@ -1,13 +1,13 @@ -package play.stage; +package funkin.play.stage; import flixel.math.FlxPoint; import flixel.FlxSprite; import flixel.group.FlxSpriteGroup; import flixel.util.FlxSort; -import modding.IHook; -import play.character.Character.CharacterType; -import play.stage.StageData.StageDataParser; -import util.SortUtil; +import funkin.modding.IHook; +import funkin.play.character.Character.CharacterType; +import funkin.play.stage.StageData.StageDataParser; +import funkin.util.SortUtil; /** * A Stage is a group of objects rendered in the PlayState. diff --git a/source/play/stage/StageData.hx b/source/funkin/play/stage/StageData.hx similarity index 95% rename from source/play/stage/StageData.hx rename to source/funkin/play/stage/StageData.hx index 4cc78cf2e..2e9058a87 100644 --- a/source/play/stage/StageData.hx +++ b/source/funkin/play/stage/StageData.hx @@ -1,509 +1,509 @@ -package play.stage; - -import openfl.Assets; -import util.assets.DataAssets; -import haxe.Json; -import flixel.util.typeLimit.OneOfTwo; - -using StringTools; - -/** - * Contains utilities for loading and parsing stage data. - */ -class StageDataParser -{ - /** - * The current version string for the stage data format. - * Handle breaking changes by incrementing this value - * and adding migration to the `migrateStageData()` function. - */ - public static final STAGE_DATA_VERSION:String = "1.0"; - - static final stageCache:Map = new Map(); - - static final DEFAULT_STAGE_ID = 'UNKNOWN'; - - /** - * Parses and preloads the game's stage data and scripts when the game starts. - * - * If you want to force stages to be reloaded, you can just call this function again. - */ - public static function loadStageCache():Void - { - // Clear any stages that are cached if there were any. - clearStageCache(); - trace("[STAGEDATA] Loading stage cache..."); - - // - // SCRIPTED STAGES - // - var scriptedStageClassNames:Array = ScriptedStage.listScriptClasses(); - trace(' Instantiating ${scriptedStageClassNames.length} scripted stages...'); - for (stageCls in scriptedStageClassNames) - { - var stage:Stage = ScriptedStage.init(stageCls, DEFAULT_STAGE_ID); - if (stage != null) - { - trace(' Loaded scripted stage: ${stage.stageName}'); - // Disable the rendering logic for stage until it's loaded. - // Note that kill() =/= destroy() - stage.kill(); - - // Then store it. - stageCache.set(stage.stageId, stage); - } - else - { - trace(' Failed to instantiate scripted stage class: ${stageCls}'); - } - } - - // - // UNSCRIPTED STAGES - // - var stageIdList:Array = DataAssets.listDataFilesInPath('stages/'); - var unscriptedStageIds:Array = stageIdList.filter(function(stageId:String):Bool - { - return !stageCache.exists(stageId); - }); - trace(' Instantiating ${unscriptedStageIds.length} non-scripted stages...'); - for (stageId in unscriptedStageIds) - { - var stage:Stage; - try - { - stage = new Stage(stageId); - if (stage != null) - { - trace(' Loaded stage data: ${stage.stageName}'); - stageCache.set(stageId, stage); - } - } - catch (e) - { - // Assume error was already logged. - continue; - } - } - - trace(' Successfully loaded ${Lambda.count(stageCache)} stages.'); - } - - public static function fetchStage(stageId:String):Null - { - if (stageCache.exists(stageId)) - { - trace('[STAGEDATA] Successfully fetch stage: ${stageId}'); - var stage:Stage = stageCache.get(stageId); - stage.revive(); - return stage; - } - else - { - trace('[STAGEDATA] Failed to fetch stage, not found in cache: ${stageId}'); - return null; - } - } - - static function clearStageCache():Void - { - if (stageCache != null) - { - for (stage in stageCache) - { - stage.destroy(); - } - stageCache.clear(); - } - } - - /** - * Load a stage's JSON file, parse its data, and return it. - * - * @param stageId The stage to load. - * @return The stage data, or null if validation failed. - */ - public static function parseStageData(stageId:String):Null - { - var rawJson:String = loadStageFile(stageId); - - var stageData:StageData = migrateStageData(rawJson, stageId); - - return validateStageData(stageId, stageData); - } - - static function loadStageFile(stagePath:String):String - { - var stageFilePath:String = Paths.json('stages/${stagePath}'); - var rawJson = Assets.getText(stageFilePath).trim(); - - while (!rawJson.endsWith("}")) - { - rawJson = rawJson.substr(0, rawJson.length - 1); - } - - return rawJson; - } - - static function migrateStageData(rawJson:String, stageId:String) - { - // If you update the stage data format in a breaking way, - // handle migration here by checking the `version` value. - - try - { - var stageData:StageData = cast Json.parse(rawJson); - return stageData; - } - catch (e) - { - trace(' Error parsing data for stage: ${stageId}'); - trace(' ${e}'); - return null; - } - } - - static final DEFAULT_NAME:String = "Untitled Stage"; - static final DEFAULT_CAMERAZOOM:Float = 1.0; - static final DEFAULT_ZINDEX:Int = 0; - static final DEFAULT_DANCEEVERY:Int = 0; - static final DEFAULT_SCALE:Float = 1.0; - static final DEFAULT_ISPIXEL:Bool = false; - static final DEFAULT_POSITION:Array = [0, 0]; - static final DEFAULT_SCROLL:Array = [0, 0]; - static final DEFAULT_FRAMEINDICES:Array = []; - static final DEFAULT_ANIMTYPE:String = "sparrow"; - - static final DEFAULT_CHARACTER_DATA:StageDataCharacter = { - zIndex: DEFAULT_ZINDEX, - position: DEFAULT_POSITION, - } - - /** - * Set unspecified parameters to their defaults. - * If the parameter is mandatory, print an error message. - * @param id - * @param input - * @return The validated stage data - */ - static function validateStageData(id:String, input:StageData):Null - { - if (input == null) - { - trace('[STAGEDATA] ERROR: Could not parse stage data for "${id}".'); - return null; - } - - if (input.version != STAGE_DATA_VERSION) - { - trace('[STAGEDATA] ERROR: Could not load stage data for "$id": missing version'); - return null; - } - - if (input.name == null) - { - trace('[STAGEDATA] WARN: Stage data for "$id" missing name'); - input.name = DEFAULT_NAME; - } - - if (input.cameraZoom == null) - { - input.cameraZoom = DEFAULT_CAMERAZOOM; - } - - if (input.props == null || input.props.length == 0) - { - trace('[STAGEDATA] ERROR: Could not load stage data for "$id": missing props'); - return null; - } - - for (inputProp in input.props) - { - // It's fine for inputProp.name to be null - - if (inputProp.assetPath == null) - { - trace('[STAGEDATA] ERROR: Could not load stage data for "$id": missing assetPath for prop "${inputProp.name}"'); - return null; - } - - if (inputProp.position == null) - { - inputProp.position = DEFAULT_POSITION; - } - - if (inputProp.zIndex == null) - { - inputProp.zIndex = DEFAULT_ZINDEX; - } - - if (inputProp.isPixel == null) - { - inputProp.isPixel = DEFAULT_ISPIXEL; - } - - if (inputProp.danceEvery == null) - { - inputProp.danceEvery = DEFAULT_DANCEEVERY; - } - - if (inputProp.scale == null) - { - inputProp.scale = DEFAULT_SCALE; - } - - if (inputProp.animType == null) - { - inputProp.animType = DEFAULT_ANIMTYPE; - } - - if (Std.isOfType(inputProp.scale, Float)) - { - inputProp.scale = [inputProp.scale, inputProp.scale]; - } - - if (inputProp.scroll == null) - { - inputProp.scroll = DEFAULT_SCROLL; - } - - if (Std.isOfType(inputProp.scroll, Float)) - { - inputProp.scroll = [inputProp.scroll, inputProp.scroll]; - } - - if (inputProp.animations == null) - { - inputProp.animations = []; - } - - if (inputProp.animations.length == 0 && inputProp.startingAnimation != null) - { - trace('[STAGEDATA] ERROR: Could not load stage data for "$id": missing animations for prop "${inputProp.name}"'); - return null; - } - - for (inputAnimation in inputProp.animations) - { - if (inputAnimation.name == null) - { - trace('[STAGEDATA] ERROR: Could not load stage data for "$id": missing animation name for prop "${inputProp.name}"'); - return null; - } - - if (inputAnimation.frameRate == null) - { - inputAnimation.frameRate = 24; - } - - if (inputAnimation.frameIndices == null) - { - inputAnimation.frameIndices = DEFAULT_FRAMEINDICES; - } - - if (inputAnimation.loop == null) - { - inputAnimation.loop = true; - } - - if (inputAnimation.flipX == null) - { - inputAnimation.flipX = false; - } - - if (inputAnimation.flipY == null) - { - inputAnimation.flipY = false; - } - } - } - - if (input.characters == null) - { - trace('[STAGEDATA] ERROR: Could not load stage data for "$id": missing characters'); - return null; - } - - if (input.characters.bf == null) - { - input.characters.bf = DEFAULT_CHARACTER_DATA; - } - if (input.characters.dad == null) - { - input.characters.dad = DEFAULT_CHARACTER_DATA; - } - if (input.characters.gf == null) - { - input.characters.gf = DEFAULT_CHARACTER_DATA; - } - - for (inputCharacter in [input.characters.bf, input.characters.dad, input.characters.gf]) - { - if (inputCharacter.zIndex == null) - { - inputCharacter.zIndex = 0; - } - if (inputCharacter.position == null || inputCharacter.position.length != 2) - { - inputCharacter.position = [0, 0]; - } - } - - // All good! - return input; - } -} - -typedef StageData = -{ - // Uses semantic versioning. - var version:String; - var name:String; - var cameraZoom:Null; - var props:Array; - var characters: - { - bf:StageDataCharacter, - dad:StageDataCharacter, - gf:StageDataCharacter, - }; -}; - -typedef StageDataProp = -{ - /** - * The name of the prop for later lookup by scripts. - * Optional; if unspecified, the prop can't be referenced by scripts. - */ - var name:String; - - /** - * The asset used to display the prop. - */ - var assetPath:String; - - /** - * The position of the prop as an [x, y] array of two floats. - */ - var position:Array; - - /** - * A number determining the stack order of the prop, relative to other props and the characters in the stage. - * Props with lower numbers render below those with higher numbers. - * This is just like CSS, it isn't hard. - * @default 0 - */ - var zIndex:Null; - - /** - * If set to true, anti-aliasing will be forcibly disabled on the sprite. - * This prevents blurry images on pixel-art levels. - * @default false - */ - var isPixel:Null; - - /** - * Either the scale of the prop as a float, or the [w, h] scale as an array of two floats. - * Pro tip: On pixel-art levels, save the sprite small and set this value to 6 or so to save memory. - * @default 1 - */ - var scale:OneOfTwo>; - - /** - * If not zero, this prop will play an animation every X beats of the song. - * This requires animations to be defined. If `danceLeft` and `danceRight` are defined, - * they will alternated between, otherwise the `idle` animation will be used. - * - * @default 0 - */ - var danceEvery:Null; - - /** - * How much the prop scrolls relative to the camera. Used to create a parallax effect. - * Represented as a float or as an [x, y] array of two floats. - * [1, 1] means the prop moves 1:1 with the camera. - * [0.5, 0.5] means the prop half as much as the camera. - * [0, 0] means the prop is not moved. - * @default [0, 0] - */ - var scroll:OneOfTwo>; - - /** - * An optional array of animations which the prop can play. - * @default Prop has no animations. - */ - var animations:Array; - - /** - * If animations are used, this is the name of the animation to play first. - * @default Don't play an animation. - */ - var startingAnimation:String; - - /** - * The animation type to use. - * Options: "sparrow", "packer" - * @default "sparrow" - */ - var animType:String; -}; - -typedef StageDataPropAnimation = -{ - /** - * The name of the animation. - */ - var name:String; - - /** - * The common beginning of image names in atlas for this animation's frames. - * For example, if the frames are named "test0001.png", "test0002.png", etc., use "test". - */ - var prefix:String; - - /** - * If you want this animation to use only certain frames of an animation with a given prefix, - * select them here. - * @example [0, 1, 2, 3] (use only the first four frames) - * @default [] (all frames) - */ - var frameIndices:Array; - - /** - * The speed of the animation in frames per second. - * @default 24 - */ - var frameRate:Null; - - /** - * Whether the animation should loop. - * @default false - */ - var loop:Null; - - /** - * Whether to flip the sprite horizontally while animating. - * @default false - */ - var flipX:Null; - - /** - * Whether to flip the sprite vertically while animating. - * @default false - */ - var flipY:Null; -}; - -typedef StageDataCharacter = -{ - /** - * A number determining the stack order of the character, relative to props and other characters in the stage. - * Again, just like CSS. - * @default 0 - */ - zIndex:Null, - - /** - * The position to render the character at. - */ position:Array -}; +package funkin.play.stage; + +import openfl.Assets; +import funkin.util.assets.DataAssets; +import haxe.Json; +import flixel.util.typeLimit.OneOfTwo; + +using StringTools; + +/** + * Contains utilities for loading and parsing stage data. + */ +class StageDataParser +{ + /** + * The current version string for the stage data format. + * Handle breaking changes by incrementing this value + * and adding migration to the `migrateStageData()` function. + */ + public static final STAGE_DATA_VERSION:String = "1.0"; + + static final stageCache:Map = new Map(); + + static final DEFAULT_STAGE_ID = 'UNKNOWN'; + + /** + * Parses and preloads the game's stage data and scripts when the game starts. + * + * If you want to force stages to be reloaded, you can just call this function again. + */ + public static function loadStageCache():Void + { + // Clear any stages that are cached if there were any. + clearStageCache(); + trace("[STAGEDATA] Loading stage cache..."); + + // + // SCRIPTED STAGES + // + var scriptedStageClassNames:Array = ScriptedStage.listScriptClasses(); + trace(' Instantiating ${scriptedStageClassNames.length} scripted stages...'); + for (stageCls in scriptedStageClassNames) + { + var stage:Stage = ScriptedStage.init(stageCls, DEFAULT_STAGE_ID); + if (stage != null) + { + trace(' Loaded scripted stage: ${stage.stageName}'); + // Disable the rendering logic for stage until it's loaded. + // Note that kill() =/= destroy() + stage.kill(); + + // Then store it. + stageCache.set(stage.stageId, stage); + } + else + { + trace(' Failed to instantiate scripted stage class: ${stageCls}'); + } + } + + // + // UNSCRIPTED STAGES + // + var stageIdList:Array = DataAssets.listDataFilesInPath('stages/'); + var unscriptedStageIds:Array = stageIdList.filter(function(stageId:String):Bool + { + return !stageCache.exists(stageId); + }); + trace(' Instantiating ${unscriptedStageIds.length} non-scripted stages...'); + for (stageId in unscriptedStageIds) + { + var stage:Stage; + try + { + stage = new Stage(stageId); + if (stage != null) + { + trace(' Loaded stage data: ${stage.stageName}'); + stageCache.set(stageId, stage); + } + } + catch (e) + { + // Assume error was already logged. + continue; + } + } + + trace(' Successfully loaded ${Lambda.count(stageCache)} stages.'); + } + + public static function fetchStage(stageId:String):Null + { + if (stageCache.exists(stageId)) + { + trace('[STAGEDATA] Successfully fetch stage: ${stageId}'); + var stage:Stage = stageCache.get(stageId); + stage.revive(); + return stage; + } + else + { + trace('[STAGEDATA] Failed to fetch stage, not found in cache: ${stageId}'); + return null; + } + } + + static function clearStageCache():Void + { + if (stageCache != null) + { + for (stage in stageCache) + { + stage.destroy(); + } + stageCache.clear(); + } + } + + /** + * Load a stage's JSON file, parse its data, and return it. + * + * @param stageId The stage to load. + * @return The stage data, or null if validation failed. + */ + public static function parseStageData(stageId:String):Null + { + var rawJson:String = loadStageFile(stageId); + + var stageData:StageData = migrateStageData(rawJson, stageId); + + return validateStageData(stageId, stageData); + } + + static function loadStageFile(stagePath:String):String + { + var stageFilePath:String = Paths.json('stages/${stagePath}'); + var rawJson = Assets.getText(stageFilePath).trim(); + + while (!rawJson.endsWith("}")) + { + rawJson = rawJson.substr(0, rawJson.length - 1); + } + + return rawJson; + } + + static function migrateStageData(rawJson:String, stageId:String) + { + // If you update the stage data format in a breaking way, + // handle migration here by checking the `version` value. + + try + { + var stageData:StageData = cast Json.parse(rawJson); + return stageData; + } + catch (e) + { + trace(' Error parsing data for stage: ${stageId}'); + trace(' ${e}'); + return null; + } + } + + static final DEFAULT_NAME:String = "Untitled Stage"; + static final DEFAULT_CAMERAZOOM:Float = 1.0; + static final DEFAULT_ZINDEX:Int = 0; + static final DEFAULT_DANCEEVERY:Int = 0; + static final DEFAULT_SCALE:Float = 1.0; + static final DEFAULT_ISPIXEL:Bool = false; + static final DEFAULT_POSITION:Array = [0, 0]; + static final DEFAULT_SCROLL:Array = [0, 0]; + static final DEFAULT_FRAMEINDICES:Array = []; + static final DEFAULT_ANIMTYPE:String = "sparrow"; + + static final DEFAULT_CHARACTER_DATA:StageDataCharacter = { + zIndex: DEFAULT_ZINDEX, + position: DEFAULT_POSITION, + } + + /** + * Set unspecified parameters to their defaults. + * If the parameter is mandatory, print an error message. + * @param id + * @param input + * @return The validated stage data + */ + static function validateStageData(id:String, input:StageData):Null + { + if (input == null) + { + trace('[STAGEDATA] ERROR: Could not parse stage data for "${id}".'); + return null; + } + + if (input.version != STAGE_DATA_VERSION) + { + trace('[STAGEDATA] ERROR: Could not load stage data for "$id": missing version'); + return null; + } + + if (input.name == null) + { + trace('[STAGEDATA] WARN: Stage data for "$id" missing name'); + input.name = DEFAULT_NAME; + } + + if (input.cameraZoom == null) + { + input.cameraZoom = DEFAULT_CAMERAZOOM; + } + + if (input.props == null || input.props.length == 0) + { + trace('[STAGEDATA] ERROR: Could not load stage data for "$id": missing props'); + return null; + } + + for (inputProp in input.props) + { + // It's fine for inputProp.name to be null + + if (inputProp.assetPath == null) + { + trace('[STAGEDATA] ERROR: Could not load stage data for "$id": missing assetPath for prop "${inputProp.name}"'); + return null; + } + + if (inputProp.position == null) + { + inputProp.position = DEFAULT_POSITION; + } + + if (inputProp.zIndex == null) + { + inputProp.zIndex = DEFAULT_ZINDEX; + } + + if (inputProp.isPixel == null) + { + inputProp.isPixel = DEFAULT_ISPIXEL; + } + + if (inputProp.danceEvery == null) + { + inputProp.danceEvery = DEFAULT_DANCEEVERY; + } + + if (inputProp.scale == null) + { + inputProp.scale = DEFAULT_SCALE; + } + + if (inputProp.animType == null) + { + inputProp.animType = DEFAULT_ANIMTYPE; + } + + if (Std.isOfType(inputProp.scale, Float)) + { + inputProp.scale = [inputProp.scale, inputProp.scale]; + } + + if (inputProp.scroll == null) + { + inputProp.scroll = DEFAULT_SCROLL; + } + + if (Std.isOfType(inputProp.scroll, Float)) + { + inputProp.scroll = [inputProp.scroll, inputProp.scroll]; + } + + if (inputProp.animations == null) + { + inputProp.animations = []; + } + + if (inputProp.animations.length == 0 && inputProp.startingAnimation != null) + { + trace('[STAGEDATA] ERROR: Could not load stage data for "$id": missing animations for prop "${inputProp.name}"'); + return null; + } + + for (inputAnimation in inputProp.animations) + { + if (inputAnimation.name == null) + { + trace('[STAGEDATA] ERROR: Could not load stage data for "$id": missing animation name for prop "${inputProp.name}"'); + return null; + } + + if (inputAnimation.frameRate == null) + { + inputAnimation.frameRate = 24; + } + + if (inputAnimation.frameIndices == null) + { + inputAnimation.frameIndices = DEFAULT_FRAMEINDICES; + } + + if (inputAnimation.loop == null) + { + inputAnimation.loop = true; + } + + if (inputAnimation.flipX == null) + { + inputAnimation.flipX = false; + } + + if (inputAnimation.flipY == null) + { + inputAnimation.flipY = false; + } + } + } + + if (input.characters == null) + { + trace('[STAGEDATA] ERROR: Could not load stage data for "$id": missing characters'); + return null; + } + + if (input.characters.bf == null) + { + input.characters.bf = DEFAULT_CHARACTER_DATA; + } + if (input.characters.dad == null) + { + input.characters.dad = DEFAULT_CHARACTER_DATA; + } + if (input.characters.gf == null) + { + input.characters.gf = DEFAULT_CHARACTER_DATA; + } + + for (inputCharacter in [input.characters.bf, input.characters.dad, input.characters.gf]) + { + if (inputCharacter.zIndex == null) + { + inputCharacter.zIndex = 0; + } + if (inputCharacter.position == null || inputCharacter.position.length != 2) + { + inputCharacter.position = [0, 0]; + } + } + + // All good! + return input; + } +} + +typedef StageData = +{ + // Uses semantic versioning. + var version:String; + var name:String; + var cameraZoom:Null; + var props:Array; + var characters: + { + bf:StageDataCharacter, + dad:StageDataCharacter, + gf:StageDataCharacter, + }; +}; + +typedef StageDataProp = +{ + /** + * The name of the prop for later lookup by scripts. + * Optional; if unspecified, the prop can't be referenced by scripts. + */ + var name:String; + + /** + * The asset used to display the prop. + */ + var assetPath:String; + + /** + * The position of the prop as an [x, y] array of two floats. + */ + var position:Array; + + /** + * A number determining the stack order of the prop, relative to other props and the characters in the stage. + * Props with lower numbers render below those with higher numbers. + * This is just like CSS, it isn't hard. + * @default 0 + */ + var zIndex:Null; + + /** + * If set to true, anti-aliasing will be forcibly disabled on the sprite. + * This prevents blurry images on pixel-art levels. + * @default false + */ + var isPixel:Null; + + /** + * Either the scale of the prop as a float, or the [w, h] scale as an array of two floats. + * Pro tip: On pixel-art levels, save the sprite small and set this value to 6 or so to save memory. + * @default 1 + */ + var scale:OneOfTwo>; + + /** + * If not zero, this prop will play an animation every X beats of the song. + * This requires animations to be defined. If `danceLeft` and `danceRight` are defined, + * they will alternated between, otherwise the `idle` animation will be used. + * + * @default 0 + */ + var danceEvery:Null; + + /** + * How much the prop scrolls relative to the camera. Used to create a parallax effect. + * Represented as a float or as an [x, y] array of two floats. + * [1, 1] means the prop moves 1:1 with the camera. + * [0.5, 0.5] means the prop half as much as the camera. + * [0, 0] means the prop is not moved. + * @default [0, 0] + */ + var scroll:OneOfTwo>; + + /** + * An optional array of animations which the prop can play. + * @default Prop has no animations. + */ + var animations:Array; + + /** + * If animations are used, this is the name of the animation to play first. + * @default Don't play an animation. + */ + var startingAnimation:String; + + /** + * The animation type to use. + * Options: "sparrow", "packer" + * @default "sparrow" + */ + var animType:String; +}; + +typedef StageDataPropAnimation = +{ + /** + * The name of the animation. + */ + var name:String; + + /** + * The common beginning of image names in atlas for this animation's frames. + * For example, if the frames are named "test0001.png", "test0002.png", etc., use "test". + */ + var prefix:String; + + /** + * If you want this animation to use only certain frames of an animation with a given prefix, + * select them here. + * @example [0, 1, 2, 3] (use only the first four frames) + * @default [] (all frames) + */ + var frameIndices:Array; + + /** + * The speed of the animation in frames per second. + * @default 24 + */ + var frameRate:Null; + + /** + * Whether the animation should loop. + * @default false + */ + var loop:Null; + + /** + * Whether to flip the sprite horizontally while animating. + * @default false + */ + var flipX:Null; + + /** + * Whether to flip the sprite vertically while animating. + * @default false + */ + var flipY:Null; +}; + +typedef StageDataCharacter = +{ + /** + * A number determining the stack order of the character, relative to props and other characters in the stage. + * Again, just like CSS. + * @default 0 + */ + zIndex:Null, + + /** + * The position to render the character at. + */ position:Array +}; diff --git a/source/rendering/MeshRender.hx b/source/funkin/rendering/MeshRender.hx similarity index 98% rename from source/rendering/MeshRender.hx rename to source/funkin/rendering/MeshRender.hx index d981a1303..2865b1a3d 100644 --- a/source/rendering/MeshRender.hx +++ b/source/funkin/rendering/MeshRender.hx @@ -1,4 +1,4 @@ -package rendering; +package funkin.rendering; import flixel.FlxStrip; import flixel.util.FlxColor; diff --git a/source/shaderslmfao/AngleMask.hx b/source/funkin/shaderslmfao/AngleMask.hx similarity index 96% rename from source/shaderslmfao/AngleMask.hx rename to source/funkin/shaderslmfao/AngleMask.hx index 2b276de05..1f16d63ca 100644 --- a/source/shaderslmfao/AngleMask.hx +++ b/source/funkin/shaderslmfao/AngleMask.hx @@ -1,4 +1,4 @@ -package shaderslmfao; +package funkin.shaderslmfao; import flixel.system.FlxAssets.FlxShader; diff --git a/source/BlendModeEffect.hx b/source/funkin/shaderslmfao/BlendModeEffect.hx similarity index 96% rename from source/BlendModeEffect.hx rename to source/funkin/shaderslmfao/BlendModeEffect.hx index 1c9038be7..bc242b3e3 100644 --- a/source/BlendModeEffect.hx +++ b/source/funkin/shaderslmfao/BlendModeEffect.hx @@ -1,4 +1,4 @@ -package; +package funkin.shaderslmfao; import flixel.util.FlxColor; import openfl.display.ShaderParameter; diff --git a/source/shaderslmfao/BuildingShaders.hx b/source/funkin/shaderslmfao/BuildingShaders.hx similarity index 96% rename from source/shaderslmfao/BuildingShaders.hx rename to source/funkin/shaderslmfao/BuildingShaders.hx index a89a3b0df..62b9b0154 100644 --- a/source/shaderslmfao/BuildingShaders.hx +++ b/source/funkin/shaderslmfao/BuildingShaders.hx @@ -1,4 +1,4 @@ -package shaderslmfao; +package funkin.shaderslmfao; import flixel.system.FlxAssets.FlxShader; diff --git a/source/shaderslmfao/ColorSwap.hx b/source/funkin/shaderslmfao/ColorSwap.hx similarity index 99% rename from source/shaderslmfao/ColorSwap.hx rename to source/funkin/shaderslmfao/ColorSwap.hx index e24ac1095..0738789be 100644 --- a/source/shaderslmfao/ColorSwap.hx +++ b/source/funkin/shaderslmfao/ColorSwap.hx @@ -1,4 +1,4 @@ -package shaderslmfao; +package funkin.shaderslmfao; import flixel.system.FlxAssets.FlxShader; import flixel.util.FlxColor; diff --git a/source/shaderslmfao/MultiplyShader.hx b/source/funkin/shaderslmfao/MultiplyShader.hx similarity index 95% rename from source/shaderslmfao/MultiplyShader.hx rename to source/funkin/shaderslmfao/MultiplyShader.hx index e86820ba1..27ae60d3b 100644 --- a/source/shaderslmfao/MultiplyShader.hx +++ b/source/funkin/shaderslmfao/MultiplyShader.hx @@ -1,4 +1,4 @@ -package; +package funkin.shaderslmfao; import flixel.system.FlxAssets.FlxShader; @@ -28,4 +28,4 @@ class MultiplyShader extends FlxShader { super(); } -} \ No newline at end of file +} diff --git a/source/shaderslmfao/OverlayBlend.hx b/source/funkin/shaderslmfao/OverlayBlend.hx similarity index 97% rename from source/shaderslmfao/OverlayBlend.hx rename to source/funkin/shaderslmfao/OverlayBlend.hx index cf8996346..162726f69 100644 --- a/source/shaderslmfao/OverlayBlend.hx +++ b/source/funkin/shaderslmfao/OverlayBlend.hx @@ -1,8 +1,9 @@ -package shaderslmfao; +package funkin.shaderslmfao; import flixel.math.FlxPoint; import flixel.system.FlxAssets.FlxShader; +@:keep class OverlayBlend extends FlxShader { // these r copypaste diff --git a/source/shaderslmfao/PureColor.hx b/source/funkin/shaderslmfao/PureColor.hx similarity index 96% rename from source/shaderslmfao/PureColor.hx rename to source/funkin/shaderslmfao/PureColor.hx index 774df767a..3546e7fda 100644 --- a/source/shaderslmfao/PureColor.hx +++ b/source/funkin/shaderslmfao/PureColor.hx @@ -1,4 +1,4 @@ -package shaderslmfao; +package funkin.shaderslmfao; import flixel.system.FlxAssets.FlxShader; import flixel.util.FlxColor; diff --git a/source/shaderslmfao/ScreenWipeShader.hx b/source/funkin/shaderslmfao/ScreenWipeShader.hx similarity index 98% rename from source/shaderslmfao/ScreenWipeShader.hx rename to source/funkin/shaderslmfao/ScreenWipeShader.hx index 5264f7c33..37e6d604d 100644 --- a/source/shaderslmfao/ScreenWipeShader.hx +++ b/source/funkin/shaderslmfao/ScreenWipeShader.hx @@ -1,4 +1,4 @@ -package shaderslmfao; +package funkin.shaderslmfao; import flixel.system.FlxAssets.FlxShader; diff --git a/source/shaderslmfao/StrokeShader.hx b/source/funkin/shaderslmfao/StrokeShader.hx similarity index 98% rename from source/shaderslmfao/StrokeShader.hx rename to source/funkin/shaderslmfao/StrokeShader.hx index a6ba1ccad..575ff9419 100644 --- a/source/shaderslmfao/StrokeShader.hx +++ b/source/funkin/shaderslmfao/StrokeShader.hx @@ -1,4 +1,4 @@ -package shaderslmfao; +package funkin.shaderslmfao; import flixel.system.FlxAssets.FlxShader; import flixel.util.FlxColor; diff --git a/source/shaderslmfao/TitleOutline.hx b/source/funkin/shaderslmfao/TitleOutline.hx similarity index 98% rename from source/shaderslmfao/TitleOutline.hx rename to source/funkin/shaderslmfao/TitleOutline.hx index c8d002d85..cabab767d 100644 --- a/source/shaderslmfao/TitleOutline.hx +++ b/source/funkin/shaderslmfao/TitleOutline.hx @@ -1,4 +1,4 @@ -package shaderslmfao; +package funkin.shaderslmfao; import flixel.math.FlxPoint; import flixel.system.FlxAssets.FlxShader; diff --git a/source/shaderslmfao/WaveShader.hx b/source/funkin/shaderslmfao/WaveShader.hx similarity index 91% rename from source/shaderslmfao/WaveShader.hx rename to source/funkin/shaderslmfao/WaveShader.hx index 9e7be1adf..14aa2b7b1 100644 --- a/source/shaderslmfao/WaveShader.hx +++ b/source/funkin/shaderslmfao/WaveShader.hx @@ -1,4 +1,4 @@ -package shaderslmfao; +package funkin.shaderslmfao; import flixel.system.FlxAssets.FlxShader; diff --git a/source/shaderslmfao/WiggleEffect.hx b/source/funkin/shaderslmfao/WiggleEffect.hx similarity index 99% rename from source/shaderslmfao/WiggleEffect.hx rename to source/funkin/shaderslmfao/WiggleEffect.hx index fe134e4cc..bae55c6b1 100644 --- a/source/shaderslmfao/WiggleEffect.hx +++ b/source/funkin/shaderslmfao/WiggleEffect.hx @@ -1,4 +1,4 @@ -package shaderslmfao; +package funkin.shaderslmfao; // STOLEN FROM HAXEFLIXEL DEMO LOL import flixel.system.FlxAssets.FlxShader; diff --git a/source/ui/AtlasMenuList.hx b/source/funkin/ui/AtlasMenuList.hx similarity index 86% rename from source/ui/AtlasMenuList.hx rename to source/funkin/ui/AtlasMenuList.hx index 68232da5c..7a217a44c 100644 --- a/source/ui/AtlasMenuList.hx +++ b/source/funkin/ui/AtlasMenuList.hx @@ -1,7 +1,6 @@ -package ui; - -import ui.MenuList; +package funkin.ui; +import funkin.ui.MenuList; import flixel.graphics.frames.FlxAtlasFrames; typedef AtlasAsset = flixel.util.typeLimit.OneOfTwo; @@ -9,24 +8,24 @@ typedef AtlasAsset = flixel.util.typeLimit.OneOfTwo; class AtlasMenuList extends MenuTypedList { public var atlas:FlxAtlasFrames; - - public function new (atlas, navControls:NavControls = Vertical, ?wrapMode) + + public function new(atlas, navControls:NavControls = Vertical, ?wrapMode) { super(navControls, wrapMode); - + if (Std.is(atlas, String)) this.atlas = Paths.getSparrowAtlas(cast atlas); else this.atlas = cast atlas; } - + public function createItem(x = 0.0, y = 0.0, name, callback, fireInstantly = false) { var item = new AtlasMenuItem(x, y, name, atlas, callback); item.fireInstantly = fireInstantly; return addItem(name, item); } - + override function destroy() { super.destroy(); @@ -35,47 +34,48 @@ class AtlasMenuList extends MenuTypedList } class AtlasMenuItem extends MenuItem -{ +{ var atlas:FlxAtlasFrames; - public function new (x = 0.0, y = 0.0, name:String, atlas:FlxAtlasFrames, callback) + + public function new(x = 0.0, y = 0.0, name:String, atlas:FlxAtlasFrames, callback) { this.atlas = atlas; super(x, y, name, callback); } - + override function setData(name:String, ?callback:Void->Void) { frames = atlas; animation.addByPrefix('idle', '$name idle', 24); animation.addByPrefix('selected', '$name selected', 24); - + super.setData(name, callback); } - + function changeAnim(animName:String) { animation.play(animName); updateHitbox(); } - + override function idle() { changeAnim('idle'); } - + override function select() { changeAnim('selected'); } - + override function get_selected() { return animation.curAnim != null && animation.curAnim.name == "selected"; } - + override function destroy() { super.destroy(); atlas = null; } -} \ No newline at end of file +} diff --git a/source/ui/AtlasText.hx b/source/funkin/ui/AtlasText.hx similarity index 80% rename from source/ui/AtlasText.hx rename to source/funkin/ui/AtlasText.hx index 9ac6ae059..6df5f9e22 100644 --- a/source/ui/AtlasText.hx +++ b/source/funkin/ui/AtlasText.hx @@ -1,4 +1,4 @@ -package ui; +package funkin.ui; import flixel.FlxSprite; import flixel.group.FlxSpriteGroup; @@ -8,7 +8,7 @@ import flixel.util.FlxStringUtil; @:forward abstract BoldText(AtlasText) from AtlasText to AtlasText { - inline public function new (x = 0.0, y = 0.0, text:String) + inline public function new(x = 0.0, y = 0.0, text:String) { this = new AtlasText(x, y, text, Bold); } @@ -21,58 +21,67 @@ class AtlasText extends FlxTypedSpriteGroup { static var fonts = new Map(); static var casesAllowed = new Map(); + public var text(default, set):String = ""; - + var font:AtlasFontData; - + public var atlas(get, never):FlxAtlasFrames; - inline function get_atlas() return font.atlas; + + inline function get_atlas() + return font.atlas; + public var caseAllowed(get, never):Case; - inline function get_caseAllowed() return font.caseAllowed; + + inline function get_caseAllowed() + return font.caseAllowed; + public var maxHeight(get, never):Float; - inline function get_maxHeight() return font.maxHeight; - - public function new (x = 0.0, y = 0.0, text:String, fontName:AtlasFont = Default) + + inline function get_maxHeight() + return font.maxHeight; + + public function new(x = 0.0, y = 0.0, text:String, fontName:AtlasFont = Default) { if (!fonts.exists(fontName)) fonts[fontName] = new AtlasFontData(fontName); font = fonts[fontName]; - + super(x, y); - + this.text = text; } - + function set_text(value:String) { if (value == null) value = ""; - + var caseValue = restrictCase(value); var caseText = restrictCase(this.text); - + this.text = value; if (caseText == caseValue) return value; // cancel redraw - + if (caseValue.indexOf(caseText) == 0) { // new text is just old text with additions at the end, append the difference appendTextCased(caseValue.substr(caseText.length)); return this.text; } - + value = caseValue; - + group.kill(); - + if (value == "") return this.text; - + appendTextCased(caseValue); return this.text; } - + /** * Adds new characters, without needing to redraw the previous characters * @param text The text to add. @@ -82,27 +91,27 @@ class AtlasText extends FlxTypedSpriteGroup { if (text == null) throw "cannot append null"; - + if (text == "") return; - + this.text = this.text + text; } - + /** * Converts all characters to fit the font's `allowedCase`. * @param text */ function restrictCase(text:String) { - return switch(caseAllowed) + return switch (caseAllowed) { case Both: text; case Upper: text.toUpperCase(); case Lower: text.toLowerCase(); } } - + /** * Adds new text on top of the existing text. Helper for other methods; DOESN'T CHANGE `this.text`. * @param text The text to add, assumed to match the font's `caseAllowed`. @@ -121,58 +130,58 @@ class AtlasText extends FlxTypedSpriteGroup xPos = lastChar.x + lastChar.width - x; yPos = lastChar.y + lastChar.height - maxHeight - y; } - + var splitValues = text.split(""); for (i in 0...splitValues.length) { - switch(splitValues[i]) + switch (splitValues[i]) { case " ": - { - xPos += 40; - } - case "\n": - { - xPos = 0; - yPos += maxHeight; - } - case char: - { - var charSprite:AtlasChar; - if (group.members.length <= charCount) - charSprite = new AtlasChar(atlas, char); - else { - charSprite = group.members[charCount]; - charSprite.revive(); - charSprite.char = char; - charSprite.alpha = 1;//gets multiplied when added + xPos += 40; + } + case "\n": + { + xPos = 0; + yPos += maxHeight; + } + case char: + { + var charSprite:AtlasChar; + if (group.members.length <= charCount) + charSprite = new AtlasChar(atlas, char); + else + { + charSprite = group.members[charCount]; + charSprite.revive(); + charSprite.char = char; + charSprite.alpha = 1; // gets multiplied when added + } + charSprite.x = xPos; + charSprite.y = yPos + maxHeight - charSprite.height; + add(charSprite); + + xPos += charSprite.width; + charCount++; } - charSprite.x = xPos; - charSprite.y = yPos + maxHeight - charSprite.height; - add(charSprite); - - xPos += charSprite.width; - charCount++; - } } } } - + override function toString() { - return "InputItem, " + FlxStringUtil.getDebugString( - [ LabelValuePair.weak("x", x) - , LabelValuePair.weak("y", y) - , LabelValuePair.weak("text", text) - ] - ); + return "InputItem, " + FlxStringUtil.getDebugString([ + LabelValuePair.weak("x", x), + LabelValuePair.weak("y", y), + LabelValuePair.weak("text", text) + ]); } } class AtlasChar extends FlxSprite { public var char(default, set):String; + public function new(x = 0.0, y = 0.0, atlas:FlxAtlasFrames, char:String) { super(x, y); @@ -180,7 +189,7 @@ class AtlasChar extends FlxSprite this.char = char; antialiasing = true; } - + function set_char(value:String) { if (this.char != value) @@ -230,31 +239,31 @@ private class AtlasFontData { static public var upperChar = ~/^[A-Z]\d+$/; static public var lowerChar = ~/^[a-z]\d+$/; - + public var atlas:FlxAtlasFrames; public var maxHeight:Float = 0.0; public var caseAllowed:Case = Both; - - public function new (name:AtlasFont) + + public function new(name:AtlasFont) { atlas = Paths.getSparrowAtlas("fonts/" + name.getName().toLowerCase()); atlas.parent.destroyOnNoUse = false; atlas.parent.persist = true; - + var containsUpper = false; var containsLower = false; - + for (frame in atlas.frames) { maxHeight = Math.max(maxHeight, frame.frame.height); - + if (!containsUpper) containsUpper = upperChar.match(frame.name); - + if (!containsLower) containsLower = lowerChar.match(frame.name); } - + if (containsUpper != containsLower) caseAllowed = containsUpper ? Upper : Lower; } @@ -271,4 +280,4 @@ enum AtlasFont { Default; Bold; -} \ No newline at end of file +} diff --git a/source/ui/ColorsMenu.hx b/source/funkin/ui/ColorsMenu.hx similarity index 94% rename from source/ui/ColorsMenu.hx rename to source/funkin/ui/ColorsMenu.hx index cef364c2c..84739058b 100644 --- a/source/ui/ColorsMenu.hx +++ b/source/funkin/ui/ColorsMenu.hx @@ -1,11 +1,12 @@ -package ui; +package funkin.ui; import flixel.addons.effects.chainable.FlxEffectSprite; import flixel.addons.effects.chainable.FlxOutlineEffect; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.util.FlxColor; +import funkin.ui.OptionsState.Page; -class ColorsMenu extends ui.OptionsState.Page +class ColorsMenu extends Page { var curSelected:Int = 0; diff --git a/source/ui/ControlsMenu.hx b/source/funkin/ui/ControlsMenu.hx similarity index 97% rename from source/ui/ControlsMenu.hx rename to source/funkin/ui/ControlsMenu.hx index 7b8d129cf..fb4144b5b 100644 --- a/source/ui/ControlsMenu.hx +++ b/source/funkin/ui/ControlsMenu.hx @@ -1,6 +1,6 @@ -package ui; +package funkin.ui; -import Controls; +import funkin.Controls; import flixel.FlxCamera; import flixel.FlxObject; import flixel.FlxSprite; @@ -8,11 +8,11 @@ import flixel.group.FlxGroup; import flixel.input.actions.FlxActionInput; import flixel.input.gamepad.FlxGamepadInputID; import flixel.input.keyboard.FlxKey; -import ui.AtlasText; -import ui.MenuList; -import ui.TextMenuList; +import funkin.ui.AtlasText; +import funkin.ui.MenuList; +import funkin.ui.TextMenuList; -class ControlsMenu extends ui.OptionsState.Page +class ControlsMenu extends funkin.ui.OptionsState.Page { inline static public var COLUMNS = 2; static var controlList = Control.createAll(); diff --git a/source/ui/MenuList.hx b/source/funkin/ui/MenuList.hx similarity index 99% rename from source/ui/MenuList.hx rename to source/funkin/ui/MenuList.hx index e8bc63cc3..347415f70 100644 --- a/source/ui/MenuList.hx +++ b/source/funkin/ui/MenuList.hx @@ -1,4 +1,4 @@ -package ui; +package funkin.ui; import flixel.FlxSprite; import flixel.effects.FlxFlicker; diff --git a/source/ui/ModMenu.hx b/source/funkin/ui/ModMenu.hx similarity index 95% rename from source/ui/ModMenu.hx rename to source/funkin/ui/ModMenu.hx index 5979cf926..3d195e861 100644 --- a/source/ui/ModMenu.hx +++ b/source/funkin/ui/ModMenu.hx @@ -1,12 +1,13 @@ -package ui; +package funkin.ui; -import modding.PolymodHandler; +import funkin.modding.PolymodHandler; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.text.FlxText; import flixel.util.FlxColor; import polymod.Polymod; +import funkin.ui.OptionsState.Page; -class ModMenu extends ui.OptionsState.Page +class ModMenu extends Page { var grpMods:FlxTypedGroup; var enabledMods:Array = []; diff --git a/source/ui/NgPrompt.hx b/source/funkin/ui/NgPrompt.hx similarity index 52% rename from source/ui/NgPrompt.hx rename to source/funkin/ui/NgPrompt.hx index 4bf75997f..716880b11 100644 --- a/source/ui/NgPrompt.hx +++ b/source/funkin/ui/NgPrompt.hx @@ -1,80 +1,77 @@ -package ui; +package funkin.ui; -import NGio; -import ui.Prompt; +#if newgrounds +import funkin.NGio; +import funkin.ui.Prompt; class NgPrompt extends Prompt { - public function new (text:String, style:ButtonStyle = Yes_No) + public function new(text:String, style:ButtonStyle = Yes_No) { super(text, style); } - + static public function showLogin() { return showLoginPrompt(true); } - + static public function showSavedSessionFailed() { return showLoginPrompt(false); } - + static function showLoginPrompt(fromUi:Bool) { var prompt = new NgPrompt("Talking to server...", None); - prompt.openCallback = NGio.login.bind - ( - function popupLauncher(openPassportUrl) + prompt.openCallback = NGio.login.bind(function popupLauncher(openPassportUrl) + { + var choiceMsg = fromUi ? #if web "Log in to Newgrounds?" #else null #end // User-input needed to allow popups + : "Your session has expired.\n Please login again."; + + if (choiceMsg != null) { - var choiceMsg = fromUi - ? #if web "Log in to Newgrounds?" #else null #end // User-input needed to allow popups - : "Your session has expired.\n Please login again."; - - if (choiceMsg != null) + prompt.setText(choiceMsg); + prompt.setButtons(Yes_No); + #if web + prompt.buttons.getItem("yes").fireInstantly = true; + #end + prompt.onYes = function() { - prompt.setText(choiceMsg); - prompt.setButtons(Yes_No); - #if web - prompt.buttons.getItem("yes").fireInstantly = true; - #end - prompt.onYes = function() - { - prompt.setText("Connecting..." #if web + "\n(check your popup blocker)" #end); - prompt.setButtons(None); - openPassportUrl(); - }; - prompt.onNo = function() - { - prompt.close(); - prompt = null; - NGio.cancelLogin(); - }; - } - else - { - prompt.setText("Connecting..."); + prompt.setText("Connecting..." #if web + "\n(check your popup blocker)" #end); + prompt.setButtons(None); openPassportUrl(); - } - }, - function onLoginComplete(result:ConnectionResult) - { - switch (result) + }; + prompt.onNo = function() { - case Success: + prompt.close(); + prompt = null; + NGio.cancelLogin(); + }; + } + else + { + prompt.setText("Connecting..."); + openPassportUrl(); + } + }, function onLoginComplete(result:ConnectionResult) + { + switch (result) + { + case Success: { prompt.setText("Login Successful"); prompt.setButtons(Ok); prompt.onYes = prompt.close; } - case Fail(msg): + case Fail(msg): { trace("Login Error:" + msg); prompt.setText("Login failed"); prompt.setButtons(Ok); prompt.onYes = prompt.close; } - case Cancelled: + case Cancelled: { if (prompt != null) { @@ -85,13 +82,12 @@ class NgPrompt extends Prompt else trace("Login cancelled via prompt"); } - } } - ); - + }); + return prompt; } - + static public function showLogout() { var user = io.newgrounds.NG.core.user.name; @@ -104,4 +100,5 @@ class NgPrompt extends Prompt prompt.onNo = prompt.close; return prompt; } -} \ No newline at end of file +} +#end diff --git a/source/ui/OptionsState.hx b/source/funkin/ui/OptionsState.hx similarity index 98% rename from source/ui/OptionsState.hx rename to source/funkin/ui/OptionsState.hx index 6d2dade8f..1b6d03e93 100644 --- a/source/ui/OptionsState.hx +++ b/source/funkin/ui/OptionsState.hx @@ -1,11 +1,11 @@ -package ui; +package funkin.ui; import flixel.FlxSprite; import flixel.FlxSubState; import flixel.addons.transition.FlxTransitionableState; import flixel.group.FlxGroup; import flixel.util.FlxSignal; -import i18n.FireTongueHandler.t; +import funkin.i18n.FireTongueHandler.t; // typedef OptionsState = OptionsMenu_old; // class OptionsState_new extends MusicBeatState diff --git a/source/ui/PopUpStuff.hx b/source/funkin/ui/PopUpStuff.hx similarity index 98% rename from source/ui/PopUpStuff.hx rename to source/funkin/ui/PopUpStuff.hx index a28c8f0cb..02f08687d 100644 --- a/source/ui/PopUpStuff.hx +++ b/source/funkin/ui/PopUpStuff.hx @@ -1,8 +1,9 @@ -package ui; +package funkin.ui; import flixel.FlxSprite; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.tweens.FlxTween; +import funkin.play.PlayState; using StringTools; diff --git a/source/ui/PreferencesMenu.hx b/source/funkin/ui/PreferencesMenu.hx similarity index 96% rename from source/ui/PreferencesMenu.hx rename to source/funkin/ui/PreferencesMenu.hx index d77aff357..6fcf7b57a 100644 --- a/source/ui/PreferencesMenu.hx +++ b/source/funkin/ui/PreferencesMenu.hx @@ -1,14 +1,13 @@ -package ui; +package funkin.ui; import flixel.FlxCamera; import flixel.FlxObject; import flixel.FlxSprite; -import flixel.group.FlxGroup; -import flixel.util.FlxColor; -import ui.AtlasText.AtlasFont; -import ui.TextMenuList.TextMenuItem; +import funkin.ui.AtlasText.AtlasFont; +import funkin.ui.TextMenuList.TextMenuItem; +import funkin.ui.OptionsState.Page; -class PreferencesMenu extends ui.OptionsState.Page +class PreferencesMenu extends Page { public static var preferences:Map = new Map(); diff --git a/source/ui/Prompt.hx b/source/funkin/ui/Prompt.hx similarity index 97% rename from source/ui/Prompt.hx rename to source/funkin/ui/Prompt.hx index acd584e97..1679d3886 100644 --- a/source/ui/Prompt.hx +++ b/source/funkin/ui/Prompt.hx @@ -1,11 +1,11 @@ -package ui; +package funkin.ui; import flixel.FlxSprite; import flixel.graphics.frames.FlxAtlasFrames; import flixel.text.FlxText; import flixel.util.FlxColor; -import ui.AtlasText; -import ui.MenuList; +import funkin.ui.AtlasText; +import funkin.ui.MenuList; class Prompt extends flixel.FlxSubState { diff --git a/source/ui/TextMenuList.hx b/source/funkin/ui/TextMenuList.hx similarity index 94% rename from source/ui/TextMenuList.hx rename to source/funkin/ui/TextMenuList.hx index c507ae864..ae3ed7bff 100644 --- a/source/ui/TextMenuList.hx +++ b/source/funkin/ui/TextMenuList.hx @@ -1,7 +1,7 @@ -package ui; +package funkin.ui; -import ui.AtlasText; -import ui.MenuList; +import funkin.ui.AtlasText; +import funkin.ui.MenuList; class TextMenuList extends MenuTypedList { diff --git a/source/ui/animDebugShit/DebugBoundingState.hx b/source/funkin/ui/animDebugShit/DebugBoundingState.hx similarity index 99% rename from source/ui/animDebugShit/DebugBoundingState.hx rename to source/funkin/ui/animDebugShit/DebugBoundingState.hx index 5a2b1535d..9f49f5cc0 100644 --- a/source/ui/animDebugShit/DebugBoundingState.hx +++ b/source/funkin/ui/animDebugShit/DebugBoundingState.hx @@ -1,4 +1,4 @@ -package ui.animDebugShit; +package funkin.ui.animDebugShit; import flixel.FlxCamera; import flixel.FlxSprite; diff --git a/source/ui/stageBuildShit/CharStage.hx b/source/funkin/ui/stageBuildShit/CharStage.hx similarity index 80% rename from source/ui/stageBuildShit/CharStage.hx rename to source/funkin/ui/stageBuildShit/CharStage.hx index a0e1ed062..740c8de3b 100644 --- a/source/ui/stageBuildShit/CharStage.hx +++ b/source/funkin/ui/stageBuildShit/CharStage.hx @@ -1,4 +1,4 @@ -package ui.stageBuildShit; +package funkin.ui.stageBuildShit; class CharStage extends SprStage { diff --git a/source/ui/stageBuildShit/SprStage.hx b/source/funkin/ui/stageBuildShit/SprStage.hx similarity index 96% rename from source/ui/stageBuildShit/SprStage.hx rename to source/funkin/ui/stageBuildShit/SprStage.hx index 5011355f0..95eba9325 100644 --- a/source/ui/stageBuildShit/SprStage.hx +++ b/source/funkin/ui/stageBuildShit/SprStage.hx @@ -1,4 +1,4 @@ -package ui.stageBuildShit; +package funkin.ui.stageBuildShit; import flixel.FlxSprite; import flixel.input.mouse.FlxMouseEventManager; diff --git a/source/ui/stageBuildShit/StageBuilderState.hx b/source/funkin/ui/stageBuildShit/StageBuilderState.hx similarity index 99% rename from source/ui/stageBuildShit/StageBuilderState.hx rename to source/funkin/ui/stageBuildShit/StageBuilderState.hx index 1ca1f6145..5ebb6df57 100644 --- a/source/ui/stageBuildShit/StageBuilderState.hx +++ b/source/funkin/ui/stageBuildShit/StageBuilderState.hx @@ -1,4 +1,4 @@ -package ui.stageBuildShit; +package funkin.ui.stageBuildShit; import flixel.FlxCamera; import flixel.FlxSprite; diff --git a/source/ui/stageBuildShit/StagetoolBar.hx b/source/funkin/ui/stageBuildShit/StagetoolBar.hx similarity index 91% rename from source/ui/stageBuildShit/StagetoolBar.hx rename to source/funkin/ui/stageBuildShit/StagetoolBar.hx index 74337d64d..521881c9c 100644 --- a/source/ui/stageBuildShit/StagetoolBar.hx +++ b/source/funkin/ui/stageBuildShit/StagetoolBar.hx @@ -1,4 +1,4 @@ -package ui.stageBuildShit; +package funkin.ui.stageBuildShit; import flixel.group.FlxGroup; diff --git a/source/util/SortUtil.hx b/source/funkin/util/SortUtil.hx similarity index 95% rename from source/util/SortUtil.hx rename to source/funkin/util/SortUtil.hx index 9b444e42c..29f64fb0d 100644 --- a/source/util/SortUtil.hx +++ b/source/funkin/util/SortUtil.hx @@ -1,4 +1,4 @@ -package util; +package funkin.util; #if !macro import flixel.group.FlxGroup.FlxTypedGroup; diff --git a/source/util/assets/DataAssets.hx b/source/funkin/util/assets/DataAssets.hx similarity index 92% rename from source/util/assets/DataAssets.hx rename to source/funkin/util/assets/DataAssets.hx index d35cd7ab6..d00703068 100644 --- a/source/util/assets/DataAssets.hx +++ b/source/funkin/util/assets/DataAssets.hx @@ -1,30 +1,30 @@ -package util.assets; - -using StringTools; - -class DataAssets -{ - static function buildDataPath(path:String):String - { - return 'assets/data/${path}'; - } - - public static function listDataFilesInPath(path:String, ?ext:String = '.json'):Array - { - var textAssets = openfl.utils.Assets.list(); - var queryPath = buildDataPath(path); - - var results:Array = []; - for (textPath in textAssets) - { - if (textPath.startsWith(queryPath) && textPath.endsWith(ext)) - { - var pathNoSuffix = textPath.substring(0, textPath.length - ext.length); - var pathNoPrefix = pathNoSuffix.substring(queryPath.length); - results.push(pathNoPrefix); - } - } - - return results; - } -} +package funkin.util.assets; + +using StringTools; + +class DataAssets +{ + static function buildDataPath(path:String):String + { + return 'assets/data/${path}'; + } + + public static function listDataFilesInPath(path:String, ?ext:String = '.json'):Array + { + var textAssets = openfl.utils.Assets.list(); + var queryPath = buildDataPath(path); + + var results:Array = []; + for (textPath in textAssets) + { + if (textPath.startsWith(queryPath) && textPath.endsWith(ext)) + { + var pathNoSuffix = textPath.substring(0, textPath.length - ext.length); + var pathNoPrefix = pathNoSuffix.substring(queryPath.length); + results.push(pathNoPrefix); + } + } + + return results; + } +} diff --git a/source/util/macro/FlxMacro.hx b/source/funkin/util/macro/FlxMacro.hx similarity index 97% rename from source/util/macro/FlxMacro.hx rename to source/funkin/util/macro/FlxMacro.hx index f66be4a32..adbee3319 100644 --- a/source/util/macro/FlxMacro.hx +++ b/source/funkin/util/macro/FlxMacro.hx @@ -1,4 +1,4 @@ -package util.macro; +package funkin.util.macro; #if macro class FlxMacro diff --git a/source/util/macro/MacroUtil.hx b/source/funkin/util/macro/MacroUtil.hx similarity index 88% rename from source/util/macro/MacroUtil.hx rename to source/funkin/util/macro/MacroUtil.hx index 96f86223b..ebf5bd5ec 100644 --- a/source/util/macro/MacroUtil.hx +++ b/source/funkin/util/macro/MacroUtil.hx @@ -1,12 +1,12 @@ -package util.macro; - -class MacroUtil -{ - public static macro function getDefine(key:String, defaultValue:String = null):haxe.macro.Expr - { - var value = haxe.macro.Context.definedValue(key); - if (value == null) - value = defaultValue; - return macro $v{value}; - } -} +package funkin.util.macro; + +class MacroUtil +{ + public static macro function getDefine(key:String, defaultValue:String = null):haxe.macro.Expr + { + var value = haxe.macro.Context.definedValue(key); + if (value == null) + value = defaultValue; + return macro $v{value}; + } +}