c4c85cf4b8
- Translated project documentation (LEARNING-JOURNEY, CONTRIBUTORS, AI_DISCLOSURE) to English for better accessibility. - Standardized internal code documentation by converting XML-doc blocks to standard comment format. - Cleaned up inline comments and removed redundant versioning metadata across the codebase. - Refactored non-functional text elements to improve readability and maintain a consistent style.
73 lines
2.2 KiB
C#
73 lines
2.2 KiB
C#
namespace HellionChat.Ui;
|
|
|
|
// Pure string resolver logic with no Dalamud dependency, kept in its own
|
|
// file so tests (HellionChat.Tests, no Dalamud reference) can call it directly.
|
|
// Used in the settings UI glyph picker and indirectly via TabIconMapping.Resolve.
|
|
internal static class TabIconGlyphResolver
|
|
{
|
|
// Single source of truth for the glyph set; order matches the settings combobox.
|
|
public static readonly IReadOnlyList<string> PickerOptions =
|
|
[
|
|
"comment",
|
|
"comments",
|
|
"cog",
|
|
"users",
|
|
"user-friends",
|
|
"link",
|
|
"envelope",
|
|
"clock",
|
|
"hashtag",
|
|
"star",
|
|
"heart",
|
|
"bell",
|
|
"bookmark",
|
|
"flag",
|
|
"fire",
|
|
];
|
|
|
|
// Derived from PickerOptions -- never maintain this manually.
|
|
private static readonly HashSet<string> KnownGlyphs = new(
|
|
PickerOptions,
|
|
StringComparer.OrdinalIgnoreCase
|
|
);
|
|
|
|
// Tab.Name is localised, so we match against a pool of DE/EN synonyms.
|
|
private static readonly Dictionary<string, string> NameDefaults = new(
|
|
StringComparer.OrdinalIgnoreCase
|
|
)
|
|
{
|
|
["allgemein"] = "comment",
|
|
["general"] = "comment",
|
|
["system"] = "cog",
|
|
["free company"] = "users",
|
|
["fc"] = "users",
|
|
["gruppe"] = "user-friends",
|
|
["group"] = "user-friends",
|
|
["party"] = "user-friends",
|
|
["linkshell"] = "link",
|
|
["ls"] = "link",
|
|
["cwls"] = "link",
|
|
["tells"] = "envelope",
|
|
["tell"] = "envelope",
|
|
};
|
|
|
|
// Resolves the glyph name for a tab. Priority order:
|
|
// 1. Tab.Icon override (if set): known glyph -> use it, unknown -> "hashtag"
|
|
// 2. Auto-tell tab -> autoTellGlyph if provided, else "clock"
|
|
// 3. Name default lookup
|
|
// 4. Fallback "hashtag"
|
|
public static string ResolveGlyphName(Tab tab, string? autoTellGlyph = null)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(tab.Icon))
|
|
return KnownGlyphs.Contains(tab.Icon) ? tab.Icon : "hashtag";
|
|
|
|
if (tab.IsTempTab)
|
|
return autoTellGlyph ?? "clock";
|
|
|
|
if (tab.Name is { } name && NameDefaults.TryGetValue(name, out var byName))
|
|
return byName;
|
|
|
|
return "hashtag";
|
|
}
|
|
}
|