fix: make the plugin work
This commit is contained in:
parent
5328032e0b
commit
cd47b171f7
25
Plugin.cs
25
Plugin.cs
@ -1,5 +1,6 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||
using Dalamud.Hooking;
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.Plugin;
|
||||
@ -20,7 +21,7 @@ public class Plugin : IDalamudPlugin {
|
||||
private HttpClient Client { get; } = new();
|
||||
|
||||
private DataFile Data { get; set; }
|
||||
private Dictionary<uint, nint> ReplacementPointers { get; set; }
|
||||
private Dictionary<uint, nint> ReplacementPointers { get; } = [];
|
||||
private SemaphoreSlim Mutex { get; } = new(1, 1);
|
||||
|
||||
private static class Signatures {
|
||||
@ -33,6 +34,9 @@ public class Plugin : IDalamudPlugin {
|
||||
private Hook<GetBalloonRowDelegate>? GetBalloonRowHook { get; init; }
|
||||
|
||||
public Plugin() {
|
||||
this.GameInterop!.InitializeFromAttributes(this);
|
||||
this.GetBalloonRowHook?.Enable();
|
||||
|
||||
Task.Run(async () => {
|
||||
#if DEBUG
|
||||
var stream = typeof(Plugin).Assembly.GetManifestResourceStream("TimePasses.replacements.yaml");
|
||||
@ -51,8 +55,20 @@ public class Plugin : IDalamudPlugin {
|
||||
try {
|
||||
this.Data = de.Deserialize<DataFile>(yaml);
|
||||
foreach (var replacement in this.Data.Replacements) {
|
||||
var replaced = replacement.Text.ReplaceLineEndings("\x02\x10\x01\x03");
|
||||
var textBytes = Encoding.UTF8.GetBytes(replaced);
|
||||
var lines = replacement.Text
|
||||
.ReplaceLineEndings("\n")
|
||||
.Split('\n');
|
||||
var seStringBuilder = new SeStringBuilder();
|
||||
for (var i = 0; i < lines.Length; i++) {
|
||||
if (i != 0) {
|
||||
seStringBuilder.Add(NewLinePayload.Payload);
|
||||
}
|
||||
|
||||
seStringBuilder.AddText(lines[i].TrimEnd());
|
||||
}
|
||||
|
||||
var textBytes = seStringBuilder.Encode();
|
||||
this.Log!.Info(Convert.ToHexString(textBytes));
|
||||
|
||||
unsafe {
|
||||
var ptr = (uint*) Marshal.AllocHGlobal(8 + textBytes.Length + 1);
|
||||
@ -78,6 +94,7 @@ public class Plugin : IDalamudPlugin {
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
this.GetBalloonRowHook?.Dispose();
|
||||
this.Client.Dispose();
|
||||
this.Mutex.Dispose();
|
||||
foreach (var (_, ptr) in this.ReplacementPointers) {
|
||||
|
@ -48,7 +48,12 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DalamudPackager" Version="2.1.12" />
|
||||
<PackageReference Include="YamlDotNet" Version="15.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="replacements.yaml" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
4
TimePasses.yaml
Executable file
4
TimePasses.yaml
Executable file
@ -0,0 +1,4 @@
|
||||
name: Time Passes
|
||||
author: Anna
|
||||
punchline: Replace NPC text bubble text with updated lines.
|
||||
description: blah
|
@ -2,6 +2,12 @@
|
||||
"version": 1,
|
||||
"dependencies": {
|
||||
"net8.0-windows7.0": {
|
||||
"DalamudPackager": {
|
||||
"type": "Direct",
|
||||
"requested": "[2.1.12, )",
|
||||
"resolved": "2.1.12",
|
||||
"contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg=="
|
||||
},
|
||||
"YamlDotNet": {
|
||||
"type": "Direct",
|
||||
"requested": "[15.3.0, )",
|
||||
@ -10,4 +16,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
replacements:
|
||||
- id: 22
|
||||
text: |-
|
||||
It's been quiet
|
||||
lately.
|
||||
It's been
|
||||
quiet lately.
|
||||
|
Loading…
Reference in New Issue
Block a user