private readonly QuestFunctions _questFunctions;
private readonly GameFunctions _gameFunctions;
private readonly IDataManager _dataManager;
+ private readonly IClientState _clientState;
private readonly Configuration _configuration;
+ private IReadOnlyList<uint> _previouslyUnlockedUnlockLinks = [];
+
public CommandHandler(
ICommandManager commandManager,
IChatGui chatGui,
QuestFunctions questFunctions,
GameFunctions gameFunctions,
IDataManager dataManager,
+ IClientState clientState,
Configuration configuration)
{
_commandManager = commandManager;
_questFunctions = questFunctions;
_gameFunctions = gameFunctions;
_dataManager = dataManager;
+ _clientState = clientState;
_configuration = configuration;
+ _clientState.Logout += OnLogout;
_commandManager.AddHandler("/qst", new CommandInfo(ProcessCommand)
{
HelpMessage = string.Join($"{Environment.NewLine}\t",
break;
case "unlock-links":
- int foundUnlockLinks = _gameFunctions.DumpUnlockLinks();
- if (foundUnlockLinks >= 0)
- _chatGui.Print($"Saved {foundUnlockLinks} unlock links to log.", MessageTag, TagColor);
+ IReadOnlyList<uint> unlockedUnlockLinks = _gameFunctions.GetUnlockLinks();
+ if (unlockedUnlockLinks.Count >= 0)
+ {
+ _chatGui.Print($"Saved {unlockedUnlockLinks.Count} unlock links to log.", MessageTag, TagColor);
+
+ var newUnlockLinks = unlockedUnlockLinks.Except(_previouslyUnlockedUnlockLinks).ToList();
+ if (_previouslyUnlockedUnlockLinks.Count > 0 && newUnlockLinks.Count > 0)
+ _chatGui.Print($"New unlock links: {string.Join(", ", newUnlockLinks)}", MessageTag, TagColor);
+ }
else
_chatGui.PrintError("Could not query unlock links.", MessageTag, TagColor);
+
+ _previouslyUnlockedUnlockLinks = unlockedUnlockLinks;
break;
case "taxi":
_chatGui.Print("You are not mounted.", MessageTag, TagColor);
}
+ private void OnLogout(int type, int code)
+ {
+ _previouslyUnlockedUnlockLinks = [];
+ }
+
public void Dispose()
{
#if DEBUG
_commandManager.RemoveHandler("/qst@");
#endif
_commandManager.RemoveHandler("/qst");
+ _clientState.Logout -= OnLogout;
}
}
/// </summary>
public void AbandonDuty() => _abandonDuty(false);
- public int DumpUnlockLinks()
+ public IReadOnlyList<uint> GetUnlockLinks()
{
UIState* uiState = UIState.Instance();
if (uiState == null)
{
_logger.LogError("Could not query unlock links");
- return -1;
+ return [];
}
List<uint> unlockedUnlockLinks = [];
}
_logger.LogInformation("Unlocked unlock links: {UnlockedUnlockLinks}", string.Join(", ", unlockedUnlockLinks));
- return unlockedUnlockLinks.Count;
+ return unlockedUnlockLinks;
}
#if false