Exemplo n.º 1
0
        public static void DrawTradeableRow(Rect rect, Tradeable trad, int index)
        {
            if (index % 2 == 1)
            {
                GUI.DrawTexture(rect, TradeUI.TradeAlternativeBGTex);
            }
            Text.Font = GameFont.Small;
            GUI.BeginGroup(rect);
            float width = rect.width;
            int   num   = trad.CountHeldBy(Transactor.Trader);

            if (num != 0)
            {
                Rect rect2 = new Rect((float)(width - 75.0), 0f, 75f, rect.height);
                if (Mouse.IsOver(rect2))
                {
                    Widgets.DrawHighlight(rect2);
                }
                Text.Anchor = TextAnchor.MiddleRight;
                Rect rect3 = rect2;
                rect3.xMin += 5f;
                rect3.xMax -= 5f;
                Widgets.Label(rect3, num.ToStringCached());
                TooltipHandler.TipRegion(rect2, "TraderCount".Translate());
                Rect rect4 = new Rect((float)(rect2.x - 100.0), 0f, 100f, rect.height);
                Text.Anchor = TextAnchor.MiddleRight;
                TradeUI.DrawPrice(rect4, trad, TradeAction.PlayerBuys);
            }
            width = (float)(width - 175.0);
            Rect rect5 = new Rect((float)(width - 240.0), 0f, 240f, rect.height);

            if (trad.TraderWillTrade)
            {
                bool flash = Time.time - Dialog_Trade.lastCurrencyFlashTime < 1.0 && trad.IsCurrency;
                TransferableUIUtility.DoCountAdjustInterface(rect5, trad, index, -trad.CountHeldBy(Transactor.Colony), trad.CountHeldBy(Transactor.Trader), flash, null);
            }
            else
            {
                TradeUI.DrawWillNotTradeIndication(rect, trad);
            }
            width = (float)(width - 240.0);
            int num2 = trad.CountHeldBy(Transactor.Colony);

            if (num2 != 0)
            {
                Rect rect6 = new Rect((float)(width - 100.0), 0f, 100f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                TradeUI.DrawPrice(rect6, trad, TradeAction.PlayerSells);
                Rect rect7 = new Rect((float)(rect6.x - 75.0), 0f, 75f, rect.height);
                if (Mouse.IsOver(rect7))
                {
                    Widgets.DrawHighlight(rect7);
                }
                Text.Anchor = TextAnchor.MiddleLeft;
                Rect rect8 = rect7;
                rect8.xMin += 5f;
                rect8.xMax -= 5f;
                Widgets.Label(rect8, num2.ToStringCached());
                TooltipHandler.TipRegion(rect7, "ColonyCount".Translate());
            }
            width = (float)(width - 175.0);
            Rect idRect = new Rect(0f, 0f, width, rect.height);

            TransferableUIUtility.DrawTransferableInfo(trad, idRect, (!trad.TraderWillTrade) ? TradeUI.NoTradeColor : Color.white);
            GenUI.ResetLabelAlign();
            GUI.EndGroup();
        }
Exemplo n.º 2
0
        private void DoRow(Rect rect, TransferableOneWay trad, int index, float availableMass)
        {
            if (index % 2 == 1)
            {
                Widgets.DrawLightHighlight(rect);
            }
            Text.Font = GameFont.Small;
            GUI.BeginGroup(rect);
            float num      = rect.width;
            int   maxCount = trad.MaxCount;
            Rect  rect2    = new Rect(num - 240f, 0f, 240f, rect.height);

            TransferableOneWayWidget.stoppingPoints.Clear();
            if (this.availableMassGetter != null && (!(trad.AnyThing is Pawn) || this.includePawnsMassInMassUsage))
            {
                float num2      = availableMass + this.GetMass(trad.AnyThing) * (float)trad.CountToTransfer;
                int   threshold = (num2 > 0f) ? Mathf.FloorToInt(num2 / this.GetMass(trad.AnyThing)) : 0;
                TransferableOneWayWidget.stoppingPoints.Add(new TransferableCountToTransferStoppingPoint(threshold, "M<", ">M"));
            }
            Pawn pawn  = trad.AnyThing as Pawn;
            bool flag  = pawn != null && (pawn.IsColonist || pawn.IsPrisonerOfColony);
            Rect rect3 = rect2;
            int  min   = 0;
            int  max   = maxCount;
            List <TransferableCountToTransferStoppingPoint> extraStoppingPoints = TransferableOneWayWidget.stoppingPoints;

            TransferableUIUtility.DoCountAdjustInterface(rect3, trad, index, min, max, false, extraStoppingPoints, this.playerPawnsReadOnly && flag);
            num -= 240f;
            if (this.drawMarketValue)
            {
                Rect rect4 = new Rect(num - 100f, 0f, 100f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                this.DrawMarketValue(rect4, trad);
                num -= 100f;
            }
            if (this.drawMass)
            {
                Rect rect5 = new Rect(num - 100f, 0f, 100f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                this.DrawMass(rect5, trad, availableMass);
                num -= 100f;
            }
            if (this.drawDaysUntilRot)
            {
                Rect rect6 = new Rect(num - 75f, 0f, 75f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                this.DrawDaysUntilRot(rect6, trad);
                num -= 75f;
            }
            if (this.drawItemNutrition)
            {
                Rect rect7 = new Rect(num - 75f, 0f, 75f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                this.DrawItemNutrition(rect7, trad);
                num -= 75f;
            }
            if (this.drawForagedFoodPerDay)
            {
                Rect rect8 = new Rect(num - 75f, 0f, 75f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                if (!this.DrawGrazeability(rect8, trad))
                {
                    this.DrawForagedFoodPerDay(rect8, trad);
                }
                num -= 75f;
            }
            if (this.drawNutritionEatenPerDay)
            {
                Rect rect9 = new Rect(num - 75f, 0f, 75f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                this.DrawNutritionEatenPerDay(rect9, trad);
                num -= 75f;
            }
            if (this.ShouldShowCount(trad))
            {
                Rect rect10 = new Rect(num - 75f, 0f, 75f, rect.height);
                Widgets.DrawHighlightIfMouseover(rect10);
                Text.Anchor = TextAnchor.MiddleLeft;
                Rect rect11 = rect10;
                rect11.xMin += 5f;
                rect11.xMax -= 5f;
                Widgets.Label(rect11, maxCount.ToStringCached());
                TooltipHandler.TipRegion(rect10, this.sourceCountDesc);
            }
            num -= 75f;
            if (this.drawEquippedWeapon)
            {
                Rect rect12   = new Rect(num - 30f, 0f, 30f, rect.height);
                Rect iconRect = new Rect(num - 30f, (rect.height - 30f) / 2f, 30f, 30f);
                this.DrawEquippedWeapon(rect12, iconRect, trad);
                num -= 30f;
            }
            Pawn pawn2 = trad.AnyThing as Pawn;

            if (pawn2 != null && pawn2.def.race.Animal)
            {
                Rect rect13 = new Rect(num - TransferableOneWayWidget.BondIconWidth, (rect.height - TransferableOneWayWidget.BondIconWidth) / 2f, TransferableOneWayWidget.BondIconWidth, TransferableOneWayWidget.BondIconWidth);
                num -= TransferableOneWayWidget.BondIconWidth;
                Rect rect14 = new Rect(num - TransferableOneWayWidget.PregnancyIconWidth, (rect.height - TransferableOneWayWidget.PregnancyIconWidth) / 2f, TransferableOneWayWidget.PregnancyIconWidth, TransferableOneWayWidget.PregnancyIconWidth);
                num -= TransferableOneWayWidget.PregnancyIconWidth;
                string iconTooltipText = TrainableUtility.GetIconTooltipText(pawn2);
                if (!iconTooltipText.NullOrEmpty())
                {
                    TooltipHandler.TipRegion(rect13, iconTooltipText);
                }
                if (pawn2.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Bond, null) != null)
                {
                    GUI.DrawTexture(rect13, TransferableOneWayWidget.BondIcon);
                }
                if (pawn2.health.hediffSet.HasHediff(HediffDefOf.Pregnant, true))
                {
                    TooltipHandler.TipRegion(rect14, PawnColumnWorker_Pregnant.GetTooltipText(pawn2));
                    GUI.DrawTexture(rect14, TransferableOneWayWidget.PregnantIcon);
                }
            }
            Rect idRect = new Rect(0f, 0f, num, rect.height);

            TransferableUIUtility.DrawTransferableInfo(trad, idRect, Color.white);
            GenUI.ResetLabelAlign();
            GUI.EndGroup();
        }
Exemplo n.º 3
0
        private void DoRow(Rect rect, TransferableOneWay trad, int index, float availableMass)
        {
            if (index % 2 == 1)
            {
                GUI.DrawTexture(rect, TradeUI.TradeAlternativeBGTex);
            }
            Text.Font = GameFont.Small;
            GUI.BeginGroup(rect);
            float width    = rect.width;
            int   maxCount = trad.MaxCount;
            Rect  rect2    = new Rect((float)(width - 240.0), 0f, 240f, rect.height);

            TransferableOneWayWidget.stoppingPoints.Clear();
            if (this.availableMassGetter != null && (!(trad.AnyThing is Pawn) || this.includePawnsMassInMassUsage))
            {
                float num       = availableMass + this.GetMass(trad.AnyThing) * (float)trad.CountToTransfer;
                int   threshold = (!(num <= 0.0)) ? Mathf.FloorToInt(num / this.GetMass(trad.AnyThing)) : 0;
                TransferableOneWayWidget.stoppingPoints.Add(new TransferableCountToTransferStoppingPoint(threshold, "M<", ">M"));
            }
            Rect rect3 = rect2;
            int  min   = 0;
            int  max   = maxCount;
            List <TransferableCountToTransferStoppingPoint> extraStoppingPoints = TransferableOneWayWidget.stoppingPoints;

            TransferableUIUtility.DoCountAdjustInterface(rect3, trad, index, min, max, false, extraStoppingPoints);
            width = (float)(width - 240.0);
            if (this.drawMarketValue)
            {
                Rect rect4 = new Rect((float)(width - 100.0), 0f, 100f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                this.DrawMarketValue(rect4, trad);
                width = (float)(width - 100.0);
            }
            if (this.drawMass)
            {
                Rect rect5 = new Rect((float)(width - 100.0), 0f, 100f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                this.DrawMass(rect5, trad, availableMass);
                width = (float)(width - 100.0);
            }
            if (this.drawDaysUntilRotForTile >= 0)
            {
                Rect rect6 = new Rect((float)(width - 75.0), 0f, 75f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                this.DrawDaysUntilRot(rect6, trad);
                width = (float)(width - 75.0);
            }
            Rect rect7 = new Rect((float)(width - 75.0), 0f, 75f, rect.height);

            if (Mouse.IsOver(rect7))
            {
                Widgets.DrawHighlight(rect7);
            }
            Text.Anchor = TextAnchor.MiddleLeft;
            Rect rect8 = rect7;

            rect8.xMin += 5f;
            rect8.xMax -= 5f;
            Widgets.Label(rect8, maxCount.ToStringCached());
            TooltipHandler.TipRegion(rect7, this.sourceCountDesc);
            width = (float)(width - 75.0);
            Rect idRect = new Rect(0f, 0f, width, rect.height);

            TransferableUIUtility.DrawTransferableInfo(trad, idRect, Color.white);
            GenUI.ResetLabelAlign();
            GUI.EndGroup();
        }
        private void DoRow(Rect rect, TransferableOneWay trad, int index, float availableMass)
        {
            if (index % 2 == 1)
            {
                Widgets.DrawLightHighlight(rect);
            }
            Text.Font = GameFont.Small;
            GUI.BeginGroup(rect);
            float width    = rect.width;
            int   maxCount = trad.MaxCount;
            Rect  rect2    = new Rect(width - 240f, 0f, 240f, rect.height);

            stoppingPoints.Clear();
            if (availableMassGetter != null && (!(trad.AnyThing is Pawn) || includePawnsMassInMassUsage))
            {
                float num       = availableMass + GetMass(trad.AnyThing) * (float)trad.CountToTransfer;
                int   threshold = ((!(num <= 0f)) ? Mathf.FloorToInt(num / GetMass(trad.AnyThing)) : 0);
                stoppingPoints.Add(new TransferableCountToTransferStoppingPoint(threshold, "M<", ">M"));
            }
            Pawn pawn = trad.AnyThing as Pawn;
            bool flag = pawn != null && (pawn.IsColonist || pawn.IsPrisonerOfColony);

            TransferableUIUtility.DoCountAdjustInterface(rect2, trad, index, 0, maxCount, flash: false, stoppingPoints, (playerPawnsReadOnly && flag) || readOnly);
            width -= 240f;
            if (drawMarketValue)
            {
                Rect rect3 = new Rect(width - 100f, 0f, 100f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                DrawMarketValue(rect3, trad);
                width -= 100f;
            }
            if (drawMass)
            {
                Rect rect4 = new Rect(width - 100f, 0f, 100f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                DrawMass(rect4, trad, availableMass);
                width -= 100f;
            }
            if (drawDaysUntilRot)
            {
                Rect rect5 = new Rect(width - 75f, 0f, 75f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                DrawDaysUntilRot(rect5, trad);
                width -= 75f;
            }
            if (drawItemNutrition)
            {
                Rect rect6 = new Rect(width - 75f, 0f, 75f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                DrawItemNutrition(rect6, trad);
                width -= 75f;
            }
            if (drawForagedFoodPerDay)
            {
                Rect rect7 = new Rect(width - 75f, 0f, 75f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                if (!DrawGrazeability(rect7, trad))
                {
                    DrawForagedFoodPerDay(rect7, trad);
                }
                width -= 75f;
            }
            if (drawNutritionEatenPerDay)
            {
                Rect rect8 = new Rect(width - 75f, 0f, 75f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                DrawNutritionEatenPerDay(rect8, trad);
                width -= 75f;
            }
            if (ShouldShowCount(trad))
            {
                Rect rect9 = new Rect(width - 75f, 0f, 75f, rect.height);
                Widgets.DrawHighlightIfMouseover(rect9);
                Text.Anchor = TextAnchor.MiddleLeft;
                Rect rect10 = rect9;
                rect10.xMin += 5f;
                rect10.xMax -= 5f;
                Widgets.Label(rect10, maxCount.ToStringCached());
                TooltipHandler.TipRegion(rect9, sourceCountDesc);
            }
            width -= 75f;
            if (drawEquippedWeapon)
            {
                Rect rect11   = new Rect(width - 30f, 0f, 30f, rect.height);
                Rect iconRect = new Rect(width - 30f, (rect.height - 30f) / 2f, 30f, 30f);
                DrawEquippedWeapon(rect11, iconRect, trad);
                width -= 30f;
            }
            TransferableUIUtility.DoExtraAnimalIcons(trad, rect, ref width);
            Rect idRect = new Rect(0f, 0f, width, rect.height);

            TransferableUIUtility.DrawTransferableInfo(trad, idRect, Color.white);
            GenUI.ResetLabelAlign();
            GUI.EndGroup();
        }
Exemplo n.º 5
0
        public static void DrawTradeableRow(Rect rect, Tradeable trad, int index)
        {
            if (index % 2 == 1)
            {
                Widgets.DrawLightHighlight(rect);
            }
            Text.Font = GameFont.Small;
            GUI.BeginGroup(rect);
            float width = rect.width;
            int   num   = trad.CountHeldBy(Transactor.Trader);

            if (num != 0 && trad.IsThing)
            {
                Rect rect2 = new Rect(width - 75f, 0f, 75f, rect.height);
                if (Mouse.IsOver(rect2))
                {
                    Widgets.DrawHighlight(rect2);
                }
                Text.Anchor = TextAnchor.MiddleRight;
                Rect rect3 = rect2;
                rect3.xMin += 5f;
                rect3.xMax -= 5f;
                Widgets.Label(rect3, num.ToStringCached());
                TooltipHandler.TipRegionByKey(rect2, "TraderCount");
                Rect rect4 = new Rect(rect2.x - 100f, 0f, 100f, rect.height);
                Text.Anchor = TextAnchor.MiddleRight;
                DrawPrice(rect4, trad, TradeAction.PlayerBuys);
            }
            width -= 175f;
            Rect rect5 = new Rect(width - 240f, 0f, 240f, rect.height);

            if (trad.TraderWillTrade)
            {
                bool flash = Time.time - Dialog_Trade.lastCurrencyFlashTime < 1f && trad.IsCurrency;
                TransferableUIUtility.DoCountAdjustInterface(rect5, trad, index, trad.GetMinimumToTransfer(), trad.GetMaximumToTransfer(), flash);
            }
            else
            {
                DrawWillNotTradeIndication(rect5, trad);
            }
            width -= 240f;
            int num2 = trad.CountHeldBy(Transactor.Colony);

            if (num2 != 0)
            {
                Rect rect6 = new Rect(width - 100f, 0f, 100f, rect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                DrawPrice(rect6, trad, TradeAction.PlayerSells);
                Rect rect7 = new Rect(rect6.x - 75f, 0f, 75f, rect.height);
                if (Mouse.IsOver(rect7))
                {
                    Widgets.DrawHighlight(rect7);
                }
                Text.Anchor = TextAnchor.MiddleLeft;
                Rect rect8 = rect7;
                rect8.xMin += 5f;
                rect8.xMax -= 5f;
                Widgets.Label(rect8, num2.ToStringCached());
                TooltipHandler.TipRegionByKey(rect7, "ColonyCount");
            }
            width -= 175f;
            TransferableUIUtility.DoExtraAnimalIcons(trad, rect, ref width);
            Rect idRect = new Rect(0f, 0f, width, rect.height);

            TransferableUIUtility.DrawTransferableInfo(trad, idRect, trad.TraderWillTrade ? Color.white : NoTradeColor);
            GenUI.ResetLabelAlign();
            GUI.EndGroup();
        }