public void OnGUI(Rect inRect, out bool anythingChanged) { if (!this.transferablesCached) { this.CacheTransferables(); } TransferableUIUtility.DoTransferableSorters(this.sorter1, this.sorter2, delegate(TransferableSorterDef x) { this.sorter1 = x; this.CacheTransferables(); }, delegate(TransferableSorterDef x) { this.sorter2 = x; this.CacheTransferables(); }); float num = (float)(inRect.width - 515.0); Rect position = new Rect(inRect.x + num, inRect.y, inRect.width - num, 55f); GUI.BeginGroup(position); Text.Font = GameFont.Medium; Rect rect = new Rect(0f, 0f, (float)(position.width / 2.0), position.height); Text.Anchor = TextAnchor.UpperLeft; Widgets.Label(rect, this.sourceLabel); Rect rect2 = new Rect((float)(position.width / 2.0), 0f, (float)(position.width / 2.0), position.height); Text.Anchor = TextAnchor.UpperRight; Widgets.Label(rect2, this.destinationLabel); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; GUI.EndGroup(); Rect mainRect = new Rect(inRect.x, (float)(inRect.y + 55.0 + this.extraHeaderSpace), inRect.width, (float)(inRect.height - 55.0 - this.extraHeaderSpace)); this.FillMainRect(mainRect, out anythingChanged); }
public TransferableOneWayWidget(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 drawEquippedWeapon = false, bool drawNutritionEatenPerDay = false, bool drawItemNutrition = false, bool drawForagedFoodPerDay = false, bool drawDaysUntilRot = false, bool playerPawnsReadOnly = false) { if (transferables != null) { this.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.drawEquippedWeapon = drawEquippedWeapon; this.drawNutritionEatenPerDay = drawNutritionEatenPerDay; this.drawItemNutrition = drawItemNutrition; this.drawForagedFoodPerDay = drawForagedFoodPerDay; this.drawDaysUntilRot = drawDaysUntilRot; this.playerPawnsReadOnly = playerPawnsReadOnly; this.sorter1 = TransferableSorterDefOf.Category; this.sorter2 = TransferableSorterDefOf.MarketValue; }
public static void DoTransferableSorters(TransferableSorterDef sorter1, TransferableSorterDef sorter2, Action <TransferableSorterDef> sorter1Setter, Action <TransferableSorterDef> sorter2Setter) { Rect position = new Rect(0f, 0f, 350f, 27f); GUI.BeginGroup(position); Text.Font = GameFont.Tiny; Rect rect = new Rect(0f, 0f, 60f, 27f); Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(rect, "SortBy".Translate()); Text.Anchor = TextAnchor.UpperLeft; Rect rect2 = new Rect(rect.xMax + 10f, 0f, 130f, 27f); if (Widgets.ButtonText(rect2, sorter1.LabelCap, true, false, true)) { TransferableUIUtility.OpenSorterChangeFloatMenu(sorter1Setter); } Rect rect3 = new Rect(rect2.xMax + 10f, 0f, 130f, 27f); if (Widgets.ButtonText(rect3, sorter2.LabelCap, true, false, true)) { TransferableUIUtility.OpenSorterChangeFloatMenu(sorter2Setter); } GUI.EndGroup(); }
private static void OpenSorterChangeFloatMenu(Action <TransferableSorterDef> sorterSetter) { List <FloatMenuOption> list = new List <FloatMenuOption>(); List <TransferableSorterDef> allDefsListForReading = DefDatabase <TransferableSorterDef> .AllDefsListForReading; for (int i = 0; i < allDefsListForReading.Count; i++) { TransferableSorterDef def = allDefsListForReading[i]; list.Add(new FloatMenuOption(def.LabelCap, delegate { sorterSetter(def); }, MenuOptionPriority.Default, null, null, 0f, null, null)); } Find.WindowStack.Add(new FloatMenu(list)); }
public Dialog_Trade(Pawn playerNegotiator, ITrader trader) { TradeSession.SetupWith(trader, playerNegotiator); this.SetupPlayerCaravanVariables(); this.closeOnEscapeKey = true; this.forcePause = true; this.absorbInputAroundWindow = true; this.soundAppear = SoundDefOf.CommsWindow_Open; this.soundClose = SoundDefOf.CommsWindow_Close; if (trader is PassingShip) { this.soundAmbient = SoundDefOf.RadioComms_Ambience; } this.sorter1 = TransferableSorterDefOf.Category; this.sorter2 = TransferableSorterDefOf.MarketValue; }
public Dialog_Trade(Pawn playerNegotiator, ITrader trader, bool giftsOnly = false) { 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; }
public void OnGUI(Rect inRect, out bool anythingChanged) { if (!this.transferablesCached) { this.CacheTransferables(); } Profiler.BeginSample("TransferableOneWayWidget.OnGUI()"); TransferableUIUtility.DoTransferableSorters(this.sorter1, this.sorter2, delegate(TransferableSorterDef x) { this.sorter1 = x; this.CacheTransferables(); }, delegate(TransferableSorterDef x) { this.sorter2 = x; this.CacheTransferables(); }); if (!this.sourceLabel.NullOrEmpty() || !this.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 (!this.sourceLabel.NullOrEmpty()) { Rect rect = new Rect(0f, 0f, position.width / 2f, position.height); Text.Anchor = TextAnchor.UpperLeft; Widgets.Label(rect, this.sourceLabel); } if (!this.destinationLabel.NullOrEmpty()) { Rect rect2 = new Rect(position.width / 2f, 0f, position.width / 2f, position.height); Text.Anchor = TextAnchor.UpperRight; Widgets.Label(rect2, this.destinationLabel); } Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; GUI.EndGroup(); } Rect mainRect = new Rect(inRect.x, inRect.y + 37f + this.extraHeaderSpace, inRect.width, inRect.height - 37f - this.extraHeaderSpace); this.FillMainRect(mainRect, out anythingChanged); Profiler.EndSample(); }
public TransferableOneWayWidget(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 ignoreCorpseGearAndInventoryMass = false, bool drawMarketValue = false, int drawDaysUntilRotForTile = -1) { if (transferables != null) { this.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.ignoreCorpseGearAndInventoryMass = ignoreCorpseGearAndInventoryMass; this.drawMarketValue = drawMarketValue; this.drawDaysUntilRotForTile = drawDaysUntilRotForTile; this.sorter1 = TransferableSorterDefOf.Category; this.sorter2 = TransferableSorterDefOf.MarketValue; }
public override void DoWindowContents(Rect inRect) { TradeSession.deal.UpdateCurrencyCount(); TransferableUIUtility.DoTransferableSorters(this.sorter1, this.sorter2, delegate(TransferableSorterDef x) { this.sorter1 = x; this.CacheTradeables(); }, delegate(TransferableSorterDef x) { this.sorter2 = x; this.CacheTradeables(); }); float num = inRect.width - 590f; Rect rect = new Rect(num, 0f, inRect.width - num, this.TopAreaHeight); GUI.BeginGroup(rect); Text.Font = GameFont.Medium; Rect rect2 = new Rect(0f, 0f, rect.width / 2f, rect.height); Text.Anchor = TextAnchor.UpperLeft; Widgets.Label(rect2, Faction.OfPlayer.Name); Rect rect3 = new Rect(rect.width / 2f, 0f, rect.width / 2f, rect.height); Text.Anchor = TextAnchor.UpperRight; string text = TradeSession.trader.TraderName; if (Text.CalcSize(text).x > rect3.width) { Text.Font = GameFont.Small; text = text.Truncate(rect3.width, null); } Widgets.Label(rect3, text); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; Rect rect4 = new Rect(0f, 27f, rect.width / 2f, rect.height / 2f); Widgets.Label(rect4, "Negotiator".Translate() + ": " + TradeSession.playerNegotiator.LabelShort); Text.Anchor = TextAnchor.UpperRight; Rect rect5 = new Rect(rect.width / 2f, 27f, rect.width / 2f, rect.height / 2f); Widgets.Label(rect5, TradeSession.trader.TraderKind.LabelCap); Text.Anchor = TextAnchor.UpperLeft; GUI.color = new Color(1f, 1f, 1f, 0.6f); Text.Font = GameFont.Tiny; Rect rect6 = new Rect(rect.width / 2f - 100f - 30f, 0f, 200f, rect.height); Text.Anchor = TextAnchor.LowerCenter; Widgets.Label(rect6, "PositiveBuysNegativeSells".Translate()); Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; if (this.playerIsCaravan) { Text.Font = GameFont.Small; float massUsage = this.MassUsage; float massCapacity = this.MassCapacity; Rect rect7 = rect.AtZero(); rect7.y = 45f; TransferableUIUtility.DrawMassInfo(rect7, massUsage, massCapacity, "TradeMassUsageTooltip".Translate(), -9999f, false); CaravanUIUtility.DrawDaysWorthOfFoodInfo(new Rect(rect7.x, rect7.y + 19f, rect7.width, rect7.height), this.DaysWorthOfFood.First, this.DaysWorthOfFood.Second, this.EnvironmentAllowsEatingVirtualPlantsNow, false, 200f); } GUI.EndGroup(); float num2 = 0f; if (this.cachedCurrencyTradeable != null) { float num3 = inRect.width - 16f; Rect rect8 = new Rect(0f, this.TopAreaHeight, num3, 30f); TradeUI.DrawTradeableRow(rect8, this.cachedCurrencyTradeable, 1); GUI.color = Color.gray; Widgets.DrawLineHorizontal(0f, this.TopAreaHeight + 30f - 1f, num3); GUI.color = Color.white; num2 = 30f; } Rect mainRect = new Rect(0f, this.TopAreaHeight + num2, inRect.width, inRect.height - this.TopAreaHeight - 38f - num2 - 20f); this.FillMainRect(mainRect); Rect rect9 = new Rect(inRect.width / 2f - this.AcceptButtonSize.x / 2f, inRect.height - 55f, this.AcceptButtonSize.x, this.AcceptButtonSize.y); if (Widgets.ButtonText(rect9, "AcceptButton".Translate(), true, false, true)) { Action action = delegate { bool flag; if (TradeSession.deal.TryExecute(out flag)) { if (flag) { SoundDefOf.ExecuteTrade.PlayOneShotOnCamera(null); Pawn pawn = TradeSession.trader as Pawn; if (pawn != null) { TaleRecorder.RecordTale(TaleDefOf.TradedWith, new object[] { TradeSession.playerNegotiator, pawn }); } TradeSession.playerNegotiator.mindState.inspirationHandler.EndInspiration(InspirationDefOf.InspiredTrade); this.Close(false); } else { this.Close(true); } } }; if (TradeSession.deal.DoesTraderHaveEnoughSilver()) { action(); } else { this.FlashSilver(); SoundDefOf.ClickReject.PlayOneShotOnCamera(null); Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmTraderShortFunds".Translate(), action, false, null)); } Event.current.Use(); } Rect rect10 = new Rect(rect9.x - 10f - this.OtherBottomButtonSize.x, rect9.y, this.OtherBottomButtonSize.x, this.OtherBottomButtonSize.y); if (Widgets.ButtonText(rect10, "ResetButton".Translate(), true, false, true)) { SoundDefOf.TickLow.PlayOneShotOnCamera(null); TradeSession.deal.Reset(); this.CacheTradeables(); this.CountToTransferChanged(); Event.current.Use(); } Rect rect11 = new Rect(rect9.xMax + 10f, rect9.y, this.OtherBottomButtonSize.x, this.OtherBottomButtonSize.y); if (Widgets.ButtonText(rect11, "CancelButton".Translate(), true, false, true)) { this.Close(true); Event.current.Use(); } }
private void <OnGUI> m__3(TransferableSorterDef x) { this.sorter2 = x; this.CacheTransferables(); }
public override void DoWindowContents(Rect inRect) { if (this.playerIsCaravan) { CaravanUIUtility.DrawCaravanInfo(new CaravanUIUtility.CaravanInfo(this.MassUsage, this.MassCapacity, this.cachedMassCapacityExplanation, this.TilesPerDay, this.cachedTilesPerDayExplanation, this.DaysWorthOfFood, this.ForagedFoodPerDay, this.cachedForagedFoodPerDayExplanation, this.Visibility, this.cachedVisibilityExplanation, -1f, -1f, null), null, this.Tile, null, -9999f, new Rect(12f, 0f, inRect.width - 24f, 40f), true, null, false); inRect.yMin += 52f; } TradeSession.deal.UpdateCurrencyCount(); GUI.BeginGroup(inRect); inRect = inRect.AtZero(); TransferableUIUtility.DoTransferableSorters(this.sorter1, this.sorter2, delegate(TransferableSorterDef x) { this.sorter1 = x; this.CacheTradeables(); }, delegate(TransferableSorterDef x) { this.sorter2 = x; this.CacheTradeables(); }); float num = inRect.width - 590f; Rect position = new Rect(num, 0f, inRect.width - num, 58f); 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.UpperLeft; Rect rect3 = new Rect(0f, 27f, position.width / 2f, position.height / 2f); Widgets.Label(rect3, "Negotiator".Translate() + ": " + TradeSession.playerNegotiator.LabelShort); Text.Anchor = TextAnchor.UpperRight; Rect rect4 = new Rect(position.width / 2f, 27f, position.width / 2f, position.height / 2f); Widgets.Label(rect4, 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 rect5 = new Rect(position.width / 2f - 100f - 30f, 0f, 200f, position.height); Text.Anchor = TextAnchor.LowerCenter; Widgets.Label(rect5, "PositiveBuysNegativeSells".Translate()); Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; } GUI.EndGroup(); float num2 = 0f; if (this.cachedCurrencyTradeable != null) { float num3 = inRect.width - 16f; Rect rect6 = new Rect(0f, 58f, num3, 30f); TradeUI.DrawTradeableRow(rect6, this.cachedCurrencyTradeable, 1); GUI.color = Color.gray; Widgets.DrawLineHorizontal(0f, 87f, num3); GUI.color = Color.white; num2 = 30f; } Rect mainRect = new Rect(0f, 58f + num2, inRect.width, inRect.height - 58f - 38f - num2 - 20f); this.FillMainRect(mainRect); Rect rect7 = new Rect(inRect.width / 2f - Dialog_Trade.AcceptButtonSize.x / 2f, inRect.height - 55f, Dialog_Trade.AcceptButtonSize.x, Dialog_Trade.AcceptButtonSize.y); if (Widgets.ButtonText(rect7, (!TradeSession.giftMode) ? "AcceptButton".Translate() : ("OfferGifts".Translate() + " (" + FactionGiftUtility.GetGoodwillChange(TradeSession.deal.AllTradeables, TradeSession.trader.Faction).ToStringWithSign() + ")"), true, false, true)) { Action action = delegate { bool flag; if (TradeSession.deal.TryExecute(out flag)) { if (flag) { SoundDefOf.ExecuteTrade.PlayOneShotOnCamera(null); this.Close(false); } else { this.Close(true); } } }; if (TradeSession.deal.DoesTraderHaveEnoughSilver()) { action(); } else { this.FlashSilver(); SoundDefOf.ClickReject.PlayOneShotOnCamera(null); Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmTraderShortFunds".Translate(), action, false, null)); } Event.current.Use(); } Rect rect8 = new Rect(rect7.x - 10f - Dialog_Trade.OtherBottomButtonSize.x, rect7.y, Dialog_Trade.OtherBottomButtonSize.x, Dialog_Trade.OtherBottomButtonSize.y); if (Widgets.ButtonText(rect8, "ResetButton".Translate(), true, false, true)) { SoundDefOf.Tick_Low.PlayOneShotOnCamera(null); TradeSession.deal.Reset(); this.CacheTradeables(); this.CountToTransferChanged(); } Rect rect9 = new Rect(rect7.xMax + 10f, rect7.y, Dialog_Trade.OtherBottomButtonSize.x, Dialog_Trade.OtherBottomButtonSize.y); if (Widgets.ButtonText(rect9, "CancelButton".Translate(), true, false, true)) { this.Close(true); Event.current.Use(); } float y = Dialog_Trade.OtherBottomButtonSize.y; Rect rect10 = new Rect(inRect.width - y, rect7.y, y, y); if (Widgets.ButtonImageWithBG(rect10, Dialog_Trade.ShowSellableItemsIcon, new Vector2?(new Vector2(32f, 32f)))) { Find.WindowStack.Add(new Dialog_SellableItems(TradeSession.trader.TraderKind)); } TooltipHandler.TipRegion(rect10, "CommandShowSellableItemsDesc".Translate()); Faction faction = TradeSession.trader.Faction; if (faction != null && !this.giftsOnly && !faction.def.permanentEnemy) { Rect rect11 = new Rect(rect10.x - y - 4f, rect7.y, y, y); if (TradeSession.giftMode) { if (Widgets.ButtonImageWithBG(rect11, Dialog_Trade.TradeModeIcon, new Vector2?(new Vector2(32f, 32f)))) { TradeSession.giftMode = false; TradeSession.deal.Reset(); this.CacheTradeables(); this.CountToTransferChanged(); SoundDefOf.Tick_High.PlayOneShotOnCamera(null); } TooltipHandler.TipRegion(rect11, "TradeModeTip".Translate()); } else { if (Widgets.ButtonImageWithBG(rect11, Dialog_Trade.GiftModeIcon, new Vector2?(new Vector2(32f, 32f)))) { TradeSession.giftMode = true; TradeSession.deal.Reset(); this.CacheTradeables(); this.CountToTransferChanged(); SoundDefOf.Tick_High.PlayOneShotOnCamera(null); } TooltipHandler.TipRegion(rect11, "GiftModeTip".Translate(faction.Name)); } } GUI.EndGroup(); }
private void <DoWindowContents> m__A(TransferableSorterDef x) { this.sorter2 = x; this.CacheTradeables(); }