refactor: clean up some code
This commit is contained in:
parent
48369bb172
commit
eb6217bad3
|
@ -5,32 +5,33 @@
|
|||
<Version>1.3.2</Version>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Dalamud, Version=5.2.4.3, Culture=neutral, PublicKeyToken=null">
|
||||
<Reference Include="Dalamud">
|
||||
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\Dalamud.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="ImGui.NET, Version=1.72.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<Reference Include="ImGui.NET">
|
||||
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\ImGui.NET.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="ImGuiScene, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<Reference Include="ImGuiScene">
|
||||
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\ImGuiScene.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AngleSharp" Version="0.14.0"/>
|
||||
<PackageReference Include="DalamudPackager" Version="1.2.1"/>
|
||||
<PackageReference Include="ILRepack.Lib.MSBuild.Task" Version="2.0.18.2"/>
|
||||
<PackageReference Include="Nager.PublicSuffix" Version="2.2.2"/>
|
||||
<PackageReference Include="AngleSharp" Version="0.14.0" />
|
||||
<PackageReference Include="DalamudPackager" Version="1.2.1" />
|
||||
<PackageReference Include="ILRepack.Lib.MSBuild.Task" Version="2.0.18.2" />
|
||||
<PackageReference Include="Nager.PublicSuffix" Version="2.2.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Hooking;
|
||||
using Dalamud.Plugin;
|
||||
|
||||
|
@ -11,7 +12,7 @@ namespace ExpandedSearchInfo {
|
|||
|
||||
private readonly Hook<SearchInfoDownloadedDelegate>? _searchInfoDownloadedHook;
|
||||
|
||||
internal delegate void ReceiveSearchInfoEventDelegate(int actorId, string info);
|
||||
internal delegate void ReceiveSearchInfoEventDelegate(int actorId, SeString info);
|
||||
|
||||
internal event ReceiveSearchInfoEventDelegate? ReceiveSearchInfo;
|
||||
|
||||
|
@ -34,7 +35,7 @@ namespace ExpandedSearchInfo {
|
|||
var actorId = Marshal.ReadInt32(data + 48);
|
||||
|
||||
// var searchInfoPtr = data + 90;
|
||||
var searchInfo = Util.ReadRawString(searchInfoPtr);
|
||||
var searchInfo = this.Plugin.Interface.SeStringManager.ReadRawSeString(searchInfoPtr);
|
||||
|
||||
this.ReceiveSearchInfo?.Invoke(actorId, searchInfo);
|
||||
} catch (Exception ex) {
|
||||
|
@ -44,4 +45,4 @@ namespace ExpandedSearchInfo {
|
|||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
using Dalamud.Configuration;
|
||||
using System;
|
||||
using Dalamud.Configuration;
|
||||
using ExpandedSearchInfo.Configs;
|
||||
|
||||
namespace ExpandedSearchInfo {
|
||||
[Serializable]
|
||||
public class PluginConfiguration : IPluginConfiguration {
|
||||
private Plugin Plugin { get; set; } = null!;
|
||||
|
||||
|
@ -18,6 +20,7 @@ namespace ExpandedSearchInfo {
|
|||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class ProviderConfigs {
|
||||
public CarrdConfig Carrd { get; set; } = new();
|
||||
public FListConfig FList { get; set; } = new();
|
||||
|
@ -25,4 +28,4 @@ namespace ExpandedSearchInfo {
|
|||
public PlainTextConfig PlainText { get; set; } = new();
|
||||
public RefsheetConfig Refsheet { get; set; } = new();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ namespace ExpandedSearchInfo {
|
|||
private void DrawExpandedSearchInfo() {
|
||||
// check if the examine window is open
|
||||
var addon = this.Plugin.Interface.Framework.Gui.GetAddonByName("CharacterInspect", 1);
|
||||
if (addon == null || !addon.Visible) {
|
||||
if (addon is not {Visible: true}) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ namespace ExpandedSearchInfo.Providers {
|
|||
}
|
||||
|
||||
// remove bbcode and turn special characters into normal ascii
|
||||
info = Util.StripBbCode(info).Normalize(NormalizationForm.FormKD);
|
||||
info = info.StripBbCode().Normalize(NormalizationForm.FormKD);
|
||||
|
||||
var fave = KinkSection(document, "Character_FetishlistFave");
|
||||
var yes = KinkSection(document, "Character_FetishlistYes");
|
||||
|
|
|
@ -6,6 +6,7 @@ using System.Net;
|
|||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Plugin;
|
||||
using ExpandedSearchInfo.Providers;
|
||||
using ExpandedSearchInfo.Sections;
|
||||
|
@ -61,9 +62,11 @@ namespace ExpandedSearchInfo {
|
|||
this.Providers.Add(new PlainTextProvider(this.Plugin));
|
||||
}
|
||||
|
||||
private void ProcessSearchInfo(int actorId, string info) {
|
||||
private void ProcessSearchInfo(int actorId, SeString raw) {
|
||||
this.LastActorId = actorId;
|
||||
|
||||
var info = raw.TextValue;
|
||||
|
||||
// if empty search info, short circuit
|
||||
if (string.IsNullOrWhiteSpace(info)) {
|
||||
// remove any existing search info
|
||||
|
|
|
@ -1,30 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace ExpandedSearchInfo {
|
||||
internal static class Util {
|
||||
private static readonly Regex BbCodeTag = new(@"\[/?\w+(?:=.+?)?\]", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
||||
internal static string ReadRawString(IntPtr data) {
|
||||
internal static unsafe SeString ReadRawSeString(this SeStringManager manager, IntPtr data) {
|
||||
var bytes = new List<byte>();
|
||||
|
||||
for (var i = 0;; i++) {
|
||||
var b = Marshal.ReadByte(data, i);
|
||||
if (b == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
bytes.Add(b);
|
||||
var ptr = (byte*) data;
|
||||
while (*ptr != 0) {
|
||||
bytes.Add(*ptr);
|
||||
ptr += 1;
|
||||
}
|
||||
|
||||
return Encoding.UTF8.GetString(bytes.ToArray());
|
||||
return manager.Parse(bytes.ToArray());
|
||||
}
|
||||
|
||||
internal static string StripBbCode(string input) => BbCodeTag.Replace(input, "");
|
||||
internal static string StripBbCode(this string input) => BbCodeTag.Replace(input, "");
|
||||
|
||||
internal static void DrawLines(string input) {
|
||||
// FIXME: this is a workaround for imgui breaking on extremely long strings
|
||||
|
@ -33,4 +29,4 @@ namespace ExpandedSearchInfo {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue