protected override void FillTab()
        {
            CheckCreateSorters();
            Rect rect = new Rect(0f, 0f, size.x, size.y);

            if (Widgets.ButtonText(new Rect(rect.x + 10f, rect.y + 10f, 200f, 27f), "AssignDrugPolicies".Translate()))
            {
                Find.WindowStack.Add(new Dialog_AssignCaravanDrugPolicies(base.SelCaravan));
            }
            rect.yMin += 37f;
            GUI.BeginGroup(rect.ContractedBy(10f));
            TransferableUIUtility.DoTransferableSorters(sorter1, sorter2, delegate(TransferableSorterDef x)
            {
                sorter1 = x;
                CacheItems();
            }, delegate(TransferableSorterDef x)
            {
                sorter2 = x;
                CacheItems();
            });
            GUI.EndGroup();
            rect.yMin += 25f;
            GUI.BeginGroup(rect);
            CheckCacheItems();
            CaravanItemsTabUtility.DoRows(rect.size, cachedItems, base.SelCaravan, ref scrollPosition, ref scrollViewHeight);
            GUI.EndGroup();
        }
Exemple #2
0
 public TransferableVehicleWidget(IEnumerable <TransferableOneWay> transferables, string sourceLabel, string destinationLabel, string sourceCountDesc, bool drawMass = false,
                                  IgnorePawnsInventoryMode ignorePawnInventoryMass = IgnorePawnsInventoryMode.DontIgnore, bool includePawnsMassInMassUsage = false, Func <float> availableMassGetter = null,
                                  float extraHeaderSpace = 0f, bool ignoreSpawnedCorpseGearAndInventoryMass = false, int tile = -1, bool drawMarketValue = false, bool drawNutritionEatenPerDay = false,
                                  bool drawFishPerDay    = false, bool playerPawnsReadOnly = false)
 {
     if (transferables != null)
     {
         AddSection(null, transferables);
     }
     this.sourceLabel                             = sourceLabel;
     this.destinationLabel                        = destinationLabel;
     this.sourceCountDesc                         = sourceCountDesc;
     this.drawMass                                = drawMass;
     this.ignorePawnInventoryMass                 = ignorePawnInventoryMass;
     this.includePawnsMassInMassUsage             = includePawnsMassInMassUsage;
     this.availableMassGetter                     = availableMassGetter;
     this.extraHeaderSpace                        = extraHeaderSpace;
     this.ignoreSpawnedCorpseGearAndInventoryMass = ignoreSpawnedCorpseGearAndInventoryMass;
     this.tile                     = tile;
     this.drawMarketValue          = drawMarketValue;
     this.drawNutritionEatenPerDay = drawNutritionEatenPerDay;
     this.drawFishPerDay           = drawFishPerDay;
     this.playerPawnsReadOnly      = playerPawnsReadOnly;
     sorter1 = TransferableSorterDefOf.Category;
     sorter2 = TransferableSorterDefOf.MarketValue;
 }
 private void CheckCreateSorters()
 {
     if (sorter1 == null)
     {
         sorter1 = TransferableSorterDefOf.Category;
     }
     if (sorter2 == null)
     {
         sorter2 = TransferableSorterDefOf.MarketValue;
     }
 }
 public Dialog_TradeAerialVehicle(AerialVehicleInFlight aerialVehicle, Pawn playerNegotiator, ITrader trader, bool giftsOnly = false)
 {
     this.aerialVehicle = aerialVehicle;
     this.giftsOnly     = giftsOnly;
     TradeSession.SetupWith(trader, playerNegotiator, giftsOnly);
     SetupPlayerCaravanVariables();
     forcePause = true;
     absorbInputAroundWindow = true;
     soundAppear             = SoundDefOf.CommsWindow_Open;
     soundClose = SoundDefOf.CommsWindow_Close;
     if (trader is PassingShip)
     {
         soundAmbient = SoundDefOf.RadioComms_Ambience;
     }
     sorter1 = TransferableSorterDefOf.Category;
     sorter2 = TransferableSorterDefOf.MarketValue;
 }
Exemple #5
0
 public override void PostOpen()
 {
     base.PostOpen();
     this.sorter1 = TransferableSorterDefOf.Category;
     this.sorter2 = TransferableSorterDefOf.MarketValue;
     var tradeables = (from tr in TradeSession.deal.AllTradeables
                       where !tr.IsCurrency
                       orderby(!tr.TraderWillTrade) ? -1 : 0 descending
                       select tr).ThenBy((Tradeable tr) => tr, this.sorter1.Comparer).ThenBy((Tradeable tr) => tr, this.sorter2.Comparer).ThenBy(new Func <Tradeable, float>(TransferableUIUtility.DefaultListOrderPriority)).ThenBy((Tradeable tr) => tr.ThingDef.label).ThenBy(delegate(Tradeable tr)
     {
         QualityCategory result;
         if (tr.AnyThing.TryGetQuality(out result))
         {
             return((int)result);
         }
         return(-1);
     }).ThenBy((Tradeable tr) => tr.AnyThing.HitPoints).ToList <Tradeable>();
 }
Exemple #6
0
        public void OnGUI(Rect inRect, out bool anythingChanged)
        {
            if (!transferablesCached)
            {
                CacheTransferables();
            }
            TransferableUIUtility.DoTransferableSorters(sorter1, sorter2, delegate(TransferableSorterDef x)
            {
                sorter1 = x;
                CacheTransferables();
            }, delegate(TransferableSorterDef x)
            {
                sorter2 = x;
                CacheTransferables();
            });
            if (!sourceLabel.NullOrEmpty() || !destinationLabel.NullOrEmpty())
            {
                float num      = inRect.width - 515f;
                Rect  position = new Rect(inRect.x + num, inRect.y, inRect.width - num, 37f);
                GUI.BeginGroup(position);
                Text.Font = GameFont.Medium;
                if (!sourceLabel.NullOrEmpty())
                {
                    Rect rect = new Rect(0f, 0f, position.width / 2f, position.height);
                    Text.Anchor = TextAnchor.UpperLeft;
                    Widgets.Label(rect, sourceLabel);
                }
                if (!destinationLabel.NullOrEmpty())
                {
                    Rect rect2 = new Rect(position.width / 2f, 0f, position.width / 2f, position.height);
                    Text.Anchor = TextAnchor.UpperRight;
                    Widgets.Label(rect2, destinationLabel);
                }
                Text.Font   = GameFont.Small;
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.EndGroup();
            }
            Rect mainRect = new Rect(inRect.x, inRect.y + 37f + extraHeaderSpace, inRect.width, inRect.height - 37f - extraHeaderSpace);

            FillMainRect(mainRect, out anythingChanged);
        }
 private void <FillTab> m__1(TransferableSorterDef x)
 {
     this.sorter2 = x;
     this.CacheItems();
 }
        public override void DoWindowContents(Rect inRect)
        {
            TradeSession.deal.UpdateCurrencyCount();
            GUI.BeginGroup(inRect);
            inRect = inRect.AtZero();
            TransferableUIUtility.DoTransferableSorters(sorter1, sorter2, delegate(TransferableSorterDef x)
            {
                sorter1 = x;
                CacheTradeables();
            }, delegate(TransferableSorterDef x)
            {
                sorter2 = x;
                CacheTradeables();
            });
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;
            Widgets.Label(new Rect(0f, SpaceBetweenTraderNameAndTraderKind, inRect.width / 2f, inRect.height / 2f), "NegotiatorTradeDialogInfo".Translate(TradeSession.playerNegotiator.Name.ToStringFull, TradeSession.playerNegotiator.GetStatValue(StatDefOf.TradePriceImprovement, true).ToStringPercent()));
            float num      = inRect.width - 590f;
            Rect  position = new Rect(num, 0f, inRect.width - num, TopAreaHeight);

            GUI.BeginGroup(position);
            Text.Font = GameFont.Medium;
            Rect rect = new Rect(0f, 0f, position.width / 2f, position.height);

            Text.Anchor = TextAnchor.UpperLeft;
            Widgets.Label(rect, Faction.OfPlayer.Name.Truncate(rect.width, null));
            Rect rect2 = new Rect(position.width / 2f, 0f, position.width / 2f, position.height);

            Text.Anchor = TextAnchor.UpperRight;
            string text = TradeSession.trader.TraderName;

            if (Text.CalcSize(text).x > rect2.width)
            {
                Text.Font = GameFont.Small;
                text      = text.Truncate(rect2.width, null);
            }
            Widgets.Label(rect2, text);
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperRight;
            Widgets.Label(new Rect(position.width / 2f, SpaceBetweenTraderNameAndTraderKind, position.width / 2f, position.height / 2f), TradeSession.trader.TraderKind.LabelCap);
            Text.Anchor = TextAnchor.UpperLeft;
            if (!TradeSession.giftMode)
            {
                GUI.color = new Color(1f, 1f, 1f, 0.6f);
                Text.Font = GameFont.Tiny;
                Rect rect3 = new Rect(position.width / 2f - 100f - RowInterval, 0f, 200f, position.height);
                Text.Anchor = TextAnchor.LowerCenter;
                Widgets.Label(rect3, "PositiveBuysNegativeSells".Translate());
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
            }
            GUI.EndGroup();
            float num2 = 0f;

            if (cachedCurrencyTradeable != null)
            {
                float num3 = inRect.width - 16f;
                TradeUI.DrawTradeableRow(new Rect(0f, TopAreaHeight, num3, RowInterval), cachedCurrencyTradeable, 1);
                GUI.color = Color.gray;
                Widgets.DrawLineHorizontal(0f, 87f, num3);
                GUI.color = Color.white;
                num2      = RowInterval;
            }
            Rect mainRect = new Rect(0f, TopAreaHeight + num2, inRect.width, inRect.height - TopAreaHeight - 38f - num2 - 20f);

            FillMainRect(mainRect);
            Rect rect4 = new Rect(inRect.width / 2f - AcceptButtonSize.x / 2f, inRect.height - 55f, AcceptButtonSize.x, AcceptButtonSize.y);

            if (Widgets.ButtonText(rect4, TradeSession.giftMode ? ("OfferGifts".Translate() + " (" + FactionGiftUtility.GetGoodwillChange(TradeSession.deal.AllTradeables, TradeSession.trader.Faction).ToStringWithSign() + ")") : "AcceptButton".Translate(), true, true, true))
            {
                void action()
                {
                    if (TradeSession.deal.TryExecute(out bool flag))
                    {
                        if (flag)
                        {
                            SoundDefOf.ExecuteTrade.PlayOneShotOnCamera(null);
                            Close(false);
                            return;
                        }
                        Close(true);
                    }
                }

                if (TradeSession.deal.DoesTraderHaveEnoughSilver())
                {
                    action();
                }
                else
                {
                    FlashSilver();
                    SoundDefOf.ClickReject.PlayOneShotOnCamera(null);
                    Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmTraderShortFunds".Translate(), action, false, null));
                }
                Event.current.Use();
            }
            if (Widgets.ButtonText(new Rect(rect4.x - 10f - OtherBottomButtonSize.x, rect4.y, OtherBottomButtonSize.x, OtherBottomButtonSize.y), "ResetButton".Translate(), true, true, true))
            {
                SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                TradeSession.deal.Reset();
                CacheTradeables();
                CountToTransferChanged();
            }
            if (Widgets.ButtonText(new Rect(rect4.xMax + 10f, rect4.y, OtherBottomButtonSize.x, OtherBottomButtonSize.y), "CancelButton".Translate(), true, true, true))
            {
                this.Close(true);
                Event.current.Use();
            }
            float y     = OtherBottomButtonSize.y;
            Rect  rect5 = new Rect(inRect.width - y, rect4.y, y, y);

            if (Widgets.ButtonImageWithBG(rect5, ShowSellableItemsIcon, new Vector2?(new Vector2(ShowSellableItemsIconSize, ShowSellableItemsIconSize))))
            {
                Find.WindowStack.Add(new Dialog_SellableItems(TradeSession.trader));
            }
            TooltipHandler.TipRegionByKey(rect5, "CommandShowSellableItemsDesc");
            Faction faction = TradeSession.trader.Faction;

            if (faction != null && !giftsOnly && !faction.def.permanentEnemy)
            {
                Rect rect6 = new Rect(rect5.x - y - 4f, rect4.y, y, y);
                if (TradeSession.giftMode)
                {
                    if (Widgets.ButtonImageWithBG(rect6, TradeModeIcon, new Vector2?(new Vector2(TradeModeIconSize, TradeModeIconSize))))
                    {
                        TradeSession.giftMode = false;
                        TradeSession.deal.Reset();
                        CacheTradeables();
                        CountToTransferChanged();
                        SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                    }
                    TooltipHandler.TipRegionByKey(rect6, "TradeModeTip");
                }
                else
                {
                    if (Widgets.ButtonImageWithBG(rect6, GiftModeIcon, new Vector2?(new Vector2(GiftModeIconSize, GiftModeIconSize))))
                    {
                        TradeSession.giftMode = true;
                        TradeSession.deal.Reset();
                        CacheTradeables();
                        CountToTransferChanged();
                        SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                    }
                    TooltipHandler.TipRegionByKey(rect6, "GiftModeTip", faction.Name);
                }
            }
            GUI.EndGroup();
        }