diff --git a/ARKBreedingStats/ARKBreedingStats.csproj b/ARKBreedingStats/ARKBreedingStats.csproj index 8e46f889..2eabdac1 100644 --- a/ARKBreedingStats/ARKBreedingStats.csproj +++ b/ARKBreedingStats/ARKBreedingStats.csproj @@ -961,7 +961,7 @@ all - 13.0.1 + 13.0.2 diff --git a/ARKBreedingStats/AboutBox1.cs b/ARKBreedingStats/AboutBox1.cs index d2edd5ea..316555e8 100644 --- a/ARKBreedingStats/AboutBox1.cs +++ b/ARKBreedingStats/AboutBox1.cs @@ -108,6 +108,7 @@ private void linkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs * dunger (fixes) * Myrmecoleon (extra species images) * Lunat1q (improved OCR) +* ThatGamerBlue (species dividers in virtual listview) Translations: * French by Vykan and Yanuut diff --git a/ARKBreedingStats/CreatureInfoInput.Designer.cs b/ARKBreedingStats/CreatureInfoInput.Designer.cs index 1aeea697..52e7eeda 100644 --- a/ARKBreedingStats/CreatureInfoInput.Designer.cs +++ b/ARKBreedingStats/CreatureInfoInput.Designer.cs @@ -412,7 +412,7 @@ private void InitializeComponent() this.label12.AutoSize = true; this.label12.Location = new System.Drawing.Point(173, 388); this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(17, 13); + this.label12.Size = new System.Drawing.Size(19, 13); this.label12.TabIndex = 34; this.label12.Text = "♂"; // @@ -421,7 +421,7 @@ private void InitializeComponent() this.label11.AutoSize = true; this.label11.Location = new System.Drawing.Point(85, 388); this.label11.Name = "label11"; - this.label11.Size = new System.Drawing.Size(16, 13); + this.label11.Size = new System.Drawing.Size(19, 13); this.label11.TabIndex = 33; this.label11.Text = "♀"; // @@ -432,6 +432,7 @@ private void InitializeComponent() this.dhmsInputGrown.Size = new System.Drawing.Size(136, 26); this.dhmsInputGrown.TabIndex = 10; this.dhmsInputGrown.Timespan = System.TimeSpan.Parse("00:00:00"); + this.dhmsInputGrown.ValueChanged += new ARKBreedingStats.uiControls.dhmsInput.ValueChangedEventHandler(this.dhmsInputGrown_ValueChanged); // // dhmsInputCooldown // @@ -541,6 +542,13 @@ private void InitializeComponent() // // regionColorChooser1 // + this.regionColorChooser1.ColorIdsAlsoPossible = new byte[] { + ((byte)(0)), + ((byte)(0)), + ((byte)(0)), + ((byte)(0)), + ((byte)(0)), + ((byte)(0))}; this.regionColorChooser1.Location = new System.Drawing.Point(82, 496); this.regionColorChooser1.Margin = new System.Windows.Forms.Padding(0); this.regionColorChooser1.Name = "regionColorChooser1"; diff --git a/ARKBreedingStats/CreatureInfoInput.cs b/ARKBreedingStats/CreatureInfoInput.cs index b0754d0e..eb130462 100644 --- a/ARKBreedingStats/CreatureInfoInput.cs +++ b/ARKBreedingStats/CreatureInfoInput.cs @@ -80,8 +80,6 @@ public CreatureInfoInput() parentComboBoxFather.SelectedIndex = 0; _updateMaturation = true; _regionColorIDs = new byte[Ark.ColorRegionCount]; - CooldownUntil = new DateTime(2000, 1, 1); - GrowingUntil = new DateTime(2000, 1, 1); NamesOfAllCreatures = new List(); var namingPatternButtons = ButtonsNamingPattern; @@ -291,38 +289,39 @@ private void groupBox1_Enter(object sender, EventArgs e) ParentListRequested?.Invoke(this); } - //private void dhmsInputGrown_ValueChanged(object sender, TimeSpan ts) - //{ - // if (_updateMaturation && _selectedSpecies != null) - // { - // _updateMaturation = false; - // double maturation = 0; - // if (_selectedSpecies.breeding != null && _selectedSpecies.breeding.maturationTimeAdjusted > 0) - // { - // maturation = 1 - dhmsInputGrown.Timespan.TotalSeconds / _selectedSpecies.breeding.maturationTimeAdjusted; - // if (maturation < 0) maturation = 0; - // if (maturation > 1) maturation = 1; - // } - // nudMaturation.Value = (decimal)maturation * 100; - - // _updateMaturation = true; - // } - //} + private void dhmsInputGrown_ValueChanged(object sender, TimeSpan ts) + { + if (!_updateMaturation || _selectedSpecies?.breeding == null) return; + dhmsInputGrown.changed = true; + SetMaturationAccordingToGrownUpIn(); + } + + private void SetMaturationAccordingToGrownUpIn() + { + double maturation = 1; + if (_selectedSpecies.breeding != null && _selectedSpecies.breeding.maturationTimeAdjusted > 0) + { + maturation = 1 - dhmsInputGrown.Timespan.TotalSeconds / _selectedSpecies.breeding.maturationTimeAdjusted; + if (maturation < 0) maturation = 0; + if (maturation > 1) maturation = 1; + } + _updateMaturation = false; + nudMaturation.Value = (decimal)maturation * 100; + _updateMaturation = true; + } private void nudMaturation_ValueChanged(object sender, EventArgs e) { - if (_updateMaturation) + if (!_updateMaturation) return; + + _updateMaturation = false; + if (_selectedSpecies.breeding != null) { - _updateMaturation = false; - if (_selectedSpecies.breeding != null) - { - dhmsInputGrown.Timespan = new TimeSpan(0, 0, (int)(_selectedSpecies.breeding.maturationTimeAdjusted * - (1 - (double)nudMaturation.Value / 100))); - dhmsInputGrown.changed = true; - } - else dhmsInputGrown.Timespan = TimeSpan.Zero; - _updateMaturation = true; + dhmsInputGrown.Timespan = TimeSpan.FromSeconds(_selectedSpecies.breeding.maturationTimeAdjusted * (1 - (double)nudMaturation.Value / 100)); + dhmsInputGrown.changed = true; } + else dhmsInputGrown.Timespan = TimeSpan.Zero; + _updateMaturation = true; } /// @@ -348,8 +347,9 @@ public DateTime? GrowingUntil get => dhmsInputGrown.changed ? DateTime.Now.Add(dhmsInputGrown.Timespan) : default(DateTime?); set { - if (value.HasValue) - dhmsInputGrown.Timespan = value.Value - DateTime.Now; + if (!value.HasValue) return; + dhmsInputGrown.Timespan = value.Value - DateTime.Now; + SetMaturationAccordingToGrownUpIn(); } } @@ -540,7 +540,7 @@ public Species SelectedSpecies lbMaturationPerc.Visible = breedingPossible; if (!breedingPossible) { - nudMaturation.Value = 0; + nudMaturation.Value = 1; dhmsInputGrown.Timespan = TimeSpan.Zero; dhmsInputCooldown.Timespan = TimeSpan.Zero; } @@ -632,7 +632,8 @@ public void SetCreatureData(Creature cr) cr.colors = RegionColors; cr.ColorIdsAlsoPossible = ColorIdsAlsoPossible; cr.cooldownUntil = CooldownUntil; - cr.growingUntil = GrowingUntil; + if (GrowingUntil != null) // if growing was not changed, don't change that value, growing could be paused + cr.growingUntil = GrowingUntil; cr.domesticatedAt = DomesticatedAt; cr.ArkId = ArkId; cr.InitializeArkInGame(); diff --git a/ARKBreedingStats/Form1.cs b/ARKBreedingStats/Form1.cs index dab88684..ff6628fa 100644 --- a/ARKBreedingStats/Form1.cs +++ b/ARKBreedingStats/Form1.cs @@ -172,6 +172,10 @@ public Form1() listViewLibrary.VirtualMode = true; listViewLibrary.RetrieveVirtualItem += ListViewLibrary_RetrieveVirtualItem; listViewLibrary.CacheVirtualItems += ListViewLibrary_CacheVirtualItems; + listViewLibrary.OwnerDraw = true; + listViewLibrary.DrawItem += ListViewLibrary_DrawItem; + listViewLibrary.DrawColumnHeader += (sender, args) => args.DrawDefault = true; + listViewLibrary.DrawSubItem += ListViewLibrary_DrawSubItem; speciesSelector1.SetTextBox(tbSpeciesGlobal); diff --git a/ARKBreedingStats/Form1.library.cs b/ARKBreedingStats/Form1.library.cs index 93b35b3c..16ec6d47 100644 --- a/ARKBreedingStats/Form1.library.cs +++ b/ARKBreedingStats/Form1.library.cs @@ -758,7 +758,8 @@ private void UpdateIncubationParents(CreatureCollection cc) private void ShowCreaturesInListView(IEnumerable creatures) { listViewLibrary.BeginUpdate(); - _creaturesDisplayed = _creatureListSorter.DoSort(creatures, orderBySpecies: Properties.Settings.Default.LibraryGroupBySpecies ? _speciesInLibraryOrdered : null); + IEnumerable sorted = _creatureListSorter.DoSort(creatures, orderBySpecies: Properties.Settings.Default.LibraryGroupBySpecies ? _speciesInLibraryOrdered : null); + _creaturesDisplayed = Properties.Settings.Default.LibraryGroupBySpecies ? InsertDividers(sorted) : sorted.ToArray(); listViewLibrary.VirtualListSize = _creaturesDisplayed.Length; _libraryListViewItemCache = null; listViewLibrary.EndUpdate(); @@ -777,6 +778,31 @@ private void ShowCreaturesInListView(IEnumerable creatures) } } + private Creature[] InsertDividers(IEnumerable creatures) + { + var enumerable = creatures.ToList(); + if (!enumerable.Any()) + { + return Array.Empty(); + } + List result = new List(); + Species lastSpecies = null; + foreach (Creature c in enumerable) + { + if (lastSpecies == null || c.Species != lastSpecies) + { + result.Add(new Creature(c.Species) + { + flags = CreatureFlags.Placeholder | CreatureFlags.Divider, + Status = CreatureStatus.Unavailable + }); + } + result.Add(c); + lastSpecies = c.Species; + } + return result.ToArray(); + } + #region ListViewLibrary virtual private Creature[] _creaturesDisplayed; @@ -821,6 +847,33 @@ private void ListViewLibrary_CacheVirtualItems(object sender, CacheVirtualItemsE } } + private void ListViewLibrary_DrawItem(object sender, DrawListViewItemEventArgs e) + { + e.DrawDefault = true; + + if (!(e.Item.Tag is Creature creature)) + { + return; + } + + if (creature.flags.HasFlag(CreatureFlags.Divider)) + { + e.DrawDefault = false; + var rect = e.Bounds; + float middle = (rect.Top + rect.Bottom) / 2f; + e.Graphics.FillRectangle(Brushes.Blue, rect.Left, middle, rect.Width - 3, 1); + SizeF strSize = e.Graphics.MeasureString(creature.Species.DescriptiveNameAndMod, e.Item.Font); + e.Graphics.FillRectangle(new SolidBrush(e.Item.BackColor), rect.Left, rect.Top, strSize.Width + 15, rect.Height); + e.Graphics.DrawString(creature.Species.DescriptiveNameAndMod, e.Item.Font, Brushes.Black, rect.Left + 10, rect.Top + ((rect.Height - strSize.Height) / 2f)); + } + } + + private void ListViewLibrary_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) + { + var isDivider = e.Item.Tag is Creature creature && creature.flags.HasFlag(CreatureFlags.Divider); + e.DrawDefault = !isDivider; + } + #endregion /// @@ -951,6 +1004,14 @@ private void UpdateCreatureListViewItem(Creature creature) private ListViewItem CreateCreatureLvItem(Creature cr) { + if (cr.flags.HasFlag(CreatureFlags.Divider)) + { + return new ListViewItem(Enumerable.Repeat(string.Empty, listViewLibrary.Columns.Count).ToArray()) + { + Tag = cr + }; + } + double colorFactor = 100d / _creatureCollection.maxChartLevel; string[] subItems = new[] @@ -1187,7 +1248,8 @@ private void SortLibrary(int columnIndex = -1) foreach (int i in listViewLibrary.SelectedIndices) selectedCreatures.Add(_creaturesDisplayed[i]); - _creaturesDisplayed = _creatureListSorter.DoSort(_creaturesDisplayed, columnIndex, Properties.Settings.Default.LibraryGroupBySpecies ? _speciesInLibraryOrdered : null); + IEnumerable sorted = _creatureListSorter.DoSort(_creaturesDisplayed.Where(c => !c.flags.HasFlag(CreatureFlags.Divider)), columnIndex, Properties.Settings.Default.LibraryGroupBySpecies ? _speciesInLibraryOrdered : null); + _creaturesDisplayed = Properties.Settings.Default.LibraryGroupBySpecies ? InsertDividers(sorted) : sorted.ToArray(); _libraryListViewItemCache = null; listViewLibrary.EndUpdate(); SelectCreaturesInLibrary(selectedCreatures); @@ -1207,6 +1269,13 @@ private void listViewLibrary_SelectedIndexChanged(object sender, EventArgs e) /// private void LibrarySelectedIndexChanged() { + // remove dividers from selection + foreach (int i in listViewLibrary.SelectedIndices) + { + if (_creaturesDisplayed[i].flags.HasFlag(CreatureFlags.Divider)) + listViewLibrary.SelectedIndices.Remove(i); + } + int cnt = listViewLibrary.SelectedIndices.Count; if (cnt == 0) { diff --git a/ARKBreedingStats/Form1.tester.cs b/ARKBreedingStats/Form1.tester.cs index 8b10fc06..2d1273c7 100644 --- a/ARKBreedingStats/Form1.tester.cs +++ b/ARKBreedingStats/Form1.tester.cs @@ -215,10 +215,10 @@ private void creatureInfoInputTester_Save2Library_Clicked(CreatureInfoInput send _creatureTesterEdit.RecalculateNewMutations(); // if maturation was changed, update raising-timers - if (_creatureTesterEdit.growingUntil != creatureInfoInputTester.GrowingUntil) + var newGrownUpAt = creatureInfoInputTester.GrowingUntil; + if (newGrownUpAt != null && _creatureTesterEdit.growingUntil != newGrownUpAt) { raisingControl1.RecreateList(); - _creatureTesterEdit.StartStopMatureTimer(true); } SetTesterInfoInputCreature(); diff --git a/ARKBreedingStats/Properties/AssemblyInfo.cs b/ARKBreedingStats/Properties/AssemblyInfo.cs index a92ab41f..ba3e6990 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.50.7.0")] +[assembly: AssemblyFileVersion("0.50.8.0")] [assembly: NeutralResourcesLanguage("en")] diff --git a/ARKBreedingStats/_manifest.json b/ARKBreedingStats/_manifest.json index ec42f75d..09be4a9d 100644 --- a/ARKBreedingStats/_manifest.json +++ b/ARKBreedingStats/_manifest.json @@ -4,7 +4,7 @@ "ARK Smart Breeding": { "Id": "ARK Smart Breeding", "Category": "main", - "version": "0.50.7.0" + "version": "0.50.8.0" }, "SpeciesColorImages": { "Id": "SpeciesColorImages", diff --git a/ARKBreedingStats/json/values/_manifest.json b/ARKBreedingStats/json/values/_manifest.json index 48a4430b..4de1620c 100644 --- a/ARKBreedingStats/json/values/_manifest.json +++ b/ARKBreedingStats/json/values/_manifest.json @@ -35,7 +35,7 @@ "mod": { "id": "1139775728", "tag": "Confuciusornis", "title": "Confuciusornis" } }, "1169020368-Trex.json": { - "version": "354.4.1669539497", + "version": "354.6.1670659701", "mod": { "id": "1169020368", "tag": "Trex", "title": "Ark Creature Rebalance (AG Reborn)" } }, "1178308359-ShadDragon.json": { @@ -235,7 +235,7 @@ "mod": { "id": "2000326197", "tag": "ExtraResources", "title": "Event Assets" } }, "2003934830-Beasts.json": { - "version": "354.4.1669867458", + "version": "354.4.1670199617", "mod": { "id": "2003934830", "tag": "Beasts", "title": "Prehistoric Beasts" } }, "2019846325-ApexMod.json": { @@ -263,7 +263,7 @@ "mod": { "id": "2135314513", "tag": "CI_Dinos", "title": "Crystal Isles Dino Addition" } }, "2447186973-ArkOmega.json": { - "version": "351.6.1667016777", + "version": "354.6.1670707999", "mod": { "id": "2447186973", "tag": "ArkOmega", "title": "Ark Omega" } }, "2869411055-SDinoVariants.json": { diff --git a/ARKBreedingStats/library/Creature.cs b/ARKBreedingStats/library/Creature.cs index e9e530a8..dbfa8443 100644 --- a/ARKBreedingStats/library/Creature.cs +++ b/ARKBreedingStats/library/Creature.cs @@ -1,5 +1,4 @@ using ARKBreedingStats.species; -using ARKBreedingStats.values; using Newtonsoft.Json; using System; using System.Collections.Generic; @@ -160,8 +159,21 @@ private int[] ColorIdsAlsoPossibleSerialization get => ColorIdsAlsoPossible?.Select(i => (int)i).ToArray(); } + private DateTime? _growingUntil; + [JsonProperty] - public DateTime? growingUntil; + public DateTime? growingUntil + { + set + { + if (growingPaused && value != null) + growingLeft = value.Value.Subtract(DateTime.Now); + else + _growingUntil = value; + } + get => growingPaused ? DateTime.Now.Add(growingLeft) : _growingUntil; + } + public TimeSpan growingLeft; [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public bool growingPaused; @@ -240,6 +252,15 @@ public Creature(long arkId) flags = CreatureFlags.Placeholder; } + /// + /// Creates a placeholder creature with a species and no other info. + /// + public Creature(Species species) + { + _species = species; + flags = CreatureFlags.Placeholder; + } + public bool Equals(Creature other) => other != null && other.guid == guid; public override bool Equals(object obj) => obj is Creature creatureObj && creatureObj.guid == guid; @@ -249,6 +270,9 @@ public CreatureStatus Status get => _status; set { + // remove other status while keeping the other flags + flags = (flags & CreatureFlags.StatusMask) | (CreatureFlags)(1 << (int)value); + if (_status == value) return; if (Maturation < 1) @@ -264,9 +288,6 @@ public CreatureStatus Status } _status = value; - // remove other status while keeping the other flags - flags = (flags & CreatureFlags.StatusMask) | (CreatureFlags)(1 << (int)value); - } } @@ -454,13 +475,13 @@ private void PauseMaturationTimer() { if (!growingPaused) { - growingPaused = true; growingLeft = growingUntil?.Subtract(DateTime.Now) ?? TimeSpan.Zero; if (growingLeft.Ticks <= 0) { growingLeft = TimeSpan.Zero; growingUntil = null; } + growingPaused = true; } } @@ -571,8 +592,12 @@ public enum CreatureFlags Male = 1024, MutagenApplied = 2048, /// + /// Indicates a dummy creature used as a species separator in the library listView. + /// + Divider = 4096, + /// /// If applied to the flags with &, the status is removed. /// - StatusMask = Mutated | Neutered | Placeholder | Female | Male | MutagenApplied + StatusMask = Mutated | Neutered | Placeholder | Female | Male | MutagenApplied | Divider } } \ No newline at end of file diff --git a/ARKBreedingStats/species/Species.cs b/ARKBreedingStats/species/Species.cs index f9be2300..a2f1b1c0 100644 --- a/ARKBreedingStats/species/Species.cs +++ b/ARKBreedingStats/species/Species.cs @@ -199,18 +199,19 @@ private void Initialize(StreamingContext context) /// public void InitializeNames() { + string variantInfoForName = null; if (variants != null && variants.Any()) { VariantInfo = string.Join(", ", variants); + variantInfoForName = string.Join(", ", variants.Where(v => !name.Contains(v))); } - DescriptiveName = name + (string.IsNullOrEmpty(VariantInfo) ? string.Empty : " (" + VariantInfo + ")"); + DescriptiveName = name + (string.IsNullOrEmpty(variantInfoForName) ? string.Empty : " (" + variantInfoForName + ")"); string modSuffix = string.IsNullOrEmpty(_mod?.title) ? string.Empty : _mod.title; DescriptiveNameAndMod = DescriptiveName + (string.IsNullOrEmpty(modSuffix) ? string.Empty : " (" + modSuffix + ")"); SortName = DescriptiveNameAndMod; } - /// /// Sets the ArkColor objects for the natural occurring colors. Call after colors are loaded or changed by loading mods. /// diff --git a/ARKBreedingStats/uiControls/dhmsInput.cs b/ARKBreedingStats/uiControls/dhmsInput.cs index 0622430e..aceaefa6 100644 --- a/ARKBreedingStats/uiControls/dhmsInput.cs +++ b/ARKBreedingStats/uiControls/dhmsInput.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Text.RegularExpressions; using System.Windows.Forms; @@ -13,77 +12,92 @@ public partial class dhmsInput : UserControl public event ValueChangedEventHandler ValueChanged; public bool changed; - private bool change; + private bool _change; public dhmsInput() { InitializeComponent(); ts = TimeSpan.Zero; changed = false; - change = true; + _change = true; + + mTBD.MouseWheel += (s, e) => ChangeValue((TextBox)s, Math.Sign(e.Delta)); + mTBH.MouseWheel += (s, e) => ChangeValue((TextBox)s, Math.Sign(e.Delta)); + mTBM.MouseWheel += (s, e) => ChangeValue((TextBox)s, Math.Sign(e.Delta) * 5); + mTBS.MouseWheel += (s, e) => ChangeValue((TextBox)s, Math.Sign(e.Delta) * 5); } private void mTB_KeyUp(object sender, KeyEventArgs e) { TextBox input = (TextBox)sender; - if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Right) + switch (e.KeyCode) { - int i = 0; - if (input == mTBH) - { - i = 1; - } - else if (input == mTBM) - { - i = 2; - } - else if (input == mTBS) - { - i = 3; - } + case Keys.Left: + case Keys.Right: + { + int i = 0; + if (input == mTBH) + { + i = 1; + } + else if (input == mTBM) + { + i = 2; + } + else if (input == mTBS) + { + i = 3; + } - List inputs = new List { mTBD, mTBH, mTBM, mTBS }; + var inputs = new TextBox[] { mTBD, mTBH, mTBM, mTBS }; - if (e.KeyCode == Keys.Left) i--; - else i++; + if (e.KeyCode == Keys.Left) i--; + else i++; - if (i < 0) i = 3; - else if (i > 3) i = 0; + if (i < 0) i = 3; + else if (i > 3) i = 0; - inputs[i].Focus(); - } - else if (e.KeyCode == Keys.Up) - { - int.TryParse(input.Text, out int i); - input.Text = (++i).ToString("D2"); - input.SelectAll(); + inputs[i].Focus(); + break; + } + case Keys.Up: + { + ChangeValue(input, 1); + break; + } + case Keys.Down: + { + ChangeValue(input, -1); + break; + } + default: + input.Text = RegexNonNumbers.Replace(input.Text, string.Empty); + break; } - else if (e.KeyCode == Keys.Down) - { - int.TryParse(input.Text, out int i); - i--; - if (i < 0) i = 0; - input.Text = i.ToString("D2"); + } + + private static readonly Regex RegexNonNumbers = new Regex(@"\D", RegexOptions.Compiled); + + private void ChangeValue(TextBox input, int valueChange, bool selectAfterChange = true) + { + int.TryParse(input.Text, out var v); + v += valueChange; + if (v < 0) v = 0; + input.Text = v.ToString("D2"); + if (selectAfterChange) input.SelectAll(); - } - else - { - input.Text = Regex.Replace(input.Text, @"\D", ""); - } } private void mTB_TextChanged(object sender, EventArgs e) { - if (change) - { - int.TryParse(mTBD.Text, out int d); - int.TryParse(mTBH.Text, out int h); - int.TryParse(mTBM.Text, out int m); - int.TryParse(mTBS.Text, out int s); - ts = new TimeSpan(d, h, m, s); - changed = true; - ValueChanged?.Invoke(this, ts); - } + if (!_change) return; + int.TryParse(mTBD.Text, out int d); + int.TryParse(mTBH.Text, out int h); + int.TryParse(mTBM.Text, out int m); + int.TryParse(mTBS.Text, out int s); + ts = new TimeSpan(d, h, m, s); + changed = true; + ValueChanged?.Invoke(this, ts); } public TimeSpan Timespan @@ -91,14 +105,14 @@ public TimeSpan Timespan get => ts; set { - change = false; + _change = false; ts = value.TotalSeconds >= 0 ? value : TimeSpan.Zero; mTBD.Text = ((int)Math.Floor(ts.TotalDays)).ToString("D2"); mTBH.Text = ts.Hours.ToString("D2"); mTBM.Text = ts.Minutes.ToString("D2"); mTBS.Text = ts.Seconds.ToString("D2"); changed = false; - change = true; + _change = true; } } diff --git a/ARKBreedingStats/utils/CreatureListSorter.cs b/ARKBreedingStats/utils/CreatureListSorter.cs index 4a196d6f..7f96c9c1 100644 --- a/ARKBreedingStats/utils/CreatureListSorter.cs +++ b/ARKBreedingStats/utils/CreatureListSorter.cs @@ -34,7 +34,7 @@ public class CreatureListSorter /// /// Sort list by given column index. If the columnIndex is -1, use last sorting. /// - public Creature[] DoSort(IEnumerable list, int columnIndex = -1, Species[] orderBySpecies = null) + public IEnumerable DoSort(IEnumerable list, int columnIndex = -1, Species[] orderBySpecies = null) { if (list == null) return null; @@ -54,7 +54,7 @@ public Creature[] DoSort(IEnumerable list, int columnIndex = -1, Speci } // Perform the sort with these new sort options. - return OrderList(list, orderBySpecies).ToArray(); + return OrderList(list, orderBySpecies); } private IEnumerable OrderList(IEnumerable list, Species[] orderBySpecies = null) diff --git a/ASB-Updater/ASB Updater.csproj b/ASB-Updater/ASB Updater.csproj index 00eb2c59..b349ad76 100644 --- a/ASB-Updater/ASB Updater.csproj +++ b/ASB-Updater/ASB Updater.csproj @@ -142,7 +142,7 @@ all - 13.0.1 + 13.0.2 4.3.0