Example #1
0
        private static void DoRow(ref float curY, Rect viewRect, Rect scrollOutRect, Vector2 scrollPosition, Thing thing, Caravan caravan, ref Pawn specificNeedsTabForPawn, bool doNeeds, bool listingUsesAbandonSpecificCountButtons)
        {
            float num  = (float)((!(thing is Pawn)) ? 30.0 : 50.0);
            float num2 = scrollPosition.y - num;
            float num3 = scrollPosition.y + scrollOutRect.height;

            if (curY > num2 && curY < num3)
            {
                CaravanPeopleAndItemsTabUtility.DoRow(new Rect(0f, curY, viewRect.width, num), thing, caravan, ref specificNeedsTabForPawn, doNeeds, listingUsesAbandonSpecificCountButtons);
            }
            curY += num;
        }
Example #2
0
        public static void DoRows(Vector2 size, List <Thing> things, Caravan caravan, ref Vector2 scrollPosition, ref float scrollViewHeight, bool alwaysShowItemsSection, ref Pawn specificNeedsTabForPawn, bool doNeeds = true)
        {
            if (specificNeedsTabForPawn != null && (!things.Contains(specificNeedsTabForPawn) || specificNeedsTabForPawn.Dead))
            {
                specificNeedsTabForPawn = null;
            }
            Text.Font = GameFont.Small;
            Rect rect     = new Rect(0f, 0f, size.x, size.y).ContractedBy(10f);
            Rect viewRect = new Rect(0f, 0f, (float)(rect.width - 16.0), scrollViewHeight);
            bool listingUsesAbandonSpecificCountButtons = CaravanPeopleAndItemsTabUtility.AnyItemOrEmpty(things);

            Widgets.BeginScrollView(rect, ref scrollPosition, viewRect, true);
            float num  = 0f;
            bool  flag = false;

            for (int i = 0; i < things.Count; i++)
            {
                Pawn pawn = things[i] as Pawn;
                if (pawn != null && pawn.IsColonist)
                {
                    if (!flag)
                    {
                        Widgets.ListSeparator(ref num, viewRect.width, "CaravanColonists".Translate());
                        flag = true;
                    }
                    CaravanPeopleAndItemsTabUtility.DoRow(ref num, viewRect, rect, scrollPosition, (Thing)pawn, caravan, ref specificNeedsTabForPawn, doNeeds, listingUsesAbandonSpecificCountButtons);
                }
            }
            bool flag2 = false;

            for (int j = 0; j < things.Count; j++)
            {
                Pawn pawn2 = things[j] as Pawn;
                if (pawn2 != null && !pawn2.IsColonist)
                {
                    if (!flag2)
                    {
                        Widgets.ListSeparator(ref num, viewRect.width, "CaravanPrisonersAndAnimals".Translate());
                        flag2 = true;
                    }
                    CaravanPeopleAndItemsTabUtility.DoRow(ref num, viewRect, rect, scrollPosition, (Thing)pawn2, caravan, ref specificNeedsTabForPawn, doNeeds, listingUsesAbandonSpecificCountButtons);
                }
            }
            bool flag3 = false;

            if (alwaysShowItemsSection)
            {
                Widgets.ListSeparator(ref num, viewRect.width, "CaravanItems".Translate());
            }
            for (int k = 0; k < things.Count; k++)
            {
                if (!(things[k] is Pawn))
                {
                    if (!flag3)
                    {
                        if (!alwaysShowItemsSection)
                        {
                            Widgets.ListSeparator(ref num, viewRect.width, "CaravanItems".Translate());
                        }
                        flag3 = true;
                    }
                    CaravanPeopleAndItemsTabUtility.DoRow(ref num, viewRect, rect, scrollPosition, things[k], caravan, ref specificNeedsTabForPawn, doNeeds, listingUsesAbandonSpecificCountButtons);
                }
            }
            if (alwaysShowItemsSection && !flag3)
            {
                GUI.color   = Color.gray;
                Text.Anchor = TextAnchor.UpperCenter;
                Widgets.Label(new Rect(0f, num, viewRect.width, 25f), "NoneBrackets".Translate());
                Text.Anchor = TextAnchor.UpperLeft;
                num         = (float)(num + 25.0);
                GUI.color   = Color.white;
            }
            if (Event.current.type == EventType.Layout)
            {
                scrollViewHeight = (float)(num + 30.0);
            }
            Widgets.EndScrollView();
        }