Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 32 additions & 7 deletions Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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<string> 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
{
Expand All @@ -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;
}
Expand Down
22 changes: 15 additions & 7 deletions SSSLoadingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<AudioClip> loadedAmbientSFX = new List<AudioClip>();
private static List<AudioClip> loadedRegularSFX = new List<AudioClip>();

Expand All @@ -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]);
}
}
Expand All @@ -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");
Expand Down Expand Up @@ -253,6 +256,11 @@ public static SSSLoadableResource[] GetCustomWallPapers()
return customWallpapers;
}

public static string[] GetCustomLoadingScreenTips()
{
return customLoadingScreenTips;
}

public static SSSLoadableResource[] GetCustomMusicTracks()
{
return customMusicTracks;
Expand Down
1 change: 0 additions & 1 deletion SSSoftcoded.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<PropertyGroup>
<TargetFramework>net35</TargetFramework>
<AssemblyName>SSSoftcoded</AssemblyName>
<Description>My first plugin</Description>
<Version>1.0.0</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
Expand Down