Example #1
0
 public static SSSParameter MakeSSSParameterFromTextureAndColor(TextureAndColor src)
 {
     return(new SSSParameter {
         scatteringMap = src.texture,
         scatteringMapOffset = Vector2.zero,
         scatteringMapScale = Vector2.one,
         scatteringColor = src.color,
     });
 }
Example #2
0
        private static void DrawHediffRow(Rect rect, Pawn pawn, IEnumerable <Hediff> diffs, ref float curY)
        {
            float          num   = rect.width * 0.375f;
            float          width = rect.width - num - lastMaxIconsTotalWidth;
            BodyPartRecord part  = diffs.First().Part;
            float          a     = ((part != null) ? Text.CalcHeight(part.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;
                }
                num4 += Text.CalcHeight(text, width);
            }
            num2 = num4;
            Rect rect2 = new Rect(0f, curY, rect.width, Mathf.Max(a, num2));

            DoRightRowHighlight(rect2);
            if (part != null)
            {
                GUI.color = HealthUtility.GetPartConditionLabel(pawn, part).Second;
                Widgets.Label(new Rect(0f, curY, num, 100f), part.LabelCap);
            }
            else
            {
                GUI.color = HealthUtility.RedColor;
                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       bleedingIcon   = null;
                TextureAndColor stateIcon      = null;
                float           totalBleedRate = 0f;
                foreach (Hediff item3 in item2)
                {
                    if (num6 == 0)
                    {
                        hediff = item3;
                    }
                    stateIcon = item3.StateIcon;
                    if (item3.Bleeding)
                    {
                        bleedingIcon = BleedingIcon;
                    }
                    totalBleedRate += item3.BleedRate;
                    num6++;
                }
                string text2 = hediff.LabelCap;
                if (num6 != 1)
                {
                    text2 = text2 + " x" + num6.ToStringCached();
                }
                GUI.color = hediff.LabelColor;
                float num7  = Text.CalcHeight(text2, width);
                Rect  rect3 = new Rect(num, curY, width, num7);
                Widgets.Label(rect3, text2);
                GUI.color = Color.white;
                Rect iconsRect = new Rect(rect3.x + 10f, rect3.y, rect.width - num - 10f, rect3.height);
                List <GenUI.AnonymousStackElement> list = new List <GenUI.AnonymousStackElement>();
                foreach (HediffDef item4 in item2.Select((Hediff h) => h.def).Distinct())
                {
                    HediffDef localHediffDef = item4;
                    list.Add(new GenUI.AnonymousStackElement
                    {
                        drawer = delegate(Rect r)
                        {
                            float num10 = iconsRect.width - (r.x - iconsRect.x) - 20f;
                            r           = new Rect(iconsRect.x + num10, r.y, 20f, 20f);
                            Widgets.InfoCardButton(r.x, r.y, localHediffDef);
                        },
                        width = 20f
                    });
                }
                if ((bool)bleedingIcon)
                {
                    list.Add(new GenUI.AnonymousStackElement
                    {
                        drawer = delegate(Rect r)
                        {
                            float num9 = iconsRect.width - (r.x - iconsRect.x) - 20f;
                            r          = new Rect(iconsRect.x + num9, r.y, 20f, 20f);
                            GUI.DrawTexture(r.ContractedBy(GenMath.LerpDouble(0f, 0.6f, 5f, 0f, Mathf.Min(totalBleedRate, 1f))), bleedingIcon);
                        },
                        width = 20f
                    });
                }
                if (stateIcon.HasValue)
                {
                    list.Add(new GenUI.AnonymousStackElement
                    {
                        drawer = delegate(Rect r)
                        {
                            float num8 = iconsRect.width - (r.x - iconsRect.x) - 20f;
                            r          = new Rect(iconsRect.x + num8, r.y, 20f, 20f);
                            GUI.color  = stateIcon.Color;
                            GUI.DrawTexture(r, stateIcon.Texture);
                            GUI.color = Color.white;
                        },
                        width = 20f
                    });
                }
                GenUI.DrawElementStack(iconsRect, num7, list, delegate(Rect r, GenUI.AnonymousStackElement obj)
                {
                    obj.drawer(r);
                }, (GenUI.AnonymousStackElement obj) => obj.width);
                lastMaxIconsTotalWidth = Mathf.Max(lastMaxIconsTotalWidth, list.Sum((GenUI.AnonymousStackElement x) => x.width + 5f) - 5f);
                curY += num7;
            }
            GUI.color = Color.white;
            curY      = num3 + Mathf.Max(a, num2);
            if (Widgets.ButtonInvisible(rect2, CanEntryBeClicked(diffs, pawn)))
            {
                EntryClicked(diffs, pawn);
            }
            if (Mouse.IsOver(rect2))
            {
                TooltipHandler.TipRegion(rect2, new TipSignal(() => GetTooltip(diffs, pawn, part), (int)curY + 7857));
            }
        }
Example #3
0
        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));
        }