Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
cadon committed Feb 3, 2025
2 parents 364f7c8 + 8abc5d0 commit 7b6ec73
Show file tree
Hide file tree
Showing 43 changed files with 2,677 additions and 481 deletions.
5 changes: 4 additions & 1 deletion ARKBreedingStats/ARKBreedingStats.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,9 @@
<None Include="json\canHaveWildLevelExceptions.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="json\speciesSpecificExtractionFails.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="json\values\ASA-values.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -823,7 +826,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Content Include="ARKSmartBreeding.ico" />
<Content Include="json\sortNames.txt" />
<None Include="json\sortNames.txt" />
<EmbeddedResource Include="ARKOverlay.resx">
<DependentUpon>ARKOverlay.cs</DependentUpon>
</EmbeddedResource>
Expand Down
5 changes: 4 additions & 1 deletion ARKBreedingStats/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<value>60,0</value>
</setting>
<setting name="inventoryCheckTimer" serializeAs="String">
<value>True</value>
<value>False</value>
</setting>
<setting name="showColorsInLibrary" serializeAs="String">
<value>True</value>
Expand Down Expand Up @@ -532,6 +532,9 @@
<setting name="ExtractorConvertWildTorporTotalLevel" serializeAs="String">
<value>True</value>
</setting>
<setting name="ColorSelectorShowAllColors" serializeAs="String">
<value>False</value>
</setting>
</ARKBreedingStats.Properties.Settings>
</userSettings>
</configuration>
18 changes: 9 additions & 9 deletions ARKBreedingStats/BreedingPlanning/BreedingPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,15 @@ private void DoCalculateBreedingScoresAndDisplayPairs()
Creature[] selectedFemales = selectFemales.ToArray();
Creature[] selectedMales = selectMales?.ToArray();

// if only pairings for one specific creatures are shown, add the creature after the filtering
if (considerChosenCreature)
{
if (_chosenCreature.sex == Sex.Female)
selectedFemales = new[] { _chosenCreature };
if (_chosenCreature.sex == Sex.Male)
selectedMales = new[] { _chosenCreature };
}

bool creaturesTagFilteredOut = (crCountF != selectedFemales.Length)
|| (crCountM != (selectedMales?.Length ?? 0));

Expand Down Expand Up @@ -390,15 +399,6 @@ private void DoCalculateBreedingScoresAndDisplayPairs()
pedigreeCreatureBestPossibleInSpeciesFiltered.Visible = false;
}

// if only pairings for one specific creatures are shown, add the creature after the filtering
if (considerChosenCreature)
{
if (_chosenCreature.sex == Sex.Female)
selectedFemales = new[] { _chosenCreature };
if (_chosenCreature.sex == Sex.Male)
selectedMales = new[] { _chosenCreature };
}

if (!selectedFemales.Any() || !selectedMales.Any())
{
NoPossiblePairingsFound(creaturesMutationsFilteredOut, noCreaturesWithTopStatsInBothSexes);
Expand Down
2 changes: 2 additions & 0 deletions ARKBreedingStats/CreatureBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ public CreatureBox()

public void SetCreature(Creature creature)
{
this.SuspendDrawing();
Clear();
_creature = creature;
regionColorChooser1.SetSpecies(creature.Species, creature.colors);
regionColorChooser1.ColorIdsAlsoPossible = creature.ColorIdsAlsoPossible;
_colorRegionUseds = regionColorChooser1.ColorRegionsUseds;

UpdateLabel();
this.ResumeDrawing();
}

public CreatureCollection CreatureCollection
Expand Down
23 changes: 6 additions & 17 deletions ARKBreedingStats/CreatureInfoInput.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using System.Windows.Threading;
using ARKBreedingStats.library;
Expand Down Expand Up @@ -514,18 +515,7 @@ public byte[] ColorIdsAlsoPossible
get
{
var arr = DontUpdateVisuals ? _colorIdsAlsoPossible : regionColorChooser1.ColorIdsAlsoPossible;
if (arr == null) return null;

// if array is empty, return null
var isEmpty = true;
for (int i = 0; i < arr.Length; i++)
{
if (arr[i] != 0)
{
isEmpty = false;
break;
}
}
var isEmpty = arr?.All(c => c == 0) ?? true;

return isEmpty ? null : arr;
}
Expand Down Expand Up @@ -834,10 +824,9 @@ internal void SetNamePatternButtons(string[] patterns)
{
if (patterns == null) return;
var namingPatternButtons = ButtonsNamingPattern;
var l = Math.Min(namingPatternButtons.Length, patterns.Length);
for (int i = 0; i < namingPatternButtons.Length; i++)
for (var i = 0; i < namingPatternButtons.Length; i++)
{
namingPatternButtons[i].BackColor = (patterns?.Length ?? 0) > i && !string.IsNullOrWhiteSpace(patterns[i])
namingPatternButtons[i].BackColor = patterns.Length > i && !string.IsNullOrWhiteSpace(patterns[i])
? Color.FromArgb(150, 110, 255, 104)
: Color.Transparent;
}
Expand Down Expand Up @@ -907,8 +896,8 @@ public void SetLocalizations()
Loc.ControlText(BtSaveOTSPreset, _tt);

var namingPatternButtons = new List<Button> { btnGenerateUniqueName, btNamingPattern2, btNamingPattern3, btNamingPattern4, btNamingPattern5, btNamingPattern6 };
for (int bi = 0; bi < namingPatternButtons.Count; bi++)
_tt.SetToolTip(namingPatternButtons[bi], Loc.S("btnGenerateUniqueNameTT", false));
foreach (var bt in namingPatternButtons)
_tt.SetToolTip(bt, Loc.S("btnGenerateUniqueNameTT", false));
}

internal (bool newInRegion, bool newInSpecies) SetRegionColorsExisting(CreatureCollection.ColorExisting[] colorAlreadyAvailable = null)
Expand Down
27 changes: 27 additions & 0 deletions ARKBreedingStats/FileService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Net.Http;
using System.Reflection;
Expand All @@ -24,6 +25,7 @@ public static class FileService
public const string DataFolderName = "data";
public const string OcrReplacingsFile = "ocrReplacings.txt";
public const string EqualColorIdsFile = "equalColorIds.json";
public const string HideVariantsInSpeciesNameFile = "hideVariantsInSpeciesName.txt";

/// <summary>
/// Where the colored species images are cached.
Expand Down Expand Up @@ -133,6 +135,14 @@ public static bool LoadJsonFile<T>(string filePath, out T data, out string error
return false;
}

/// <summary>
/// Loads json file if available, returns null if an error occured.
/// </summary>
public static T LoadJsonFileIfAvailable<T>(string filePath) where T : class =>
!string.IsNullOrEmpty(filePath)
&& File.Exists(filePath)
&& LoadJsonFile(filePath, out T data, out _) ? data : null;

/// <summary>
/// Tries to create a directory if not existing. Returns true if the path exists.
/// </summary>
Expand Down Expand Up @@ -296,5 +306,22 @@ public static HttpClient GetHttpClient
return _httpClient;
}
}

/// <summary>
/// Opens the folder in the explorer. If it's a file, it will be selected.
/// </summary>
public static void OpenFolderInExplorer(string path)
{
if (string.IsNullOrEmpty(path)) return;
bool isFile = false;

if (File.Exists(path))
isFile = true;
else if (!Directory.Exists(path))
return;

Process.Start("explorer.exe",
$"{(isFile ? "/select, " : string.Empty)}\"{path}\"");
}
}
}
76 changes: 54 additions & 22 deletions ARKBreedingStats/Form1.Designer.cs

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

Loading

0 comments on commit 7b6ec73

Please sign in to comment.