Esempio n. 1
0
        private static void DrawStatsWorker(Rect rect, Thing optionalThing, WorldObject optionalWorldObject)
        {
            Rect rect2 = new Rect(rect);

            rect2.width *= 0.5f;
            Rect rect3 = new Rect(rect);

            rect3.x     = rect2.xMax;
            rect3.width = rect.xMax - rect3.x;
            Text.Font   = GameFont.Small;
            Rect viewRect = new Rect(0f, 0f, rect2.width - 16f, listHeight);

            Widgets.BeginScrollView(rect2, ref scrollPosition, viewRect);
            float  curY = 0f;
            string b    = null;

            mousedOverEntry = null;
            for (int i = 0; i < cachedDrawEntries.Count; i++)
            {
                StatDrawEntry ent = cachedDrawEntries[i];
                if ((string)ent.category.LabelCap != b)
                {
                    Widgets.ListSeparator(ref curY, viewRect.width, ent.category.LabelCap);
                    b = ent.category.LabelCap;
                }
                curY += ent.Draw(8f, curY, viewRect.width - 8f, selectedEntry == ent, delegate
                {
                    SelectEntry(ent);
                }, delegate
                {
                    mousedOverEntry = ent;
                }, scrollPosition, rect2);
            }
            listHeight = curY + 100f;
            Widgets.EndScrollView();
            Rect          outRect       = rect3.ContractedBy(10f);
            StatDrawEntry statDrawEntry = selectedEntry ?? mousedOverEntry ?? cachedDrawEntries.FirstOrDefault();

            if (statDrawEntry != null)
            {
                Rect        rect4           = new Rect(0f, 0f, outRect.width - 16f, rightPanelHeight);
                StatRequest statRequest     = statDrawEntry.hasOptionalReq ? statDrawEntry.optionalReq : ((optionalThing == null) ? StatRequest.ForEmpty() : StatRequest.For(optionalThing));
                string      explanationText = statDrawEntry.GetExplanationText(statRequest);
                float       num             = 0f;
                Widgets.BeginScrollView(outRect, ref scrollPositionRightPanel, rect4);
                Rect rect5 = rect4;
                rect5.width -= 4f;
                Widgets.Label(rect5, explanationText);
                float num2 = Text.CalcHeight(explanationText, rect5.width) + 10f;
                num += num2;
                IEnumerable <Dialog_InfoCard.Hyperlink> hyperlinks = statDrawEntry.GetHyperlinks(statRequest);
                if (hyperlinks != null)
                {
                    Rect  rect6 = new Rect(rect5.x, rect5.y + num2, rect5.width, rect5.height - num2);
                    Color color = GUI.color;
                    GUI.color = Widgets.NormalOptionColor;
                    foreach (Dialog_InfoCard.Hyperlink item in hyperlinks)
                    {
                        float num3 = Text.CalcHeight(item.Label, rect6.width);
                        Widgets.HyperlinkWithIcon(new Rect(rect6.x, rect6.y, rect6.width, num3), item, "ViewHyperlink".Translate(item.Label));
                        rect6.y      += num3;
                        rect6.height -= num3;
                        num          += num3;
                    }
                    GUI.color = color;
                }
                rightPanelHeight = num;
                Widgets.EndScrollView();
            }
        }