From 5d291991977a8bb29841879f6bb83d72a9a1054f Mon Sep 17 00:00:00 2001 From: cadon Date: Tue, 10 Sep 2024 19:19:03 +0200 Subject: [PATCH 1/3] null fixes --- ARKBreedingStats/Form1.Designer.cs | 26 +++++++++---------- .../StatsOptions/StatsOptionsControl.cs | 8 +++++- .../StatsOptions/StatsOptionsForm.cs | 10 ++++--- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/ARKBreedingStats/Form1.Designer.cs b/ARKBreedingStats/Form1.Designer.cs index 974f1d21..2ed5cd75 100644 --- a/ARKBreedingStats/Form1.Designer.cs +++ b/ARKBreedingStats/Form1.Designer.cs @@ -320,6 +320,7 @@ private void InitializeComponent() this.listBoxSpeciesLib = new System.Windows.Forms.ListBox(); this.tabPage3 = new System.Windows.Forms.TabPage(); this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); + this.BtRecalculateTopStatsAfterChange = new System.Windows.Forms.Button(); this.label17 = new System.Windows.Forms.Label(); this.buttonRecalculateTops = new System.Windows.Forms.Button(); this.tabPageLibRadarChart = new System.Windows.Forms.TabPage(); @@ -404,7 +405,6 @@ private void InitializeComponent() this.toolStripSeparator27 = new System.Windows.Forms.ToolStripSeparator(); this.resetColumnOrderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.speciesSelector1 = new ARKBreedingStats.SpeciesSelector(); - this.BtRecalculateTopStatsAfterChange = new System.Windows.Forms.Button(); this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownImprintingBonusTester)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.NumericUpDownTestingTE)).BeginInit(); @@ -1325,7 +1325,7 @@ private void InitializeComponent() // this.statsOptionsToolStripMenuItem.Name = "statsOptionsToolStripMenuItem"; this.statsOptionsToolStripMenuItem.Size = new System.Drawing.Size(226, 22); - this.statsOptionsToolStripMenuItem.Text = "StatsOptions"; + this.statsOptionsToolStripMenuItem.Text = "Stats options"; this.statsOptionsToolStripMenuItem.Click += new System.EventHandler(this.statsOptionsToolStripMenuItem_Click); // // toolStripSeparator18 @@ -3112,6 +3112,17 @@ private void InitializeComponent() this.tableLayoutPanel2.Size = new System.Drawing.Size(175, 322); this.tableLayoutPanel2.TabIndex = 0; // + // BtRecalculateTopStatsAfterChange + // + this.BtRecalculateTopStatsAfterChange.Dock = System.Windows.Forms.DockStyle.Top; + this.BtRecalculateTopStatsAfterChange.Location = new System.Drawing.Point(3, 58); + this.BtRecalculateTopStatsAfterChange.Name = "BtRecalculateTopStatsAfterChange"; + this.BtRecalculateTopStatsAfterChange.Size = new System.Drawing.Size(169, 52); + this.BtRecalculateTopStatsAfterChange.TabIndex = 5; + this.BtRecalculateTopStatsAfterChange.Text = "Recalculate top stats after change"; + this.BtRecalculateTopStatsAfterChange.UseVisualStyleBackColor = true; + this.BtRecalculateTopStatsAfterChange.Click += new System.EventHandler(this.BtRecalculateTopStatsAfterChange_Click); + // // label17 // this.label17.AutoSize = true; @@ -3967,17 +3978,6 @@ private void InitializeComponent() this.speciesSelector1.SplitterDistance = 500; this.speciesSelector1.TabIndex = 0; // - // BtRecalculateTopStatsAfterChange - // - this.BtRecalculateTopStatsAfterChange.Dock = System.Windows.Forms.DockStyle.Top; - this.BtRecalculateTopStatsAfterChange.Location = new System.Drawing.Point(3, 58); - this.BtRecalculateTopStatsAfterChange.Name = "BtRecalculateTopStatsAfterChange"; - this.BtRecalculateTopStatsAfterChange.Size = new System.Drawing.Size(169, 52); - this.BtRecalculateTopStatsAfterChange.TabIndex = 5; - this.BtRecalculateTopStatsAfterChange.Text = "Recalculate top stats after change"; - this.BtRecalculateTopStatsAfterChange.UseVisualStyleBackColor = true; - this.BtRecalculateTopStatsAfterChange.Click += new System.EventHandler(this.BtRecalculateTopStatsAfterChange_Click); - // // Form1 // this.AcceptButton = this.btExtractLevels; diff --git a/ARKBreedingStats/StatsOptions/StatsOptionsControl.cs b/ARKBreedingStats/StatsOptions/StatsOptionsControl.cs index cab650d4..f8837f1f 100644 --- a/ARKBreedingStats/StatsOptions/StatsOptionsControl.cs +++ b/ARKBreedingStats/StatsOptions/StatsOptionsControl.cs @@ -37,6 +37,7 @@ public StatsOptionsControl(StatsOptionsSettings settings, ToolTip tt) protected void InitializeControls(StatsOptionsSettings settings, ToolTip tt) { + if (settings == null) return; StatsOptionsSettings = settings; Tt = tt; @@ -163,7 +164,7 @@ private void CbbOptions_SelectedIndexChanged(object sender, EventArgs e) if (SelectedStatsOptions == null) return; this.SuspendDrawing(); - TbOptionsName.Text = SelectedStatsOptions.ToString(); + TbOptionsName.Text = SelectedStatsOptions.Name; var isNotRoot = SelectedStatsOptions.Name != string.Empty; TbOptionsName.Enabled = isNotRoot; LbParent.Visible = isNotRoot; @@ -237,6 +238,11 @@ private void TbOptionsName_Leave(object sender, EventArgs e) newName = newNameBase + "_" + ++suffix; TbOptionsName.Text = newName; + if (SelectedStatsOptions.AffectedSpecies?.Any() != false) + { + SelectedStatsOptions.AffectedSpecies = new[] { newNameBase }; + TbAffectedSpecies.Text = newNameBase; + } StatsOptionsSettings.StatsOptionsDict.Remove(SelectedStatsOptions.Name); SelectedStatsOptions.Name = newName; StatsOptionsSettings.StatsOptionsDict.Add(newName, SelectedStatsOptions); diff --git a/ARKBreedingStats/StatsOptions/StatsOptionsForm.cs b/ARKBreedingStats/StatsOptions/StatsOptionsForm.cs index a4cdd87d..b1868766 100644 --- a/ARKBreedingStats/StatsOptions/StatsOptionsForm.cs +++ b/ARKBreedingStats/StatsOptions/StatsOptionsForm.cs @@ -1,5 +1,6 @@ using ARKBreedingStats.StatsOptions.LevelColorSettings; using System; +using System.CodeDom; using System.Drawing; using System.Windows.Forms; using ARKBreedingStats.StatsOptions.TopStatsSettings; @@ -29,15 +30,18 @@ public static void ShowWindow(Form parent, Width = Properties.Settings.Default.LevelColorWindowRectangle.Width, Height = Properties.Settings.Default.LevelColorWindowRectangle.Height, StartPosition = FormStartPosition.Manual, - Location = new Point(Properties.Settings.Default.LevelColorWindowRectangle.X, Properties.Settings.Default.LevelColorWindowRectangle.Y) + Location = new Point(Properties.Settings.Default.LevelColorWindowRectangle.X, Properties.Settings.Default.LevelColorWindowRectangle.Y), + Text = "Stats options" }; // stat settings tab var tabs = new TabControl(); tabs.Dock = DockStyle.Fill; - AddAndDock(new LevelGraphOptionsControl(levelColorSettings, f.Tt), levelColorSettings.SettingsName); - AddAndDock(new ConsiderTopStatsControl(topStatsSettings, f.Tt), topStatsSettings.SettingsName); + if (levelColorSettings != null) + AddAndDock(new LevelGraphOptionsControl(levelColorSettings, f.Tt), levelColorSettings.SettingsName); + if (topStatsSettings != null) + AddAndDock(new ConsiderTopStatsControl(topStatsSettings, f.Tt), topStatsSettings.SettingsName); void AddAndDock(Control c, string tabName) { From 5608865bd0c9ac13c2971f9aea4624fe64311baf Mon Sep 17 00:00:00 2001 From: cadon Date: Tue, 10 Sep 2024 21:19:41 +0200 Subject: [PATCH 2/3] open considerTopStatsSettings from settings window --- ARKBreedingStats/Form1.cs | 24 +++++++++---------- ARKBreedingStats/Form1.library.cs | 8 +++---- ARKBreedingStats/Pedigree/PedigreeCreature.cs | 2 +- .../StatsOptions/StatsOptionsForm.cs | 1 - .../TopStatsSettings/ConsiderTopStats.cs | 2 +- ARKBreedingStats/settings/Settings.cs | 7 ++---- 6 files changed, 20 insertions(+), 24 deletions(-) diff --git a/ARKBreedingStats/Form1.cs b/ARKBreedingStats/Form1.cs index ef185a61..94da8092 100644 --- a/ARKBreedingStats/Form1.cs +++ b/ARKBreedingStats/Form1.cs @@ -88,8 +88,8 @@ public delegate void SetMessageLabelTextEventHandler(string text = null, Message private static double[] _lastOcrValues; private Species _lastOcrSpecies; - internal static readonly StatsOptionsSettings StatsLevelColors = new StatsOptionsSettings("statsLevelColors.json", "Level colors"); - internal static readonly StatsOptionsSettings StatsTopStats = new StatsOptionsSettings("statsTopStats.json", "Consider for top stats"); + internal static readonly StatsOptionsSettings StatsOptionsLevelColors = new StatsOptionsSettings("statsLevelColors.json", "Level colors"); + internal static readonly StatsOptionsSettings StatsOptionsConsiderTopStats = new StatsOptionsSettings("statsTopStats.json", "Consider for top stats"); public Form1() { @@ -167,7 +167,7 @@ public Form1() ocrControl1.OcrLabelSetsChanged += InitializeOcrLabelSets; ocrControl1.OcrLabelSelectedSetChanged += SetCurrentOcrLabelSet; - StatsLevelColors.SettingsChanged += StatsLevelColors_SettingsChanged; + StatsOptionsLevelColors.SettingsChanged += StatsOptionsLevelColorsSettingsChanged; openSettingsToolStripMenuItem.ShortcutKeyDisplayString = new KeysConverter() .ConvertTo(Keys.Control, typeof(string))?.ToString().Replace("None", ","); @@ -688,7 +688,7 @@ private void SpeciesSelector1OnSpeciesSelected(bool speciesChanged) creatureInfoInputTester.SelectedSpecies = species; radarChart1.SetLevels(species: species); var statNames = species.statNames; - var levelGraphRepresentations = StatsLevelColors.GetStatsOptions(species); + var levelGraphRepresentations = StatsOptionsLevelColors.GetStatsOptions(species); for (int s = 0; s < Stats.StatsCount; s++) { @@ -797,9 +797,9 @@ private void SpeciesSelector1OnSpeciesSelected(bool speciesChanged) /// /// Applies the level color settings to the stat controls. Call if a species setting was added or removed. /// - private void StatsLevelColors_SettingsChanged() + private void StatsOptionsLevelColorsSettingsChanged() { - var levelGraphRepresentations = StatsLevelColors.GetStatsOptions(speciesSelector1.SelectedSpecies); + var levelGraphRepresentations = StatsOptionsLevelColors.GetStatsOptions(speciesSelector1.SelectedSpecies); if (levelGraphRepresentations == null) return; for (int s = 0; s < Stats.StatsCount; s++) @@ -1451,8 +1451,8 @@ private void SaveAppSettings() /////// save settings for next session Properties.Settings.Default.Save(); - StatsLevelColors.SaveSettings(); - StatsTopStats.SaveSettings(); + StatsOptionsLevelColors.SaveSettings(); + StatsOptionsConsiderTopStats.SaveSettings(); } /// @@ -2110,7 +2110,7 @@ private void OpenSettingsDialog(SettingsTabPages page = SettingsTabPages.Unknown var gameSettingBefore = _creatureCollection.Game; var displayLibraryCreatureIndexBefore = Properties.Settings.Default.DisplayLibraryCreatureIndex; - using (Settings settingsForm = new Settings(_creatureCollection, page, StatsLevelColors)) + using (Settings settingsForm = new Settings(_creatureCollection, page)) { var settingsSaved = settingsForm.ShowDialog() == DialogResult.OK; _settingsLastTabPage = settingsForm.LastTabPageIndex; @@ -3960,12 +3960,12 @@ private void showTokenPopupOnListeningToolStripMenuItem_Click(object sender, Eve private void statsOptionsToolStripMenuItem_Click(object sender, EventArgs e) { - StatsOptionsForm.ShowWindow(this, StatsLevelColors, StatsTopStats); + StatsOptionsForm.ShowWindow(this, StatsOptionsLevelColors, StatsOptionsConsiderTopStats); } private void ButtonOpenTopStatsSettingsClick(object sender, EventArgs e) { - StatsOptionsForm.ShowWindow(this, StatsLevelColors, StatsTopStats, 1); + StatsOptionsForm.ShowWindow(this, StatsOptionsLevelColors, StatsOptionsConsiderTopStats, 1); } private void ExportAppSettings() @@ -4049,7 +4049,7 @@ private void loadAppSettingsFromFileToolStripMenuItem_Click(object sender, Event private void showStatsOptionsFileInExplorerToolStripMenuItem_Click(object sender, EventArgs e) { - OpenFolderInExplorer(StatsLevelColors.SettingsFilePath); + OpenFolderInExplorer(StatsOptionsLevelColors.SettingsFilePath); } } } diff --git a/ARKBreedingStats/Form1.library.cs b/ARKBreedingStats/Form1.library.cs index bbd6c41c..875aff77 100644 --- a/ARKBreedingStats/Form1.library.cs +++ b/ARKBreedingStats/Form1.library.cs @@ -312,7 +312,7 @@ private void CalculateTopStats(List creatures, Species onlySpecies = n var lowestLevels = new int[Stats.StatsCount]; var highestMutationLevels = new int[Stats.StatsCount]; var lowestMutationLevels = new int[Stats.StatsCount]; - var considerAsTopStat = StatsTopStats.GetStatsOptions(species).StatOptions; + var considerAsTopStat = StatsOptionsConsiderTopStats.GetStatsOptions(species).StatOptions; var statWeights = breedingPlan1.StatWeighting.GetWeightingForSpecies(species); for (int s = 0; s < Stats.StatsCount; s++) { @@ -576,7 +576,7 @@ private void CalculateTopStats(List creatures, Species onlySpecies = n continue; if (!considerTopStats.TryGetValue(c.Species, out var consideredTopStats)) { - consideredTopStats = StatsTopStats.GetStatsOptions(c.Species).StatOptions.Select(si => si.ConsiderStat).ToArray(); + consideredTopStats = StatsOptionsConsiderTopStats.GetStatsOptions(c.Species).StatOptions.Select(si => si.ConsiderStat).ToArray(); considerTopStats[c.Species] = consideredTopStats; } c.SetTopStatCount(consideredTopStats, considerWastedStatsForTopCreatures); @@ -1124,8 +1124,8 @@ private ListViewItem CreateCreatureLvItem(Creature cr, bool displayIndex = false // apply colors to the subItems var displayZeroMutationLevels = Properties.Settings.Default.LibraryDisplayZeroMutationLevels; - var statOptionsColors = StatsLevelColors.GetStatsOptions(cr.Species).StatOptions; - var statOptionsTopStats = StatsTopStats.GetStatsOptions(cr.Species).StatOptions; + var statOptionsColors = StatsOptionsLevelColors.GetStatsOptions(cr.Species).StatOptions; + var statOptionsTopStats = StatsOptionsConsiderTopStats.GetStatsOptions(cr.Species).StatOptions; for (int s = 0; s < Stats.StatsCount; s++) { diff --git a/ARKBreedingStats/Pedigree/PedigreeCreature.cs b/ARKBreedingStats/Pedigree/PedigreeCreature.cs index 25cc5d77..f56c8393 100644 --- a/ARKBreedingStats/Pedigree/PedigreeCreature.cs +++ b/ARKBreedingStats/Pedigree/PedigreeCreature.cs @@ -181,7 +181,7 @@ public Creature Creature _tt.SetToolTip(labelSex, "Sex: " + Loc.S(_creature.sex.ToString())); - var levelColorOptions = Form1.StatsLevelColors.GetStatsOptions(Creature.Species); + var levelColorOptions = Form1.StatsOptionsLevelColors.GetStatsOptions(Creature.Species); for (int s = 0; s < DisplayedStatsCount; s++) { diff --git a/ARKBreedingStats/StatsOptions/StatsOptionsForm.cs b/ARKBreedingStats/StatsOptions/StatsOptionsForm.cs index b1868766..00b15c79 100644 --- a/ARKBreedingStats/StatsOptions/StatsOptionsForm.cs +++ b/ARKBreedingStats/StatsOptions/StatsOptionsForm.cs @@ -1,6 +1,5 @@ using ARKBreedingStats.StatsOptions.LevelColorSettings; using System; -using System.CodeDom; using System.Drawing; using System.Windows.Forms; using ARKBreedingStats.StatsOptions.TopStatsSettings; diff --git a/ARKBreedingStats/StatsOptions/TopStatsSettings/ConsiderTopStats.cs b/ARKBreedingStats/StatsOptions/TopStatsSettings/ConsiderTopStats.cs index 5130156b..aa893c43 100644 --- a/ARKBreedingStats/StatsOptions/TopStatsSettings/ConsiderTopStats.cs +++ b/ARKBreedingStats/StatsOptions/TopStatsSettings/ConsiderTopStats.cs @@ -6,7 +6,7 @@ namespace ARKBreedingStats.StatsOptions.TopStatsSettings /// Setting which stats are considered in top stats calculation. /// [JsonObject(MemberSerialization.OptIn)] - internal class ConsiderTopStats : StatOptionsBase + public class ConsiderTopStats : StatOptionsBase { [JsonProperty("top", DefaultValueHandling = DefaultValueHandling.Ignore)] public bool ConsiderStat; diff --git a/ARKBreedingStats/settings/Settings.cs b/ARKBreedingStats/settings/Settings.cs index 15829767..2f5e8f21 100644 --- a/ARKBreedingStats/settings/Settings.cs +++ b/ARKBreedingStats/settings/Settings.cs @@ -22,7 +22,6 @@ public partial class Settings : Form { private MultiplierSetting[] _multSetter; private readonly CreatureCollection _cc; - private readonly StatsOptionsSettings _statsLevelColors; private ToolTip _tt; private Dictionary _languages; public SettingsTabPages LastTabPageIndex; @@ -30,12 +29,10 @@ public partial class Settings : Form public bool ColorRegionDisplayChanged; private CancellationTokenSource _cancellationTokenSource; - public Settings(CreatureCollection cc, SettingsTabPages page, - StatsOptionsSettings statsLevelColors) + public Settings(CreatureCollection cc, SettingsTabPages page) { InitializeData(); _cc = cc; - _statsLevelColors = statsLevelColors; CreateListOfProcesses(); LoadSettings(cc); Localization(); @@ -1882,7 +1879,7 @@ private void BtnUpdateOfficialEventValues_Click(object sender, EventArgs e) private void BtOpenLevelColorOptions_Click(object sender, EventArgs e) { - StatsOptionsForm.ShowWindow(this, _statsLevelColors, null); + StatsOptionsForm.ShowWindow(this, Form1.StatsOptionsLevelColors, Form1.StatsOptionsConsiderTopStats); } } } From fc255132ea1b93637ab4bfefab156026756039b6 Mon Sep 17 00:00:00 2001 From: cadon Date: Tue, 10 Sep 2024 21:24:16 +0200 Subject: [PATCH 3/3] ver --- ARKBreedingStats/Properties/AssemblyInfo.cs | 2 +- ARKBreedingStats/_manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ARKBreedingStats/Properties/AssemblyInfo.cs b/ARKBreedingStats/Properties/AssemblyInfo.cs index 0c1f66c0..1b802758 100644 --- a/ARKBreedingStats/Properties/AssemblyInfo.cs +++ b/ARKBreedingStats/Properties/AssemblyInfo.cs @@ -30,6 +30,6 @@ // Revision // [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("0.63.1.1")] +[assembly: AssemblyFileVersion("0.63.1.2")] [assembly: NeutralResourcesLanguage("en")] diff --git a/ARKBreedingStats/_manifest.json b/ARKBreedingStats/_manifest.json index e284a5a5..ed6885d3 100644 --- a/ARKBreedingStats/_manifest.json +++ b/ARKBreedingStats/_manifest.json @@ -4,7 +4,7 @@ "ARK Smart Breeding": { "Id": "ARK Smart Breeding", "Category": "main", - "version": "0.63.1.1" + "version": "0.63.1.2" }, "SpeciesColorImages": { "Id": "SpeciesColorImages",