Skip to content

Commit

Permalink
option to hide variant tags for species
Browse files Browse the repository at this point in the history
  • Loading branch information
cadon committed Jan 30, 2025
1 parent b6efde8 commit d9bebe1
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ARKBreedingStats/ARKBreedingStats.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -826,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
1 change: 1 addition & 0 deletions ARKBreedingStats/FileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,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
12 changes: 12 additions & 0 deletions ARKBreedingStats/Form1.Designer.cs

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

11 changes: 11 additions & 0 deletions ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4025,5 +4025,16 @@ private void showStatsOptionsFileInExplorerToolStripMenuItem_Click(object sender
{
FileService.OpenFolderInExplorer(StatsOptionsLevelColors.SettingsFilePath);
}

private void editVariantTagsToHideToolStripMenuItem_Click(object sender, EventArgs e)
{
var filePath = FileService.GetJsonPath(FileService.HideVariantsInSpeciesNameFile);

if (!File.Exists(filePath))
File.WriteAllText(filePath, string.Empty);
if (File.Exists(filePath))
Process.Start(filePath);
else MessageBoxes.ShowMessageBox($"Couldn't create file {filePath} automatically. Maybe you can create that file manually.");
}
}
}
18 changes: 17 additions & 1 deletion ARKBreedingStats/species/Species.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Text.RegularExpressions;
using ARKBreedingStats.Library;
using ARKBreedingStats.mods;
using System.IO;

namespace ARKBreedingStats.species
{
Expand Down Expand Up @@ -170,6 +171,8 @@ public double[] StatImprintMultipliersRaw
[OnDeserialized]
private void Initialize(StreamingContext _) => Initialize();

private static string[] _ignoreVariantInName;

public void Initialize()
{
// TODO: Base species are maybe not used in game and may only lead to confusion (e.g. Giganotosaurus).
Expand Down Expand Up @@ -284,8 +287,10 @@ public void InitializeNames()
string variantInfoForName = null;
if (variants != null && variants.Any())
{
var ignoreVariants = _getIgnoreVariantInName();
VariantInfo = string.Join(", ", variants);
variantInfoForName = string.Join(", ", string.IsNullOrEmpty(name) ? variants : variants.Where(v => !name.Contains(v)));
var gaun = variants.Any(v => ignoreVariants.Contains(v));
variantInfoForName = string.Join(", ", string.IsNullOrEmpty(name) ? variants : variants.Where(v => !name.Contains(v) && !ignoreVariants.Contains(v)));
}

DescriptiveName = name + (string.IsNullOrEmpty(variantInfoForName) ? string.Empty : " (" + variantInfoForName + ")");
Expand Down Expand Up @@ -532,5 +537,16 @@ public string Name(Sex creatureSex)
return name;
}
}

private static string[] _getIgnoreVariantInName()
{
if (_ignoreVariantInName != null) return _ignoreVariantInName;

var filePath = FileService.GetJsonPath(FileService.HideVariantsInSpeciesNameFile);
_ignoreVariantInName = !File.Exists(filePath) ? Array.Empty<string>() : File.ReadAllLines(filePath).Where(l => !string.IsNullOrEmpty(l)).ToArray();
return _ignoreVariantInName;
}

public static void ClearIgnoreVariantsInName() => _ignoreVariantInName = null;
}
}
1 change: 1 addition & 0 deletions ARKBreedingStats/values/Values.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ private void InitializeSpeciesAndColors(bool undefinedColorAsa = false)

InitializeArkColors(undefinedColorAsa);
_speciesAndColorsInitialized = true;
Species.ClearIgnoreVariantsInName();
}

/// <summary>
Expand Down

0 comments on commit d9bebe1

Please sign in to comment.