change to string event

This commit is contained in:
Noah Pilarski 2025-02-15 22:54:55 -05:00
parent cfaa0dc55a
commit 325180589f
4 changed files with 27 additions and 17 deletions

View File

@ -91,15 +91,6 @@ namespace NewHorizons.Handlers
// default to displaying nh planets if no title screen builders // default to displaying nh planets if no title screen builders
else else
DisplayBodiesOnTitleScreen(); DisplayBodiesOnTitleScreen();
try
{
Main.Instance.OnTitleScreenLoaded?.Invoke();
}
catch (Exception e)
{
NHLogger.LogError($"Error in event handler for OnTitleScreenLoaded: {e}");
}
} }
public static void InitSubtitles() public static void InitSubtitles()
@ -465,6 +456,15 @@ namespace NewHorizons.Handlers
{ {
NHLogger.LogError(e); NHLogger.LogError(e);
} }
try
{
Main.Instance.OnTitleScreenLoaded?.Invoke(mod.ModHelper.Manifest.UniqueName);
}
catch (Exception e)
{
NHLogger.LogError($"Error in event handler for OnTitleScreenLoaded on title screen {mod.ModHelper.Manifest.UniqueName}: {e}");
}
} }
public IModBehaviour Mod => mod; public IModBehaviour Mod => mod;
@ -500,6 +500,15 @@ namespace NewHorizons.Handlers
{ {
NHLogger.LogError(e); NHLogger.LogError(e);
} }
try
{
Main.Instance.OnTitleScreenLoaded?.Invoke(mod.ModHelper.Manifest.UniqueName);
}
catch (Exception e)
{
NHLogger.LogError($"Error in event handler for OnTitleScreenLoaded on title screen {mod.ModHelper.Manifest.UniqueName}: {e}");
}
} }
public IModBehaviour Mod => mod; public IModBehaviour Mod => mod;

View File

@ -75,9 +75,10 @@ namespace NewHorizons
UnityEvent<string> GetBodyLoadedEvent(); UnityEvent<string> GetBodyLoadedEvent();
/// <summary> /// <summary>
/// An event invoked when NH has finished building the title screen. /// An event invoked when NH has finished building a title screen.
/// Gives the unique name of the mod the title screen builder was from.
/// </summary> /// </summary>
UnityEvent GetTitleScreenLoadedEvent(); UnityEvent<string> GetTitleScreenLoadedEvent();
#endregion #endregion
#region Querying configs #region Querying configs

View File

@ -107,11 +107,11 @@ namespace NewHorizons
public ShipWarpController ShipWarpController { get; private set; } public ShipWarpController ShipWarpController { get; private set; }
// API events // API events
public class StarSystemEvent : UnityEvent<string> { } public class StringEvent : UnityEvent<string> { }
public StarSystemEvent OnChangeStarSystem = new(); public StringEvent OnChangeStarSystem = new();
public StarSystemEvent OnStarSystemLoaded = new(); public StringEvent OnStarSystemLoaded = new();
public StarSystemEvent OnPlanetLoaded = new(); public StringEvent OnPlanetLoaded = new();
public UnityEvent OnTitleScreenLoaded = new(); public StringEvent OnTitleScreenLoaded = new();
/// <summary> /// <summary>
/// Depending on platform, the AsyncOwnershipStatus might not be ready by the time we go to check it. /// Depending on platform, the AsyncOwnershipStatus might not be ready by the time we go to check it.

View File

@ -90,7 +90,7 @@ namespace NewHorizons
public UnityEvent<string> GetChangeStarSystemEvent() => Main.Instance.OnChangeStarSystem; public UnityEvent<string> GetChangeStarSystemEvent() => Main.Instance.OnChangeStarSystem;
public UnityEvent<string> GetStarSystemLoadedEvent() => Main.Instance.OnStarSystemLoaded; public UnityEvent<string> GetStarSystemLoadedEvent() => Main.Instance.OnStarSystemLoaded;
public UnityEvent<string> GetBodyLoadedEvent() => Main.Instance.OnPlanetLoaded; public UnityEvent<string> GetBodyLoadedEvent() => Main.Instance.OnPlanetLoaded;
public UnityEvent GetTitleScreenLoadedEvent() => Main.Instance.OnTitleScreenLoaded; public UnityEvent<string> GetTitleScreenLoadedEvent() => Main.Instance.OnTitleScreenLoaded;
public bool SetDefaultSystem(string name) public bool SetDefaultSystem(string name)
{ {