diff --git a/HideTips/HideTips.cs b/HideTips/HideTips.cs index e4f7f7a..0b53b95 100644 --- a/HideTips/HideTips.cs +++ b/HideTips/HideTips.cs @@ -1,6 +1,7 @@ using System; using BepInEx; using HarmonyLib; +using UnityEngine; namespace HideTips; @@ -15,6 +16,7 @@ public class HideTips : BaseUnityPlugin private static bool _noAchievementCardPopups = false; private static bool _noMilestoneCardPopups = true; private static bool _skipPrologue = true; + private static bool _hideMenuDemo = false; private void Awake() { @@ -24,8 +26,13 @@ public class HideTips : BaseUnityPlugin _noAchievementCardPopups = Config.Bind("General", "NoAchievementCardPopups", _noAchievementCardPopups, "Disable Achievement Card Popups").Value; _noMilestoneCardPopups = Config.Bind("General", "NoMilestoneCardPopups", _noMilestoneCardPopups, "Disable Milestone Card Popups").Value; _skipPrologue = Config.Bind("General", "SkipPrologue", _skipPrologue, "Skip prologue for new game").Value; + _hideMenuDemo = Config.Bind("General", "HideMenuDemo", _hideMenuDemo, "Disable title screen demo scene loading").Value; if (!_cfgEnabled) return; Harmony.CreateAndPatchAll(typeof(HideTips)); + if (_hideMenuDemo) + { + Harmony.CreateAndPatchAll(typeof(HideMenuDemo)); + } } [HarmonyPostfix] @@ -75,10 +82,80 @@ public class HideTips : BaseUnityPlugin [HarmonyPrefix] [HarmonyPatch(typeof(DSPGame), "StartGame", typeof(GameDesc))] - private static bool OnStartGame(GameDesc _gameDesc) + private static bool DSPGame_OnStartGame_Prefix(GameDesc _gameDesc) { if (!_skipPrologue) return true; DSPGame.StartGameSkipPrologue(_gameDesc); return false; } } + +[HarmonyPatch] +class HideMenuDemo +{ + [HarmonyPrefix] + [HarmonyPatch(typeof(DSPGame), "StartDemoGame", typeof(int))] + private static bool DSPGame_OnStartDemoGame_Prefix() + { + if (DSPGame.Game != null) + { + DSPGame.EndGame(); + } + + DSPGame.IsMenuDemo = true; + DSPGame.CreateGameMainObject(); + DSPGame.Game.isMenuDemo = true; + DSPGame.Game.CreateIconSet(); + GameMain.data = new GameData(); + GameMain.data.mainPlayer = Player.Create(GameMain.data, 1); + GameMain.data.galaxy = new GalaxyData + { + starCount = 0 + }; + + if (GameMain.universeSimulator != null) + { + UnityEngine.Object.Destroy(GameMain.universeSimulator.gameObject); + } + GameMain.universeSimulator = UnityEngine.Object.Instantiate(Configs.builtin.universeSimulatorPrefab); + GameMain.universeSimulator.spaceAudio = new GameObject("Space Audio") + { + transform = + { + parent = GameMain.universeSimulator.transform + } + }.AddComponent(); + GameMain.Begin(); + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(VFPreload), "IsMenuDemoLoaded")] + private static bool VFPreload_IsMenuDemoLoaded_Prefix(ref bool __result) + { + __result = true; + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(DSPGame), "LateUpdate")] + [HarmonyPatch(typeof(GameMain), "LateUpdate")] + [HarmonyPatch(typeof(GameMain), "FixedUpdate")] + [HarmonyPatch(typeof(GameMain), "Update")] + [HarmonyPatch(typeof(GameCamera), "LateUpdate")] + private static bool DSPGame_LateUpdate_Prefix() + { + return !DSPGame.IsMenuDemo; + } + + [HarmonyPrefix] + [HarmonyPriority(Priority.Last)] + [HarmonyPatch(typeof(GameMain), "Begin")] + private static bool GameMain_Begin_Prefix() + { + if (!DSPGame.IsMenuDemo) return true; + DSPGame.Game._loading = false; + DSPGame.Game._running = true; + return false; + } +} \ No newline at end of file diff --git a/HideTips/HideTips.csproj b/HideTips/HideTips.csproj index fac2036..769e99c 100644 --- a/HideTips/HideTips.csproj +++ b/HideTips/HideTips.csproj @@ -5,7 +5,7 @@ HideTips org.soardev.hidetips DSP MOD - HideTips - 1.0.1 + 1.0.2 true latest diff --git a/HideTips/README.md b/HideTips/README.md index 856cb2a..df90c4e 100644 --- a/HideTips/README.md +++ b/HideTips/README.md @@ -5,17 +5,22 @@ ## Updates +* 1.0.2 + * Add option to disable title screen demo scene loading + * 1.0.1 - * Hide 3 more random tutorial tips popup from bottom-right panel + * Hide 3 more random tutorial tips popup from bottom-right panel ## Usage * Tips/messages that can be hidden: random-reminder, tutorial, achievement/milestone card. * Skip prologue for new game. +* Disable title screen demo scene loading. * Each type of tips/messages is configurable individually. ## 使用说明 * 可以屏蔽的消息:随机提醒,教程,成就/里程碑卡片。 * 跳过新游戏引导动画。 +* 关闭标题画面的演示场景加载。 * 各种屏蔽功能都可以在配置文件里开关。 diff --git a/HideTips/package/manifest.json b/HideTips/package/manifest.json index bf5a58b..9f2c1cf 100644 --- a/HideTips/package/manifest.json +++ b/HideTips/package/manifest.json @@ -1,6 +1,6 @@ { "name": "HideTips", - "version_number": "1.0.1", + "version_number": "1.0.2", "website_url": "https://github.com/soarqin/DSP_Mods/tree/master/HideTips", "description": "Hide/Disable various tutorial tips/messages / 隐藏/屏蔽各种引导提示/消息", "dependencies": [