1
0
Fork 0

refactor: update for api 10

main
Anna 2024-07-01 20:52:09 -04:00
parent 61702e638d
commit 30b8d5d5ac
No known key found for this signature in database
GPG Key ID: D0943384CD9F87D1
6 changed files with 54 additions and 71 deletions

View File

@ -8,7 +8,7 @@ namespace QuestMap {
internal uint Id { get; } internal uint Id { get; }
internal List<Node<T>> Parents { get; set; } internal List<Node<T>> Parents { get; set; }
internal T Value { get; set; } internal T Value { get; set; }
internal List<Node<T>> Children { get; } = new(); internal List<Node<T>> Children { get; } = [];
internal Node(List<Node<T>> parents, uint id, T value) { internal Node(List<Node<T>> parents, uint id, T value) {
this.Id = id; this.Id = id;
@ -18,7 +18,7 @@ namespace QuestMap {
private Node(uint id) { private Node(uint id) {
this.Id = id; this.Id = id;
this.Parents = new List<Node<T>>(); this.Parents = [];
this.Value = default!; this.Value = default!;
} }
@ -58,7 +58,7 @@ namespace QuestMap {
var consolidated = consolidator(parent.Value); var consolidated = consolidator(parent.Value);
parents.Push(consolidated == null parents.Push(consolidated == null
? parent ? parent
: new Node<T>(new List<Node<T>>(), parent.Id, consolidated) { : new Node<T>([], parent.Id, consolidated) {
Children = { this }, Children = { this },
}); });
} }
@ -70,7 +70,7 @@ namespace QuestMap {
var consolidated = consolidator(parent.Value); var consolidated = consolidator(parent.Value);
parents.Push(consolidated == null parents.Push(consolidated == null
? parent ? parent
: new Node<T>(new List<Node<T>>(), parent.Id, consolidated) { : new Node<T>([], parent.Id, consolidated) {
Children = { next }, Children = { next },
}); });
} }
@ -110,7 +110,7 @@ namespace QuestMap {
if (lookup.TryGetValue(item.Key, out var ourNode)) { if (lookup.TryGetValue(item.Key, out var ourNode)) {
ourNode.Value = item.Value; ourNode.Value = item.Value;
} else { } else {
ourNode = new Node<Quest>(new List<Node<Quest>>(), item.Key, item.Value); ourNode = new Node<Quest>([], item.Key, item.Value);
lookup[item.Key] = ourNode; lookup[item.Key] = ourNode;
allNodes[item.Key] = ourNode; allNodes[item.Key] = ourNode;
} }

View File

@ -2,7 +2,6 @@
using Dalamud.IoC; using Dalamud.IoC;
using Dalamud.Plugin; using Dalamud.Plugin;
using Dalamud.Plugin.Services; using Dalamud.Plugin.Services;
using XivCommon;
namespace QuestMap { namespace QuestMap {
// ReSharper disable once ClassNeverInstantiated.Global // ReSharper disable once ClassNeverInstantiated.Global
@ -10,7 +9,7 @@ namespace QuestMap {
internal static string Name => "Quest Map"; internal static string Name => "Quest Map";
[PluginService] [PluginService]
internal DalamudPluginInterface Interface { get; init; } = null!; internal IDalamudPluginInterface Interface { get; init; } = null!;
[PluginService] [PluginService]
internal IClientState ClientState { get; init; } = null!; internal IClientState ClientState { get; init; } = null!;
@ -27,14 +26,12 @@ namespace QuestMap {
[PluginService] [PluginService]
internal ITextureProvider TextureProvider { get; init; } = null!; internal ITextureProvider TextureProvider { get; init; } = null!;
internal XivCommonBase Common { get; }
internal Configuration Config { get; } internal Configuration Config { get; }
internal Quests Quests { get; } internal Quests Quests { get; }
internal PluginUi Ui { get; } internal PluginUi Ui { get; }
private Commands Commands { get; } private Commands Commands { get; }
public Plugin() { public Plugin() {
this.Common = new XivCommonBase(this.Interface);
this.Config = this.Interface.GetPluginConfig() as Configuration ?? new Configuration(); this.Config = this.Interface.GetPluginConfig() as Configuration ?? new Configuration();
var graphChannel = Channel.CreateUnbounded<GraphInfo>(); var graphChannel = Channel.CreateUnbounded<GraphInfo>();
@ -47,7 +44,6 @@ namespace QuestMap {
public void Dispose() { public void Dispose() {
this.Commands.Dispose(); this.Commands.Dispose();
this.Ui.Dispose(); this.Ui.Dispose();
this.Common.Dispose();
} }
internal void SaveConfig() { internal void SaveConfig() {

View File

@ -5,11 +5,14 @@ using System.Numerics;
using System.Reflection; using System.Reflection;
using System.Threading; using System.Threading;
using System.Threading.Channels; using System.Threading.Channels;
using Dalamud; using Dalamud.Game;
using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Interface; using Dalamud.Interface;
using Dalamud.Interface.Internal; using Dalamud.Interface.Textures;
using Dalamud.Interface.Textures.TextureWraps;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using ImGuiNET; using ImGuiNET;
using Lumina.Data; using Lumina.Data;
using Lumina.Excel; using Lumina.Excel;
@ -40,9 +43,8 @@ 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; } = new(); private HashSet<uint> InfoWindows { get; } = [];
private Dictionary<uint, IDalamudTextureWrap> Icons { get; } = new(); private List<(Quest, bool, string)> FilteredQuests { get; } = [];
private List<(Quest, bool, string)> FilteredQuests { get; } = new();
internal bool Show; internal bool Show;
@ -67,17 +69,13 @@ namespace QuestMap {
public void Dispose() { public void Dispose() {
this.Plugin.Interface.UiBuilder.OpenConfigUi -= this.OpenConfig; this.Plugin.Interface.UiBuilder.OpenConfigUi -= this.OpenConfig;
this.Plugin.Interface.UiBuilder.Draw -= this.Draw; this.Plugin.Interface.UiBuilder.Draw -= this.Draw;
foreach (var icon in this.Icons.Values) {
icon.Dispose();
}
} }
private void OpenConfig() { private void OpenConfig() {
this.Show = true; this.Show = true;
} }
private void Refilter() { private unsafe void Refilter() {
this.FilteredQuests.Clear(); this.FilteredQuests.Clear();
var filterLower = this._filter.ToLowerInvariant(); var filterLower = this._filter.ToLowerInvariant();
@ -91,7 +89,7 @@ namespace QuestMap {
return false; return false;
} }
var completed = this.Plugin.Common.Functions.Journal.IsQuestCompleted(quest); var completed = QuestManager.IsQuestComplete(quest.RowId);
if (!this.Plugin.Config.ShowCompleted && completed) { if (!this.Plugin.Config.ShowCompleted && completed) {
return false; return false;
} }
@ -191,7 +189,7 @@ namespace QuestMap {
this.DrawMainWindow(); this.DrawMainWindow();
} }
private void DrawMainWindow() { private unsafe void DrawMainWindow() {
if (!this.Show) { if (!this.Show) {
return; return;
} }
@ -289,13 +287,9 @@ namespace QuestMap {
var (quest, indent, drawItem) = this.FilteredQuests[row]; var (quest, indent, drawItem) = this.FilteredQuests[row];
void DrawSelectable(string name, Quest quest) { void DrawSelectable(string name, Quest quest) {
var completed = this.Plugin.Common.Functions.Journal.IsQuestCompleted(quest); var completed = QuestManager.IsQuestComplete(quest.RowId);
if (completed) { if (completed) {
Vector4 disabled; var disabled = *ImGui.GetStyleColorVec4(ImGuiCol.TextDisabled);
unsafe {
disabled = *ImGui.GetStyleColorVec4(ImGuiCol.TextDisabled);
}
ImGui.PushStyleColor(ImGuiCol.Text, disabled); ImGui.PushStyleColor(ImGuiCol.Text, disabled);
} }
@ -385,7 +379,7 @@ namespace QuestMap {
return !open; return !open;
} }
var completed = this.Plugin.Common.Functions.Journal.IsQuestCompleted(quest); var completed = QuestManager.IsQuestComplete(quest.RowId);
ImGui.TextUnformatted($"Level: {quest.ClassJobLevel0}"); ImGui.TextUnformatted($"Level: {quest.ClassJobLevel0}");
@ -399,16 +393,7 @@ namespace QuestMap {
} }
IDalamudTextureWrap? GetIcon(uint id) { IDalamudTextureWrap? GetIcon(uint id) {
if (this.Icons.TryGetValue(id, out var wrap)) { return this.Plugin.TextureProvider.GetFromGameIcon(new GameIconLookup(id)).GetWrapOrDefault();
return wrap;
}
wrap = this.Plugin.TextureProvider.GetIcon(id);
if (wrap != null) {
this.Icons[id] = wrap;
}
return wrap;
} }
var textWrap = ImGui.GetFontSize() * 20f; var textWrap = ImGui.GetFontSize() * 20f;
@ -417,7 +402,7 @@ namespace QuestMap {
var header = GetIcon(quest.Icon); var header = GetIcon(quest.Icon);
if (header != null) { if (header != null) {
textWrap = header.Width; textWrap = header.Width;
ImGui.Image(header.ImGuiHandle, new Vector2(header.Width, header.Height)); ImGui.Image(header.ImGuiHandle, new Vector2(header.Width / 2f, header.Height / 2f));
} }
} }
@ -452,8 +437,8 @@ namespace QuestMap {
var maxHeight = items var maxHeight = items
.Select(entry => GetIcon(entry.icon)) .Select(entry => GetIcon(entry.icon))
.Where(image => image != null) .Select(image => image?.Height ?? 0)
.Max(image => image!.Height); .Max(height => height / 2f);
var originalY = ImGui.GetCursorPosY(); var originalY = ImGui.GetCursorPosY();
foreach (var (name, icon, qty) in items) { foreach (var (name, icon, qty) in items) {
@ -463,7 +448,7 @@ namespace QuestMap {
ImGui.SetCursorPosY(originalY + (maxHeight - image.Height) / 2f); ImGui.SetCursorPosY(originalY + (maxHeight - image.Height) / 2f);
} }
ImGui.Image(image.ImGuiHandle, new Vector2(image.Width, image.Height)); ImGui.Image(image.ImGuiHandle, new Vector2(image.Width / 2f, image.Height / 2f));
Util.Tooltip(name.ToString()); Util.Tooltip(name.ToString());
} }
@ -563,7 +548,7 @@ namespace QuestMap {
if (icon > 0) { if (icon > 0) {
var image = GetIcon(icon); var image = GetIcon(icon);
if (image != null) { if (image != null) {
ImGui.Image(image.ImGuiHandle, new Vector2(image.Width, image.Height)); ImGui.Image(image.ImGuiHandle, new Vector2(image.Width / 2f, image.Height / 2f));
Util.Tooltip(this.Convert(instance.Name).ToString()); Util.Tooltip(this.Convert(instance.Name).ToString());
} }
} else { } else {
@ -583,7 +568,7 @@ namespace QuestMap {
var image = GetIcon(tribe.Icon); var image = GetIcon(tribe.Icon);
if (image != null) { if (image != null) {
ImGui.Image(image.ImGuiHandle, new Vector2(image.Width, image.Height)); ImGui.Image(image.ImGuiHandle, new Vector2(image.Width / 2f, image.Height / 2f));
Util.Tooltip(this.Convert(tribe.Name).ToString()); Util.Tooltip(this.Convert(tribe.Name).ToString());
} }
@ -606,11 +591,11 @@ namespace QuestMap {
// ReSharper disable once ConstantConditionalAccessQualifier // ReSharper disable once ConstantConditionalAccessQualifier
.MakeGenericMethod(typeof(QuestData))? .MakeGenericMethod(typeof(QuestData))?
// ReSharper disable once ConstantConditionalAccessQualifier // ReSharper disable once ConstantConditionalAccessQualifier
.Invoke(this.Plugin.DataManager.Excel, new object?[] { .Invoke(this.Plugin.DataManager.Excel, [
path, path,
lang, lang,
null, null,
}) as ExcelSheet<QuestData>; ]) as ExcelSheet<QuestData>;
// default to english if reflection failed // default to english if reflection failed
sheet ??= this.Plugin.DataManager.Excel.GetSheet<QuestData>(path); sheet ??= this.Plugin.DataManager.Excel.GetSheet<QuestData>(path);
var firstData = sheet?.GetRow(0); var firstData = sheet?.GetRow(0);
@ -657,7 +642,9 @@ namespace QuestMap {
ImGui.SameLine(); ImGui.SameLine();
if (Util.IconButton(FontAwesomeIcon.Book)) { if (Util.IconButton(FontAwesomeIcon.Book)) {
this.Plugin.Common.Functions.Journal.OpenQuest(quest); unsafe {
AgentQuestJournal.Instance()->OpenForQuest(quest.RowId & 0xFFFF, 1);
}
} }
Util.Tooltip("Open quest in Journal"); Util.Tooltip("Open quest in Journal");
@ -836,7 +823,7 @@ namespace QuestMap {
}; };
var textColour = Colours.Text; var textColour = Colours.Text;
var completed = this.Plugin.Common.Functions.Journal.IsQuestCompleted(quest.RowId); var completed = QuestManager.IsQuestComplete(quest.RowId);
if (completed) { if (completed) {
colour.W = .5f; colour.W = .5f;
textColour = (uint) ((0x80 << 24) | (textColour & 0xFFFFFF)); textColour = (uint) ((0x80 << 24) | (textColour & 0xFFFFFF));
@ -885,7 +872,9 @@ namespace QuestMap {
} }
if (right) { if (right) {
this.Plugin.Common.Functions.Journal.OpenQuest(id); unsafe {
AgentQuestJournal.Instance()->OpenForQuest(id, 1);
}
} }
break; break;
@ -901,7 +890,7 @@ namespace QuestMap {
// ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 5); // ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 5);
} }
private static readonly byte[] NewLinePayload = { 0x02, 0x10, 0x01, 0x03 }; private static readonly byte[] NewLinePayload = [0x02, 0x10, 0x01, 0x03];
private SeString Convert(Lumina.Text.SeString lumina) { private SeString Convert(Lumina.Text.SeString lumina) {
var se = (SeString) lumina; var se = (SeString) lumina;

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7-windows</TargetFramework> <TargetFramework>net8-windows</TargetFramework>
<RootNamespace>QuestMap</RootNamespace> <RootNamespace>QuestMap</RootNamespace>
<Version>1.4.7</Version> <Version>1.4.7</Version>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
@ -33,6 +33,10 @@
<HintPath>$(DalamudLibPath)\ImGui.NET.dll</HintPath> <HintPath>$(DalamudLibPath)\ImGui.NET.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="FFXIVClientStructs">
<HintPath>$(DalamudLibPath)\FFXIVClientStructs.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Lumina"> <Reference Include="Lumina">
<HintPath>$(DalamudLibPath)\Lumina.dll</HintPath> <HintPath>$(DalamudLibPath)\Lumina.dll</HintPath>
<Private>False</Private> <Private>False</Private>
@ -45,9 +49,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="AutomaticGraphLayout" Version="1.1.12"/> <PackageReference Include="AutomaticGraphLayout" Version="1.1.12"/>
<PackageReference Include="DalamudPackager" Version="2.1.12"/> <PackageReference Include="DalamudPackager" Version="2.1.13" />
<PackageReference Include="System.Threading.Channels" Version="7.0.0"/> <PackageReference Include="System.Threading.Channels" Version="8.0.0" />
<PackageReference Include="XivCommon" Version="9.0.0"/>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -62,7 +62,7 @@ namespace QuestMap {
if (itemRewards.TryGetValue(quest.RowId, out var items)) { if (itemRewards.TryGetValue(quest.RowId, out var items)) {
rewards = items; rewards = items;
} else { } else {
rewards = new List<Item>(); rewards = [];
itemRewards[quest.RowId] = rewards; itemRewards[quest.RowId] = rewards;
} }
@ -76,7 +76,7 @@ namespace QuestMap {
if (itemRewards.TryGetValue(quest.RowId, out var items)) { if (itemRewards.TryGetValue(quest.RowId, out var items)) {
rewards = items; rewards = items;
} else { } else {
rewards = new List<Item>(); rewards = [];
itemRewards[quest.RowId] = rewards; itemRewards[quest.RowId] = rewards;
} }
@ -254,6 +254,7 @@ namespace QuestMap {
70214 => "Gods Revel, Lands Tremble (6.3)", 70214 => "Gods Revel, Lands Tremble (6.3)",
70279 => "The Dark Throne (6.4)", 70279 => "The Dark Throne (6.4)",
70286 => "Growing Light (6.5)", 70286 => "Growing Light (6.5)",
70495 => "Dawntrail (7.0)",
_ => null, _ => null,
}; };
@ -272,7 +273,7 @@ namespace QuestMap {
private HashSet<ContentFinderCondition> InstanceUnlocks(Quest quest, ICollection<ContentFinderCondition> others) { private HashSet<ContentFinderCondition> InstanceUnlocks(Quest quest, ICollection<ContentFinderCondition> others) {
if (quest.IsRepeatable) { if (quest.IsRepeatable) {
return new HashSet<ContentFinderCondition>(); return [];
} }
var unlocks = new HashSet<ContentFinderCondition>(); var unlocks = new HashSet<ContentFinderCondition>();

20
QuestMap/packages.lock.json Normal file → Executable file
View File

@ -1,7 +1,7 @@
{ {
"version": 1, "version": 1,
"dependencies": { "dependencies": {
"net7.0-windows7.0": { "net8.0-windows7.0": {
"AutomaticGraphLayout": { "AutomaticGraphLayout": {
"type": "Direct", "type": "Direct",
"requested": "[1.1.12, )", "requested": "[1.1.12, )",
@ -10,21 +10,15 @@
}, },
"DalamudPackager": { "DalamudPackager": {
"type": "Direct", "type": "Direct",
"requested": "[2.1.12, )", "requested": "[2.1.13, )",
"resolved": "2.1.12", "resolved": "2.1.13",
"contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg==" "contentHash": "rMN1omGe8536f4xLMvx9NwfvpAc9YFFfeXJ1t4P4PE6Gu8WCIoFliR1sh07hM+bfODmesk/dvMbji7vNI+B/pQ=="
}, },
"System.Threading.Channels": { "System.Threading.Channels": {
"type": "Direct", "type": "Direct",
"requested": "[7.0.0, )", "requested": "[8.0.0, )",
"resolved": "7.0.0", "resolved": "8.0.0",
"contentHash": "qmeeYNROMsONF6ndEZcIQ+VxR4Q/TX/7uIVLJqtwIWL7dDWeh0l1UIqgo4wYyjG//5lUNhwkLDSFl+pAWO6oiA==" "contentHash": "CMaFr7v+57RW7uZfZkPExsPB6ljwzhjACWW1gfU35Y56rk72B/Wu+sTqxVmGSk4SFUlPc3cjeKND0zktziyjBA=="
},
"XivCommon": {
"type": "Direct",
"requested": "[9.0.0, )",
"resolved": "9.0.0",
"contentHash": "avaBp3FmSCi/PiQhntCeBDYOHejdyTWmFtz4pRBVQQ8vHkmRx+YTk1la9dkYBMlXxRXKckEdH1iI1Fu61JlE7w=="
} }
} }
} }