public static void DrawCaravanInfo(CaravanInfo info, CaravanInfo?info2, int currentTile, int?ticksToArrive, float lastMassFlashTime, Rect rect, bool lerpMassColor = true, string extraDaysWorthOfFoodTipInfo = null, bool multiline = false) { tmpInfo.Clear(); TaggedString taggedString = info.massUsage.ToStringEnsureThreshold(info.massCapacity, 0) + " / " + info.massCapacity.ToString("F0") + " " + "kg".Translate(); TaggedString taggedString2 = info2.HasValue ? (info2.Value.massUsage.ToStringEnsureThreshold(info2.Value.massCapacity, 0) + " / " + info2.Value.massCapacity.ToString("F0") + " " + "kg".Translate()) : ((TaggedString)null); tmpInfo.Add(new TransferableUIUtility.ExtraInfo("Mass".Translate(), taggedString, GetMassColor(info.massUsage, info.massCapacity, lerpMassColor), GetMassTip(info.massUsage, info.massCapacity, info.massCapacityExplanation, info2.HasValue ? new float?(info2.Value.massUsage) : null, info2.HasValue ? new float?(info2.Value.massCapacity) : null, info2.HasValue ? info2.Value.massCapacityExplanation : null), taggedString2, info2.HasValue ? GetMassColor(info2.Value.massUsage, info2.Value.massCapacity, lerpMassColor) : Color.white, lastMassFlashTime)); if (info.extraMassUsage != -1f) { TaggedString taggedString3 = info.extraMassUsage.ToStringEnsureThreshold(info.extraMassCapacity, 0) + " / " + info.extraMassCapacity.ToString("F0") + " " + "kg".Translate(); TaggedString taggedString4 = info2.HasValue ? (info2.Value.extraMassUsage.ToStringEnsureThreshold(info2.Value.extraMassCapacity, 0) + " / " + info2.Value.extraMassCapacity.ToString("F0") + " " + "kg".Translate()) : ((TaggedString)null); tmpInfo.Add(new TransferableUIUtility.ExtraInfo("CaravanMass".Translate(), taggedString3, GetMassColor(info.extraMassUsage, info.extraMassCapacity, lerpMassColor: true), GetMassTip(info.extraMassUsage, info.extraMassCapacity, info.extraMassCapacityExplanation, info2.HasValue ? new float?(info2.Value.extraMassUsage) : null, info2.HasValue ? new float?(info2.Value.extraMassCapacity) : null, info2.HasValue ? info2.Value.extraMassCapacityExplanation : null), taggedString4, info2.HasValue ? GetMassColor(info2.Value.extraMassUsage, info2.Value.extraMassCapacity, lerpMassColor: true) : Color.white)); } string text = "CaravanMovementSpeedTip".Translate(); if (!info.tilesPerDayExplanation.NullOrEmpty()) { text = text + "\n\n" + info.tilesPerDayExplanation; } if (info2.HasValue && !info2.Value.tilesPerDayExplanation.NullOrEmpty()) { text = text + "\n\n-----\n\n" + info2.Value.tilesPerDayExplanation; } tmpInfo.Add(new TransferableUIUtility.ExtraInfo("CaravanMovementSpeed".Translate(), info.tilesPerDay.ToString("0.#") + " " + "TilesPerDay".Translate(), GenUI.LerpColor(TilesPerDayColor, info.tilesPerDay), text, info2.HasValue ? (info2.Value.tilesPerDay.ToString("0.#") + " " + "TilesPerDay".Translate()) : ((TaggedString)null), info2.HasValue ? GenUI.LerpColor(TilesPerDayColor, info2.Value.tilesPerDay) : Color.white)); tmpInfo.Add(new TransferableUIUtility.ExtraInfo("DaysWorthOfFood".Translate(), GetDaysWorthOfFoodLabel(info.daysWorthOfFood, multiline), GetDaysWorthOfFoodColor(info.daysWorthOfFood, ticksToArrive), "DaysWorthOfFoodTooltip".Translate() + extraDaysWorthOfFoodTipInfo + "\n\n" + VirtualPlantsUtility.GetVirtualPlantsStatusExplanationAt(currentTile, Find.TickManager.TicksAbs), info2.HasValue ? GetDaysWorthOfFoodLabel(info2.Value.daysWorthOfFood, multiline) : null, info2.HasValue ? GetDaysWorthOfFoodColor(info2.Value.daysWorthOfFood, ticksToArrive) : Color.white)); string text2 = info.foragedFoodPerDay.Second.ToString("0.#"); string text3 = info2.HasValue ? info2.Value.foragedFoodPerDay.Second.ToString("0.#") : null; TaggedString taggedString5 = "ForagedFoodPerDayTip".Translate(); taggedString5 += "\n\n" + info.foragedFoodPerDayExplanation; if (info2.HasValue) { taggedString5 += "\n\n-----\n\n" + info2.Value.foragedFoodPerDayExplanation; } if (info.foragedFoodPerDay.Second > 0f || (info2.HasValue && info2.Value.foragedFoodPerDay.Second > 0f)) { string text4 = multiline ? "\n" : " "; if (!info2.HasValue) { text2 = text2 + text4 + "(" + info.foragedFoodPerDay.First.label + ")"; } else { text3 = text3 + text4 + "(" + info2.Value.foragedFoodPerDay.First.label.Truncate(50f) + ")"; } } tmpInfo.Add(new TransferableUIUtility.ExtraInfo("ForagedFoodPerDay".Translate(), text2, Color.white, taggedString5, text3, Color.white)); string text5 = "CaravanVisibilityTip".Translate(); if (!info.visibilityExplanation.NullOrEmpty()) { text5 = text5 + "\n\n" + info.visibilityExplanation; } if (info2.HasValue && !info2.Value.visibilityExplanation.NullOrEmpty()) { text5 = text5 + "\n\n-----\n\n" + info2.Value.visibilityExplanation; } tmpInfo.Add(new TransferableUIUtility.ExtraInfo("Visibility".Translate(), info.visibility.ToStringPercent(), GenUI.LerpColor(VisibilityColor, info.visibility), text5, info2.HasValue ? info2.Value.visibility.ToStringPercent() : null, info2.HasValue ? GenUI.LerpColor(VisibilityColor, info2.Value.visibility) : Color.white)); TransferableUIUtility.DrawExtraInfo(tmpInfo, rect); }
public static int Compare(ThingDef lhsTh, ThingDef rhsTh) { if (lhsTh.category != rhsTh.category) { return(lhsTh.category.CompareTo(rhsTh.category)); } var num = TransferableUIUtility.DefaultListOrderPriority(lhsTh); var num2 = TransferableUIUtility.DefaultListOrderPriority(rhsTh); if (num != num2) { return(num.CompareTo(num2)); } var num3 = 0; if (!lhsTh.thingCategories.NullOrEmpty()) { num3 = lhsTh.thingCategories[0].index; } var value = 0; if (!rhsTh.thingCategories.NullOrEmpty()) { value = rhsTh.thingCategories[0].index; } return(num3.CompareTo(value)); }
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(); }
private void DrawMassAndFoodInfo(Rect rect) { TransferableUIUtility.DrawMassInfo(rect, this.SourceMassUsage, this.SourceMassCapacity, "SplitCaravanMassUsageTooltip".Translate(), this.lastSourceMassFlashTime, false); CaravanUIUtility.DrawDaysWorthOfFoodInfo(new Rect(rect.x, rect.y + 19f, rect.width, rect.height), this.SourceDaysWorthOfFood.First, this.SourceDaysWorthOfFood.Second, this.EnvironmentAllowsEatingVirtualPlantsNow, false, 3.40282347E+38f); TransferableUIUtility.DrawMassInfo(rect, this.DestMassUsage, this.DestMassCapacity, "SplitCaravanMassUsageTooltip".Translate(), this.lastDestMassFlashTime, true); CaravanUIUtility.DrawDaysWorthOfFoodInfo(new Rect(rect.x, rect.y + 19f, rect.width, rect.height), this.DestDaysWorthOfFood.First, this.DestDaysWorthOfFood.Second, this.EnvironmentAllowsEatingVirtualPlantsNow, true, 3.40282347E+38f); }
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.TransportersLabelFull })); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; Dialog_LoadShipCargo.tabsList.Clear(); Dialog_LoadShipCargo.tabsList.Add(new TabRecord("PawnsTab".Translate(), delegate { this.tab = Dialog_LoadShipCargo.Tab.Pawns; }, this.tab == Dialog_LoadShipCargo.Tab.Pawns)); Dialog_LoadShipCargo.tabsList.Add(new TabRecord("ItemsTab".Translate(), delegate { this.tab = Dialog_LoadShipCargo.Tab.Items; }, this.tab == Dialog_LoadShipCargo.Tab.Items)); inRect.yMin += 72f; Widgets.DrawMenuSection(inRect); TabDrawer.DrawTabs(inRect, Dialog_LoadShipCargo.tabsList); inRect = inRect.ContractedBy(17f); GUI.BeginGroup(inRect); Rect rect2 = inRect.AtZero(); Rect rect3 = rect2; rect3.xMin += rect2.width - this.pawnsTransfer.TotalNumbersColumnsWidths; rect3.y += 32f; TransferableUIUtility.DrawMassInfo(rect3, this.MassUsage, this.MassCapacity, "TransportersMassUsageTooltip".Translate(), this.lastMassFlashTime, true); CaravanUIUtility.DrawDaysWorthOfFoodInfo(new Rect(rect3.x, rect3.y + 22f, rect3.width, rect3.height), this.DaysWorthOfFood.First, this.DaysWorthOfFood.Second, this.EnvironmentAllowsEatingVirtualPlantsNow, true, 3.40282347E+38f); this.DrawPassengerCapacity(rect3); this.DoBottomButtons(rect2); Rect inRect2 = rect2; inRect2.yMax += 59f; bool flag = false; Dialog_LoadShipCargo.Tab tab = this.tab; if (tab != Dialog_LoadShipCargo.Tab.Pawns) { if (tab == Dialog_LoadShipCargo.Tab.Items) { this.itemsTransfer.OnGUI(inRect2, out flag); } } else { this.pawnsTransfer.OnGUI(inRect2, out flag); } if (flag) { this.CountToTransferChanged(); } GUI.EndGroup(); }
private void SetToLoadEverything() { for (int i = 0; i < this.transferables.Count; i++) { this.transferables[i].SetToTransferMaxToDest(); TransferableUIUtility.ClearEditBuffer(this.transferables[i]); } this.CountToTransferChanged(); }
public virtual void Sort(TabComparer sort1, TabComparer sort2) { var itemsWithValue = items.Where(x => x.MarketValueAll >= 1f); if (sort1 is TabComparer_MarketValueAll && sort2 is TabComparer_None) { items = itemsWithValue .OrderByDescending(x => x, sort1) .ToList(); return; } // sort like trade window items = itemsWithValue .OrderBy(x => x, sort1) .ThenBy(x => x, sort2) .ThenBy(x => TransferableUIUtility.DefaultListOrderPriority(x.thing.def)) .ToList(); }
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); }
public static void DrawCaravanInfo(CaravanInfo info, CaravanInfo?info2, int currentTile, int?ticksToArrive, float lastMassFlashTime, Rect rect, bool lerpMassColor = true, string extraDaysWorthOfFoodTipInfo = null, bool multiline = false) { tmpInfo.Clear(); string text = info.massUsage.ToStringEnsureThreshold(info.massCapacity, 0) + " / " + info.massCapacity.ToString("F0") + " " + "kg".Translate(); object obj2; if (info2.HasValue) { string[] obj = new string[5]; CaravanInfo value = info2.Value; float massUsage = value.massUsage; CaravanInfo value2 = info2.Value; obj[0] = massUsage.ToStringEnsureThreshold(value2.massCapacity, 0); obj[1] = " / "; CaravanInfo value3 = info2.Value; obj[2] = value3.massCapacity.ToString("F0"); obj[3] = " "; obj[4] = "kg".Translate(); obj2 = string.Concat(obj); } else { obj2 = null; } string text2 = (string)obj2; List <TransferableUIUtility.ExtraInfo> list = tmpInfo; string key = "Mass".Translate(); string value4 = text; Color massColor = GetMassColor(info.massUsage, info.massCapacity, lerpMassColor); float massUsage2 = info.massUsage; float massCapacity = info.massCapacity; string massCapacityExplanation = info.massCapacityExplanation; float? massUsage3; if (info2.HasValue) { CaravanInfo value5 = info2.Value; massUsage3 = value5.massUsage; } else { massUsage3 = null; } float?massCapacity2; if (info2.HasValue) { CaravanInfo value6 = info2.Value; massCapacity2 = value6.massCapacity; } else { massCapacity2 = null; } object massCapacity2Explanation; if (info2.HasValue) { CaravanInfo value7 = info2.Value; massCapacity2Explanation = value7.massCapacityExplanation; } else { massCapacity2Explanation = null; } string massTip = GetMassTip(massUsage2, massCapacity, massCapacityExplanation, massUsage3, massCapacity2, (string)massCapacity2Explanation); string secondValue = text2; Color secondColor; if (info2.HasValue) { CaravanInfo value8 = info2.Value; float massUsage4 = value8.massUsage; CaravanInfo value9 = info2.Value; secondColor = GetMassColor(massUsage4, value9.massCapacity, lerpMassColor); } else { secondColor = Color.white; } list.Add(new TransferableUIUtility.ExtraInfo(key, value4, massColor, massTip, secondValue, secondColor, lastMassFlashTime)); if (info.extraMassUsage != -1f) { string text3 = info.extraMassUsage.ToStringEnsureThreshold(info.extraMassCapacity, 0) + " / " + info.extraMassCapacity.ToString("F0") + " " + "kg".Translate(); object obj4; if (info2.HasValue) { string[] obj3 = new string[5]; CaravanInfo value10 = info2.Value; float extraMassUsage = value10.extraMassUsage; CaravanInfo value11 = info2.Value; obj3[0] = extraMassUsage.ToStringEnsureThreshold(value11.extraMassCapacity, 0); obj3[1] = " / "; CaravanInfo value12 = info2.Value; obj3[2] = value12.extraMassCapacity.ToString("F0"); obj3[3] = " "; obj3[4] = "kg".Translate(); obj4 = string.Concat(obj3); } else { obj4 = null; } string text4 = (string)obj4; List <TransferableUIUtility.ExtraInfo> list2 = tmpInfo; string key2 = "CaravanMass".Translate(); string value13 = text3; Color massColor2 = GetMassColor(info.extraMassUsage, info.extraMassCapacity, lerpMassColor: true); float extraMassUsage2 = info.extraMassUsage; float extraMassCapacity = info.extraMassCapacity; string extraMassCapacityExplanation = info.extraMassCapacityExplanation; float? massUsage5; if (info2.HasValue) { CaravanInfo value14 = info2.Value; massUsage5 = value14.extraMassUsage; } else { massUsage5 = null; } float?massCapacity3; if (info2.HasValue) { CaravanInfo value15 = info2.Value; massCapacity3 = value15.extraMassCapacity; } else { massCapacity3 = null; } object massCapacity2Explanation2; if (info2.HasValue) { CaravanInfo value16 = info2.Value; massCapacity2Explanation2 = value16.extraMassCapacityExplanation; } else { massCapacity2Explanation2 = null; } string massTip2 = GetMassTip(extraMassUsage2, extraMassCapacity, extraMassCapacityExplanation, massUsage5, massCapacity3, (string)massCapacity2Explanation2); string secondValue2 = text4; Color secondColor2; if (info2.HasValue) { CaravanInfo value17 = info2.Value; float extraMassUsage3 = value17.extraMassUsage; CaravanInfo value18 = info2.Value; secondColor2 = GetMassColor(extraMassUsage3, value18.extraMassCapacity, lerpMassColor: true); } else { secondColor2 = Color.white; } list2.Add(new TransferableUIUtility.ExtraInfo(key2, value13, massColor2, massTip2, secondValue2, secondColor2)); } string text5 = "CaravanMovementSpeedTip".Translate(); if (!info.tilesPerDayExplanation.NullOrEmpty()) { text5 = text5 + "\n\n" + info.tilesPerDayExplanation; } if (info2.HasValue) { CaravanInfo value19 = info2.Value; if (!value19.tilesPerDayExplanation.NullOrEmpty()) { string str = text5; CaravanInfo value20 = info2.Value; text5 = str + "\n\n-----\n\n" + value20.tilesPerDayExplanation; } } List <TransferableUIUtility.ExtraInfo> list3 = tmpInfo; string key3 = "CaravanMovementSpeed".Translate(); string value21 = info.tilesPerDay.ToString("0.#") + " " + "TilesPerDay".Translate(); Color color = GenUI.LerpColor(TilesPerDayColor, info.tilesPerDay); string tip = text5; object secondValue3; if (info2.HasValue) { CaravanInfo value22 = info2.Value; secondValue3 = value22.tilesPerDay.ToString("0.#") + " " + "TilesPerDay".Translate(); } else { secondValue3 = null; } Color secondColor3; if (info2.HasValue) { List <Pair <float, Color> > tilesPerDayColor = TilesPerDayColor; CaravanInfo value23 = info2.Value; secondColor3 = GenUI.LerpColor(tilesPerDayColor, value23.tilesPerDay); } else { secondColor3 = Color.white; } list3.Add(new TransferableUIUtility.ExtraInfo(key3, value21, color, tip, (string)secondValue3, secondColor3)); List <TransferableUIUtility.ExtraInfo> list4 = tmpInfo; string key4 = "DaysWorthOfFood".Translate(); string daysWorthOfFoodLabel = GetDaysWorthOfFoodLabel(info.daysWorthOfFood, multiline); Color daysWorthOfFoodColor = GetDaysWorthOfFoodColor(info.daysWorthOfFood, ticksToArrive); string tip2 = "DaysWorthOfFoodTooltip".Translate() + extraDaysWorthOfFoodTipInfo + "\n\n" + VirtualPlantsUtility.GetVirtualPlantsStatusExplanationAt(currentTile, Find.TickManager.TicksAbs); object secondValue4; if (info2.HasValue) { CaravanInfo value24 = info2.Value; secondValue4 = GetDaysWorthOfFoodLabel(value24.daysWorthOfFood, multiline); } else { secondValue4 = null; } Color secondColor4; if (info2.HasValue) { CaravanInfo value25 = info2.Value; secondColor4 = GetDaysWorthOfFoodColor(value25.daysWorthOfFood, ticksToArrive); } else { secondColor4 = Color.white; } list4.Add(new TransferableUIUtility.ExtraInfo(key4, daysWorthOfFoodLabel, daysWorthOfFoodColor, tip2, (string)secondValue4, secondColor4)); string text6 = info.foragedFoodPerDay.Second.ToString("0.#"); object obj5; if (info2.HasValue) { CaravanInfo value26 = info2.Value; obj5 = value26.foragedFoodPerDay.Second.ToString("0.#"); } else { obj5 = null; } string text7 = (string)obj5; string str2 = "ForagedFoodPerDayTip".Translate(); str2 = str2 + "\n\n" + info.foragedFoodPerDayExplanation; if (info2.HasValue) { string str3 = str2; CaravanInfo value27 = info2.Value; str2 = str3 + "\n\n-----\n\n" + value27.foragedFoodPerDayExplanation; } if (info.foragedFoodPerDay.Second > 0f) { goto IL_06ad; } if (info2.HasValue) { CaravanInfo value28 = info2.Value; if (value28.foragedFoodPerDay.Second > 0f) { goto IL_06ad; } } goto IL_076b; IL_06ad: string text8 = (!multiline) ? " " : "\n"; if (!info2.HasValue) { string text9 = text6; text6 = text9 + text8 + "(" + info.foragedFoodPerDay.First.label + ")"; } else { string text9 = text7; string[] obj6 = new string[5] { text9, text8, "(", null, null }; CaravanInfo value29 = info2.Value; obj6[3] = value29.foragedFoodPerDay.First.label.Truncate(50f); obj6[4] = ")"; text7 = string.Concat(obj6); } goto IL_076b; IL_076b: tmpInfo.Add(new TransferableUIUtility.ExtraInfo("ForagedFoodPerDay".Translate(), text6, Color.white, str2, text7, Color.white)); string text10 = "CaravanVisibilityTip".Translate(); if (!info.visibilityExplanation.NullOrEmpty()) { text10 = text10 + "\n\n" + info.visibilityExplanation; } if (info2.HasValue) { CaravanInfo value30 = info2.Value; if (!value30.visibilityExplanation.NullOrEmpty()) { string str4 = text10; CaravanInfo value31 = info2.Value; text10 = str4 + "\n\n-----\n\n" + value31.visibilityExplanation; } } List <TransferableUIUtility.ExtraInfo> list5 = tmpInfo; string key5 = "Visibility".Translate(); string value32 = info.visibility.ToStringPercent(); Color color2 = GenUI.LerpColor(VisibilityColor, info.visibility); string tip3 = text10; object secondValue5; if (info2.HasValue) { CaravanInfo value33 = info2.Value; secondValue5 = value33.visibility.ToStringPercent(); } else { secondValue5 = null; } Color secondColor5; if (info2.HasValue) { List <Pair <float, Color> > visibilityColor = VisibilityColor; CaravanInfo value34 = info2.Value; secondColor5 = GenUI.LerpColor(visibilityColor, value34.visibility); } else { secondColor5 = Color.white; } list5.Add(new TransferableUIUtility.ExtraInfo(key5, value32, color2, tip3, (string)secondValue5, secondColor5)); TransferableUIUtility.DrawExtraInfo(tmpInfo, rect); }
public void DrawTradeableRow(Rect rect, Tradeable trad, int index) { if (index == 1) { Widgets.DrawLightHighlight(rect); } Text.Font = GameFont.Small; GUI.BeginGroup(rect); float width = rect.width; int num = trad.CountHeldBy(Transactor.Trader); if (num != 0) { 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.TipRegion(rect2, "TraderCount".Translate()); } width -= 85f; Rect rect4 = new Rect(width - 240f, 0f, 240f, rect.height); if (index == 2 && notesTradeable.CountHeldBy(Transactor.Colony) == 0 && notesTradeable.CountHeldBy(Transactor.Trader) == 0) { Text.Anchor = TextAnchor.MiddleCenter; Color color = GUI.color; GUI.color = Color.gray; Widgets.Label(rect4, "NoNotes".Translate()); GUI.color = color; } else if (index == 1 && isVirtual && VirtualTrader.SilverAlsoAdjustable) { ExtUtil.DoCountAdjustInterfaceForSilver(rect4, trad, index, -trad.CountHeldBy(Transactor.Colony), trad.CountHeldBy(Transactor.Trader), flash: false); } else { TransferableUIUtility.DoCountAdjustInterface(rect4, trad, index, -trad.CountHeldBy(Transactor.Colony), trad.CountHeldBy(Transactor.Trader)); } width -= 240f; int num2 = trad.CountHeldBy(Transactor.Colony); if (num2 != 0) { Rect rect5 = new Rect(width - 75f - 10f, 0f, 75f, rect.height); if (Mouse.IsOver(rect5)) { Widgets.DrawHighlight(rect5); } Text.Anchor = TextAnchor.MiddleLeft; Rect rect6 = rect5; rect6.xMin += 5f; rect6.xMax -= 5f; Widgets.Label(rect6, num2.ToStringCached()); TooltipHandler.TipRegion(rect5, "ColonyCount".Translate()); } GenUI.ResetLabelAlign(); GUI.EndGroup(); }
public static void DrawCaravanInfo(CaravanUIUtility.CaravanInfo info, CaravanUIUtility.CaravanInfo?info2, int currentTile, int?ticksToArrive, float lastMassFlashTime, Rect rect, bool lerpMassColor = true, string extraDaysWorthOfFoodTipInfo = null, bool multiline = false) { CaravanUIUtility.tmpInfo.Clear(); string value = string.Concat(new string[] { info.massUsage.ToStringEnsureThreshold(info.massCapacity, 0), " / ", info.massCapacity.ToString("F0"), " ", "kg".Translate() }); string secondValue = (!info2.HasValue) ? null : string.Concat(new string[] { info2.Value.massUsage.ToStringEnsureThreshold(info2.Value.massCapacity, 0), " / ", info2.Value.massCapacity.ToString("F0"), " ", "kg".Translate() }); CaravanUIUtility.tmpInfo.Add(new TransferableUIUtility.ExtraInfo("Mass".Translate(), value, CaravanUIUtility.GetMassColor(info.massUsage, info.massCapacity, lerpMassColor), CaravanUIUtility.GetMassTip(info.massUsage, info.massCapacity, info.massCapacityExplanation, (!info2.HasValue) ? null : new float?(info2.Value.massUsage), (!info2.HasValue) ? null : new float?(info2.Value.massCapacity), (!info2.HasValue) ? null : info2.Value.massCapacityExplanation), secondValue, (!info2.HasValue) ? Color.white : CaravanUIUtility.GetMassColor(info2.Value.massUsage, info2.Value.massCapacity, lerpMassColor), lastMassFlashTime)); if (info.extraMassUsage != -1f) { string value2 = string.Concat(new string[] { info.extraMassUsage.ToStringEnsureThreshold(info.extraMassCapacity, 0), " / ", info.extraMassCapacity.ToString("F0"), " ", "kg".Translate() }); string secondValue2 = (!info2.HasValue) ? null : string.Concat(new string[] { info2.Value.extraMassUsage.ToStringEnsureThreshold(info2.Value.extraMassCapacity, 0), " / ", info2.Value.extraMassCapacity.ToString("F0"), " ", "kg".Translate() }); CaravanUIUtility.tmpInfo.Add(new TransferableUIUtility.ExtraInfo("CaravanMass".Translate(), value2, CaravanUIUtility.GetMassColor(info.extraMassUsage, info.extraMassCapacity, true), CaravanUIUtility.GetMassTip(info.extraMassUsage, info.extraMassCapacity, info.extraMassCapacityExplanation, (!info2.HasValue) ? null : new float?(info2.Value.extraMassUsage), (!info2.HasValue) ? null : new float?(info2.Value.extraMassCapacity), (!info2.HasValue) ? null : info2.Value.extraMassCapacityExplanation), secondValue2, (!info2.HasValue) ? Color.white : CaravanUIUtility.GetMassColor(info2.Value.extraMassUsage, info2.Value.extraMassCapacity, true), -9999f)); } string text = "CaravanMovementSpeedTip".Translate(); if (!info.tilesPerDayExplanation.NullOrEmpty()) { text = text + "\n\n" + info.tilesPerDayExplanation; } if (info2.HasValue && !info2.Value.tilesPerDayExplanation.NullOrEmpty()) { text = text + "\n\n-----\n\n" + info2.Value.tilesPerDayExplanation; } CaravanUIUtility.tmpInfo.Add(new TransferableUIUtility.ExtraInfo("CaravanMovementSpeed".Translate(), info.tilesPerDay.ToString("0.#") + " " + "TilesPerDay".Translate(), GenUI.LerpColor(CaravanUIUtility.TilesPerDayColor, info.tilesPerDay), text, (!info2.HasValue) ? null : (info2.Value.tilesPerDay.ToString("0.#") + " " + "TilesPerDay".Translate()), (!info2.HasValue) ? Color.white : GenUI.LerpColor(CaravanUIUtility.TilesPerDayColor, info2.Value.tilesPerDay), -9999f)); CaravanUIUtility.tmpInfo.Add(new TransferableUIUtility.ExtraInfo("DaysWorthOfFood".Translate(), CaravanUIUtility.GetDaysWorthOfFoodLabel(info.daysWorthOfFood, multiline), CaravanUIUtility.GetDaysWorthOfFoodColor(info.daysWorthOfFood, ticksToArrive), "DaysWorthOfFoodTooltip".Translate() + extraDaysWorthOfFoodTipInfo + "\n\n" + VirtualPlantsUtility.GetVirtualPlantsStatusExplanationAt(currentTile, Find.TickManager.TicksAbs), (!info2.HasValue) ? null : CaravanUIUtility.GetDaysWorthOfFoodLabel(info2.Value.daysWorthOfFood, multiline), (!info2.HasValue) ? Color.white : CaravanUIUtility.GetDaysWorthOfFoodColor(info2.Value.daysWorthOfFood, ticksToArrive), -9999f)); string text2 = info.foragedFoodPerDay.Second.ToString("0.#"); string text3 = (!info2.HasValue) ? null : info2.Value.foragedFoodPerDay.Second.ToString("0.#"); string text4 = "ForagedFoodPerDayTip".Translate(); text4 = text4 + "\n\n" + info.foragedFoodPerDayExplanation; if (info2.HasValue) { text4 = text4 + "\n\n-----\n\n" + info2.Value.foragedFoodPerDayExplanation; } if (info.foragedFoodPerDay.Second > 0f || (info2.HasValue && info2.Value.foragedFoodPerDay.Second > 0f)) { string text5 = (!multiline) ? " " : "\n"; if (!info2.HasValue) { string text6 = text2; text2 = string.Concat(new string[] { text6, text5, "(", info.foragedFoodPerDay.First.label, ")" }); } else { string text6 = text3; text3 = string.Concat(new string[] { text6, text5, "(", info2.Value.foragedFoodPerDay.First.label.Truncate(50f, null), ")" }); } } CaravanUIUtility.tmpInfo.Add(new TransferableUIUtility.ExtraInfo("ForagedFoodPerDay".Translate(), text2, Color.white, text4, text3, Color.white, -9999f)); string text7 = "CaravanVisibilityTip".Translate(); if (!info.visibilityExplanation.NullOrEmpty()) { text7 = text7 + "\n\n" + info.visibilityExplanation; } if (info2.HasValue && !info2.Value.visibilityExplanation.NullOrEmpty()) { text7 = text7 + "\n\n-----\n\n" + info2.Value.visibilityExplanation; } CaravanUIUtility.tmpInfo.Add(new TransferableUIUtility.ExtraInfo("Visibility".Translate(), info.visibility.ToStringPercent(), GenUI.LerpColor(CaravanUIUtility.VisibilityColor, info.visibility), text7, (!info2.HasValue) ? null : info2.Value.visibility.ToStringPercent(), (!info2.HasValue) ? Color.white : GenUI.LerpColor(CaravanUIUtility.VisibilityColor, info2.Value.visibility), -9999f)); TransferableUIUtility.DrawExtraInfo(CaravanUIUtility.tmpInfo, rect); }
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((TransferableImmutable tr) => TransferableUIUtility.DefaultListOrderPriority(tr)) .ToList(); cachedItemsCount = list.Count; cachedItemsHash = seed; }
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(); }
private static float <CacheItems> m__4(TransferableImmutable tr) { return(TransferableUIUtility.DefaultListOrderPriority(tr)); }
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 <TransferableOneWay>()); } }
private void DrawTradeableRow(Rect rowRect, ThingEntry entry, int index) { if (index % 2 == 1) { Widgets.DrawLightHighlight(rowRect); } var trade = entry.tradeable; // Begin Row group GUI.BeginGroup(rowRect); float x = 0; // starting from left // Draw item icon and info icon Text.Anchor = TextAnchor.MiddleLeft; var idRect = new Rect(x, 0, iconNameAreaWidth, rowRect.height); TransferableUIUtility.DoExtraAnimalIcons(trade, rowRect, ref x); DrawTradeableLabels(idRect, entry); x += iconNameAreaWidth; // Draw the price for requesting the item var priceTextArea = new Rect(x, 0, priceTextAreaWidth, rowRect.height); var price = DrawPrice(priceTextArea, trade); x += priceTextAreaWidth; // Draw the number the colony currently has, if any var countHeldBy = trade.CountHeldBy(Transactor.Colony); if (countHeldBy != 0) { var colonyItemCountArea = new Rect(x, 0, colonyItemCountAreaWidth, rowRect.height); if (Mouse.IsOver(colonyItemCountArea)) { Widgets.DrawHighlight(colonyItemCountArea); } var paddedRect = colonyItemCountArea; paddedRect.xMin += 5f; paddedRect.xMax -= 5f; Widgets.Label(paddedRect, countHeldBy.ToStringCached()); TooltipHandler.TipRegion(colonyItemCountArea, colonyCountTooltipText); } // Draw the input box to select number of requests var countAdjustInterfaceRect = new Rect(rightAlignOffset, 0, rightContentSize, rowRect.height); var interactiveNumericFieldArea = new Rect(countAdjustInterfaceRect.center.x - 45f, countAdjustInterfaceRect.center.y - 12.5f, 90f, 25f).Rounded(); var paddedNumericFieldArea = interactiveNumericFieldArea.ContractedBy(2f); paddedNumericFieldArea.xMax -= 15f; paddedNumericFieldArea.xMin += 16f; if (requestSession?.deal != null) { var amountRequested = requestSession.deal.GetCountForItem(thingTypeFilter, trade); var amountAsString = amountRequested.ToString(); Widgets.TextFieldNumeric(paddedNumericFieldArea, ref amountRequested, ref amountAsString, 0, float.MaxValue); requestSession.deal.AdjustItemRequest(thingTypeFilter, entry, amountRequested, price); // Draw the reset to zero button by input field if (amountRequested > 0) { var resetToZeroButton = interactiveNumericFieldArea; resetToZeroButton.x -= resetItemCountAreaWidth - 5; resetToZeroButton.width = resetItemCountAreaWidth; if (Widgets.ButtonText(resetToZeroButton, "0")) { requestSession.deal.AdjustItemRequest(thingTypeFilter, entry, 0, price); } } } // End Row group GenUI.ResetLabelAlign(); GUI.EndGroup(); }
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) select tr).OrderByDescending(delegate(Tradeable tr) { if (!tr.TraderWillTrade) { return(-1); } return(0); }).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(delegate(Tradeable tr) { QualityCategory result; if (tr.AnyThing.TryGetQuality(out result)) { return((int)result); } return(-1); }).ThenBy((Tradeable tr) => tr.AnyThing.HitPoints).ToList <Tradeable>(); }