diff --git a/Plugin.cs b/Plugin.cs index bdf15a5..6be47c1 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -13,20 +13,22 @@ namespace SSSoftcoded { - [BepInPlugin("mod.clevercrumbish.SSSoftcoded", "Sunless Sea Softcoded", "1.0.0")] + [BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)] public class Plugin : BaseUnityPlugin { - private void Start() - { - SSSLoadingHelper.Initialise(); - SSSLoadingHelper.DocumentAllCustomContent(); - } private void Awake() { Logger.LogInfo($"Loaded {PluginInfo.PLUGIN_GUID} {PluginInfo.PLUGIN_VERSION}!"); DoPatching(); } + private void Start() + { + SSSLoadingHelper.Initialise(); + SSSLoadingHelper.DocumentAllCustomContent(); + CustomLoadingScreenTips(); + } + private void DoPatching() { Harmony.CreateAndPatchAll(typeof(SetupBackgroundPatch)); @@ -36,8 +38,30 @@ private void DoPatching() Harmony.CreateAndPatchAll(typeof(PlayRegularSFXPatch)); Harmony.CreateAndPatchAll(typeof(StopRegularSFXPatch)); } + + private static void CustomLoadingScreenTips() + { + string[] oldTips = StaticEntities.LoadingScreenTips; + string[] customTips = SSSLoadingHelper.GetCustomLoadingScreenTips(); + + List newTips = customTips.ToList(); + + if (!SSSLoadingHelper.ignoreVanillaLoadingScreenTips) + { + // Add old tips to the loading tips list + newTips.AddRange(oldTips); + } + else if (customTips.Length == 0) // if the user ignores vanilla tips, but doesn't provide their own + { + // Add a fallback tip to prevent a crash, and to inform the user of the fact they've disabled vanilla tips without providing new ones + newTips.Add("Ignore Vanilla Loading Screen Tips is enabled, but no custom tips have been provided."); + } + + StaticEntities.LoadingScreenTips = newTips.ToArray(); + } } + [HarmonyPatch(typeof(LoadingScreen), "SetupBackground")] class SetupBackgroundPatch { @@ -50,7 +74,8 @@ static bool Prefix(LoadingScreen __instance) if (chosenWallpaper.GetExtension() != "") { texture2D = SSSLoadingHelper.LoadWallpaperTexture(chosenWallpaper); - } else + } + else { texture2D = UnityEngine.Resources.Load("UI/Loading/Backgrounds/" + chosenWallpaper.GetName()) as Texture2D; } diff --git a/SSSLoadingHelper.cs b/SSSLoadingHelper.cs index eefa6a3..c0fc04a 100644 --- a/SSSLoadingHelper.cs +++ b/SSSLoadingHelper.cs @@ -18,12 +18,15 @@ public static class SSSLoadingHelper private static string regularSFXFilePath = GameProvider.Instance.GetApplicationPath("audio/sfx/"); private static bool ignoreVanillaWallpapers = false; + public static bool ignoreVanillaLoadingScreenTips = false; private static SSSLoadableResource[] customWallpapers; private static SSSLoadableResource[] customMusicTracks; private static SSSLoadableResource[] customAmbientSFX; private static SSSLoadableResource[] customRegularSFX; + private static string[] customLoadingScreenTips; + private static List loadedAmbientSFX = new List(); private static List loadedRegularSFX = new List(); @@ -36,15 +39,11 @@ public static void Initialise() foreach (var s in lines) { - s.Trim(); + string line = s.Replace(" ", ""); - if (s.StartsWith("#") || s.StartsWith("[")) - { - continue; - } - else if (s.Contains("=")) + if (line.Contains("=")) { - string[] split = s.Split('='); + string[] split = line.Split('='); optionsDict.Add(split[0], split[1]); } } @@ -69,6 +68,10 @@ public static void Initialise() { ignoreVanillaWallpapers = true; } + if (optionsDict["ignoreVanillaLoadingScreenTips"] == "true") + { + ignoreVanillaLoadingScreenTips = true; + } } else { System.Console.WriteLine("Couldn't find SSSConfig.ini in the Sunless Sea root folder. Only default settings will be available"); @@ -253,6 +256,11 @@ public static SSSLoadableResource[] GetCustomWallPapers() return customWallpapers; } + public static string[] GetCustomLoadingScreenTips() + { + return customLoadingScreenTips; + } + public static SSSLoadableResource[] GetCustomMusicTracks() { return customMusicTracks; diff --git a/SSSoftcoded.csproj b/SSSoftcoded.csproj index 37539d0..5634dcf 100644 --- a/SSSoftcoded.csproj +++ b/SSSoftcoded.csproj @@ -3,7 +3,6 @@ net35 SSSoftcoded - My first plugin 1.0.0 true latest