static bool DrawOverviewTab(ref Rect leftRect, ref Pawn pawn, ref float curY) { if (pawn is Droid) { curY += 4f; Pawn p = pawn; Text.Font = GameFont.Small; if (!pawn.Dead) { IEnumerable <PawnCapacityDef> source = pawn.def.race.Humanlike ? (from x in DefDatabase <PawnCapacityDef> .AllDefs where x.showOnHumanlikes select x) : ((!pawn.def.race.Animal) ? DefDatabase <PawnCapacityDef> .AllDefs.Where((PawnCapacityDef x) => x.showOnMechanoids) : DefDatabase <PawnCapacityDef> .AllDefs.Where((PawnCapacityDef x) => x.showOnAnimals)); foreach (PawnCapacityDef item in from act in source orderby act.listOrder select act) { if (PawnCapacityUtility.BodyCanEverDoCapacity(pawn.RaceProps.body, item)) { PawnCapacityDef activityLocal = item; Pair <string, Color> efficiencyLabel = HealthCardUtility.GetEfficiencyLabel(pawn, item); Func <string> textGetter = () => (!p.Dead) ? HealthCardUtility.GetPawnCapacityTip(p, activityLocal) : ""; curY = (float)(typeof(HealthCardUtility).GetMethod("DrawLeftRow", BindingFlags.NonPublic | BindingFlags.Static).Invoke(new object(), new object[] { leftRect, curY, item.GetLabelFor(pawn.RaceProps.IsFlesh, pawn.RaceProps.Humanlike).CapitalizeFirst(), efficiencyLabel.First, efficiencyLabel.Second, new TipSignal(textGetter, pawn.thingIDNumber ^ item.index) })); } } } return(false); } else { return(true); } }
private static string GetHealthReport(Pawn subject) { var health = subject.health; var payload = health.summaryHealth.SummaryHealthPercent.ToStringPercent() + " "; payload += health.State != PawnHealthState.Mobile ? GetHealthStateFriendly(health.State) : GetMoodFriendly(subject); if (health.hediffSet.BleedRateTotal > 0.01f) { var ticks = HealthUtility.TicksUntilDeathDueToBloodLoss(subject); payload += " | "; payload += ticks >= 60000 ? "⌛" : $"⏳ {ticks.ToStringTicksToPeriod(shortForm: true)}"; payload += " | "; } var source = DefDatabase <PawnCapacityDef> .AllDefsListForReading; if (subject.def.race.Humanlike) { source = source.Where(c => c.showOnHumanlikes).ToList(); } else if (subject.def.race.Animal) { source = source.Where(c => c.showOnAnimals).ToList(); } else if (subject.def.race.IsMechanoid) { source = source.Where(c => c.showOnMechanoids).ToList(); } else { source.Clear(); payload += "Unsupported race"; } if (!source.Any()) { return(payload); } var container = ""; foreach (var capacity in source.OrderBy(c => c.listOrder)) { if (!PawnCapacityUtility.BodyCanEverDoCapacity(subject.RaceProps.body, capacity)) { continue; } container += $"{capacity.GetLabelFor(subject).CapitalizeFirst()}: "; container += HealthCardUtility.GetEfficiencyLabel(subject, capacity).First; container += ", "; } return(payload + container.Substring(0, container.Length - 2)); }
private static string MyPawnHealthCapacity(Viewer viewer, Pawn pawn, PawnCapacityDef capacityDef) { if (PawnCapacityUtility.BodyCanEverDoCapacity(pawn.RaceProps.body, capacityDef)) { Pair <string, Color> efficiencyLabel = HealthCardUtility.GetEfficiencyLabel(pawn, capacityDef); List <PawnCapacityUtility.CapacityImpactor> impactorList = new List <PawnCapacityUtility.CapacityImpactor>(); float fLevel = PawnCapacityUtility.CalculateCapacityLevel(pawn.health.hediffSet, capacityDef, impactorList); string sLevel = (fLevel * 100.0f).ToString("F0") + "%"; string output = $"@{viewer.username} {pawn.Name.ToStringShort.CapitalizeFirst()}'s {capacityDef.LabelCap}: {efficiencyLabel.First} ({sLevel})"; output += " - " + "AffectedBy".Translate() + " "; if (impactorList.Count > 0) { for (int i = 0; i < impactorList.Count; i++) { if (impactorList[i] is PawnCapacityUtility.CapacityImpactorHediff) { output += impactorList[i].Readable(pawn) + ", "; } } for (int i = 0; i < impactorList.Count; i++) { if (impactorList[i] is PawnCapacityUtility.CapacityImpactorBodyPartHealth) { output += impactorList[i].Readable(pawn) + ", "; } } for (int i = 0; i < impactorList.Count; i++) { if (impactorList[i] is PawnCapacityUtility.CapacityImpactorCapacity) { output += impactorList[i].Readable(pawn) + ", "; } } for (int i = 0; i < impactorList.Count; i++) { if (impactorList[i] is PawnCapacityUtility.CapacityImpactorPain) { output += impactorList[i].Readable(pawn) + ", "; } } output = output.Substring(0, output.Length - 2); } else { output += $"nothing "; } return(output); } else { return($"@{viewer.username} {pawn.Name.ToStringShort.CapitalizeFirst()} Can not have {capacityDef.LabelCap}."); } }
private void DoCapacity(Rect rect, Pawn pawn, PawnCapacityDef capacity) { var efficiencyLabel = HealthCardUtility.GetEfficiencyLabel(pawn, capacity); var pawnCapacityTip = HealthCardUtility.GetPawnCapacityTip(pawn, capacity); if (Mouse.IsOver(rect)) { Widgets.DrawHighlight(rect); } GUI.color = efficiencyLabel.Second; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect, efficiencyLabel.First); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; TooltipHandler.TipRegion(rect, pawnCapacityTip); }
public override void DoCell(Rect rect, Pawn pawn, PawnTable table) { // get values float level = Efficiency(pawn); string label = level.ToStringPercent(); Color color = HealthCardUtility.GetEfficiencyLabel(pawn, Capacity).Second; string tip = HealthCardUtility.GetPawnCapacityTip(pawn, Capacity); // draw label GUI.color = color; Text.Anchor = TextAnchor.LowerCenter; Widgets.Label(rect, label); Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; // pending bills DoPendingBillsDrawExtra(rect, pawn); if (Mouse.IsOver(rect)) { // getting that tooltip can be quite expensive, let's not do it until we have to. tip += GetPendingBillsTip(pawn); } // tooltip Widgets.DrawHighlightIfMouseover(rect); tip += GetInteractionTip(pawn); TooltipHandler.TipRegion(rect, tip); // done for hostile pawns if (MainTabWindow_Medical.Instance.Source == SourceType.Hostiles) { return; } // click DoInteractions(rect, pawn, level); }
public override void DoCell(Rect rect, Pawn pawn, PawnTable table) { GUI.color = HealthCardUtility.GetEfficiencyLabel(pawn, def.Ext().capacity).Second; base.DoCell(rect, pawn, table); GUI.color = Color.white; }
private static string HealthReport([NotNull] Pawn pawn) { var segments = new List <string> { ResponseHelper.JoinPair("TKUtils.PawnHealth.OverallHealth".Localize(), pawn.health.summaryHealth.SummaryHealthPercent.ToStringPercent()) }; if (pawn.health.State != PawnHealthState.Mobile) { segments[0] += $" {GetHealthStateFriendly(pawn.health.State)}"; } else { segments[0] += $" {GetMoodFriendly(pawn)}"; } if (pawn.health.hediffSet.BleedRateTotal > 0.01f) { int ticks = HealthUtility.TicksUntilDeathDueToBloodLoss(pawn); segments.Add( ticks >= 60000 ? ResponseHelper.BleedingSafeGlyphs.AltText("WontBleedOutSoon".Localize().CapitalizeFirst()) : $"{ResponseHelper.BleedingBadGlyphs.AltText("BleedingRate".Localize())} ({ticks.ToStringTicksToPeriod(shortForm: true)})" ); } List <PawnCapacityDef> source = GetCapacitiesForPawn(pawn).ToList(); if (source.Count > 0) { source = source.OrderBy(d => d.listOrder).ToList(); string[] capacities = source.Where(capacity => PawnCapacityUtility.BodyCanEverDoCapacity(pawn.RaceProps.body, capacity)) .Select( capacity => ResponseHelper.JoinPair( RichTextHelper.StripTags(capacity.GetLabelFor(pawn)).CapitalizeFirst(), HealthCardUtility.GetEfficiencyLabel(pawn, capacity).First ) ) .ToArray(); segments.Add(capacities.SectionJoin()); } else { segments.Add("TKUtils.Responses.UnsupportedRace".LocalizeKeyed(pawn.kindDef.race.defName)); } if (!TkSettings.ShowSurgeries) { return(segments.GroupedJoin()); } BillStack surgeries = pawn.health.surgeryBills; if (surgeries?.Count <= 0) { return(segments.GroupedJoin()); } string[] queued = surgeries !.Bills.Select(item => RichTextHelper.StripTags(item.LabelCap)).ToArray(); segments.Add(ResponseHelper.JoinPair("TKUtils.PawnHealth.QueuedSurgeries".Localize(), queued.SectionJoin())); return(segments.GroupedJoin()); }
public void Draw(Rect rect, ThingWithComps ownerPawn) { Text.Font = GameFont.Small; string value = "-"; switch (oType) { case objectType.Stat: Text.Anchor = TextAnchor.MiddleCenter; StatDef stat = (StatDef)displayObject; string statValue = (stat.ValueToString(ownerPawn.GetStatValue((StatDef)displayObject, true))); Widgets.Label(rect, statValue); if (Mouse.IsOver(rect)) { GUI.DrawTexture(rect, TexUI.HighlightTex); } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(stat.LabelCap); stringBuilder.AppendLine(); stringBuilder.AppendLine(stat.description); TooltipHandler.TipRegion(rect, new TipSignal(stringBuilder.ToString(), rect.GetHashCode())); break; case objectType.Skill: if ((ownerPawn is Pawn) && (ownerPawn as Pawn).RaceProps.Humanlike) { DrawSkill(rect, ownerPawn as Pawn); } break; case objectType.Need: if (ownerPawn is Pawn) { DrawNeed(rect, ownerPawn as Pawn); } break; case objectType.Capacity: Text.Anchor = TextAnchor.MiddleCenter; if (ownerPawn is Pawn) { Pawn p = (Pawn)ownerPawn; PawnCapacityDef cap = (PawnCapacityDef)displayObject; Pair <string, Color> effLabel = HealthCardUtility.GetEfficiencyLabel(p, cap); string pawnCapTip = HealthCardUtility.GetPawnCapacityTip(p, cap); // I stole this one line from Fluffy's Medical Tab. THANKS FLUFFY! string capValue = (p.health.capacities.GetEfficiency(cap) * 100f).ToString("F0") + "%"; GUI.color = effLabel.Second; Widgets.Label(rect, capValue); GUI.color = Color.white; if (Mouse.IsOver(rect)) { GUI.DrawTexture(rect, TexUI.HighlightTex); } StringBuilder stringBuilder2 = new StringBuilder(); stringBuilder2.AppendLine(cap.LabelCap); stringBuilder2.AppendLine(); stringBuilder2.AppendLine(cap.description); TooltipHandler.TipRegion(rect, new TipSignal(stringBuilder2.ToString(), rect.GetHashCode())); } break; case objectType.MentalState: Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.MiddleCenter; if (ownerPawn is Pawn && (ownerPawn as Pawn).MentalState != null) { string ms = ((ownerPawn as Pawn).MentalState.InspectLine); Widgets.Label(rect, ms); if (Mouse.IsOver(rect)) { GUI.DrawTexture(rect, TexUI.HighlightTex); } } Text.Font = GameFont.Medium; break; case objectType.Age: Text.Anchor = TextAnchor.MiddleCenter; string ageValue = ((ownerPawn as Pawn).ageTracker.AgeBiologicalYears.ToString()); Widgets.Label(rect, ageValue); if (Mouse.IsOver(rect)) { GUI.DrawTexture(rect, TexUI.HighlightTex); } break; case objectType.Gear: DrawGear(rect, ownerPawn); break; case objectType.ControlPrisonerGetsFood: if (ownerPawn is Pawn) { if (Mouse.IsOver(rect)) { GUI.DrawTexture(rect, TexUI.HighlightTex); } bool getsFood = (ownerPawn as Pawn).guest.GetsFood; Widgets.CheckboxLabeled(new Rect(rect.x + 8f, rect.y + 3f, 27f, 27f), "", ref getsFood, false); (ownerPawn as Pawn).guest.GetsFood = getsFood; } break; case objectType.ControlPrisonerInteraction: if (ownerPawn is Pawn) { if (Mouse.IsOver(rect)) { GUI.DrawTexture(rect, TexUI.HighlightTex); } float x = 8f; GUI.BeginGroup(rect); IEnumerator enumerator = Enum.GetValues(typeof(PrisonerInteractionMode)).GetEnumerator(); try { while (enumerator.MoveNext()) { PrisonerInteractionMode prisonerInteractionMode = (PrisonerInteractionMode)((byte)enumerator.Current); if (Widgets.RadioButton(new Vector2(x, 3f), (ownerPawn as Pawn).guest.interactionMode == prisonerInteractionMode)) { (ownerPawn as Pawn).guest.interactionMode = prisonerInteractionMode; } TooltipHandler.TipRegion(new Rect(x, 0f, 30f, 30f), new TipSignal(prisonerInteractionMode.GetLabel())); x += 30f; } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } GUI.EndGroup(); } break; case objectType.ControlMedicalCare: if (ownerPawn is Pawn) { MedicalCareSetter(rect, ref (ownerPawn as Pawn).playerSettings.medCare); } break; case objectType.AnimalMilkFullness: Text.Anchor = TextAnchor.MiddleCenter; if (ownerPawn is Pawn && ((Pawn)ownerPawn).ageTracker.CurLifeStage.milkable) { var comp = ((Pawn)ownerPawn).AllComps.Where <ThingComp>(x => x is CompMilkable).FirstOrDefault(); if (comp != null) { value = ((CompMilkable)comp).Fullness.ToStringPercent(); } } Widgets.Label(rect, value); break; case objectType.AnimalWoolGrowth: Text.Anchor = TextAnchor.MiddleCenter; if (ownerPawn is Pawn && ((Pawn)ownerPawn).ageTracker.CurLifeStage.shearable) { var comp = ((Pawn)ownerPawn).AllComps.Where <ThingComp>(x => x is CompShearable).FirstOrDefault(); if (comp != null) { value = ((CompShearable)comp).Fullness.ToStringPercent(); } } Widgets.Label(rect, value); break; case objectType.CurrentJob: if (ownerPawn is Pawn && ((Pawn)ownerPawn).jobs.curDriver != null) { string text = ((Pawn)ownerPawn).jobs.curDriver.GetReport(); Text.Anchor = TextAnchor.MiddleLeft; Rect tRect = new Rect(rect.xMin + 2, rect.yMin + 3, rect.width - 2, rect.height); GenText.SetTextSizeToFit(text, tRect); if (Text.Font == GameFont.Tiny) { Widgets.Label(tRect, text); } else { Rect sRect = new Rect(rect.xMin + 2, rect.yMin, rect.width - 2, rect.height); Widgets.Label(sRect, text); } if (Mouse.IsOver(rect)) { GUI.DrawTexture(rect, TexUI.HighlightTex); } } break; } }
private static string MyPawnHealthSummary(Viewer viewer, Pawn pawn) { string healthPercent = (pawn.health.summaryHealth.SummaryHealthPercent * 100.0f).ToString("n1") + "%"; string output = $"@{viewer.username} {pawn.Name.ToStringShort.CapitalizeFirst()}'s health: {healthPercent} "; if (pawn.health.State != PawnHealthState.Mobile) { output += $"({HealthStateForPawn(pawn)}) "; } if (pawn.health.hediffSet.BleedRateTotal > 0.01f) { int ticksUntilDeath = HealthUtility.TicksUntilDeathDueToBloodLoss(pawn); if (ticksUntilDeath < 60000) { output += "- " + "TimeToDeath".Translate(ticksUntilDeath.ToStringTicksToPeriod()) + " "; } else { output += "- " + "WontBleedOutSoon".Translate() + " "; } } output += " | "; IEnumerable <PawnCapacityDef> capacityDefs; if (pawn.def.race.Humanlike) { capacityDefs = from x in DefDatabase <PawnCapacityDef> .AllDefs where x.showOnHumanlikes select x; } else if (pawn.def.race.Animal) { capacityDefs = from x in DefDatabase <PawnCapacityDef> .AllDefs where x.showOnAnimals select x; } else if (pawn.def.race.IsMechanoid) { capacityDefs = from x in DefDatabase <PawnCapacityDef> .AllDefs where x.showOnMechanoids select x; } else { capacityDefs = new List <PawnCapacityDef>(); output += "(can't show capacities for this race) "; } foreach (PawnCapacityDef pawnCapacityDef in from def in capacityDefs orderby def.listOrder select def) { if (PawnCapacityUtility.BodyCanEverDoCapacity(pawn.RaceProps.body, pawnCapacityDef)) { Pair <string, Color> efficiencyLabel = HealthCardUtility.GetEfficiencyLabel(pawn, pawnCapacityDef); output += $"{pawnCapacityDef}: {efficiencyLabel.First} | "; } } if (capacityDefs.Count() > 0) { output = output.Substring(0, output.Length - 2); } if (ModSettings.Singleton.MyPawnHealthShowSurgeries) { output += " | Queued Surgeries - "; if (pawn.health.surgeryBills?.Count > 0) { foreach (var surgeryBill in pawn.health.surgeryBills) { output += $"{surgeryBill.LabelCap}, "; } output = output.Substring(0, output.Length - 2); } else { output += $"none"; } } return(output); }
public void Draw(Rect rect, ThingWithComps ownerPawn) { Text.Font = GameFont.Small; string value = "-"; switch (oType) { case ObjectType.Stat: Text.Anchor = TextAnchor.MiddleCenter; StatDef stat = (StatDef)displayObject; stat.neverDisabled = true; string statValue = (stat.ValueToString(ownerPawn.GetStatValue((StatDef)displayObject, true))); Widgets.Label(rect, statValue); if (Mouse.IsOver(rect)) { GUI.DrawTexture(rect, TexUI.HighlightTex); } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(stat.LabelCap); stringBuilder.AppendLine(); stringBuilder.AppendLine(stat.description); TooltipHandler.TipRegion(rect, new TipSignal(stringBuilder.ToString(), rect.GetHashCode())); break; case ObjectType.Skill: if ((ownerPawn is Pawn) && (ownerPawn as Pawn).RaceProps.Humanlike) { DrawSkill(rect, ownerPawn as Pawn); } break; case ObjectType.Need: if (ownerPawn is Pawn) { DrawNeed(rect, ownerPawn as Pawn); } break; case ObjectType.Capacity: Text.Anchor = TextAnchor.MiddleCenter; if (ownerPawn is Pawn p) { PawnCapacityDef cap = (PawnCapacityDef)displayObject; Pair <string, Color> effLabel = HealthCardUtility.GetEfficiencyLabel(p, cap); string pawnCapTip = HealthCardUtility.GetPawnCapacityTip(p, cap); // I stole this one line from Fluffy's Medical Tab. THANKS FLUFFY! string capValue = (p.health.capacities.GetLevel(cap) * 100f).ToString("F0") + "%"; GUI.color = effLabel.Second; Widgets.Label(rect, capValue); GUI.color = Color.white; if (Mouse.IsOver(rect)) { GUI.DrawTexture(rect, TexUI.HighlightTex); } StringBuilder stringBuilder2 = new StringBuilder(); stringBuilder2.AppendLine(cap.LabelCap); stringBuilder2.AppendLine(); stringBuilder2.AppendLine(cap.description); TooltipHandler.TipRegion(rect, new TipSignal(stringBuilder2.ToString(), rect.GetHashCode())); } break; case ObjectType.Record: Text.Anchor = TextAnchor.MiddleCenter; if (ownerPawn is Pawn pawn) { RecordDef recordDef = (RecordDef)displayObject; string recordValue; if (recordDef.type == RecordType.Time) { recordValue = pawn.records.GetAsInt(recordDef).ToStringTicksToPeriod(); } else { recordValue = pawn.records.GetValue(recordDef).ToString("0.##"); } Widgets.Label(rect, recordValue); if (Mouse.IsOver(rect)) { GUI.DrawTexture(rect, TexUI.HighlightTex); } StringBuilder recordDefStringBuilder = new StringBuilder(); recordDefStringBuilder.AppendLine(recordDef.LabelCap); recordDefStringBuilder.AppendLine(); recordDefStringBuilder.AppendLine(recordDef.description); TooltipHandler.TipRegion(rect, new TipSignal(recordDefStringBuilder.ToString(), rect.GetHashCode())); } break; case ObjectType.MentalState: Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.MiddleCenter; if (ownerPawn is Pawn && (ownerPawn as Pawn).MentalState != null) { string ms = ((ownerPawn as Pawn).MentalState.InspectLine); Widgets.Label(rect, ms); if (Mouse.IsOver(rect)) { GUI.DrawTexture(rect, TexUI.HighlightTex); } } Text.Font = GameFont.Medium; break; case ObjectType.Age: Text.Anchor = TextAnchor.MiddleCenter; string ageValue = ((ownerPawn as Pawn).ageTracker.AgeBiologicalYears.ToString()); Widgets.Label(rect, ageValue); if (Mouse.IsOver(rect)) { GUI.DrawTexture(rect, TexUI.HighlightTex); } break; case ObjectType.Race: Text.Anchor = TextAnchor.MiddleCenter; string race = ((ownerPawn as Pawn).kindDef.race.LabelCap) ?? string.Empty; Widgets.Label(rect, race); if (Mouse.IsOver(rect)) { GUI.DrawTexture(rect, TexUI.HighlightTex); } break; case ObjectType.Gear: DrawGear(rect, ownerPawn); break; case ObjectType.ControlPrisonerGetsFood: if (ownerPawn is Pawn) { if (Mouse.IsOver(rect)) { GUI.DrawTexture(rect, TexUI.HighlightTex); } bool getsFood = (ownerPawn as Pawn).guest.GetsFood; Widgets.CheckboxLabeled(new Rect(rect.x + 8f, rect.y + 3f, 27f, 27f), "", ref getsFood, false); (ownerPawn as Pawn).guest.GetsFood = getsFood; } break; case ObjectType.ControlPrisonerInteraction: if (ownerPawn is Pawn) { if (Mouse.IsOver(rect)) { GUI.DrawTexture(rect, TexUI.HighlightTex); } float x = 8f; GUI.BeginGroup(rect); foreach (PrisonerInteractionModeDef current in from prisonerinteractionmode in DefDatabase <PrisonerInteractionModeDef> .AllDefs orderby prisonerinteractionmode.listOrder select prisonerinteractionmode) { if (Widgets.RadioButton(new Vector2(x, 3f), (ownerPawn as Pawn).guest.interactionMode == current)) { (ownerPawn as Pawn).guest.interactionMode = current; } TooltipHandler.TipRegion(new Rect(x, 0f, 30f, 30f), new TipSignal(current.LabelCap)); x += 30f; } GUI.EndGroup(); } break; case ObjectType.PrisonerRecruitmentDifficulty: Text.Anchor = TextAnchor.MiddleCenter; if (ownerPawn is Pawn) { value = (ownerPawn as Pawn).RecruitDifficulty(Faction.OfPlayer, false).ToStringPercent(); } Widgets.Label(rect, value); break; case ObjectType.ControlMedicalCare: if (ownerPawn is Pawn) { MedicalCareSetter(rect, ref (ownerPawn as Pawn).playerSettings.medCare); } break; case ObjectType.AnimalMilkFullness: Text.Anchor = TextAnchor.MiddleCenter; if (ownerPawn is Pawn && ((Pawn)ownerPawn).ageTracker.CurLifeStage.milkable) { var comp = ((Pawn)ownerPawn).AllComps.Where <ThingComp>(x => x is CompMilkable).FirstOrDefault(); if (comp != null) { value = ((CompMilkable)comp).Fullness.ToStringPercent(); } } Widgets.Label(rect, value); break; case ObjectType.AnimalWoolGrowth: Text.Anchor = TextAnchor.MiddleCenter; if (ownerPawn is Pawn && ((Pawn)ownerPawn).ageTracker.CurLifeStage.shearable) { var comp = ((Pawn)ownerPawn).AllComps.Where <ThingComp>(x => x is CompShearable).FirstOrDefault(); if (comp != null) { value = ((CompShearable)comp).Fullness.ToStringPercent(); } } Widgets.Label(rect, value); break; case ObjectType.AnimalEggProgress: Text.Anchor = TextAnchor.MiddleCenter; if (ownerPawn is Pawn && ((Pawn)ownerPawn).ageTracker.CurLifeStage.reproductive) { var comp = ((Pawn)ownerPawn).AllComps.Where <ThingComp>(x => x is CompEggLayer).FirstOrDefault(); if (comp != null) { value = ((CompEggLayer)comp).CompInspectStringExtra(); } } Widgets.Label(rect, value); break; case ObjectType.CurrentJob: if (ownerPawn is Pawn && ((Pawn)ownerPawn).jobs?.curDriver != null) { string text = ((Pawn)ownerPawn).jobs.curDriver.GetReport(); Text.Anchor = TextAnchor.MiddleLeft; Rect tRect = new Rect(rect.xMin + 2, rect.yMin + 3, rect.width - 2, rect.height); GenText.SetTextSizeToFit(text, tRect); if (Text.Font == GameFont.Tiny) { Widgets.Label(tRect, text); } else { Rect sRect = new Rect(rect.xMin + 2, rect.yMin, rect.width - 2, rect.height); Widgets.Label(sRect, text); } if (Mouse.IsOver(rect)) { GUI.DrawTexture(rect, TexUI.HighlightTex); } } break; case ObjectType.QueuedJob: if (ownerPawn is Pawn && ((Pawn)ownerPawn).jobs?.jobQueue.Count > 0) { string text = ((Pawn)ownerPawn).jobs.jobQueue[0].job.GetReport((Pawn)ownerPawn); Text.Anchor = TextAnchor.MiddleLeft; Rect tRect = new Rect(rect.xMin + 2, rect.yMin + 3, rect.width - 2, rect.height); GenText.SetTextSizeToFit(text, tRect); if (Text.Font == GameFont.Tiny) { Widgets.Label(tRect, text); } else { Rect sRect = new Rect(rect.xMin + 2, rect.yMin, rect.width - 2, rect.height); Widgets.Label(sRect, text); } if (Mouse.IsOver(rect)) { GUI.DrawTexture(rect, TexUI.HighlightTex); } } break; } }
protected override void DrawPawnRow(Rect rect, Pawn p) { // name is handled in PreDrawRow, start at 175 var x = 165f; var y = rect.yMin; // care var careRect = new Rect(x, y, 100f, 30f); Utility_Medical.MedicalCareSetter(careRect, ref p.playerSettings.medCare); x += 100f; // blood var bloodRect = new Rect(x, y, 50f, 30f); var bleedRate = p.health.hediffSet.BleedRateTotal; // float in range 0 - 1 var healthPercent = p.health.summaryHealth.SummaryHealthPercent; float iconSize; if (bleedRate < 0.01f) { iconSize = 0f; } else if (bleedRate < .1f) { iconSize = 8f; } else if (bleedRate < .3f) { iconSize = 16f; } else { iconSize = 24f; } var iconRect = Inner(bloodRect, iconSize); GUI.DrawTexture(iconRect, Utility_Medical.BloodTexture); Utility_Medical.DoHediffTooltip(bloodRect, p, bleedRate, healthPercent); Widgets.DrawHighlightIfMouseover(bloodRect); x += 50f; // Operations var opLabel = new Rect(x, y, 50f, 30f); if (Widgets.ButtonInvisible(opLabel)) { if (Event.current.button == 0) { Utility_Medical.RecipeOptionsMaker(p); } else if (Event.current.button == 1) { p.BillStack.Clear(); } } var opLabelString = new StringBuilder(); opLabelString.AppendLine("FluffyMedical.ClickTo".Translate("FluffyMedical.ScheduleOperation".Translate())); opLabelString.AppendLine("FluffyMedical.RightClickTo".Translate("FluffyMedical.UnScheduleOperations".Translate())); opLabelString.AppendLine(); opLabelString.AppendLine("FluffyMedical.ScheduledOperations".Translate()); var opScheduled = false; foreach (var op in p.BillStack) { opLabelString.AppendLine(op.LabelCap); opScheduled = true; } if (opScheduled) { GUI.DrawTexture(Inner(opLabel, 16f), Widgets.CheckboxOnTex); } else { opLabelString.AppendLine("FluffyMedical.NumCurrentOperations".Translate("No")); } TooltipHandler.TipRegion(opLabel, opLabelString.ToString()); Widgets.DrawHighlightIfMouseover(opLabel); x += 50f; // main window var colWidth = (rect.width - x) / (CapDefs.Count + 1); Text.Anchor = TextAnchor.MiddleCenter; // Pain var painCell = new Rect(x, y, colWidth, 30f); var painLabel = HealthCardUtility.GetPainLabel(p); var painPersent = p.health.hediffSet.PainTotal.ToStringPercent(); GUI.color = painLabel.Second; Widgets.Label(painCell, painPersent); if (Mouse.IsOver(painCell)) { GUI.DrawTexture(painCell, TexUI.HighlightTex); } TooltipHandler.TipRegion(painCell, painLabel.First); x += colWidth; // Efficiency foreach (PawnCapacityDef t in CapDefs) { var capDefCell = new Rect(x, y, colWidth, 30f); var colorPair = HealthCardUtility.GetEfficiencyLabel(p, t); var label = p.health.capacities.GetEfficiency(t).ToStringPercent(); GUI.color = colorPair.Second; Widgets.Label(capDefCell, label); if (Mouse.IsOver(capDefCell)) { GUI.DrawTexture(capDefCell, TexUI.HighlightTex); } Utility_Medical.DoHediffTooltip(capDefCell, p, colorPair.First, t); x += colWidth; } }