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