1
0
Fork 0

Add command to show single quest

main
Liza 2024-07-16 19:14:36 +02:00
parent 5511e36921
commit 8f7b0a6ffd
Signed by: liza
GPG Key ID: 7199F8D727D55F67
2 changed files with 19 additions and 5 deletions

View File

@ -8,17 +8,28 @@ namespace QuestMap {
internal Commands(Plugin plugin) { internal Commands(Plugin plugin) {
this.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", HelpMessage = "Show Quest Map",
}); });
this.Plugin.CommandManager.AddHandler("/questinfo", new CommandInfo(this.OnShowQuestInfo) {
HelpMessage = "Show Quest Details",
});
} }
public void Dispose() { public void Dispose() {
this.Plugin.CommandManager.RemoveHandler("/quests"); this.Plugin.CommandManager.RemoveHandler("/quests");
} }
private void OnCommand(string command, string args) { private void OnShowQuestMap(string command, string args) {
this.Plugin.Ui.Show ^= true; 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);
}
}
} }
} }

View File

@ -45,7 +45,7 @@ namespace QuestMap {
private Node? Centre { get; set; } private Node? Centre { get; set; }
private ChannelReader<GraphInfo> GraphChannel { get; } private ChannelReader<GraphInfo> GraphChannel { get; }
private CancellationTokenSource? CancellationTokenSource { get; set; } private CancellationTokenSource? CancellationTokenSource { get; set; }
private HashSet<uint> InfoWindows { get; } = []; public HashSet<uint> InfoWindows { get; } = [];
private List<(Quest, bool, string)> FilteredQuests { get; } = []; private List<(Quest, bool, string)> FilteredQuests { get; } = [];
internal bool Show; internal bool Show;
@ -364,7 +364,9 @@ namespace QuestMap {
foreach (var id in this.InfoWindows) { foreach (var id in this.InfoWindows) {
var quest = this.Plugin.DataManager.GetExcelSheet<Quest>()!.GetRow(id); var quest = this.Plugin.DataManager.GetExcelSheet<Quest>()!.GetRow(id);
if (quest == null) { if (quest == null)
{
remove = id;
continue; continue;
} }
@ -381,7 +383,7 @@ namespace QuestMap {
/// <returns>true if closing</returns> /// <returns>true if closing</returns>
private bool DrawInfoWindow(Quest quest) { private bool DrawInfoWindow(Quest quest) {
var open = true; 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(); ImGui.End();
return !open; return !open;
} }
@ -660,6 +662,7 @@ namespace QuestMap {
if (Util.IconButton(FontAwesomeIcon.ProjectDiagram)) { if (Util.IconButton(FontAwesomeIcon.ProjectDiagram)) {
this.Quest = quest; this.Quest = quest;
this._relayout = true; this._relayout = true;
this.Plugin.Ui.Show = true;
} }
Util.Tooltip("Show quest graph"); Util.Tooltip("Show quest graph");