using System.Text.Json;
namespace XFEWarframe.Client;
/// <summary>Original game icon and localization resources, indexed by ability type.</summary>
public static class AbilityHudCatalog
{
public sealed record Entry(string Name, string Icon);
public static IReadOnlyDictionary<string, Entry> Entries { get; } = Read();
private static IReadOnlyDictionary<string, Entry> Read()
{
var entries = new Dictionary<string, Entry>(StringComparer.Ordinal);
// The server merges supplemental suits (including playable Stalker). The
// client must use that same complete catalog, even with only one skill bank.
foreach (var resource in new[] { "XFEWarframe.AbilityHudCatalog.json", "XFEWarframe.SupplementalAbilityHudCatalog.json" })
{
using var stream = typeof(AbilityHudCatalog).Assembly.GetManifestResourceStream(resource)
?? throw new InvalidDataException("Missing ability HUD catalog: " + resource);
using var document = JsonDocument.Parse(stream);
foreach (var suit in document.RootElement.EnumerateObject())
{
if (!suit.Value.TryGetProperty("abilities", out var abilities)) continue;
foreach (var ability in abilities.EnumerateArray())
if (ability.TryGetProperty("uniqueName", out var type) && ability.TryGetProperty("icon", out var icon) &&
ability.TryGetProperty("name", out var name))
entries.TryAdd(type.GetString()!, new(name.GetString()!, icon.GetString()!));
}
}
// The server also exposes Helminth, operator and other exported abilities.
using var otherStream = typeof(AbilityHudCatalog).Assembly.GetManifestResourceStream("XFEWarframe.OtherAbilityHudCatalog.json")
?? throw new InvalidDataException("Missing additional ability HUD catalog.");
using var other = JsonDocument.Parse(otherStream);
foreach (var ability in other.RootElement.EnumerateObject())
if (ability.Value.TryGetProperty("icon", out var icon))
entries.TryAdd(ability.Name, new(ability.Value.TryGetProperty("name", out var name) ? name.GetString()! : ability.Name.Split('/')[^1], icon.GetString()!));
return entries.AsReadOnly();
}
}
using System.Text.Json;
namespace XFEWarframe.Client;
/// <summary>Original game icon and localization resources, indexed by ability type.</summary>
public static class AbilityHudCatalog
{
public sealed record Entry(string Name, string Icon);
public static IReadOnlyDictionary<string, Entry> Entries { get; } = Read();
private static IReadOnlyDictionary<string, Entry> Read()
{
var entries = new Dictionary<string, Entry>(StringComparer.Ordinal);
// The server merges supplemental suits (including playable Stalker). The
// client must use that same complete catalog, even with only one skill bank.
foreach (var resource in new[] { "XFEWarframe.AbilityHudCatalog.json", "XFEWarframe.SupplementalAbilityHudCatalog.json" })
{
using var stream = typeof(AbilityHudCatalog).Assembly.GetManifestResourceStream(resource)
?? throw new InvalidDataException("Missing ability HUD catalog: " + resource);
using var document = JsonDocument.Parse(stream);
foreach (var suit in document.RootElement.EnumerateObject())
{
if (!suit.Value.TryGetProperty("abilities", out var abilities)) continue;
foreach (var ability in abilities.EnumerateArray())
if (ability.TryGetProperty("uniqueName", out var type) && ability.TryGetProperty("icon", out var icon) &&
ability.TryGetProperty("name", out var name))
entries.TryAdd(type.GetString()!, new(name.GetString()!, icon.GetString()!));
}
}
// The server also exposes Helminth, operator and other exported abilities.
using var otherStream = typeof(AbilityHudCatalog).Assembly.GetManifestResourceStream("XFEWarframe.OtherAbilityHudCatalog.json")
?? throw new InvalidDataException("Missing additional ability HUD catalog.");
using var other = JsonDocument.Parse(otherStream);
foreach (var ability in other.RootElement.EnumerateObject())
if (ability.Value.TryGetProperty("icon", out var icon))
entries.TryAdd(ability.Name, new(ability.Value.TryGetProperty("name", out var name) ? name.GetString()! : ability.Name.Split('/')[^1], icon.GetString()!));
return entries.AsReadOnly();
}
}