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);
 }
 private void CalculateAndRecacheTransferables()
 {
     this.transferables = new List <TransferableOneWay>();
     this.AddPawnsToTransferables();
     this.AddItemsToTransferables();
     CaravanUIUtility.CreateCaravanTransferableWidgets(this.transferables, out this.pawnsTransfer, out this.itemsTransfer, "CaravanSplitSourceLabel".Translate(), "CaravanSplitDestLabel".Translate(), "SplitCaravanThingCountTip".Translate(), IgnorePawnsInventoryMode.Ignore, () => this.DestMassCapacity - this.DestMassUsage, false, this.caravan.Tile);
     this.CountToTransferChanged();
 }
Example #3
0
 private void CalculateAndRecacheTransferables()
 {
     transferables = new List <TransferableOneWay>();
     AddPawnsToTransferables();
     AddItemsToTransferables();
     CaravanUIUtility.CreateCaravanTransferableWidgets(transferables, out pawnsTransfer, out itemsTransfer, "SplitCaravanThingCountTip".Translate(), IgnorePawnsInventoryMode.Ignore, () => DestMassCapacity - DestMassUsage, ignoreSpawnedCorpsesGearAndInventoryMass: false, caravan.Tile);
     CountToTransferChanged();
 }
Example #4
0
        public override void DoWindowContents(Rect inRect)
        {
            Rect rect = new Rect(0f, 0f, inRect.width, 35f);

            Text.Font   = GameFont.Medium;
            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(rect, "SplitCaravan".Translate());
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;
            CaravanUIUtility.DrawCaravanInfo(new CaravanUIUtility.CaravanInfo(SourceMassUsage, SourceMassCapacity, cachedSourceMassCapacityExplanation, SourceTilesPerDay, cachedSourceTilesPerDayExplanation, SourceDaysWorthOfFood, SourceForagedFoodPerDay, cachedSourceForagedFoodPerDayExplanation, SourceVisibility, cachedSourceVisibilityExplanation), new CaravanUIUtility.CaravanInfo(DestMassUsage, DestMassCapacity, cachedDestMassCapacityExplanation, DestTilesPerDay, cachedDestTilesPerDayExplanation, DestDaysWorthOfFood, DestForagedFoodPerDay, cachedDestForagedFoodPerDayExplanation, DestVisibility, cachedDestVisibilityExplanation), caravan.Tile, caravan.pather.Moving ? new int?(TicksToArrive) : null, -9999f, new Rect(12f, 35f, inRect.width - 24f, 40f));
            tabsList.Clear();
            tabsList.Add(new TabRecord("PawnsTab".Translate(), delegate
            {
                tab = Tab.Pawns;
            }, tab == Tab.Pawns));
            tabsList.Add(new TabRecord("ItemsTab".Translate(), delegate
            {
                tab = Tab.Items;
            }, tab == Tab.Items));
            tabsList.Add(new TabRecord("FoodAndMedicineTab".Translate(), delegate
            {
                tab = Tab.FoodAndMedicine;
            }, tab == Tab.FoodAndMedicine));
            inRect.yMin += 119f;
            Widgets.DrawMenuSection(inRect);
            TabDrawer.DrawTabs(inRect, tabsList);
            inRect = inRect.ContractedBy(17f);
            GUI.BeginGroup(inRect);
            Rect rect2 = inRect.AtZero();

            DoBottomButtons(rect2);
            Rect inRect2 = rect2;

            inRect2.yMax -= 59f;
            bool anythingChanged = false;

            switch (tab)
            {
            case Tab.Pawns:
                pawnsTransfer.OnGUI(inRect2, out anythingChanged);
                break;

            case Tab.Items:
                itemsTransfer.OnGUI(inRect2, out anythingChanged);
                break;

            case Tab.FoodAndMedicine:
                foodAndMedicineTransfer.OnGUI(inRect2, out anythingChanged);
                break;
            }
            if (anythingChanged)
            {
                CountToTransferChanged();
            }
            GUI.EndGroup();
        }
Example #5
0
        public override void DoWindowContents(Rect inRect)
        {
            Rect rect = new Rect(0f, 0f, inRect.width, 35f);

            Text.Font   = GameFont.Medium;
            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(rect, "SplitCaravan".Translate());
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;
            CaravanUIUtility.DrawCaravanInfo(new CaravanUIUtility.CaravanInfo(this.SourceMassUsage, this.SourceMassCapacity, this.cachedSourceMassCapacityExplanation, this.SourceTilesPerDay, this.cachedSourceTilesPerDayExplanation, this.SourceDaysWorthOfFood, this.SourceForagedFoodPerDay, this.cachedSourceForagedFoodPerDayExplanation, this.SourceVisibility, this.cachedSourceVisibilityExplanation, -1f, -1f, null), new CaravanUIUtility.CaravanInfo?(new CaravanUIUtility.CaravanInfo(this.DestMassUsage, this.DestMassCapacity, this.cachedDestMassCapacityExplanation, this.DestTilesPerDay, this.cachedDestTilesPerDayExplanation, this.DestDaysWorthOfFood, this.DestForagedFoodPerDay, this.cachedDestForagedFoodPerDayExplanation, this.DestVisibility, this.cachedDestVisibilityExplanation, -1f, -1f, null)), this.caravan.Tile, (!this.caravan.pather.Moving) ? null : new int?(this.TicksToArrive), -9999f, new Rect(12f, 35f, inRect.width - 24f, 40f), true, null, false);
            Dialog_SplitCaravan.tabsList.Clear();
            Dialog_SplitCaravan.tabsList.Add(new TabRecord("PawnsTab".Translate(), delegate
            {
                this.tab = Dialog_SplitCaravan.Tab.Pawns;
            }, this.tab == Dialog_SplitCaravan.Tab.Pawns));
            Dialog_SplitCaravan.tabsList.Add(new TabRecord("ItemsTab".Translate(), delegate
            {
                this.tab = Dialog_SplitCaravan.Tab.Items;
            }, this.tab == Dialog_SplitCaravan.Tab.Items));
            inRect.yMin += 119f;
            Widgets.DrawMenuSection(inRect);
            TabDrawer.DrawTabs(inRect, Dialog_SplitCaravan.tabsList, 200f);
            inRect = inRect.ContractedBy(17f);
            GUI.BeginGroup(inRect);
            Rect rect2 = inRect.AtZero();

            this.DoBottomButtons(rect2);
            Rect inRect2 = rect2;

            inRect2.yMax -= 59f;
            bool flag = false;

            Dialog_SplitCaravan.Tab tab = this.tab;
            if (tab != Dialog_SplitCaravan.Tab.Pawns)
            {
                if (tab == Dialog_SplitCaravan.Tab.Items)
                {
                    this.itemsTransfer.OnGUI(inRect2, out flag);
                }
            }
            else
            {
                this.pawnsTransfer.OnGUI(inRect2, out flag);
            }
            if (flag)
            {
                this.CountToTransferChanged();
            }
            GUI.EndGroup();
        }
Example #6
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            if (!caravan.Spawned)
            {
                return(new GizmoResult(GizmoState.Clear));
            }
            Rect rect = new Rect(topLeft.x, topLeft.y, GetWidth(maxWidth), 75f);

            Widgets.DrawWindowBackground(rect);
            GUI.BeginGroup(rect);
            Rect          rect2         = rect.AtZero();
            int?          ticksToArrive = (caravan.pather.Moving ? new int?(CaravanArrivalTimeEstimator.EstimatedTicksToArrive(caravan, allowCaching: true)) : null);
            StringBuilder stringBuilder = new StringBuilder();

            CaravanUIUtility.DrawCaravanInfo(new CaravanUIUtility.CaravanInfo(tilesPerDay: TilesPerDayCalculator.ApproxTilesPerDay(caravan, stringBuilder), massUsage: caravan.MassUsage, massCapacity: caravan.MassCapacity, massCapacityExplanation: caravan.MassCapacityExplanation, tilesPerDayExplanation: stringBuilder.ToString(), daysWorthOfFood: caravan.DaysWorthOfFood, foragedFoodPerDay: caravan.forage.ForagedFoodPerDay, foragedFoodPerDayExplanation: caravan.forage.ForagedFoodPerDayExplanation, visibility: caravan.Visibility, visibilityExplanation: caravan.VisibilityExplanation), null, caravan.Tile, ticksToArrive, -9999f, rect2, lerpMassColor: true, null, multiline: true);
            GUI.EndGroup();
            GenUI.AbsorbClicksInRect(rect);
            return(new GizmoResult(GizmoState.Clear));
        }
Example #7
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            if (!this.caravan.Spawned)
            {
                return(new GizmoResult(GizmoState.Clear));
            }
            Rect rect = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), 75f);

            Widgets.DrawWindowBackground(rect);
            GUI.BeginGroup(rect);
            Rect          rect2         = rect.AtZero();
            int?          ticksToArrive = (!this.caravan.pather.Moving) ? null : new int?(CaravanArrivalTimeEstimator.EstimatedTicksToArrive(this.caravan, true));
            StringBuilder stringBuilder = new StringBuilder();
            float         tilesPerDay   = TilesPerDayCalculator.ApproxTilesPerDay(this.caravan, stringBuilder);

            CaravanUIUtility.DrawCaravanInfo(new CaravanUIUtility.CaravanInfo(this.caravan.MassUsage, this.caravan.MassCapacity, this.caravan.MassCapacityExplanation, tilesPerDay, stringBuilder.ToString(), this.caravan.DaysWorthOfFood, this.caravan.forage.ForagedFoodPerDay, this.caravan.forage.ForagedFoodPerDayExplanation, this.caravan.Visibility, this.caravan.VisibilityExplanation, -1f, -1f, null), null, this.caravan.Tile, ticksToArrive, -9999f, rect2, true, null, true);
            GUI.EndGroup();
            GenUI.AbsorbClicksInRect(rect);
            return(new GizmoResult(GizmoState.Clear));
        }
Example #8
0
        public static void CreateCaravanTransferableWidgets(List <TransferableOneWay> transferables, out TransferableOneWayWidget pawnsTransfer, out TransferableOneWayWidget itemsTransfer, string thingCountTip, IgnorePawnsInventoryMode ignorePawnInventoryMass, Func <float> availableMassGetter, bool ignoreSpawnedCorpsesGearAndInventoryMass, int tile, bool playerPawnsReadOnly = false)
        {
            IEnumerable <TransferableOneWay> transferables2 = null;
            string sourceLabel                 = null;
            string destinationLabel            = null;
            bool   drawMass                    = true;
            bool   includePawnsMassInMassUsage = false;

            pawnsTransfer = new TransferableOneWayWidget(transferables2, sourceLabel, destinationLabel, thingCountTip, drawMass, ignorePawnInventoryMass, includePawnsMassInMassUsage, availableMassGetter, 0f, ignoreSpawnedCorpsesGearAndInventoryMass, tile, true, true, true, false, true, false, playerPawnsReadOnly);
            CaravanUIUtility.AddPawnsSections(pawnsTransfer, transferables);
            transferables2 = from x in transferables
                             where x.ThingDef.category != ThingCategory.Pawn
                             select x;
            string sourceLabel2 = null;

            destinationLabel = null;
            bool drawMass2 = true;
            bool includePawnsMassInMassUsage2 = false;

            itemsTransfer = new TransferableOneWayWidget(transferables2, sourceLabel2, destinationLabel, thingCountTip, drawMass2, ignorePawnInventoryMass, includePawnsMassInMassUsage2, availableMassGetter, 0f, ignoreSpawnedCorpsesGearAndInventoryMass, tile, true, false, false, true, false, true, false);
        }
Example #9
0
        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);
        }