示例#1
0
        protected override void DoConfigInterface(Rect baseRect, Color baseColor)
        {
            Rect rect = new Rect(28f, 32f, 100f, 30f);

            GUI.color = new Color(1f, 1f, 1f, 0.65f);
            Widgets.Label(rect, RepeatInfoText);
            GUI.color = baseColor;
            WidgetRow widgetRow = new WidgetRow(baseRect.xMax, baseRect.y + 29f, UIDirection.LeftThenUp);

            if (widgetRow.ButtonText("Details".Translate() + "..."))
            {
                Find.WindowStack.Add(new Dialog_BillConfig(this, ((Thing)billStack.billGiver).Position));
            }
            if (widgetRow.ButtonText(repeatMode.LabelCap.PadRight(20)))
            {
                BillRepeatModeUtility.MakeConfigFloatMenu(this);
            }
            if (widgetRow.ButtonIcon(TexButton.Plus))
            {
                if (repeatMode == BillRepeatModeDefOf.Forever)
                {
                    repeatMode  = BillRepeatModeDefOf.RepeatCount;
                    repeatCount = 1;
                }
                else if (repeatMode == BillRepeatModeDefOf.TargetCount)
                {
                    int num = recipe.targetCountAdjustment * GenUI.CurrentAdjustmentMultiplier();
                    targetCount        += num;
                    unpauseWhenYouHave += num;
                }
                else if (repeatMode == BillRepeatModeDefOf.RepeatCount)
                {
                    repeatCount += GenUI.CurrentAdjustmentMultiplier();
                }
                SoundDefOf.AmountIncrement.PlayOneShotOnCamera();
                if (TutorSystem.TutorialMode && repeatMode == BillRepeatModeDefOf.RepeatCount)
                {
                    TutorSystem.Notify_Event(recipe.defName + "-RepeatCountSetTo-" + repeatCount);
                }
            }
            if (widgetRow.ButtonIcon(TexButton.Minus))
            {
                if (repeatMode == BillRepeatModeDefOf.Forever)
                {
                    repeatMode  = BillRepeatModeDefOf.RepeatCount;
                    repeatCount = 1;
                }
                else if (repeatMode == BillRepeatModeDefOf.TargetCount)
                {
                    int num2 = recipe.targetCountAdjustment * GenUI.CurrentAdjustmentMultiplier();
                    targetCount        = Mathf.Max(0, targetCount - num2);
                    unpauseWhenYouHave = Mathf.Max(0, unpauseWhenYouHave - num2);
                }
                else if (repeatMode == BillRepeatModeDefOf.RepeatCount)
                {
                    repeatCount = Mathf.Max(0, repeatCount - GenUI.CurrentAdjustmentMultiplier());
                }
                SoundDefOf.AmountDecrement.PlayOneShotOnCamera();
                if (TutorSystem.TutorialMode && repeatMode == BillRepeatModeDefOf.RepeatCount)
                {
                    TutorSystem.Notify_Event(recipe.defName + "-RepeatCountSetTo-" + repeatCount);
                }
            }
        }
示例#2
0
        public override void DoWindowContents(Rect inRect)
        {
            Text.Font = GameFont.Medium;
            Rect rect = new Rect(0f, 0f, 400f, 50f);

            Widgets.Label(rect, this.bill.LabelCap);
            float width = (float)((int)((inRect.width - 34f) / 3f));
            Rect  rect2 = new Rect(0f, 80f, width, inRect.height - 80f);
            Rect  rect3 = new Rect(rect2.xMax + 17f, 50f, width, inRect.height - 50f - this.CloseButSize.y);
            Rect  rect4 = new Rect(rect3.xMax + 17f, 50f, 0f, inRect.height - 50f - this.CloseButSize.y);

            rect4.xMax = inRect.xMax;
            Text.Font  = GameFont.Small;
            Listing_Standard listing_Standard = new Listing_Standard();

            listing_Standard.Begin(rect3);
            Listing_Standard listing_Standard2 = listing_Standard.BeginSection((float)Dialog_BillConfig.RepeatModeSubdialogHeight);

            if (listing_Standard2.ButtonText(this.bill.repeatMode.LabelCap, null))
            {
                BillRepeatModeUtility.MakeConfigFloatMenu(this.bill);
            }
            listing_Standard2.Gap(12f);
            if (this.bill.repeatMode == BillRepeatModeDefOf.RepeatCount)
            {
                listing_Standard2.Label("RepeatCount".Translate(new object[]
                {
                    this.bill.repeatCount
                }), -1f, null);
                listing_Standard2.IntEntry(ref this.bill.repeatCount, ref this.repeatCountEditBuffer, 1);
            }
            else if (this.bill.repeatMode == BillRepeatModeDefOf.TargetCount)
            {
                string text = "CurrentlyHave".Translate() + ": ";
                text += this.bill.recipe.WorkerCounter.CountProducts(this.bill);
                text += " / ";
                text += ((this.bill.targetCount >= 999999) ? "Infinite".Translate().ToLower() : this.bill.targetCount.ToString());
                string text2 = this.bill.recipe.WorkerCounter.ProductsDescription(this.bill);
                if (!text2.NullOrEmpty())
                {
                    string text3 = text;
                    text = string.Concat(new string[]
                    {
                        text3,
                        "\n",
                        "CountingProducts".Translate(),
                        ": ",
                        text2
                    });
                }
                listing_Standard2.Label(text, -1f, null);
                int targetCount = this.bill.targetCount;
                listing_Standard2.IntEntry(ref this.bill.targetCount, ref this.targetCountEditBuffer, this.bill.recipe.targetCountAdjustment);
                this.bill.unpauseWhenYouHave = Mathf.Max(0, this.bill.unpauseWhenYouHave + (this.bill.targetCount - targetCount));
                ThingDef producedThingDef = this.bill.recipe.ProducedThingDef;
                if (producedThingDef != null)
                {
                    if (producedThingDef.IsWeapon || producedThingDef.IsApparel)
                    {
                        listing_Standard2.CheckboxLabeled("IncludeEquipped".Translate(), ref this.bill.includeEquipped, null);
                    }
                    if (producedThingDef.IsApparel && producedThingDef.apparel.careIfWornByCorpse)
                    {
                        listing_Standard2.CheckboxLabeled("IncludeTainted".Translate(), ref this.bill.includeTainted, null);
                    }
                    Widgets.Dropdown <Bill_Production, Zone_Stockpile>(listing_Standard2.GetRect(30f), this.bill, (Bill_Production b) => b.includeFromZone, (Bill_Production b) => this.GenerateStockpileInclusion(), (this.bill.includeFromZone != null) ? "IncludeSpecific".Translate(new object[]
                    {
                        this.bill.includeFromZone.label
                    }) : "IncludeFromAll".Translate(), null, null, null, null, false);
                    Widgets.FloatRange(listing_Standard2.GetRect(28f), 10, ref this.bill.hpRange, 0f, 1f, "HitPoints", ToStringStyle.PercentZero);
                    if (producedThingDef.HasComp(typeof(CompQuality)))
                    {
                        Widgets.QualityRange(listing_Standard2.GetRect(28f), 2, ref this.bill.qualityRange);
                    }
                    if (producedThingDef.MadeFromStuff)
                    {
                        listing_Standard2.CheckboxLabeled("LimitToAllowedStuff".Translate(), ref this.bill.limitToAllowedStuff, null);
                    }
                }
            }
            if (this.bill.repeatMode == BillRepeatModeDefOf.TargetCount)
            {
                listing_Standard2.Gap(12f);
                listing_Standard2.Gap(12f);
                listing_Standard2.CheckboxLabeled("PauseWhenSatisfied".Translate(), ref this.bill.pauseWhenSatisfied, null);
                if (this.bill.pauseWhenSatisfied)
                {
                    listing_Standard2.Label("UnpauseWhenYouHave".Translate() + ": " + this.bill.unpauseWhenYouHave.ToString("F0"), -1f, null);
                    listing_Standard2.IntEntry(ref this.bill.unpauseWhenYouHave, ref this.unpauseCountEditBuffer, this.bill.recipe.targetCountAdjustment);
                    if (this.bill.unpauseWhenYouHave >= this.bill.targetCount)
                    {
                        this.bill.unpauseWhenYouHave = this.bill.targetCount - 1;
                        this.unpauseCountEditBuffer  = this.bill.unpauseWhenYouHave.ToStringCached();
                    }
                }
            }
            listing_Standard.EndSection(listing_Standard2);
            listing_Standard.Gap(12f);
            Listing_Standard listing_Standard3 = listing_Standard.BeginSection((float)Dialog_BillConfig.StoreModeSubdialogHeight);
            string           text4             = string.Format(this.bill.GetStoreMode().LabelCap, (this.bill.GetStoreZone() == null) ? "" : this.bill.GetStoreZone().SlotYielderLabel());

            if (this.bill.GetStoreZone() != null && !this.bill.recipe.WorkerCounter.CanPossiblyStoreInStockpile(this.bill, this.bill.GetStoreZone()))
            {
                text4    += string.Format(" ({0})", "IncompatibleLower".Translate());
                Text.Font = GameFont.Tiny;
            }
            if (listing_Standard3.ButtonText(text4, null))
            {
                Text.Font = GameFont.Small;
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                foreach (BillStoreModeDef billStoreModeDef in from bsm in DefDatabase <BillStoreModeDef> .AllDefs
                         orderby bsm.listOrder
                         select bsm)
                {
                    if (billStoreModeDef == BillStoreModeDefOf.SpecificStockpile)
                    {
                        List <SlotGroup> allGroupsListInPriorityOrder = this.bill.billStack.billGiver.Map.haulDestinationManager.AllGroupsListInPriorityOrder;
                        int count = allGroupsListInPriorityOrder.Count;
                        for (int i = 0; i < count; i++)
                        {
                            SlotGroup      group          = allGroupsListInPriorityOrder[i];
                            Zone_Stockpile zone_Stockpile = group.parent as Zone_Stockpile;
                            if (zone_Stockpile != null)
                            {
                                if (!this.bill.recipe.WorkerCounter.CanPossiblyStoreInStockpile(this.bill, zone_Stockpile))
                                {
                                    list.Add(new FloatMenuOption(string.Format("{0} ({1})", string.Format(billStoreModeDef.LabelCap, group.parent.SlotYielderLabel()), "IncompatibleLower".Translate()), null, MenuOptionPriority.Default, null, null, 0f, null, null));
                                }
                                else
                                {
                                    list.Add(new FloatMenuOption(string.Format(billStoreModeDef.LabelCap, group.parent.SlotYielderLabel()), delegate()
                                    {
                                        this.bill.SetStoreMode(BillStoreModeDefOf.SpecificStockpile, (Zone_Stockpile)group.parent);
                                    }, MenuOptionPriority.Default, null, null, 0f, null, null));
                                }
                            }
                        }
                    }
                    else
                    {
                        BillStoreModeDef smLocal = billStoreModeDef;
                        list.Add(new FloatMenuOption(smLocal.LabelCap, delegate()
                        {
                            this.bill.SetStoreMode(smLocal, null);
                        }, MenuOptionPriority.Default, null, null, 0f, null, null));
                    }
                }
                Find.WindowStack.Add(new FloatMenu(list));
            }
            Text.Font = GameFont.Small;
            listing_Standard.EndSection(listing_Standard3);
            listing_Standard.Gap(12f);
            Listing_Standard listing_Standard4 = listing_Standard.BeginSection((float)Dialog_BillConfig.WorkerSelectionSubdialogHeight);

            Widgets.Dropdown <Bill_Production, Pawn>(listing_Standard4.GetRect(30f), this.bill, (Bill_Production b) => b.pawnRestriction, (Bill_Production b) => this.GeneratePawnRestrictionOptions(), (this.bill.pawnRestriction != null) ? this.bill.pawnRestriction.LabelShortCap : "AnyWorker".Translate(), null, null, null, null, false);
            if (this.bill.pawnRestriction == null && this.bill.recipe.workSkill != null)
            {
                listing_Standard4.Label("AllowedSkillRange".Translate(new object[]
                {
                    this.bill.recipe.workSkill.label
                }), -1f, null);
                listing_Standard4.IntRange(ref this.bill.allowedSkillRange, 0, 20);
            }
            listing_Standard.EndSection(listing_Standard4);
            listing_Standard.End();
            Rect rect5 = rect4;

            rect5.yMin = rect5.yMax - (float)Dialog_BillConfig.IngredientRadiusSubdialogHeight;
            rect4.yMax = rect5.yMin - 17f;
            bool flag = this.bill.GetStoreZone() == null || this.bill.recipe.WorkerCounter.CanPossiblyStoreInStockpile(this.bill, this.bill.GetStoreZone());

            ThingFilterUI.DoThingFilterConfigWindow(rect4, ref this.thingFilterScrollPosition, this.bill.ingredientFilter, this.bill.recipe.fixedIngredientFilter, 4, null, this.bill.recipe.forceHiddenSpecialFilters, this.bill.recipe.GetPremultipliedSmallIngredients(), this.bill.Map);
            bool flag2 = this.bill.GetStoreZone() == null || this.bill.recipe.WorkerCounter.CanPossiblyStoreInStockpile(this.bill, this.bill.GetStoreZone());

            if (flag && !flag2)
            {
                Messages.Message("MessageBillValidationStoreZoneInsufficient".Translate(new object[]
                {
                    this.bill.LabelCap,
                    this.bill.billStack.billGiver.LabelShort.CapitalizeFirst(),
                    this.bill.GetStoreZone().label
                }), this.bill.billStack.billGiver as Thing, MessageTypeDefOf.RejectInput, false);
            }
            Listing_Standard listing_Standard5 = new Listing_Standard();

            listing_Standard5.Begin(rect5);
            listing_Standard5.Label("IngredientSearchRadius".Translate() + ": " + ((this.bill.ingredientSearchRadius != 999f) ? this.bill.ingredientSearchRadius.ToString("F0") : "Unlimited".Translate()), -1f, null);
            this.bill.ingredientSearchRadius = listing_Standard5.Slider(this.bill.ingredientSearchRadius, 3f, 100f);
            if (this.bill.ingredientSearchRadius >= 100f)
            {
                this.bill.ingredientSearchRadius = 999f;
            }
            listing_Standard5.End();
            Listing_Standard listing_Standard6 = new Listing_Standard();

            listing_Standard6.Begin(rect2);
            if (this.bill.suspended)
            {
                if (listing_Standard6.ButtonText("Suspended".Translate(), null))
                {
                    this.bill.suspended = false;
                    SoundDefOf.Click.PlayOneShotOnCamera(null);
                }
            }
            else if (listing_Standard6.ButtonText("NotSuspended".Translate(), null))
            {
                this.bill.suspended = true;
                SoundDefOf.Click.PlayOneShotOnCamera(null);
            }
            StringBuilder stringBuilder = new StringBuilder();

            if (this.bill.recipe.description != null)
            {
                stringBuilder.AppendLine(this.bill.recipe.description);
                stringBuilder.AppendLine();
            }
            stringBuilder.AppendLine("WorkAmount".Translate() + ": " + this.bill.recipe.WorkAmountTotal(null).ToStringWorkAmount());
            for (int j = 0; j < this.bill.recipe.ingredients.Count; j++)
            {
                IngredientCount ingredientCount = this.bill.recipe.ingredients[j];
                if (!ingredientCount.filter.Summary.NullOrEmpty())
                {
                    stringBuilder.AppendLine(this.bill.recipe.IngredientValueGetter.BillRequirementsDescription(this.bill.recipe, ingredientCount));
                }
            }
            stringBuilder.AppendLine();
            string text5 = this.bill.recipe.IngredientValueGetter.ExtraDescriptionLine(this.bill.recipe);

            if (text5 != null)
            {
                stringBuilder.AppendLine(text5);
                stringBuilder.AppendLine();
            }
            if (!this.bill.recipe.skillRequirements.NullOrEmpty <SkillRequirement>())
            {
                stringBuilder.AppendLine("MinimumSkills".Translate());
                stringBuilder.AppendLine(this.bill.recipe.MinSkillString);
            }
            Text.Font = GameFont.Small;
            string text6 = stringBuilder.ToString();

            if (Text.CalcHeight(text6, rect2.width) > rect2.height)
            {
                Text.Font = GameFont.Tiny;
            }
            listing_Standard6.Label(text6, -1f, null);
            Text.Font = GameFont.Small;
            listing_Standard6.End();
            if (this.bill.recipe.products.Count == 1)
            {
                ThingDef thingDef = this.bill.recipe.products[0].thingDef;
                Widgets.InfoCardButton(rect2.x, rect4.y, thingDef, GenStuff.DefaultStuffFor(thingDef));
            }
        }
        public override void DoWindowContents(Rect inRect)
        {
            Text.Font = GameFont.Medium;
            Rect rect = new Rect(0f, 0f, 400f, 50f);

            Widgets.Label(rect, this.bill.LabelCap);
            Rect    rect2         = new Rect(0f, 80f, 200f, (float)(inRect.height - 80.0));
            double  x             = rect2.xMax + 17.0;
            double  num           = inRect.height - 50.0;
            Vector2 closeButSize  = base.CloseButSize;
            Rect    rect3         = new Rect((float)x, 50f, 180f, (float)(num - closeButSize.y));
            double  x2            = rect3.xMax + 17.0;
            double  width         = inRect.width - (rect3.xMax + 17.0);
            double  num2          = inRect.height - 50.0;
            Vector2 closeButSize2 = base.CloseButSize;
            Rect    rect4         = new Rect((float)x2, 50f, (float)width, (float)(num2 - closeButSize2.y));

            Text.Font = GameFont.Small;
            Listing_Standard listing_Standard = new Listing_Standard();

            listing_Standard.Begin(rect3);
            if (this.bill.suspended)
            {
                if (listing_Standard.ButtonText("Suspended".Translate(), null))
                {
                    this.bill.suspended = false;
                }
            }
            else if (listing_Standard.ButtonText("NotSuspended".Translate(), null))
            {
                this.bill.suspended = true;
            }
            if (listing_Standard.ButtonText(this.bill.repeatMode.LabelCap, null))
            {
                BillRepeatModeUtility.MakeConfigFloatMenu(this.bill);
            }
            string labelCap = this.bill.storeMode.LabelCap;

            if (listing_Standard.ButtonText(labelCap, null))
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                foreach (BillStoreModeDef item in from bsm in DefDatabase <BillStoreModeDef> .AllDefs
                         orderby bsm.listOrder
                         select bsm)
                {
                    BillStoreModeDef smLocal = item;
                    list.Add(new FloatMenuOption(smLocal.LabelCap, delegate
                    {
                        this.bill.storeMode = smLocal;
                    }, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
                Find.WindowStack.Add(new FloatMenu(list));
            }
            listing_Standard.Gap(12f);
            if (this.bill.repeatMode == BillRepeatModeDefOf.RepeatCount)
            {
                listing_Standard.Label("RepeatCount".Translate(this.bill.RepeatInfoText), -1f);
                listing_Standard.IntSetter(ref this.bill.repeatCount, 1, "1", 42f);
                listing_Standard.IntAdjuster(ref this.bill.repeatCount, 1, 0);
                listing_Standard.IntAdjuster(ref this.bill.repeatCount, 25, 0);
            }
            else if (this.bill.repeatMode == BillRepeatModeDefOf.TargetCount)
            {
                string arg = "CurrentlyHave".Translate() + ": ";
                arg += this.bill.recipe.WorkerCounter.CountProducts(this.bill);
                arg += " / ";
                arg += ((this.bill.targetCount >= 999999) ? "Infinite".Translate().ToLower() : this.bill.targetCount.ToString());
                string text = this.bill.recipe.WorkerCounter.ProductsDescription(this.bill);
                if (!text.NullOrEmpty())
                {
                    string text2 = arg;
                    arg = text2 + "\n" + "CountingProducts".Translate() + ": " + text;
                }
                listing_Standard.Label(arg, -1f);
                int targetCount = this.bill.targetCount;
                listing_Standard.IntSetter(ref this.bill.targetCount, 1, "1", 42f);
                listing_Standard.IntAdjuster(ref this.bill.targetCount, 1, 1);
                listing_Standard.IntAdjuster(ref this.bill.targetCount, 25, 1);
                listing_Standard.IntAdjuster(ref this.bill.targetCount, 250, 1);
                this.bill.unpauseWhenYouHave = Mathf.Max(0, this.bill.unpauseWhenYouHave + (this.bill.targetCount - targetCount));
            }
            listing_Standard.Gap(12f);
            listing_Standard.Label("IngredientSearchRadius".Translate() + ": " + this.bill.ingredientSearchRadius.ToString("F0"), -1f);
            this.bill.ingredientSearchRadius = listing_Standard.Slider(this.bill.ingredientSearchRadius, 3f, 100f);
            if (this.bill.ingredientSearchRadius >= 100.0)
            {
                this.bill.ingredientSearchRadius = 999f;
            }
            if (this.bill.recipe.workSkill != null)
            {
                listing_Standard.Label("AllowedSkillRange".Translate(this.bill.recipe.workSkill.label), -1f);
                listing_Standard.IntRange(ref this.bill.allowedSkillRange, 0, 20);
            }
            if (this.bill.repeatMode == BillRepeatModeDefOf.TargetCount)
            {
                listing_Standard.Gap(12f);
                listing_Standard.CheckboxLabeled("PauseWhenSatisfied".Translate(), ref this.bill.pauseWhenSatisfied, (string)null);
                if (this.bill.pauseWhenSatisfied)
                {
                    listing_Standard.Label("UnpauseWhenYouHave".Translate() + ": " + this.bill.unpauseWhenYouHave.ToString("F0"), -1f);
                    this.bill.unpauseWhenYouHave = Mathf.RoundToInt(listing_Standard.Slider((float)this.bill.unpauseWhenYouHave, 0f, (float)(this.bill.targetCount - 1)));
                }
            }
            listing_Standard.End();
            ThingFilterUI.DoThingFilterConfigWindow(rect4, ref this.scrollPosition, this.bill.ingredientFilter, this.bill.recipe.fixedIngredientFilter, 4, (IEnumerable <ThingDef>)null, (IEnumerable <SpecialThingFilterDef>) this.bill.recipe.forceHiddenSpecialFilters, this.bill.recipe.GetPremultipliedSmallIngredients());
            StringBuilder stringBuilder = new StringBuilder();

            if (this.bill.recipe.description != null)
            {
                stringBuilder.AppendLine(this.bill.recipe.description);
                stringBuilder.AppendLine();
            }
            stringBuilder.AppendLine("WorkAmount".Translate() + ": " + this.bill.recipe.WorkAmountTotal(null).ToStringWorkAmount());
            stringBuilder.AppendLine();
            for (int i = 0; i < this.bill.recipe.ingredients.Count; i++)
            {
                IngredientCount ingredientCount = this.bill.recipe.ingredients[i];
                if (!ingredientCount.filter.Summary.NullOrEmpty())
                {
                    stringBuilder.AppendLine(this.bill.recipe.IngredientValueGetter.BillRequirementsDescription(this.bill.recipe, ingredientCount));
                }
            }
            stringBuilder.AppendLine();
            string text3 = this.bill.recipe.IngredientValueGetter.ExtraDescriptionLine(this.bill.recipe);

            if (text3 != null)
            {
                stringBuilder.AppendLine(text3);
                stringBuilder.AppendLine();
            }
            if (!this.bill.recipe.skillRequirements.NullOrEmpty())
            {
                stringBuilder.AppendLine("MinimumSkills".Translate());
                stringBuilder.AppendLine(this.bill.recipe.MinSkillString);
            }
            Text.Font = GameFont.Small;
            string text4 = stringBuilder.ToString();

            if (Text.CalcHeight(text4, rect2.width) > rect2.height)
            {
                Text.Font = GameFont.Tiny;
            }
            Widgets.Label(rect2, text4);
            Text.Font = GameFont.Small;
            if (this.bill.recipe.products.Count == 1)
            {
                Widgets.InfoCardButton(rect2.x, rect4.y, this.bill.recipe.products[0].thingDef);
            }
        }
示例#4
0
        public override void DoWindowContents(Rect inRect)
        {
            Text.Font = GameFont.Medium;
            Widgets.Label(new Rect(0f, 0f, 400f, 50f), bill.LabelCap);
            float width = (int)((inRect.width - 34f) / 3f);
            Rect  rect  = new Rect(0f, 80f, width, inRect.height - 80f);
            Rect  rect2 = new Rect(rect.xMax + 17f, 50f, width, inRect.height - 50f - CloseButSize.y);
            Rect  rect3 = new Rect(rect2.xMax + 17f, 50f, 0f, inRect.height - 50f - CloseButSize.y);

            rect3.xMax = inRect.xMax;
            Text.Font  = GameFont.Small;
            Listing_Standard listing_Standard = new Listing_Standard();

            listing_Standard.Begin(rect2);
            Listing_Standard listing_Standard2 = listing_Standard.BeginSection(RepeatModeSubdialogHeight);

            if (listing_Standard2.ButtonText(bill.repeatMode.LabelCap))
            {
                BillRepeatModeUtility.MakeConfigFloatMenu(bill);
            }
            listing_Standard2.Gap();
            if (bill.repeatMode == BillRepeatModeDefOf.RepeatCount)
            {
                listing_Standard2.Label("RepeatCount".Translate(bill.repeatCount));
                listing_Standard2.IntEntry(ref bill.repeatCount, ref repeatCountEditBuffer);
            }
            else if (bill.repeatMode == BillRepeatModeDefOf.TargetCount)
            {
                string arg = "CurrentlyHave".Translate() + ": ";
                arg += bill.recipe.WorkerCounter.CountProducts(bill);
                arg += " / ";
                arg += ((bill.targetCount < 999999) ? bill.targetCount.ToString() : "Infinite".Translate().ToLower().ToString());
                string str = bill.recipe.WorkerCounter.ProductsDescription(bill);
                if (!str.NullOrEmpty())
                {
                    arg += "\n" + "CountingProducts".Translate() + ": " + str.CapitalizeFirst();
                }
                listing_Standard2.Label(arg);
                int targetCount = bill.targetCount;
                listing_Standard2.IntEntry(ref bill.targetCount, ref targetCountEditBuffer, bill.recipe.targetCountAdjustment);
                bill.unpauseWhenYouHave = Mathf.Max(0, bill.unpauseWhenYouHave + (bill.targetCount - targetCount));
                ThingDef producedThingDef = bill.recipe.ProducedThingDef;
                if (producedThingDef != null)
                {
                    if (producedThingDef.IsWeapon || producedThingDef.IsApparel)
                    {
                        listing_Standard2.CheckboxLabeled("IncludeEquipped".Translate(), ref bill.includeEquipped);
                    }
                    if (producedThingDef.IsApparel && producedThingDef.apparel.careIfWornByCorpse)
                    {
                        listing_Standard2.CheckboxLabeled("IncludeTainted".Translate(), ref bill.includeTainted);
                    }
                    Widgets.Dropdown(listing_Standard2.GetRect(30f), bill, (Bill_Production b) => b.includeFromZone, (Bill_Production b) => GenerateStockpileInclusion(), (bill.includeFromZone == null) ? "IncludeFromAll".Translate() : "IncludeSpecific".Translate(bill.includeFromZone.label));
                    if (bill.recipe.products.Any((ThingDefCountClass prod) => prod.thingDef.useHitPoints))
                    {
                        Widgets.FloatRange(listing_Standard2.GetRect(28f), 975643279, ref bill.hpRange, 0f, 1f, "HitPoints", ToStringStyle.PercentZero);
                        bill.hpRange.min = Mathf.Round(bill.hpRange.min * 100f) / 100f;
                        bill.hpRange.max = Mathf.Round(bill.hpRange.max * 100f) / 100f;
                    }
                    if (producedThingDef.HasComp(typeof(CompQuality)))
                    {
                        Widgets.QualityRange(listing_Standard2.GetRect(28f), 1098906561, ref bill.qualityRange);
                    }
                    if (producedThingDef.MadeFromStuff)
                    {
                        listing_Standard2.CheckboxLabeled("LimitToAllowedStuff".Translate(), ref bill.limitToAllowedStuff);
                    }
                }
            }
            if (bill.repeatMode == BillRepeatModeDefOf.TargetCount)
            {
                listing_Standard2.CheckboxLabeled("PauseWhenSatisfied".Translate(), ref bill.pauseWhenSatisfied);
                if (bill.pauseWhenSatisfied)
                {
                    listing_Standard2.Label("UnpauseWhenYouHave".Translate() + ": " + bill.unpauseWhenYouHave.ToString("F0"));
                    listing_Standard2.IntEntry(ref bill.unpauseWhenYouHave, ref unpauseCountEditBuffer, bill.recipe.targetCountAdjustment);
                    if (bill.unpauseWhenYouHave >= bill.targetCount)
                    {
                        bill.unpauseWhenYouHave = bill.targetCount - 1;
                        unpauseCountEditBuffer  = bill.unpauseWhenYouHave.ToStringCached();
                    }
                }
            }
            listing_Standard.EndSection(listing_Standard2);
            listing_Standard.Gap();
            Listing_Standard listing_Standard3 = listing_Standard.BeginSection(StoreModeSubdialogHeight);
            string           text = string.Format(bill.GetStoreMode().LabelCap, (bill.GetStoreZone() != null) ? bill.GetStoreZone().SlotYielderLabel() : "");

            if (bill.GetStoreZone() != null && !bill.recipe.WorkerCounter.CanPossiblyStoreInStockpile(bill, bill.GetStoreZone()))
            {
                text     += string.Format(" ({0})", "IncompatibleLower".Translate());
                Text.Font = GameFont.Tiny;
            }
            if (listing_Standard3.ButtonText(text))
            {
                Text.Font = GameFont.Small;
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                foreach (BillStoreModeDef item in DefDatabase <BillStoreModeDef> .AllDefs.OrderBy((BillStoreModeDef bsm) => bsm.listOrder))
                {
                    if (item == BillStoreModeDefOf.SpecificStockpile)
                    {
                        List <SlotGroup> allGroupsListInPriorityOrder = bill.billStack.billGiver.Map.haulDestinationManager.AllGroupsListInPriorityOrder;
                        int count = allGroupsListInPriorityOrder.Count;
                        for (int i = 0; i < count; i++)
                        {
                            SlotGroup      group          = allGroupsListInPriorityOrder[i];
                            Zone_Stockpile zone_Stockpile = group.parent as Zone_Stockpile;
                            if (zone_Stockpile != null)
                            {
                                if (!bill.recipe.WorkerCounter.CanPossiblyStoreInStockpile(bill, zone_Stockpile))
                                {
                                    list.Add(new FloatMenuOption(string.Format("{0} ({1})", string.Format(item.LabelCap, group.parent.SlotYielderLabel()), "IncompatibleLower".Translate()), null));
                                }
                                else
                                {
                                    list.Add(new FloatMenuOption(string.Format(item.LabelCap, group.parent.SlotYielderLabel()), delegate
                                    {
                                        bill.SetStoreMode(BillStoreModeDefOf.SpecificStockpile, (Zone_Stockpile)group.parent);
                                    }));
                                }
                            }
                        }
                    }
                    else
                    {
                        BillStoreModeDef smLocal = item;
                        list.Add(new FloatMenuOption(smLocal.LabelCap, delegate
                        {
                            bill.SetStoreMode(smLocal);
                        }));
                    }
                }
                Find.WindowStack.Add(new FloatMenu(list));
            }
            Text.Font = GameFont.Small;
            listing_Standard.EndSection(listing_Standard3);
            listing_Standard.Gap();
            Listing_Standard listing_Standard4 = listing_Standard.BeginSection(WorkerSelectionSubdialogHeight);

            Widgets.Dropdown(listing_Standard4.GetRect(30f), bill, (Bill_Production b) => b.pawnRestriction, (Bill_Production b) => GeneratePawnRestrictionOptions(), (bill.pawnRestriction == null) ? "AnyWorker".TranslateSimple() : bill.pawnRestriction.LabelShortCap);
            if (bill.pawnRestriction == null && bill.recipe.workSkill != null)
            {
                listing_Standard4.Label("AllowedSkillRange".Translate(bill.recipe.workSkill.label));
                listing_Standard4.IntRange(ref bill.allowedSkillRange, 0, 20);
            }
            listing_Standard.EndSection(listing_Standard4);
            listing_Standard.End();
            Rect rect4 = rect3;
            bool flag  = true;

            for (int j = 0; j < bill.recipe.ingredients.Count; j++)
            {
                if (!bill.recipe.ingredients[j].IsFixedIngredient)
                {
                    flag = false;
                    break;
                }
            }
            if (!flag)
            {
                rect4.yMin = rect4.yMax - (float)IngredientRadiusSubdialogHeight;
                rect3.yMax = rect4.yMin - 17f;
                bool num = bill.GetStoreZone() == null || bill.recipe.WorkerCounter.CanPossiblyStoreInStockpile(bill, bill.GetStoreZone());
                ThingFilterUI.DoThingFilterConfigWindow(rect3, ref thingFilterScrollPosition, bill.ingredientFilter, bill.recipe.fixedIngredientFilter, 4, null, bill.recipe.forceHiddenSpecialFilters, forceHideHitPointsConfig: false, bill.recipe.GetPremultipliedSmallIngredients(), bill.Map);
                bool flag2 = bill.GetStoreZone() == null || bill.recipe.WorkerCounter.CanPossiblyStoreInStockpile(bill, bill.GetStoreZone());
                if (num && !flag2)
                {
                    Messages.Message("MessageBillValidationStoreZoneInsufficient".Translate(bill.LabelCap, bill.billStack.billGiver.LabelShort.CapitalizeFirst(), bill.GetStoreZone().label), bill.billStack.billGiver as Thing, MessageTypeDefOf.RejectInput, historical: false);
                }
            }
            else
            {
                rect4.yMin = 50f;
            }
            Listing_Standard listing_Standard5 = new Listing_Standard();

            listing_Standard5.Begin(rect4);
            string str2 = "IngredientSearchRadius".Translate().Truncate(rect4.width * 0.6f);
            string str3 = (bill.ingredientSearchRadius == 999f) ? "Unlimited".TranslateSimple().Truncate(rect4.width * 0.3f) : bill.ingredientSearchRadius.ToString("F0");

            listing_Standard5.Label(str2 + ": " + str3);
            bill.ingredientSearchRadius = listing_Standard5.Slider((bill.ingredientSearchRadius > 100f) ? 100f : bill.ingredientSearchRadius, 3f, 100f);
            if (bill.ingredientSearchRadius >= 100f)
            {
                bill.ingredientSearchRadius = 999f;
            }
            listing_Standard5.End();
            Listing_Standard listing_Standard6 = new Listing_Standard();

            listing_Standard6.Begin(rect);
            if (bill.suspended)
            {
                if (listing_Standard6.ButtonText("Suspended".Translate()))
                {
                    bill.suspended = false;
                    SoundDefOf.Click.PlayOneShotOnCamera();
                }
            }
            else if (listing_Standard6.ButtonText("NotSuspended".Translate()))
            {
                bill.suspended = true;
                SoundDefOf.Click.PlayOneShotOnCamera();
            }
            StringBuilder stringBuilder = new StringBuilder();

            if (bill.recipe.description != null)
            {
                stringBuilder.AppendLine(bill.recipe.description);
                stringBuilder.AppendLine();
            }
            stringBuilder.AppendLine("WorkAmount".Translate() + ": " + bill.recipe.WorkAmountTotal(null).ToStringWorkAmount());
            for (int k = 0; k < bill.recipe.ingredients.Count; k++)
            {
                IngredientCount ingredientCount = bill.recipe.ingredients[k];
                if (!ingredientCount.filter.Summary.NullOrEmpty())
                {
                    stringBuilder.AppendLine(bill.recipe.IngredientValueGetter.BillRequirementsDescription(bill.recipe, ingredientCount));
                }
            }
            stringBuilder.AppendLine();
            string text2 = bill.recipe.IngredientValueGetter.ExtraDescriptionLine(bill.recipe);

            if (text2 != null)
            {
                stringBuilder.AppendLine(text2);
                stringBuilder.AppendLine();
            }
            if (!bill.recipe.skillRequirements.NullOrEmpty())
            {
                stringBuilder.AppendLine("MinimumSkills".Translate());
                stringBuilder.AppendLine(bill.recipe.MinSkillString);
            }
            Text.Font = GameFont.Small;
            string text3 = stringBuilder.ToString();

            if (Text.CalcHeight(text3, rect.width) > rect.height)
            {
                Text.Font = GameFont.Tiny;
            }
            listing_Standard6.Label(text3);
            Text.Font = GameFont.Small;
            listing_Standard6.End();
            if (bill.recipe.products.Count == 1)
            {
                ThingDef thingDef = bill.recipe.products[0].thingDef;
                Widgets.InfoCardButton(rect.x, rect3.y, thingDef, GenStuff.DefaultStuffFor(thingDef));
            }
        }
示例#5
0
        public override void DoWindowContents(Rect inRect)
        {
            Text.Font = GameFont.Medium;
            Rect rect = new Rect(0f, 0f, 400f, 50f);

            Widgets.Label(rect, bill.LabelCap);
            float   num           = (float)(int)((inRect.width - 34f) / 3f);
            Rect    rect2         = new Rect(0f, 80f, num, inRect.height - 80f);
            float   x             = rect2.xMax + 17f;
            float   width         = num;
            float   num2          = inRect.height - 50f;
            Vector2 closeButSize  = CloseButSize;
            Rect    rect3         = new Rect(x, 50f, width, num2 - closeButSize.y);
            float   x2            = rect3.xMax + 17f;
            float   num3          = inRect.height - 50f;
            Vector2 closeButSize2 = CloseButSize;
            Rect    rect4         = new Rect(x2, 50f, 0f, num3 - closeButSize2.y);

            rect4.xMax = inRect.xMax;
            Text.Font  = GameFont.Small;
            Listing_Standard listing_Standard = new Listing_Standard();

            listing_Standard.Begin(rect3);
            Listing_Standard listing_Standard2 = listing_Standard.BeginSection((float)RepeatModeSubdialogHeight);

            if (listing_Standard2.ButtonText(bill.repeatMode.LabelCap))
            {
                BillRepeatModeUtility.MakeConfigFloatMenu(bill);
            }
            listing_Standard2.Gap();
            if (bill.repeatMode == BillRepeatModeDefOf.RepeatCount)
            {
                listing_Standard2.Label("RepeatCount".Translate(bill.repeatCount));
                listing_Standard2.IntEntry(ref bill.repeatCount, ref repeatCountEditBuffer);
            }
            else if (bill.repeatMode == BillRepeatModeDefOf.TargetCount)
            {
                string arg = "CurrentlyHave".Translate() + ": ";
                arg += bill.recipe.WorkerCounter.CountProducts(bill);
                arg += " / ";
                arg += ((bill.targetCount >= 999999) ? "Infinite".Translate().ToLower() : bill.targetCount.ToString());
                string str = bill.recipe.WorkerCounter.ProductsDescription(bill);
                if (!str.NullOrEmpty())
                {
                    string text = arg;
                    arg = text + "\n" + "CountingProducts".Translate() + ": " + str.CapitalizeFirst();
                }
                listing_Standard2.Label(arg);
                int targetCount = bill.targetCount;
                listing_Standard2.IntEntry(ref bill.targetCount, ref targetCountEditBuffer, bill.recipe.targetCountAdjustment);
                bill.unpauseWhenYouHave = Mathf.Max(0, bill.unpauseWhenYouHave + (bill.targetCount - targetCount));
                ThingDef producedThingDef = bill.recipe.ProducedThingDef;
                if (producedThingDef != null)
                {
                    if (producedThingDef.IsWeapon || producedThingDef.IsApparel)
                    {
                        listing_Standard2.CheckboxLabeled("IncludeEquipped".Translate(), ref bill.includeEquipped);
                    }
                    if (producedThingDef.IsApparel && producedThingDef.apparel.careIfWornByCorpse)
                    {
                        listing_Standard2.CheckboxLabeled("IncludeTainted".Translate(), ref bill.includeTainted);
                    }
                    Widgets.Dropdown(listing_Standard2.GetRect(30f), bill, (Bill_Production b) => b.includeFromZone, (Bill_Production b) => GenerateStockpileInclusion(), (bill.includeFromZone != null) ? "IncludeSpecific".Translate(bill.includeFromZone.label) : "IncludeFromAll".Translate());
                    Widgets.FloatRange(listing_Standard2.GetRect(28f), 975643279, ref bill.hpRange, 0f, 1f, "HitPoints", ToStringStyle.PercentZero);
                    if (producedThingDef.HasComp(typeof(CompQuality)))
                    {
                        Widgets.QualityRange(listing_Standard2.GetRect(28f), 1098906561, ref bill.qualityRange);
                    }
                    if (producedThingDef.MadeFromStuff)
                    {
                        listing_Standard2.CheckboxLabeled("LimitToAllowedStuff".Translate(), ref bill.limitToAllowedStuff);
                    }
                }
            }
            if (bill.repeatMode == BillRepeatModeDefOf.TargetCount)
            {
                listing_Standard2.CheckboxLabeled("PauseWhenSatisfied".Translate(), ref bill.pauseWhenSatisfied);
                if (bill.pauseWhenSatisfied)
                {
                    listing_Standard2.Label("UnpauseWhenYouHave".Translate() + ": " + bill.unpauseWhenYouHave.ToString("F0"));
                    listing_Standard2.IntEntry(ref bill.unpauseWhenYouHave, ref unpauseCountEditBuffer, bill.recipe.targetCountAdjustment);
                    if (bill.unpauseWhenYouHave >= bill.targetCount)
                    {
                        bill.unpauseWhenYouHave = bill.targetCount - 1;
                        unpauseCountEditBuffer  = bill.unpauseWhenYouHave.ToStringCached();
                    }
                }
            }
            listing_Standard.EndSection(listing_Standard2);
            listing_Standard.Gap();
            Listing_Standard listing_Standard3 = listing_Standard.BeginSection((float)StoreModeSubdialogHeight);
            string           text2             = string.Format(bill.GetStoreMode().LabelCap, (bill.GetStoreZone() == null) ? string.Empty : bill.GetStoreZone().SlotYielderLabel());

            if (bill.GetStoreZone() != null && !bill.recipe.WorkerCounter.CanPossiblyStoreInStockpile(bill, bill.GetStoreZone()))
            {
                text2    += string.Format(" ({0})", "IncompatibleLower".Translate());
                Text.Font = GameFont.Tiny;
            }
            if (listing_Standard3.ButtonText(text2))
            {
                Text.Font = GameFont.Small;
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                foreach (BillStoreModeDef item in from bsm in DefDatabase <BillStoreModeDef> .AllDefs
                         orderby bsm.listOrder
                         select bsm)
                {
                    if (item == BillStoreModeDefOf.SpecificStockpile)
                    {
                        List <SlotGroup> allGroupsListInPriorityOrder = bill.billStack.billGiver.Map.haulDestinationManager.AllGroupsListInPriorityOrder;
                        int count = allGroupsListInPriorityOrder.Count;
                        for (int i = 0; i < count; i++)
                        {
                            SlotGroup      group          = allGroupsListInPriorityOrder[i];
                            Zone_Stockpile zone_Stockpile = group.parent as Zone_Stockpile;
                            if (zone_Stockpile != null)
                            {
                                if (!bill.recipe.WorkerCounter.CanPossiblyStoreInStockpile(bill, zone_Stockpile))
                                {
                                    list.Add(new FloatMenuOption(string.Format("{0} ({1})", string.Format(item.LabelCap, group.parent.SlotYielderLabel()), "IncompatibleLower".Translate()), null));
                                }
                                else
                                {
                                    list.Add(new FloatMenuOption(string.Format(item.LabelCap, group.parent.SlotYielderLabel()), delegate
                                    {
                                        bill.SetStoreMode(BillStoreModeDefOf.SpecificStockpile, (Zone_Stockpile)group.parent);
                                    }));
                                }
                            }
                        }
                    }
                    else
                    {
                        BillStoreModeDef smLocal = item;
                        list.Add(new FloatMenuOption(smLocal.LabelCap, delegate
                        {
                            bill.SetStoreMode(smLocal);
                        }));
                    }
                }
                Find.WindowStack.Add(new FloatMenu(list));
            }
            Text.Font = GameFont.Small;
            listing_Standard.EndSection(listing_Standard3);
            listing_Standard.Gap();
            Listing_Standard listing_Standard4 = listing_Standard.BeginSection((float)WorkerSelectionSubdialogHeight);

            Widgets.Dropdown(listing_Standard4.GetRect(30f), bill, (Bill_Production b) => b.pawnRestriction, (Bill_Production b) => GeneratePawnRestrictionOptions(), (bill.pawnRestriction != null) ? bill.pawnRestriction.LabelShortCap : "AnyWorker".Translate());
            if (bill.pawnRestriction == null && bill.recipe.workSkill != null)
            {
                listing_Standard4.Label("AllowedSkillRange".Translate(bill.recipe.workSkill.label));
                listing_Standard4.IntRange(ref bill.allowedSkillRange, 0, 20);
            }
            listing_Standard.EndSection(listing_Standard4);
            listing_Standard.End();
            Rect rect5 = rect4;

            rect5.yMin = rect5.yMax - (float)IngredientRadiusSubdialogHeight;
            rect4.yMax = rect5.yMin - 17f;
            bool                         flag                          = bill.GetStoreZone() == null || bill.recipe.WorkerCounter.CanPossiblyStoreInStockpile(bill, bill.GetStoreZone());
            Rect                         rect6                         = rect4;
            ref Vector2                  scrollPosition                = ref thingFilterScrollPosition;