Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
cadaei committed Jun 14, 2020
2 parents 12508d9 + 7b50911 commit 9b97116
Show file tree
Hide file tree
Showing 26 changed files with 656 additions and 431 deletions.
2 changes: 2 additions & 0 deletions ARKBreedingStats/ARKBreedingStats.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -47,6 +48,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>ARKSmartBreeding.ico</ApplicationIcon>
Expand Down
1 change: 1 addition & 0 deletions ARKBreedingStats/AboutBox1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ private void linkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs
* hallipr (FTP savefile import)
* EmkioA (Cryopod import, listView tweaks)
* dunger (fixes)
* Myrmecoleon (extra species images)
Translations:
* French by Vykan and Yanuut
Expand Down
9 changes: 5 additions & 4 deletions ARKBreedingStats/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@
<setting name="inventoryCheckTimer" serializeAs="String">
<value>True</value>
</setting>
<setting name="LastImportFile" serializeAs="String">
<value />
</setting>
<setting name="showColorsInLibrary" serializeAs="String">
<value>True</value>
</setting>
Expand Down Expand Up @@ -294,7 +291,11 @@
<setting name="applyNamePatternOnAutoImportForNewCreatures" serializeAs="String">
<value>False</value>
</setting>
<setting name="AlreadyAskedToDownloadImageFiles" serializeAs="String">
<setting name="AlreadyAskedToDownloadImageFilesTropeognathus"
serializeAs="String">
<value>False</value>
</setting>
<setting name="LibrarySelectSelectedSpeciesOnLoad" serializeAs="String">
<value>False</value>
</setting>
</ARKBreedingStats.Properties.Settings>
Expand Down
422 changes: 287 additions & 135 deletions ARKBreedingStats/CreatureColored.cs

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions ARKBreedingStats/CreatureInfoInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,7 @@ public Species SelectedSpecies
dhmsInputGrown.Timespan = TimeSpan.Zero;
dhmsInputCooldown.Timespan = TimeSpan.Zero;
}
RegionColors = new int[6];
UpdateRegionColorImage();
RegionColors = null;
}
}

Expand Down
26 changes: 24 additions & 2 deletions ARKBreedingStats/FileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public static class FileService
public const string ArkDataJson = "ark_data.json";
public const string IgnoreSpeciesClasses = "ignoreSpeciesClasses.json";
public const string CustomReplacingsNamePattern = "customReplacings.json";
public const string ImageFolderName = "img";
public const string CacheFolderName = "cache";

public static readonly string ExeFilePath = new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath;
public static readonly string ExeLocation = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
Expand Down Expand Up @@ -154,7 +156,6 @@ public static bool TryCreateDirectory(string path, out string error)
/// <summary>
/// Tries to delete a file, doesn't throw an exception.
/// </summary>
/// <param name="filePath"></param>
public static bool TryDeleteFile(string filePath)
{
if (!File.Exists(filePath)) return false;
Expand All @@ -163,7 +164,28 @@ public static bool TryDeleteFile(string filePath)
File.Delete(filePath);
return true;
}
catch { }
catch
{
// ignored
}
return false;
}

/// <summary>
/// Tries to delete a file, doesn't throw an exception.
/// </summary>
public static bool TryDeleteFile(FileInfo fileInfo)
{
if (!fileInfo.Exists) return false;
try
{
fileInfo.Delete();
return true;
}
catch
{
// ignored
}
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 12 additions & 15 deletions ARKBreedingStats/Form1.collection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace ARKBreedingStats
{
public partial class Form1
{
private const string COLLECTION_FILE_EXTENSION = ".asb";
private const string CollectionFileExtension = ".asb";

private void NewCollection()
{
Expand Down Expand Up @@ -53,8 +53,7 @@ private void NewCollection()

UpdateCreatureListings();
creatureBoxListView.Clear();
Properties.Settings.Default.LastSaveFile = "";
Properties.Settings.Default.LastImportFile = "";
Properties.Settings.Default.LastSaveFile = null;
_currentFileName = null;
_fileSync.ChangeFile(_currentFileName);
SetCollectionChanged(false);
Expand Down Expand Up @@ -108,8 +107,8 @@ private void LoadCollection(bool add = false)
}
using (OpenFileDialog dlg = new OpenFileDialog
{
Filter = $"ASB Collection Files (*{COLLECTION_FILE_EXTENSION}; *.xml)|*{COLLECTION_FILE_EXTENSION};*.xml"
+ $"|ASB Collection File (*{COLLECTION_FILE_EXTENSION})|*{COLLECTION_FILE_EXTENSION}"
Filter = $"ASB Collection Files (*{CollectionFileExtension}; *.xml)|*{CollectionFileExtension};*.xml"
+ $"|ASB Collection File (*{CollectionFileExtension})|*{CollectionFileExtension}"
+ "|Old ASB Collection File(*.xml)| *.xml"
})
{
Expand Down Expand Up @@ -139,7 +138,7 @@ private void SaveNewCollection()
{
using (SaveFileDialog dlg = new SaveFileDialog
{
Filter = $"Creature Collection File (*{COLLECTION_FILE_EXTENSION})|*{COLLECTION_FILE_EXTENSION}"
Filter = $"Creature Collection File (*{CollectionFileExtension})|*{CollectionFileExtension}"
})
{
if (dlg.ShowDialog() == DialogResult.OK)
Expand Down Expand Up @@ -293,12 +292,12 @@ private bool LoadCollectionFile(string filePath, bool keepCurrentCreatures = fal

string fileNameWOExt = Path.Combine(Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath));
// check if new fileName is not yet existing
filePath = fileNameWOExt + COLLECTION_FILE_EXTENSION;
filePath = fileNameWOExt + CollectionFileExtension;
if (File.Exists(filePath))
{
int fi = 2;
while (File.Exists(fileNameWOExt + "_" + fi + COLLECTION_FILE_EXTENSION)) fi++;
filePath = fileNameWOExt + "_" + fi + COLLECTION_FILE_EXTENSION;
while (File.Exists(fileNameWOExt + "_" + fi + CollectionFileExtension)) fi++;
filePath = fileNameWOExt + "_" + fi + CollectionFileExtension;
}

// save converted library
Expand Down Expand Up @@ -437,12 +436,10 @@ private bool LoadCollectionFile(string filePath, bool keepCurrentCreatures = fal
speciesSelector1.SetSpecies(_creatureCollection.creatures[0].Species);

// set library species to what it was before loading
if (selectedlibrarySpecies == null
|| !_creatureCollection.creatures.Any(c => c.Species != null && c.Species.Equals(selectedlibrarySpecies))
)
selectedlibrarySpecies = speciesSelector1.SelectedSpecies;
if (selectedlibrarySpecies != null)
listBoxSpeciesLib.SelectedItem = selectedlibrarySpecies;
else if (Properties.Settings.Default.LibrarySelectSelectedSpeciesOnLoad)
listBoxSpeciesLib.SelectedItem = speciesSelector1.SelectedSpecies;

_filterListAllowed = true;
FilterLib();
Expand All @@ -467,7 +464,7 @@ private void SetCollectionChanged(bool changed, Species species = null)
{
if (changed)
{
if (species == null || pedigree1.creature != null && pedigree1.creature.Species == species)
if (species == null || pedigree1.SelectedSpecies == species)
_pedigreeNeedsUpdate = true;
if (species == null || breedingPlan1.CurrentSpecies == species)
breedingPlan1.breedingPlanNeedsUpdate = true;
Expand All @@ -480,7 +477,7 @@ private void SetCollectionChanged(bool changed, Species species = null)
{
string filenameWOExt = Path.GetFileNameWithoutExtension(_currentFileName);
string timeStamp = DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");
string backupFileName = filenameWOExt + "_backup_" + timeStamp + COLLECTION_FILE_EXTENSION;
string backupFileName = filenameWOExt + "_backup_" + timeStamp + CollectionFileExtension;
string backupFilePath = Path.Combine(Path.GetDirectoryName(_currentFileName), backupFileName);
File.Copy(_currentFileName, backupFilePath);
_lastAutoSaveBackup = DateTime.Now;
Expand Down
Loading

0 comments on commit 9b97116

Please sign in to comment.