protected override void FillTab()
        {
            ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.StorageTab, KnowledgeAmount.GuiFrame);
            ConceptDecider.TeachOpportunity(ConceptDefOf.StorageTabCategories, OpportunityType.GuiFrame);
            ConceptDecider.TeachOpportunity(ConceptDefOf.StoragePriority, OpportunityType.GuiFrame);
            IStoreSettingsParent selStoreSettingsParent = this.SelStoreSettingsParent;
            StorageSettings      settings = selStoreSettingsParent.GetStoreSettings();
            Rect position = new Rect(0f, 0f, ITab_Storage_Enhanced.WinSize.x, ITab_Storage_Enhanced.WinSize.y).ContractedBy(10f);

            GUI.BeginGroup(position);
            Text.Font = GameFont.Small;
            Rect rect = new Rect(0f, 0f, 160f, 29f);

            if (Widgets.TextButton(rect, "Priority".Translate() + ": " + settings.Priority.Label(), true, false))
            {
                List <FloatMenuOption> list       = new List <FloatMenuOption>();
                IEnumerator            enumerator = Enum.GetValues(typeof(StoragePriority)).GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        StoragePriority storagePriority = (StoragePriority)((byte)enumerator.Current);
                        if (storagePriority != StoragePriority.Unstored)
                        {
                            StoragePriority localPr = storagePriority;
                            list.Add(new FloatMenuOption(localPr.Label(), delegate
                            {
                                settings.Priority = localPr;
                                ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.StoragePriority, KnowledgeAmount.Total);
                            }, MenuOptionPriority.Medium, null, null));
                        }
                    }
                }
                finally
                {
                    IDisposable disposable = enumerator as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
                Find.WindowStack.Add(new FloatMenu(list, false));
            }

            var clearSearchRect   = new Rect(position.width - 33f, (29f - 14f) / 2f, 14f, 14f);
            var shouldClearSearch = (Widgets.ImageButton(clearSearchRect, Widgets.CheckboxOffTex));

            var searchRect = new Rect(165f, 0f, position.width - 160f - 20f, 29f);
            var watermark  = (searchText != string.Empty || isFocused) ? searchText : "Search";

            var escPressed     = (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape);
            var clickedOutside = (!Mouse.IsOver(searchRect) && Event.current.type == EventType.MouseDown);

            if (!isFocused)
            {
                GUI.color = new Color(1f, 1f, 1f, 0.6f);
            }

            GUI.SetNextControlName("StorageSearchInput");
            var searchInput = Widgets.TextField(searchRect, watermark);

            GUI.color = Color.white;

            if (isFocused)
            {
                searchText = searchInput;
            }

            if ((GUI.GetNameOfFocusedControl() == "StorageSearchInput" || isFocused) && (escPressed || clickedOutside))
            {
                GUIUtility.keyboardControl = 0;
                isFocused = false;
            }
            else if (GUI.GetNameOfFocusedControl() == "StorageSearchInput" && !isFocused)
            {
                isFocused = true;
            }

            if (shouldClearSearch)
            {
                searchText = string.Empty;
            }

            TutorUIHighlighter.HighlightOpportunity("StoragePriority", rect);
            ThingFilter parentFilter = null;

            if (selStoreSettingsParent.GetParentStoreSettings() != null)
            {
                parentFilter = selStoreSettingsParent.GetParentStoreSettings().filter;
            }

            Rect rect2 = new Rect(0f, 35f, position.width, position.height - 35f);

            HelperThingFilterUI.DoThingFilterConfigWindow(rect2, ref this.scrollPosition, settings.filter, parentFilter, 8, searchText);
            GUI.EndGroup();
        }
Esempio n. 2
0
        public static void FillTab(ITab_Storage tab)
        {
            IStoreSettingsParent storeSettingsParent = (IStoreSettingsParent)ITab_Storage_Detour.SelStoreSettingsParent.GetValue(tab, null);

            Debug.Log(storeSettingsParent);
            StorageSettings settings = storeSettingsParent.GetStoreSettings();
            Rect            position = new Rect(0f, 0f, ITab_Storage_Detour.WinSize.x, ITab_Storage_Detour.WinSize.y).ContractedBy(10f);

            GUI.BeginGroup(position);
            Text.Font = GameFont.Small;
            Rect rect = new Rect(0f, 0f, 160f, 29f);

            if (Widgets.ButtonText(rect, "Priority".Translate() + ": " + settings.Priority.Label(), true, false, true))
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                foreach (object current in Enum.GetValues(typeof(StoragePriority)))
                {
                    if ((StoragePriority)current > StoragePriority.Unstored)
                    {
                        StoragePriority localPr = (StoragePriority)current;
                        list.Add(new FloatMenuOption(localPr.Label().CapitalizeFirst(), delegate
                        {
                            settings.Priority = localPr;
                        }, MenuOptionPriority.Default, null, null, 0f, null, null));
                    }
                }
                Find.WindowStack.Add(new FloatMenu(list));
            }
            bool   arg_2B9_0 = Widgets.ButtonImage(new Rect(position.width - 33f, 7.5f, 14f, 14f), Widgets.CheckboxOffTex);
            Rect   arg_204_0 = new Rect(165f, 0f, position.width - 160f - 20f, 29f);
            string text      = (ITab_Storage_Detour.searchText != string.Empty || ITab_Storage_Detour.isFocused) ? ITab_Storage_Detour.searchText : "SearchLabel".Translate();
            bool   flag      = Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape;
            bool   flag2     = !Mouse.IsOver(arg_204_0) && Event.current.type == EventType.MouseDown;

            if (!ITab_Storage_Detour.isFocused)
            {
                GUI.color = new Color(1f, 1f, 1f, 0.6f);
            }
            GUI.SetNextControlName("StorageSearchInput");
            string text2 = Widgets.TextField(arg_204_0, text);

            GUI.color = Color.white;
            if (ITab_Storage_Detour.isFocused)
            {
                ITab_Storage_Detour.searchText = text2;
            }
            if ((GUI.GetNameOfFocusedControl() == "StorageSearchInput" || ITab_Storage_Detour.isFocused) && (flag | flag2))
            {
                GUIUtility.keyboardControl    = 0;
                ITab_Storage_Detour.isFocused = false;
            }
            else if (GUI.GetNameOfFocusedControl() == "StorageSearchInput" && !ITab_Storage_Detour.isFocused)
            {
                ITab_Storage_Detour.isFocused = true;
            }
            if (arg_2B9_0)
            {
                ITab_Storage_Detour.searchText = string.Empty;
            }
            UIHighlighter.HighlightOpportunity(rect, "StoragePriority");
            ThingFilter parentFilter = null;

            if (storeSettingsParent.GetParentStoreSettings() != null)
            {
                parentFilter = storeSettingsParent.GetParentStoreSettings().filter;
            }
            Rect    arg_334_0 = new Rect(0f, 35f, position.width, position.height - 70f);
            Vector2 vector    = (Vector2)ITab_Storage_Detour.ScrollPosition.GetValue(tab);

            HelperThingFilterUI.DoThingFilterConfigWindow(arg_334_0, ref vector, settings.filter, parentFilter, 8, null, null, ITab_Storage_Detour.searchText);
            ITab_Storage_Detour.ScrollPosition.SetValue(tab, vector);
            Rect rect2 = new Rect(0f, position.height - 30f, position.width, 30f);
            StorageSettings_Hysteresis storageSettings_Hysteresis = StorageSettings_Mapping.Get(settings);

            if (storageSettings_Hysteresis == null)
            {
                storageSettings_Hysteresis = new StorageSettings_Hysteresis();
            }
            storageSettings_Hysteresis.FillPercent = Widgets.HorizontalSlider(rect2.LeftPart(0.8f), storageSettings_Hysteresis.FillPercent, 0f, 100f, false, "Refill cells less then", null, null, -1f);
            Widgets.Label(rect2.RightPart(0.2f), storageSettings_Hysteresis.FillPercent.ToString("N0") + "%");
            StorageSettings_Mapping.Set(settings, storageSettings_Hysteresis);
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.StorageTab, KnowledgeAmount.FrameDisplayed);
            GUI.EndGroup();
        }
Esempio n. 3
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 arg_10C_0 = new Rect(num, 0f, 150f, 35f);

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

            num += 150f;
            if (Widgets.ButtonText(arg_15A_0, "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, MessageSound.RejectInput);
                            return;
                        }
                        if (localOut == this.SelectedOutfit)
                        {
                            this.SelectedOutfit = null;
                        }
                    }, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
                Find.WindowStack.Add(new FloatMenu(list2));
            }
            Rect rect2 = 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(rect2, "NoOutfitSelected".Translate());
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
                return;
            }
            GUI.BeginGroup(rect2);
            Rect rect3 = new Rect(0f, 0f, 180f, 30f);

            Dialog_ManageOutfitsStorageSearch.DoNameInputRect(rect3, ref this.SelectedOutfit.label, 30);
            bool   arg_403_0 = Widgets.ButtonImage(new Rect(rect2.width - 20f, 7.5f, 14f, 14f), Widgets.CheckboxOffTex);
            Rect   arg_347_0 = new Rect(rect3.width + 10f, 0f, rect2.width - rect3.width - 10f, 29f);
            string text      = (this.searchText != string.Empty || this.isFocused) ? this.searchText : "Search";
            bool   flag      = Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape;
            bool   flag2     = !Mouse.IsOver(arg_347_0) && Event.current.type == EventType.MouseDown;

            if (!this.isFocused)
            {
                GUI.color = new Color(1f, 1f, 1f, 0.6f);
            }
            GUI.SetNextControlName("StorageSearchInput");
            string text2 = Widgets.TextField(arg_347_0, text);

            GUI.color = Color.white;
            if (this.isFocused)
            {
                this.searchText = text2;
            }
            if ((GUI.GetNameOfFocusedControl() == "StorageSearchInput" || this.isFocused) && (flag | flag2))
            {
                GUIUtility.keyboardControl = 0;
                this.isFocused             = false;
            }
            else if (GUI.GetNameOfFocusedControl() == "StorageSearchInput" && !this.isFocused)
            {
                this.isFocused = true;
            }
            if (arg_403_0)
            {
                this.searchText = string.Empty;
            }
            UIHighlighter.HighlightOpportunity(rect, "StoragePriority");
            Rect arg_488_0 = new Rect(0f, 40f, rect2.width, rect2.height - 45f - 10f);

            if (Dialog_ManageOutfitsStorageSearch._apparelGlobalFilter == null)
            {
                Dialog_ManageOutfitsStorageSearch._apparelGlobalFilter = new ThingFilter();
                Dialog_ManageOutfitsStorageSearch._apparelGlobalFilter.SetAllow(ThingCategoryDefOf.Apparel, true);
            }
            ThingFilter apparelGlobalFilter = Dialog_ManageOutfitsStorageSearch._apparelGlobalFilter;

            HelperThingFilterUI.DoThingFilterConfigWindow(arg_488_0, ref this._scrollPosition, this.SelectedOutfit.filter, apparelGlobalFilter, 8, null, null, this.searchText);
            GUI.EndGroup();
            rect2 = new Rect(300f, 40f, inRect.width - 300f, inRect.height - 40f - this.CloseButSize.y).ContractedBy(10f);
            GUI.BeginGroup(rect2);
            new Rect(0f, 40f, rect2.width, rect2.height - 45f - 10f);
            GUI.EndGroup();
        }