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 19ddf5f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 20 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
2 changes: 1 addition & 1 deletion Source/PawnRules.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Patch\RimWorld_HealthCardUtility_DrawOverviewTab.cs" />
<Compile Include="Patch\RimWorld_PawnColumnWorker_FoodRestriction_Compare.cs" />
<Compile Include="Patch\RimWorld_PawnColumnWorker_FoodRestriction_DoAssignFoodRestrictionButtons.cs" />
<Compile Include="Patch\RimWorld_PawnColumnWorker_FoodRestriction_DoHeader.cs" />
Expand Down Expand Up @@ -94,7 +95,6 @@
<Compile Include="Patch\RimWorld_GenConstruct_CanConstruct.cs" />
<Compile Include="Patch\RimWorld_InteractionWorker_RomanceAttempt_RandomSelectionWeight.cs" />
<Compile Include="Patch\RimWorld_InteractionWorker_RomanceAttempt_SuccessChance.cs" />
<Compile Include="Patch\RimWorld_Pawn_FoodRestrictionTracker_Configurable.cs" />
<Compile Include="Patch\RimWorld_Pawn_FoodRestrictionTracker_CurrentFoodRestriction.cs" />
<Compile Include="Patch\RimWorld_Pawn_GuestTracker_SetGuestStatus.cs" />
<Compile Include="Patch\RimWorld_PawnUtility_TrySpawnHatchedOrBornPawn.cs" />
Expand Down

0 comments on commit 19ddf5f

Please sign in to comment.