Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
cadaei committed May 14, 2020
2 parents e1a3ea9 + 0c83b02 commit 177f131
Show file tree
Hide file tree
Showing 28 changed files with 697 additions and 483 deletions.
1 change: 1 addition & 0 deletions ARKBreedingStats.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/TYPE_DECLARATION_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
2 changes: 1 addition & 1 deletion ARKBreedingStats/BreedingPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ private void listViewSpeciesBP_SelectedIndexChanged(object sender, EventArgs e)
|| listViewSpeciesBP.SelectedItems[0].Text != currentSpecies.DescriptiveNameAndMod)
)
{
SetGlobalSpecies?.Invoke((Species)((ListViewItem)listViewSpeciesBP.SelectedItems[0]).Tag);
SetGlobalSpecies?.Invoke((Species)listViewSpeciesBP.SelectedItems[0].Tag);
}
}

Expand Down
210 changes: 118 additions & 92 deletions ARKBreedingStats/CreatureInfoInput.Designer.cs

Large diffs are not rendered by default.

17 changes: 16 additions & 1 deletion ARKBreedingStats/CreatureInfoInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public int[] RegionColors
{
if (selectedSpecies != null)
{
regionColorIDs = (int[])value.Clone();
regionColorIDs = (int[])value?.Clone() ?? new int[6];
regionColorChooser1.SetSpecies(selectedSpecies, regionColorIDs);
}
}
Expand Down Expand Up @@ -517,6 +517,7 @@ private void SetCreatureData(Creature cr)
cr.tribe = CreatureTribe;
cr.server = CreatureServer;
cr.flags = CreatureFlags;
cr.colors = RegionColors;
}

private void textBoxOwner_Leave(object sender, EventArgs e)
Expand Down Expand Up @@ -649,6 +650,20 @@ private void NudMutations_ValueChanged(object sender, EventArgs e)
CalculateNewMutations();
}

private void BtSaveOTSPreset_Click(object sender, EventArgs e)
{
Properties.Settings.Default.DefaultOwnerName = CreatureOwner;
Properties.Settings.Default.DefaultTribeName = CreatureTribe;
Properties.Settings.Default.DefaultServerName = CreatureServer;
}

private void BtApplyOTSPreset_Click(object sender, EventArgs e)
{
CreatureOwner = Properties.Settings.Default.DefaultOwnerName;
CreatureTribe = Properties.Settings.Default.DefaultTribeName;
CreatureServer = Properties.Settings.Default.DefaultServerName;
}

internal void Clear()
{
textBoxName.Clear();
Expand Down
18 changes: 9 additions & 9 deletions ARKBreedingStats/Form1.Designer.cs

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

14 changes: 6 additions & 8 deletions ARKBreedingStats/Form1.collection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,7 @@ private bool LoadCollectionFile(string filePath, bool keepCurrentCreatures = fal
return false;
}

List<Creature> oldCreatures = null;
if (keepCurrentCreatures)
oldCreatures = creatureCollection.creatures;

// for the case the collectionfile has no multipliers, keep the current ones
ServerMultipliers oldMultipliers = creatureCollection.serverMultipliers;
CreatureCollection previouslyLoadedCreatureCollection = creatureCollection;

// Wait until the file is readable
const int numberOfRetries = 5;
Expand Down Expand Up @@ -378,7 +373,7 @@ private bool LoadCollectionFile(string filePath, bool keepCurrentCreatures = fal

if (creatureCollection.serverMultipliers == null)
{
creatureCollection.serverMultipliers = oldMultipliers ?? Values.V.serverMultipliersPresets.GetPreset(ServerMultipliersPresets.OFFICIAL);
creatureCollection.serverMultipliers = previouslyLoadedCreatureCollection.serverMultipliers ?? Values.V.serverMultipliersPresets.GetPreset(ServerMultipliersPresets.OFFICIAL);
}

if (speciesSelector1.LastSpecies != null && speciesSelector1.LastSpecies.Length > 0)
Expand All @@ -393,7 +388,10 @@ private bool LoadCollectionFile(string filePath, bool keepCurrentCreatures = fal
bool creatureWasAdded = false;

if (keepCurrentCreatures)
creatureWasAdded = creatureCollection.MergeCreatureList(oldCreatures);
{
creatureWasAdded = previouslyLoadedCreatureCollection.MergeCreatureList(creatureCollection.creatures);
creatureCollection = previouslyLoadedCreatureCollection;
}
else
{
currentFileName = filePath;
Expand Down
32 changes: 21 additions & 11 deletions ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ private void Form1_Load(object sender, EventArgs e)
// default owner and tribe
creatureInfoInputExtractor.CreatureOwner = Properties.Settings.Default.DefaultOwnerName;
creatureInfoInputExtractor.CreatureTribe = Properties.Settings.Default.DefaultTribeName;
creatureInfoInputExtractor.CreatureServer = Properties.Settings.Default.DefaultServerName;
creatureInfoInputExtractor.OwnerLock = Properties.Settings.Default.OwnerNameLocked;
creatureInfoInputExtractor.TribeLock = Properties.Settings.Default.TribeNameLocked;

Expand Down Expand Up @@ -630,7 +631,7 @@ private void SpeciesSelector1_onSpeciesChanged(bool speciesChanged)
else if (tabControlMain.SelectedTab == tabPageLibrary)
{
if (Properties.Settings.Default.ApplyGlobalSpeciesToLibrary)
listBoxSpeciesLib.SelectedIndex = listBoxSpeciesLib.Items.IndexOf(species);
listBoxSpeciesLib.SelectedItem = species;
}
else if (tabControlMain.SelectedTab == tabPageTaming)
{
Expand Down Expand Up @@ -757,7 +758,7 @@ private void ApplySettingsToValues()
ATImportExportedFolderLocation aTImportExportedFolderLocation = ATImportExportedFolderLocation.CreateFromString(f);
string menuItemHeader = string.IsNullOrEmpty(aTImportExportedFolderLocation.ConvenientName) ? "<unnamed>" : aTImportExportedFolderLocation.ConvenientName;
ToolStripMenuItem tsmi = new ToolStripMenuItem(menuItemHeader
+ (string.IsNullOrEmpty(aTImportExportedFolderLocation.OwnerSuffix) ? "" : " - " + aTImportExportedFolderLocation.OwnerSuffix))
+ (string.IsNullOrEmpty(aTImportExportedFolderLocation.OwnerSuffix) ? string.Empty : " - " + aTImportExportedFolderLocation.OwnerSuffix))
{
Tag = aTImportExportedFolderLocation
};
Expand Down Expand Up @@ -786,7 +787,7 @@ private void ApplySettingsToValues()
{
Tag = atImportFileLocation
};
tsmi.Click += RunSavegameImport;
tsmi.Click += SavegameImportClick;
importingFromSavegameToolStripMenuItem.DropDownItems.Add(tsmi);
}
}
Expand Down Expand Up @@ -1195,8 +1196,11 @@ private void LoadListViewSettings(ListView lv, string widthName, string indicesN
// load column display indices
if (Properties.Settings.Default[indicesName] is int[] colIndices)
{
for (int c = 0; c < colIndices.Length && c < lv.Columns.Count; c++)
lv.Columns[c].DisplayIndex = colIndices[c];
// indices have to be set increasingly, or they will "push" other values up
var colIndicesOrdered = colIndices.Select((i, c) => (columnIndex: c, displayIndex: i))
.OrderBy(c => c.displayIndex).ToArray();
for (int c = 0; c < colIndicesOrdered.Length && c < lv.Columns.Count; c++)
lv.Columns[colIndicesOrdered[c].columnIndex].DisplayIndex = colIndicesOrdered[c].displayIndex;
}

// load listviewLibSorting
Expand Down Expand Up @@ -1248,9 +1252,7 @@ private void Form1_FormClosed(object sender, FormClosedEventArgs e)
// save onlyNonMutatedInBreedingPlanner
Properties.Settings.Default.MutationLimitBreedingPlanner = breedingPlan1.MutationLimit;

// save default owner and tribe name and if they're locked
Properties.Settings.Default.DefaultOwnerName = creatureInfoInputExtractor.CreatureOwner;
Properties.Settings.Default.DefaultTribeName = creatureInfoInputExtractor.CreatureTribe;
// save locked state of owner and tribe name
Properties.Settings.Default.OwnerNameLocked = creatureInfoInputExtractor.OwnerLock;
Properties.Settings.Default.TribeNameLocked = creatureInfoInputExtractor.TribeLock;

Expand Down Expand Up @@ -1391,6 +1393,7 @@ private void checkBoxUseFiltersInTopStatCalculation_CheckedChanged(object sender

private void listBoxSpeciesLib_SelectedIndexChanged(object sender, EventArgs e)
{
SetSpecies(listBoxSpeciesLib.SelectedItem as Species);
FilterLib();
}

Expand Down Expand Up @@ -3254,6 +3257,12 @@ private void Form1_DragDrop(object sender, DragEventArgs e)
LoadCollectionFile(filePath);
}
}
else if (ext == ".ark")
{
if (MessageBox.Show($"Import all of the creatures in the following ARK save file to the currently opened library?\n{filePath}",
"Import savefile?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
RunSavegameImport(new ATImportFileLocation(null, null, filePath));
}
else
DoOCR(files[0]);
}
Expand Down Expand Up @@ -3345,10 +3354,11 @@ private void openJsonDataFolderToolStripMenuItem_Click(object sender, EventArgs
private void ReloadNamePatternCustomReplacings(PatternEditor pe = null)
{
string filePath = FileService.GetJsonPath(FileService.CustomReplacingsNamePattern);
if (!FileService.LoadJSONFile(filePath, out customReplacingsNamingPattern, out string error))
string errorMessage = null;
if (!File.Exists(filePath) || !FileService.LoadJSONFile(filePath, out customReplacingsNamingPattern, out errorMessage))
{
if (!string.IsNullOrEmpty(error))
MessageBox.Show(error, "ASB Custom replacings file loading error", MessageBoxButtons.OK, MessageBoxIcon.Error);
if (!string.IsNullOrEmpty(errorMessage))
MessageBox.Show(errorMessage, "ASB Custom replacings file loading error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (pe != null) pe.SetCustomReplacings(customReplacingsNamingPattern);
}
Expand Down
14 changes: 10 additions & 4 deletions ARKBreedingStats/Form1.importSave.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -17,12 +16,19 @@ namespace ARKBreedingStats
{
public partial class Form1
{
private async void RunSavegameImport(object sender, EventArgs e)
private void SavegameImportClick(object sender, EventArgs e)
{
RunSavegameImport((ATImportFileLocation)((ToolStripMenuItem)sender).Tag);
}

/// <summary>
/// Imports the creatures from the given savegame. ftp is possible.
/// </summary>
/// <param name="atImportFileLocation"></param>
private async void RunSavegameImport(ATImportFileLocation atImportFileLocation)
{
try
{
ATImportFileLocation atImportFileLocation = (ATImportFileLocation)((ToolStripMenuItem)sender).Tag;

string workingCopyfilename = Properties.Settings.Default.savegameExtractionPath;

// working dir not configured? use temp dir
Expand Down
9 changes: 4 additions & 5 deletions ARKBreedingStats/Form1.library.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void AddCreatureToCollection(bool fromExtractor = true, long motherArkId
&& creatureCollection.DeletedCreatureGuids.Contains(creature.guid))
creatureCollection.DeletedCreatureGuids.RemoveAll(guid => guid == creature.guid);

creatureCollection.MergeCreatureList(new List<Creature> { creature }, update: true);
creatureCollection.MergeCreatureList(new List<Creature> { creature });

// if creature already exists by guid, use the already existing creature object for the parent assignments
creature = creatureCollection.creatures.SingleOrDefault(c => c.guid == creature.guid) ?? creature;
Expand Down Expand Up @@ -894,7 +894,7 @@ private void CooldownColors(Creature c, out Color forecolor, out Color backcolor

private void listView_ColumnClick(object sender, ColumnClickEventArgs e)
{
ListViewColumnSorter.doSort((ListView)sender, e.Column);
ListViewColumnSorter.DoSort((ListView)sender, e.Column);
}

// onlibrarychange
Expand Down Expand Up @@ -1046,10 +1046,9 @@ private void FilterLib()
// if only one species should be shown adjust statnames if the selected species is a glow-species
bool chargeStatsHeaders = false;
if (listBoxSpeciesLib.SelectedIndex > 0
&& listBoxSpeciesLib.SelectedItem.GetType() == typeof(Species))
&& listBoxSpeciesLib.SelectedItem is Species selectedSpecies)
{
Species selectedSpecies = listBoxSpeciesLib.SelectedItem as Species;
filteredList = filteredList.Where(c => c.Species == selectedSpecies);
filteredList = filteredList.Where(c => c.Species.Equals(selectedSpecies));
if (selectedSpecies.IsGlowSpecies)
chargeStatsHeaders = true;
}
Expand Down
Loading

0 comments on commit 177f131

Please sign in to comment.