1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-09 04:13:32 +08:00

HideTips v1.0.3

This commit is contained in:
2023-10-29 17:22:33 +08:00
parent ae41836659
commit 81256a1b79
4 changed files with 58 additions and 16 deletions

View File

@@ -1,4 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.Reflection.Emit;
using BepInEx; using BepInEx;
using HarmonyLib; using HarmonyLib;
using UnityEngine; using UnityEngine;
@@ -13,10 +15,12 @@ public class HideTips : BaseUnityPlugin
private bool _cfgEnabled = true; private bool _cfgEnabled = true;
private static bool _noRandomReminderTips = true; private static bool _noRandomReminderTips = true;
private static bool _noTutorialTips = true; private static bool _noTutorialTips = true;
private static bool _noAchievementCardPopups = false; private static bool _noAchievementCardPopups;
private static bool _noMilestoneCardPopups = true; private static bool _noMilestoneCardPopups = true;
private static bool _noResearchCompletionPopups = true;
private static bool _noResearchCompletionTips;
private static bool _skipPrologue = true; private static bool _skipPrologue = true;
private static bool _hideMenuDemo = false; private static bool _hideMenuDemo;
private static Harmony _patch; private static Harmony _patch;
@@ -27,6 +31,8 @@ public class HideTips : BaseUnityPlugin
_noTutorialTips = Config.Bind("General", "NoTutorialTips", _noTutorialTips, "Disable Tutorial Tips").Value; _noTutorialTips = Config.Bind("General", "NoTutorialTips", _noTutorialTips, "Disable Tutorial Tips").Value;
_noAchievementCardPopups = Config.Bind("General", "NoAchievementCardPopups", _noAchievementCardPopups, "Disable Achievement Card Popups").Value; _noAchievementCardPopups = Config.Bind("General", "NoAchievementCardPopups", _noAchievementCardPopups, "Disable Achievement Card Popups").Value;
_noMilestoneCardPopups = Config.Bind("General", "NoMilestoneCardPopups", _noMilestoneCardPopups, "Disable Milestone Card Popups").Value; _noMilestoneCardPopups = Config.Bind("General", "NoMilestoneCardPopups", _noMilestoneCardPopups, "Disable Milestone Card Popups").Value;
_noResearchCompletionPopups = Config.Bind("General", "NoResearchCompletionPopups", _noResearchCompletionPopups, "Disable Research Completion Popup Windows").Value;
_noResearchCompletionTips = Config.Bind("General", "NoResearchCompletionTips", _noResearchCompletionTips, "Disable Research Completion Tips").Value;
_skipPrologue = Config.Bind("General", "SkipPrologue", _skipPrologue, "Skip prologue for new game").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; _hideMenuDemo = Config.Bind("General", "HideMenuDemo", _hideMenuDemo, "Disable title screen demo scene loading").Value;
if (!_cfgEnabled) return; if (!_cfgEnabled) return;
@@ -60,7 +66,7 @@ public class HideTips : BaseUnityPlugin
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(UIGameMenu), "_OnCreate")] [HarmonyPatch(typeof(UIGameMenu), "_OnCreate")]
private static void ClearGameMenuRandTips(UIGameMenu __instance) private static void UIGameMenu__OnCreate_Postfix(UIGameMenu __instance)
{ {
__instance.randTipButton0.pop = __instance.randTipButton0.popCount; __instance.randTipButton0.pop = __instance.randTipButton0.popCount;
__instance.randTipButton1.pop = __instance.randTipButton1.popCount; __instance.randTipButton1.pop = __instance.randTipButton1.popCount;
@@ -69,28 +75,58 @@ public class HideTips : BaseUnityPlugin
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(UITutorialTip), "PopupTutorialTip")] [HarmonyPatch(typeof(UITutorialTip), "PopupTutorialTip")]
private static bool SkipTutorialTips() private static bool UITutorialTip_PopupTutorialTip_Prefix()
{ {
return !_noTutorialTips; return !_noTutorialTips;
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(UIVariousPopupGroup), "CreateAchievementPopupCard")] [HarmonyPatch(typeof(UIVariousPopupGroup), "CreateAchievementPopupCard")]
private static bool SkipAchievementCardPopups() private static bool UIVariousPopupGroup_CreateAchievementPopupCard_Prefix()
{ {
return !_noAchievementCardPopups; return !_noAchievementCardPopups;
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(UIVariousPopupGroup), "CreateMilestonePopupCard")] [HarmonyPatch(typeof(UIVariousPopupGroup), "CreateMilestonePopupCard")]
private static bool SkipMilestoneCardPopups() private static bool UIVariousPopupGroup_CreateMilestonePopupCard_Prefix()
{ {
return !_noMilestoneCardPopups; return !_noMilestoneCardPopups;
} }
[HarmonyPrefix]
[HarmonyPatch(typeof(UIResearchResultWindow), "SetTechId")]
private static bool UIResearchResultWindow_SetTechId_Prefix()
{
return !_noResearchCompletionPopups;
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(UIGeneralTips), "OnTechUnlocked")]
private static IEnumerable<CodeInstruction> UIGeneralTips_OnTechUnlocked_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
var matcher = new CodeMatcher(instructions, generator);
matcher.MatchForward(false,
new CodeMatch(OpCodes.Ldarg_0),
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(UIGeneralTips), "researchCompleteTip")),
new CodeMatch(OpCodes.Callvirt)
);
var labels = matcher.Labels;
var label1 = generator.DefineLabel();
matcher.Labels = new List<Label>();
matcher.InsertAndAdvance(
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(HideTips), nameof(_noResearchCompletionTips))).WithLabels(labels),
new CodeInstruction(OpCodes.Brtrue, label1)
).MatchForward(false,
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(Animation), nameof(Animation.Play))),
new CodeMatch(OpCodes.Pop)
).Advance(2).Labels.Add(label1);
return matcher.InstructionEnumeration();
}
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(DSPGame), "StartGame", typeof(GameDesc))] [HarmonyPatch(typeof(DSPGame), "StartGame", typeof(GameDesc))]
private static bool DSPGame_OnStartGame_Prefix(GameDesc _gameDesc) private static bool DSPGame_StartGame_Prefix(GameDesc _gameDesc)
{ {
if (!_skipPrologue) return true; if (!_skipPrologue) return true;
DSPGame.StartGameSkipPrologue(_gameDesc); DSPGame.StartGameSkipPrologue(_gameDesc);
@@ -103,7 +139,7 @@ class HideMenuDemo
{ {
[HarmonyPriority(Priority.First), HarmonyPrefix] [HarmonyPriority(Priority.First), HarmonyPrefix]
[HarmonyPatch(typeof(DSPGame), "StartDemoGame", typeof(int))] [HarmonyPatch(typeof(DSPGame), "StartDemoGame", typeof(int))]
private static bool DSPGame_OnStartDemoGame_Prefix() private static bool DSPGame_StartDemoGame_Prefix()
{ {
if (DSPGame.Game != null) if (DSPGame.Game != null)
{ {

View File

@@ -6,7 +6,7 @@
<AssemblyName>HideTips</AssemblyName> <AssemblyName>HideTips</AssemblyName>
<BepInExPluginGuid>org.soardev.hidetips</BepInExPluginGuid> <BepInExPluginGuid>org.soardev.hidetips</BepInExPluginGuid>
<Description>DSP MOD - HideTips</Description> <Description>DSP MOD - HideTips</Description>
<Version>1.0.2</Version> <Version>1.0.3</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
</PropertyGroup> </PropertyGroup>

View File

@@ -4,29 +4,35 @@
#### 隐藏/屏蔽各种引导提示/消息 #### 隐藏/屏蔽各种引导提示/消息
## Changelog ## Changelog
* 1.0.3
+ Add config entries to disable research completion tips/popup windows
+ Add a note to README for mod compatibility on `Disable title screen demo scene loading`.
* 1.0.2 * 1.0.2
+ Add option to disable title screen demo scene loading + Add a config entry to disable title screen demo scene loading
* 1.0.1 * 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
* 1.0.0 * 1.0.0
+ Initial release + Initial release
## Usage ## Usage
* Tips/messages that can be hidden: random-reminder, tutorial, achievement/milestone card. * Tips/messages that can be hidden: random-reminder, tutorial, achievement/milestone card, research completion tips/popup windows.
* Skip prologue for new game. * Skip prologue for new game.
* Disable title screen demo scene loading. * Disable title screen demo scene loading. Be note that this may conflict with some mods, disable this if you get any error popup on title screen.
* Each type of tips/messages is configurable individually. * Each type of tips/messages is configurable individually.
## 更新日志 ## 更新日志
* 1.0.3
+ 增加设置项以关闭研究完成的提示/弹窗
+ 在README中增加了一个关于`关闭标题画面的演示场景加载`设置的兼容性说明
* 1.0.2 * 1.0.2
+ 增加项以关闭标题画面的演示场景加载 + 增加设置项以关闭标题画面的演示场景加载
* 1.0.1 * 1.0.1
+ 可屏蔽右下面板的3种随机提醒 + 可屏蔽右下面板的3种随机提醒
* 1.0.0 * 1.0.0
+ 初始版本 + 初始版本
## 使用说明 ## 使用说明
* 可以屏蔽的消息:随机提醒,教程,成就/里程碑卡片。 * 可以屏蔽的消息:随机提醒,教程,成就/里程碑卡片,研究完成的提示/弹窗
* 跳过新游戏引导动画。 * 跳过新游戏引导动画。
* 关闭标题画面的演示场景加载。 * 关闭标题画面的演示场景加载。注意这可能会和其他mod冲突如果在标题画面出现错误弹窗请关闭这个设置。
* 各种屏蔽功能都可以在配置文件里开关。 * 各种屏蔽功能都可以在配置文件里开关。

View File

@@ -1,6 +1,6 @@
{ {
"name": "HideTips", "name": "HideTips",
"version_number": "1.0.2", "version_number": "1.0.3",
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/HideTips", "website_url": "https://github.com/soarqin/DSP_Mods/tree/master/HideTips",
"description": "Hide/Disable various tutorial tips/messages / 隐藏/屏蔽各种引导提示/消息", "description": "Hide/Disable various tutorial tips/messages / 隐藏/屏蔽各种引导提示/消息",
"dependencies": [ "dependencies": [