예제 #1
0
        public static void TryAbandonOrBanishViaInterface(TransferableImmutable t, Caravan caravan)
        {
            Pawn pawn = t.AnyThing as Pawn;

            if (pawn != null)
            {
                TryAbandonOrBanishViaInterface(pawn, caravan);
                return;
            }
            Dialog_MessageBox window = Dialog_MessageBox.CreateConfirmation("ConfirmAbandonItemDialog".Translate(t.LabelWithTotalStackCount), delegate
            {
                for (int i = 0; i < t.things.Count; i++)
                {
                    Thing thing  = t.things[i];
                    Pawn ownerOf = CaravanInventoryUtility.GetOwnerOf(caravan, thing);
                    if (ownerOf == null)
                    {
                        Log.Error("Could not find owner of " + thing);
                        return;
                    }
                    ownerOf.inventory.innerContainer.Remove(thing);
                    thing.Destroy();
                }
                caravan.RecacheImmobilizedNow();
                caravan.RecacheDaysWorthOfFood();
            }, destructive: true);

            Find.WindowStack.Add(window);
        }
예제 #2
0
        private static void DoRow(Rect rect, TransferableImmutable thing, Caravan caravan)
        {
            GUI.BeginGroup(rect);
            Rect rect2 = rect.AtZero();

            if (thing.TotalStackCount != 1)
            {
                CaravanThingsTabUtility.DoAbandonSpecificCountButton(rect2, thing, caravan);
            }
            rect2.width -= 24f;
            CaravanThingsTabUtility.DoAbandonButton(rect2, thing, caravan);
            rect2.width -= 24f;
            Widgets.InfoCardButton(rect2.width - 24f, (rect.height - 24f) / 2f, thing.AnyThing);
            rect2.width -= 24f;
            Rect rect3 = rect2;

            rect3.xMin = rect3.xMax - 60f;
            CaravanThingsTabUtility.DrawMass(thing, rect3);
            rect2.width -= 60f;
            Widgets.DrawHighlightIfMouseover(rect2);
            Rect rect4 = new Rect(4f, (rect.height - 27f) / 2f, 27f, 27f);

            Widgets.ThingIcon(rect4, thing.AnyThing, 1f);
            Rect rect5 = new Rect(rect4.xMax + 4f, 0f, 300f, 30f);

            Text.Anchor   = TextAnchor.MiddleLeft;
            Text.WordWrap = false;
            Widgets.Label(rect5, thing.LabelCapWithTotalStackCount.Truncate(rect5.width, null));
            Text.Anchor   = TextAnchor.UpperLeft;
            Text.WordWrap = true;
            GUI.EndGroup();
        }
예제 #3
0
 public static void TryAbandonSpecificCountViaInterface(TransferableImmutable t, Caravan caravan)
 {
     Find.WindowStack.Add(new Dialog_Slider("AbandonSliderText".Translate(t.Label), 1, t.TotalStackCount, delegate(int x)
     {
         int num = x;
         for (int i = 0; i < t.things.Count; i++)
         {
             if (num <= 0)
             {
                 break;
             }
             Thing thing  = t.things[i];
             Pawn ownerOf = CaravanInventoryUtility.GetOwnerOf(caravan, thing);
             if (ownerOf == null)
             {
                 Log.Error("Could not find owner of " + thing);
                 return;
             }
             if (num >= thing.stackCount)
             {
                 num -= thing.stackCount;
                 ownerOf.inventory.innerContainer.Remove(thing);
                 thing.Destroy();
             }
             else
             {
                 thing.SplitOff(num).Destroy();
                 num = 0;
             }
         }
         caravan.RecacheImmobilizedNow();
         caravan.RecacheDaysWorthOfFood();
     }));
 }
        private void CacheItems()
        {
            this.CheckCreateSorters();
            this.cachedItems.Clear();
            List <Thing> list = CaravanInventoryUtility.AllInventoryItems(base.SelCaravan);
            int          seed = 0;

            for (int i = 0; i < list.Count; i++)
            {
                TransferableImmutable transferableImmutable = TransferableUtility.TransferableMatching <TransferableImmutable>(list[i], this.cachedItems, TransferAsOneMode.Normal);
                if (transferableImmutable == null)
                {
                    transferableImmutable = new TransferableImmutable();
                    this.cachedItems.Add(transferableImmutable);
                }
                transferableImmutable.things.Add(list[i]);
                seed = Gen.HashCombineInt(seed, list[i].GetHashCode());
            }
            IOrderedEnumerable <TransferableImmutable> source = this.cachedItems.OrderBy((TransferableImmutable tr) => tr, this.sorter1.Comparer).ThenBy((TransferableImmutable tr) => tr, this.sorter2.Comparer);

            if (WITab_Caravan_Items.< > f__mg$cache0 == null)
            {
                WITab_Caravan_Items.< > f__mg$cache0 = new Func <TransferableImmutable, float>(TransferableUIUtility.DefaultListOrderPriority);
            }
            this.cachedItems      = source.ThenBy(WITab_Caravan_Items.< > f__mg$cache0).ToList <TransferableImmutable>();
            this.cachedItemsCount = list.Count;
            this.cachedItemsHash  = seed;
        }
        public static void DrawMass(TransferableImmutable transferable, Rect rect)
        {
            float num = 0f;

            for (int i = 0; i < transferable.things.Count; i++)
            {
                num += transferable.things[i].GetStatValue(StatDefOf.Mass, true) * (float)transferable.things[i].stackCount;
            }
            CaravanThingsTabUtility.DrawMass(num, rect);
        }
        public static void DoAbandonSpecificCountButton(Rect rowRect, TransferableImmutable t, Caravan caravan)
        {
            Rect rect = new Rect(rowRect.width - 24f, (rowRect.height - 24f) / 2f, 24f, 24f);

            if (Widgets.ButtonImage(rect, CaravanThingsTabUtility.AbandonSpecificCountButtonTex))
            {
                CaravanAbandonOrBanishUtility.TryAbandonSpecificCountViaInterface(t, caravan);
            }
            TooltipHandler.TipRegion(rect, () => CaravanAbandonOrBanishUtility.GetAbandonOrBanishButtonTooltip(t, true), Gen.HashCombineInt(t.GetHashCode(), 1163428609));
        }
            private static void DoRenameFloatMenuButton(ref Rect rect2, Rect rect, TransferableImmutable thing)
            {
                rect2.width -= 24;
                var renamableComp = thing.AnyThing.TryGetComp <CompRenamable>();

                if (renamableComp != null && Widgets.ButtonImage(new Rect(rect2.width - 24, rect.height - 24, 24, 24), TexButton.RenameTex))
                {
                    Find.WindowStack.Add(new FloatMenu(RenameUtility.CaravanRenameThingButtonFloatMenuOptions(renamableComp).ToList()));
                }
            }
예제 #8
0
        public static string GetAbandonOrBanishButtonTooltip(TransferableImmutable t, bool abandonSpecificCount)
        {
            Pawn pawn = t.AnyThing as Pawn;

            if (pawn != null)
            {
                return(PawnBanishUtility.GetBanishButtonTip(pawn));
            }
            return(GetAbandonItemButtonTooltip(t.TotalStackCount, abandonSpecificCount));
        }
예제 #9
0
        public static void DoAbandonButton(Rect rowRect, TransferableImmutable t, Caravan caravan)
        {
            Rect rect = new Rect(rowRect.width - 24f, (rowRect.height - 24f) / 2f, 24f, 24f);

            if (Widgets.ButtonImage(rect, AbandonButtonTex))
            {
                CaravanAbandonOrBanishUtility.TryAbandonOrBanishViaInterface(t, caravan);
            }
            if (Mouse.IsOver(rect))
            {
                TooltipHandler.TipRegion(rect, () => CaravanAbandonOrBanishUtility.GetAbandonOrBanishButtonTooltip(t, abandonSpecificCount: false), Gen.HashCombineInt(t.GetHashCode(), 8476546));
            }
        }
예제 #10
0
        private void CacheItems()
        {
            CheckCreateSorters();
            cachedItems.Clear();
            List <Thing> list = CaravanInventoryUtility.AllInventoryItems(base.SelCaravan);
            int          seed = 0;

            for (int i = 0; i < list.Count; i++)
            {
                TransferableImmutable transferableImmutable = TransferableUtility.TransferableMatching(list[i], cachedItems, TransferAsOneMode.Normal);
                if (transferableImmutable == null)
                {
                    transferableImmutable = new TransferableImmutable();
                    cachedItems.Add(transferableImmutable);
                }
                transferableImmutable.things.Add(list[i]);
                seed = Gen.HashCombineInt(seed, list[i].GetHashCode());
            }
            cachedItems = cachedItems.OrderBy((TransferableImmutable tr) => tr, sorter1.Comparer).ThenBy((TransferableImmutable tr) => tr, sorter2.Comparer).ThenBy(TransferableUIUtility.DefaultListOrderPriority)
                          .ToList();
            cachedItemsCount = list.Count;
            cachedItemsHash  = seed;
        }
예제 #11
0
        private static void DoRow(ref float curY, Rect viewRect, Rect scrollOutRect, Vector2 scrollPosition, TransferableImmutable thing, Caravan caravan)
        {
            float num  = scrollPosition.y - 30f;
            float num2 = scrollPosition.y + scrollOutRect.height;

            if (curY > num && curY < num2)
            {
                CaravanItemsTabUtility.DoRow(new Rect(0f, curY, viewRect.width, 30f), thing, caravan);
            }
            curY += 30f;
        }
 private static float <CacheItems> m__4(TransferableImmutable tr)
 {
     return(TransferableUIUtility.DefaultListOrderPriority(tr));
 }
 private static Transferable <CacheItems> m__3(TransferableImmutable tr)
 {
     return(tr);
 }