Ejemplo n.º 1
0
        private void CalculateAndRecacheTransferables()
        {
            transferables = new List <TransferableOneWay>();
            AddPawnsToTransferables();
            AddItemsToTransferables();
            IEnumerable <TransferableOneWay> enumerable = null;
            string sourceLabel      = null;
            string destinationLabel = null;
            string sourceCountDesc  = "FormCaravanColonyThingCountTip".Translate();
            bool   drawMass         = true;
            IgnorePawnsInventoryMode ignorePawnInventoryMass = IgnorePawnsInventoryMode.IgnoreIfAssignedToUnload;
            bool         includePawnsMassInMassUsage         = true;
            Func <float> availableMassGetter = () => MassCapacity - MassUsage;
            int          tile = map.Tile;

            pawnsTransfer = new TransferableOneWayWidget(enumerable, sourceLabel, destinationLabel, sourceCountDesc, drawMass, ignorePawnInventoryMass, includePawnsMassInMassUsage, availableMassGetter, 0f, ignoreSpawnedCorpseGearAndInventoryMass: false, tile, drawMarketValue: true, drawEquippedWeapon: true, drawNutritionEatenPerDay: true, drawItemNutrition: false, drawForagedFoodPerDay: true);
            CaravanUIUtility.AddPawnsSections(pawnsTransfer, transferables);
            enumerable = from x in transferables
                         where x.ThingDef.category != ThingCategory.Pawn
                         select x;

            sourceCountDesc             = null;
            destinationLabel            = null;
            sourceLabel                 = "FormCaravanColonyThingCountTip".Translate();
            includePawnsMassInMassUsage = true;
            ignorePawnInventoryMass     = IgnorePawnsInventoryMode.IgnoreIfAssignedToUnload;
            drawMass            = true;
            availableMassGetter = (() => MassCapacity - MassUsage);
            tile          = map.Tile;
            itemsTransfer = new TransferableOneWayWidget(enumerable, sourceCountDesc, destinationLabel, sourceLabel, includePawnsMassInMassUsage, ignorePawnInventoryMass, drawMass, availableMassGetter, 0f, ignoreSpawnedCorpseGearAndInventoryMass: false, tile, drawMarketValue: true, drawEquippedWeapon: false, drawNutritionEatenPerDay: false, drawItemNutrition: true, drawForagedFoodPerDay: false, drawDaysUntilRot: true);
            CountToTransferChanged();
        }
Ejemplo n.º 2
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, ((!this.reform) ? "FormCaravan" : "ReformCaravan").Translate());
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;
            CaravanUIUtility.CaravanInfo info  = 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);
            CaravanUIUtility.CaravanInfo?info2 = null;
            int    currentTile   = this.CurrentTile;
            int?   ticksToArrive = (this.destinationTile != -1) ? new int?(this.TicksToArrive) : null;
            float  num           = this.lastMassFlashTime;
            Rect   rect2         = new Rect(12f, 35f, inRect.width - 24f, 40f);
            string extraDaysWorthOfFoodTipInfo = (this.destinationTile != -1) ? ("\n" + "DaysWorthOfFoodTooltip_OnlyFirstWaypoint".Translate()) : null;

            CaravanUIUtility.DrawCaravanInfo(info, info2, currentTile, ticksToArrive, num, rect2, true, extraDaysWorthOfFoodTipInfo, false);
            Dialog_FormCaravan.tabsList.Clear();
            Dialog_FormCaravan.tabsList.Add(new TabRecord("PawnsTab".Translate(), delegate
            {
                this.tab = Dialog_FormCaravan.Tab.Pawns;
            }, this.tab == Dialog_FormCaravan.Tab.Pawns));
            Dialog_FormCaravan.tabsList.Add(new TabRecord("ItemsTab".Translate(), delegate
            {
                this.tab = Dialog_FormCaravan.Tab.Items;
            }, this.tab == Dialog_FormCaravan.Tab.Items));
            inRect.yMin += 119f;
            Widgets.DrawMenuSection(inRect);
            TabDrawer.DrawTabs(inRect, Dialog_FormCaravan.tabsList, 200f);
            Dialog_FormCaravan.tabsList.Clear();
            inRect         = inRect.ContractedBy(17f);
            inRect.height += 17f;
            GUI.BeginGroup(inRect);
            Rect rect3 = inRect.AtZero();

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

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

            Dialog_FormCaravan.Tab tab = this.tab;
            if (tab != Dialog_FormCaravan.Tab.Pawns)
            {
                if (tab == Dialog_FormCaravan.Tab.Items)
                {
                    this.itemsTransfer.OnGUI(inRect2, out flag);
                }
            }
            else
            {
                this.pawnsTransfer.OnGUI(inRect2, out flag);
            }
            if (flag)
            {
                this.CountToTransferChanged();
            }
            GUI.EndGroup();
        }
Ejemplo n.º 3
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, (reform ? "ReformCaravan" : "FormCaravan").Translate());
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;
            CaravanUIUtility.DrawCaravanInfo(new CaravanUIUtility.CaravanInfo(MassUsage, MassCapacity, cachedMassCapacityExplanation, TilesPerDay, cachedTilesPerDayExplanation, DaysWorthOfFood, ForagedFoodPerDay, cachedForagedFoodPerDayExplanation, Visibility, cachedVisibilityExplanation), null, CurrentTile, (destinationTile == -1) ? null : new int?(TicksToArrive), lastMassFlashTime, new Rect(12f, 35f, inRect.width - 24f, 40f), lerpMassColor: true, (destinationTile == -1) ? ((TaggedString)null) : ("\n" + "DaysWorthOfFoodTooltip_OnlyFirstWaypoint".Translate()));
            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);
            tabsList.Clear();
            inRect         = inRect.ContractedBy(17f);
            inRect.height += 17f;
            GUI.BeginGroup(inRect);
            Rect rect2 = inRect.AtZero();

            DoBottomButtons(rect2);
            Rect rect3 = rect2;

            rect3.yMax -= 76f;
            bool anythingChanged = false;

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

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

            case Tab.FoodAndMedicine:
                foodAndMedicineTransfer.extraHeaderSpace = 35f;
                foodAndMedicineTransfer.OnGUI(rect3, out anythingChanged);
                DrawAutoSelectCheckbox(rect3, ref anythingChanged);
                break;
            }
            if (anythingChanged)
            {
                CountToTransferChanged();
            }
            GUI.EndGroup();
        }
Ejemplo n.º 4
0
        private void CalculateAndRecacheTransferables()
        {
            this.transferables = new List <TransferableOneWay>();
            this.AddPawnsToTransferables();
            this.AddItemsToTransferables();
            IEnumerable <TransferableOneWay> enumerable = null;
            string text             = null;
            string destinationLabel = null;
            string text2            = "FormCaravanColonyThingCountTip".Translate();
            bool   flag             = true;
            IgnorePawnsInventoryMode ignorePawnInventoryMass = IgnorePawnsInventoryMode.IgnoreIfAssignedToUnload;
            bool         flag2 = true;
            Func <float> availableMassGetter = () => this.MassCapacity - this.MassUsage;
            int          tile = this.map.Tile;

            this.pawnsTransfer = new TransferableOneWayWidget(enumerable, text, destinationLabel, text2, flag, ignorePawnInventoryMass, flag2, availableMassGetter, 0f, false, tile, true, true, true, false, true, false, false);
            CaravanUIUtility.AddPawnsSections(this.pawnsTransfer, this.transferables);
            enumerable = from x in this.transferables
                         where x.ThingDef.category != ThingCategory.Pawn
                         select x;

            text2                   = null;
            destinationLabel        = null;
            text                    = "FormCaravanColonyThingCountTip".Translate();
            flag2                   = true;
            ignorePawnInventoryMass = IgnorePawnsInventoryMode.IgnoreIfAssignedToUnload;
            flag                    = true;
            availableMassGetter     = (() => this.MassCapacity - this.MassUsage);
            tile                    = this.map.Tile;
            this.itemsTransfer      = new TransferableOneWayWidget(enumerable, text2, destinationLabel, text, flag2, ignorePawnInventoryMass, flag, availableMassGetter, 0f, false, tile, true, false, false, true, false, true, false);
            this.CountToTransferChanged();
        }
Ejemplo n.º 5
0
 private void CalculateAndRecacheTransferables()
 {
     this.transferables = new List <TransferableOneWay>();
     this.AddPawnsToTransferables();
     this.AddItemsToTransferables();
     CaravanUIUtility.CreateCaravanTransferableWidgets(this.transferables, out this.pawnsTransfer, out this.itemsTransfer, "FormCaravanColonyThingCountTip".Translate(), this.IgnoreInventoryMode, () => this.MassCapacity - this.MassUsage, this.AutoStripSpawnedCorpses, this.CurrentTile, this.mapAboutToBeRemoved);
     this.CountToTransferChanged();
 }
Ejemplo n.º 6
0
 private void CalculateAndRecacheTransferables()
 {
     transferables = new List <TransferableOneWay>();
     AddPawnsToTransferables();
     AddItemsToTransferables();
     CaravanUIUtility.CreateCaravanTransferableWidgets_NewTmp(transferables, out pawnsTransfer, out itemsTransfer, out foodAndMedicineTransfer, "FormCaravanColonyThingCountTip".Translate(), IgnoreInventoryMode, () => MassCapacity - MassUsage, AutoStripSpawnedCorpses, CurrentTile, mapAboutToBeRemoved);
     CountToTransferChanged();
 }
 public static void CreateCaravanTransferableWidgets(List <TransferableOneWay> transferables, out TransferableOneWayWidget pawnsTransfer, out TransferableOneWayWidget itemsTransfer, string sourceLabel, string destLabel, string thingCountTip, IgnorePawnsInventoryMode ignorePawnInventoryMass, Func <float> availableMassGetter, bool ignoreCorpsesGearAndInventoryMass, int drawDaysUntilRotForTile)
 {
     pawnsTransfer = new TransferableOneWayWidget(null, sourceLabel, destLabel, thingCountTip, true, ignorePawnInventoryMass, false, availableMassGetter, 24f, ignoreCorpsesGearAndInventoryMass, true, -1);
     CaravanUIUtility.AddPawnsSections(pawnsTransfer, transferables);
     itemsTransfer = new TransferableOneWayWidget(from x in transferables
                                                  where x.ThingDef.category != ThingCategory.Pawn
                                                  select x, sourceLabel, destLabel, thingCountTip, true, ignorePawnInventoryMass, false, availableMassGetter, 24f, ignoreCorpsesGearAndInventoryMass, true, drawDaysUntilRotForTile);
 }
Ejemplo n.º 8
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, ((!reform) ? "FormCaravan" : "ReformCaravan").Translate());
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;
            CaravanUIUtility.CaravanInfo info  = new CaravanUIUtility.CaravanInfo(MassUsage, MassCapacity, cachedMassCapacityExplanation, TilesPerDay, cachedTilesPerDayExplanation, DaysWorthOfFood, ForagedFoodPerDay, cachedForagedFoodPerDayExplanation, Visibility, cachedVisibilityExplanation);
            CaravanUIUtility.CaravanInfo?info2 = null;
            int    currentTile   = CurrentTile;
            int?   ticksToArrive = (destinationTile != -1) ? new int?(TicksToArrive) : null;
            float  num           = lastMassFlashTime;
            Rect   rect2         = new Rect(12f, 35f, inRect.width - 24f, 40f);
            string extraDaysWorthOfFoodTipInfo = (destinationTile != -1) ? ("\n" + "DaysWorthOfFoodTooltip_OnlyFirstWaypoint".Translate()) : null;

            CaravanUIUtility.DrawCaravanInfo(info, info2, currentTile, ticksToArrive, num, rect2, lerpMassColor: true, extraDaysWorthOfFoodTipInfo);
            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));
            inRect.yMin += 119f;
            Widgets.DrawMenuSection(inRect);
            TabDrawer.DrawTabs(inRect, tabsList);
            tabsList.Clear();
            inRect         = inRect.ContractedBy(17f);
            inRect.height += 17f;
            GUI.BeginGroup(inRect);
            Rect rect3 = inRect.AtZero();

            DoBottomButtons(rect3);
            Rect inRect2 = rect3;

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

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

            case Tab.Items:
                itemsTransfer.OnGUI(inRect2, out anythingChanged);
                break;
            }
            if (anythingChanged)
            {
                CountToTransferChanged();
            }
            GUI.EndGroup();
        }
        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();
        }
Ejemplo n.º 10
0
        private void CalculateAndRecacheTransferables()
        {
            this.transferables = new List <TransferableOneWay>();
            this.AddPawnsToTransferables();
            this.AddItemsToTransferables();
            string sourceLabel = (!this.reform) ? Faction.OfPlayer.Name : this.map.info.parent.LabelCap;

            CaravanUIUtility.CreateCaravanTransferableWidgets(this.transferables, out this.pawnsTransfer, out this.itemsTransfer, sourceLabel, WorldObjectDefOf.Caravan.LabelCap, "FormCaravanColonyThingCountTip".Translate(), IgnorePawnsInventoryMode.IgnoreIfAssignedToUnload, (Func <float>)(() => this.MassCapacity - this.MassUsage), this.AutoStripCorpses, this.CurrentTile);
            this.CountToTransferChanged();
        }
 private void CalculateAndRecacheTransferables()
 {
     this.transferables = new List <TransferableOneWay>();
     this.AddPawnsToTransferables();
     this.AddItemsToTransferables();
     this.pawnsTransfer = new TransferableOneWayWidget(null, Faction.OfPlayer.Name, this.TransportersLabelCap, "FormCaravanColonyThingCountTip".Translate(), true, IgnorePawnsInventoryMode.IgnoreIfAssignedToUnload, true, () => this.MassCapacity - this.MassUsage, 24f, false, true, -1);
     CaravanUIUtility.AddPawnsSections(this.pawnsTransfer, this.transferables);
     this.itemsTransfer = new TransferableOneWayWidget(from x in this.transferables
                                                       where x.ThingDef.category != ThingCategory.Pawn
                                                       select x, Faction.OfPlayer.Name, this.TransportersLabelCap, "FormCaravanColonyThingCountTip".Translate(), true, IgnorePawnsInventoryMode.IgnoreIfAssignedToUnload, true, () => this.MassCapacity - this.MassUsage, 24f, false, true, this.map.Tile);
     this.CountToTransferChanged();
 }
        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, "LoadTransporters".Translate(new object[]
            {
                this.TransportersLabel
            }));
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;
            CaravanUIUtility.DrawCaravanInfo(new CaravanUIUtility.CaravanInfo(this.MassUsage, this.MassCapacity, string.Empty, this.TilesPerDay, this.cachedTilesPerDayExplanation, this.DaysWorthOfFood, this.ForagedFoodPerDay, this.cachedForagedFoodPerDayExplanation, this.Visibility, this.cachedVisibilityExplanation, this.CaravanMassUsage, this.CaravanMassCapacity, this.cachedCaravanMassCapacityExplanation), null, this.map.Tile, null, this.lastMassFlashTime, new Rect(12f, 35f, inRect.width - 24f, 40f), false, null, false);
            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 += 119f;
            Widgets.DrawMenuSection(inRect);
            TabDrawer.DrawTabs(inRect, Dialog_LoadTransporters.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_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();
        }
Ejemplo n.º 13
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, "LoadTransporters".Translate(TransportersLabel));
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;
            if (transporters[0].Props.showOverallStats)
            {
                CaravanUIUtility.DrawCaravanInfo(new CaravanUIUtility.CaravanInfo(MassUsage, MassCapacity, "", TilesPerDay, cachedTilesPerDayExplanation, DaysWorthOfFood, ForagedFoodPerDay, cachedForagedFoodPerDayExplanation, Visibility, cachedVisibilityExplanation, CaravanMassUsage, CaravanMassCapacity, cachedCaravanMassCapacityExplanation), null, map.Tile, null, lastMassFlashTime, new Rect(12f, 35f, inRect.width - 24f, 40f), lerpMassColor: false);
                inRect.yMin += 52f;
            }
            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));
            inRect.yMin += 67f;
            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;
            }
            if (anythingChanged)
            {
                CountToTransferChanged();
            }
            GUI.EndGroup();
        }
Ejemplo n.º 14
0
 private void CalculateAndRecacheTransferables()
 {
     transferables = new List <TransferableOneWay>();
     AddPawnsToTransferables();
     AddItemsToTransferables();
     if (CanChangeAssignedThingsAfterStarting && LoadingInProgressOrReadyToLaunch)
     {
         for (int i = 0; i < transporters.Count; i++)
         {
             for (int j = 0; j < transporters[i].innerContainer.Count; j++)
             {
                 AddToTransferables(transporters[i].innerContainer[j]);
             }
         }
         foreach (Thing item in TransporterUtility.ThingsBeingHauledTo(transporters, map))
         {
             AddToTransferables(item);
         }
     }
     pawnsTransfer = new TransferableOneWayWidget(null, null, null, "FormCaravanColonyThingCountTip".Translate(), drawMass: true, IgnorePawnsInventoryMode.IgnoreIfAssignedToUnload, includePawnsMassInMassUsage: true, () => MassCapacity - MassUsage, 0f, ignoreSpawnedCorpseGearAndInventoryMass: false, map.Tile, drawMarketValue: true, drawEquippedWeapon: true, drawNutritionEatenPerDay: true, drawItemNutrition: false, drawForagedFoodPerDay: true);
     CaravanUIUtility.AddPawnsSections(pawnsTransfer, transferables);
     itemsTransfer = new TransferableOneWayWidget(transferables.Where((TransferableOneWay x) => x.ThingDef.category != ThingCategory.Pawn), null, null, "FormCaravanColonyThingCountTip".Translate(), drawMass: true, IgnorePawnsInventoryMode.IgnoreIfAssignedToUnload, includePawnsMassInMassUsage: true, () => MassCapacity - MassUsage, 0f, ignoreSpawnedCorpseGearAndInventoryMass: false, map.Tile, drawMarketValue: true, drawEquippedWeapon: false, drawNutritionEatenPerDay: false, drawItemNutrition: true, drawForagedFoodPerDay: false, drawDaysUntilRot: true);
     CountToTransferChanged();
 }
Ejemplo n.º 15
0
        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();
        }
Ejemplo n.º 16
0
        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();
            }
        }
Ejemplo n.º 17
0
        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();
        }