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(); }
public static void DoCountAdjustInterface(Rect rect, Transferable trad, int index, int min, int max, bool flash = false, List <TransferableCountToTransferStoppingPoint> extraStoppingPoints = null, bool readOnly = false) { TransferableUIUtility.stoppingPoints.Clear(); if (extraStoppingPoints != null) { TransferableUIUtility.stoppingPoints.AddRange(extraStoppingPoints); } for (int i = TransferableUIUtility.stoppingPoints.Count - 1; i >= 0; i--) { if (TransferableUIUtility.stoppingPoints[i].threshold != 0 && (TransferableUIUtility.stoppingPoints[i].threshold <= min || TransferableUIUtility.stoppingPoints[i].threshold >= max)) { TransferableUIUtility.stoppingPoints.RemoveAt(i); } } bool flag = false; for (int j = 0; j < TransferableUIUtility.stoppingPoints.Count; j++) { if (TransferableUIUtility.stoppingPoints[j].threshold == 0) { flag = true; break; } } if (!flag) { TransferableUIUtility.stoppingPoints.Add(new TransferableCountToTransferStoppingPoint(0, "0", "0")); } TransferableUIUtility.DoCountAdjustInterfaceInternal(rect, trad, index, min, max, flash, readOnly); }
public static int Compare(ThingDef lhsTh, ThingDef rhsTh) { if (lhsTh.category != rhsTh.category) { return(lhsTh.category.CompareTo(rhsTh.category)); } float num = TransferableUIUtility.DefaultListOrderPriority(lhsTh); float num2 = TransferableUIUtility.DefaultListOrderPriority(rhsTh); if (num != num2) { return(num.CompareTo(num2)); } int num3 = 0; if (!lhsTh.thingCategories.NullOrEmpty <ThingCategoryDef>()) { num3 = (int)lhsTh.thingCategories[0].index; } int value = 0; if (!rhsTh.thingCategories.NullOrEmpty <ThingCategoryDef>()) { value = (int)rhsTh.thingCategories[0].index; } return(num3.CompareTo(value)); }
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 static float DefaultListOrderPriority(Transferable transferable) { if (!transferable.HasAnyThing) { return(0f); } return(TransferableUIUtility.DefaultListOrderPriority(transferable.ThingDef)); }
public override void DoWindowContents(Rect inRect) { Rect rect = new Rect(0f, 0f, inRect.width, 40f); Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect, "LoadTransporters".Translate(new object[] { this.TransportersLabel })); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; Dialog_LoadTransporters.tabsList.Clear(); Dialog_LoadTransporters.tabsList.Add(new TabRecord("PawnsTab".Translate(), delegate { this.tab = Dialog_LoadTransporters.Tab.Pawns; }, this.tab == Dialog_LoadTransporters.Tab.Pawns)); Dialog_LoadTransporters.tabsList.Add(new TabRecord("ItemsTab".Translate(), delegate { this.tab = Dialog_LoadTransporters.Tab.Items; }, this.tab == Dialog_LoadTransporters.Tab.Items)); inRect.yMin += 72f; Widgets.DrawMenuSection(inRect); TabDrawer.DrawTabs(inRect, Dialog_LoadTransporters.tabsList); inRect = inRect.ContractedBy(17f); GUI.BeginGroup(inRect); Rect rect2 = inRect.AtZero(); Rect rect3 = rect2; rect3.xMin += rect2.width - 515f; rect3.y += 32f; TransferableUIUtility.DrawMassInfo(rect3, this.MassUsage, this.MassCapacity, "TransportersMassUsageTooltip".Translate(), this.lastMassFlashTime, true); CaravanUIUtility.DrawDaysWorthOfFoodInfo(new Rect(rect3.x, rect3.y + 19f, rect3.width, rect3.height), this.DaysWorthOfFood.First, this.DaysWorthOfFood.Second, this.EnvironmentAllowsEatingVirtualPlantsNow, true, 3.40282347E+38f); this.DoBottomButtons(rect2); Rect inRect2 = rect2; inRect2.yMax -= 59f; bool flag = false; Dialog_LoadTransporters.Tab tab = this.tab; if (tab != Dialog_LoadTransporters.Tab.Pawns) { if (tab == Dialog_LoadTransporters.Tab.Items) { this.itemsTransfer.OnGUI(inRect2, out flag); } } else { this.pawnsTransfer.OnGUI(inRect2, out flag); } if (flag) { this.CountToTransferChanged(); } GUI.EndGroup(); }
public static float DefaultListOrderPriority(Transferable transferable) { float result; if (!transferable.HasAnyThing) { result = 0f; } else { result = TransferableUIUtility.DefaultListOrderPriority(transferable.ThingDef); } return(result); }
public static void DoCountAdjustInterface(Rect rect, Transferable trad, int index, int min, int max, bool flash = false, List <TransferableCountToTransferStoppingPoint> extraStoppingPoints = null) { TransferableUIUtility.stoppingPoints.Clear(); if (extraStoppingPoints != null) { TransferableUIUtility.stoppingPoints.AddRange(extraStoppingPoints); } for (int i = TransferableUIUtility.stoppingPoints.Count - 1; i >= 0; i--) { TransferableCountToTransferStoppingPoint transferableCountToTransferStoppingPoint = TransferableUIUtility.stoppingPoints[i]; if (transferableCountToTransferStoppingPoint.threshold != 0) { TransferableCountToTransferStoppingPoint transferableCountToTransferStoppingPoint2 = TransferableUIUtility.stoppingPoints[i]; if (transferableCountToTransferStoppingPoint2.threshold > min) { TransferableCountToTransferStoppingPoint transferableCountToTransferStoppingPoint3 = TransferableUIUtility.stoppingPoints[i]; if (transferableCountToTransferStoppingPoint3.threshold >= max) { goto IL_007a; } continue; } goto IL_007a; } continue; IL_007a: TransferableUIUtility.stoppingPoints.RemoveAt(i); } bool flag = false; for (int j = 0; j < TransferableUIUtility.stoppingPoints.Count; j++) { TransferableCountToTransferStoppingPoint transferableCountToTransferStoppingPoint4 = TransferableUIUtility.stoppingPoints[j]; if (transferableCountToTransferStoppingPoint4.threshold == 0) { flag = true; break; } } if (!flag) { TransferableUIUtility.stoppingPoints.Add(new TransferableCountToTransferStoppingPoint(0, "0", "0")); } TransferableUIUtility.DoCountAdjustInterfaceInternal(rect, trad, index, min, max, flash); }
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 static void DrawTradeableRow(Rect rect, Tradeable trad, int index) { if (index % 2 == 1) { GUI.DrawTexture(rect, TradeUI.TradeAlternativeBGTex); } Text.Font = GameFont.Small; GUI.BeginGroup(rect); float width = rect.width; int num = trad.CountHeldBy(Transactor.Trader); if (num != 0) { Rect rect2 = new Rect((float)(width - 75.0), 0f, 75f, rect.height); if (Mouse.IsOver(rect2)) { Widgets.DrawHighlight(rect2); } Text.Anchor = TextAnchor.MiddleRight; Rect rect3 = rect2; rect3.xMin += 5f; rect3.xMax -= 5f; Widgets.Label(rect3, num.ToStringCached()); TooltipHandler.TipRegion(rect2, "TraderCount".Translate()); Rect rect4 = new Rect((float)(rect2.x - 100.0), 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleRight; TradeUI.DrawPrice(rect4, trad, TradeAction.PlayerBuys); } width = (float)(width - 175.0); Rect rect5 = new Rect((float)(width - 240.0), 0f, 240f, rect.height); if (trad.TraderWillTrade) { bool flash = Time.time - Dialog_Trade.lastCurrencyFlashTime < 1.0 && trad.IsCurrency; TransferableUIUtility.DoCountAdjustInterface(rect5, trad, index, -trad.CountHeldBy(Transactor.Colony), trad.CountHeldBy(Transactor.Trader), flash, null); } else { TradeUI.DrawWillNotTradeIndication(rect, trad); } width = (float)(width - 240.0); int num2 = trad.CountHeldBy(Transactor.Colony); if (num2 != 0) { Rect rect6 = new Rect((float)(width - 100.0), 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; TradeUI.DrawPrice(rect6, trad, TradeAction.PlayerSells); Rect rect7 = new Rect((float)(rect6.x - 75.0), 0f, 75f, rect.height); if (Mouse.IsOver(rect7)) { Widgets.DrawHighlight(rect7); } Text.Anchor = TextAnchor.MiddleLeft; Rect rect8 = rect7; rect8.xMin += 5f; rect8.xMax -= 5f; Widgets.Label(rect8, num2.ToStringCached()); TooltipHandler.TipRegion(rect7, "ColonyCount".Translate()); } width = (float)(width - 175.0); Rect idRect = new Rect(0f, 0f, width, rect.height); TransferableUIUtility.DrawTransferableInfo(trad, idRect, (!trad.TraderWillTrade) ? TradeUI.NoTradeColor : Color.white); GenUI.ResetLabelAlign(); GUI.EndGroup(); }
private void DoRow(Rect rect, TransferableOneWay trad, int index, float availableMass) { if (index % 2 == 1) { Widgets.DrawLightHighlight(rect); } Text.Font = GameFont.Small; GUI.BeginGroup(rect); float num = rect.width; int maxCount = trad.MaxCount; Rect rect2 = new Rect(num - 240f, 0f, 240f, rect.height); TransferableOneWayWidget.stoppingPoints.Clear(); if (this.availableMassGetter != null && (!(trad.AnyThing is Pawn) || this.includePawnsMassInMassUsage)) { float num2 = availableMass + this.GetMass(trad.AnyThing) * (float)trad.CountToTransfer; int threshold = (num2 > 0f) ? Mathf.FloorToInt(num2 / this.GetMass(trad.AnyThing)) : 0; TransferableOneWayWidget.stoppingPoints.Add(new TransferableCountToTransferStoppingPoint(threshold, "M<", ">M")); } Pawn pawn = trad.AnyThing as Pawn; bool flag = pawn != null && (pawn.IsColonist || pawn.IsPrisonerOfColony); Rect rect3 = rect2; int min = 0; int max = maxCount; List <TransferableCountToTransferStoppingPoint> extraStoppingPoints = TransferableOneWayWidget.stoppingPoints; TransferableUIUtility.DoCountAdjustInterface(rect3, trad, index, min, max, false, extraStoppingPoints, this.playerPawnsReadOnly && flag); num -= 240f; if (this.drawMarketValue) { Rect rect4 = new Rect(num - 100f, 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; this.DrawMarketValue(rect4, trad); num -= 100f; } if (this.drawMass) { Rect rect5 = new Rect(num - 100f, 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; this.DrawMass(rect5, trad, availableMass); num -= 100f; } if (this.drawDaysUntilRot) { Rect rect6 = new Rect(num - 75f, 0f, 75f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; this.DrawDaysUntilRot(rect6, trad); num -= 75f; } if (this.drawItemNutrition) { Rect rect7 = new Rect(num - 75f, 0f, 75f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; this.DrawItemNutrition(rect7, trad); num -= 75f; } if (this.drawForagedFoodPerDay) { Rect rect8 = new Rect(num - 75f, 0f, 75f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; if (!this.DrawGrazeability(rect8, trad)) { this.DrawForagedFoodPerDay(rect8, trad); } num -= 75f; } if (this.drawNutritionEatenPerDay) { Rect rect9 = new Rect(num - 75f, 0f, 75f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; this.DrawNutritionEatenPerDay(rect9, trad); num -= 75f; } if (this.ShouldShowCount(trad)) { Rect rect10 = new Rect(num - 75f, 0f, 75f, rect.height); Widgets.DrawHighlightIfMouseover(rect10); Text.Anchor = TextAnchor.MiddleLeft; Rect rect11 = rect10; rect11.xMin += 5f; rect11.xMax -= 5f; Widgets.Label(rect11, maxCount.ToStringCached()); TooltipHandler.TipRegion(rect10, this.sourceCountDesc); } num -= 75f; if (this.drawEquippedWeapon) { Rect rect12 = new Rect(num - 30f, 0f, 30f, rect.height); Rect iconRect = new Rect(num - 30f, (rect.height - 30f) / 2f, 30f, 30f); this.DrawEquippedWeapon(rect12, iconRect, trad); num -= 30f; } Pawn pawn2 = trad.AnyThing as Pawn; if (pawn2 != null && pawn2.def.race.Animal) { Rect rect13 = new Rect(num - TransferableOneWayWidget.BondIconWidth, (rect.height - TransferableOneWayWidget.BondIconWidth) / 2f, TransferableOneWayWidget.BondIconWidth, TransferableOneWayWidget.BondIconWidth); num -= TransferableOneWayWidget.BondIconWidth; Rect rect14 = new Rect(num - TransferableOneWayWidget.PregnancyIconWidth, (rect.height - TransferableOneWayWidget.PregnancyIconWidth) / 2f, TransferableOneWayWidget.PregnancyIconWidth, TransferableOneWayWidget.PregnancyIconWidth); num -= TransferableOneWayWidget.PregnancyIconWidth; string iconTooltipText = TrainableUtility.GetIconTooltipText(pawn2); if (!iconTooltipText.NullOrEmpty()) { TooltipHandler.TipRegion(rect13, iconTooltipText); } if (pawn2.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Bond, null) != null) { GUI.DrawTexture(rect13, TransferableOneWayWidget.BondIcon); } if (pawn2.health.hediffSet.HasHediff(HediffDefOf.Pregnant, true)) { TooltipHandler.TipRegion(rect14, PawnColumnWorker_Pregnant.GetTooltipText(pawn2)); GUI.DrawTexture(rect14, TransferableOneWayWidget.PregnantIcon); } } Rect idRect = new Rect(0f, 0f, num, rect.height); TransferableUIUtility.DrawTransferableInfo(trad, idRect, Color.white); GenUI.ResetLabelAlign(); GUI.EndGroup(); }
private void DoRow(Rect rect, TransferableOneWay trad, int index, float availableMass) { if (index % 2 == 1) { Widgets.DrawLightHighlight(rect); } Text.Font = GameFont.Small; GUI.BeginGroup(rect); float width = rect.width; int maxCount = trad.MaxCount; Rect rect2 = new Rect(width - 240f, 0f, 240f, rect.height); stoppingPoints.Clear(); if (availableMassGetter != null && (!(trad.AnyThing is Pawn) || includePawnsMassInMassUsage)) { float num = availableMass + GetMass(trad.AnyThing) * (float)trad.CountToTransfer; int threshold = ((!(num <= 0f)) ? Mathf.FloorToInt(num / GetMass(trad.AnyThing)) : 0); stoppingPoints.Add(new TransferableCountToTransferStoppingPoint(threshold, "M<", ">M")); } Pawn pawn = trad.AnyThing as Pawn; bool flag = pawn != null && (pawn.IsColonist || pawn.IsPrisonerOfColony); TransferableUIUtility.DoCountAdjustInterface(rect2, trad, index, 0, maxCount, flash: false, stoppingPoints, (playerPawnsReadOnly && flag) || readOnly); width -= 240f; if (drawMarketValue) { Rect rect3 = new Rect(width - 100f, 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; DrawMarketValue(rect3, trad); width -= 100f; } if (drawMass) { Rect rect4 = new Rect(width - 100f, 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; DrawMass(rect4, trad, availableMass); width -= 100f; } if (drawDaysUntilRot) { Rect rect5 = new Rect(width - 75f, 0f, 75f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; DrawDaysUntilRot(rect5, trad); width -= 75f; } if (drawItemNutrition) { Rect rect6 = new Rect(width - 75f, 0f, 75f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; DrawItemNutrition(rect6, trad); width -= 75f; } if (drawForagedFoodPerDay) { Rect rect7 = new Rect(width - 75f, 0f, 75f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; if (!DrawGrazeability(rect7, trad)) { DrawForagedFoodPerDay(rect7, trad); } width -= 75f; } if (drawNutritionEatenPerDay) { Rect rect8 = new Rect(width - 75f, 0f, 75f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; DrawNutritionEatenPerDay(rect8, trad); width -= 75f; } if (ShouldShowCount(trad)) { Rect rect9 = new Rect(width - 75f, 0f, 75f, rect.height); Widgets.DrawHighlightIfMouseover(rect9); Text.Anchor = TextAnchor.MiddleLeft; Rect rect10 = rect9; rect10.xMin += 5f; rect10.xMax -= 5f; Widgets.Label(rect10, maxCount.ToStringCached()); TooltipHandler.TipRegion(rect9, sourceCountDesc); } width -= 75f; if (drawEquippedWeapon) { Rect rect11 = new Rect(width - 30f, 0f, 30f, rect.height); Rect iconRect = new Rect(width - 30f, (rect.height - 30f) / 2f, 30f, 30f); DrawEquippedWeapon(rect11, iconRect, trad); width -= 30f; } TransferableUIUtility.DoExtraAnimalIcons(trad, rect, ref width); Rect idRect = new Rect(0f, 0f, width, rect.height); TransferableUIUtility.DrawTransferableInfo(trad, idRect, Color.white); GenUI.ResetLabelAlign(); GUI.EndGroup(); }
private void CacheTransferables() { transferablesCached = true; for (int i = 0; i < sections.Count; i++) { List <TransferableOneWay> cachedTransferables = sections[i].cachedTransferables; cachedTransferables.Clear(); cachedTransferables.AddRange(sections[i].transferables.OrderBy((TransferableOneWay tr) => tr, sorter1.Comparer).ThenBy((TransferableOneWay tr) => tr, sorter2.Comparer).ThenBy((TransferableOneWay tr) => TransferableUIUtility.DefaultListOrderPriority(tr)) .ToList()); } }
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 static float <CacheTradeables> m__5(Tradeable tr) { return(TransferableUIUtility.DefaultListOrderPriority(tr)); }
private void CacheTradeables() { this.cachedCurrencyTradeable = (from x in TradeSession.deal.AllTradeables where x.IsCurrency select x).FirstOrDefault <Tradeable>(); this.cachedTradeables = (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((Tradeable tr) => TransferableUIUtility.DefaultListOrderPriority(tr)).ThenBy((Tradeable tr) => tr.ThingDef.label).ThenBy(delegate(Tradeable tr) { QualityCategory qualityCategory; int result; if (tr.AnyThing.TryGetQuality(out qualityCategory)) { result = (int)qualityCategory; } else { result = -1; } return(result); }).ThenBy((Tradeable tr) => tr.AnyThing.HitPoints).ToList <Tradeable>(); }
private void CacheTradeables() { cachedCurrencyTradeable = TradeSession.deal.AllTradeables.FirstOrDefault((Tradeable x) => x.IsCurrency && (TradeSession.TradeCurrency != TradeCurrency.Favor || x.IsFavor)); cachedTradeables = (from tr in TradeSession.deal.AllTradeables where !tr.IsCurrency && (tr.TraderWillTrade || !TradeSession.trader.TraderKind.hideThingsNotWillingToTrade) orderby(!tr.TraderWillTrade) ? (-1) : 0 descending select tr).ThenBy((Tradeable tr) => tr, sorter1.Comparer).ThenBy((Tradeable tr) => tr, sorter2.Comparer).ThenBy((Tradeable tr) => TransferableUIUtility.DefaultListOrderPriority(tr)) .ThenBy((Tradeable tr) => tr.ThingDef.label) .ThenBy((Tradeable tr) => tr.AnyThing.TryGetQuality(out var qc) ? ((int)qc) : (-1)) .ThenBy((Tradeable tr) => tr.AnyThing.HitPoints) .ToList(); }
public override void DoWindowContents(Rect inRect) { Rect rect = new Rect(0f, 0f, inRect.width, 40f); Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect, ((!this.reform) ? "FormCaravan" : "ReformCaravan").Translate()); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; Dialog_FormCaravan.tabsList.Clear(); Dialog_FormCaravan.tabsList.Add(new TabRecord("PawnsTab".Translate(), delegate { this.tab = Tab.Pawns; }, this.tab == Tab.Pawns)); Dialog_FormCaravan.tabsList.Add(new TabRecord("ItemsTab".Translate(), delegate { this.tab = Tab.Items; }, this.tab == Tab.Items)); if (!this.reform) { Dialog_FormCaravan.tabsList.Add(new TabRecord("CaravanConfigTab".Translate(), delegate { this.tab = Tab.Config; }, this.tab == Tab.Config)); } inRect.yMin += 72f; Widgets.DrawMenuSection(inRect); TabDrawer.DrawTabs(inRect, Dialog_FormCaravan.tabsList); inRect = inRect.ContractedBy(17f); GUI.BeginGroup(inRect); Rect rect2 = inRect.AtZero(); if (this.tab != Tab.Config) { Rect rect3 = rect2; rect3.xMin += (float)(rect2.width - 515.0); rect3.y += 32f; TransferableUIUtility.DrawMassInfo(rect3, this.MassUsage, this.MassCapacity, "CaravanMassUsageTooltip".Translate(), this.lastMassFlashTime, true); CaravanUIUtility.DrawDaysWorthOfFoodInfo(new Rect(rect3.x, (float)(rect3.y + 19.0), rect3.width, rect3.height), this.DaysWorthOfFood.First, this.DaysWorthOfFood.Second, this.EnvironmentAllowsEatingVirtualPlantsNow, true, 3.40282347E+38f); } this.DoBottomButtons(rect2); Rect inRect2 = rect2; inRect2.yMax -= 59f; bool flag = false; switch (this.tab) { case Tab.Pawns: this.pawnsTransfer.OnGUI(inRect2, out flag); break; case Tab.Items: this.itemsTransfer.OnGUI(inRect2, out flag); break; case Tab.Config: this.DrawConfig(rect2); break; } if (flag) { this.CountToTransferChanged(); } GUI.EndGroup(); }
public static void DrawTradeableRow(Rect rect, Tradeable trad, int index) { if (index % 2 == 1) { Widgets.DrawLightHighlight(rect); } Text.Font = GameFont.Small; GUI.BeginGroup(rect); float width = rect.width; int num = trad.CountHeldBy(Transactor.Trader); if (num != 0 && trad.IsThing) { Rect rect2 = new Rect(width - 75f, 0f, 75f, rect.height); if (Mouse.IsOver(rect2)) { Widgets.DrawHighlight(rect2); } Text.Anchor = TextAnchor.MiddleRight; Rect rect3 = rect2; rect3.xMin += 5f; rect3.xMax -= 5f; Widgets.Label(rect3, num.ToStringCached()); TooltipHandler.TipRegionByKey(rect2, "TraderCount"); Rect rect4 = new Rect(rect2.x - 100f, 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleRight; DrawPrice(rect4, trad, TradeAction.PlayerBuys); } width -= 175f; Rect rect5 = new Rect(width - 240f, 0f, 240f, rect.height); if (trad.TraderWillTrade) { bool flash = Time.time - Dialog_Trade.lastCurrencyFlashTime < 1f && trad.IsCurrency; TransferableUIUtility.DoCountAdjustInterface(rect5, trad, index, trad.GetMinimumToTransfer(), trad.GetMaximumToTransfer(), flash); } else { DrawWillNotTradeIndication(rect5, trad); } width -= 240f; int num2 = trad.CountHeldBy(Transactor.Colony); if (num2 != 0) { Rect rect6 = new Rect(width - 100f, 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; DrawPrice(rect6, trad, TradeAction.PlayerSells); Rect rect7 = new Rect(rect6.x - 75f, 0f, 75f, rect.height); if (Mouse.IsOver(rect7)) { Widgets.DrawHighlight(rect7); } Text.Anchor = TextAnchor.MiddleLeft; Rect rect8 = rect7; rect8.xMin += 5f; rect8.xMax -= 5f; Widgets.Label(rect8, num2.ToStringCached()); TooltipHandler.TipRegionByKey(rect7, "ColonyCount"); } width -= 175f; TransferableUIUtility.DoExtraAnimalIcons(trad, rect, ref width); Rect idRect = new Rect(0f, 0f, width, rect.height); TransferableUIUtility.DrawTransferableInfo(trad, idRect, trad.TraderWillTrade ? Color.white : NoTradeColor); GenUI.ResetLabelAlign(); GUI.EndGroup(); }
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 DoRow(Rect rect, TransferableOneWay trad, int index, float availableMass) { if (index % 2 == 1) { GUI.DrawTexture(rect, TradeUI.TradeAlternativeBGTex); } Text.Font = GameFont.Small; GUI.BeginGroup(rect); float width = rect.width; int maxCount = trad.MaxCount; Rect rect2 = new Rect((float)(width - 240.0), 0f, 240f, rect.height); TransferableOneWayWidget.stoppingPoints.Clear(); if (this.availableMassGetter != null && (!(trad.AnyThing is Pawn) || this.includePawnsMassInMassUsage)) { float num = availableMass + this.GetMass(trad.AnyThing) * (float)trad.CountToTransfer; int threshold = (!(num <= 0.0)) ? Mathf.FloorToInt(num / this.GetMass(trad.AnyThing)) : 0; TransferableOneWayWidget.stoppingPoints.Add(new TransferableCountToTransferStoppingPoint(threshold, "M<", ">M")); } Rect rect3 = rect2; int min = 0; int max = maxCount; List <TransferableCountToTransferStoppingPoint> extraStoppingPoints = TransferableOneWayWidget.stoppingPoints; TransferableUIUtility.DoCountAdjustInterface(rect3, trad, index, min, max, false, extraStoppingPoints); width = (float)(width - 240.0); if (this.drawMarketValue) { Rect rect4 = new Rect((float)(width - 100.0), 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; this.DrawMarketValue(rect4, trad); width = (float)(width - 100.0); } if (this.drawMass) { Rect rect5 = new Rect((float)(width - 100.0), 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; this.DrawMass(rect5, trad, availableMass); width = (float)(width - 100.0); } if (this.drawDaysUntilRotForTile >= 0) { Rect rect6 = new Rect((float)(width - 75.0), 0f, 75f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; this.DrawDaysUntilRot(rect6, trad); width = (float)(width - 75.0); } Rect rect7 = new Rect((float)(width - 75.0), 0f, 75f, rect.height); if (Mouse.IsOver(rect7)) { Widgets.DrawHighlight(rect7); } Text.Anchor = TextAnchor.MiddleLeft; Rect rect8 = rect7; rect8.xMin += 5f; rect8.xMax -= 5f; Widgets.Label(rect8, maxCount.ToStringCached()); TooltipHandler.TipRegion(rect7, this.sourceCountDesc); width = (float)(width - 75.0); Rect idRect = new Rect(0f, 0f, width, rect.height); TransferableUIUtility.DrawTransferableInfo(trad, idRect, Color.white); GenUI.ResetLabelAlign(); GUI.EndGroup(); }