diff --git a/.gitignore b/.gitignore index cf29055..8b85bbf 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,6 @@ Source/BetterAnimalsTab/obj/Debug/BetterAnimalsTab.pdb /Source/ModConfig.json /.mailmap /Source/SteamConfig.vdf + +# VS Code +.mono/* \ No newline at end of file diff --git a/Assemblies/MedicalTab.dll b/Assemblies/MedicalTab.dll index 919aabd..53420f4 100644 Binary files a/Assemblies/MedicalTab.dll and b/Assemblies/MedicalTab.dll differ diff --git a/Assemblies/MedicalTab.pdb b/Assemblies/MedicalTab.pdb index e1813ca..9ccef4d 100644 Binary files a/Assemblies/MedicalTab.pdb and b/Assemblies/MedicalTab.pdb differ diff --git a/Source/CapacityUtility.cs b/Source/CapacityUtility.cs index 3a47ac5..126e04e 100644 --- a/Source/CapacityUtility.cs +++ b/Source/CapacityUtility.cs @@ -10,17 +10,20 @@ using UnityEngine; using Verse; -namespace Fluffy { +namespace Fluffy +{ // todo; consolidation and clean up of various helpers. // todo; lobby for xml implementation of capacity tags on bodyparts so we can get rid of the dictionary. [StaticConstructorOnStartup] - public static class CapacityUtility { + public static class CapacityUtility + { public static Dictionary> CapacityTags = new Dictionary>(); private static MethodInfo _generateSurgeryOptionMethodInfo; - static CapacityUtility() { + static CapacityUtility() + { HashSet filtrationTags = new HashSet { BodyPartTagDefOf.BloodFiltrationKidney, BodyPartTagDefOf.BloodFiltrationLiver, @@ -45,12 +48,6 @@ static CapacityUtility() { }; CapacityTags.Add(PawnCapacityDefOf.Consciousness, consciousnessTags); - HashSet eatingTags = new HashSet { - BodyPartTagDefOf.EatingPathway, - BodyPartTagDefOf.EatingSource - }; - CapacityTags.Add(PawnCapacityDefOf.Eating, eatingTags); - HashSet hearingTags = new HashSet { BodyPartTagDefOf.HearingSource }; @@ -63,11 +60,6 @@ static CapacityUtility() { }; CapacityTags.Add(PawnCapacityDefOf.Manipulation, manipulationTags); - HashSet metabolismTags = new HashSet { - BodyPartTagDefOf.MetabolismSource - }; - CapacityTags.Add(PawnCapacityDefOf.Metabolism, metabolismTags); - HashSet movingTags = new HashSet { BodyPartTagDefOf.MovingLimbCore, BodyPartTagDefOf.MovingLimbDigit, @@ -84,26 +76,56 @@ static CapacityUtility() { HashSet talkingTags = new HashSet { BodyPartTagDefOf.TalkingPathway, - BodyPartTagDefOf.TalkingSource + BodyPartTagDefOf.TalkingSource, + BodyPartTagDefOf.Tongue }; CapacityTags.Add(PawnCapacityDefOf.Talking, talkingTags); + HashSet eatingTags = new HashSet { + BodyPartTagDefOf.EatingPathway, + BodyPartTagDefOf.EatingSource + }; + // CapacityTags.Add(PawnCapacityDefOf.Eating, eatingTags); + + HashSet metabolismTags = new HashSet { + BodyPartTagDefOf.MetabolismSource + }; + // CapacityTags.Add(PawnCapacityDefOf.Metabolism, metabolismTags); + // try and make an educated guess for any other capacity added by mods - foreach (PawnCapacityDef capacityDef in DefDatabase.AllDefsListForReading) { - if (CapacityTags.ContainsKey(capacityDef)) { + foreach (PawnCapacityDef capacityDef in DefDatabase.AllDefsListForReading) + { + + if (CapacityTags.ContainsKey(capacityDef)) + { + continue; + } + + // in Rimworld 1.5.4069 Eating and Metabolism have been removed from BodyPartTagDefOf for some reason... + if (capacityDef.defName.Equals("Eating")) + { + CapacityTags.Add(capacityDef, eatingTags); + continue; + } + + if (capacityDef.defName.Equals("Metabolism")) + { + CapacityTags.Add(capacityDef, metabolismTags); continue; } HashSet tags = new HashSet(); foreach (BodyPartTagDef tag in DefDatabase.AllDefsListForReading.Where( td => td.defName.Contains(capacityDef.defName) - )) { + )) + { Log.Message( $"Medical Tab :: Adding {tag.defName} to the list of required capacities for {capacityDef.defName}."); tags.Add(tag); } - if (tags.Count == 0) { + if (tags.Count == 0) + { Log.Warning( $"Medical Tab :: Capacity {capacityDef.defName} does not have any bodyPartTags associated with it. This may be intentional. For modders; if the tag defName contains the capacity defName the two will be linked."); } @@ -112,16 +134,20 @@ static CapacityUtility() { } // spawn a message about orphan tags - foreach (BodyPartTagDef tag in DefDatabase.AllDefsListForReading) { + foreach (BodyPartTagDef tag in DefDatabase.AllDefsListForReading) + { bool used = false; - foreach (HashSet tagset in CapacityTags.Values) { - if (tagset.Contains(tag)) { + foreach (HashSet tagset in CapacityTags.Values) + { + if (tagset.Contains(tag)) + { used = true; break; } } - if (!used) { + if (!used) + { Log.Warning( $"Medical Tab :: Tag {tag.defName} is not associated with any pawnCapacity. This may be intentional. For modders; if the tag defName contains the capacity defName the two will be linked."); } @@ -129,29 +155,34 @@ static CapacityUtility() { } - public static IEnumerable GetDiseases(this Pawn pawn) { + public static IEnumerable GetDiseases(this Pawn pawn) + { return GetPotentiallyLethalHediffs(pawn).Where(h => h.IsDisease()); } - public static bool IsDisease(this Hediff hediff) { + public static bool IsDisease(this Hediff hediff) + { return hediff.TryGetComp() != null && hediff.def.PossibleToDevelopImmunityNaturally(); } - public static IEnumerable GetPotentiallyLethalHediffs(this Pawn pawn) { + public static IEnumerable GetPotentiallyLethalHediffs(this Pawn pawn) + { return pawn.health.hediffSet.hediffs .Where(h => h.Visible && h.def.lethalSeverity > 0); } - public static bool IsHealthy(this Pawn pawn) { + public static bool IsHealthy(this Pawn pawn) + { if (pawn.health.State != PawnHealthState.Mobile || pawn.health.summaryHealth.SummaryHealthPercent < 1f || pawn.health.hediffSet.BleedRateTotal > 0f || pawn.health.hediffSet.PainTotal > 0f || pawn.GetDiseases().Any() || DefDatabase.AllDefsListForReading - .Any(cap => pawn.health.capacities.GetLevel(cap) < 1f)) { + .Any(cap => pawn.health.capacities.GetLevel(cap) < 1f)) + { return false; } @@ -159,26 +190,31 @@ public static bool IsHealthy(this Pawn pawn) { } public static List AddedPartOptionsThatAffect(this RecipeDef r, PawnCapacityDef capacity, - Pawn pawn, bool negative = false) { + Pawn pawn, bool negative = false) + { List options = new List(); - if (!r?.addsHediff?.IsAddedPart() ?? true) { + if (!r?.addsHediff?.IsAddedPart() ?? true) + { return options; } - if (!NotMissingVitalIngredient(pawn, r)) { + if (!NotMissingVitalIngredient(pawn, r)) + { return options; } float after = r.addsHediff.addedPartProps.partEfficiency; - IEnumerable parts = r.Worker.GetPartsToApplyOn( pawn, r ) - .Where( p => p.Affects( capacity ) && - !pawn.health.hediffSet.AncestorHasDirectlyAddedParts( p ) ); + IEnumerable parts = r.Worker.GetPartsToApplyOn(pawn, r) + .Where(p => p.Affects(capacity) && + !pawn.health.hediffSet.AncestorHasDirectlyAddedParts(p)); - foreach (BodyPartRecord part in parts) { - float current = PawnCapacityUtility.CalculatePartEfficiency( pawn.health.hediffSet, part ); - if ((after < current) == negative) { + foreach (BodyPartRecord part in parts) + { + float current = PawnCapacityUtility.CalculatePartEfficiency(pawn.health.hediffSet, part); + if ((after < current) == negative) + { options.Add(GenerateSurgeryOption(pawn, pawn, r, r.PotentiallyMissingIngredients(null, pawn.Map), part)); @@ -189,12 +225,15 @@ public static List AddedPartOptionsThatAffect(this RecipeDef r, } public static bool AddsHediffThatAffects(this RecipeDef r, PawnCapacityDef capacity, float current, - bool negative = false) { + bool negative = false) + { return r.addsHediff.IsHediffThatAffects(capacity, current, negative); } - public static bool Affects(this Bill_Medical bill, PawnCapacityDef capacity) { - if (bill?.recipe == null) { + public static bool Affects(this Bill_Medical bill, PawnCapacityDef capacity) + { + if (bill?.recipe == null) + { return false; } @@ -203,13 +242,16 @@ public static bool Affects(this Bill_Medical bill, PawnCapacityDef capacity) { (bill.recipe.addsHediff.IsAddedPart() && bill.Part.Affects(capacity)); } - public static bool AddsHediffThatReducesPain(this RecipeDef r) { + public static bool AddsHediffThatReducesPain(this RecipeDef r) + { return r.addsHediff.IsHediffThatReducesPain(); } public static bool AdministersDrugThatAffects(this RecipeDef r, PawnCapacityDef capacity, float current, - bool negative = false) { - if (r.ingredients.NullOrEmpty()) { + bool negative = false) + { + if (r.ingredients.NullOrEmpty()) + { return false; } @@ -217,32 +259,39 @@ public static bool AdministersDrugThatAffects(this RecipeDef r, PawnCapacityDef negative); } - public static bool AdministersDrugThatReducesPain(this RecipeDef r) { - if (r.ingredients.NullOrEmpty()) { + public static bool AdministersDrugThatReducesPain(this RecipeDef r) + { + if (r.ingredients.NullOrEmpty()) + { return false; } return r.ingredients[0].filter.BestThingRequest.singleDef.ReducesPainOnIngestion(); } - public static bool Affects(this BodyPartRecord part, PawnCapacityDef capacity) { + public static bool Affects(this BodyPartRecord part, PawnCapacityDef capacity) + { return CapacityTags[capacity].Any(tag => part.ThisOrAnyChildHasTag(tag)); } public static bool AffectsCapacityOnIngestion(this ThingDef def, PawnCapacityDef capacity, float current, - bool negative = false) { + bool negative = false) + { return def?.ingestible?.outcomeDoers?.OfType() .Any(od => od.hediffDef.IsHediffThatAffects(capacity, current, negative)) ?? false; } public static FloatMenuOption GenerateSurgeryOption(Pawn pawn, Thing thingForMedBills, RecipeDef recipe, - IEnumerable missingIngredients, BodyPartRecord part = null) { - if (_generateSurgeryOptionMethodInfo == null) { + IEnumerable missingIngredients, BodyPartRecord part = null) + { + if (_generateSurgeryOptionMethodInfo == null) + { _generateSurgeryOptionMethodInfo = typeof(HealthCardUtility).GetMethod("GenerateSurgeryOption", BindingFlags.NonPublic | BindingFlags.Static); - if (_generateSurgeryOptionMethodInfo == null) { + if (_generateSurgeryOptionMethodInfo == null) + { throw new NullReferenceException("GenerateSurgeryOption method info not found!"); } } @@ -257,24 +306,31 @@ public static FloatMenuOption GenerateSurgeryOption(Pawn pawn, Thing thingForMed return option; } - public static bool IsAddedPart(this HediffDef hediff) { + public static bool IsAddedPart(this HediffDef hediff) + { return hediff?.addedPartProps?.partEfficiency != null; } public static bool IsHediffThatAffects(this HediffDef hediffDef, PawnCapacityDef capacity, float current, - bool negative = false) { - if (hediffDef?.stages.NullOrEmpty() ?? true) { + bool negative = false) + { + if (hediffDef?.stages.NullOrEmpty() ?? true) + { return false; } - foreach (HediffStage stage in hediffDef.stages) { - if (stage.capMods.NullOrEmpty()) { + foreach (HediffStage stage in hediffDef.stages) + { + if (stage.capMods.NullOrEmpty()) + { continue; } - foreach (PawnCapacityModifier capMod in stage.capMods) { - if (capMod.capacity == capacity) { - float after = Mathf.Min( ( current + capMod.offset ) * capMod.postFactor, capMod.setMax ); + foreach (PawnCapacityModifier capMod in stage.capMods) + { + if (capMod.capacity == capacity) + { + float after = Mathf.Min((current + capMod.offset) * capMod.postFactor, capMod.setMax); return (after < current) == negative; } } @@ -283,63 +339,74 @@ public static bool IsHediffThatAffects(this HediffDef hediffDef, PawnCapacityDef return false; } - public static bool IsHediffThatReducesPain(this HediffDef hediffDef) { - if (hediffDef?.stages.NullOrEmpty() ?? true) { + public static bool IsHediffThatReducesPain(this HediffDef hediffDef) + { + if (hediffDef?.stages.NullOrEmpty() ?? true) + { return false; } return hediffDef.stages?.Any(hs => hs.painFactor < 1f || hs.painOffset < 0f) ?? false; } - public static bool NotMissingVitalIngredient(Pawn pawn, RecipeDef r) { + public static bool NotMissingVitalIngredient(Pawn pawn, RecipeDef r) + { return !r.PotentiallyMissingIngredients(null, pawn.Map).Any(); } - public static bool ReducesPainOnIngestion(this ThingDef def) { + public static bool ReducesPainOnIngestion(this ThingDef def) + { return def?.ingestible?.outcomeDoers?.OfType() .Any(od => od.hediffDef.IsHediffThatReducesPain()) ?? false; } - public static bool ThisOrAnyChildHasTag(this BodyPartRecord part, BodyPartTagDef tag) { - if (part?.def?.tags == null) { + public static bool ThisOrAnyChildHasTag(this BodyPartRecord part, BodyPartTagDef tag) + { + if (part?.def?.tags == null) + { return false; } - if (part.def.tags.Contains(tag)) { + if (part.def.tags.Contains(tag)) + { return true; } - if (part.parts.NullOrEmpty()) { + if (part.parts.NullOrEmpty()) + { return false; } return part.parts.Any(p => p.ThisOrAnyChildHasTag(tag)); } - public struct DiseaseProgress { + public struct DiseaseProgress + { #region Fields - public float immunity; + public float immunity; public string label; - public float severity; - public bool tended; - public int tillTendTicks; + public float severity; + public bool tended; + public int tillTendTicks; public Color color; #endregion Fields #region Methods - public static explicit operator DiseaseProgress(Hediff hediff) { + public static explicit operator DiseaseProgress(Hediff hediff) + { HediffComp_Immunizable immunizable = hediff.TryGetComp(); HediffComp_TendDuration tendable = hediff.TryGetComp(); Color.RGBToHSV(hediff.LabelColor, out float hue, out _, out _); - Color color = Color.HSVToRGB( hue, 1f, 1f ); + Color color = Color.HSVToRGB(hue, 1f, 1f); - return new DiseaseProgress { + return new DiseaseProgress + { label = hediff.Label, immunity = immunizable?.Immunity ?? 0, severity = hediff.Severity, diff --git a/Source/ColumnWorkers/PawnColumnWorker_MedicalCare.cs b/Source/ColumnWorkers/PawnColumnWorker_MedicalCare.cs index 2de0ed1..ffc06cd 100644 --- a/Source/ColumnWorkers/PawnColumnWorker_MedicalCare.cs +++ b/Source/ColumnWorkers/PawnColumnWorker_MedicalCare.cs @@ -7,21 +7,29 @@ using UnityEngine; using Verse; -namespace Fluffy { - public class PawnColumnWorker_MedicalCare: PawnColumnWorker, IOptionalColumn { - public MedicalCareCategory OverallCare { +namespace Fluffy +{ + public class PawnColumnWorker_MedicalCare : PawnColumnWorker, IOptionalColumn + { + public MedicalCareCategory OverallCare + { get => MainTabWindow_Medical.Instance?.Table?.PawnsListForReading?.Max(p => p.playerSettings?.medCare) ?? MedicalCareCategory.Best; - set { - foreach (Pawn pawn in MainTabWindow_Medical.Instance.Table.PawnsListForReading) { - if (pawn?.playerSettings?.medCare != null) { + set + { + foreach (Pawn pawn in MainTabWindow_Medical.Instance.Table.PawnsListForReading) + { + if (pawn?.playerSettings?.medCare != null) + { pawn.playerSettings.medCare = value; } } } } - public bool ShowFor(SourceType source) { - switch (source) { + public bool ShowFor(SourceType source) + { + switch (source) + { case SourceType.Hostiles: return false; case SourceType.Colonists: @@ -33,24 +41,29 @@ public bool ShowFor(SourceType source) { } } - public override int Compare(Pawn a, Pawn b) { + public override int Compare(Pawn a, Pawn b) + { return GetValueToCompare(a).CompareTo(GetValueToCompare(b)); } - public override void DoCell(Rect rect, Pawn pawn, PawnTable table) { - if (pawn?.playerSettings?.medCare != null) { + public override void DoCell(Rect rect, Pawn pawn, PawnTable table) + { + if (pawn?.playerSettings?.medCare != null) + { MedicalCareUtility.MedicalCareSetter(rect, ref pawn.playerSettings.medCare); } } - public void DoDefaultMedCareHeader(Rect rect, PawnTable table) { - switch (MainTabWindow_Medical.Instance.Source) { + public void DoDefaultMedCareHeader(Rect rect, PawnTable table) + { + switch (MainTabWindow_Medical.Instance.Source) + { case SourceType.Animals: - MedicalCareUtility.MedicalCareSetter(rect, ref Find.PlaySettings.defaultCareForColonyAnimal); + MedicalCareUtility.MedicalCareSetter(rect, ref Find.PlaySettings.defaultCareForTamedAnimal); break; case SourceType.Colonists: - MedicalCareUtility.MedicalCareSetter(rect, ref Find.PlaySettings.defaultCareForColonyHumanlike); + MedicalCareUtility.MedicalCareSetter(rect, ref Find.PlaySettings.defaultCareForColonist); break; case SourceType.Hostiles: @@ -58,7 +71,7 @@ public void DoDefaultMedCareHeader(Rect rect, PawnTable table) { break; case SourceType.Prisoners: - MedicalCareUtility.MedicalCareSetter(rect, ref Find.PlaySettings.defaultCareForColonyPrisoner); + MedicalCareUtility.MedicalCareSetter(rect, ref Find.PlaySettings.defaultCareForPrisoner); break; case SourceType.Visitors: @@ -69,41 +82,52 @@ public void DoDefaultMedCareHeader(Rect rect, PawnTable table) { } } - public override void DoHeader(Rect rect, PawnTable table) { + public override void DoHeader(Rect rect, PawnTable table) + { // decrease height of rect (base does this already, but MedCareSetter does not. rect.yMin = rect.yMax - Constants.DesiredHeaderHeight; - if ((Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) && Mouse.IsOver(rect) && table.PawnsListForReading.Any()) { - MedicalCareCategory current = table.PawnsListForReading.Max( p => p.playerSettings.medCare ); + if ((Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) && Mouse.IsOver(rect) && table.PawnsListForReading.Any()) + { + MedicalCareCategory current = table.PawnsListForReading.Max(p => p.playerSettings.medCare); MedicalCareUtility.MedicalCareSetter(rect, ref current); - if (OverallCare != current) { + if (OverallCare != current) + { OverallCare = current; } TooltipHandler.TipRegion(rect, GetHeaderTip(table)); - } else if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl) || Input.GetKey(KeyCode.LeftCommand) || Input.GetKey(KeyCode.RightCommand)) && Mouse.IsOver(rect)) { + } + else if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl) || Input.GetKey(KeyCode.LeftCommand) || Input.GetKey(KeyCode.RightCommand)) && Mouse.IsOver(rect)) + { // defaults DoDefaultMedCareHeader(rect, table); TooltipHandler.TipRegion(rect, GetHeaderTip(table)); - } else { + } + else + { // text base.DoHeader(rect, table); } } - public override int GetMinWidth(PawnTable table) { + public override int GetMinWidth(PawnTable table) + { return Constants.MedicalCareSetterWidth; } - internal int GetValueToCompare(Pawn pawn) { - return (int) pawn.playerSettings.medCare; + internal int GetValueToCompare(Pawn pawn) + { + return (int)pawn.playerSettings.medCare; } - protected override string GetHeaderTip(PawnTable table) { - string tip = base.GetHeaderTip( table ); + protected override string GetHeaderTip(PawnTable table) + { + string tip = base.GetHeaderTip(table); tip += "\n\n"; - if (table.PawnsListForReading.Any()) { + if (table.PawnsListForReading.Any()) + { tip += "MedicalTab.XClickToY".Translate("MedicalTab.Shift".Translate(), "MedicalTab.MassAssignMedicalCare".Translate()) .CapitalizeFirst(); diff --git a/Source/MainTabWindow_Medical.cs b/Source/MainTabWindow_Medical.cs index 7300787..a282ac0 100644 --- a/Source/MainTabWindow_Medical.cs +++ b/Source/MainTabWindow_Medical.cs @@ -10,8 +10,10 @@ using UnityEngine; using Verse; -namespace Fluffy { - public enum SourceType { +namespace Fluffy +{ + public enum SourceType + { Colonists, Animals, Prisoners, @@ -19,7 +21,8 @@ public enum SourceType { Hostiles } - public class MainTabWindow_Medical: MainTabWindow_PawnTable { + public class MainTabWindow_Medical : MainTabWindow_PawnTable + { #region Fields private static readonly FieldInfo _tableFieldInfo; @@ -30,15 +33,18 @@ public class MainTabWindow_Medical: MainTabWindow_PawnTable { #region Constructors - static MainTabWindow_Medical() { + static MainTabWindow_Medical() + { _tableFieldInfo = typeof(MainTabWindow_PawnTable).GetField("table", BindingFlags.Instance | BindingFlags.NonPublic); - if (_tableFieldInfo == null) { + if (_tableFieldInfo == null) + { throw new NullReferenceException("table field not found!"); } } - public MainTabWindow_Medical() { + public MainTabWindow_Medical() + { Instance = this; } @@ -48,23 +54,29 @@ public MainTabWindow_Medical() { public static MainTabWindow_Medical Instance { get; private set; } - public SourceType Source { + public SourceType Source + { get => _source; - private set { + private set + { _source = value; RebuildTable(); } } - public PawnTable Table { + public PawnTable Table + { get => _tableFieldInfo.GetValue(this) as PawnTable_PlayerPawns; private set => _tableFieldInfo.SetValue(this, value); } - public static bool FilterHealthy { + public static bool FilterHealthy + { get => _filterHealthy; - set { - if (_filterHealthy == value) { + set + { + if (_filterHealthy == value) + { return; } @@ -73,11 +85,14 @@ public static bool FilterHealthy { } } - protected override IEnumerable Pawns { - get { + protected override IEnumerable Pawns + { + get + { IEnumerable pawns; - switch (Source) { + switch (Source) + { case SourceType.Colonists: pawns = Find.CurrentMap.mapPawns.FreeColonists; break; @@ -118,7 +133,8 @@ protected override IEnumerable Pawns { break; } - if (_filterHealthy) { + if (_filterHealthy) + { pawns = pawns.Where(p => !p.IsHealthy()); } @@ -132,14 +148,18 @@ protected override IEnumerable Pawns { #region Methods - public void DoSourceSelectionButton(Rect rect) { + public void DoSourceSelectionButton(Rect rect) + { // apparently, font size going to tiny on fully zooming in is working as designed... Text.Font = GameFont.Small; - if (Widgets.ButtonText(rect, Source.ToString().Translate())) { + if (Widgets.ButtonText(rect, Source.ToString().Translate())) + { List options = new List(); - foreach (SourceType sourceOption in Enum.GetValues(typeof(SourceType)).OfType()) { - if (sourceOption != Source) { + foreach (SourceType sourceOption in Enum.GetValues(typeof(SourceType)).OfType()) + { + if (sourceOption != Source) + { options.Add(new FloatMenuOption(sourceOption.ToString().Translate(), delegate { Source = sourceOption; })); } @@ -149,24 +169,29 @@ public void DoSourceSelectionButton(Rect rect) { } } - public void DoFilterHealthyButton(Rect rect) { + public void DoFilterHealthyButton(Rect rect) + { TooltipHandler.TipRegion(rect, FilterHealthy ? "MedicalTab.FilterHealthyOn".Translate() : "MedicalTab.FilterHealthyOff".Translate()); if (Widgets.ButtonImage(rect, FilterHealthy ? Resources.HealthyFilterOn : Resources.HealthyFilterOff, FilterHealthy ? GenUI.MouseoverColor : Color.white, - FilterHealthy ? Color.white : GenUI.MouseoverColor)) { + FilterHealthy ? Color.white : GenUI.MouseoverColor)) + { FilterHealthy = !FilterHealthy; } } - public override void DoWindowContents(Rect rect) { + public override void DoWindowContents(Rect rect) + { DoSourceSelectionButton(new Rect(rect.xMin, rect.yMin, 120f, 30f)); DoFilterHealthyButton(new Rect(rect.xMin + 120f + 6f, rect.yMin, 30f, 30f)); + rect.y += 20; base.DoWindowContents(rect); } - private void RebuildTable() { + private void RebuildTable() + { DynamicPawnTableDefOf.Medical.Select(c => (c.Worker as IOptionalColumn)?.ShowFor(Source) ?? true); - Table = new PawnTable_PlayerPawns(DynamicPawnTableDefOf.Medical, () => Pawns, UI.screenWidth - (int) (Margin * 2f), (int) (UI.screenHeight - 35 - ExtraBottomSpace - ExtraTopSpace - (Margin * 2f))); + Table = new PawnTable_PlayerPawns(DynamicPawnTableDefOf.Medical, () => Pawns, UI.screenWidth - (int)(Margin * 2f), (int)(UI.screenHeight - ExtraBottomSpace - ExtraTopSpace - (Margin * 2f))); } #endregion Methods