Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
cadon committed Jan 9, 2024
2 parents 6f1680c + d667ed9 commit 8e96036
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 24 deletions.
4 changes: 2 additions & 2 deletions ARKBreedingStats/Form1.collection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/Form1.importExported.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]

6 changes: 6 additions & 0 deletions ARKBreedingStats/TamingControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,12 @@ private void UpdateTamingData()
/// </summary>
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;
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
51 changes: 38 additions & 13 deletions ARKBreedingStats/importExported/ExportedCreatureList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -296,22 +297,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;
}
}

Expand Down
12 changes: 11 additions & 1 deletion ARKBreedingStats/importExported/FileWatcherExports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class FileWatcherExports : IDisposable
{
private readonly FileSystemWatcher _fileWatcherExport;
private readonly Action<string, FileWatcherExports> _callbackNewFile;
private string _lastFilePath;
private DateTime _lastChangedTime;

public FileWatcherExports(string folderToWatch, Action<string, FileWatcherExports> callbackNewFile, Control synchronizingObject)
{
Expand Down Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions ARKBreedingStats/species/Species.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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][];
Expand Down Expand Up @@ -325,7 +328,7 @@ public void SetCustomImprintingMultipliers(double?[] overrides)
}
if (isEqual) statImprintMultOverride = null;
else statImprintMultOverride = overrideValues;
StatImprintMultipliers = statImprintMultOverride ?? statImprintMult;
StatImprintMultipliers = statImprintMultOverride ?? statImprintMult.ToArray();
}

/// <summary>
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8e96036

Please sign in to comment.