private void DrawPortraitArea(Rect rect) { Widgets.DrawMenuSection(rect); rect = rect.ContractedBy(17f); GUI.DrawTexture(new Rect(rect.center.x - Page_ConfigureStartingPawns.PawnPortraitSize.x / 2f, rect.yMin - 20f, Page_ConfigureStartingPawns.PawnPortraitSize.x, Page_ConfigureStartingPawns.PawnPortraitSize.y), PortraitsCache.Get(this.curPawn, Page_ConfigureStartingPawns.PawnPortraitSize, default(Vector3), 1f)); Rect rect2 = rect; rect2.width = 500f; CharacterCardUtility.DrawCharacterCard(rect2, this.curPawn, new Action(this.RandomizeCurPawn), rect); Rect rect3 = rect; rect3.yMin += 100f; rect3.xMin = rect2.xMax + 5f; rect3.height = 200f; Text.Font = GameFont.Medium; Widgets.Label(rect3, "Health".Translate()); Text.Font = GameFont.Small; rect3.yMin += 35f; HealthCardUtility.DrawHediffListing(rect3, this.curPawn, true); Rect rect4 = new Rect(rect3.x, rect3.yMax, rect3.width, 200f); Text.Font = GameFont.Medium; Widgets.Label(rect4, "Relations".Translate()); Text.Font = GameFont.Small; rect4.yMin += 35f; SocialCardUtility.DrawRelationsAndOpinions(rect4, this.curPawn); }
private void DrawPortraitArea(Rect rect) { Widgets.DrawMenuSection(rect); rect = rect.ContractedBy(17f); GUI.DrawTexture(new Rect(rect.center.x - PawnPortraitSize.x / 2f, rect.yMin - 24f, PawnPortraitSize.x, PawnPortraitSize.y), PortraitsCache.Get(curPawn, PawnPortraitSize)); Rect rect2 = rect; rect2.width = 500f; CharacterCardUtility.DrawCharacterCard(rect2, curPawn, RandomizeCurPawn, rect); Rect rect3 = rect; rect3.yMin += 100f; rect3.xMin = rect2.xMax + 5f; rect3.height = 200f; Text.Font = GameFont.Medium; Widgets.Label(rect3, "Health".Translate()); Text.Font = GameFont.Small; rect3.yMin += 35f; HealthCardUtility.DrawHediffListing(rect3, curPawn, showBloodLoss: true); Rect rect4 = new Rect(rect3.x, rect3.yMax, rect3.width, 200f); Text.Font = GameFont.Medium; Widgets.Label(rect4, "Relations".Translate()); Text.Font = GameFont.Small; rect4.yMin += 35f; SocialCardUtility.DrawRelationsAndOpinions(rect4, curPawn); }
private static float DrawMedOperationsTab(Rect leftRect, Pawn pawn, Thing thingForMedBills, float curY) { curY = (float)(curY + 2.0); Func <List <FloatMenuOption> > recipeOptionsMaker = delegate { List <FloatMenuOption> list = new List <FloatMenuOption>(); foreach (RecipeDef allRecipe in thingForMedBills.def.AllRecipes) { if (allRecipe.AvailableNow) { IEnumerable <ThingDef> enumerable = allRecipe.PotentiallyMissingIngredients(null, thingForMedBills.Map); if (!enumerable.Any((ThingDef x) => x.isBodyPartOrImplant) && !enumerable.Any((ThingDef x) => x.IsDrug) && (!enumerable.Any() || !allRecipe.dontShowIfAnyIngredientMissing)) { if (allRecipe.targetsBodyPart) { foreach (BodyPartRecord item in allRecipe.Worker.GetPartsToApplyOn(pawn, allRecipe)) { list.Add(HealthCardUtility.GenerateSurgeryOption(pawn, thingForMedBills, allRecipe, enumerable, item)); } } else { list.Add(HealthCardUtility.GenerateSurgeryOption(pawn, thingForMedBills, allRecipe, enumerable, null)); } } } } return(list); }; Rect rect = new Rect((float)(leftRect.x - 9.0), curY, leftRect.width, (float)(leftRect.height - curY - 20.0)); ((IBillGiver)thingForMedBills).BillStack.DoListing(rect, recipeOptionsMaker, ref HealthCardUtility.billsScrollPosition, ref HealthCardUtility.billsScrollHeight); return(curY); }
private static IEnumerable <IGrouping <BodyPartRecord, Hediff> > VisibleHediffGroupsInOrder(Pawn pawn, bool showBloodLoss) { foreach (IGrouping <BodyPartRecord, Hediff> group in from x in HealthCardUtility.VisibleHediffs(pawn, showBloodLoss) group x by x.Part into x orderby HealthCardUtility.GetListPriority(x.First <Hediff>().Part) descending select x) { yield return(group); } }
public static void DrawHediffListing(Rect rect, Pawn pawn, bool showBloodLoss) { GUI.color = Color.white; if (Prefs.DevMode && Current.ProgramState == ProgramState.Playing) { HealthCardUtility.DoDebugOptions(rect, pawn); } GUI.BeginGroup(rect); float lineHeight = Text.LineHeight; Rect outRect = new Rect(0f, 0f, rect.width, rect.height - lineHeight); Rect viewRect = new Rect(0f, 0f, (float)(rect.width - 16.0), HealthCardUtility.scrollViewHeight); Rect rect2 = rect; if (viewRect.height > outRect.height) { rect2.width -= 16f; } Widgets.BeginScrollView(outRect, ref HealthCardUtility.scrollPosition, viewRect, true); GUI.color = Color.white; float num = 0f; HealthCardUtility.highlight = true; bool flag = false; foreach (IGrouping <BodyPartRecord, Hediff> item in HealthCardUtility.VisibleHediffGroupsInOrder(pawn, showBloodLoss)) { flag = true; HealthCardUtility.DrawHediffRow(rect2, pawn, item, ref num); } if (!flag) { GUI.color = Color.gray; Text.Anchor = TextAnchor.UpperCenter; Rect rect3 = new Rect(0f, 0f, viewRect.width, 30f); Widgets.Label(rect3, "NoInjuries".Translate()); Text.Anchor = TextAnchor.UpperLeft; } if (Event.current.type == EventType.Layout) { HealthCardUtility.scrollViewHeight = num; } Widgets.EndScrollView(); float bleedRateTotal = pawn.health.hediffSet.BleedRateTotal; if (bleedRateTotal > 0.0099999997764825821) { Rect rect4 = new Rect(0f, rect.height - lineHeight, rect.width, lineHeight); string str = "BleedingRate".Translate() + ": " + bleedRateTotal.ToStringPercent() + "/" + "LetterDay".Translate(); int num2 = HealthUtility.TicksUntilDeathDueToBloodLoss(pawn); str = ((num2 >= 60000) ? (str + " (" + "WontBleedOutSoon".Translate() + ")") : (str + " (" + "TimeToDeath".Translate(num2.ToStringTicksToPeriod(true, false, true)) + ")")); Widgets.Label(rect4, str); } GUI.EndGroup(); GUI.color = Color.white; }
protected override void FillTab() { Pawn pawnForHealth = PawnForHealth; if (pawnForHealth == null) { Log.Error("Health tab found no selected pawn to display."); return; } Corpse corpse = base.SelThing as Corpse; bool showBloodLoss = corpse == null || corpse.Age < 60000; HealthCardUtility.DrawPawnHealthCard(new Rect(0f, 20f, size.x, size.y - 20f), pawnForHealth, ShouldAllowOperations(), showBloodLoss, base.SelThing); }
public static void DrawHealthSummary(Rect rect, Pawn pawn, bool allowOperations, Thing thingForMedBills) { GUI.color = Color.white; if (!allowOperations) { HealthCardUtility.onOperationTab = false; } Widgets.DrawMenuSection(rect); List <TabRecord> list = new List <TabRecord>(); list.Add(new TabRecord("HealthOverview".Translate(), delegate { HealthCardUtility.onOperationTab = false; }, !HealthCardUtility.onOperationTab)); if (allowOperations) { string label = (!pawn.RaceProps.IsMechanoid) ? "MedicalOperationsShort".Translate(new object[] { pawn.BillStack.Count }) : "MedicalOperationsMechanoidsShort".Translate(new object[] { pawn.BillStack.Count }); list.Add(new TabRecord(label, delegate { HealthCardUtility.onOperationTab = true; }, HealthCardUtility.onOperationTab)); } TabDrawer.DrawTabs(rect, list); rect = rect.ContractedBy(9f); GUI.BeginGroup(rect); float curY = 0f; Text.Font = GameFont.Medium; GUI.color = Color.white; Text.Anchor = TextAnchor.UpperCenter; if (HealthCardUtility.onOperationTab) { PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.MedicalOperations, KnowledgeAmount.FrameDisplayed); curY = HealthCardUtility.DrawMedOperationsTab(rect, pawn, thingForMedBills, curY); } else { curY = HealthCardUtility.DrawOverviewTab(rect, pawn, curY); } Text.Font = GameFont.Small; GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; GUI.EndGroup(); }
public static void DrawPawnHealthCard(Rect outRect, Pawn pawn, bool allowOperations, bool showBloodLoss, Thing thingForMedBills) { if (pawn.Dead && allowOperations) { Log.Error("Called DrawPawnHealthCard with a dead pawn and allowOperations=true. Operations are disallowed on corpses."); allowOperations = false; } outRect = outRect.Rounded(); Rect rect = new Rect(outRect.x, outRect.y, (float)(outRect.width * 0.375), outRect.height).Rounded(); Rect rect2 = new Rect(rect.xMax, outRect.y, outRect.width - rect.width, outRect.height); rect.yMin += 11f; HealthCardUtility.DrawHealthSummary(rect, pawn, allowOperations, thingForMedBills); HealthCardUtility.DrawHediffListing(rect2.ContractedBy(10f), pawn, showBloodLoss); }
protected override void FillTab() { Pawn pawnForHealth = this.PawnForHealth; if (pawnForHealth == null) { Log.Error("Health tab found no selected pawn to display."); } else { Corpse corpse = base.SelThing as Corpse; bool showBloodLoss = corpse == null || corpse.Age < 60000; Rect outRect = new Rect(0f, 20f, base.size.x, (float)(base.size.y - 20.0)); HealthCardUtility.DrawPawnHealthCard(outRect, pawnForHealth, this.ShouldAllowOperations(), showBloodLoss, base.SelThing); } }
private void DrawPortraitArea(Rect rect) { Widgets.DrawMenuSection(rect); rect = rect.ContractedBy(17f); Vector2 center = rect.center; float x = center.x; Vector2 pawnPortraitSize = Page_ConfigureStartingPawns.PawnPortraitSize; double x2 = x - pawnPortraitSize.x / 2.0; double y = rect.yMin - 20.0; Vector2 pawnPortraitSize2 = Page_ConfigureStartingPawns.PawnPortraitSize; float x3 = pawnPortraitSize2.x; Vector2 pawnPortraitSize3 = Page_ConfigureStartingPawns.PawnPortraitSize; GUI.DrawTexture(new Rect((float)x2, (float)y, x3, pawnPortraitSize3.y), PortraitsCache.Get(this.curPawn, Page_ConfigureStartingPawns.PawnPortraitSize, default(Vector3), 1f)); Rect rect2 = rect; rect2.width = 500f; CharacterCardUtility.DrawCharacterCard(rect2, this.curPawn, this.RandomizeCurPawn, rect); Rect rect3 = rect; rect3.yMin += 100f; rect3.xMin = (float)(rect2.xMax + 5.0); rect3.height = 200f; Text.Font = GameFont.Medium; Widgets.Label(rect3, "Health".Translate()); Text.Font = GameFont.Small; rect3.yMin += 35f; HealthCardUtility.DrawHediffListing(rect3, this.curPawn, true); Rect rect4 = new Rect(rect3.x, rect3.yMax, rect3.width, 200f); Text.Font = GameFont.Medium; Widgets.Label(rect4, "Relations".Translate()); Text.Font = GameFont.Small; rect4.yMin += 35f; SocialCardUtility.DrawRelationsAndOpinions(rect4, this.curPawn); }
private static void DrawHediffRow(Rect rect, Pawn pawn, IEnumerable <Hediff> diffs, ref float curY) { float num = (float)(rect.width * 0.375); float width = (float)(rect.width - num - 20.0); BodyPartRecord part = diffs.First().Part; float a = (part != null) ? Text.CalcHeight(part.def.LabelCap, num) : Text.CalcHeight("WholeBody".Translate(), num); float num2 = 0f; float num3 = curY; float num4 = 0f; foreach (IGrouping <int, Hediff> item in from x in diffs group x by x.UIGroupKey) { int num5 = item.Count(); string text = item.First().LabelCap; if (num5 != 1) { text = text + " x" + num5.ToString(); } num4 += Text.CalcHeight(text, width); } num2 = num4; Rect rect2 = new Rect(0f, curY, rect.width, Mathf.Max(a, num2)); HealthCardUtility.DoRightRowHighlight(rect2); if (part != null) { GUI.color = HealthUtility.GetPartConditionLabel(pawn, part).Second; Widgets.Label(new Rect(0f, curY, num, 100f), part.def.LabelCap); } else { GUI.color = HealthUtility.DarkRedColor; Widgets.Label(new Rect(0f, curY, num, 100f), "WholeBody".Translate()); } GUI.color = Color.white; foreach (IGrouping <int, Hediff> item2 in from x in diffs group x by x.UIGroupKey) { int num6 = 0; Hediff hediff = null; Texture2D texture2D = null; TextureAndColor textureAndColor = null; float num7 = 0f; foreach (Hediff item3 in item2) { if (num6 == 0) { hediff = item3; } textureAndColor = item3.StateIcon; if (item3.Bleeding) { texture2D = HealthCardUtility.BleedingIcon; } num7 += item3.BleedRate; num6++; } string text2 = hediff.LabelCap; if (num6 != 1) { text2 = text2 + " x" + num6.ToStringCached(); } GUI.color = hediff.LabelColor; float num8 = Text.CalcHeight(text2, width); Rect rect3 = new Rect(num, curY, width, num8); Widgets.Label(rect3, text2); GUI.color = Color.white; Rect rect4 = new Rect((float)(rect2.xMax - 20.0), curY, 20f, 20f); if ((bool)texture2D) { Rect position = rect4.ContractedBy(GenMath.LerpDouble(0f, 0.6f, 5f, 0f, Mathf.Min(num7, 1f))); GUI.DrawTexture(position, texture2D); rect4.x -= rect4.width; } if (textureAndColor.HasValue) { GUI.color = textureAndColor.Color; GUI.DrawTexture(rect4, textureAndColor.Texture); GUI.color = Color.white; rect4.x -= rect4.width; } curY += num8; } GUI.color = Color.white; curY = num3 + Mathf.Max(a, num2); TooltipHandler.TipRegion(rect2, new TipSignal(() => HealthCardUtility.GetTooltip(diffs, pawn, part), (int)curY + 7857)); }
private static float DrawOverviewTab(Rect leftRect, Pawn pawn, float curY) { curY = (float)(curY + 4.0); Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.UpperLeft; GUI.color = new Color(0.9f, 0.9f, 0.9f); string str = string.Empty; if (pawn.gender != 0) { str = pawn.gender.GetLabel() + " "; } str = str + pawn.def.label + ", " + "AgeIndicator".Translate(pawn.ageTracker.AgeNumberString); Rect rect = new Rect(0f, curY, leftRect.width, 34f); Widgets.Label(rect, str.CapitalizeFirst()); TooltipHandler.TipRegion(rect, () => pawn.ageTracker.AgeTooltipString, 73412); if (Mouse.IsOver(rect)) { Widgets.DrawHighlight(rect); } GUI.color = Color.white; curY = (float)(curY + 34.0); GUI.color = Color.white; if (pawn.IsColonist && !pawn.Dead) { bool selfTend = pawn.playerSettings.selfTend; Rect rect2 = new Rect(0f, curY, leftRect.width, 24f); Widgets.CheckboxLabeled(rect2, "SelfTend".Translate(), ref pawn.playerSettings.selfTend, false); if (pawn.playerSettings.selfTend && !selfTend) { if (pawn.story.WorkTypeIsDisabled(WorkTypeDefOf.Doctor)) { pawn.playerSettings.selfTend = false; Messages.Message("MessageCannotSelfTendEver".Translate(pawn.LabelShort), MessageTypeDefOf.RejectInput); } else if (pawn.workSettings.GetPriority(WorkTypeDefOf.Doctor) == 0) { Messages.Message("MessageSelfTendUnsatisfied".Translate(pawn.LabelShort), MessageTypeDefOf.CautionInput); } } TooltipHandler.TipRegion(rect2, "SelfTendTip".Translate(Faction.OfPlayer.def.pawnsPlural, 0.7f.ToStringPercent()).CapitalizeFirst()); curY = (float)(curY + 28.0); } if (pawn.playerSettings != null && !pawn.Dead && Current.ProgramState == ProgramState.Playing) { Rect rect3 = new Rect(0f, curY, 140f, 28f); MedicalCareUtility.MedicalCareSetter(rect3, ref pawn.playerSettings.medCare); if (Widgets.ButtonText(new Rect((float)(leftRect.width - 70.0), curY, 70f, 28f), "MedGroupDefaults".Translate(), true, false, true)) { Find.WindowStack.Add(new Dialog_MedicalDefaults()); } curY = (float)(curY + 32.0); } Text.Font = GameFont.Small; if (pawn.def.race.IsFlesh) { Pair <string, Color> painLabel = HealthCardUtility.GetPainLabel(pawn); string painTip = HealthCardUtility.GetPainTip(pawn); curY = HealthCardUtility.DrawLeftRow(leftRect, curY, "PainLevel".Translate(), painLabel.First, painLabel.Second, painTip); } if (!pawn.Dead) { IEnumerable <PawnCapacityDef> source = (!pawn.def.race.Humanlike) ? ((!pawn.def.race.Animal) ? (from x in DefDatabase <PawnCapacityDef> .AllDefs where x.showOnMechanoids select x) : DefDatabase <PawnCapacityDef> .AllDefs.Where((PawnCapacityDef x) => x.showOnAnimals)) : (from x in DefDatabase <PawnCapacityDef> .AllDefs where x.showOnHumanlikes select x); { 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 = () => (!pawn.Dead) ? HealthCardUtility.GetPawnCapacityTip(pawn, activityLocal) : string.Empty; curY = HealthCardUtility.DrawLeftRow(leftRect, curY, item.GetLabelFor(pawn.RaceProps.IsFlesh, pawn.RaceProps.Humanlike).CapitalizeFirst(), efficiencyLabel.First, efficiencyLabel.Second, new TipSignal(textGetter, pawn.thingIDNumber ^ item.index)); } } return(curY); } } return(curY); }
private static FloatMenuOption GenerateSurgeryOption(Pawn pawn, Thing thingForMedBills, RecipeDef recipe, IEnumerable <ThingDef> missingIngredients, BodyPartRecord part = null) { string text = recipe.Worker.GetLabelWhenUsedOn(pawn, part); if (part != null && !recipe.hideBodyPartNames) { text = text + " (" + part.def.label + ")"; } FloatMenuOption floatMenuOption; if (missingIngredients.Any()) { text += " ("; bool flag = true; foreach (ThingDef missingIngredient in missingIngredients) { if (!flag) { text += ", "; } flag = false; text += "MissingMedicalBillIngredient".Translate(missingIngredient.label); } text += ")"; floatMenuOption = new FloatMenuOption(text, null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { Action action = delegate { Pawn pawn2 = thingForMedBills as Pawn; if (pawn2 != null) { Bill_Medical bill_Medical = new Bill_Medical(recipe); pawn2.BillStack.AddBill(bill_Medical); bill_Medical.Part = part; if (recipe.conceptLearned != null) { PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total); } Map map = thingForMedBills.Map; if (!map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col))) { Bill.CreateNoPawnsWithSkillDialog(recipe); } if (!pawn2.InBed() && pawn2.RaceProps.IsFlesh) { if (pawn2.RaceProps.Humanlike) { if (!map.listerBuildings.allBuildingsColonist.Any((Building x) => x is Building_Bed && RestUtility.CanUseBedEver(pawn, x.def) && ((Building_Bed)x).Medical)) { Messages.Message("MessageNoMedicalBeds".Translate(), pawn2, MessageTypeDefOf.CautionInput); } } else if (!map.listerBuildings.allBuildingsColonist.Any((Building x) => x is Building_Bed && RestUtility.CanUseBedEver(pawn, x.def))) { Messages.Message("MessageNoAnimalBeds".Translate(), pawn2, MessageTypeDefOf.CautionInput); } } if (pawn2.Faction != null && !pawn2.Faction.def.hidden && !pawn2.Faction.HostileTo(Faction.OfPlayer) && recipe.Worker.IsViolationOnPawn(pawn2, part, Faction.OfPlayer)) { Messages.Message("MessageMedicalOperationWillAngerFaction".Translate(pawn2.Faction), pawn2, MessageTypeDefOf.CautionInput); } ThingDef minRequiredMedicine = HealthCardUtility.GetMinRequiredMedicine(recipe); if (minRequiredMedicine != null && pawn2.playerSettings != null && !pawn2.playerSettings.medCare.AllowsMedicine(minRequiredMedicine)) { Messages.Message("MessageTooLowMedCare".Translate(minRequiredMedicine.label, pawn2.LabelShort, pawn2.playerSettings.medCare.GetLabel()), pawn2, MessageTypeDefOf.CautionInput); } } }; floatMenuOption = new FloatMenuOption(text, action, MenuOptionPriority.Default, null, null, 0f, null, null); } floatMenuOption.extraPartWidth = 29f; floatMenuOption.extraPartOnGUI = ((Rect rect) => Widgets.InfoCardButton((float)(rect.x + 5.0), (float)(rect.y + (rect.height - 24.0) / 2.0), recipe)); return(floatMenuOption); }
private static IEnumerable <IGrouping <BodyPartRecord, Hediff> > VisibleHediffGroupsInOrder(Pawn pawn, bool showBloodLoss) { using (IEnumerator <IGrouping <BodyPartRecord, Hediff> > enumerator = (from x in HealthCardUtility.VisibleHediffs(pawn, showBloodLoss) group x by x.Part into x orderby HealthCardUtility.GetListPriority(x.First().Part) descending select x).GetEnumerator()) { if (enumerator.MoveNext()) { IGrouping <BodyPartRecord, Hediff> group = enumerator.Current; yield return(group); /*Error: Unable to find new state assignment for yield return*/; } } yield break; IL_0103: /*Error near IL_0104: Unexpected return in MoveNext()*/; }