mirror of
https://github.com/waynebian01/Shigure.git
synced 2026-09-03 07:15:24 +08:00
Add SpellFieldKey class for managing spell and aura keys
- Introduced a new class `SpellFieldKey` to encapsulate constants and methods related to spell and aura identifiers. - Added methods for generating keys for spells and auras, including parsing functionality for spell and aura strings. - Implemented utility methods for stripping prefixes and canonicalizing aura IDs.
This commit is contained in:
@@ -10,6 +10,7 @@ public sealed class KeymapService : IKeymapResolver
|
||||
private readonly Dictionary<(int Unit, string Spell, string MacroCondition), string> _hotkeys = new();
|
||||
private readonly Dictionary<(int Unit, string Spell), string> _fallbackHotkeys = new();
|
||||
private readonly Dictionary<long, int> _spellIndices = new();
|
||||
private readonly Dictionary<long, string> _spellNames = new();
|
||||
private int? _currentClassId;
|
||||
private int? _currentSpecId;
|
||||
|
||||
@@ -36,6 +37,7 @@ public sealed class KeymapService : IKeymapResolver
|
||||
_hotkeys.Clear();
|
||||
_fallbackHotkeys.Clear();
|
||||
_spellIndices.Clear();
|
||||
_spellNames.Clear();
|
||||
|
||||
LoadSpellIndices(classId);
|
||||
|
||||
@@ -111,12 +113,17 @@ public sealed class KeymapService : IKeymapResolver
|
||||
return null;
|
||||
}
|
||||
|
||||
public IReadOnlyDictionary<int, string> GetCurrentFailedSpells()
|
||||
public string? GetHotkey(int? unit, long spellId, string? macroCondition = null)
|
||||
=> _spellNames.TryGetValue(spellId, out var spell)
|
||||
? GetHotkey(unit, spell, macroCondition)
|
||||
: null;
|
||||
|
||||
public IReadOnlyDictionary<int, long> GetCurrentFailedSpells()
|
||||
{
|
||||
return _config.GetFailedSpells(_currentClassId);
|
||||
}
|
||||
|
||||
public IReadOnlyDictionary<int, string> GetCurrentOneKeySpells()
|
||||
public IReadOnlyDictionary<int, long> GetCurrentOneKeySpells()
|
||||
{
|
||||
return _config.GetOneKeySpells(_currentClassId);
|
||||
}
|
||||
@@ -126,6 +133,11 @@ public sealed class KeymapService : IKeymapResolver
|
||||
return _spellIndices;
|
||||
}
|
||||
|
||||
public IReadOnlyDictionary<long, string> GetCurrentSpellNames()
|
||||
{
|
||||
return _spellNames;
|
||||
}
|
||||
|
||||
private void LoadSpellIndices(int? classId)
|
||||
{
|
||||
if (classId is null)
|
||||
@@ -144,6 +156,10 @@ public sealed class KeymapService : IKeymapResolver
|
||||
foreach (var spell in document.SpellsList.Where(spell => spell.SpellId > 0))
|
||||
{
|
||||
_spellIndices.TryAdd(spell.SpellId, spell.Index);
|
||||
if (!string.IsNullOrWhiteSpace(spell.Name))
|
||||
{
|
||||
_spellNames.TryAdd(spell.SpellId, spell.Name.Trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException
|
||||
|
||||
Reference in New Issue
Block a user