-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preloading bundles and setting subtitle path (#772)
## Minor features - Can now set `preloadBundles` in the addon config file. This will load asset bundles on the main menu and keep them loaded. Will improve initial load times at the cost of more memory usage. - Can now set `subtitlePath` in the addon config file for displaying a subtitle for your mod on the main menu.
- Loading branch information
Showing
7 changed files
with
134 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 48 additions & 1 deletion
49
NewHorizons/Patches/EyeScenePatches/SubmitActionLoadScenePatches.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,69 @@ | ||
using HarmonyLib; | ||
using NewHorizons.Utility.Files; | ||
using NewHorizons.Utility.OWML; | ||
|
||
namespace NewHorizons.Patches.EyeScenePatches | ||
{ | ||
[HarmonyPatch(typeof(SubmitActionLoadScene))] | ||
public static class SubmitActionLoadScenePatches | ||
{ | ||
// To call the base method | ||
[HarmonyReversePatch] | ||
[HarmonyPatch(typeof(SubmitActionConfirm), nameof(SubmitActionConfirm.ConfirmSubmit))] | ||
public static void SubmitActionConfirm_ConfirmSubmit(SubmitActionConfirm instance) { } | ||
|
||
|
||
[HarmonyPrefix] | ||
[HarmonyPatch(nameof(SubmitActionLoadScene.ConfirmSubmit))] | ||
public static void SubmitActionLoadScene_ConfirmSubmit(SubmitActionLoadScene __instance) | ||
public static bool SubmitActionLoadScene_ConfirmSubmit(SubmitActionLoadScene __instance) | ||
{ | ||
if (__instance._receivedSubmitAction) return false; | ||
|
||
// Title screen can warp you to eye and cause problems. | ||
if (__instance._sceneToLoad == SubmitActionLoadScene.LoadableScenes.EYE) | ||
{ | ||
NHLogger.LogWarning("Warping to solar system and then back to eye"); | ||
Main.Instance.IsWarpingBackToEye = true; | ||
__instance._sceneToLoad = SubmitActionLoadScene.LoadableScenes.GAME; | ||
} | ||
|
||
// modified from patched function | ||
SubmitActionConfirm_ConfirmSubmit(__instance); | ||
__instance._receivedSubmitAction = true; | ||
Locator.GetMenuInputModule().DisableInputs(); | ||
|
||
Delay.RunWhen(() => | ||
{ | ||
// update text. just use 0% | ||
__instance.ResetStringBuilder(); | ||
__instance._nowLoadingSB.Append(UITextLibrary.GetString(UITextType.LoadingMessage)); | ||
__instance._nowLoadingSB.Append(0.ToString("P0")); | ||
__instance._loadingText.text = __instance._nowLoadingSB.ToString(); | ||
|
||
return AssetBundleUtilities.AreRequiredAssetsLoaded(); | ||
}, () => | ||
{ | ||
switch (__instance._sceneToLoad) | ||
{ | ||
case SubmitActionLoadScene.LoadableScenes.GAME: | ||
LoadManager.LoadSceneAsync(OWScene.SolarSystem, false, LoadManager.FadeType.ToBlack, 1f, false); | ||
__instance.ResetStringBuilder(); | ||
__instance._waitingOnStreaming = true; | ||
break; | ||
case SubmitActionLoadScene.LoadableScenes.EYE: | ||
LoadManager.LoadSceneAsync(OWScene.EyeOfTheUniverse, true, LoadManager.FadeType.ToBlack, 1f, false); | ||
__instance.ResetStringBuilder(); | ||
break; | ||
case SubmitActionLoadScene.LoadableScenes.TITLE: | ||
LoadManager.LoadScene(OWScene.TitleScreen, LoadManager.FadeType.ToBlack, 2f, true); | ||
break; | ||
case SubmitActionLoadScene.LoadableScenes.CREDITS: | ||
LoadManager.LoadScene(OWScene.Credits_Fast, LoadManager.FadeType.ToBlack, 1f, false); | ||
break; | ||
} | ||
}); | ||
|
||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters