From 6976d0feeaf14e6bc53794d16d1c692426f1545f Mon Sep 17 00:00:00 2001 From: cadon Date: Fri, 5 Jan 2024 18:53:45 +0100 Subject: [PATCH 1/7] fix exception for species without eating (fixes #1336) --- ARKBreedingStats/TamingControl.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ARKBreedingStats/TamingControl.cs b/ARKBreedingStats/TamingControl.cs index 6a378a6d..5541b86c 100644 --- a/ARKBreedingStats/TamingControl.cs +++ b/ARKBreedingStats/TamingControl.cs @@ -401,6 +401,12 @@ private void UpdateTamingData() /// private void UpdateTimeToFeedAll(bool enoughFood = true) { + if (_foodDepletion == 0) + { + lbTimeUntilStarving.Text = string.Empty; + return; + } + double hunger = (double)(nudTotalFood.Value - nudCurrentFood.Value); if (hunger < 0) hunger = 0; if (hunger > _neededHunger) hunger = _neededHunger; From 084ae9449daee6b487ed544886ca379eaae3a1c7 Mon Sep 17 00:00:00 2001 From: cadon Date: Fri, 5 Jan 2024 21:33:36 +0100 Subject: [PATCH 2/7] ask to overwrite if moving export files exist --- .../importExported/ExportedCreatureList.cs | 44 ++++++++++++++----- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/ARKBreedingStats/importExported/ExportedCreatureList.cs b/ARKBreedingStats/importExported/ExportedCreatureList.cs index 3ae1dc2d..a1dc7db0 100644 --- a/ARKBreedingStats/importExported/ExportedCreatureList.cs +++ b/ARKBreedingStats/importExported/ExportedCreatureList.cs @@ -296,22 +296,46 @@ private void moveAllImportedFilesToimportedSubfolderToolStripMenuItem_Click(obje return; } + bool overwriteAllFiles = false; int movedFilesCount = 0; foreach (var ecc in _eccs) { - if (ecc.Status == ExportedCreatureControl.ImportStatus.JustImported || ecc.Status == ExportedCreatureControl.ImportStatus.OldImported) + if (ecc.Status != ExportedCreatureControl.ImportStatus.JustImported && + ecc.Status != ExportedCreatureControl.ImportStatus.OldImported) continue; + + var destFilePath = Path.Combine(importedPath, Path.GetFileName(ecc.exportedFile)); + var destFileExists = File.Exists(destFilePath); + if (!overwriteAllFiles && destFileExists) { - try - { - File.Move(ecc.exportedFile, Path.Combine(importedPath, Path.GetFileName(ecc.exportedFile))); - movedFilesCount++; - ecc.Dispose(); - } - catch (Exception ex) + var doBreak = false; + switch (MessageBox.Show($"The file{Environment.NewLine}{destFilePath}{Environment.NewLine}already exists. Overwrite?", "Overwrite file?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning)) { - MessageBoxes.ExceptionMessageBox(ex, $"The file\n{ecc.exportedFile}\ncould not be moved. The following files will not be moved either.", "Error moving file"); - break; + case DialogResult.Cancel: + doBreak = true; + break; + case DialogResult.No: + continue; + case DialogResult.Yes: + overwriteAllFiles = MessageBox.Show( + $"Overwrite all already existing export files in the folder{Environment.NewLine}{importedPath}?", + "Overwrite all files?", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == + DialogResult.Yes; + break; } + if (doBreak) break; + } + + try + { + if (destFileExists) File.Delete(destFilePath); + File.Move(ecc.exportedFile, destFilePath); + movedFilesCount++; + ecc.Dispose(); + } + catch (Exception ex) + { + MessageBoxes.ExceptionMessageBox(ex, $"The file\n{ecc.exportedFile}\ncould not be moved. The following files will not be moved either.", "Error moving file"); + break; } } From aa897d7cace8b5fdd98585e967027b2244c7478e Mon Sep 17 00:00:00 2001 From: cadon Date: Fri, 5 Jan 2024 21:38:07 +0100 Subject: [PATCH 3/7] consider all unimported creatres on bulk import --- ARKBreedingStats/importExported/ExportedCreatureList.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ARKBreedingStats/importExported/ExportedCreatureList.cs b/ARKBreedingStats/importExported/ExportedCreatureList.cs index a1dc7db0..e801122c 100644 --- a/ARKBreedingStats/importExported/ExportedCreatureList.cs +++ b/ARKBreedingStats/importExported/ExportedCreatureList.cs @@ -269,9 +269,10 @@ private void ImportAll(bool onlyUnimported) UpdateVisualData?.Invoke(false); foreach (var ecc in _eccs) { - if (ecc.Visible - && (!onlyUnimported || ecc.Status == ExportedCreatureControl.ImportStatus.NotImported)) - ecc.extractAndAddToLibrary(false); + if (!ecc.Visible + || (onlyUnimported && ecc.Status != ExportedCreatureControl.ImportStatus.NotImported && ecc.Status != ExportedCreatureControl.ImportStatus.NeedsLevelChoosing)) + continue; + ecc.extractAndAddToLibrary(false); } UpdateStatusBarLabelAndControls(); UpdateVisualData?.Invoke(true); From e63fa8c2f492d5cf2edc3b965cf57f04f3518386 Mon Sep 17 00:00:00 2001 From: cadon Date: Sun, 7 Jan 2024 19:33:04 +0100 Subject: [PATCH 4/7] ignore multiple redundant fileWatcher events --- ARKBreedingStats/Form1.collection.cs | 4 ++-- ARKBreedingStats/Form1.importExported.cs | 2 +- .../importExported/FileWatcherExports.cs | 12 +++++++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ARKBreedingStats/Form1.collection.cs b/ARKBreedingStats/Form1.collection.cs index f4a9c5d7..c938fc06 100644 --- a/ARKBreedingStats/Form1.collection.cs +++ b/ARKBreedingStats/Form1.collection.cs @@ -843,8 +843,8 @@ private Creature ImportExportGunFiles(string[] filePaths, out bool creatureAdded var serverMultiplierFilePath = Path.Combine(Path.GetDirectoryName(lastCreatureFilePath), "Servers", serverMultipliersHash + ".json"); if (!File.Exists(serverMultiplierFilePath)) serverMultiplierFilePath = Path.Combine(Path.GetDirectoryName(lastCreatureFilePath), "Servers", serverMultipliersHash + ".sav"); - - multipliersImportSuccessful = ImportExportGun.ImportServerMultipliers(_creatureCollection, serverMultiplierFilePath, serverMultipliersHash, out serverImportResult); + if (File.Exists(serverMultiplierFilePath)) + multipliersImportSuccessful = ImportExportGun.ImportServerMultipliers(_creatureCollection, serverMultiplierFilePath, serverMultipliersHash, out serverImportResult); } if (multipliersImportSuccessful == true) diff --git a/ARKBreedingStats/Form1.importExported.cs b/ARKBreedingStats/Form1.importExported.cs index 75fbe8cf..2ae5f5dd 100644 --- a/ARKBreedingStats/Form1.importExported.cs +++ b/ARKBreedingStats/Form1.importExported.cs @@ -297,7 +297,7 @@ private Creature ImportExportedAddIfPossible(string filePath) { if (alreadyExists) SoundFeedback.BeepSignal(SoundFeedback.FeedbackSounds.Indifferent); - if (hasNewTopLevels) + else if (hasNewTopLevels) SoundFeedback.BeepSignal(SoundFeedback.FeedbackSounds.Great); else if (hasTopLevels) SoundFeedback.BeepSignal(SoundFeedback.FeedbackSounds.Good); diff --git a/ARKBreedingStats/importExported/FileWatcherExports.cs b/ARKBreedingStats/importExported/FileWatcherExports.cs index f353f016..8ad4d3ec 100644 --- a/ARKBreedingStats/importExported/FileWatcherExports.cs +++ b/ARKBreedingStats/importExported/FileWatcherExports.cs @@ -8,6 +8,8 @@ public class FileWatcherExports : IDisposable { private readonly FileSystemWatcher _fileWatcherExport; private readonly Action _callbackNewFile; + private string _lastFilePath; + private DateTime _lastChangedTime; public FileWatcherExports(string folderToWatch, Action callbackNewFile, Control synchronizingObject) { @@ -41,7 +43,15 @@ public bool Watching private void OnChanged(object source, FileSystemEventArgs e) { - _callbackNewFile?.Invoke(e.FullPath, this); + if (_callbackNewFile == null) return; + var filePath = e.FullPath; + var lastWriteTime = new FileInfo(filePath).LastWriteTimeUtc; + if (filePath == _lastFilePath && lastWriteTime == _lastChangedTime) + return; // event was already processed. Some file changes raise multiple events + + _lastFilePath = filePath; + _lastChangedTime = lastWriteTime; + _callbackNewFile.Invoke(filePath, this); } #region Disposing From 9625b79b0e8c4cc319cbd305a7810985c8cb901d Mon Sep 17 00:00:00 2001 From: cadon Date: Tue, 9 Jan 2024 22:10:41 +0100 Subject: [PATCH 5/7] fix null exception for default imprinting values --- ARKBreedingStats/species/Species.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ARKBreedingStats/species/Species.cs b/ARKBreedingStats/species/Species.cs index ab707c77..658ccaac 100644 --- a/ARKBreedingStats/species/Species.cs +++ b/ARKBreedingStats/species/Species.cs @@ -164,7 +164,10 @@ private void Initialize(StreamingContext _) _skipWildLevelStatsWithServerSettings = skipWildLevelStats; usedStats = 0; - StatImprintMultipliers = statImprintMult ?? StatImprintMultipliersDefaultAse.ToArray(); + if (statImprintMult == null) + statImprintMult = StatImprintMultipliersDefaultAse; + + StatImprintMultipliers = statImprintMult.ToArray(); if (mutationMult == null) mutationMult = MutationMultipliersDefault; double[][] completeRaws = new double[Stats.StatsCount][]; @@ -325,7 +328,7 @@ public void SetCustomImprintingMultipliers(double?[] overrides) } if (isEqual) statImprintMultOverride = null; else statImprintMultOverride = overrideValues; - StatImprintMultipliers = statImprintMultOverride ?? statImprintMult; + StatImprintMultipliers = statImprintMultOverride ?? statImprintMult.ToArray(); } /// @@ -340,7 +343,7 @@ public void ApplyCanLevelOptions(bool canLevelSpeedStat, bool canFlyerLevelSpeed { DisplayedStats |= statBit; StatImprintMultipliers[Stats.SpeedMultiplier] = - (statImprintMultOverride ?? statImprintMult ?? StatImprintMultipliersDefaultAse)[Stats.SpeedMultiplier]; + (statImprintMultOverride ?? statImprintMult)[Stats.SpeedMultiplier]; _skipWildLevelStatsWithServerSettings &= ~statBit; } else @@ -433,7 +436,7 @@ public void LoadOverrides(Species overrides) if (overrides.DisplayedStats != 0) DisplayedStats = overrides.DisplayedStats; if (overrides.skipWildLevelStats != 0) skipWildLevelStats = overrides.skipWildLevelStats; if (overrides.TamedBaseHealthMultiplier != null) TamedBaseHealthMultiplier = overrides.TamedBaseHealthMultiplier; - if (overrides.statImprintMult != null) statImprintMult = overrides.statImprintMult; + if (overrides.statImprintMult != null) statImprintMult = overrides.statImprintMult.ToArray(); if (overrides.mutationMult != null) mutationMult = overrides.mutationMult; if (overrides.colors != null) colors = overrides.colors; if (overrides.taming != null) taming = overrides.taming; From 5383951a5706ed20897f2298d5ab8988ad5fd9ba Mon Sep 17 00:00:00 2001 From: cadon Date: Tue, 9 Jan 2024 23:00:24 +0100 Subject: [PATCH 6/7] possible null exception fix --- ARKBreedingStats/Form1.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ARKBreedingStats/Form1.cs b/ARKBreedingStats/Form1.cs index 7cc99510..4e2dd11b 100644 --- a/ARKBreedingStats/Form1.cs +++ b/ARKBreedingStats/Form1.cs @@ -3517,7 +3517,7 @@ private void GenerateCreatureNames() { var cr = _creaturesDisplayed[i]; - if (sameSpecies == null || sameSpecies[0].Species != cr.Species) + if (sameSpecies?.FirstOrDefault()?.Species != cr.Species) sameSpecies = _creatureCollection.creatures.Where(c => c.Species == cr.Species).ToArray(); // set new name From d667ed942563a59fab56da43a930785db23ce9bd Mon Sep 17 00:00:00 2001 From: cadon Date: Tue, 9 Jan 2024 23:01:30 +0100 Subject: [PATCH 7/7] 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 eec1282a..50ab4ac2 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.59.5.0")] +[assembly: AssemblyFileVersion("0.59.6.0")] [assembly: NeutralResourcesLanguage("en")] diff --git a/ARKBreedingStats/_manifest.json b/ARKBreedingStats/_manifest.json index b3cec913..66fe0e5f 100644 --- a/ARKBreedingStats/_manifest.json +++ b/ARKBreedingStats/_manifest.json @@ -4,7 +4,7 @@ "ARK Smart Breeding": { "Id": "ARK Smart Breeding", "Category": "main", - "version": "0.59.5.0" + "version": "0.59.6.0" }, "SpeciesColorImages": { "Id": "SpeciesColorImages",