public static void Postfix(ref Rect rect) { ITab_Storage tab = ITab_StorageFillTabsPatcher.currentTab; if (tab == null) { return; } IStoreSettingsParent storeSettingsParent = (IStoreSettingsParent)typeof(ITab_Storage).GetProperty("SelStoreSettingsParent", BindingFlags.NonPublic | BindingFlags.Instance).GetGetMethod(true).Invoke(tab, new object[0]); StorageSettings settings = storeSettingsParent.GetStoreSettings(); int limit = Limits.GetLimit(settings); bool hasLimit = limit != -1; Widgets.CheckboxLabeled(new Rect(rect.xMin, rect.yMin - 24f - 3f - 32f, rect.width / 2, 24f), "Total stack limit", ref hasLimit); if (hasLimit) { if (oldSettings != settings) { buffer = limit.ToString(); } Widgets.TextFieldNumeric <int>(new Rect(rect.xMin + (rect.width / 2) + 60f, rect.yMin - 24f - 3f - 32f, rect.width / 2 - 60f, 24f), ref limit, ref buffer, 0, max); } Limits.SetLimit(settings, hasLimit ? limit : -1); oldSettings = settings; }
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(); }
protected IStoreSettingsParent GetThingOrThingCompStoreSettingsParent(Thing t) { IStoreSettingsParent storeSettingsParent = t as IStoreSettingsParent; IStoreSettingsParent result; if (storeSettingsParent != null) { result = storeSettingsParent; } else { ThingWithComps thingWithComps = t as ThingWithComps; if (thingWithComps != null) { List <ThingComp> allComps = thingWithComps.AllComps; for (int i = 0; i < allComps.Count; i++) { storeSettingsParent = (allComps[i] as IStoreSettingsParent); if (storeSettingsParent != null) { return(storeSettingsParent); } } } result = null; } return(result); }
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(); }
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 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(); }
public static void Before_ITab_Storage_FillTab(ITab_Storage __instance) { if (ReferenceEquals(__instance.GetType().Assembly, typeof(ITab_Storage).Assembly)) { // only show hysteresis option for non derived (non-custom) storage(s) HaulingHysteresis_InjectControls.showHysteresisCount++; IStoreSettingsParent selStoreSettingsParent = GetSelStoreSettingsParent(__instance); HaulingHysteresis_InjectControls.SettingsQueue.Enqueue(selStoreSettingsParent.GetStoreSettings()); } }
public StorageSettings(IStoreSettingsParent owner) : this() { this.owner = owner; if (owner != null) { StorageSettings parentStoreSettings = owner.GetParentStoreSettings(); if (parentStoreSettings != null) { this.priorityInt = parentStoreSettings.priorityInt; } } }
public static bool prefix(StoragePriority value, IStoreSettingsParent ___owner) { if (use_native) { return(true); } else { set_storage_priority(___owner, value); return(false); } }
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(); }
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(); }
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(); }
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(); }
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 static void StorageSettings(StorageSettings __instance, IStoreSettingsParent owner) { __instance.filter = new MarketValueFilter(__instance.filter); }
protected override void FillTab() { IStoreSettingsParent selStoreSettingsParent = this.SelStoreSettingsParent; Comp_PawnMenu comp = selStoreSettingsParent as Comp_PawnMenu; comp.syncForAndWhen(comp.kind, comp.supper); Rect rect = new Rect(8f, 0f, 300f, 30f); rect = rect.ContractedBy(2f); GUI.BeginGroup(rect); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.LowerLeft; string labelKind = "Kind"; string labelSelf = "Self"; string labelNormal = "Breakfast"; string labelSupper = "Supper"; string buttonLabel; if (comp.kind) { buttonLabel = labelKind; } else { buttonLabel = labelSelf; } rect = new Rect(0f, 0f, 30f, 30f); Widgets.Label(rect, "For:"); rect = new Rect(30f, 0f, 60f, 30f); if (Widgets.ButtonText(rect, buttonLabel, true, false, true)) { List <FloatMenuOption> list = new List <FloatMenuOption>(); list.Add(new FloatMenuOption(labelKind, delegate { comp.kind = true; comp.syncForAndWhen(comp.kind, comp.supper); })); list.Add(new FloatMenuOption(labelSelf, delegate { comp.kind = false; comp.syncForAndWhen(comp.kind, comp.supper); })); Find.WindowStack.Add(new FloatMenu(list)); } UIHighlighter.HighlightOpportunity(rect, buttonLabel); rect = new Rect(100f, 0f, 45f, 30f); Widgets.Label(rect, "When:"); rect = new Rect(145f, 0f, 100f, 30f); if (comp.supper) { buttonLabel = labelSupper; } else { buttonLabel = labelNormal; } if (Widgets.ButtonText(rect, buttonLabel, true, false, true)) { List <FloatMenuOption> list = new List <FloatMenuOption>(); list.Add(new FloatMenuOption(labelSupper, delegate { comp.supper = true; comp.syncForAndWhen(comp.kind, comp.supper); })); list.Add(new FloatMenuOption(labelNormal, delegate { comp.supper = false; comp.syncForAndWhen(comp.kind, comp.supper); })); Find.WindowStack.Add(new FloatMenu(list)); } UIHighlighter.HighlightOpportunity(rect, buttonLabel); GUI.EndGroup(); base.FillTab(); }
protected override void FillTab() { IStoreSettingsParent storeSettingsParent = SelStoreSettingsParent; StorageSettings settings = storeSettingsParent.GetStoreSettings(); Vector2 winSize = WinSize; float x = winSize.x; Vector2 winSize2 = WinSize; Rect position = new Rect(0f, 0f, x, winSize2.y).ContractedBy(10f); GUI.BeginGroup(position); if (IsPrioritySettingVisible) { Text.Font = GameFont.Small; Rect rect = new Rect(0f, 0f, 160f, TopAreaHeight - 6f); if (Widgets.ButtonText(rect, "Priority".Translate() + ": " + settings.Priority.Label().CapitalizeFirst())) { 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; })); } } } 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 (storeSettingsParent.GetParentStoreSettings() != null) { parentFilter = storeSettingsParent.GetParentStoreSettings().filter; } Rect rect2 = new Rect(0f, TopAreaHeight, position.width, position.height - 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(); ThingFilterUI.DoThingFilterConfigWindow(rect2, ref scrollPosition, settings.filter, parentFilter, 8); 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(); 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, historical: false); } PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.StorageTab, KnowledgeAmount.FrameDisplayed); GUI.EndGroup(); }
//When loading public LazySettings(IStoreSettingsParent owner) : base(owner) { }