From 503fbae7e7061ecb4edfb8c06c754e899d32a11d Mon Sep 17 00:00:00 2001 From: amevarashi Date: Mon, 21 Mar 2022 08:18:30 +0500 Subject: [PATCH] Hide history Gizmo when several pawns selected --- .../RJWSexperience/Patches/GetGizmos.cs | 78 ++++++++----------- 1 file changed, 34 insertions(+), 44 deletions(-) diff --git a/RJWSexperience/RJWSexperience/Patches/GetGizmos.cs b/RJWSexperience/RJWSexperience/Patches/GetGizmos.cs index e6ffa0a..0795d32 100644 --- a/RJWSexperience/RJWSexperience/Patches/GetGizmos.cs +++ b/RJWSexperience/RJWSexperience/Patches/GetGizmos.cs @@ -1,57 +1,47 @@ -using System; +using HarmonyLib; +using RJWSexperience.UI; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using RimWorld; using Verse; -using HarmonyLib; -using rjw; -using RJWSexperience.UI; namespace RJWSexperience { - [HarmonyPatch(typeof(Pawn),"GetGizmos")] - public class Pawn_GetGizmos - { - public static void Postfix(ref IEnumerable __result, Pawn __instance) - { + [HarmonyPatch(typeof(Pawn), "GetGizmos")] + public class Pawn_GetGizmos + { + public static void Postfix(ref IEnumerable __result, Pawn __instance) + { + if (Find.Selector.NumSelected > 1) + return; - List gizmoList = __result.ToList(); + List gizmoList = __result.ToList(); - AddHistoryGizmo(__instance, ref gizmoList); + AddHistoryGizmo(__instance, ref gizmoList); + __result = gizmoList; + } - __result = gizmoList; - } - - private static void AddHistoryGizmo(Pawn pawn, ref List gizmos) - { - SexPartnerHistory history = pawn.GetPartnerHistory(); - if (history != null) gizmos.Add(CreateHIstoryGizmo(pawn,history)); - } - - private static Gizmo CreateHIstoryGizmo(Pawn pawn, SexPartnerHistory history) - { - Gizmo gizmo = new Command_Action - { - defaultLabel = Keyed.RS_Sex_History, - icon = HistoryUtility.HistoryIcon, - defaultIconColor = HistoryUtility.HistoryColor, - hotKey = VariousDefOf.OpenSexStatistics, - action = delegate - { - SexStatusWindow.ToggleWindow(pawn, history); - } - - }; - - return gizmo; - } - - - } - + private static void AddHistoryGizmo(Pawn pawn, ref List gizmos) + { + SexPartnerHistory history = pawn.GetPartnerHistory(); + if (history != null) gizmos.Add(CreateHIstoryGizmo(pawn, history)); + } + private static Gizmo CreateHIstoryGizmo(Pawn pawn, SexPartnerHistory history) + { + Gizmo gizmo = new Command_Action + { + defaultLabel = Keyed.RS_Sex_History, + icon = HistoryUtility.HistoryIcon, + defaultIconColor = HistoryUtility.HistoryColor, + hotKey = VariousDefOf.OpenSexStatistics, + action = delegate + { + SexStatusWindow.ToggleWindow(pawn, history); + } + }; + return gizmo; + } + } }