Skip to content

Commit

Permalink
automatically move and use existing species images
Browse files Browse the repository at this point in the history
  • Loading branch information
cadon committed May 18, 2021
1 parent f8da82b commit b623b5f
Showing 1 changed file with 39 additions and 10 deletions.
49 changes: 39 additions & 10 deletions ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,16 +292,6 @@ private void Form1_Load(object sender, EventArgs e)

CreatureColored.InitializeSpeciesImageLocation();

// Set up the file watcher
if (Properties.Settings.Default.syncCollection)
_fileSync = new FileSync(_currentFileName, CollectionChanged);

// exports file watcher
bool enableExportWatcher = Utils.GetFirstImportExportFolder(out string exportFolderDefault)
&& Properties.Settings.Default.AutoImportExportedCreatures;
_fileWatcherExports = new FileWatcherExports(exportFolderDefault, ImportExportedAddIfPossible_WatcherThread,
enableExportWatcher);

if (!LoadStatAndKibbleValues(applySettings: false).statValuesLoaded || !Values.V.species.Any())
{
MessageBoxes.ShowMessageBox(Loc.S("valuesFileLoadingError"),
Expand Down Expand Up @@ -381,6 +371,8 @@ private void Form1_Load(object sender, EventArgs e)
// check for updates
if (DateTime.Now.AddHours(-20) > Properties.Settings.Default.lastUpdateCheck)
{
MoveSpeciesImagesToNewFolder();

bool displayModuleWindow = false;
bool selectDefaultImages = false;
if (!Properties.Settings.Default.AlreadyAskedToDownloadSpeciesImageFiles)
Expand Down Expand Up @@ -443,6 +435,17 @@ private void Form1_Load(object sender, EventArgs e)
}

_updateExtractorVisualData = true;

// Set up the file watcher
if (Properties.Settings.Default.syncCollection)
_fileSync = new FileSync(_currentFileName, CollectionChanged);

// exports file watcher
bool enableExportWatcher = Utils.GetFirstImportExportFolder(out string exportFolderDefault)
&& Properties.Settings.Default.AutoImportExportedCreatures;
_fileWatcherExports = new FileWatcherExports(exportFolderDefault, ImportExportedAddIfPossible_WatcherThread,
enableExportWatcher);

_timerGlobal.Start();
}

Expand Down Expand Up @@ -3536,5 +3539,31 @@ void InitializeImages()
}
}
}

/// <summary>
/// If the user has downloaded the species images already but not in the new folder, move them.
/// This method can probably be removed at 07-2021.
/// </summary>
private void MoveSpeciesImagesToNewFolder()
{
var oldImagesFolder = FileService.GetPath("img");
var newImagesFolder = FileService.GetPath("images/speciesImages");
if (!Directory.Exists(oldImagesFolder)
|| Directory.Exists(newImagesFolder))
return;

try
{
Directory.Move(oldImagesFolder, newImagesFolder);

Properties.Settings.Default.SpeciesImagesFolder = "images/speciesImages";
CreatureColored.InitializeSpeciesImageLocation();
speciesSelector1.InitializeSpeciesImages(Values.V.species);
}
catch
{
// ignore
}
}
}
}

0 comments on commit b623b5f

Please sign in to comment.