refactor: update for api 9
This commit is contained in:
parent
672e83e186
commit
3eda6e5e57
|
@ -1,6 +1,6 @@
|
|||
namespace ExpandedSearchInfo.Configs {
|
||||
public abstract class BaseConfig {
|
||||
namespace ExpandedSearchInfo.Configs;
|
||||
|
||||
public abstract class BaseConfig {
|
||||
public bool Enabled { get; set; } = true;
|
||||
public bool DefaultExpanded { get; set; } = true;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
namespace ExpandedSearchInfo.Configs {
|
||||
public class CarrdConfig : BaseConfig {
|
||||
}
|
||||
namespace ExpandedSearchInfo.Configs;
|
||||
|
||||
public class CarrdConfig : BaseConfig {
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
using Newtonsoft.Json;
|
||||
|
||||
namespace ExpandedSearchInfo.Configs {
|
||||
public class FListConfig : BaseConfig {
|
||||
namespace ExpandedSearchInfo.Configs;
|
||||
|
||||
public class FListConfig : BaseConfig {
|
||||
[JsonConstructor]
|
||||
public FListConfig() {
|
||||
this.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
namespace ExpandedSearchInfo.Configs {
|
||||
public class PastebinConfig : BaseConfig {
|
||||
}
|
||||
namespace ExpandedSearchInfo.Configs;
|
||||
|
||||
public class PastebinConfig : BaseConfig {
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
namespace ExpandedSearchInfo.Configs {
|
||||
public class PlainTextConfig : BaseConfig {
|
||||
}
|
||||
namespace ExpandedSearchInfo.Configs;
|
||||
|
||||
public class PlainTextConfig : BaseConfig {
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
namespace ExpandedSearchInfo.Configs {
|
||||
public class RefsheetConfig : BaseConfig {
|
||||
}
|
||||
namespace ExpandedSearchInfo.Configs;
|
||||
|
||||
public class RefsheetConfig : BaseConfig {
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
using System;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Hooking;
|
||||
using Dalamud.Logging;
|
||||
|
||||
namespace ExpandedSearchInfo {
|
||||
public class GameFunctions : IDisposable {
|
||||
namespace ExpandedSearchInfo;
|
||||
|
||||
public class GameFunctions : IDisposable {
|
||||
private Plugin Plugin { get; }
|
||||
|
||||
private delegate byte SearchInfoDownloadedDelegate(IntPtr data, IntPtr a2, IntPtr searchInfoPtr, IntPtr a4);
|
||||
|
@ -19,7 +19,7 @@ namespace ExpandedSearchInfo {
|
|||
this.Plugin = plugin;
|
||||
|
||||
var sidPtr = this.Plugin.SigScanner.ScanText("48 89 5C 24 ?? 48 89 6C 24 ?? 56 48 83 EC 20 49 8B E8 8B DA");
|
||||
this._searchInfoDownloadedHook = Hook<SearchInfoDownloadedDelegate>.FromAddress(sidPtr, this.SearchInfoDownloaded);
|
||||
this._searchInfoDownloadedHook = this.Plugin.GameInteropProvider.HookFromAddress<SearchInfoDownloadedDelegate>(sidPtr, this.SearchInfoDownloaded);
|
||||
this._searchInfoDownloadedHook.Enable();
|
||||
}
|
||||
|
||||
|
@ -38,10 +38,9 @@ namespace ExpandedSearchInfo {
|
|||
|
||||
this.ReceiveSearchInfo?.Invoke(actorId, searchInfo);
|
||||
} catch (Exception ex) {
|
||||
PluginLog.LogError(ex, "Error in SearchInfoDownloaded hook");
|
||||
Plugin.Log.Error(ex, "Error in SearchInfoDownloaded hook");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +1,35 @@
|
|||
using Dalamud.Game;
|
||||
using Dalamud.Game.ClientState.Objects;
|
||||
using Dalamud.Game.Command;
|
||||
using Dalamud.Game.Gui;
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Services;
|
||||
|
||||
namespace ExpandedSearchInfo {
|
||||
// ReSharper disable once ClassNeverInstantiated.Global
|
||||
public class Plugin : IDalamudPlugin {
|
||||
public string Name => "Expanded Search Info";
|
||||
namespace ExpandedSearchInfo;
|
||||
|
||||
// ReSharper disable once ClassNeverInstantiated.Global
|
||||
public class Plugin : IDalamudPlugin {
|
||||
internal static string Name => "Expanded Search Info";
|
||||
|
||||
[PluginService]
|
||||
internal static IPluginLog Log { get; private set; } = null!;
|
||||
|
||||
[PluginService]
|
||||
internal DalamudPluginInterface Interface { get; init; } = null!;
|
||||
|
||||
[PluginService]
|
||||
internal CommandManager CommandManager { get; init; } = null!;
|
||||
internal ICommandManager CommandManager { get; init; } = null!;
|
||||
|
||||
[PluginService]
|
||||
internal GameGui GameGui { get; init; } = null!;
|
||||
internal IGameGui GameGui { get; init; } = null!;
|
||||
|
||||
[PluginService]
|
||||
internal ObjectTable ObjectTable { get; init; } = null!;
|
||||
internal IObjectTable ObjectTable { get; init; } = null!;
|
||||
|
||||
[PluginService]
|
||||
internal SigScanner SigScanner { get; init; } = null!;
|
||||
internal ISigScanner SigScanner { get; init; } = null!;
|
||||
|
||||
[PluginService]
|
||||
internal IGameInteropProvider GameInteropProvider { get; init; } = null!;
|
||||
|
||||
internal PluginConfiguration Config { get; }
|
||||
internal GameFunctions Functions { get; }
|
||||
|
@ -53,5 +59,4 @@ namespace ExpandedSearchInfo {
|
|||
private void OnCommand(string command, string arguments) {
|
||||
this.Ui.ConfigVisible = !this.Ui.ConfigVisible;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,9 +2,10 @@
|
|||
using Dalamud.Configuration;
|
||||
using ExpandedSearchInfo.Configs;
|
||||
|
||||
namespace ExpandedSearchInfo {
|
||||
[Serializable]
|
||||
public class PluginConfiguration : IPluginConfiguration {
|
||||
namespace ExpandedSearchInfo;
|
||||
|
||||
[Serializable]
|
||||
public class PluginConfiguration : IPluginConfiguration {
|
||||
private Plugin Plugin { get; set; } = null!;
|
||||
|
||||
public int Version { get; set; } = 1;
|
||||
|
@ -18,14 +19,13 @@ namespace ExpandedSearchInfo {
|
|||
internal void Save() {
|
||||
this.Plugin.Interface.SavePluginConfig(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class ProviderConfigs {
|
||||
[Serializable]
|
||||
public class ProviderConfigs {
|
||||
public CarrdConfig Carrd { get; set; } = new();
|
||||
public FListConfig FList { get; set; } = new();
|
||||
public PastebinConfig Pastebin { get; set; } = new();
|
||||
public PlainTextConfig PlainText { get; set; } = new();
|
||||
public RefsheetConfig Refsheet { get; set; } = new();
|
||||
}
|
||||
}
|
|
@ -2,11 +2,13 @@
|
|||
using System.Diagnostics;
|
||||
using System.Numerics;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Utility;
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace ExpandedSearchInfo {
|
||||
public class PluginUi : IDisposable {
|
||||
namespace ExpandedSearchInfo;
|
||||
|
||||
public class PluginUi : IDisposable {
|
||||
private Plugin Plugin { get; }
|
||||
|
||||
private bool _configVisible;
|
||||
|
@ -59,7 +61,7 @@ namespace ExpandedSearchInfo {
|
|||
|
||||
ImGui.SetNextWindowSize(new Vector2(500, -1), ImGuiCond.FirstUseEver);
|
||||
|
||||
if (!ImGui.Begin($"{this.Plugin.Name} settings", ref this._configVisible)) {
|
||||
if (!ImGui.Begin($"{Plugin.Name} settings", ref this._configVisible)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -165,7 +167,7 @@ namespace ExpandedSearchInfo {
|
|||
);
|
||||
ImGui.SetNextWindowSize(new Vector2(-1, -1));
|
||||
|
||||
if (!ImGui.Begin(this.Plugin.Name, ImGuiWindowFlags.NoTitleBar)) {
|
||||
if (!ImGui.Begin(Plugin.Name, ImGuiWindowFlags.NoTitleBar)) {
|
||||
ImGui.End();
|
||||
return;
|
||||
}
|
||||
|
@ -229,5 +231,4 @@ namespace ExpandedSearchInfo {
|
|||
|
||||
ImGui.End();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,8 +8,9 @@ using AngleSharp.Html.Parser;
|
|||
using ExpandedSearchInfo.Configs;
|
||||
using ExpandedSearchInfo.Sections;
|
||||
|
||||
namespace ExpandedSearchInfo.Providers {
|
||||
public abstract class BaseHtmlProvider : IProvider {
|
||||
namespace ExpandedSearchInfo.Providers;
|
||||
|
||||
public abstract class BaseHtmlProvider : IProvider {
|
||||
private IBrowsingContext Context { get; } = BrowsingContext.New();
|
||||
|
||||
public abstract string Name { get; }
|
||||
|
@ -33,5 +34,4 @@ namespace ExpandedSearchInfo.Providers {
|
|||
var parser = this.Context.GetService<IHtmlParser>();
|
||||
return await parser.ParseDocumentAsync(html);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,8 +7,9 @@ using AngleSharp.Dom;
|
|||
using ExpandedSearchInfo.Configs;
|
||||
using ExpandedSearchInfo.Sections;
|
||||
|
||||
namespace ExpandedSearchInfo.Providers {
|
||||
public class CarrdProvider : BaseHtmlProvider {
|
||||
namespace ExpandedSearchInfo.Providers;
|
||||
|
||||
public class CarrdProvider : BaseHtmlProvider {
|
||||
private static readonly string[] Domains = {
|
||||
".carrd.co",
|
||||
".crd.co",
|
||||
|
@ -87,5 +88,4 @@ namespace ExpandedSearchInfo.Providers {
|
|||
text
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,8 +8,9 @@ using AngleSharp.Dom;
|
|||
using ExpandedSearchInfo.Configs;
|
||||
using ExpandedSearchInfo.Sections;
|
||||
|
||||
namespace ExpandedSearchInfo.Providers {
|
||||
public class FListProvider : BaseHtmlProvider {
|
||||
namespace ExpandedSearchInfo.Providers;
|
||||
|
||||
public class FListProvider : BaseHtmlProvider {
|
||||
private Plugin Plugin { get; }
|
||||
|
||||
public override string Name => "F-List (18+)";
|
||||
|
@ -120,5 +121,4 @@ namespace ExpandedSearchInfo.Providers {
|
|||
|
||||
return kinks;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,8 +5,9 @@ using System.Threading.Tasks;
|
|||
using ExpandedSearchInfo.Configs;
|
||||
using ExpandedSearchInfo.Sections;
|
||||
|
||||
namespace ExpandedSearchInfo.Providers {
|
||||
public interface IProvider {
|
||||
namespace ExpandedSearchInfo.Providers;
|
||||
|
||||
public interface IProvider {
|
||||
string Name { get; }
|
||||
|
||||
string Description { get; }
|
||||
|
@ -52,5 +53,4 @@ namespace ExpandedSearchInfo.Providers {
|
|||
/// <param name="request">HTTP request about to be sent</param>
|
||||
void ModifyRequest(HttpRequestMessage request) {
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,8 +7,9 @@ using System.Threading.Tasks;
|
|||
using ExpandedSearchInfo.Configs;
|
||||
using ExpandedSearchInfo.Sections;
|
||||
|
||||
namespace ExpandedSearchInfo.Providers {
|
||||
public class PastebinProvider : IProvider {
|
||||
namespace ExpandedSearchInfo.Providers;
|
||||
|
||||
public class PastebinProvider : IProvider {
|
||||
private static readonly Regex Matcher = new(@"pb:(\S+)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
||||
private Plugin Plugin { get; }
|
||||
|
@ -48,5 +49,4 @@ namespace ExpandedSearchInfo.Providers {
|
|||
|
||||
return new TextSection(this, $"Pastebin ({id})", response.RequestMessage.RequestUri, info);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,8 +6,9 @@ using System.Threading.Tasks;
|
|||
using ExpandedSearchInfo.Configs;
|
||||
using ExpandedSearchInfo.Sections;
|
||||
|
||||
namespace ExpandedSearchInfo.Providers {
|
||||
public class PlainTextProvider : IProvider {
|
||||
namespace ExpandedSearchInfo.Providers;
|
||||
|
||||
public class PlainTextProvider : IProvider {
|
||||
private Plugin Plugin { get; }
|
||||
|
||||
public string Name => "Plain text";
|
||||
|
@ -43,5 +44,4 @@ namespace ExpandedSearchInfo.Providers {
|
|||
public void ModifyRequest(HttpRequestMessage request) {
|
||||
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("text/plain"));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,8 +8,9 @@ using ExpandedSearchInfo.Sections;
|
|||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
namespace ExpandedSearchInfo.Providers {
|
||||
public class RefsheetProvider : BaseHtmlProvider {
|
||||
namespace ExpandedSearchInfo.Providers;
|
||||
|
||||
public class RefsheetProvider : BaseHtmlProvider {
|
||||
private const string JsonLineStart = "var props = ";
|
||||
|
||||
private Plugin Plugin { get; }
|
||||
|
@ -158,5 +159,4 @@ namespace ExpandedSearchInfo.Providers {
|
|||
public string Id { get; set; }
|
||||
}
|
||||
#pragma warning restore 8618
|
||||
}
|
||||
}
|
|
@ -7,13 +7,13 @@ using System.Net.Http;
|
|||
using System.Net.Http.Headers;
|
||||
using System.Threading.Tasks;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Logging;
|
||||
using ExpandedSearchInfo.Providers;
|
||||
using ExpandedSearchInfo.Sections;
|
||||
using Nager.PublicSuffix;
|
||||
|
||||
namespace ExpandedSearchInfo {
|
||||
public class ExpandedSearchInfo {
|
||||
namespace ExpandedSearchInfo;
|
||||
|
||||
public class ExpandedSearchInfo {
|
||||
public string Info { get; }
|
||||
public List<ISearchInfoSection> Sections { get; }
|
||||
|
||||
|
@ -21,9 +21,9 @@ namespace ExpandedSearchInfo {
|
|||
this.Info = info;
|
||||
this.Sections = sections;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SearchInfoRepository : IDisposable {
|
||||
public class SearchInfoRepository : IDisposable {
|
||||
private Plugin Plugin { get; }
|
||||
private DomainParser Parser { get; }
|
||||
internal ConcurrentDictionary<uint, ExpandedSearchInfo> SearchInfos { get; } = new();
|
||||
|
@ -87,7 +87,7 @@ namespace ExpandedSearchInfo {
|
|||
try {
|
||||
await this.DoExtraction(objectId, info);
|
||||
} catch (Exception ex) {
|
||||
PluginLog.LogError(ex, "Error in extraction thread");
|
||||
Plugin.Log.Error(ex, "Error in extraction thread");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -201,5 +201,4 @@ namespace ExpandedSearchInfo {
|
|||
// otherwise set the expanded search info for this actor id
|
||||
this.SearchInfos[objectId] = new ExpandedSearchInfo(info, sections);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,8 +4,9 @@ using System.Linq;
|
|||
using ExpandedSearchInfo.Providers;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace ExpandedSearchInfo.Sections {
|
||||
public class FListSection : ISearchInfoSection {
|
||||
namespace ExpandedSearchInfo.Sections;
|
||||
|
||||
public class FListSection : ISearchInfoSection {
|
||||
public IProvider Provider { get; }
|
||||
public string Name { get; }
|
||||
public Uri Uri { get; }
|
||||
|
@ -66,5 +67,4 @@ namespace ExpandedSearchInfo.Sections {
|
|||
ImGui.EndTooltip();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
using System;
|
||||
using ExpandedSearchInfo.Providers;
|
||||
|
||||
namespace ExpandedSearchInfo.Sections {
|
||||
public interface ISearchInfoSection {
|
||||
namespace ExpandedSearchInfo.Sections;
|
||||
|
||||
public interface ISearchInfoSection {
|
||||
IProvider Provider { get; }
|
||||
string Name { get; }
|
||||
Uri Uri { get; }
|
||||
|
||||
void Draw();
|
||||
}
|
||||
}
|
|
@ -3,8 +3,9 @@ using System.Collections.Generic;
|
|||
using ExpandedSearchInfo.Providers;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace ExpandedSearchInfo.Sections {
|
||||
public class RefsheetSection : ISearchInfoSection {
|
||||
namespace ExpandedSearchInfo.Sections;
|
||||
|
||||
public class RefsheetSection : ISearchInfoSection {
|
||||
public IProvider Provider { get; }
|
||||
public string Name { get; }
|
||||
public Uri Uri { get; }
|
||||
|
@ -41,5 +42,4 @@ namespace ExpandedSearchInfo.Sections {
|
|||
Util.DrawLines(cardContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
using System;
|
||||
using ExpandedSearchInfo.Providers;
|
||||
|
||||
namespace ExpandedSearchInfo.Sections {
|
||||
public class TextSection : ISearchInfoSection {
|
||||
namespace ExpandedSearchInfo.Sections;
|
||||
|
||||
public class TextSection : ISearchInfoSection {
|
||||
public IProvider Provider { get; }
|
||||
public string Name { get; }
|
||||
public Uri Uri { get; }
|
||||
|
@ -19,5 +20,4 @@ namespace ExpandedSearchInfo.Sections {
|
|||
public void Draw() {
|
||||
Util.DrawLines(this.Info);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,8 +4,9 @@ using System.Text.RegularExpressions;
|
|||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace ExpandedSearchInfo {
|
||||
internal static class Util {
|
||||
namespace ExpandedSearchInfo;
|
||||
|
||||
internal static class Util {
|
||||
private static readonly Regex BbCodeTag = new(@"\[/?\w+(?:=.+?)?\]", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
||||
internal static unsafe SeString ReadRawSeString(IntPtr data) {
|
||||
|
@ -28,5 +29,4 @@ namespace ExpandedSearchInfo {
|
|||
ImGui.TextUnformatted(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue