Example #1
0
        public static void DrawRelationsAndOpinions(Rect rect, Pawn selPawnForSocialInfo)
        {
            SocialCardUtility.CheckRecache(selPawnForSocialInfo);
            if (Current.ProgramState != ProgramState.Playing)
            {
                SocialCardUtility.showAllRelations = false;
            }
            GUI.BeginGroup(rect);
            Text.Font = GameFont.Small;
            GUI.color = Color.white;
            Rect outRect  = new Rect(0f, 0f, rect.width, rect.height);
            Rect viewRect = new Rect(0f, 0f, rect.width - 16f, SocialCardUtility.listScrollViewHeight);
            Rect rect2    = rect;

            if (viewRect.height > outRect.height)
            {
                rect2.width -= 16f;
            }
            Widgets.BeginScrollView(outRect, ref SocialCardUtility.listScrollPosition, viewRect, true);
            float num  = 0f;
            float y    = SocialCardUtility.listScrollPosition.y;
            float num2 = SocialCardUtility.listScrollPosition.y + outRect.height;

            for (int i = 0; i < SocialCardUtility.cachedEntries.Count; i++)
            {
                float rowHeight = SocialCardUtility.GetRowHeight(SocialCardUtility.cachedEntries[i], rect2.width, selPawnForSocialInfo);
                if (num > y - rowHeight && num < num2)
                {
                    SocialCardUtility.DrawPawnRow(num, rect2.width, SocialCardUtility.cachedEntries[i], selPawnForSocialInfo);
                }
                num += rowHeight;
            }
            if (!SocialCardUtility.cachedEntries.Any <SocialCardUtility.CachedSocialTabEntry>())
            {
                GUI.color   = Color.gray;
                Text.Anchor = TextAnchor.UpperCenter;
                Rect rect3 = new Rect(0f, 0f, rect2.width, 30f);
                Widgets.Label(rect3, "NoRelationships".Translate());
                Text.Anchor = TextAnchor.UpperLeft;
            }
            if (Event.current.type == EventType.Layout)
            {
                SocialCardUtility.listScrollViewHeight = num + 30f;
            }
            Widgets.EndScrollView();
            GUI.EndGroup();
            GUI.color = Color.white;
        }