public Bill(RecipeDef recipe) { this.recipe = recipe; ingredientFilter = new ThingFilter(); ingredientFilter.CopyAllowancesFrom(recipe.defaultIngredientFilter); InitializeAfterClone(); }
/// <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 }); }
public void GenerateStrangeMeatRecipe() { if (LoadedModManager.RunningMods.Any(x => x.Name.Contains("Cosmic Horrors")) && !AreRecipesReady) { //Not really, but hey, let's get started. AreRecipesReady = true; //We want to use strange meat to make wax. RecipeDef recipeMakeWax = DefDatabase <RecipeDef> .AllDefs.FirstOrDefault((RecipeDef d) => d.defName == "Jecrell_MakeWax"); if (recipeMakeWax != null) { ThingFilter newFilter = new ThingFilter(); newFilter.CopyAllowancesFrom(recipeMakeWax.fixedIngredientFilter); newFilter.SetAllow(ThingCategoryDef.Named("ROM_StrangeMeatRaw"), true); recipeMakeWax.fixedIngredientFilter = newFilter; ThingFilter newFilter2 = new ThingFilter(); newFilter2.CopyAllowancesFrom(recipeMakeWax.defaultIngredientFilter); newFilter2.SetAllow(ThingCategoryDef.Named("ROM_StrangeMeatRaw"), true); recipeMakeWax.defaultIngredientFilter = newFilter; foreach (IngredientCount temp in recipeMakeWax.ingredients) { if (temp.filter != null) { ThingFilter newFilter3 = new ThingFilter(); newFilter3.CopyAllowancesFrom(temp.filter); newFilter3.SetAllow(ThingCategoryDef.Named("ROM_StrangeMeatRaw"), true); temp.filter = newFilter3; Log.Message("Added new filter"); } } Log.Message("Strange meat added to wax recipes."); } //I want stoves to be able to cook strange meals too. ThingDef stoveDef = DefDatabase <ThingDef> .AllDefs.FirstOrDefault((ThingDef def) => def.defName == "WoodStoveFurnace"); if (stoveDef != null) { if (stoveDef.recipes.FirstOrDefault((RecipeDef def) => def.defName == "ROM_CookStrangeMealSimple") == null) { stoveDef.recipes.Add(DefDatabase <RecipeDef> .GetNamed("ROM_CookStrangeMealSimple")); } if (stoveDef.recipes.FirstOrDefault((RecipeDef def) => def.defName == "ROM_CookStrangeMealFine") == null) { stoveDef.recipes.Add(DefDatabase <RecipeDef> .GetNamed("ROM_CookStrangeMealFine")); } if (stoveDef.recipes.FirstOrDefault((RecipeDef def) => def.defName == "ROM_CookStrangeMealLavish") == null) { stoveDef.recipes.Add(DefDatabase <RecipeDef> .GetNamed("ROM_CookStrangeMealLavish")); } Log.Message("Strange meal recipes added to WoodStoveFurnace defs"); } } return; }
public Dialog_ThingFilter(ExtendedBillData e, Window w) { reOpenWindow = w; extendedBill = e; filter = new ThingFilter(); if (extendedBill.ProductAdditionalFilter != null) { filter.CopyAllowancesFrom(extendedBill.ProductAdditionalFilter); } }
public void CloneFrom(ExtendedBillData other) { OutputFilter.CopyAllowancesFrom(other.OutputFilter); AllowDeadmansApparel = other.AllowDeadmansApparel; CountWornApparel = other.CountWornApparel; UseInputFilter = other.UseInputFilter; Worker = other.Worker; Name = other.Name; _countingStockpile = other._countingStockpile; _takeToStockpile = other._takeToStockpile; }
public void AddFilter(StorageSettings settings, ThingFilter filter = null) { if (filter == null) { filter = GetLowestFilter(settings); } ThingFilter newFilter = new ThingFilter(SettingsChangedAction(settings)); newFilter.CopyAllowancesFrom(filter); GetRanks(settings).Add(newFilter); }
public ThingOrderRequest(ThingOrderRequest other) { customLabel = other.customLabel; thing = other.thing; amount = other.amount; if (other.HasThingFilter) { ThingFilter filter = new ThingFilter(); filter.CopyAllowancesFrom(other.thingFilter); thingFilter = filter; } Initialize(); }
public static void FillOrderProcessorFromVatGrowerRecipe(ThingOrderProcessor orderProcessor, GrowerRecipeDef recipeDef) { foreach (IngredientCount ingredientCount in recipeDef.ingredients) { ThingFilter filterCopy = new ThingFilter(); filterCopy.CopyAllowancesFrom(ingredientCount.filter); ThingOrderRequest copy = new ThingOrderRequest(filterCopy); copy.amount = (int)(ingredientCount.GetBaseCount() * QEESettings.instance.organTotalResourcesFloat); orderProcessor.desiredIngredients.Add(copy); } }
public void CloneFrom(ExtendedBillData other, bool cloneName) { CountAway = other.CountAway; ProductAdditionalFilter = new ThingFilter(); if (other.ProductAdditionalFilter != null) { ProductAdditionalFilter.CopyAllowancesFrom(other.ProductAdditionalFilter); } if (cloneName) { Name = other.Name; } }
public void UpdateDesiredRequests() { desiredRequests.Clear(); List <Bill> bills = new List <Bill>(); if (_activeBill != null) { bills.Add(_activeBill); } else { bills = (observedThingHolder as IBillGiver)?.BillStack.Bills; } for (int i = 0; i < bills.Count; i++) { Bill_Production theBill = bills[i] as Bill_Production; if (theBill?.recipe?.ingredients == null) { continue; } foreach (IngredientCount curIng in theBill.recipe.ingredients) { ThingFilter filterCopy = new ThingFilter(); filterCopy.CopyAllowancesFrom(curIng.filter); ThingOrderRequest request = new ThingOrderRequest(filterCopy); int storedCount = request.TotalStackCountForOrderRequestInContainer(ObservedThingOwner); int countNeededFromRecipe = (int)(curIng.CountRequiredOfFor(curIng.FixedIngredient, theBill.recipe) * QEESettings.instance.organTotalResourcesFloat); int countNeededForCrafting = countNeededFromRecipe - storedCount; countNeededForCrafting = countNeededForCrafting < 0 ? 0 : countNeededForCrafting; if (countNeededForCrafting > 0) { //QEEMod.TryLog("Adding " + curIng.FixedIngredient.label + " amount: " + countNeededForCrafting); request.amount = countNeededForCrafting; desiredRequests[curIng.FixedIngredient.defName] = request; } } //end foreach loop } //end for loop } //end UpdateDesiredRequests
public override void Initialize(CompProperties props) { filter = new ThingFilter(new Action(this.FilterChanged)); var fuels = parent.GetComp <CompRefuelable>()?.Props.fuelFilter; if (fuels != null) { filter.CopyAllowancesFrom(fuels); } else { Log.Warning("LWM.FuelFilter: Could not find any allowed fuels for " + parent + "; this is probably a mistake on someone's part (maybe not mine)"); } }
public void UpdateDesiredRequests() { desiredRequests.Clear(); List <Bill> bills = new List <Bill>(); if (_activeBill != null) { bills.Add(_activeBill); } else { bills = (observedThingHolder as IBillGiver)?.BillStack.Bills; } for (int i = 0; i < bills.Count; i++) { Bill_Production theBill = bills[i] as Bill_Production; if (theBill?.recipe?.ingredients == null) { continue; } foreach (IngredientCount curIng in theBill.recipe.ingredients) { ThingFilter filterCopy = new ThingFilter(); filterCopy.CopyAllowancesFrom(curIng.filter); ThingOrderRequest request = new ThingOrderRequest(filterCopy); int countNeededForCrafting = IngredientUtility.RemainingCountForIngredient(ObservedThingOwner, theBill.recipe, curIng); if (countNeededForCrafting > 0) { //QEEMod.TryLog("Adding " + curIng.FixedIngredient.label + " amount: " + countNeededForCrafting); request.amount = countNeededForCrafting; desiredRequests[curIng.FixedIngredient.defName] = request; } } //end foreach loop } //end for loop } //end UpdateDesiredRequests
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 void CopyFilter(ThingFilter filter, ThingFilter parent) { _copiedFilter = new ThingFilter(); _copiedFilter.CopyAllowancesFrom(filter); _copiedFiltersParent = parent; }
public void PasteCopiedFilterInto(ThingFilter other) { other.CopyAllowancesFrom(_copiedFilter); }
public void CopyFrom(StorageSettings other) { Priority = other.Priority; filter.CopyAllowancesFrom(other.filter); TryNotifyChanged(); }
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(); } }
private void InitCategoryFilter() { CategoryFilter = new ThingFilter(CallbackAction); CategoryFilter.CopyAllowancesFrom(CategoryFilterGlobal); }
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(); } }