private static void ValidateExpandedEvents() { var wereChanges = false; // TODO: Check to see if this fixes the issue described below. Store_IncidentEditor.LoadCopies(); // We're not going to update this to use EventExtension // since it appears to wipe previous settings. foreach (StoreIncident incident in DefDatabase <StoreIncident> .AllDefs.Where( i => i.defName == "BuyPawn" || i.defName == "AddTrait" || i.defName == "RemoveTrait" )) { if (incident.cost <= 1) { continue; } incident.cost = 1; wereChanges = true; } if (wereChanges) { Store_IncidentEditor.UpdatePriceSheet(); } }
private static void ValidateEventList() { Store_IncidentEditor.LoadCopies(); // Just to ensure the actual incidents are loaded. Events = DefDatabase <StoreIncident> .AllDefs.Select(i => new EventItem { Incident = i }).ToList(); }
/// <inheritdoc cref="Window.PreClose"/> public override void PreClose() { base.PreClose(); Store_ItemEditor.UpdateStoreItemList(); Store_IncidentEditor.UpdatePriceSheet(); Toolkit.Mod.WriteSettings(); Task.Run( async() => { switch (TkSettings.DumpStyle) { case "SingleFile": await Data.SaveLegacyShopAsync(Paths.LegacyShopDumpFilePath); return; case "MultiFile": await Data.SaveTraitsAsync(Paths.TraitFilePath); await Data.SavePawnKindsAsync(Paths.PawnKindFilePath); return; } await Data.SaveItemDataAsync(Paths.ItemDataFilePath); await Data.SaveEventDataAsync(Paths.EventDataFilePath); } ) .ConfigureAwait(false); }
public override void DoWindowContents(Rect inRect) { if (searchQuery != lastSearch) { UpdateList(); } Rect rect = new Rect(0f, 0f, inRect.width, 60f); Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect, "Store Incidents"); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; Rect search = new Rect(inRect.width / 5, rect.height, inRect.width / 2, 26f); searchQuery = Widgets.TextEntryLabeled(search, "Search:", searchQuery); Rect resetButton = new Rect(search.x, search.y + 28f, search.width, 26f); if (Widgets.ButtonText(resetButton, "Reset all Incidents")) { Store_IncidentEditor.LoadBackups(); } inRect.yMin += 120f; Widgets.DrawMenuSection(inRect); //TabDrawer.DrawTabs(inRect, this.tabs, 2); inRect = inRect.ContractedBy(17f); GUI.BeginGroup(inRect); Rect rect2 = inRect.AtZero(); this.DoBottomButtons(rect2); Rect outRect = rect2; outRect.yMax -= 65f; if (storeIncidents.Count > 0) { float height = (float)storeIncidents.Count * 24f; float num = 0f; Rect viewRect = new Rect(0f, 0f, outRect.width - 16f, height); Widgets.BeginScrollView(outRect, ref this.scrollPosition, viewRect, true); float num2 = this.scrollPosition.y - 24f; float num3 = this.scrollPosition.y + outRect.height; for (int i = 0; i < storeIncidents.Count; i++) { if (num > num2 && num < num3) { Rect rect3 = new Rect(0f, num, viewRect.width, 24f); this.DoRow(rect3, storeIncidents[i], i); } num += 24f; } Widgets.EndScrollView(); } else { Widgets.NoneLabel(0f, outRect.width, null); } GUI.EndGroup(); }
public void MakeSureSaveExists(bool forceSave = true) { checkedForBackup = true; haveBackup = Store_IncidentEditor.CopyExists(storeIncident); if (!haveBackup || forceSave) { Store_IncidentEditor.SaveCopy(storeIncident); } }
public void MakeSureSaveExists(bool forceSave = true) { checkedForBackup = true; Log.Warning("Checking if save exists"); if (storeIncident == null) { Log.Error("incident is null"); } haveBackup = Store_IncidentEditor.CopyExists(storeIncident); if (!haveBackup || forceSave) { Store_IncidentEditor.SaveCopy(storeIncident); } }
private void DrawButtonHeader(Rect inRect) { var buttonRect = new Rect(inRect.width - _headerButtonWidth, 0, _headerButtonWidth, Text.LineHeight); GUI.BeginGroup(inRect); if (storeIncident.cost > 0) { if (Widgets.ButtonText(buttonRect, _disableText)) { storeIncident.cost = -10; } buttonRect = buttonRect.Shift(Direction8Way.West, 0f); } if (!storeIncident.defName.Equals("Item")) { if (Widgets.ButtonText(buttonRect, _resetText)) { Store_IncidentEditor.LoadBackup(storeIncident); if (storeIncident.cost < 1) { storeIncident.cost = 50; } MakeSureSaveExists(); } buttonRect = buttonRect.Shift(Direction8Way.West, 0f); } if (storeIncidentVariables?.customSettings == true && Widgets.ButtonText(buttonRect, _settingsText)) { storeIncidentVariables.settings.EditSettings(); } GUI.EndGroup(); }
public override void DoWindowContents(Rect inRect) { if (!checkedForBackup || !haveBackup) { MakeSureSaveExists(); return; } Listing_Standard ls = new Listing_Standard(); ls.Begin(inRect); ls.Label(storeIncident.label.CapitalizeFirst()); ls.Gap(); if (storeIncident.cost > 0) { storeIncident.abbreviation = ls.TextEntryLabeled("Purchase Code:", storeIncident.abbreviation); ls.Gap(); ls.AddLabeledNumericalTextField <int>("Cost", ref storeIncident.cost); ls.SliderLabeled("Max times per " + ToolkitSettings.EventCooldownInterval + " ingame day(s)", ref storeIncident.eventCap, storeIncident.eventCap.ToString(), 0, 15); if (variableIncident && storeIncidentVariables.maxWager > 0) { ls.Gap(); ls.SliderLabeled("Maximum coin wager", ref storeIncidentVariables.maxWager, storeIncidentVariables.cost.ToString(), storeIncident.cost, 20000f); } ls.Gap(); ls.AddLabeledRadioList("Karma Type", karmaTypeStrings, ref setKarmaType); storeIncident.karmaType = (KarmaType)Enum.Parse(typeof(KarmaType), setKarmaType); if (variableIncident) { ls.Gap(); ls.GapLine(); ls.Label("Custom Settings"); int KeyIndex = 0; if (storeIncidentVariables.customSettingStringValues != null) { foreach (string str in storeIncidentVariables.customSettingStringValues) { string key = storeIncidentVariables.customSettingKeys[KeyIndex]; CustomSettings.SetStringSetting(key, ls.TextEntryLabeled(StripSettingKey(key), CustomSettings.LookupStringSetting(key))); KeyIndex++; } } if (storeIncidentVariables.customSettingFloatValues != null) { foreach (float flt in storeIncidentVariables.customSettingFloatValues) { string key = storeIncidentVariables.customSettingKeys[KeyIndex]; float newValue = CustomSettings.LookupFloatSetting(key); string newValueBuffer = newValue.ToString(); ls.TextFieldNumericLabeled <float>(StripSettingKey(key), ref newValue, ref newValueBuffer); CustomSettings.SetFloatSetting(key, newValue); KeyIndex++; } } ls.GapLine(); } ls.Gap(); if (ls.ButtonTextLabeled("Disable Store Incident", "Disable")) { storeIncident.cost = -10; } } ls.Gap(); if (storeIncident.defName == "Item") { ls.SliderLabeled("Max times per " + ToolkitSettings.EventCooldownInterval + " ingame day(s)", ref storeIncident.eventCap, storeIncident.eventCap.ToString(), 0, 15); ls.Gap(); } if (storeIncident.defName != "Item" && ls.ButtonTextLabeled("Reset to Default", "Reset")) { Store_IncidentEditor.LoadBackup(storeIncident); if (storeIncident.cost < 1) { storeIncident.cost = 50; } MakeSureSaveExists(true); } if (storeIncident.defName == "Item" && ls.ButtonTextLabeled("Edit item prices", "Edit")) { Type type = typeof(StoreItemsWindow); Find.WindowStack.TryRemove(type); Window window = new StoreItemsWindow(); Find.WindowStack.Add(window); } ls.End(); }
public override void PostClose() { MakeSureSaveExists(true); Store_IncidentEditor.UpdatePriceSheet(); }
public override void DoWindowContents(Rect inRect) { if (!checkedForBackup || !haveBackup) { MakeSureSaveExists(); return; } Listing_Standard ls = new Listing_Standard(); ls.Begin(inRect); ls.Label(storeIncident.label.CapitalizeFirst()); ls.Gap(); if (storeIncident.cost > 0) { storeIncident.abbreviation = ls.TextEntryLabeled("Purchase Code:", storeIncident.abbreviation); ls.Gap(); ls.AddLabeledNumericalTextField <int>("Cost", ref storeIncident.cost); ls.SliderLabeled("Max times per " + ToolkitSettings.EventCooldownInterval + " ingame day(s)", ref storeIncident.eventCap, storeIncident.eventCap.ToString(), 0, 15); if (variableIncident && storeIncidentVariables.maxWager > 0) { ls.Gap(); ls.SliderLabeled("Maximum coin wager", ref storeIncidentVariables.maxWager, storeIncidentVariables.cost.ToString(), storeIncident.cost, 20000f); } ls.Gap(); ls.AddLabeledRadioList("Karma Type", karmaTypeStrings, ref setKarmaType); storeIncident.karmaType = (KarmaType)Enum.Parse(typeof(KarmaType), setKarmaType); ls.Gap(); if (ls.ButtonTextLabeled("Disable Store Incident", "Disable")) { storeIncident.cost = -10; } } ls.Gap(); if (storeIncident.defName == "Item") { ls.SliderLabeled("Max times per " + ToolkitSettings.EventCooldownInterval + " ingame day(s)", ref storeIncident.eventCap, storeIncident.eventCap.ToString(), 0, 15); ls.Gap(); } if (variableIncident && storeIncidentVariables.customSettings) { ls.Gap(); if (ls.ButtonTextLabeled("Edit Extra Settings", "Settings")) { storeIncidentVariables.settings.EditSettings(); } } ls.Gap(); if (storeIncident.defName != "Item" && ls.ButtonTextLabeled("Reset to Default", "Reset")) { Store_IncidentEditor.LoadBackup(storeIncident); if (storeIncident.cost < 1) { storeIncident.cost = 50; } MakeSureSaveExists(true); } if (storeIncident.defName == "Item" && ls.ButtonTextLabeled("Edit item prices", "Edit")) { Type type = typeof(StoreItemsWindow); Find.WindowStack.TryRemove(type); Window window = new StoreItemsWindow(); Find.WindowStack.Add(window); } ls.End(); }
public override void PostClose() { MakeSureSaveExists(true); Store_IncidentEditor.UpdatePriceSheet(); Toolkit.Mod.WriteSettings(); }
public override void Close(bool doCloseSound = true) { Store_IncidentEditor.UpdatePriceSheet(); base.Close(doCloseSound); }
public StoreIncidentsWindow() { Store_IncidentEditor.UpdatePriceSheet(); }
/// <summary> /// Draws the given <see cref="EventItem"/> in the pre-defined row /// space. /// </summary> /// <param name="canvas"> /// The region to draw the <see cref="EventItem"/> /// in /// </param> /// <param name="ev">The <see cref="EventItem"/> to draw</param> protected virtual void DrawEvent(Rect canvas, [NotNull] TableSettingsItem <EventItem> ev) { Rect checkboxRect = LayoutHelper.IconRect(_stateHeaderRect.x + 2f, canvas.y + 2f, _stateHeaderRect.width - 4f, RowLineHeight - 4f); var nameMouseOverRect = new Rect(NameHeaderRect.x, canvas.y, NameHeaderRect.width, RowLineHeight); var nameRect = new Rect(NameHeaderTextRect.x, canvas.y, NameHeaderTextRect.width, RowLineHeight); var priceRect = new Rect(PriceHeaderTextRect.x, canvas.y, PriceHeaderTextRect.width, RowLineHeight); var karmaRect = new Rect(KarmaHeaderTextRect.x, canvas.y, KarmaHeaderTextRect.width, RowLineHeight); Rect settingRect = LayoutHelper.IconRect( _expandedHeaderRect.x + 2f, canvas.y + Mathf.FloorToInt(Mathf.Abs(_expandedHeaderRect.width - RowLineHeight) / 2f) + 2f, _expandedHeaderRect.width - 4f, _expandedHeaderRect.width - 4f ); bool proxy = ev.Data.Enabled; if (UiHelper.DrawCheckbox(checkboxRect, ref proxy)) { if (!ev.Data.Enabled && proxy) { Store_IncidentEditor.LoadBackup(ev.Data.Incident); } ev.Data.Enabled = proxy; if (!Store_IncidentEditor.CopyExists(ev.Data.Incident)) { Store_IncidentEditor.SaveCopy(ev.Data.Incident); } } DrawConfigurableEventName(nameRect, ev); if (!ev.EditingName) { Widgets.DrawHighlightIfMouseover(nameMouseOverRect); if (!ev.Data.Incident.description.NullOrEmpty()) { TooltipHandler.TipRegion(nameMouseOverRect, ev.Data.Incident.description); } } if (ev.Data.Enabled && ev.Data.CostEditable) { int cost = ev.Data.Cost; SettingsHelper.DrawPriceField(priceRect, ref cost); ev.Data.Cost = cost; } UiHelper.Label(karmaRect, ev.Data.KarmaType.ToString()); if (Widgets.ButtonImage(settingRect, Textures.Gear)) { ev.SettingsVisible = !ev.SettingsVisible; } if (!ev.SettingsVisible) { return; } var expandedRect = new Rect( NameHeaderRect.x + 10f, canvas.y + RowLineHeight + 10f, canvas.width - checkboxRect.width - settingRect.width - 20f, canvas.height - RowLineHeight - 20f ); GUI.BeginGroup(expandedRect); DrawExpandedSettings(expandedRect.AtZero(), ev); GUI.EndGroup(); }