Add setting to enable/disable custom title screen

This commit is contained in:
Nick 2022-05-04 23:17:18 -04:00
parent bdb6fb40ab
commit 68316f7cfe
2 changed files with 22 additions and 4 deletions

View File

@ -36,7 +36,10 @@ namespace NewHorizons
public static AssetBundle ShaderBundle; public static AssetBundle ShaderBundle;
public static Main Instance { get; private set; } public static Main Instance { get; private set; }
// Settings
public static bool Debug; public static bool Debug;
private static bool _useCustomTitleScreen;
private static bool _wasConfigured = false;
public static Dictionary<string, NewHorizonsSystem> SystemDict = new Dictionary<string, NewHorizonsSystem>(); public static Dictionary<string, NewHorizonsSystem> SystemDict = new Dictionary<string, NewHorizonsSystem>();
public static Dictionary<string, List<NewHorizonsBody>> BodyDict = new Dictionary<string, List<NewHorizonsBody>>(); public static Dictionary<string, List<NewHorizonsBody>> BodyDict = new Dictionary<string, List<NewHorizonsBody>>();
@ -63,7 +66,7 @@ namespace NewHorizons
public StarSystemEvent OnChangeStarSystem; public StarSystemEvent OnChangeStarSystem;
public StarSystemEvent OnStarSystemLoaded; public StarSystemEvent OnStarSystemLoaded;
// For warping to the eye system
private GameObject _ship; private GameObject _ship;
public override object GetApi() public override object GetApi()
@ -73,9 +76,23 @@ namespace NewHorizons
public override void Configure(IModConfig config) public override void Configure(IModConfig config)
{ {
Logger.Log("Settings changed");
Debug = config.GetSettingsValue<bool>("Debug"); Debug = config.GetSettingsValue<bool>("Debug");
DebugReload.UpdateReloadButton(); DebugReload.UpdateReloadButton();
Logger.UpdateLogLevel(Debug? Logger.LogType.Log : Logger.LogType.Error); Logger.UpdateLogLevel(Debug ? Logger.LogType.Log : Logger.LogType.Error);
var wasUsingCustomTitleScreen = _useCustomTitleScreen;
_useCustomTitleScreen = config.GetSettingsValue<bool>("Custom title screen");
// Reload the title screen if this was updated on it
// Don't reload if we haven't configured yet (called on game start)
if (wasUsingCustomTitleScreen != _useCustomTitleScreen && SceneManager.GetActiveScene().name == "TitleScreen" && _wasConfigured)
{
Logger.Log("Reloading");
SceneManager.LoadScene("TitleScreen", LoadSceneMode.Single);
}
_wasConfigured = true;
} }
public void Start() public void Start()
@ -144,7 +161,7 @@ namespace NewHorizons
_isChangingStarSystem = false; _isChangingStarSystem = false;
if (scene.name == "TitleScreen") if (scene.name == "TitleScreen" && _useCustomTitleScreen)
{ {
TitleSceneHandler.DisplayBodyOnTitleScreen(BodyDict.Values.ToList().SelectMany(x => x).ToList()); TitleSceneHandler.DisplayBodyOnTitleScreen(BodyDict.Values.ToList().SelectMany(x => x).ToList());
} }

View File

@ -1,6 +1,7 @@
{ {
"enabled": true, "enabled": true,
"settings": { "settings": {
"Debug": false "Debug": false,
"Custom title screen": true
} }
} }