mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-02-05 00:22:21 +08:00
HideTips v1.0.3
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using BepInEx;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
@@ -13,10 +15,12 @@ public class HideTips : BaseUnityPlugin
|
||||
private bool _cfgEnabled = true;
|
||||
private static bool _noRandomReminderTips = true;
|
||||
private static bool _noTutorialTips = true;
|
||||
private static bool _noAchievementCardPopups = false;
|
||||
private static bool _noAchievementCardPopups;
|
||||
private static bool _noMilestoneCardPopups = true;
|
||||
private static bool _noResearchCompletionPopups = true;
|
||||
private static bool _noResearchCompletionTips;
|
||||
private static bool _skipPrologue = true;
|
||||
private static bool _hideMenuDemo = false;
|
||||
private static bool _hideMenuDemo;
|
||||
|
||||
private static Harmony _patch;
|
||||
|
||||
@@ -27,6 +31,8 @@ public class HideTips : BaseUnityPlugin
|
||||
_noTutorialTips = Config.Bind("General", "NoTutorialTips", _noTutorialTips, "Disable Tutorial Tips").Value;
|
||||
_noAchievementCardPopups = Config.Bind("General", "NoAchievementCardPopups", _noAchievementCardPopups, "Disable Achievement 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;
|
||||
_hideMenuDemo = Config.Bind("General", "HideMenuDemo", _hideMenuDemo, "Disable title screen demo scene loading").Value;
|
||||
if (!_cfgEnabled) return;
|
||||
@@ -60,7 +66,7 @@ public class HideTips : BaseUnityPlugin
|
||||
|
||||
[HarmonyPostfix]
|
||||
[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.randTipButton1.pop = __instance.randTipButton1.popCount;
|
||||
@@ -69,28 +75,58 @@ public class HideTips : BaseUnityPlugin
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(UITutorialTip), "PopupTutorialTip")]
|
||||
private static bool SkipTutorialTips()
|
||||
private static bool UITutorialTip_PopupTutorialTip_Prefix()
|
||||
{
|
||||
return !_noTutorialTips;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(UIVariousPopupGroup), "CreateAchievementPopupCard")]
|
||||
private static bool SkipAchievementCardPopups()
|
||||
private static bool UIVariousPopupGroup_CreateAchievementPopupCard_Prefix()
|
||||
{
|
||||
return !_noAchievementCardPopups;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(UIVariousPopupGroup), "CreateMilestonePopupCard")]
|
||||
private static bool SkipMilestoneCardPopups()
|
||||
private static bool UIVariousPopupGroup_CreateMilestonePopupCard_Prefix()
|
||||
{
|
||||
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]
|
||||
[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;
|
||||
DSPGame.StartGameSkipPrologue(_gameDesc);
|
||||
@@ -103,7 +139,7 @@ class HideMenuDemo
|
||||
{
|
||||
[HarmonyPriority(Priority.First), HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(DSPGame), "StartDemoGame", typeof(int))]
|
||||
private static bool DSPGame_OnStartDemoGame_Prefix()
|
||||
private static bool DSPGame_StartDemoGame_Prefix()
|
||||
{
|
||||
if (DSPGame.Game != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user