Esempio n. 1
0
        public static Vector2 GetSize(List <Thing> things, float paneTopY, bool doNeeds = true)
        {
            float a = 0f;

            if (things.Any((Thing x) => x is Pawn))
            {
                a = 100f;
                if (doNeeds)
                {
                    a = (float)(a + (float)CaravanPeopleAndItemsTabUtility.MaxNeedsCount(things) * 100.0);
                }
                a = (float)(a + 24.0);
            }
            float b = 0f;

            if (CaravanPeopleAndItemsTabUtility.AnyItemOrEmpty(things))
            {
                b = 300f;
                b = (float)(b + 24.0);
                b = (float)(b + 60.0);
            }
            Vector2 result = default(Vector2);

            result.x = (float)(103.0 + Mathf.Max(a, b) + 16.0);
            result.y = Mathf.Min(550f, (float)(paneTopY - 30.0));
            return(result);
        }
Esempio n. 2
0
        public static Vector2 GetSize(List <Thing> things, float paneTopY, bool doNeeds = true)
        {
            float num = 0f;

            if (things.Any((Thing x) => x is Pawn))
            {
                num = 100f;
                if (doNeeds)
                {
                    num += (float)CaravanPeopleAndItemsTabUtility.MaxNeedsCount(things) * 100f;
                }
                num += 24f;
            }
            float num2 = 0f;

            if (CaravanPeopleAndItemsTabUtility.AnyItemOrEmpty(things))
            {
                num2  = 300f;
                num2 += 24f;
                num2 += 60f;
            }
            Vector2 result;

            result.x = 103f + Mathf.Max(num, num2) + 16f;
            result.y = Mathf.Min(550f, paneTopY - 30f);
            return(result);
        }
Esempio n. 3
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();
        }