Exemple #1
0
        protected override void FillTab()
        {
            IStoreSettingsParent selStoreSettingsParent = this.SelStoreSettingsParent;
            StorageSettings      settings = selStoreSettingsParent.GetStoreSettings();
            Rect position = new Rect(0f, 0f, WinSize.x, WinSize.y).ContractedBy(10f);

            GUI.BeginGroup(position);

            Text.Font   = GameFont.Medium;
            Text.Anchor = TextAnchor.MiddleCenter;
            Rect titleRect = new Rect(position);

            titleRect.height = 32f;
            Widgets.Label(titleRect, "AndroidTabTitle".Translate());

            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;

            ThingFilter parentFilter = null;

            if (selStoreSettingsParent.GetParentStoreSettings() != null)
            {
                parentFilter = selStoreSettingsParent.GetParentStoreSettings().filter;
            }
            Rect rect2 = new Rect(0f, 40f, position.width, position.height - 40f);

            ThingFilterUI.DoThingFilterConfigWindow(rect2, ref this.scrollPosition, settings.filter, parentFilter, 8);
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.StorageTab, KnowledgeAmount.FrameDisplayed);
            GUI.EndGroup();
        }
Exemple #2
0
        /// <summary>
        /// Draw window contents.
        /// </summary>
        /// <param name="inRect"> Rect for drawing. </param>
        public override void DoWindowContents(Rect inRect)
        {
            Rect labelRect = inRect.ReplaceHeight(GenUI.ListSpacing * 2);

            Widgets.TextArea(labelRect, UIText.GlobalOutfitSettingWarning.TranslateSimple(), true);

            Rect importRect = labelRect.ReplaceY(labelRect.yMax).ReplaceHeight(GenUI.ListSpacing);

            if (Widgets.ButtonText(importRect, UIText.ImportLoadout.TranslateSimple()))
            {
                FloatMenuUtility.MakeMenu(
                    LoadoutManager.Loadouts.Where(t => t.GetType() == typeof(AwesomeInventoryLoadout))
                    , (loadout) => loadout.label
                    , (loadout) => () => { _filter.CopyAllowancesFrom(loadout.filter); });
            }

            ThingFilterUI.DoThingFilterConfigWindow(
                inRect.ReplaceyMin(importRect.yMax + GenUI.GapSmall)
                , ref _scrollPosition
                , _filter
                , _apparelGlobalFilter
                , 16
                , null
                , new[] { SpecialThingFilterDefOf.AllowNonDeadmansApparel });
        }
        protected override void FillTab()
        {
            IStoreSettingsParent selStoreSettingsParent = SelStoreSettingsParent;
            StorageSettings      storeSettings          = selStoreSettingsParent.GetStoreSettings();
            Rect rect = GenUI.ContractedBy(new Rect(0f, 0f, WinSize.x, WinSize.y), 10f);

            GUI.BeginGroup(rect);
            Text.Font   = GameFont.Medium;
            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(new Rect(rect)
            {
                height = 32f
            }, Translator.Translate("RefuelTitle"));
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;
            ThingFilter thingFilter = null;

            if (selStoreSettingsParent.GetParentStoreSettings() != null)
            {
                thingFilter = selStoreSettingsParent.GetParentStoreSettings().filter;
            }
            Rect rect2 = new Rect(0f, 40f, rect.width, rect.height - 40f);

            ThingFilterUI.DoThingFilterConfigWindow(rect2, ref scrollPosition, storeSettings.filter, thingFilter, 8, null, null, false, null, null);
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.StorageTab, KnowledgeAmount.FrameDisplayed);
            GUI.EndGroup();
        }
        protected override void FillTab()
        {
            IStoreSettingsParent selStoreSettingsParent = SelStoreSettingsParent;

            if (selStoreSettingsParent == null)
            {
                return;
            }
            StorageSettings storeSettings = selStoreSettingsParent.GetStoreSettings();
            Rect            rect          = GenUI.ContractedBy(new Rect(0f, 0f, WinSize.x, WinSize.y), 10f);

            GUI.BeginGroup(rect);
            Text.Font   = GameFont.Medium;
            Text.Anchor = TextAnchor.MiddleCenter;
            //Widgets.Label(new Rect(rect)
            //{
            //    height = 32f
            //}, "RefuelTitle");
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;
            ThingFilter thingFilter = null;

            if (selStoreSettingsParent.GetParentStoreSettings() != null)
            {
                thingFilter = selStoreSettingsParent.GetParentStoreSettings().filter;
            }
            Rect rect2 = new Rect(0f, 40f, rect.width, rect.height - 40f);

            ThingFilterUI.DoThingFilterConfigWindow(rect2, ref scrollPosition, storeSettings.filter, thingFilter, 8, null, null, false, null, null);
            GUI.EndGroup();
        }
Exemple #5
0
        public override void DoWindowContents(Rect inRect)
        {
            var   modSave  = MainMod.Save;
            int   OpenMask = 9;
            float yOffset  = 10;

            ThingFilterUI.DoThingFilterConfigWindow(new Rect(inRect.x, inRect.y + yOffset, inRect.width, inRect.height - yOffset), ref scrollPosition, modSave.CategoryFilter, modSave.CategoryFilterGlobal, OpenMask);
        }
        public override void DoWindowContents ( Rect inRect )
        {
            GUI.BeginGroup( inRect );

            ThingFilterUI.DoThingFilterConfigWindow( new Rect( 0f, 20f, inRect.width, inRect.height - 22f ), ref this.scrollPositionThingFilter, this.logisticProviderPassive.thingFilter );

            GUI.EndGroup();
        }
Exemple #7
0
        protected override void FillTab()
        {
            IStoreSettingsParent storeSettingsParent = this.SelStoreSettingsParent;
            StorageSettings      settings            = storeSettingsParent.GetStoreSettings();
            Rect position = new Rect(0f, 0f, ITab_Storage.WinSize.x, ITab_Storage.WinSize.y).ContractedBy(10f);

            GUI.BeginGroup(position);
            if (this.IsPrioritySettingVisible)
            {
                Text.Font = GameFont.Small;
                Rect rect = new Rect(0f, 0f, 160f, this.TopAreaHeight - 6f);
                if (Widgets.ButtonText(rect, "Priority".Translate() + ": " + settings.Priority.Label().CapitalizeFirst(), true, false, true))
                {
                    List <FloatMenuOption> list = new List <FloatMenuOption>();
                    foreach (StoragePriority storagePriority in Enum.GetValues(typeof(StoragePriority)))
                    {
                        if (storagePriority != StoragePriority.Unstored)
                        {
                            StoragePriority localPr = storagePriority;
                            list.Add(new FloatMenuOption(localPr.Label().CapitalizeFirst(), delegate
                            {
                                settings.Priority = localPr;
                            }, MenuOptionPriority.Default, null, null, 0f, null, null));
                        }
                    }
                    Find.WindowStack.Add(new FloatMenu(list));
                }
                UIHighlighter.HighlightOpportunity(rect, "StoragePriority");
            }
            ThingFilter parentFilter = null;

            if (storeSettingsParent.GetParentStoreSettings() != null)
            {
                parentFilter = storeSettingsParent.GetParentStoreSettings().filter;
            }
            Rect rect2 = new Rect(0f, this.TopAreaHeight, position.width, position.height - this.TopAreaHeight);

            Bill[] first = (from b in BillUtility.GlobalBills()
                            where b is Bill_Production && b.GetStoreZone() == storeSettingsParent && b.recipe.WorkerCounter.CanPossiblyStoreInStockpile((Bill_Production)b, b.GetStoreZone())
                            select b).ToArray <Bill>();
            ThingFilterUI.DoThingFilterConfigWindow(rect2, ref this.scrollPosition, settings.filter, parentFilter, 8, null, null, null, null);
            Bill[] second = (from b in BillUtility.GlobalBills()
                             where b is Bill_Production && b.GetStoreZone() == storeSettingsParent && b.recipe.WorkerCounter.CanPossiblyStoreInStockpile((Bill_Production)b, b.GetStoreZone())
                             select b).ToArray <Bill>();
            IEnumerable <Bill> enumerable = first.Except(second);

            foreach (Bill current in enumerable)
            {
                Messages.Message("MessageBillValidationStoreZoneInsufficient".Translate(new object[]
                {
                    current.LabelCap,
                    current.billStack.billGiver.LabelShort.CapitalizeFirst(),
                    current.GetStoreZone().label
                }), current.billStack.billGiver as Thing, MessageTypeDefOf.RejectInput, false);
            }
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.StorageTab, KnowledgeAmount.FrameDisplayed);
            GUI.EndGroup();
        }
        protected override void FillTab()
        {
            IStoreSettingsParent selStoreSettingsParent = this.SelStoreSettingsParent;
            StorageSettings      settings = selStoreSettingsParent.GetStoreSettings();
            Vector2 winSize  = ITab_Storage.WinSize;
            float   x        = winSize.x;
            Vector2 winSize2 = ITab_Storage.WinSize;
            Rect    position = new Rect(0f, 0f, x, winSize2.y).ContractedBy(10f);

            GUI.BeginGroup(position);
            if (this.IsPrioritySettingVisible)
            {
                Text.Font = GameFont.Small;
                Rect rect = new Rect(0f, 0f, 160f, (float)(this.TopAreaHeight - 6.0));
                if (Widgets.ButtonText(rect, "Priority".Translate() + ": " + settings.Priority.Label(), true, false, true))
                {
                    List <FloatMenuOption> list       = new List <FloatMenuOption>();
                    IEnumerator            enumerator = Enum.GetValues(typeof(StoragePriority)).GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            StoragePriority storagePriority = (StoragePriority)enumerator.Current;
                            if (storagePriority != 0)
                            {
                                StoragePriority localPr = storagePriority;
                                list.Add(new FloatMenuOption(localPr.Label().CapitalizeFirst(), delegate
                                {
                                    settings.Priority = localPr;
                                }, MenuOptionPriority.Default, null, null, 0f, null, null));
                            }
                        }
                    }
                    finally
                    {
                        IDisposable disposable;
                        if ((disposable = (enumerator as IDisposable)) != null)
                        {
                            disposable.Dispose();
                        }
                    }
                    Find.WindowStack.Add(new FloatMenu(list));
                }
                UIHighlighter.HighlightOpportunity(rect, "StoragePriority");
            }
            ThingFilter parentFilter = null;

            if (selStoreSettingsParent.GetParentStoreSettings() != null)
            {
                parentFilter = selStoreSettingsParent.GetParentStoreSettings().filter;
            }
            Rect rect2 = new Rect(0f, this.TopAreaHeight, position.width, position.height - this.TopAreaHeight);

            ThingFilterUI.DoThingFilterConfigWindow(rect2, ref this.scrollPosition, settings.filter, parentFilter, 8, (IEnumerable <ThingDef>)null, (IEnumerable <SpecialThingFilterDef>)null, (List <ThingDef>)null);
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.StorageTab, KnowledgeAmount.FrameDisplayed);
            GUI.EndGroup();
        }
Exemple #9
0
        private void DrawRight(Rect rect)
        {
            // Menu
            {
                var menuRect = new Rect(rect);
                menuRect.yMax -= 36;

                Register.restaurant.Menu.GetMenuFilters(out var filter, out var parentFilter);
                ThingFilterUI.DoThingFilterConfigWindow(menuRect, ref menuScrollPosition, filter, parentFilter,
                                                        1, null, HiddenSpecialThingFilters(), true);
            }
        }
Exemple #10
0
        public override void DoWindowContents(Rect inRect)
        {
            GUI.BeginGroup(inRect);

            ThingFilterUI.DoThingFilterConfigWindow(new Rect(0f, 20f, inRect.width, inRect.height - 70f), ref this.scrollPositionThingFilter, this.logisticRequester.requestFilter);

            Widgets.IntEntry(new Rect(0f, inRect.height - 40f, inRect.width, 32f), ref this.logisticRequester.totalRequestCount, ref this.editBufferCount);
            if (this.logisticRequester.totalRequestCount < 0)
            {
                this.logisticRequester.totalRequestCount = 0;
            }

            GUI.EndGroup();
        }
Exemple #11
0
        /// <summary>
        /// Draw window contents.
        /// </summary>
        /// <param name="inRect"> Rect for drawing. </param>
        public override void DoWindowContents(Rect inRect)
        {
            Rect labelRect = inRect.ReplaceHeight(GenUI.ListSpacing * 2);

            Widgets.TextArea(labelRect, UIText.GlobalOutfitSettingWarning.TranslateSimple(), true);
            ThingFilterUI.DoThingFilterConfigWindow(
                inRect.ReplaceyMin(inRect.y + GenUI.ListSpacing * 2 + GenUI.GapSmall)
                , ref _scrollPosition
                , _filter
                , _apparelGlobalFilter
                , 16
                , null
                , new[] { SpecialThingFilterDefOf.AllowNonDeadmansApparel });
        }
        protected override void FillTab()
        {
            ThingFilter allowances;

            ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.StorageTab, KnowledgeAmount.GuiFrame);
            ConceptDecider.TeachOpportunity(ConceptDefOf.StorageTabCategories, OpportunityType.GuiFrame);
            ConceptDecider.TeachOpportunity(ConceptDefOf.StoragePriority, OpportunityType.GuiFrame);
            allowances = ((Vehicle_Cart)Enumerable.First <object>(Find.Selector.SelectedObjects)).allowances;
            Rect position = GenUI.ContractedBy(new Rect(0.0f, 0.0f, Itab_Pawn_Vehicle_Storage.WinSize.x, Itab_Pawn_Vehicle_Storage.WinSize.y), 10f);

            GUI.BeginGroup(position);

            ThingFilterUI.DoThingFilterConfigWindow(new Rect(0.0f, 35f, position.width, position.height - 35f), ref this.scrollPosition, allowances, null);
            GUI.EndGroup();
        }
        public static void DoPreview(Listing_Standard list)
        {
            list.Gap();

            const float previewHeight = 250f;

            Rect rect = list.GetRect(previewHeight);

            Text.Font = GameFont.Tiny;
            Widgets.Label(new Rect(rect.x, rect.y, rect.width * 0.5f, Text.LineHeight), RSACoreKeys.RSACore_Preview.Translate());

            ThingFilterUtil.QueueNextInvocationSearch(SearchCategories.TermFor("Settings"));
            ThingFilterUI.DoThingFilterConfigWindow(
                new Rect(rect.width - 300f, rect.y, 300f, previewHeight),
                ref scrollPosition,
                filter);
        }
Exemple #14
0
        protected override void FillTab()
        {
            ThingFilter allowances;

            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.StorageTab, KnowledgeAmount.FrameDisplayed);
            LessonAutoActivator.TeachOpportunity(ConceptDefOf.StorageTab, OpportunityType.Critical);
            LessonAutoActivator.TeachOpportunity(ConceptDefOf.Stockpiles, OpportunityType.Critical);
            Vehicle_Cart cart = Find.Selector.SelectedObjects.First() as Vehicle_Cart;

            allowances = ((Vehicle_Cart)Find.Selector.SelectedObjects.First()).allowances;



            Rect position = new Rect(0.0f, 0.0f, WinSize.x, WinSize.y).ContractedBy(10f);

            GUI.BeginGroup(position);

            ThingFilterUI.DoThingFilterConfigWindow(new Rect(0.0f, 35f, position.width, position.height - 35f), ref scrollPosition, allowances);
            GUI.EndGroup();
        }
Exemple #15
0
        protected override void FillTab()
        {
            IStoreSettingsParent selStoreSettingsParent = this.SelStoreSettingsParent;
            StorageSettings      settings = selStoreSettingsParent.GetStoreSettings();
            Rect position = new Rect(0f, 0f, ITab_Storage.WinSize.x, ITab_Storage.WinSize.y).ContractedBy(10f);

            GUI.BeginGroup(position);
            if (this.IsPrioritySettingVisible)
            {
                Text.Font = GameFont.Small;
                Rect rect = new Rect(0f, 0f, 160f, this.TopAreaHeight - 6f);
                if (Widgets.ButtonText(rect, "Priority".Translate() + ": " + settings.Priority.Label(), true, false, true))
                {
                    List <FloatMenuOption> list = new List <FloatMenuOption>();
                    foreach (StoragePriority storagePriority in Enum.GetValues(typeof(StoragePriority)))
                    {
                        if (storagePriority != StoragePriority.Unstored)
                        {
                            StoragePriority localPr = storagePriority;
                            list.Add(new FloatMenuOption(localPr.Label().CapitalizeFirst(), delegate
                            {
                                settings.Priority = localPr;
                            }, MenuOptionPriority.Default, null, null, 0f, null, null));
                        }
                    }
                    Find.WindowStack.Add(new FloatMenu(list));
                }
                UIHighlighter.HighlightOpportunity(rect, "StoragePriority");
            }
            ThingFilter parentFilter = null;

            if (selStoreSettingsParent.GetParentStoreSettings() != null)
            {
                parentFilter = selStoreSettingsParent.GetParentStoreSettings().filter;
            }
            Rect rect2 = new Rect(0f, this.TopAreaHeight, position.width, position.height - this.TopAreaHeight);

            ThingFilterUI.DoThingFilterConfigWindow(rect2, ref this.scrollPosition, settings.filter, parentFilter, 8, null, null, null);
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.StorageTab, KnowledgeAmount.FrameDisplayed);
            GUI.EndGroup();
        }
Exemple #16
0
        public override void DoWindowContents(Rect inRect)
        {
            if (thingFilter.AllowedThingDefs.Count() > 1)
            {
                thingFilter = new ThingFilter();
                thingFilter.AllowedQualityLevels     = SelectQualities;
                thingFilter.AllowedHitPointsPercents = SelectHitPointsPercents;
                thingFilter.SetDisallowAll(null, null);
            }
            SelectThingDef          = thingFilter.AllowedThingDefs.FirstOrDefault();
            SelectQualities         = thingFilter.AllowedQualityLevels;
            SelectHitPointsPercents = thingFilter.AllowedHitPointsPercents;

            const float mainListingSpacing = 6f;

            var btnSize      = new Vector2(140f, 40f);
            var buttonYStart = inRect.height - btnSize.y;

            /*
             * var ev = Event.current;
             * if (Widgets.ButtonText(new Rect(0, buttonYStart, btnSize.x, btnSize.y), "OCity_DialogInput_Ok".Translate())
             || ev.isKey && ev.type == EventType.KeyDown && ev.keyCode == KeyCode.Return)
             */
            if (SelectThingDef != null)
            {
                Close();
            }

            if (Widgets.ButtonText(new Rect(inRect.width - btnSize.x, buttonYStart, btnSize.x, btnSize.y), "OCity_DialogInput_Cancele".Translate()))
            {
                Close();
            }

            //выше кнопок
            Rect workRect = new Rect(inRect.x, inRect.y, inRect.width, buttonYStart - mainListingSpacing);

            ThingFilterUI.DoThingFilterConfigWindow(workRect, ref this.scrollPosition, thingFilter, null, 8);
        }
        public override void DoWindowContents(Rect inRect)
        {
            Rect titleRect   = inRect.TopPartPixels(40);
            Rect buttonsRect = inRect.BottomPartPixels(40);
            Rect okayRect    = buttonsRect.RightHalf();
            Rect filterRect  = inRect;

            filterRect.height -= 80;
            filterRect.y      += 35;

            Widgets.Label(titleRect, "IW.OutputFilterTitle".Translate());

            ThingFilterUI.DoThingFilterConfigWindow(filterRect, ref scrollPosition, filter,
                                                    openMask: TreeOpenMasks.ThingFilter,
                                                    forceHiddenFilters: specialThingDefs,
                                                    parentFilter: baseFilter);

            if (Widgets.ButtonText(okayRect, "OK".Translate()))
            {
                if (filter.AllowedThingDefs.Count() == 0)
                {
                    extendedBill.ProductAdditionalFilter = null;
                }
                else
                {
                    if (extendedBill.ProductAdditionalFilter == null)
                    {
                        extendedBill.ProductAdditionalFilter = filter;
                    }
                    else
                    {
                        extendedBill.ProductAdditionalFilter.CopyAllowancesFrom(filter);
                    }
                }
                Close();
            }
        }
Exemple #18
0
        public void OnGUI(Rect rect)
        {
            float curY            = 0f;
            float repeatModeButX  = 0f;
            float adjustButHeight = 30f;

            try
            {
                GUI.BeginGroup(rect);
                //Do the top buttons. If the parent is not null, then do the suspend button.
                if (!setupStage)
                {
                    float suspendButRightEdge = rect.width / 2f - 5f;
                    Rect  suspendButRect      = new Rect(0f, 0f, suspendButRightEdge, buttonSize.y);
                    if (Suspended)
                    {
                        if (Widgets.TextButton(suspendButRect, "Suspended".Translate()))
                        {
                            Suspended = false;
                        }
                    }
                    else
                    {
                        if (Widgets.TextButton(suspendButRect, "NotSuspended".Translate()))
                        {
                            Suspended = true;
                        }
                    }
                    repeatModeButX = rect.width / 2f + 5f;
                }
                string label = "But";
                if (repeatMode == BillRepeatMode.RepeatCount)
                {
                    label = "DoXTimes".Translate();
                }
                if (repeatMode == BillRepeatMode.TargetCount)
                {
                    label = "DoUntilYouHaveX".Translate();
                }
                if (repeatMode == BillRepeatMode.Forever)
                {
                    label = "DoForever".Translate();
                }
                Vector2 repeatButSize = new Vector2(rect.width - repeatModeButX, buttonSize.y);
                Rect    repeatButRect = new Rect(repeatModeButX, curY, repeatButSize.x, repeatButSize.y);
                if (Widgets.TextButton(repeatButRect, label))
                {
                    List <FloatMenuOption> list = new List <FloatMenuOption>();
                    list.Add(new FloatMenuOption("DoXTimes".Translate(), delegate
                    {
                        this.repeatMode = BillRepeatMode.RepeatCount;
                    }));
                    list.Add(new FloatMenuOption("DoUntilYouHaveX".Translate(), delegate
                    {
                        this.repeatMode = BillRepeatMode.TargetCount;
                    }));
                    list.Add(new FloatMenuOption("DoForever".Translate(), delegate
                    {
                        this.repeatMode = BillRepeatMode.Forever;
                    }));
                    Find.WindowStack.Add(new FloatMenu(list));
                }
                curY += repeatButSize.y + margin;

                //Do the target count label
                Rect countRect = new Rect(0, curY, rect.width, 30f);
                curY += countRect.height + margin;
                string text = string.Empty;
                if (this.repeatMode == BillRepeatMode.RepeatCount)
                {
                    text = "RepeatCount".Translate(new object[] {
                        Cycles.ToString()
                    });
                    float butPadding = 2f;
                    float butWidth   = (rect.width - 8 * butPadding) / 5f;
                    float xPos       = 0f;
                    Rect  but1Rect   = new Rect(xPos, curY, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but1Rect, "-25"))
                    {
                        if (Cycles == 0)
                        {
                            SoundStarter.PlayOneShot(SoundDefOf.ClickReject, SoundInfo.OnCamera());
                        }
                        else
                        {
                            Cycles -= 25;
                        }
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but2Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but2Rect, "-1"))
                    {
                        if (Cycles == 0)
                        {
                            SoundStarter.PlayOneShot(SoundDefOf.ClickReject, SoundInfo.OnCamera());
                        }
                        else
                        {
                            Cycles -= 1;
                        }
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but3Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but3Rect, "1"))
                    {
                        Cycles = 1;
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but4Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but4Rect, "+1"))
                    {
                        Cycles += 1;
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but5Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but5Rect, "+25"))
                    {
                        Cycles += 25;
                    }
                }
                else if (repeatMode == BillRepeatMode.TargetCount)
                {
                    text = "TargetCount".Translate(new object[] {
                        (TargetCount >= 999999)?"Infinite".Translate() : TargetCount.ToString()
                    });
                    float butPadding = 2f;
                    float butWidth   = (rect.width - 12 * butPadding) / 7f;
                    float xPos       = 0f;
                    Rect  but1Rect   = new Rect(xPos, curY, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but1Rect, "-250"))
                    {
                        if (TargetCount == 0)
                        {
                            SoundStarter.PlayOneShot(SoundDefOf.ClickReject, SoundInfo.OnCamera());
                        }
                        else
                        {
                            TargetCount -= 250;
                        }
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but2Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but2Rect, "-25"))
                    {
                        if (TargetCount == 0)
                        {
                            SoundStarter.PlayOneShot(SoundDefOf.ClickReject, SoundInfo.OnCamera());
                        }
                        else
                        {
                            TargetCount -= 25;
                        }
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but3Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but3Rect, "-1"))
                    {
                        if (TargetCount == 0)
                        {
                            SoundStarter.PlayOneShot(SoundDefOf.ClickReject, SoundInfo.OnCamera());
                        }
                        else
                        {
                            TargetCount -= 1;
                        }
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but4Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but4Rect, "1"))
                    {
                        TargetCount = 1;
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but5Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but5Rect, "+1"))
                    {
                        TargetCount += 1;
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but6Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but6Rect, "+25"))
                    {
                        TargetCount += 25;
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but7Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but7Rect, "+250"))
                    {
                        TargetCount += 250;
                    }
                }
                else if (repeatMode == BillRepeatMode.Forever)
                {
                    text = "Do Forever";
                }
                else
                {
                    throw new InvalidOperationException();
                }
                curY += adjustButHeight + margin + 6f;

                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(countRect, text);
                //Now for the ThingFilter box (shiver)
                Rect thingFilterLabelRect = new Rect(0f, curY, rect.width, 20f);
                curY += thingFilterLabelRect.height + margin;
                Widgets.Label(thingFilterLabelRect, "PermittedIngredients".Translate());
                Text.Anchor = TextAnchor.UpperLeft;

                float tfheight        = rect.height - curY - adjustButHeight - margin;
                Rect  thingFilterRect = new Rect(0f, curY, rect.width, tfheight);
                curY += tfheight + margin;
                ThingFilterUI.DoThingFilterConfigWindow(thingFilterRect, ref this.scrollPosition, this.ingredientsFilter, this.recipe.fixedIngredientFilter);
                //Well that wasn't so hard after all
                float checkWidth = rect.width / 2 - 30f;
                float checkXPos  = rect.width / 2 - (checkWidth / 2);
                Rect  checkRect  = new Rect(checkXPos, curY, checkWidth, adjustButHeight);
                Widgets.LabelCheckbox(checkRect, "Complete all", ref this.completeAll);
                string s = "Activating this will set the Assembly line to send down the completed products once all cycles of the order have been completed, or when it has completed 15 cycles. This helps reduce the number of incoming drops when the completion time of the recipe is very quick.";
                if (RepeatMode == BillRepeatMode.TargetCount)
                {
                    s = "Activating this will set the Assembly line to send down the completed products once all cycles of the order have been completed, or when it has completed 5 cycles. This helps reduce the number of incoming drops when the completion time of the recipe is very quick.";
                }
                TipSignal tip = new TipSignal(s);
                TooltipHandler.TipRegion(checkRect, tip);
            }
            finally
            {
                GUI.EndGroup();
                Text.Anchor = TextAnchor.UpperLeft;
                Text.Font   = GameFont.Small;
            }
        }
Exemple #19
0
        protected override void FillTab()
        {
            IStoreSettingsParent selStoreSettingsParent = this.SelStoreSettingsParent;
            StorageSettings      settings = selStoreSettingsParent.GetStoreSettings();

            Rect position = new Rect(0f, 0f, ITab_Lazy.WinSize.x, ITab_Lazy.WinSize.y).ContractedBy(10f);

            GUI.BeginGroup(position);
            if (this.IsPrioritySettingVisible)
            {
                Text.Font = GameFont.Small;
                Rect rect = new Rect(0f, 0f, 160f, this.TopAreaHeight - 6f);
                if (Widgets.ButtonText(rect, "Priority".Translate() + ": " + settings.Priority.Label(), true, false, true))
                {
                    List <FloatMenuOption> list = new List <FloatMenuOption>();
                    foreach (StoragePriority storagePriority in Enum.GetValues(typeof(StoragePriority)))
                    {
                        if (storagePriority != StoragePriority.Unstored)
                        {
                            StoragePriority localPr = storagePriority;
                            list.Add(new FloatMenuOption(localPr.Label().CapitalizeFirst(), delegate
                            {
                                settings.Priority = localPr;
                            }, MenuOptionPriority.Default, null, null, 0f, null, null));
                        }
                    }
                    Find.WindowStack.Add(new FloatMenu(list));
                }
                UIHighlighter.HighlightOpportunity(rect, "StoragePriority");
            }
            //Lazy button & Threshold Sliders
            {
                Text.Font = GameFont.Small;
                Rect         rect      = new Rect(0f, 35f, 160f, this.TopAreaHeight - 6f);
                LazySettings stockpile = settings as LazySettings;
                if (stockpile == null)
                {
                    Log.Error(string.Format($"Lazy Tab Error: Attempted to load {SelObject} settings as LazySettings, when it was of type {settings.GetType()}"));
                }
                else
                {
                    //Type Button
                    if (Widgets.ButtonText(rect, "Type: " + stockpile.type.ToString(), true, false, true))
                    {
                        List <FloatMenuOption> list = new List <FloatMenuOption>();
                        foreach (LazyType type in Enum.GetValues(typeof(LazyType)))
                        {
                            LazyType localTy = type;
                            list.Add(new FloatMenuOption(type.ToString(), delegate
                            {
                                stockpile.type = type;
                            }, MenuOptionPriority.Default, null, null, 0f, null, null));
                            Find.WindowStack.Add(new FloatMenu(list));
                        }
                    }
                    //Cache Threshold Slider
                    if (stockpile.type == LazyType.Cache)
                    {
                        Rect             sliderRect = new Rect(0f, 66f, WinSize.x - 20f, 70f);
                        Listing_Standard stand      = new Listing_Standard();
                        stand.Begin(sliderRect);
                        stand.Label(string.Format($"Cache Threshold: {stockpile.CacheThreshold * 100:0}%"));
                        stockpile.CacheThreshold = stand.Slider(stockpile.CacheThreshold, 0f, 0.75f);
                        stand.End();
                    }
                    //Buffer Threshold Slider
                    else if (stockpile.type == LazyType.Buffer)
                    {
                        Rect             sliderRect = new Rect(0f, 66f, WinSize.x - 20f, 70f);
                        Listing_Standard stand      = new Listing_Standard();
                        stand.Begin(sliderRect);
                        stand.Label(string.Format($"Buffer Threshold: {stockpile.BufferThreshold * 100:0}%"));
                        stockpile.BufferThreshold = stand.Slider(stockpile.BufferThreshold, 0.25f, 1f);
                        stand.End();
                    }
                }
            }
            ThingFilter parentFilter = null;

            if (selStoreSettingsParent.GetParentStoreSettings() != null)
            {
                parentFilter = selStoreSettingsParent.GetParentStoreSettings().filter;
            }
            Rect rect2 = new Rect(0f, (this.TopAreaHeight * 3) + 5, position.width, position.height - (this.TopAreaHeight * 2));

            ThingFilterUI.DoThingFilterConfigWindow(rect2, ref this.scrollPosition, settings.filter, parentFilter, 8, null, null, null);
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.StorageTab, KnowledgeAmount.FrameDisplayed);
            GUI.EndGroup();
        }
        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));
            }
        }
Exemple #21
0
        public override void DoWindowContents(Rect inRect)
        {
            float num  = 0f;
            Rect  rect = new Rect(0f, 0f, 150f, 35f);

            num += 150f;
            if (Widgets.ButtonText(rect, "SelectFoodRestriction".Translate()))
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                foreach (FoodRestriction allFoodRestriction in Current.Game.foodRestrictionDatabase.AllFoodRestrictions)
                {
                    FoodRestriction localRestriction = allFoodRestriction;
                    list.Add(new FloatMenuOption(localRestriction.label, delegate
                    {
                        SelectedFoodRestriction = localRestriction;
                    }));
                }
                Find.WindowStack.Add(new FloatMenu(list));
            }
            num += 10f;
            Rect rect2 = new Rect(num, 0f, 150f, 35f);

            num += 150f;
            if (Widgets.ButtonText(rect2, "NewFoodRestriction".Translate()))
            {
                SelectedFoodRestriction = Current.Game.foodRestrictionDatabase.MakeNewFoodRestriction();
            }
            num += 10f;
            Rect rect3 = new Rect(num, 0f, 150f, 35f);

            num += 150f;
            if (Widgets.ButtonText(rect3, "DeleteFoodRestriction".Translate()))
            {
                List <FloatMenuOption> list2 = new List <FloatMenuOption>();
                foreach (FoodRestriction allFoodRestriction2 in Current.Game.foodRestrictionDatabase.AllFoodRestrictions)
                {
                    FoodRestriction localRestriction2 = allFoodRestriction2;
                    list2.Add(new FloatMenuOption(localRestriction2.label, delegate
                    {
                        AcceptanceReport acceptanceReport = Current.Game.foodRestrictionDatabase.TryDelete(localRestriction2);
                        if (!acceptanceReport.Accepted)
                        {
                            Messages.Message(acceptanceReport.Reason, MessageTypeDefOf.RejectInput, historical: false);
                        }
                        else if (localRestriction2 == SelectedFoodRestriction)
                        {
                            SelectedFoodRestriction = null;
                        }
                    }));
                }
                Find.WindowStack.Add(new FloatMenu(list2));
            }
            float   width        = inRect.width;
            float   num2         = inRect.height - 40f;
            Vector2 closeButSize = CloseButSize;
            Rect    rect4        = new Rect(0f, 40f, width, num2 - closeButSize.y).ContractedBy(10f);

            if (SelectedFoodRestriction == null)
            {
                GUI.color   = Color.grey;
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(rect4, "NoFoodRestrictionSelected".Translate());
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
            }
            else
            {
                GUI.BeginGroup(rect4);
                Rect rect5 = new Rect(0f, 0f, 200f, 30f);
                DoNameInputRect(rect5, ref SelectedFoodRestriction.label);
                Rect        rect6        = new Rect(0f, 40f, 300f, rect4.height - 45f - 10f);
                Rect        rect7        = rect6;
                ref Vector2 reference    = ref scrollPosition;
                ThingFilter filter       = SelectedFoodRestriction.filter;
                ThingFilter parentFilter = foodGlobalFilter;
                IEnumerable <SpecialThingFilterDef> forceHiddenFilters = HiddenSpecialThingFilters();
                ThingFilterUI.DoThingFilterConfigWindow(rect7, ref reference, filter, parentFilter, 1, null, forceHiddenFilters, forceHideHitPointsConfig: true);
                GUI.EndGroup();
            }
        public override void DoWindowContents(Rect inRect)
        {
            float num  = 0f;
            Rect  rect = new Rect(0f, 0f, 150f, 35f);

            num += 150f;
            if (Widgets.ButtonText(rect, "SelectOutfit".Translate()))
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                foreach (Outfit allOutfit in Current.Game.outfitDatabase.AllOutfits)
                {
                    Outfit localOut = allOutfit;
                    list.Add(new FloatMenuOption(localOut.label, delegate
                    {
                        SelectedOutfit = localOut;
                    }));
                }
                Find.WindowStack.Add(new FloatMenu(list));
            }
            num += 10f;
            Rect rect2 = new Rect(num, 0f, 150f, 35f);

            num += 150f;
            if (Widgets.ButtonText(rect2, "NewOutfit".Translate()))
            {
                SelectedOutfit = Current.Game.outfitDatabase.MakeNewOutfit();
            }
            num += 10f;
            Rect rect3 = new Rect(num, 0f, 150f, 35f);

            num += 150f;
            if (Widgets.ButtonText(rect3, "DeleteOutfit".Translate()))
            {
                List <FloatMenuOption> list2 = new List <FloatMenuOption>();
                foreach (Outfit allOutfit2 in Current.Game.outfitDatabase.AllOutfits)
                {
                    Outfit localOut2 = allOutfit2;
                    list2.Add(new FloatMenuOption(localOut2.label, delegate
                    {
                        AcceptanceReport acceptanceReport = Current.Game.outfitDatabase.TryDelete(localOut2);
                        if (!acceptanceReport.Accepted)
                        {
                            Messages.Message(acceptanceReport.Reason, MessageTypeDefOf.RejectInput, historical: false);
                        }
                        else if (localOut2 == SelectedOutfit)
                        {
                            SelectedOutfit = null;
                        }
                    }));
                }
                Find.WindowStack.Add(new FloatMenu(list2));
            }
            Rect rect4 = new Rect(0f, 40f, inRect.width, inRect.height - 40f - CloseButSize.y).ContractedBy(10f);

            if (SelectedOutfit == null)
            {
                GUI.color   = Color.grey;
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(rect4, "NoOutfitSelected".Translate());
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
            }
            else
            {
                GUI.BeginGroup(rect4);
                DoNameInputRect(new Rect(0f, 0f, 200f, 30f), ref SelectedOutfit.label);
                ThingFilterUI.DoThingFilterConfigWindow(new Rect(0f, 40f, 300f, rect4.height - 45f - 10f), ref scrollPosition, SelectedOutfit.filter, apparelGlobalFilter, 16, null, HiddenSpecialThingFilters());
                GUI.EndGroup();
            }
        }
Exemple #23
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));
            }
        }
Exemple #24
0
		public override void DoWindowContents(Rect inRect)
		{
			float num = 0f;
			Rect rect = new Rect(0f, 0f, 150f, 35f);
			num += 150f;
			if (Widgets.ButtonText(rect, "SelectOutfit".Translate(), true, false, true))
			{
				List<FloatMenuOption> list = new List<FloatMenuOption>();
				foreach (Outfit current in Current.Game.outfitDatabase.AllOutfits)
				{
					Outfit localOut = current;
					list.Add(new FloatMenuOption(localOut.label, delegate
					{
						this.SelectedOutfit = localOut;
					}, MenuOptionPriority.Default, null, null, 0f, null, null));
				}
				Find.WindowStack.Add(new FloatMenu(list));
			}
			num += 10f;
			Rect rect2 = new Rect(num, 0f, 150f, 35f);
			num += 150f;
			if (Widgets.ButtonText(rect2, "NewOutfit".Translate(), true, false, true))
			{
				this.SelectedOutfit = Current.Game.outfitDatabase.MakeNewOutfit();
			}
			num += 10f;
			Rect rect3 = new Rect(num, 0f, 150f, 35f);
			num += 150f;
			if (Widgets.ButtonText(rect3, "DeleteOutfit".Translate(), true, false, true))
			{
				List<FloatMenuOption> list2 = new List<FloatMenuOption>();
				foreach (Outfit current2 in Current.Game.outfitDatabase.AllOutfits)
				{
					Outfit localOut = current2;
					list2.Add(new FloatMenuOption(localOut.label, delegate
					{
						AcceptanceReport acceptanceReport = Current.Game.outfitDatabase.TryDelete(localOut);
						if (!acceptanceReport.Accepted)
						{
							Messages.Message(acceptanceReport.Reason, MessageTypeDefOf.RejectInput);
						}
						else if (localOut == this.SelectedOutfit)
						{
							this.SelectedOutfit = null;
						}
					}, MenuOptionPriority.Default, null, null, 0f, null, null));
				}
				Find.WindowStack.Add(new FloatMenu(list2));
			}
			Rect rect4 = new Rect(0f, 40f, inRect.width, inRect.height - 40f - this.CloseButSize.y).ContractedBy(10f);
			if (this.SelectedOutfit == null)
			{
				GUI.color = Color.grey;
				Text.Anchor = TextAnchor.MiddleCenter;
				Widgets.Label(rect4, "NoOutfitSelected".Translate());
				Text.Anchor = TextAnchor.UpperLeft;
				GUI.color = Color.white;
				return;
			}
			GUI.BeginGroup(rect4);
			Rect rect5 = new Rect(0f, 0f, 200f, 30f);
			Dialog_ManageOutfits.DoNameInputRect(rect5, ref this.SelectedOutfit.label);
			Rect rect6 = new Rect(0f, 40f, 300f, rect4.height - 45f - 10f);
			Rect rect7 = rect6;
			ThingFilter filter = this.SelectedOutfit.filter;
			ThingFilter parentFilter = Dialog_ManageOutfits.apparelGlobalFilter;
			int openMask = 16;
			IEnumerable<SpecialThingFilterDef> forceHiddenFilters = this.HiddenSpecialThingFilters();
			ThingFilterUI.DoThingFilterConfigWindow(rect7, ref this.scrollPosition, filter, parentFilter, openMask, null, forceHiddenFilters, null);
			GUI.EndGroup();
		}
            public override void DoWindowContents(Rect inRect) // For a specific DSU
            {
                // for the record, Listing_Standards kind of suck. Convenient enough, but no flexibility
                // TODO when I'm bored: switch to manual, add red background for disabled units
                // Bonus problem with Listing_Standard: nested scrolling windows do not work
                //   well - specifically the ThingFilter UI insisde a Listing_Standard
                // We are able to get around that problem by having our ScrollView be outside
                //   the Listing_S... (instead of using the L_S's .ScrollView) and having the
                //   ThingFilter's UI after the L_S ends.

                // First: Set up a ScrollView:
                // outer window (with room for buttons at bottom:
                Rect s = new Rect(inRect.x, inRect.y, inRect.width, inRect.height - CloseButSize.y - 5f);

                // inner window that has entire content:
                y = y + 200; // this is to ensure the Listing_Standard does not run out of height,
                //                and can fully display everything - giving a proper length 'y' at
                //                its .End() call.
                //          Worst case scenario: y starts as 0, and the L_S gets to a CurHeight of
                //            200, and then updates at 400 the next time.  Because of the way RW's
                //            windows work, this will rapidly converge on a large enough value.
                Rect inner = new Rect(0, 0, s.width - 20, this.y);

                Widgets.BeginScrollView(s, ref DSUScrollPosition, inner);
                // We cannot do the scrollview inside the L_S:
                // l.BeginScrollView(s, ref DSUScrollPosition, ref v); // Does not allow filter UI
                var l = new Listing_Standard();

                l.Begin(inner);
                l.Label(def.label);
                l.GapLine();
                // Much TODO, so wow:
                tmpLabel = l.TextEntryLabeled("LWMDSpDSUlabel".Translate(), tmpLabel);
                string tmpstring = null;

                l.TextFieldNumericLabeled("LWM_DS_maxNumStacks".Translate().CapitalizeFirst() + " "
                                          + "LWM_DS_Default".Translate(tracker.GetDefaultValue(def.defName, "maxNumStacks",
                                                                                               tmpMaxNumStacks)),
                                          ref tmpMaxNumStacks, ref tmpstring, 0);
                tmpstring = null;
                l.TextFieldNumericLabeled <float>("LWM_DS_maxTotalMass".Translate().CapitalizeFirst() + " " +
                                                  "LWM_DS_Default".Translate(tracker.GetDefaultValue(def.defName,
                                                                                                     "maxTotalMass", tmpMaxTotalMass).ToString()),
                                                  ref tmpMaxTotalMass, ref tmpstring, 0f);
                tmpstring = null;
                l.TextFieldNumericLabeled <float>("LWM_DS_maxMassOfStoredItem".Translate().CapitalizeFirst() + " " +
                                                  "LWM_DS_Default".Translate(tracker.GetDefaultValue(def.defName,
                                                                                                     "maxMassStoredItem", tmpMaxMassStoredItem).ToString()),
                                                  ref tmpMaxMassStoredItem, ref tmpstring, 0f);
                l.CheckboxLabeled("LWMDSpDSUshowContents".Translate(), ref tmpShowContents);
                l.GapLine();
                l.EnumRadioButton(ref tmpOverlayType, "LWMDSpDSUoverlay".Translate());
                l.GapLine();
                l.EnumRadioButton(ref tmpStoragePriority, "LWMDSpDSUstoragePriority".Translate());
                l.GapLine();
                l.CheckboxLabeled("LWMDSpDSUchangeFilterQ".Translate(), ref useCustomThingFilter,
                                  "LWMDSpDSUchangeFilterQDesc".Translate());
                y = l.CurHeight;
                l.End();
                if (useCustomThingFilter)
                {
                    if (customThingFilter == null)
                    {
                        customThingFilter = new ThingFilter();
                        customThingFilter.CopyAllowancesFrom(def.building.fixedStorageSettings.filter);
                        Utils.Mess(Utils.DBF.Settings, "Created new filter for " + def.defName + ": " + customThingFilter);
//                        Log.Error("Old filter has: "+def.building.fixedStorageSettings.filter.AllowedDefCount);
//                        Log.Warning("New filter has: "+customThingFilter.AllowedDefCount);
                    }
                    // Since this is outside the L_S, we make our own rectangle and use it:
                    //   Nope: Rect r=l.GetRect(CustomThingFilterHeight); // this fails
                    Rect r = new Rect(20, y, (inner.width - 40) * 3 / 4, CustomThingFilterHeight);
                    y += CustomThingFilterHeight;
                    ThingFilterUI.DoThingFilterConfigWindow(r, thingFilterState, customThingFilter);
                }
                else     // not using custom thing filter:
                {
                    if (customThingFilter != null || tracker.HasDefaultValueFor(this.def.defName, "filter"))
                    {
                        customThingFilter = null;
                        if (tracker.HasDefaultValueFor(this.def.defName, "filter"))
                        {
                            Utils.Mess(Utils.DBF.Settings, "  Removing filter for " + def.defName);
                            def.building.fixedStorageSettings.filter = (ThingFilter)tracker
                                                                       .GetDefaultValue <ThingFilter>(def.defName, "filter", null);
                            tracker.Remove(def.defName, "filter");
                        }
                    }
                }

                // This fails: l.EndScrollView(ref v);
                Widgets.EndScrollView();

                // Cancel button
                var closeRect = new Rect(inRect.width - CloseButSize.x, inRect.height - CloseButSize.y, CloseButSize.x, CloseButSize.y);

                if (Widgets.ButtonText(closeRect, "CancelButton".Translate()))
                {
                    Utils.Mess(Utils.DBF.Settings, "Cancel button selected - no changes made");
                    Close();
                }
                // Accept button - with accompanying logic
                closeRect = new Rect(inRect.width - (2 * CloseButSize.x + 5f), inRect.height - CloseButSize.y, CloseButSize.x, CloseButSize.y);
                if (Widgets.ButtonText(closeRect, "AcceptButton".Translate()))
                {
                    LWM.DeepStorage.Properties props = def.GetCompProperties <Properties>();
                    GUI.FocusControl(null); // unfocus, so that a focused text field may commit its value
                    Utils.Warn(Utils.DBF.Settings, "\"Accept\" button selected: changing values for " + def.defName);
                    tracker.UpdateToNewValue(def.defName, "label", tmpLabel, ref def.label);
                    tracker.UpdateToNewValue(def.defName,
                                             "maxNumStacks", tmpMaxNumStacks, ref props.maxNumberStacks);
                    tracker.UpdateToNewValue(def.defName,
                                             "maxTotalMass", tmpMaxTotalMass, ref props.maxTotalMass);
                    tracker.UpdateToNewValue(def.defName,
                                             "maxMassStoredItem", tmpMaxMassStoredItem, ref props.maxMassOfStoredItem);
                    tracker.UpdateToNewValue(def.defName,
                                             "showContents", tmpShowContents, ref props.showContents);
                    tracker.UpdateToNewValue(def.defName,
                                             "overlayType", tmpOverlayType, ref props.overlayType);
                    StoragePriority tmpSP = def.building.defaultStorageSettings.Priority; // hard to access private field directly
                    tracker.UpdateToNewValue(def.defName, "storagePriority", tmpStoragePriority, ref tmpSP);
                    def.building.defaultStorageSettings.Priority = tmpSP;
                    if (useCustomThingFilter)   // danger ahead - automatically use it, even if stupidly set up
                    {
                        if (!tracker.HasDefaultValueFor(def.defName, "filter"))
                        {
                            Utils.Mess(Utils.DBF.Settings, "Creating default filter record for item " + def.defName);
                            tracker.AddDefaultValue(def.defName, "filter", def.building.fixedStorageSettings.filter);
                        }
                        def.building.fixedStorageSettings.filter = customThingFilter;
                    }
                    else
                    {
                        // restore default filter:
                        if (tracker.HasDefaultValueFor(def.defName, "filter"))
                        {
                            // we need to remove it
                            Utils.Mess(Utils.DBF.Settings, "Removing default filter record for item " + def.defName);
                            def.building.fixedStorageSettings.filter = (ThingFilter)tracker
                                                                       .GetDefaultValue <ThingFilter>(def.defName, "filter", null);
                            tracker.Remove(def.defName, "filter");
                        }
                    }
                    Close();
                }
                // Reset to Defaults
                closeRect = new Rect(inRect.width - (4 * CloseButSize.x + 10f), inRect.height - CloseButSize.y, 2 * CloseButSize.x, CloseButSize.y);
                if (!AreTempVarsDefaults() && Widgets.ButtonText(closeRect, "ResetBinding".Translate()))
                {
                    SetTempVarsToDefaults();
                }
            }
        public override void DoWindowContents(Rect inRect)
        {
            float num  = 0f;
            Rect  rect = new Rect(0f, 0f, 150f, 35f);

            num += 150f;
            if (Widgets.TextButton(rect, "SelectOutfit".Translate(), true, false))
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                foreach (Outfit current in Find.Map.outfitDatabase.AllOutfits)
                {
                    Outfit localOut = current;
                    list.Add(new FloatMenuOption(localOut.label, delegate
                    {
                        this.SelectedOutfit = localOut;
                    }, MenuOptionPriority.Medium, null, null));
                }
                Find.WindowStack.Add(new FloatMenu(list, false));
            }
            num += 10f;
            rect = new Rect(num, 0f, 150f, 35f);
            num += 150f;
            if (Widgets.TextButton(rect, "NewOutfit".Translate(), true, false))
            {
                this.SelectedOutfit = Find.Map.outfitDatabase.MakeNewOutfit();
            }
            num += 10f;
            rect = new Rect(num, 0f, 150f, 35f);
            num += 150f;
            if (Widgets.TextButton(rect, "DeleteOutfit".Translate(), true, false))
            {
                List <FloatMenuOption> list2 = new List <FloatMenuOption>();
                foreach (Outfit current2 in Find.Map.outfitDatabase.AllOutfits)
                {
                    Outfit localOut = current2;
                    list2.Add(new FloatMenuOption(localOut.label, delegate
                    {
                        AcceptanceReport acceptanceReport = Find.Map.outfitDatabase.TryDelete(localOut);
                        if (!acceptanceReport.Accepted)
                        {
                            Messages.Message(acceptanceReport.Reason, MessageSound.RejectInput);
                        }
                        else
                        {
                            if (localOut == this.SelectedOutfit)
                            {
                                this.SelectedOutfit = null;
                            }
                            foreach (Saveable_Outfit s in MapComponent_AutoEquip.Get.outfitCache.Where(i => i.outfit == localOut).ToArray())
                            {
                                MapComponent_AutoEquip.Get.outfitCache.Remove(s);
                            }
                        }
                    }, MenuOptionPriority.Medium, null, null));
                }
                Find.WindowStack.Add(new FloatMenu(list2, false));
            }
            rect = new Rect(0f, 40f, 300f, inRect.height - 40f - this.CloseButSize.y).ContractedBy(10f);
            if (this.SelectedOutfit == null)
            {
                GUI.color   = Color.grey;
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(rect, "NoOutfitSelected".Translate());
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
                return;
            }
            GUI.BeginGroup(rect);
            Rect rect1 = new Rect(0f, 0f, 200f, 30f);

            Dialog_ManageOutfitsAutoEquip.DoNameInputRect(rect1, ref this.SelectedOutfit.label, 30);
            rect1 = new Rect(0f, 40f, rect.width, rect.height - 45f - 10f);
            ThingFilterUI.DoThingFilterConfigWindow(rect1, ref this.scrollPosition, this.SelectedOutfit.filter, Dialog_ManageOutfitsAutoEquip.apparelGlobalFilter, 16);
            GUI.EndGroup();

            rect = new Rect(300f, 40f, inRect.width - 300f, inRect.height - 40f - this.CloseButSize.y).ContractedBy(10f);
            GUI.BeginGroup(rect);

            rect1 = new Rect(0f, 0f, rect.width, 30f);
            Widgets.LabelCheckbox(rect1, "AutoEquipAppendIndividualPawnStatus".Translate(), ref MapComponent_AutoEquip.Get.GetOutfit(this.SelectedOutfit).appendIndividualPawnStatus);

            rect1 = new Rect(0f, 40f, rect.width, rect.height - 45f - 10f);
            Dialog_ManageOutfitsAutoEquip.DoStatsInput(rect1, ref this.scrollPositionStats, MapComponent_AutoEquip.Get.GetOutfit(this.SelectedOutfit).stats);
            GUI.EndGroup();
        }
Exemple #27
0
        protected override void FillTab()
        {
            IStoreSettingsParent selStoreSettingsParent = this.SelStoreSettingsParent;
            StorageSettings      settings = selStoreSettingsParent.GetStoreSettings();

            Rect position = new Rect(0f, 0f, ITab_Lazy.WinSize.x, ITab_Lazy.WinSize.y).ContractedBy(10f);

            GUI.BeginGroup(position);
            if (this.IsPrioritySettingVisible)
            {
                Text.Font = GameFont.Small;
                Rect rect = new Rect(0f, 0f, 160f, this.TopAreaHeight - 6f);
                if (Widgets.ButtonText(rect, "Priority".Translate() + ": " + settings.Priority.Label(), true, false, true))
                {
                    List <FloatMenuOption> list = new List <FloatMenuOption>();
                    foreach (StoragePriority storagePriority in Enum.GetValues(typeof(StoragePriority)))
                    {
                        if (storagePriority != StoragePriority.Unstored)
                        {
                            StoragePriority localPr = storagePriority;
                            list.Add(new FloatMenuOption(localPr.Label().CapitalizeFirst(), delegate
                            {
                                settings.Priority = localPr;
                            }, MenuOptionPriority.Default, null, null, 0f, null, null));
                        }
                    }
                    Find.WindowStack.Add(new FloatMenu(list));
                }
                UIHighlighter.HighlightOpportunity(rect, "StoragePriority");
            }
            //Lazy button & Threshold Sliders
            {
                Text.Font = GameFont.Small;
                Rect         rect      = new Rect(0f, 35f, 160f, this.TopAreaHeight - 6f);
                LazySettings stockpile = LazySettingsManager.AddOrGetSettings(settings);
                if (stockpile == null)
                {
                    Log.Error(string.Format($"Lazy Tab Error: Attempted to load {SelObject} settings as LazySettings, when it was of type {settings.GetType()}"));
                }
                else
                {
                    //Type Button
                    if (Widgets.ButtonText(rect, "Type: " + stockpile.type.ToString(), true, false, true))
                    {
                        List <FloatMenuOption> list = new List <FloatMenuOption>();
                        foreach (LazyType type in Enum.GetValues(typeof(LazyType)))
                        {
                            LazyType localTy = type;
                            list.Add(new FloatMenuOption(type.ToString(), delegate
                            {
                                stockpile.type = type;
                            }, MenuOptionPriority.Default, null, null, 0f, null, null));
                            Find.WindowStack.Add(new FloatMenu(list));
                        }
                    }
                    //Cache Threshold Slider
                    if (stockpile.type == LazyType.Cache)
                    {
                        Rect             sliderRect = new Rect(0f, 66f, WinSize.x - 20f, 70f);
                        Listing_Standard stand      = new Listing_Standard();
                        stand.Begin(sliderRect);
                        stand.Label(string.Format($"Cache Threshold: {stockpile.CacheThreshold * 100:0}%"));
                        stockpile.CacheThreshold = stand.Slider(stockpile.CacheThreshold, 0f, 0.75f);
                        stand.End();
                    }
                    //Buffer Threshold Slider
                    else if (stockpile.type == LazyType.Buffer)
                    {
                        Rect             sliderRect = new Rect(0f, 66f, WinSize.x - 20f, 70f);
                        Listing_Standard stand      = new Listing_Standard();
                        stand.Begin(sliderRect);
                        stand.Label(string.Format($"Buffer Threshold: {stockpile.BufferThreshold * 100:0}%"));
                        stockpile.BufferThreshold = stand.Slider(stockpile.BufferThreshold, 0.25f, 1f);
                        stand.End();
                    }
                }
            }


            ThingFilter parentFilter = null;

            if (selStoreSettingsParent.GetParentStoreSettings() != null)
            {
                parentFilter = selStoreSettingsParent.GetParentStoreSettings().filter;
            }
            Rect rect2 = new Rect(0f, (this.TopAreaHeight * 3) + 5, position.width, position.height - (this.TopAreaHeight * 2));

            Bill[] first = (from b in BillUtility.GlobalBills()
                            where b is Bill_Production && b.GetStoreZone() == selStoreSettingsParent && b.recipe.WorkerCounter.CanPossiblyStoreInStockpile((Bill_Production)b, b.GetStoreZone())
                            select b).ToArray();


            ThingFilterUI.DoThingFilterConfigWindow(rect2, ref this.scrollPosition, settings.filter, parentFilter, 8, null, null, false, null, null);

            Bill[] second = (from b in BillUtility.GlobalBills()
                             where b is Bill_Production && b.GetStoreZone() == selStoreSettingsParent && b.recipe.WorkerCounter.CanPossiblyStoreInStockpile((Bill_Production)b, b.GetStoreZone())
                             select b).ToArray();

            IEnumerable <Bill> enumerable = first.Except(second);

            foreach (Bill item in enumerable)
            {
                Messages.Message("MessageBillValidationStoreZoneInsufficient".Translate(item.LabelCap, item.billStack.billGiver.LabelShort.CapitalizeFirst(), item.GetStoreZone().label), item.billStack.billGiver as Thing, MessageTypeDefOf.RejectInput, false);
            }

            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.StorageTab, KnowledgeAmount.FrameDisplayed);
            GUI.EndGroup();
        }
        public override void DoWindowContents(Rect inRect)
        {
            AddRenameButton(inRect);
            AddRenamedLabel();

            #region Origianl

            Text.Font = GameFont.Small;
            Rect             rect2            = new Rect(0f, 50f, 180f, inRect.height - 50f);
            Listing_Standard listing_Standard = new Listing_Standard();
            listing_Standard.Begin(rect2);

            if (bill.suspended)
            {
                if (listing_Standard.ButtonText("Suspended".Translate(), null))
                {
                    bill.suspended = false;
                }
            }
            else if (listing_Standard.ButtonText("NotSuspended".Translate(), null))
            {
                bill.suspended = true;
            }

            #endregion

            AddAssignWorkerButton(listing_Standard);

            if (listing_Standard.ButtonText(bill.repeatMode.GetLabel(), null))
            {
                BillRepeatModeUtility.MakeConfigFloatMenu(bill);
            }

            var label = ("BillStoreMode_" + bill.storeMode).Translate();
            if (listing_Standard.ButtonText(label, null))
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                foreach (BillStoreModeDef current in from bsm in DefDatabase <BillStoreModeDef> .AllDefs
                         orderby bsm.listOrder
                         select bsm)
                {
                    BillStoreModeDef smLocal = current;
                    list.Add(new FloatMenuOption(("BillStoreMode_" + current).Translate(), delegate
                    {
                        this.bill.storeMode = smLocal;
                    }, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
                Find.WindowStack.Add(new FloatMenu(list));
            }

            listing_Standard.Gap(12f);
            if (bill.repeatMode == BillRepeatModeDefOf.RepeatCount)
            {
                listing_Standard.Label("RepeatCount".Translate(bill.RepeatInfoText));
                listing_Standard.IntSetter(ref bill.repeatCount, 1, "1", 42f);
                listing_Standard.IntAdjuster(ref bill.repeatCount, 1, 25, 1); // changed
                listing_Standard.IntAdjuster(ref bill.repeatCount, 10, 250, 1);
            }
            else if (bill.repeatMode == BillRepeatModeDefOf.TargetCount)
            {
                var text = "CurrentlyHave".Translate() + ": ";
                text += bill.recipe.WorkerCounter.CountProducts(bill);
                text += " / ";
                text += bill.targetCount >= 999999 ? "Infinite".Translate().ToLower() : bill.targetCount.ToString();
                var text2 = bill.recipe.WorkerCounter.ProductsDescription(bill);
                if (!text2.NullOrEmpty())
                {
                    var text3 = text;
                    text = string.Concat(text3, "\n", "CountingProducts".Translate(), ": ", text2);
                }
                listing_Standard.Label(text);
                // changed
                // todo : extract method
                listing_Standard.IntSetter(ref bill.targetCount, 1, "1", 42f);
                listing_Standard.IntAdjuster(ref bill.targetCount, 1, 25, 1);
                listing_Standard.IntAdjuster(ref bill.targetCount, 10, 250, 1);
            }
            listing_Standard.Gap(12f);
            listing_Standard.Label("IngredientSearchRadius".Translate() + ": " + bill.ingredientSearchRadius.ToString("F0"));
            bill.ingredientSearchRadius = listing_Standard.Slider(bill.ingredientSearchRadius, 3f, 100f, null); // changed
            if (bill.ingredientSearchRadius >= 100f)
            {
                bill.ingredientSearchRadius = 999f;
            }

            //listing_Standard.Gap(-4f); // °¸ ��»ף
            if (bill.recipe.workSkill != null)
            {
                listing_Standard.Label("AllowedSkillRange".Translate(bill.recipe.workSkill.label.ToLower()));
                listing_Standard.IntRange(ref bill.allowedSkillRange, 0, 20);
            }


            AddMinBarButton(listing_Standard);

            #region original

            listing_Standard.End();
            Rect rect3 = new Rect(rect2.xMax + 6f, 50f, 280f, -1f);
            rect3.yMax = inRect.height - this.CloseButSize.y - 6f;
            ThingFilterUI.DoThingFilterConfigWindow(rect3, ref this.scrollPosition, this.bill.ingredientFilter, this.bill.recipe.fixedIngredientFilter, 4, null, null);
            Rect rect4 = new Rect(rect3.xMax + 6f, rect3.y + 30f, 0f, 0f);
            rect4.xMax = inRect.xMax;
            rect4.yMax = inRect.height - this.CloseButSize.y - 6f;
            StringBuilder stringBuilder = new StringBuilder();
            if (this.bill.recipe.description != null)
            {
                stringBuilder.AppendLine(this.bill.recipe.description);
                stringBuilder.AppendLine();
            }
            stringBuilder.AppendLine(Translator.Translate("WorkAmount") + ": " + GenText.ToStringWorkAmount(this.bill.recipe.WorkAmountTotal(null)));
            stringBuilder.AppendLine();
            for (int i = 0; i < this.bill.recipe.ingredients.Count; i++)
            {
                IngredientCount ingredientCount = this.bill.recipe.ingredients[i];
                if (!GenText.NullOrEmpty(ingredientCount.filter.Summary))
                {
                    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();
            }
            stringBuilder.AppendLine(Translator.Translate("MinimumSkills"));
            stringBuilder.AppendLine(this.bill.recipe.MinSkillString);
            Text.Font = GameFont.Small;
            string text6 = stringBuilder.ToString();
            if (Text.CalcHeight(text6, rect4.width) > rect4.height)
            {
                Text.Font = GameFont.Tiny;
            }
            Widgets.Label(rect4, text6);
            Text.Font = GameFont.Small;
            if (this.bill.recipe.products.Count == 1)
            {
                Widgets.InfoCardButton(rect4.x, rect3.y, this.bill.recipe.products[0].thingDef);
            }

            #endregion
        }
            public override void DoWindowContents(Rect inRect) // For a specific DSU
            {
//                var XXXcontentRect = new Rect(0, 0, inRect.width, inRect.height - (CloseButSize.y + 10f)).ContractedBy(10f);

                var l = new Listing_Standard();
//                l.Begin(new Rect(inRect.x, inRect.y, inRect.width, inRect.height-CloseButSize.y-5f));
                var s = new Rect(inRect.x, inRect.y, inRect.width, inRect.height - CloseButSize.y - 5f);
                var v = new Rect(inRect.x, inRect.y, inRect.width - 20f, inRect.height - CloseButSize.y - 5f);

                if (useCustomThingFilter)
                {
                    v.height += 300f;
                }
                l.BeginScrollView(s, ref DSUScrollPosition, ref v);
//                l.BeginScrollView(
//                l.BeginScrollView(Rect rect, ref Vector2 scrollPosition, ref Rect viewRect)
                l.Label(def.label);
                l.GapLine();
                // Much TODO, so wow:
                tmpLabel = l.TextEntryLabeled("LWMDSpDSUlabel".Translate(), tmpLabel);
                string tmpstring = null;

                //TODO: redo, include defaults:
                l.TextFieldNumericLabeled("LWM_DS_maxNumStacks".Translate().CapitalizeFirst() + " "
                                          + "LWM_DS_Default".Translate(tmpMaxNumStacks),
                                          ref tmpMaxNumStacks, ref tmpstring);
//                l.TextFieldNumericLabeled("Maximum Number of Stacks per Cell", ref tmpMaxNumStacks, ref tmpstring,0);
                tmpstring = null;
//                l.TextFieldNumericLabeled<float>("Maximum Total Mass per Cell", ref tmpMaxTotalMass, ref tmpstring,0f);
                l.TextFieldNumericLabeled("LWM_DS_maxTotalMass".Translate().CapitalizeFirst() + " " +
                                          "LWM_DS_Default".Translate(tmpMaxTotalMass),
                                          ref tmpMaxTotalMass, ref tmpstring);
                tmpstring = null;
//                l.TextFieldNumericLabeled<float>("Maximum Mass of any Stored Item", ref tmpMaxMassStoredItem, ref tmpstring,0f);
                l.TextFieldNumericLabeled("LWM_DS_maxMassOfStoredItem".Translate().CapitalizeFirst() + " " +
                                          "LWM_DS_Default".Translate(tmpMaxMassStoredItem),
                                          ref tmpMaxMassStoredItem, ref tmpstring);
                l.CheckboxLabeled("LWMDSpDSUshowContents".Translate(), ref tmpShowContents);
                l.GapLine();
                l.EnumRadioButton(ref tmpOverlayType, "LWMDSpDSUoverlay".Translate());
                l.GapLine();
                l.EnumRadioButton(ref tmpStoragePriority, "LWMDSpDSUstoragePriority".Translate());
                l.GapLine();
                l.CheckboxLabeled("LWMDSpDSUchangeFilterQ".Translate(), ref useCustomThingFilter,
                                  "LWMDSpDSUchangeFilterQDesc".Translate());
                if (useCustomThingFilter)
                {
                    if (customThingFilter == null)
                    {
                        customThingFilter = new ThingFilter();
                        customThingFilter.CopyAllowancesFrom(def.building.fixedStorageSettings.filter);
                        Utils.Mess(Utils.DBF.Settings, "Created new filter for " + def.defName + ": " + customThingFilter);
//                        Log.Error("Old filter has: "+def.building.fixedStorageSettings.filter.AllowedDefCount);
//                        Log.Warning("New filter has: "+customThingFilter.AllowedDefCount);
                    }

                    var r = l.GetRect(300);
                    r.width *= 2f / 3f;
                    r.x     += 10f;
                    ThingFilterUI.DoThingFilterConfigWindow(r, ref thingFilterScrollPosition, customThingFilter);
                }
                else
                {
                    // not using custom thing filter:
                    if (customThingFilter != null || defaultDSUValues.ContainsKey("DSU_" + def.defName + "_filter"))
                    {
                        customThingFilter = null;
                        if (defaultDSUValues.ContainsKey("DSU_" + def.defName + "_filter"))
                        {
                            Utils.Mess(Utils.DBF.Settings, "  Removing filter for " + def.defName);
                            def.building.fixedStorageSettings.filter = (ThingFilter)defaultDSUValues["DSU_" + def.defName + "_filter"];
                            defaultDSUValues.Remove("DSU_" + def.defName + "_filter");
                        }
                    }
                }

//                l.End();
                l.EndScrollView(ref v);

                // Cancel button
                var closeRect = new Rect(inRect.width - CloseButSize.x, inRect.height - CloseButSize.y, CloseButSize.x, CloseButSize.y);

                if (Widgets.ButtonText(closeRect, "CancelButton".Translate()))
                {
                    Utils.Mess(Utils.DBF.Settings, "Cancel button selected - no changes made");
                    Close();
                }

                // Accept button - with accompanying logic
                closeRect = new Rect(inRect.width - (2 * CloseButSize.x + 5f), inRect.height - CloseButSize.y, CloseButSize.x, CloseButSize.y);
                if (Widgets.ButtonText(closeRect, "AcceptButton".Translate()))
                {
                    GUI.FocusControl(null); // unfocus, so that a focused text field may commit its value
                    Utils.Warn(Utils.DBF.Settings, "\"Accept\" button selected: changing values for " + def.defName);
                    TestAndUpdate("label", tmpLabel, ref def.label);
                    TestAndUpdate("maxNumStacks", tmpMaxNumStacks, ref def.GetCompProperties <Properties>().maxNumberStacks);
                    TestAndUpdate("maxTotalMass", tmpMaxTotalMass, ref def.GetCompProperties <Properties>().maxTotalMass);
                    TestAndUpdate("maxMassStoredItem", tmpMaxMassStoredItem, ref def.GetCompProperties <Properties>().maxMassOfStoredItem);
                    TestAndUpdate("showContents", tmpShowContents, ref def.GetCompProperties <Properties>().showContents);
                    TestAndUpdate("overlayType", tmpOverlayType, ref def.GetCompProperties <Properties>().overlayType);
                    var tmpSP = def.building.defaultStorageSettings.Priority; // hard to access private field directly
                    TestAndUpdate("storagePriority", tmpStoragePriority, ref tmpSP);
                    def.building.defaultStorageSettings.Priority = tmpSP;
                    if (useCustomThingFilter)
                    {
                        if (!defaultDSUValues.ContainsKey("DSU_" + def.defName + "_filter"))
                        {
                            Utils.Mess(Utils.DBF.Settings, "Creating default filter record for item " + def.defName);
                            defaultDSUValues["DSU_" + def.defName + "_filter"] = def.building.fixedStorageSettings.filter;
                        }

                        def.building.fixedStorageSettings.filter = customThingFilter;
                    }
                    else
                    {
                        if (defaultDSUValues.ContainsKey("DSU_" + def.defName + "_filter"))
                        {
                            // we need to remove it
                            Utils.Mess(Utils.DBF.Settings, "Removing default filter record for item " + def.defName);
                            def.building.fixedStorageSettings.filter = (ThingFilter)defaultDSUValues["DSU_" + def.defName + "_filter"];
                            defaultDSUValues.Remove("DSU_" + def.defName + "_filter");
                        }
                    }

                    Close();
                }

                // Reset to Defaults
                closeRect = new Rect(inRect.width - (4 * CloseButSize.x + 10f), inRect.height - CloseButSize.y, 2 * CloseButSize.x, CloseButSize.y);
                if (!AreTempVarsDefaults() && Widgets.ButtonText(closeRect, "ResetBinding".Translate()))
                {
                    SetTempVarsToDefaults();
                }
                //ResetDSUToDefaults(def.defName);
                //SetTempVars();
            }
            public override void DoWindowContents(Rect inRect) // For a specific DSU
            {
//                var XXXcontentRect = new Rect(0, 0, inRect.width, inRect.height - (CloseButSize.y + 10f)).ContractedBy(10f);
                // for the record, Listing_Standards kind of suck. Convenient enough, but no flexibility
                // TODO when I'm bored: switch to manual, add red background for disabled units
                var l = new Listing_Standard();
//                l.Begin(new Rect(inRect.x, inRect.y, inRect.width, inRect.height-CloseButSize.y-5f));
                Rect s = new Rect(inRect.x, inRect.y, inRect.width, inRect.height - CloseButSize.y - 5f);
                Rect v = new Rect(inRect.x, inRect.y, inRect.width - 20f, inRect.height - CloseButSize.y - 5f);

                if (useCustomThingFilter)
                {
                    v.height += CustomThingFilterHeight;
                }
                l.BeginScrollView(s, ref DSUScrollPosition, ref v);
//                l.BeginScrollView(
//                l.BeginScrollView(Rect rect, ref Vector2 scrollPosition, ref Rect viewRect)
                l.Label(def.label);
                l.GapLine();
                // Much TODO, so wow:
                tmpLabel = l.TextEntryLabeled("LWMDSpDSUlabel".Translate(), tmpLabel);
                string tmpstring = null;

                l.TextFieldNumericLabeled("LWM_DS_maxNumStacks".Translate().CapitalizeFirst() + " "
                                          + "LWM_DS_Default".Translate(tracker.GetDefaultValue(def.defName, "maxNumStacks",
                                                                                               tmpMaxNumStacks)),
                                          ref tmpMaxNumStacks, ref tmpstring, 0);
                tmpstring = null;
                l.TextFieldNumericLabeled <float>("LWM_DS_maxTotalMass".Translate().CapitalizeFirst() + " " +
                                                  "LWM_DS_Default".Translate(tracker.GetDefaultValue(def.defName,
                                                                                                     "maxTotalMass", tmpMaxTotalMass).ToString()),
                                                  ref tmpMaxTotalMass, ref tmpstring, 0f);
                tmpstring = null;
                l.TextFieldNumericLabeled <float>("LWM_DS_maxMassOfStoredItem".Translate().CapitalizeFirst() + " " +
                                                  "LWM_DS_Default".Translate(tracker.GetDefaultValue(def.defName,
                                                                                                     "maxMassStoredItem", tmpMaxMassStoredItem).ToString()),
                                                  ref tmpMaxMassStoredItem, ref tmpstring, 0f);
                l.CheckboxLabeled("LWMDSpDSUshowContents".Translate(), ref tmpShowContents);
                l.GapLine();
                l.EnumRadioButton(ref tmpOverlayType, "LWMDSpDSUoverlay".Translate());
                l.GapLine();
                l.EnumRadioButton(ref tmpStoragePriority, "LWMDSpDSUstoragePriority".Translate());
                l.GapLine();
                l.CheckboxLabeled("LWMDSpDSUchangeFilterQ".Translate(), ref useCustomThingFilter,
                                  "LWMDSpDSUchangeFilterQDesc".Translate());
                if (useCustomThingFilter)
                {
                    if (customThingFilter == null)
                    {
                        customThingFilter = new ThingFilter();
                        customThingFilter.CopyAllowancesFrom(def.building.fixedStorageSettings.filter);
                        Utils.Mess(Utils.DBF.Settings, "Created new filter for " + def.defName + ": " + customThingFilter);
//                        Log.Error("Old filter has: "+def.building.fixedStorageSettings.filter.AllowedDefCount);
//                        Log.Warning("New filter has: "+customThingFilter.AllowedDefCount);
                    }
                    Rect r = l.GetRect(CustomThingFilterHeight);
                    r.width *= 2f / 3f;
                    r.x     += 10f;
                    ThingFilterUI.DoThingFilterConfigWindow(r, ref thingFilterScrollPosition, customThingFilter);
                }
                else     // not using custom thing filter:
                {
                    if (customThingFilter != null || tracker.HasDefaultValueFor(this.def.defName, "filter"))
                    {
                        customThingFilter = null;
                        if (tracker.HasDefaultValueFor(this.def.defName, "filter"))
                        {
                            Utils.Mess(Utils.DBF.Settings, "  Removing filter for " + def.defName);
                            def.building.fixedStorageSettings.filter = (ThingFilter)tracker
                                                                       .GetDefaultValue <ThingFilter>(def.defName, "filter", null);
                            tracker.Remove(def.defName, "filter");
                        }
                    }
                }

/*                if (l.ButtonDebug("Show default values for "+this.def)) {
 *                  foreach (var kv in defaultDSUValues) {
 *
 *                  }
 *              }
 */
//                l.End();
                l.EndScrollView(ref v);

                // Cancel button
                var closeRect = new Rect(inRect.width - CloseButSize.x, inRect.height - CloseButSize.y, CloseButSize.x, CloseButSize.y);

                if (Widgets.ButtonText(closeRect, "CancelButton".Translate()))
                {
                    Utils.Mess(Utils.DBF.Settings, "Cancel button selected - no changes made");
                    Close();
                }
                // Accept button - with accompanying logic
                closeRect = new Rect(inRect.width - (2 * CloseButSize.x + 5f), inRect.height - CloseButSize.y, CloseButSize.x, CloseButSize.y);
                if (Widgets.ButtonText(closeRect, "AcceptButton".Translate()))
                {
                    LWM.DeepStorage.Properties props = def.GetCompProperties <Properties>();
                    GUI.FocusControl(null); // unfocus, so that a focused text field may commit its value
                    Utils.Warn(Utils.DBF.Settings, "\"Accept\" button selected: changing values for " + def.defName);
                    tracker.UpdateToNewValue(def.defName, "label", tmpLabel, ref def.label);
                    tracker.UpdateToNewValue(def.defName,
                                             "maxNumStacks", tmpMaxNumStacks, ref props.maxNumberStacks);
                    tracker.UpdateToNewValue(def.defName,
                                             "maxTotalMass", tmpMaxTotalMass, ref props.maxTotalMass);
                    tracker.UpdateToNewValue(def.defName,
                                             "maxMassStoredItem", tmpMaxMassStoredItem, ref props.maxMassOfStoredItem);
                    tracker.UpdateToNewValue(def.defName,
                                             "showContents", tmpShowContents, ref props.showContents);
                    tracker.UpdateToNewValue(def.defName,
                                             "overlayType", tmpOverlayType, ref props.overlayType);
                    StoragePriority tmpSP = def.building.defaultStorageSettings.Priority; // hard to access private field directly
                    tracker.UpdateToNewValue(def.defName, "storagePriority", tmpStoragePriority, ref tmpSP);
                    def.building.defaultStorageSettings.Priority = tmpSP;
                    if (useCustomThingFilter)   // danger ahead - automatically use it, even if stupidly set up
                    {
                        if (!tracker.HasDefaultValueFor(def.defName, "filter"))
                        {
                            Utils.Mess(Utils.DBF.Settings, "Creating default filter record for item " + def.defName);
                            tracker.AddDefaultValue(def.defName, "filter", def.building.fixedStorageSettings.filter);
                        }
                        def.building.fixedStorageSettings.filter = customThingFilter;
                    }
                    else
                    {
                        // restore default filter:
                        if (tracker.HasDefaultValueFor(def.defName, "filter"))
                        {
                            // we need to remove it
                            Utils.Mess(Utils.DBF.Settings, "Removing default filter record for item " + def.defName);
                            def.building.fixedStorageSettings.filter = (ThingFilter)tracker
                                                                       .GetDefaultValue <ThingFilter>(def.defName, "filter", null);
                            tracker.Remove(def.defName, "filter");
                        }
                    }
                    Close();
                }
                // Reset to Defaults
                closeRect = new Rect(inRect.width - (4 * CloseButSize.x + 10f), inRect.height - CloseButSize.y, 2 * CloseButSize.x, CloseButSize.y);
                if (!AreTempVarsDefaults() && Widgets.ButtonText(closeRect, "ResetBinding".Translate()))
                {
                    SetTempVarsToDefaults();
                }
            }