Example #1
0
        public float DrawOverviewTab(Rect leftRect, Pawn pawn, float curY, bool showBloodLoss)
        {
            curY     += TabDrawer.DrawHeader(0f, curY, leftRect.width, "EdB.Status".Translate(), true, TextAnchor.UpperLeft);
            curY     += 4f;
            Text.Font = GameFont.Small;
            float bleedingRate = pawn.health.hediffSet.BleedingRate;

            if ((double)bleedingRate > 0.01)
            {
                string rightLabel = string.Concat(new string[]
                {
                    bleedingRate.ToStringPercent(),
                    "/",
                    "Day".Translate()
                });
                curY = this.DrawLeftRow(leftRect, curY, "BleedingRate".Translate(), rightLabel, HealthCardUtility.GetBleedingRateColor(bleedingRate), null);
            }
            if (pawn.def.race.isFlesh)
            {
                Pair <string, Color> painLabel = RimWorld.HealthCardUtility.GetPainLabel(pawn);
                string tipLabel = "PainLevel".Translate() + ": " + (pawn.health.hediffSet.Pain * 100f).ToString("F0") + "%";
                curY = this.DrawLeftRow(leftRect, curY, "PainLevel".Translate(), painLabel.First, painLabel.Second, tipLabel);
            }
            if (!pawn.Dead)
            {
                IEnumerable <PawnCapacityDef> source;
                if (pawn.def.race.Humanlike)
                {
                    source = from x in DefDatabase <PawnCapacityDef> .AllDefs
                             where x.showOnHumanlikes
                             select x;
                }
                else if (pawn.def.race.Animal)
                {
                    source = from x in DefDatabase <PawnCapacityDef> .AllDefs
                             where x.showOnAnimals
                             select x;
                }
                else
                {
                    source = from x in DefDatabase <PawnCapacityDef> .AllDefs
                             where x.showOnMechanoids
                             select x;
                }
                foreach (PawnCapacityDef current in from act in source
                         orderby act.listOrder
                         select act)
                {
                    if (PawnCapacityUtility.BodyCanEverDoActivity(pawn.RaceProps.body, current))
                    {
                        Pair <string, Color> efficiencyLabel = RimWorld.HealthCardUtility.GetEfficiencyLabel(pawn, current);
                        string tipLabel2 = "Efficiency".Translate() + ": " + (pawn.health.capacities.GetEfficiency(current) * 100f).ToString("F0") + "%";
                        curY = this.DrawLeftRow(leftRect, curY, current.GetLabelFor(pawn.RaceProps.isFlesh, pawn.RaceProps.Humanlike).CapitalizeFirst(), efficiencyLabel.First, efficiencyLabel.Second, tipLabel2);
                    }
                }
            }
            curY += 16f;
            curY += TabDrawer.DrawHeader(0f, curY, leftRect.width, "EdB.Injuries".Translate(), true, TextAnchor.UpperLeft);
            curY += 4f;
            Rect position = new Rect(leftRect.x, curY, leftRect.width, leftRect.height - curY);

            GUI.BeginGroup(position);
            Rect outRect  = new Rect(0f, 0f, position.width, position.height);
            Rect viewRect = new Rect(0f, 0f, position.width - 16f, HealthCardUtility.scrollViewHeight);
            Rect rect     = new Rect(position.x, position.y, position.width - 16f, position.height);

            GUI.color = Color.white;
            Widgets.BeginScrollView(outRect, ref HealthCardUtility.scrollPosition, viewRect);
            float num = 0f;

            HealthCardUtility.highlight = true;
            bool flag = false;

            foreach (IGrouping <BodyPartRecord, Hediff> current2 in ((IEnumerable <IGrouping <BodyPartRecord, Hediff> >) this.visibleHediffGroupsInOrderMethod.Invoke(null, new object[]
            {
                pawn,
                showBloodLoss
            })))
            {
                flag = true;
                this.DrawHediffRow(rect, pawn, current2, ref num);
            }
            if (!flag)
            {
                GUI.color   = Color.gray;
                Text.Anchor = TextAnchor.UpperCenter;
                Widgets.Label(new Rect(0f, 0f, position.width, 30f), new GUIContent("NoInjuries".Translate()));
                Text.Anchor = TextAnchor.UpperLeft;
            }
            if (Event.current.type == EventType.Layout)
            {
                HealthCardUtility.scrollViewHeight = num;
            }
            Widgets.EndScrollView();
            GUI.EndGroup();
            GUI.color = Color.white;
            return(curY);
        }
Example #2
0
        public void DrawHediffRow(Rect rect, Pawn pawn, IEnumerable <Hediff> diffs, ref float curY)
        {
            float num   = 6f;
            float num2  = rect.width * 0.4f;
            float width = rect.width - num2 - 20f;

            num2 -= num;
            float a;

            if (diffs.First <Hediff>().Part == null)
            {
                a = Text.CalcHeight("WholeBody".Translate(), num2);
            }
            else
            {
                a = Text.CalcHeight(diffs.First <Hediff>().Part.def.LabelCap, num2);
            }
            float b    = 0f;
            float num3 = curY;
            float num4 = 0f;

            foreach (IGrouping <int, Hediff> current in from x in diffs
                     group x by x.UIGroupKey)
            {
                int    num5 = current.Count <Hediff>();
                string text = current.First <Hediff>().LabelCap;
                if (num5 != 1)
                {
                    text = text + " x" + num5.ToString();
                }
                num4 += Text.CalcHeight(text, width);
            }
            b = num4;
            Rect rect2 = new Rect(0f, curY, rect.width, Mathf.Max(a, b));

            HealthCardUtility.DoRightRowHighlight(rect2);
            StringBuilder stringBuilder = new StringBuilder();

            if (diffs.First <Hediff>().Part != null)
            {
                stringBuilder.Append(diffs.First <Hediff>().Part.def.LabelCap + ": ");
                GUI.color = HealthUtility.GetPartConditionLabel(pawn, diffs.First <Hediff>().Part).Second;
                Widgets.Label(new Rect(num, curY + 1f, num2, 100f), new GUIContent(diffs.First <Hediff>().Part.def.LabelCap));
                stringBuilder.Append(" " + pawn.health.hediffSet.GetPartHealth(diffs.First <Hediff>().Part).ToString() + " / " + diffs.First <Hediff>().Part.def.GetMaxHealth(pawn).ToString());
            }
            else
            {
                stringBuilder.Append("WholeBody".Translate());
                GUI.color = HealthUtility.DarkRedColor;
                Widgets.Label(new Rect(num, curY + 1f, num2, 100f), new GUIContent("WholeBody".Translate()));
            }
            GUI.color = Color.white;
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("------------------");
            foreach (IGrouping <int, Hediff> current2 in from x in diffs
                     group x by x.UIGroupKey)
            {
                Hediff    hediff    = current2.First <Hediff>();
                int       num6      = 0;
                bool      flag      = false;
                Texture2D texture2D = null;
                foreach (Hediff current3 in current2)
                {
                    num6++;
                    Hediff_Injury hediff_Injury = current3 as Hediff_Injury;
                    if (hediff_Injury != null && hediff_Injury.IsTended() && !hediff_Injury.IsOld())
                    {
                        if (hediff_Injury.IsTendedWell())
                        {
                            texture2D = HealthCardUtility.TreatedWellIcon;
                        }
                        else
                        {
                            texture2D = HealthCardUtility.TreatedPoorIcon;
                        }
                    }
                    float bleedRate = current3.BleedRate;
                    if ((double)bleedRate > 1E-05)
                    {
                        flag = true;
                    }
                    bool   flag2       = HealthCardUtility.showHediffsDebugInfo && !current3.DebugString.NullOrEmpty();
                    string damageLabel = current3.DamageLabel;
                    if (!current3.Label.NullOrEmpty() || !damageLabel.NullOrEmpty() || !current3.CapMods.NullOrEmpty <PawnCapacityModifier>() || flag2)
                    {
                        stringBuilder.Append(current3.LabelCap);
                        if (!damageLabel.NullOrEmpty())
                        {
                            stringBuilder.Append(": " + damageLabel);
                        }
                        stringBuilder.AppendLine();
                        stringBuilder.AppendLine(current3.TipString.TrimEndNewlines().Indented());
                        if (flag2)
                        {
                            stringBuilder.AppendLine(current3.DebugString.TrimEndNewlines().Indented());
                        }
                    }
                }
                string text2 = hediff.LabelCap;
                if (num6 != 1)
                {
                    text2 = text2 + " x" + num6.ToString();
                }
                GUI.color = hediff.LabelColor;
                float num7  = Text.CalcHeight(text2, width);
                Rect  rect3 = new Rect(num + num2, curY + 1f, width, num7);
                Widgets.Label(rect3, text2);
                GUI.color = Color.white;
                Rect position = new Rect(rect2.xMax - 20f, curY, 20f, 20f);
                if (flag)
                {
                    GUI.DrawTexture(position, HealthCardUtility.BleedingIcon);
                }
                if (texture2D != null)
                {
                    GUI.DrawTexture(position, texture2D);
                }
                curY += num7;
            }
            GUI.color = Color.white;
            curY      = num3 + Mathf.Max(a, b);
            TooltipHandler.TipRegion(rect2, new TipSignal(stringBuilder.ToString().TrimEnd(new char[0]), (int)curY + 7857));
        }
Example #3
0
        public float DrawStatus(Rect leftRect, Pawn pawn, float curY, bool showBloodLoss)
        {
            Text.Font = GameFont.Small;
            float bleedingRate = pawn.health.hediffSet.BleedingRate;

            if ((double)bleedingRate > 0.01)
            {
                string rightLabel = string.Concat(new string[]
                {
                    bleedingRate.ToStringPercent(),
                    "/",
                    "Day".Translate()
                });
                curY = this.DrawLeftRow(leftRect, curY, "BleedingRate".Translate(), rightLabel, HealthCardUtility.GetBleedingRateColor(bleedingRate), null);
            }
            if (pawn.def.race.isFlesh)
            {
                Pair <string, Color> painLabel = RimWorld.HealthCardUtility.GetPainLabel(pawn);
                string tipLabel = "PainLevel".Translate() + ": " + (pawn.health.hediffSet.Pain * 100f).ToString("F0") + "%";
                curY = this.DrawLeftRow(leftRect, curY, "PainLevel".Translate(), painLabel.First, painLabel.Second, tipLabel);
            }
            if (!pawn.Dead)
            {
                IEnumerable <PawnCapacityDef> source;
                if (pawn.def.race.Humanlike)
                {
                    source = from x in DefDatabase <PawnCapacityDef> .AllDefs
                             where x.showOnHumanlikes
                             select x;
                }
                else if (pawn.def.race.Animal)
                {
                    source = from x in DefDatabase <PawnCapacityDef> .AllDefs
                             where x.showOnAnimals
                             select x;
                }
                else
                {
                    source = from x in DefDatabase <PawnCapacityDef> .AllDefs
                             where x.showOnMechanoids
                             select x;
                }
                foreach (PawnCapacityDef current in from act in source
                         orderby act.listOrder
                         select act)
                {
                    if (PawnCapacityUtility.BodyCanEverDoActivity(pawn.RaceProps.body, current))
                    {
                        Pair <string, Color> efficiencyLabel = RimWorld.HealthCardUtility.GetEfficiencyLabel(pawn, current);
                        string tipLabel2 = "Efficiency".Translate() + ": " + (pawn.health.capacities.GetEfficiency(current) * 100f).ToString("F0") + "%";
                        curY = this.DrawLeftRow(leftRect, curY, current.GetLabelFor(pawn.RaceProps.isFlesh, pawn.RaceProps.Humanlike).CapitalizeFirst(), efficiencyLabel.First, efficiencyLabel.Second, tipLabel2);
                    }
                }
            }
            return(curY);
        }