コード例 #1
0
 protected override void UpdateSize()
 {
     base.UpdateSize();
     this.UpdateItemsList();
     this.size = CaravanPeopleAndItemsTabUtility.GetSize(this.items, this.PaneTopY, true);
     this.items.Clear();
 }
コード例 #2
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);
        }
コード例 #3
0
        private void DoRow(Rect rect, Pawn p)
        {
            GUI.BeginGroup(rect);
            Rect rect2 = rect.AtZero();

            CaravanPeopleAndItemsTabUtility.DoAbandonButton(rect2, p, base.SelCaravan);
            rect2.width -= 24f;
            Widgets.InfoCardButton(rect2.width - 24f, (rect.height - 24f) / 2f, p);
            rect2.width -= 24f;
            CaravanPeopleAndItemsTabUtility.DoOpenSpecificTabButton(rect2, p, ref this.specificSocialTabForPawn);
            rect2.width -= 24f;
            if (Mouse.IsOver(rect2))
            {
                Widgets.DrawHighlight(rect2);
            }
            Rect rect3 = new Rect(4f, (rect.height - 27f) / 2f, 27f, 27f);

            Widgets.ThingIcon(rect3, p, 1f);
            Rect bgRect = new Rect(rect3.xMax + 4f, 16f, 100f, 18f);

            GenMapUI.DrawPawnLabel(p, bgRect, 1f, 100f, null, GameFont.Small, false, false);
            if (p.Downed)
            {
                GUI.color = new Color(1f, 0f, 0f, 0.5f);
                Widgets.DrawLineHorizontal(0f, rect.height / 2f, rect.width);
                GUI.color = Color.white;
            }
            GUI.EndGroup();
        }
コード例 #4
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);
        }
コード例 #5
0
        private void DoRow(Rect rect, Pawn p)
        {
            GUI.BeginGroup(rect);
            Rect rect2 = rect.AtZero();

            CaravanPeopleAndItemsTabUtility.DoAbandonButton(rect2, p, base.SelCaravan);
            rect2.width -= 24f;
            Widgets.InfoCardButton(rect2.width - 24f, (rect.height - 24f) / 2f, p);
            rect2.width -= 24f;
            CaravanPeopleAndItemsTabUtility.DoOpenSpecificTabButton(rect2, p, ref this.specificHealthTabForPawn);
            rect2.width -= 24f;
            if (Mouse.IsOver(rect2))
            {
                Widgets.DrawHighlight(rect2);
            }
            Rect rect3 = new Rect(4f, (rect.height - 27f) / 2f, 27f, 27f);

            Widgets.ThingIcon(rect3, p, 1f);
            Rect bgRect = new Rect(rect3.xMax + 4f, 16f, 100f, 18f);

            GenMapUI.DrawPawnLabel(p, bgRect, 1f, 100f, null, GameFont.Small, false, false);
            if (!this.compactMode)
            {
                float num = bgRect.xMax;
                if (p.RaceProps.IsFlesh)
                {
                    Rect rect4 = new Rect(num, 0f, 100f, 50f);
                    this.DoPain(rect4, p);
                }
                List <PawnCapacityDef> list = this.CapacitiesToDisplay;
                for (int i = 0; i < list.Count; i++)
                {
                    num += 100f;
                    Rect rect5 = new Rect(num, 0f, 100f, 50f);
                    if (!p.RaceProps.Humanlike || list[i].showOnHumanlikes)
                    {
                        if (!p.RaceProps.Animal || list[i].showOnAnimals)
                        {
                            if (!p.RaceProps.IsMechanoid || list[i].showOnMechanoids)
                            {
                                if (PawnCapacityUtility.BodyCanEverDoCapacity(p.RaceProps.body, list[i]))
                                {
                                    this.DoCapacity(rect5, p, list[i]);
                                }
                            }
                        }
                    }
                }
            }
            if (p.Downed)
            {
                GUI.color = new Color(1f, 0f, 0f, 0.5f);
                Widgets.DrawLineHorizontal(0f, rect.height / 2f, rect.width);
                GUI.color = Color.white;
            }
            GUI.EndGroup();
        }
コード例 #6
0
        private void DoPawnRow(Rect rect, Pawn p)
        {
            GUI.BeginGroup(rect);
            Rect rect2 = rect.AtZero();

            CaravanPeopleAndItemsTabUtility.DoAbandonButton(rect2, p, base.SelCaravan);
            rect2.width -= 24f;
            Widgets.InfoCardButton(rect2.width - 24f, (rect.height - 24f) / 2f, p);
            rect2.width -= 24f;
            bool flag = this.draggedItem != null && rect2.Contains(Event.current.mousePosition) && this.CurrentWearerOf(this.draggedItem) != p;

            if ((Mouse.IsOver(rect2) && this.draggedItem == null) || flag)
            {
                Widgets.DrawHighlight(rect2);
            }
            if (flag && this.droppedDraggedItem)
            {
                this.TryEquipDraggedItem(p);
                SoundDefOf.TickTiny.PlayOneShotOnCamera(null);
            }
            Rect rect3 = new Rect(4f, (rect.height - 27f) / 2f, 27f, 27f);

            Widgets.ThingIcon(rect3, p, 1f);
            Rect bgRect = new Rect(rect3.xMax + 4f, 16f, 100f, 18f);

            GenMapUI.DrawPawnLabel(p, bgRect, 1f, 100f, null, GameFont.Small, false, false);
            float xMax = bgRect.xMax;

            if (p.equipment != null)
            {
                List <ThingWithComps> allEquipmentListForReading = p.equipment.AllEquipmentListForReading;
                for (int i = 0; i < allEquipmentListForReading.Count; i++)
                {
                    this.DoEquippedGear(allEquipmentListForReading[i], p, ref xMax);
                }
            }
            if (p.apparel != null)
            {
                WITab_Caravan_Gear.tmpApparel.Clear();
                WITab_Caravan_Gear.tmpApparel.AddRange(p.apparel.WornApparel);
                WITab_Caravan_Gear.tmpApparel.SortBy((Apparel x) => (int)x.def.apparel.LastLayer, (Apparel x) => - x.def.apparel.HumanBodyCoverage);
                for (int j = 0; j < WITab_Caravan_Gear.tmpApparel.Count; j++)
                {
                    this.DoEquippedGear(WITab_Caravan_Gear.tmpApparel[j], p, ref xMax);
                }
            }
            if (p.Downed)
            {
                GUI.color = new Color(1f, 0f, 0f, 0.5f);
                Widgets.DrawLineHorizontal(0f, rect.height / 2f, rect.width);
                GUI.color = Color.white;
            }
            GUI.EndGroup();
        }
コード例 #7
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;
        }
コード例 #8
0
        protected override void FillTab()
        {
            float num = 0f;

            this.DrawMassUsage(ref num);
            Rect position = new Rect(0f, num, this.size.x, this.size.y - num);

            GUI.BeginGroup(position);
            this.UpdateItemsList();
            Pawn pawn = null;

            CaravanPeopleAndItemsTabUtility.DoRows(position.size, this.items, base.SelCaravan, ref this.scrollPosition, ref this.scrollViewHeight, true, ref pawn, true);
            this.items.Clear();
            GUI.EndGroup();
        }
コード例 #9
0
        private static int MaxNeedsCount(List <Thing> things)
        {
            int num = 0;

            for (int i = 0; i < things.Count; i++)
            {
                Pawn pawn = things[i] as Pawn;
                if (pawn != null)
                {
                    CaravanPeopleAndItemsTabUtility.GetNeedsToDisplay(pawn, CaravanPeopleAndItemsTabUtility.tmpNeeds);
                    num = Mathf.Max(num, CaravanPeopleAndItemsTabUtility.tmpNeeds.Count);
                }
            }
            return(num);
        }
コード例 #10
0
 protected override void UpdateSize()
 {
     base.UpdateSize();
     this.AddPawnsToTmpThings();
     base.size = CaravanPeopleAndItemsTabUtility.GetSize(WITab_Caravan_Needs.tmpThings, this.PaneTopY, true);
     if (base.size.x + this.SpecificNeedsTabWidth > (float)UI.screenWidth)
     {
         this.doNeeds = false;
         base.size    = CaravanPeopleAndItemsTabUtility.GetSize(WITab_Caravan_Needs.tmpThings, this.PaneTopY, false);
     }
     else
     {
         this.doNeeds = true;
     }
     ref Vector2 size     = ref base.size;
コード例 #11
0
 protected override void UpdateSize()
 {
     base.UpdateSize();
     this.AddPawnsToTmpThings();
     this.size = CaravanPeopleAndItemsTabUtility.GetSize(WITab_Caravan_Needs.tmpThings, this.PaneTopY, true);
     if (this.size.x + this.SpecificNeedsTabWidth > (float)UI.screenWidth)
     {
         this.doNeeds = false;
         this.size    = CaravanPeopleAndItemsTabUtility.GetSize(WITab_Caravan_Needs.tmpThings, this.PaneTopY, false);
     }
     else
     {
         this.doNeeds = true;
     }
     this.size.y = Mathf.Max(this.size.y, NeedsCardUtility.FullSize.y);
     WITab_Caravan_Needs.tmpThings.Clear();
 }
コード例 #12
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();
        }
コード例 #13
0
        private static void DoRow(Rect rect, Thing thing, Caravan caravan, ref Pawn specificNeedsTabForPawn, bool doNeeds, bool listingUsesAbandonSpecificCountButtons)
        {
            GUI.BeginGroup(rect);
            Rect rect2 = rect.AtZero();
            Pawn pawn  = thing as Pawn;

            if (listingUsesAbandonSpecificCountButtons)
            {
                if (thing.stackCount != 1)
                {
                    CaravanPeopleAndItemsTabUtility.DoAbandonSpecificCountButton(rect2, thing, caravan);
                }
                rect2.width -= 24f;
            }
            CaravanPeopleAndItemsTabUtility.DoAbandonButton(rect2, thing, caravan);
            rect2.width -= 24f;
            Widgets.InfoCardButton((float)(rect2.width - 24.0), (float)((rect.height - 24.0) / 2.0), thing);
            rect2.width -= 24f;
            if (pawn != null && !pawn.Dead)
            {
                CaravanPeopleAndItemsTabUtility.DoOpenSpecificTabButton(rect2, pawn, ref specificNeedsTabForPawn);
                rect2.width -= 24f;
            }
            if (pawn == null)
            {
                Rect rect3 = rect2;
                rect3.xMin = (float)(rect3.xMax - 60.0);
                CaravanPeopleAndItemsTabUtility.TryDrawMass(thing, rect3);
                rect2.width -= 60f;
            }
            if (Mouse.IsOver(rect2))
            {
                Widgets.DrawHighlight(rect2);
            }
            Rect rect4 = new Rect(4f, (float)((rect.height - 27.0) / 2.0), 27f, 27f);

            Widgets.ThingIcon(rect4, thing, 1f);
            if (pawn != null)
            {
                Rect bgRect = new Rect((float)(rect4.xMax + 4.0), 16f, 100f, 18f);
                GenMapUI.DrawPawnLabel(pawn, bgRect, 1f, 100f, null, GameFont.Small, false, false);
                if (doNeeds)
                {
                    CaravanPeopleAndItemsTabUtility.GetNeedsToDisplay(pawn, CaravanPeopleAndItemsTabUtility.tmpNeeds);
                    float xMax = bgRect.xMax;
                    for (int i = 0; i < CaravanPeopleAndItemsTabUtility.tmpNeeds.Count; i++)
                    {
                        Need      need = CaravanPeopleAndItemsTabUtility.tmpNeeds[i];
                        int       maxThresholdMarkers = 0;
                        bool      doTooltip           = true;
                        Rect      rect5 = new Rect(xMax, 0f, 100f, 50f);
                        Need_Mood mood  = need as Need_Mood;
                        if (mood != null)
                        {
                            maxThresholdMarkers = 1;
                            doTooltip           = false;
                            TooltipHandler.TipRegion(rect5, new TipSignal(() => CaravanPeopleAndItemsTabUtility.CustomMoodNeedTooltip(mood), rect5.GetHashCode()));
                        }
                        need.DrawOnGUI(rect5, maxThresholdMarkers, 10f, false, doTooltip);
                        xMax = rect5.xMax;
                    }
                }
                if (pawn.Downed)
                {
                    GUI.color = new Color(1f, 0f, 0f, 0.5f);
                    Widgets.DrawLineHorizontal(0f, (float)(rect.height / 2.0), rect.width);
                    GUI.color = Color.white;
                }
            }
            else
            {
                Rect rect6 = new Rect((float)(rect4.xMax + 4.0), 0f, 300f, 30f);
                Text.Anchor   = TextAnchor.MiddleLeft;
                Text.WordWrap = false;
                Widgets.Label(rect6, thing.LabelCap.Truncate(rect6.width, null));
                Text.Anchor   = TextAnchor.UpperLeft;
                Text.WordWrap = true;
            }
            GUI.EndGroup();
        }
コード例 #14
0
 protected override void FillTab()
 {
     this.AddPawnsToTmpThings();
     CaravanPeopleAndItemsTabUtility.DoRows(this.size, WITab_Caravan_Needs.tmpThings, base.SelCaravan, ref this.scrollPosition, ref this.scrollViewHeight, false, ref this.specificNeedsTabForPawn, this.doNeeds);
     WITab_Caravan_Needs.tmpThings.Clear();
 }