Skip to content

Commit

Permalink
Add Rules button to Health Overview, closes Jaxe-Dev#5
Browse files Browse the repository at this point in the history
  • Loading branch information
meiskam committed Feb 12, 2021
1 parent 5de5ba6 commit 992978c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
31 changes: 31 additions & 0 deletions Source/Patch/RimWorld_HealthCardUtility_DrawOverviewTab.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using HarmonyLib;
using PawnRules.Data;
using PawnRules.Interface;
using RimWorld;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Verse;

namespace PawnRules.Patch
{
[HarmonyPatch(typeof(HealthCardUtility), "DrawOverviewTab")]
internal static class RimWorld_HealthCardUtility_DrawOverviewTab
{
private static void Postfix(ref float __result, UnityEngine.Rect leftRect, Pawn pawn, float curY)
{
if (!Registry.IsActive) { return; }

FloatMenu overviewWindowStack = Find.WindowStack.FloatMenu;

if (overviewWindowStack == null) { return; }

List<FloatMenuOption> overviewWindowStackOptions = (List<FloatMenuOption>) typeof(FloatMenu).GetField("options", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(overviewWindowStack);
if (overviewWindowStackOptions?.Count > 0 && overviewWindowStackOptions.Last().Label.Equals("ManageFoodRestrictions".Translate()))
{
overviewWindowStack.Close(false);
Dialog_Rules.Open(pawn);
}
}
}
}
18 changes: 0 additions & 18 deletions Source/Patch/RimWorld_Pawn_FoodRestrictionTracker_Configurable.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ private static bool Prefix(ref FoodRestriction __result)
{
if (!Registry.IsActive) { return true; }

__result = new FoodRestriction(-1, Lang.Get("FoodRestrictionsOverridden"));
__result = new FoodRestriction(-1, Lang.Get("Gizmo.EditRulesLabel"));
return false;
}
}
Expand Down

0 comments on commit 992978c

Please sign in to comment.