示例#1
0
        protected override void ExtraOnGUI()
        {
            base.ExtraOnGUI();
            Pawn localSpecificHealthTabForPawn = this.specificHealthTabForPawn;

            if (localSpecificHealthTabForPawn != null)
            {
                Rect  tabRect = base.TabRect;
                float specificHealthTabWidth = this.SpecificHealthTabWidth;
                Rect  rect = new Rect((float)(tabRect.xMax - 1.0), tabRect.yMin, specificHealthTabWidth, tabRect.height);
                Find.WindowStack.ImmediateWindow(1439870015, rect, WindowLayer.GameUI, delegate
                {
                    if (!localSpecificHealthTabForPawn.DestroyedOrNull())
                    {
                        Rect outRect = new Rect(0f, 20f, rect.width, (float)(rect.height - 20.0));
                        HealthCardUtility.DrawPawnHealthCard(outRect, localSpecificHealthTabForPawn, false, true, localSpecificHealthTabForPawn);
                        if (Widgets.CloseButtonFor(rect.AtZero()))
                        {
                            this.specificHealthTabForPawn = null;
                            SoundDefOf.TabClose.PlayOneShotOnCamera(null);
                        }
                    }
                }, true, false, 1f);
            }
        }
示例#2
0
        protected override void ExtraOnGUI()
        {
            EnsureSpecificHealthTabForPawnValid();
            base.ExtraOnGUI();
            Pawn localSpecificHealthTabForPawn = specificHealthTabForPawn;

            if (localSpecificHealthTabForPawn != null)
            {
                Rect  tabRect = base.TabRect;
                float specificHealthTabWidth = SpecificHealthTabWidth;
                Rect  rect = new Rect(tabRect.xMax - 1f, tabRect.yMin, specificHealthTabWidth, tabRect.height);
                Find.WindowStack.ImmediateWindow(1439870015, rect, WindowLayer.GameUI, delegate
                {
                    if (!localSpecificHealthTabForPawn.DestroyedOrNull())
                    {
                        Rect outRect = new Rect(0f, 20f, rect.width, rect.height - 20f);
                        HealthCardUtility.DrawPawnHealthCard(outRect, localSpecificHealthTabForPawn, allowOperations: false, showBloodLoss: true, localSpecificHealthTabForPawn);
                        if (Widgets.CloseButtonFor(rect.AtZero()))
                        {
                            specificHealthTabForPawn = null;
                            SoundDefOf.TabClose.PlayOneShotOnCamera();
                        }
                    }
                });
            }
        }
示例#3
0
        protected override void ExtraOnGUI()
        {
            base.ExtraOnGUI();
            var localSpecificHealthTabForPawn = specificHealthTabForPawn;

            if (localSpecificHealthTabForPawn != null)
            {
                var tabRect = TabRect;
                var specificHealthTabWidth = SpecificHealthTabWidth;
                var rect = new Rect(tabRect.xMax - 1f, tabRect.yMin, specificHealthTabWidth, tabRect.height);
                Find.WindowStack.ImmediateWindow(1439870015, rect, WindowLayer.GameUI, delegate
                {
                    if (localSpecificHealthTabForPawn.DestroyedOrNull())
                    {
                        return;
                    }
                    var outRect = new Rect(0f, 20f, rect.width, rect.height - 20f);
                    HealthCardUtility.DrawPawnHealthCard(outRect, localSpecificHealthTabForPawn, false, true,
                                                         localSpecificHealthTabForPawn);
                    if (Widgets.CloseButtonFor(rect.AtZero()))
                    {
                        specificHealthTabForPawn = null;
                        SoundDefOf.TabClose.PlayOneShotOnCamera(null);
                    }
                }, true, false, 1f);
            }
        }
 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);
     }
 }
示例#5
0
        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));
        }
 protected void FillCard(Rect cardRect)
 {
     if (tab == InfoCardTab.Stats)
     {
         if (thing != null)
         {
             Thing         innerThing    = thing;
             MinifiedThing minifiedThing = thing as MinifiedThing;
             if (minifiedThing != null)
             {
                 innerThing = minifiedThing.InnerThing;
             }
             StatsReportUtility.DrawStatsReport(cardRect, innerThing);
         }
         else if (titleDef != null)
         {
             StatsReportUtility.DrawStatsReport(cardRect, titleDef, faction);
         }
         else if (faction != null)
         {
             StatsReportUtility.DrawStatsReport(cardRect, faction);
         }
         else if (worldObject != null)
         {
             StatsReportUtility.DrawStatsReport(cardRect, worldObject);
         }
         else if (def is AbilityDef)
         {
             StatsReportUtility.DrawStatsReport(cardRect, (AbilityDef)def);
         }
         else
         {
             StatsReportUtility.DrawStatsReport(cardRect, def, stuff);
         }
     }
     else if (tab == InfoCardTab.Character)
     {
         CharacterCardUtility.DrawCharacterCard(cardRect, (Pawn)thing);
     }
     else if (tab == InfoCardTab.Health)
     {
         cardRect.yMin += 8f;
         HealthCardUtility.DrawPawnHealthCard(cardRect, (Pawn)thing, allowOperations: false, showBloodLoss: false, null);
     }
     else if (tab == InfoCardTab.Records)
     {
         RecordsCardUtility.DrawRecordsCard(cardRect, (Pawn)thing);
     }
     else if (tab == InfoCardTab.Permits)
     {
         PermitsCardUtility.DrawRecordsCard(cardRect, (Pawn)thing);
     }
     if (executeAfterFillCardOnce != null)
     {
         executeAfterFillCardOnce();
         executeAfterFillCardOnce = null;
     }
 }
示例#7
0
        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}.");
            }
        }
        public override void DoWindowContents(Rect rect)
        {
            base.DrawPageTitle(rect);
            Rect mainRect = base.GetMainRect(rect, 30f, false);

            Widgets.DrawMenuSection(mainRect, true);
            TabDrawer.DrawTabs(mainRect, from c in Find.GameInitData.startingPawns
                               select new TabRecord(c.LabelCap, delegate {
                this.SelectPawn(c);
            }, c == this.curPawn));
            Rect rect2 = mainRect.ContractedBy(17f);
            Rect rect3 = rect2;

            rect3.width = 100f;
            GUI.DrawTexture(new Rect(rect3.xMin + (rect3.width - Page_ConfigureStartingPawns.PawnPortraitSize.x) / 2f - 10f, rect3.yMin + 20f, Page_ConfigureStartingPawns.PawnPortraitSize.x, Page_ConfigureStartingPawns.PawnPortraitSize.y), PortraitsCache.Get(this.curPawn, Page_ConfigureStartingPawns.PawnPortraitSize, default(Vector3), 1f));
            Rect rect4 = rect2;

            rect4.xMin = rect3.xMax;
            Rect rect5 = rect4;

            rect5.width = 475f;
            CharacterCardUtility.DrawCharacterCard(rect5, this.curPawn, new Action(this.RandomizeCurPawn));
            Rect rect6 = new Rect(rect5.xMax + 5f, rect4.y + 100f, rect4.width - rect5.width - 5f, 200f);

            Text.Font = GameFont.Medium;
            Widgets.Label(rect6, "Health".Translate());
            Text.Font   = GameFont.Small;
            rect6.yMin += 35f;
            HealthCardUtility.DrawHediffListing(rect6, this.curPawn, true);
            Rect rect7 = new Rect(rect6.x, rect6.yMax, rect6.width, 200f);

            Text.Font = GameFont.Medium;
            Widgets.Label(rect7, "Relations".Translate());
            Text.Font   = GameFont.Small;
            rect7.yMin += 35f;
            SocialCardUtility.DrawRelationsAndOpinions(rect7, this.curPawn);

            // EdB: Add a middle "Prepare Carefully" button.
            // base.DoBottomButtons(rect, "Start".Translate(), null, null, true);
            Action prepareCarefullyAction = () => {
                PrepareCarefully.Instance.Initialize();
                PrepareCarefully.Instance.OriginalPage = this;
                Find.WindowStack.Add(new Page_ConfigureStartingPawnsCarefully());
                if (!PrepareCarefully.Instance.FindScenPart())
                {
                    Find.WindowStack.Add(new Dialog_Confirm("EdB.PrepareCarefully.ModConfigProblem.Description".Translate(),
                                                            delegate { }, true, "EdB.PrepareCarefully.ModConfigProblem.Title".Translate(), false));
                }
            };

            base.DoBottomButtons(rect, "Start".Translate(), "EdB.PrepareCarefully".Translate(), prepareCarefullyAction, true);
        }
示例#9
0
        public override void DoCell(Rect rect, Pawn pawn, PawnTable table)
        {
            Pair <string, Color> painLabel = HealthCardUtility.GetPainLabel(pawn);
            string painTip = HealthCardUtility.GetPainTip(pawn);

            painTip += "\n\n";
            painTip += "MedicalTab.XClickToY".Translate("", "MedicalTab.ShowSurgeryOptionsThat".Translate(
                                                            "MedicalTab.Reduce"
                                                            .Translate
                                                                (),
                                                            "Pain"
                                                            .Translate
                                                                ()))
                       .Trim().CapitalizeFirst();

            // draw label (centered)
            GUI.color   = painLabel.Second;
            Text.Anchor = TextAnchor.LowerCenter;
            Widgets.Label(rect, pawn.health.hediffSet.PainTotal.ToStringPercent());
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.color   = Color.white;

            // tooltip
            TooltipHandler.TipRegion(rect, painTip);

            // click
            Widgets.DrawHighlightIfMouseover(rect);
            if (Widgets.ButtonInvisible(rect))
            {
                IEnumerable <RecipeDef> recipes = pawn.def.AllRecipes
                                                  .Where(
                    r => r.AvailableNow &&
                    (r.AddsHediffThatReducesPain() ||
                     (Settings.SuggestDrugs && r.AdministersDrugThatReducesPain())) &&
                    NotMissingVitalIngredient(pawn, r)
                    );
                var options = new List <FloatMenuOption>();
                foreach (RecipeDef recipe in recipes)
                {
                    options.Add(GenerateSurgeryOption(pawn, pawn, recipe,
                                                      recipe.PotentiallyMissingIngredients(null, pawn.Map)));
                }

                if (options.Count == 0)
                {
                    options.Add(new FloatMenuOption("None".Translate(), null));
                }

                Find.WindowStack.Add(new FloatMenu(options));
            }
        }
示例#10
0
        protected override void FillTab()
        {
            Pawn pawnForHealth = PawnForHealth;

            if (pawnForHealth == null)
            {
                Log.Error("Health tab found no selected pawn to display.", false);
            }
            else
            {
                Corpse corpse        = base.SelThing as Corpse;
                bool   showBloodLoss = corpse == null || corpse.Age < 60000;
                Rect   outRect       = new Rect(0f, 20f, size.x, size.y - 20f);
                HealthCardUtility.DrawPawnHealthCard(outRect, pawnForHealth, false, showBloodLoss, base.SelThing);
            }
        }
示例#11
0
        private void DoPain(Rect rect, Pawn pawn)
        {
            var painLabel = HealthCardUtility.GetPainLabel(pawn);
            var painTip   = HealthCardUtility.GetPainTip(pawn);

            if (Mouse.IsOver(rect))
            {
                Widgets.DrawHighlight(rect);
            }
            GUI.color   = painLabel.Second;
            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(rect, painLabel.First);
            GUI.color   = Color.white;
            Text.Anchor = TextAnchor.UpperLeft;
            TooltipHandler.TipRegion(rect, painTip);
        }
示例#12
0
        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);
        }
示例#13
0
        protected override void FillTab()
        {
            /*GUI.color = Color.white;
             * Rect rect = new Rect(0f, 20f, this.size.x*0.375f, this.size.y - 20f).Rounded();
             * Rect rect2 = new Rect(rect.xMax, 20f, this.size.x - rect.width, this.size.y - 20f);
             * Widgets.DrawMenuSection(rect);
             * List<TabRecord> list = new List<TabRecord>();
             * list.Add(new TabRecord("HealthOverview".Translate(), delegate ()
             * {
             *  capacityTab = true;
             * }, !capacityTab));
             * TabDrawer.DrawTabs(rect, list, 200f);
             * rect = rect.ContractedBy(9f)*/

            HealthCardUtility.DrawPawnHealthCard(new Rect(0f, TopPadding, this.size.x, this.size.y - IconSize), base.SelPawn, false, false, base.SelThing);
        }
示例#14
0
        protected override void FillTab()
        {
            Pawn pawn = null;

            if (base.SelPawn != null)
            {
                pawn = base.SelPawn;
            }
            else if (base.SelThing is Corpse)
            {
                Corpse corpse = base.SelThing as Corpse;
                if (corpse != null)
                {
                    pawn = corpse.innerPawn;
                }
            }
            else if (base.SelThing is DeactivatedDroid)
            {
                DeactivatedDroid droid = base.SelThing as DeactivatedDroid;
                if (droid != null)
                {
                    pawn = droid.InnerDroid;
                }
            }
            else if (base.SelThing is Building_RepairStation)
            {
                Building_RepairStation rps = base.SelThing as Building_RepairStation;
                if (rps != null)
                {
                    pawn = rps.InnerDroid.InnerDroid;
                }
            }
            if (pawn == null)
            {
                Log.Error("Health tab found no selected pawn to display.");
                return;
            }
            Corpse corpse2         = base.SelThing as Corpse;
            bool   showBloodLoss   = corpse2 == null || corpse2.Age < 60000;
            bool   flag            = base.SelThing.def.AllRecipes.Any <RecipeDef>();
            bool   flag2           = !pawn.RaceProps.Humanlike && pawn.Downed;
            bool   allowOperations = flag && !pawn.Dead && (pawn.IsColonist || pawn.HostFaction == Faction.OfColony || flag2);
            Rect   outRect         = new Rect(0f, 20f, this.size.x, this.size.y - 20f);

            HealthCardUtility.DrawPawnHealthCard(outRect, pawn, allowOperations, showBloodLoss, base.SelThing);
        }
示例#15
0
        private void FillCard(Rect cardRect)
        {
            switch (this.tab)
            {
            case InfoCardTab.Stats:
                this.DrawStatsWorker(cardRect);
                break;

            case InfoCardTab.Health:
                cardRect.yMin += 8f;
                HealthCardUtility.DrawPawnHealthCard(cardRect, (Pawn)this.thing, false, false, null);
                break;

            case InfoCardTab.Records:
                RecordsCardUtility.DrawRecordsCard(cardRect, (Pawn)this.thing);
                break;
            }
        }
示例#16
0
 private static bool Method_Prefix(Rect outRect, Pawn pawn, bool allowOperations, bool showBloodLoss, Thing thingForMedBills)
 {
     if (pawn.Dead)
     {
         allowOperations = true;
         outRect         = outRect.Rounded();
         Rect rect  = new Rect(outRect.x, outRect.y, outRect.width * 0.375f, 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);
         return(false);
     }
     else
     {
         return(true);
     }
 }
示例#17
0
        public override void DoWindowContents(Rect rect)
        {
            base.DrawPageTitle(rect);
            Rect mainRect = base.GetMainRect(rect, 30f, false);

            Widgets.DrawMenuSection(mainRect, true);
            TabDrawer.DrawTabs(mainRect, from c in Find.GameInitData.startingPawns
                               select new TabRecord(c.LabelCap, delegate
            {
                this.SelectPawn(c);
            }, c == this.curPawn));
            Rect rect2 = mainRect.ContractedBy(17f);
            Rect rect3 = rect2;

            rect3.width = 100f;
            GUI.DrawTexture(new Rect(rect3.xMin + (rect3.width - Page_ConfigureStartingSlaves.PawnPortraitSize.x) / 2f - 10f, rect3.yMin + 20f, Page_ConfigureStartingSlaves.PawnPortraitSize.x, Page_ConfigureStartingSlaves.PawnPortraitSize.y), PortraitsCache.Get(this.curPawn, Page_ConfigureStartingSlaves.PawnPortraitSize, default(Vector3), 1f));
            Rect rect4 = rect2;

            rect4.xMin = rect3.xMax;
            Rect rect5 = rect4;

            rect5.width = 475f;
            CharacterCardUtility.DrawCharacterCard(rect5, this.curPawn, new Action(this.RandomizeCurPawn));
            Rect rect6 = new Rect(rect5.xMax + 5f, rect4.y + 100f, rect4.width - rect5.width - 5f, 200f);

            Text.Font = GameFont.Medium;
            Widgets.Label(rect6, "Health".Translate());
            Text.Font   = GameFont.Small;
            rect6.yMin += 35f;
            HealthCardUtility.DrawHediffListing(rect6, this.curPawn, true);
            Rect rect7 = new Rect(rect6.x, rect6.yMax, rect6.width, 200f);

            Text.Font = GameFont.Medium;
            Widgets.Label(rect7, "Relations".Translate());
            Text.Font   = GameFont.Small;
            rect7.yMin += 35f;
            SocialCardUtility.DrawRelationsAndOpinions(rect7, this.curPawn);
            base.DoBottomButtons(rect, "Next".Translate(), null, null, true);
        }
        public override void DoWindowContents(Rect rect)
        {
            DrawPageTitle(rect);
            var mainRect = GetMainRect(rect, 30f);

            Widgets.DrawMenuSection(mainRect);
            TabDrawer.DrawTabs(mainRect, (from c in Find.GameInitData.startingAndOptionalPawns
                                          select new TabRecord(c.LabelCap, delegate { SelectPawn(c); }, c == curPawn)).ToList());
            var rect2 = mainRect.ContractedBy(17f);
            var rect3 = rect2;

            rect3.width = 100f;
            GUI.DrawTexture(
                new Rect(rect3.xMin + ((rect3.width - PawnPortraitSize.x) / 2f) - 10f, rect3.yMin + 20f,
                         PawnPortraitSize.x, PawnPortraitSize.y), PortraitsCache.Get(curPawn, PawnPortraitSize, Rot4.South));
            var rect4 = rect2;

            rect4.xMin = rect3.xMax;
            var rect5 = rect4;

            rect5.width = 475f;
            CharacterCardUtility.DrawCharacterCard(rect5, curPawn, RandomizeCurPawn);
            var rect6 = new Rect(rect5.xMax + 5f, rect4.y + 100f, rect4.width - rect5.width - 5f, 200f);

            Text.Font = GameFont.Medium;
            Widgets.Label(rect6, "Health".Translate());
            Text.Font   = GameFont.Small;
            rect6.yMin += 35f;
            HealthCardUtility.DrawHediffListing(rect6, curPawn, true);
            var rect7 = new Rect(rect6.x, rect6.yMax, rect6.width, 200f);

            Text.Font = GameFont.Medium;
            Widgets.Label(rect7, "Relations".Translate());
            Text.Font   = GameFont.Small;
            rect7.yMin += 35f;
            SocialCardUtility.DrawRelationsAndOpinions(rect7, curPawn);
            DoBottomButtons(rect, "Next".Translate());
        }
        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);
        }
示例#20
0
 protected void FillCard(Rect cardRect)
 {
     if (this.tab == Dialog_InfoCard.InfoCardTab.Stats)
     {
         if (this.thing != null)
         {
             Thing         innerThing    = this.thing;
             MinifiedThing minifiedThing = this.thing as MinifiedThing;
             if (minifiedThing != null)
             {
                 innerThing = minifiedThing.InnerThing;
             }
             StatsReportUtility.DrawStatsReport(cardRect, innerThing);
         }
         else if (this.worldObject != null)
         {
             StatsReportUtility.DrawStatsReport(cardRect, this.worldObject);
         }
         else
         {
             StatsReportUtility.DrawStatsReport(cardRect, this.def, this.stuff);
         }
     }
     else if (this.tab == Dialog_InfoCard.InfoCardTab.Character)
     {
         CharacterCardUtility.DrawCharacterCard(cardRect, (Pawn)this.thing, null, default(Rect));
     }
     else if (this.tab == Dialog_InfoCard.InfoCardTab.Health)
     {
         cardRect.yMin += 8f;
         HealthCardUtility.DrawPawnHealthCard(cardRect, (Pawn)this.thing, false, false, null);
     }
     else if (this.tab == Dialog_InfoCard.InfoCardTab.Records)
     {
         RecordsCardUtility.DrawRecordsCard(cardRect, (Pawn)this.thing);
     }
 }
示例#21
0
 protected void FillCard(Rect cardRect)
 {
     if (tab == InfoCardTab.Stats)
     {
         if (thing != null)
         {
             Thing         innerThing    = thing;
             MinifiedThing minifiedThing = thing as MinifiedThing;
             if (minifiedThing != null)
             {
                 innerThing = minifiedThing.InnerThing;
             }
             StatsReportUtility.DrawStatsReport(cardRect, innerThing);
         }
         else if (worldObject != null)
         {
             StatsReportUtility.DrawStatsReport(cardRect, worldObject);
         }
         else
         {
             StatsReportUtility.DrawStatsReport(cardRect, def, stuff);
         }
     }
     else if (tab == InfoCardTab.Character)
     {
         CharacterCardUtility.DrawCharacterCard(cardRect, (Pawn)thing);
     }
     else if (tab == InfoCardTab.Health)
     {
         cardRect.yMin += 8f;
         HealthCardUtility.DrawPawnHealthCard(cardRect, (Pawn)thing, allowOperations: false, showBloodLoss: false, null);
     }
     else if (tab == InfoCardTab.Records)
     {
         RecordsCardUtility.DrawRecordsCard(cardRect, (Pawn)thing);
     }
 }
示例#22
0
        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;
            }
        }
示例#23
0
 public void DrawAdwanceMod()
 {
     GUI.color = Color.gray;
     Widgets.DrawLineHorizontal(20f, AdvancedMode_Rect.y, AdvancedMode_Rect.x - 40f);
     HealthCardUtility.DrawHediffListing(new Rect(20f, 30f, AdvancedMode_Rect.x - 40f, AdvancedMode_Rect.y), localSelPawn, true);
 }
示例#24
0
        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;
            }
        }
示例#25
0
        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 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;
 }
 protected override string GetTip(Pawn pawn)
 => HealthCardUtility.GetPawnCapacityTip(pawn, def.Ext().capacity);
 public override void DoCell(Rect rect, Pawn pawn, PawnTable table)
 {
     GUI.color = HealthCardUtility.GetPainLabel(pawn).Second;
     base.DoCell(rect, pawn, table);
     GUI.color = Color.white;
 }
示例#29
0
        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;
            }
        }
示例#30
0
        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());
        }