Skip to content

Commit 112809e

Browse files
committed
Merge branch 'dev'
2 parents 44c717b + 8292dff commit 112809e

34 files changed

+3424
-2216
lines changed

ARKBreedingStats/App.config

+3
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,9 @@
526526
<setting name="LevelColorWindowRectangle" serializeAs="String">
527527
<value>200, 200, 1000, 650</value>
528528
</setting>
529+
<setting name="OverlayImportPattern" serializeAs="String">
530+
<value />
531+
</setting>
529532
</ARKBreedingStats.Properties.Settings>
530533
</userSettings>
531534
</configuration>

ARKBreedingStats/BreedingPlanning/BreedingPlan.Designer.cs

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ARKBreedingStats/BreedingPlanning/BreedingScore.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ public static List<BreedingPair> CalculateBreedingScores(Creature[] females, Cre
147147
if (female.levelsWild[s] == bestLevelsOfSpecies[s] && male.levelsWild[s] == bestLevelsOfSpecies[s])
148148
weightedExpectedStatLevel *= 1.142;
149149
}
150-
else if (bestLevelsOfSpecies[s] > 0)
150+
else if (bestLevelsOfSpecies[s] > 0 || statWeights[s] < 0)
151151
weightedExpectedStatLevel *= .01;
152152
}
153-
else if (breedingMode == BreedingMode.TopStatsConservative && bestLevelsOfSpecies[s] > 0)
153+
else if (breedingMode == BreedingMode.TopStatsConservative && (bestLevelsOfSpecies[s] > 0 || statWeights[s] < 0))
154154
{
155155
bool higherIsBetter = statWeights[s] >= 0;
156156
bestPossLevels[s] = (short)(higherIsBetter ? Math.Max(female.levelsWild[s], male.levelsWild[s]) : Math.Min(female.levelsWild[s], male.levelsWild[s]));

ARKBreedingStats/CreatureBox.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void SetParentLabel(Label l, string lbText = null, bool clickable = false)
148148
statsDisplay1.SetCreatureValues(_creature);
149149
labelNotes.Text = _creature.note;
150150
_tt.SetToolTip(labelNotes, _creature.note);
151-
labelSpecies.Text = _creature.Species.name;
151+
labelSpecies.Text = _creature.SpeciesName;
152152
pictureBox1.SetImageAndDisposeOld(CreatureColored.GetColoredCreature(_creature.colors, _creature.Species, _colorRegionUseds, creatureSex: _creature.sex));
153153
_tt.SetToolTip(pictureBox1, CreatureColored.RegionColorInfo(_creature.Species, _creature.colors)
154154
+ "\n\nClick to copy creature infos as image to the clipboard");

ARKBreedingStats/CreatureInfoInput.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,8 @@ public void OpenNamePatternEditor(Creature creature, TopLevels topLevels, Dictio
612612
{
613613
if (!parentListValid)
614614
ParentListRequested?.Invoke(this);
615-
using (var pe = new PatternEditor(creature, _sameSpecies, topLevels, ColorAlreadyExistingInformation, customReplacings, namingPatternIndex, reloadCallback, LibraryCreatureCount))
615+
using (var pe = new PatternEditor(creature, _sameSpecies, topLevels, ColorAlreadyExistingInformation,
616+
customReplacings, $"pattern {namingPatternIndex + 1}", Settings.Default.NamingPatterns?[namingPatternIndex], reloadCallback, LibraryCreatureCount))
616617
{
617618
if (pe.ShowDialog() == DialogResult.OK)
618619
{

ARKBreedingStats/Form1.collection.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ private void LoadCollection(bool add = false)
174174
{
175175
if (dlg.ShowDialog() == DialogResult.OK)
176176
{
177-
LoadCollectionFile(dlg.FileName, add);
177+
LoadCollectionFile(dlg.FileName, add, ignoreDeletionList: true);
178178
}
179179
}
180180
}
@@ -377,7 +377,7 @@ private bool KeepBackupFile(string currentSaveFilePath, int keepBackupFilesCount
377377
/// <param name="keepCurrentCreatures">add the creatures of the loaded file to the current ones</param>
378378
/// <param name="keepCurrentSelections">don't change the species selection or tab, use if a synchronized library is loaded</param>
379379
/// <returns></returns>
380-
private bool LoadCollectionFile(string filePath, bool keepCurrentCreatures = false, bool keepCurrentSelections = false, bool triggeredByFileWatcher = false)
380+
private bool LoadCollectionFile(string filePath, bool keepCurrentCreatures = false, bool keepCurrentSelections = false, bool triggeredByFileWatcher = false, bool ignoreDeletionList = false)
381381
{
382382
Species selectedSpecies = speciesSelector1.SelectedSpecies;
383383
Species selectedLibrarySpecies = listBoxSpeciesLib.SelectedItem as Species;
@@ -551,7 +551,7 @@ private bool LoadCollectionFile(string filePath, bool keepCurrentCreatures = fal
551551

552552
if (keepCurrentCreatures)
553553
{
554-
creatureWasAdded = previouslyLoadedCreatureCollection.MergeCreatureList(_creatureCollection.creatures, removeCreatures: _creatureCollection.DeletedCreatureGuids);
554+
creatureWasAdded = previouslyLoadedCreatureCollection.MergeCreatureList(_creatureCollection.creatures, removeCreatures: ignoreDeletionList ? null : _creatureCollection.DeletedCreatureGuids);
555555
_creatureCollection = previouslyLoadedCreatureCollection;
556556
}
557557
else

ARKBreedingStats/Form1.cs

+8-42
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ private void Form1_Load(object sender, EventArgs e)
335335
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
336336

337337
// check for updates
338-
MoveSpeciesImagesToNewFolder();
339338
if (DateTime.Now.AddHours(-20) > Properties.Settings.Default.lastUpdateCheck)
340339
{
341340
bool selectDefaultImagesIfNotYet = false;
@@ -1930,8 +1929,13 @@ private void pasteCreatureToolStripMenuItem_Click(object sender, EventArgs e)
19301929
/// </summary>
19311930
private void PasteCreatureFromClipboard()
19321931
{
1933-
var importedCreatures = ExportImportCreatures.ImportFromClipboard();
1934-
if (importedCreatures?.Any() != true) return;
1932+
var importedCreatures = ExportImportCreatures.ImportFromClipboard(out var errorText);
1933+
if (importedCreatures?.Any() != true)
1934+
{
1935+
if (!string.IsNullOrEmpty(errorText))
1936+
SetMessageLabelText(errorText, MessageBoxIcon.Error);
1937+
return;
1938+
}
19351939

19361940
foreach (var c in importedCreatures)
19371941
{
@@ -3160,7 +3164,7 @@ private void UpdateTempCreatureDropDown()
31603164
{
31613165
toolStripCBTempCreatures.Items.Clear();
31623166
foreach (CreatureValues cv in _creatureCollection.creaturesValues)
3163-
toolStripCBTempCreatures.Items.Add($"{cv.name} ({cv.Species?.name ?? "unknown species"}, Lv {cv.level})");
3167+
toolStripCBTempCreatures.Items.Add($"{cv.name} ({cv.Species?.Name(cv.sex) ?? "unknown species"}, Lv {cv.level})");
31643168
}
31653169

31663170
/// <summary>
@@ -3764,44 +3768,6 @@ void InitializeImages()
37643768
}
37653769
}
37663770

3767-
/// <summary>
3768-
/// If the user has downloaded the species images already but not in the new folder, move them.
3769-
/// This method can probably be removed at 08-2021.
3770-
/// </summary>
3771-
private void MoveSpeciesImagesToNewFolder()
3772-
{
3773-
const string relativeImageFolder = "images/speciesImages";
3774-
var oldImagesFolder = FileService.GetPath("img");
3775-
var newImagesFolder = FileService.GetPath(relativeImageFolder);
3776-
3777-
if (Directory.Exists(newImagesFolder))
3778-
{
3779-
// images are already moved
3780-
// check if the images folder is set correctly (currently there's only one option)
3781-
if (Properties.Settings.Default.SpeciesImagesFolder == relativeImageFolder) return;
3782-
3783-
Properties.Settings.Default.SpeciesImagesFolder = relativeImageFolder;
3784-
CreatureColored.InitializeSpeciesImageLocation();
3785-
speciesSelector1.InitializeSpeciesImages(Values.V.species);
3786-
return;
3787-
}
3788-
3789-
if (!Directory.Exists(oldImagesFolder)) return;
3790-
3791-
try
3792-
{
3793-
Directory.Move(oldImagesFolder, newImagesFolder);
3794-
3795-
Properties.Settings.Default.SpeciesImagesFolder = relativeImageFolder;
3796-
CreatureColored.InitializeSpeciesImageLocation();
3797-
speciesSelector1.InitializeSpeciesImages(Values.V.species);
3798-
}
3799-
catch
3800-
{
3801-
// ignore
3802-
}
3803-
}
3804-
38053771
private void Form1_KeyDown(object sender, KeyEventArgs e)
38063772
{
38073773
if (e.KeyCode != Keys.ControlKey

ARKBreedingStats/Form1.extractor.cs

+44-41
Original file line numberDiff line numberDiff line change
@@ -845,61 +845,64 @@ private void CopyExtractionToClipboard()
845845
bool header = true;
846846
bool table = MessageBox.Show("Results can be copied as own table or as a long table-row. Should it be copied as own table?",
847847
"Copy as own table?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
848-
if (_extractor.ValidResults && speciesSelector1.SelectedSpecies != null)
849-
{
850-
List<string> tsv = new List<string>();
851-
string rowLevel = speciesSelector1.SelectedSpecies.name + "\t\t";
852-
string rowValues = string.Empty;
853-
// if taming effectiveness is unique, display it, too
854-
string effString = string.Empty;
855-
double eff = _extractor.UniqueTamingEffectiveness();
856-
if (eff >= 0)
848+
if (!_extractor.ValidResults || speciesSelector1.SelectedSpecies == null)
849+
{
850+
SetMessageLabelText("Extraction not successful or no species selected.", MessageBoxIcon.Error);
851+
return;
852+
}
853+
854+
List<string> tsv = new List<string>();
855+
string rowLevel = speciesSelector1.SelectedSpecies.name + "\t\t";
856+
string rowValues = string.Empty;
857+
// if taming effectiveness is unique, display it, too
858+
string effString = string.Empty;
859+
double eff = _extractor.UniqueTamingEffectiveness();
860+
if (eff >= 0)
861+
{
862+
effString = "\tTamingEff:\t" + (100 * eff) + "%";
863+
}
864+
// header row
865+
if (table || header)
866+
{
867+
if (table)
857868
{
858-
effString = "\tTamingEff:\t" + (100 * eff) + "%";
869+
tsv.Add(speciesSelector1.SelectedSpecies.name + "\tLevel " + numericUpDownLevel.Value + effString);
870+
tsv.Add("Stat\tWildLevel\tDomLevel\tBreedingValue");
859871
}
860-
// headerrow
861-
if (table || header)
872+
else
862873
{
863-
if (table)
864-
{
865-
tsv.Add(speciesSelector1.SelectedSpecies.name + "\tLevel " + numericUpDownLevel.Value + effString);
866-
tsv.Add("Stat\tWildLevel\tDomLevel\tBreedingValue");
867-
}
868-
else
869-
{
870-
tsv.Add("Species\tName\tSex\tHP-Level\tSt-Level\tOx-Level\tFo-Level\tWe-Level\tDm-Level\tSp-Level\tTo-Level\tHP-Value\tSt-Value\tOx-Value\tFo-Value\tWe-Value\tDm-Value\tSp-Value\tTo-Value");
871-
}
874+
tsv.Add("Species\tName\tSex\tHP-Level\tSt-Level\tOx-Level\tFo-Level\tWe-Level\tDm-Level\tSp-Level\tTo-Level\tHP-Value\tSt-Value\tOx-Value\tFo-Value\tWe-Value\tDm-Value\tSp-Value\tTo-Value");
872875
}
873-
for (int s = 0; s < Stats.StatsCount; s++)
876+
}
877+
for (int s = 0; s < Stats.StatsCount; s++)
878+
{
879+
if (_extractor.ChosenResults[s] < _extractor.Results[s].Count)
874880
{
875-
if (_extractor.ChosenResults[s] < _extractor.Results[s].Count)
881+
string breedingV = string.Empty;
882+
if (_activeStats[s])
876883
{
877-
string breedingV = string.Empty;
878-
if (_activeStats[s])
879-
{
880-
breedingV = _statIOs[s].BreedingValue.ToString();
881-
}
882-
if (table)
883-
{
884-
tsv.Add(Utils.StatName(s) + "\t" + (_statIOs[s].LevelWild >= 0 ? _statIOs[s].LevelWild.ToString() : string.Empty) + "\t" + (_statIOs[s].LevelWild >= 0 ? _statIOs[s].LevelWild.ToString() : string.Empty) + "\t" + breedingV);
885-
}
886-
else
887-
{
888-
rowLevel += "\t" + (_activeStats[s] ? _statIOs[s].LevelWild.ToString() : string.Empty);
889-
rowValues += "\t" + breedingV;
890-
}
884+
breedingV = _statIOs[s].BreedingValue.ToString();
885+
}
886+
if (table)
887+
{
888+
tsv.Add(Utils.StatName(s) + "\t" + (_statIOs[s].LevelWild >= 0 ? _statIOs[s].LevelWild.ToString() : string.Empty) + "\t" + (_statIOs[s].LevelWild >= 0 ? _statIOs[s].LevelWild.ToString() : string.Empty) + "\t" + breedingV);
891889
}
892890
else
893891
{
894-
return;
892+
rowLevel += "\t" + (_activeStats[s] ? _statIOs[s].LevelWild.ToString() : string.Empty);
893+
rowValues += "\t" + breedingV;
895894
}
896895
}
897-
if (!table)
896+
else
898897
{
899-
tsv.Add(rowLevel + rowValues);
898+
return;
900899
}
901-
Clipboard.SetText(string.Join("\n", tsv));
902900
}
901+
if (!table)
902+
{
903+
tsv.Add(rowLevel + rowValues);
904+
}
905+
Clipboard.SetText(string.Join("\n", tsv));
903906
}
904907

905908
/// <summary>

ARKBreedingStats/Form1.importExported.cs

+18-4
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ private Creature ImportExportedAddIfPossible(string filePath)
212212
&& Properties.Settings.Default.OnAutoImportAddToLibrary)
213213
{
214214
creature = AddCreatureToCollection(true, goToLibraryTab: Properties.Settings.Default.AutoImportGotoLibraryAfterSuccess);
215-
SetMessageLabelText($"Successful {(alreadyExists ? "updated" : "added")} {creature.name} ({species.name}) of the exported file" + Environment.NewLine + filePath, MessageBoxIcon.Information, filePath);
215+
SetMessageLabelText($"Successful {(alreadyExists ? "updated" : "added")} {creature.name} ({species.Name(creature.sex)}) of the exported file" + Environment.NewLine + filePath, MessageBoxIcon.Information, filePath);
216216
addedToLibrary = true;
217217
}
218218
break;
@@ -235,7 +235,7 @@ private Creature ImportExportedAddIfPossible(string filePath)
235235
creature = GetCreatureFromInput(true, species, levelStep);
236236
}
237237

238-
OverlayFeedbackForImport(creature, uniqueExtraction, alreadyExists, addedToLibrary, copiedNameToClipboard);
238+
OverlayFeedbackForImport(creature, uniqueExtraction, alreadyExistingCreature, addedToLibrary, copiedNameToClipboard);
239239

240240
if (addedToLibrary)
241241
{
@@ -374,7 +374,7 @@ private bool CopyCreatureNameToClipboardOnImportIfSetting(string creatureName, b
374374
/// <summary>
375375
/// Give feedback in overlay for imported creature.
376376
/// </summary>
377-
private void OverlayFeedbackForImport(Creature creature, bool uniqueExtraction, bool alreadyExists, bool addedToLibrary,
377+
private void OverlayFeedbackForImport(Creature creature, bool uniqueExtraction, Creature alreadyExistingCreature, bool addedToLibrary,
378378
bool copiedNameToClipboard)
379379
{
380380
string infoText;
@@ -383,7 +383,7 @@ private void OverlayFeedbackForImport(Creature creature, bool uniqueExtraction,
383383
if (uniqueExtraction)
384384
{
385385
var sb = new StringBuilder();
386-
sb.AppendLine($"{creature.Species.name} \"{creature.name}\" {(alreadyExists ? "updated in " : "added to")} the library.");
386+
sb.AppendLine($"{creature.SpeciesName} \"{creature.name}\" {(alreadyExistingCreature != null ? "updated in " : "added to")} the library.");
387387
if (addedToLibrary && copiedNameToClipboard)
388388
sb.AppendLine("Name copied to clipboard.");
389389

@@ -407,6 +407,20 @@ private void OverlayFeedbackForImport(Creature creature, bool uniqueExtraction,
407407

408408
if (_overlay != null)
409409
{
410+
var overlayPattern = Properties.Settings.Default.OverlayImportPattern;
411+
if (!string.IsNullOrEmpty(overlayPattern))
412+
{
413+
var overlayPatternResult = NamePattern.GenerateCreatureName(creature, alreadyExistingCreature,
414+
_creatureCollection.creatures.Where(c => c.Species == creature.Species).ToArray(),
415+
_topLevels.TryGetValue(creature.Species, out var tl) ? tl : null,
416+
_customReplacingNamingPattern, false, -1, false, overlayPattern,
417+
false, colorsExisting: _creatureCollection.ColorAlreadyAvailable(creature.Species, creature.colors, out _),
418+
libraryCreatureCount: _creatureCollection.GetTotalCreatureCount());
419+
420+
if (!string.IsNullOrEmpty(overlayPatternResult))
421+
infoText += Environment.NewLine + Environment.NewLine + overlayPatternResult;
422+
}
423+
410424
_overlay.SetInfoText(infoText, textColor);
411425
if (Properties.Settings.Default.DisplayInheritanceInOverlay)
412426
_overlay.SetInheritanceCreatures(creature, creature.Mother, creature.Father);

0 commit comments

Comments
 (0)