From d251d71daa25d25de4a895f2dbc0ddf1a104a56a Mon Sep 17 00:00:00 2001
From: EliteMasterEric <ericmyllyoja@gmail.com>
Date: Mon, 17 Jul 2023 21:54:58 -0400
Subject: [PATCH] Asset redirect

---
 Project.xml                             |  8 ++++++++
 hmm.json                                |  8 ++++----
 source/funkin/modding/PolymodHandler.hx | 22 ++++++++++++++--------
 3 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/Project.xml b/Project.xml
index 4ffb0355c..f34c9bc06 100644
--- a/Project.xml
+++ b/Project.xml
@@ -181,6 +181,14 @@
 		<!-- pretends that the saved session Id was expired, forcing the reconnect prompt -->
 		<!-- <haxedef name="NG_FORCE_EXPIRED_SESSION" if="debug" /> -->
 	</section>
+	<section if="debug">
+		<!--
+			Use the parent assets folder rather than the exported one
+			No more will we accidentally undo our changes!
+			TODO: Add a thing to disable this on builds meant for itch.io.
+		-->
+		<haxedef name="REDIRECT_ASSETS_FOLDER" />
+	</section>
 	<!-- <prebuild haxe="trace('prebuilding');"/> -->
 	<!-- <postbuild haxe="art/Postbuild.hx"/> -->
 	<!-- <config:ios allow-provisioning-updates="true" team-id="" /> -->
diff --git a/hmm.json b/hmm.json
index a1e3817e0..9edf20d30 100644
--- a/hmm.json
+++ b/hmm.json
@@ -95,8 +95,8 @@
       "name": "lime",
       "type": "git",
       "dir": null,
-      "ref": "5634ad7",
-      "url": "https://github.com/openfl/lime"
+      "ref": "acb0334",
+      "url": "https://github.com/EliteMasterEric/lime"
     },
     {
       "name": "openfl",
@@ -109,7 +109,7 @@
       "name": "polymod",
       "type": "git",
       "dir": null,
-      "ref": "6594dd8",
+      "ref": "491fd0e",
       "url": "https://github.com/larsiusprime/polymod"
     },
     {
@@ -123,4 +123,4 @@
       "version": null
     }
   ]
-}
\ No newline at end of file
+}
diff --git a/source/funkin/modding/PolymodHandler.hx b/source/funkin/modding/PolymodHandler.hx
index d90c1386d..cdc67c74c 100644
--- a/source/funkin/modding/PolymodHandler.hx
+++ b/source/funkin/modding/PolymodHandler.hx
@@ -10,12 +10,15 @@ import polymod.backends.PolymodAssets.PolymodAssetType;
 import polymod.format.ParseRules.TextFileFormat;
 import funkin.play.event.SongEventData.SongEventParser;
 import funkin.util.FileUtil;
+import funkin.play.cutscene.dialogue.ConversationDataParser;
+import funkin.play.cutscene.dialogue.DialogueBoxDataParser;
+import funkin.play.cutscene.dialogue.SpeakerDataParser;
 
 class PolymodHandler
 {
   /**
    * The API version that mods should comply with.
-      * Format this with Semantic Versioning; <MAJOR>.<MINOR>.<PATCH>.
+   * Format this with Semantic Versioning; <MAJOR>.<MINOR>.<PATCH>.
    * Bug fixes increment the patch version, new features increment the minor version.
    * Changes that break old mods increment the major version.
    */
@@ -24,7 +27,9 @@ class PolymodHandler
   /**
    * Where relative to the executable that mods are located.
    */
-  static final MOD_FOLDER = "mods";
+  static final MOD_FOLDER:String = #if REDIRECT_ASSETS_FOLDER "../../../../example_mods" #else "mods" #end;
+
+  static final CORE_FOLDER:Null<String> = #if REDIRECT_ASSETS_FOLDER "../../../../assets" #else null #end;
 
   public static function createModRoot()
   {
@@ -197,9 +202,10 @@ class PolymodHandler
   {
     return {
       assetLibraryPaths: [
-        "songs" => "songs",     "shared" => "", "tutorial" => "tutorial", "scripts" => "scripts", "week1" => "week1",      "week2" => "week2",
-        "week3" => "week3", "week4" => "week4",       "week5" => "week5",     "week6" => "week6", "week7" => "week7", "weekend1" => "weekend1",
-      ]
+        "default" => "preload", "shared" => "", "songs" => "songs", "tutorial" => "tutorial", "week1" => "week1", "week2" => "week2", "week3" => "week3",
+        "week4" => "week4", "week5" => "week5", "week6" => "week6", "week7" => "week7", "weekend1" => "weekend1",
+      ],
+      coreAssetRedirect: CORE_FOLDER,
     }
   }
 
@@ -282,9 +288,9 @@ class PolymodHandler
     funkin.data.level.LevelRegistry.instance.loadEntries();
     SongEventParser.loadEventCache();
     // TODO: Uncomment this once conversation data is implemented.
-    // ConversationDataParser.loadConversationCache();
-    // DialogueBoxDataParser.loadDialogueBoxCache();
-    // SpeakerDataParser.loadSpeakerCache();
+    ConversationDataParser.loadConversationCache();
+    DialogueBoxDataParser.loadDialogueBoxCache();
+    SpeakerDataParser.loadSpeakerCache();
     SongDataParser.loadSongCache();
     StageDataParser.loadStageCache();
     CharacterDataParser.loadCharacterCache();