diff --git a/HideTips/HideTips.cs b/HideTips/HideTips.cs index 1e2349a..4e4c8a9 100644 --- a/HideTips/HideTips.cs +++ b/HideTips/HideTips.cs @@ -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 UIGeneralTips_OnTechUnlocked_Transpiler(IEnumerable 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