Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
cadon committed Nov 2, 2024
2 parents 44c717b + 8292dff commit 112809e
Show file tree
Hide file tree
Showing 34 changed files with 3,424 additions and 2,216 deletions.
3 changes: 3 additions & 0 deletions ARKBreedingStats/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,9 @@
<setting name="LevelColorWindowRectangle" serializeAs="String">
<value>200, 200, 1000, 650</value>
</setting>
<setting name="OverlayImportPattern" serializeAs="String">
<value />
</setting>
</ARKBreedingStats.Properties.Settings>
</userSettings>
</configuration>
1 change: 1 addition & 0 deletions ARKBreedingStats/BreedingPlanning/BreedingPlan.Designer.cs

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

4 changes: 2 additions & 2 deletions ARKBreedingStats/BreedingPlanning/BreedingScore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ public static List<BreedingPair> CalculateBreedingScores(Creature[] females, Cre
if (female.levelsWild[s] == bestLevelsOfSpecies[s] && male.levelsWild[s] == bestLevelsOfSpecies[s])
weightedExpectedStatLevel *= 1.142;
}
else if (bestLevelsOfSpecies[s] > 0)
else if (bestLevelsOfSpecies[s] > 0 || statWeights[s] < 0)
weightedExpectedStatLevel *= .01;
}
else if (breedingMode == BreedingMode.TopStatsConservative && bestLevelsOfSpecies[s] > 0)
else if (breedingMode == BreedingMode.TopStatsConservative && (bestLevelsOfSpecies[s] > 0 || statWeights[s] < 0))
{
bool higherIsBetter = statWeights[s] >= 0;
bestPossLevels[s] = (short)(higherIsBetter ? Math.Max(female.levelsWild[s], male.levelsWild[s]) : Math.Min(female.levelsWild[s], male.levelsWild[s]));
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/CreatureBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void SetParentLabel(Label l, string lbText = null, bool clickable = false)
statsDisplay1.SetCreatureValues(_creature);
labelNotes.Text = _creature.note;
_tt.SetToolTip(labelNotes, _creature.note);
labelSpecies.Text = _creature.Species.name;
labelSpecies.Text = _creature.SpeciesName;
pictureBox1.SetImageAndDisposeOld(CreatureColored.GetColoredCreature(_creature.colors, _creature.Species, _colorRegionUseds, creatureSex: _creature.sex));
_tt.SetToolTip(pictureBox1, CreatureColored.RegionColorInfo(_creature.Species, _creature.colors)
+ "\n\nClick to copy creature infos as image to the clipboard");
Expand Down
3 changes: 2 additions & 1 deletion ARKBreedingStats/CreatureInfoInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,8 @@ public void OpenNamePatternEditor(Creature creature, TopLevels topLevels, Dictio
{
if (!parentListValid)
ParentListRequested?.Invoke(this);
using (var pe = new PatternEditor(creature, _sameSpecies, topLevels, ColorAlreadyExistingInformation, customReplacings, namingPatternIndex, reloadCallback, LibraryCreatureCount))
using (var pe = new PatternEditor(creature, _sameSpecies, topLevels, ColorAlreadyExistingInformation,
customReplacings, $"pattern {namingPatternIndex + 1}", Settings.Default.NamingPatterns?[namingPatternIndex], reloadCallback, LibraryCreatureCount))
{
if (pe.ShowDialog() == DialogResult.OK)
{
Expand Down
6 changes: 3 additions & 3 deletions ARKBreedingStats/Form1.collection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private void LoadCollection(bool add = false)
{
if (dlg.ShowDialog() == DialogResult.OK)
{
LoadCollectionFile(dlg.FileName, add);
LoadCollectionFile(dlg.FileName, add, ignoreDeletionList: true);
}
}
}
Expand Down Expand Up @@ -377,7 +377,7 @@ private bool KeepBackupFile(string currentSaveFilePath, int keepBackupFilesCount
/// <param name="keepCurrentCreatures">add the creatures of the loaded file to the current ones</param>
/// <param name="keepCurrentSelections">don't change the species selection or tab, use if a synchronized library is loaded</param>
/// <returns></returns>
private bool LoadCollectionFile(string filePath, bool keepCurrentCreatures = false, bool keepCurrentSelections = false, bool triggeredByFileWatcher = false)
private bool LoadCollectionFile(string filePath, bool keepCurrentCreatures = false, bool keepCurrentSelections = false, bool triggeredByFileWatcher = false, bool ignoreDeletionList = false)
{
Species selectedSpecies = speciesSelector1.SelectedSpecies;
Species selectedLibrarySpecies = listBoxSpeciesLib.SelectedItem as Species;
Expand Down Expand Up @@ -551,7 +551,7 @@ private bool LoadCollectionFile(string filePath, bool keepCurrentCreatures = fal

if (keepCurrentCreatures)
{
creatureWasAdded = previouslyLoadedCreatureCollection.MergeCreatureList(_creatureCollection.creatures, removeCreatures: _creatureCollection.DeletedCreatureGuids);
creatureWasAdded = previouslyLoadedCreatureCollection.MergeCreatureList(_creatureCollection.creatures, removeCreatures: ignoreDeletionList ? null : _creatureCollection.DeletedCreatureGuids);
_creatureCollection = previouslyLoadedCreatureCollection;
}
else
Expand Down
50 changes: 8 additions & 42 deletions ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ private void Form1_Load(object sender, EventArgs e)
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

// check for updates
MoveSpeciesImagesToNewFolder();
if (DateTime.Now.AddHours(-20) > Properties.Settings.Default.lastUpdateCheck)
{
bool selectDefaultImagesIfNotYet = false;
Expand Down Expand Up @@ -1930,8 +1929,13 @@ private void pasteCreatureToolStripMenuItem_Click(object sender, EventArgs e)
/// </summary>
private void PasteCreatureFromClipboard()
{
var importedCreatures = ExportImportCreatures.ImportFromClipboard();
if (importedCreatures?.Any() != true) return;
var importedCreatures = ExportImportCreatures.ImportFromClipboard(out var errorText);
if (importedCreatures?.Any() != true)
{
if (!string.IsNullOrEmpty(errorText))
SetMessageLabelText(errorText, MessageBoxIcon.Error);
return;
}

foreach (var c in importedCreatures)
{
Expand Down Expand Up @@ -3160,7 +3164,7 @@ private void UpdateTempCreatureDropDown()
{
toolStripCBTempCreatures.Items.Clear();
foreach (CreatureValues cv in _creatureCollection.creaturesValues)
toolStripCBTempCreatures.Items.Add($"{cv.name} ({cv.Species?.name ?? "unknown species"}, Lv {cv.level})");
toolStripCBTempCreatures.Items.Add($"{cv.name} ({cv.Species?.Name(cv.sex) ?? "unknown species"}, Lv {cv.level})");
}

/// <summary>
Expand Down Expand Up @@ -3764,44 +3768,6 @@ 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 08-2021.
/// </summary>
private void MoveSpeciesImagesToNewFolder()
{
const string relativeImageFolder = "images/speciesImages";
var oldImagesFolder = FileService.GetPath("img");
var newImagesFolder = FileService.GetPath(relativeImageFolder);

if (Directory.Exists(newImagesFolder))
{
// images are already moved
// check if the images folder is set correctly (currently there's only one option)
if (Properties.Settings.Default.SpeciesImagesFolder == relativeImageFolder) return;

Properties.Settings.Default.SpeciesImagesFolder = relativeImageFolder;
CreatureColored.InitializeSpeciesImageLocation();
speciesSelector1.InitializeSpeciesImages(Values.V.species);
return;
}

if (!Directory.Exists(oldImagesFolder)) return;

try
{
Directory.Move(oldImagesFolder, newImagesFolder);

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

private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode != Keys.ControlKey
Expand Down
85 changes: 44 additions & 41 deletions ARKBreedingStats/Form1.extractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -845,61 +845,64 @@ private void CopyExtractionToClipboard()
bool header = true;
bool table = MessageBox.Show("Results can be copied as own table or as a long table-row. Should it be copied as own table?",
"Copy as own table?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
if (_extractor.ValidResults && speciesSelector1.SelectedSpecies != null)
{
List<string> tsv = new List<string>();
string rowLevel = speciesSelector1.SelectedSpecies.name + "\t\t";
string rowValues = string.Empty;
// if taming effectiveness is unique, display it, too
string effString = string.Empty;
double eff = _extractor.UniqueTamingEffectiveness();
if (eff >= 0)
if (!_extractor.ValidResults || speciesSelector1.SelectedSpecies == null)
{
SetMessageLabelText("Extraction not successful or no species selected.", MessageBoxIcon.Error);
return;
}

List<string> tsv = new List<string>();
string rowLevel = speciesSelector1.SelectedSpecies.name + "\t\t";
string rowValues = string.Empty;
// if taming effectiveness is unique, display it, too
string effString = string.Empty;
double eff = _extractor.UniqueTamingEffectiveness();
if (eff >= 0)
{
effString = "\tTamingEff:\t" + (100 * eff) + "%";
}
// header row
if (table || header)
{
if (table)
{
effString = "\tTamingEff:\t" + (100 * eff) + "%";
tsv.Add(speciesSelector1.SelectedSpecies.name + "\tLevel " + numericUpDownLevel.Value + effString);
tsv.Add("Stat\tWildLevel\tDomLevel\tBreedingValue");
}
// headerrow
if (table || header)
else
{
if (table)
{
tsv.Add(speciesSelector1.SelectedSpecies.name + "\tLevel " + numericUpDownLevel.Value + effString);
tsv.Add("Stat\tWildLevel\tDomLevel\tBreedingValue");
}
else
{
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");
}
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");
}
for (int s = 0; s < Stats.StatsCount; s++)
}
for (int s = 0; s < Stats.StatsCount; s++)
{
if (_extractor.ChosenResults[s] < _extractor.Results[s].Count)
{
if (_extractor.ChosenResults[s] < _extractor.Results[s].Count)
string breedingV = string.Empty;
if (_activeStats[s])
{
string breedingV = string.Empty;
if (_activeStats[s])
{
breedingV = _statIOs[s].BreedingValue.ToString();
}
if (table)
{
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);
}
else
{
rowLevel += "\t" + (_activeStats[s] ? _statIOs[s].LevelWild.ToString() : string.Empty);
rowValues += "\t" + breedingV;
}
breedingV = _statIOs[s].BreedingValue.ToString();
}
if (table)
{
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);
}
else
{
return;
rowLevel += "\t" + (_activeStats[s] ? _statIOs[s].LevelWild.ToString() : string.Empty);
rowValues += "\t" + breedingV;
}
}
if (!table)
else
{
tsv.Add(rowLevel + rowValues);
return;
}
Clipboard.SetText(string.Join("\n", tsv));
}
if (!table)
{
tsv.Add(rowLevel + rowValues);
}
Clipboard.SetText(string.Join("\n", tsv));
}

/// <summary>
Expand Down
22 changes: 18 additions & 4 deletions ARKBreedingStats/Form1.importExported.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ private Creature ImportExportedAddIfPossible(string filePath)
&& Properties.Settings.Default.OnAutoImportAddToLibrary)
{
creature = AddCreatureToCollection(true, goToLibraryTab: Properties.Settings.Default.AutoImportGotoLibraryAfterSuccess);
SetMessageLabelText($"Successful {(alreadyExists ? "updated" : "added")} {creature.name} ({species.name}) of the exported file" + Environment.NewLine + filePath, MessageBoxIcon.Information, filePath);
SetMessageLabelText($"Successful {(alreadyExists ? "updated" : "added")} {creature.name} ({species.Name(creature.sex)}) of the exported file" + Environment.NewLine + filePath, MessageBoxIcon.Information, filePath);
addedToLibrary = true;
}
break;
Expand All @@ -235,7 +235,7 @@ private Creature ImportExportedAddIfPossible(string filePath)
creature = GetCreatureFromInput(true, species, levelStep);
}

OverlayFeedbackForImport(creature, uniqueExtraction, alreadyExists, addedToLibrary, copiedNameToClipboard);
OverlayFeedbackForImport(creature, uniqueExtraction, alreadyExistingCreature, addedToLibrary, copiedNameToClipboard);

if (addedToLibrary)
{
Expand Down Expand Up @@ -374,7 +374,7 @@ private bool CopyCreatureNameToClipboardOnImportIfSetting(string creatureName, b
/// <summary>
/// Give feedback in overlay for imported creature.
/// </summary>
private void OverlayFeedbackForImport(Creature creature, bool uniqueExtraction, bool alreadyExists, bool addedToLibrary,
private void OverlayFeedbackForImport(Creature creature, bool uniqueExtraction, Creature alreadyExistingCreature, bool addedToLibrary,
bool copiedNameToClipboard)
{
string infoText;
Expand All @@ -383,7 +383,7 @@ private void OverlayFeedbackForImport(Creature creature, bool uniqueExtraction,
if (uniqueExtraction)
{
var sb = new StringBuilder();
sb.AppendLine($"{creature.Species.name} \"{creature.name}\" {(alreadyExists ? "updated in " : "added to")} the library.");
sb.AppendLine($"{creature.SpeciesName} \"{creature.name}\" {(alreadyExistingCreature != null ? "updated in " : "added to")} the library.");
if (addedToLibrary && copiedNameToClipboard)
sb.AppendLine("Name copied to clipboard.");

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

if (_overlay != null)
{
var overlayPattern = Properties.Settings.Default.OverlayImportPattern;
if (!string.IsNullOrEmpty(overlayPattern))
{
var overlayPatternResult = NamePattern.GenerateCreatureName(creature, alreadyExistingCreature,
_creatureCollection.creatures.Where(c => c.Species == creature.Species).ToArray(),
_topLevels.TryGetValue(creature.Species, out var tl) ? tl : null,
_customReplacingNamingPattern, false, -1, false, overlayPattern,
false, colorsExisting: _creatureCollection.ColorAlreadyAvailable(creature.Species, creature.colors, out _),
libraryCreatureCount: _creatureCollection.GetTotalCreatureCount());

if (!string.IsNullOrEmpty(overlayPatternResult))
infoText += Environment.NewLine + Environment.NewLine + overlayPatternResult;
}

_overlay.SetInfoText(infoText, textColor);
if (Properties.Settings.Default.DisplayInheritanceInOverlay)
_overlay.SetInheritanceCreatures(creature, creature.Mother, creature.Father);
Expand Down
Loading

0 comments on commit 112809e

Please sign in to comment.