From 8f7b0a6ffdb9a406e50f0ec74d4eef037166a212 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Tue, 16 Jul 2024 19:14:36 +0200 Subject: [PATCH] Add command to show single quest --- QuestMap/Commands.cs | 15 +++++++++++++-- QuestMap/PluginUi.cs | 9 ++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/QuestMap/Commands.cs b/QuestMap/Commands.cs index bbd9859..c4eb730 100644 --- a/QuestMap/Commands.cs +++ b/QuestMap/Commands.cs @@ -8,17 +8,28 @@ namespace QuestMap { internal Commands(Plugin plugin) { this.Plugin = plugin; - this.Plugin.CommandManager.AddHandler("/quests", new CommandInfo(this.OnCommand) { + this.Plugin.CommandManager.AddHandler("/quests", new CommandInfo(this.OnShowQuestMap) { HelpMessage = "Show Quest Map", }); + this.Plugin.CommandManager.AddHandler("/questinfo", new CommandInfo(this.OnShowQuestInfo) { + HelpMessage = "Show Quest Details", + }); } public void Dispose() { this.Plugin.CommandManager.RemoveHandler("/quests"); } - private void OnCommand(string command, string args) { + private void OnShowQuestMap(string command, string args) { this.Plugin.Ui.Show ^= true; } + + private void OnShowQuestInfo(string command, string args) { + if (!string.IsNullOrEmpty(args) && uint.TryParse(args, out uint questId)) { + if (questId < 0x10000) + questId += 0x10000; + this.Plugin.Ui.InfoWindows.Add(questId); + } + } } } diff --git a/QuestMap/PluginUi.cs b/QuestMap/PluginUi.cs index a19146c..8dcf54e 100644 --- a/QuestMap/PluginUi.cs +++ b/QuestMap/PluginUi.cs @@ -45,7 +45,7 @@ namespace QuestMap { private Node? Centre { get; set; } private ChannelReader GraphChannel { get; } private CancellationTokenSource? CancellationTokenSource { get; set; } - private HashSet InfoWindows { get; } = []; + public HashSet InfoWindows { get; } = []; private List<(Quest, bool, string)> FilteredQuests { get; } = []; internal bool Show; @@ -364,7 +364,9 @@ namespace QuestMap { foreach (var id in this.InfoWindows) { var quest = this.Plugin.DataManager.GetExcelSheet()!.GetRow(id); - if (quest == null) { + if (quest == null) + { + remove = id; continue; } @@ -381,7 +383,7 @@ namespace QuestMap { /// true if closing private bool DrawInfoWindow(Quest quest) { var open = true; - if (!ImGui.Begin($"{this.Convert(quest.Name)}##{quest.RowId}", ref open, ImGuiWindowFlags.AlwaysAutoResize)) { + if (!ImGui.Begin($"{this.Convert(quest.Name)} [{quest.Id}]##{quest.RowId}", ref open, ImGuiWindowFlags.AlwaysAutoResize)) { ImGui.End(); return !open; } @@ -660,6 +662,7 @@ namespace QuestMap { if (Util.IconButton(FontAwesomeIcon.ProjectDiagram)) { this.Quest = quest; this._relayout = true; + this.Plugin.Ui.Show = true; } Util.Tooltip("Show quest graph");