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.Runtime.InteropServices;
|
||||||
using System.Text;
|
using Dalamud.Game.Text.SeStringHandling;
|
||||||
|
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||||
using Dalamud.Hooking;
|
using Dalamud.Hooking;
|
||||||
using Dalamud.IoC;
|
using Dalamud.IoC;
|
||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
@ -20,7 +21,7 @@ public class Plugin : IDalamudPlugin {
|
|||||||
private HttpClient Client { get; } = new();
|
private HttpClient Client { get; } = new();
|
||||||
|
|
||||||
private DataFile Data { get; set; }
|
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 SemaphoreSlim Mutex { get; } = new(1, 1);
|
||||||
|
|
||||||
private static class Signatures {
|
private static class Signatures {
|
||||||
@ -33,6 +34,9 @@ public class Plugin : IDalamudPlugin {
|
|||||||
private Hook<GetBalloonRowDelegate>? GetBalloonRowHook { get; init; }
|
private Hook<GetBalloonRowDelegate>? GetBalloonRowHook { get; init; }
|
||||||
|
|
||||||
public Plugin() {
|
public Plugin() {
|
||||||
|
this.GameInterop!.InitializeFromAttributes(this);
|
||||||
|
this.GetBalloonRowHook?.Enable();
|
||||||
|
|
||||||
Task.Run(async () => {
|
Task.Run(async () => {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
var stream = typeof(Plugin).Assembly.GetManifestResourceStream("TimePasses.replacements.yaml");
|
var stream = typeof(Plugin).Assembly.GetManifestResourceStream("TimePasses.replacements.yaml");
|
||||||
@ -51,8 +55,20 @@ public class Plugin : IDalamudPlugin {
|
|||||||
try {
|
try {
|
||||||
this.Data = de.Deserialize<DataFile>(yaml);
|
this.Data = de.Deserialize<DataFile>(yaml);
|
||||||
foreach (var replacement in this.Data.Replacements) {
|
foreach (var replacement in this.Data.Replacements) {
|
||||||
var replaced = replacement.Text.ReplaceLineEndings("\x02\x10\x01\x03");
|
var lines = replacement.Text
|
||||||
var textBytes = Encoding.UTF8.GetBytes(replaced);
|
.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 {
|
unsafe {
|
||||||
var ptr = (uint*) Marshal.AllocHGlobal(8 + textBytes.Length + 1);
|
var ptr = (uint*) Marshal.AllocHGlobal(8 + textBytes.Length + 1);
|
||||||
@ -78,6 +94,7 @@ public class Plugin : IDalamudPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
|
this.GetBalloonRowHook?.Dispose();
|
||||||
this.Client.Dispose();
|
this.Client.Dispose();
|
||||||
this.Mutex.Dispose();
|
this.Mutex.Dispose();
|
||||||
foreach (var (_, ptr) in this.ReplacementPointers) {
|
foreach (var (_, ptr) in this.ReplacementPointers) {
|
||||||
|
@ -48,7 +48,12 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="DalamudPackager" Version="2.1.12" />
|
||||||
<PackageReference Include="YamlDotNet" Version="15.3.0" />
|
<PackageReference Include="YamlDotNet" Version="15.3.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="replacements.yaml" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</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,
|
"version": 1,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"net8.0-windows7.0": {
|
"net8.0-windows7.0": {
|
||||||
|
"DalamudPackager": {
|
||||||
|
"type": "Direct",
|
||||||
|
"requested": "[2.1.12, )",
|
||||||
|
"resolved": "2.1.12",
|
||||||
|
"contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg=="
|
||||||
|
},
|
||||||
"YamlDotNet": {
|
"YamlDotNet": {
|
||||||
"type": "Direct",
|
"type": "Direct",
|
||||||
"requested": "[15.3.0, )",
|
"requested": "[15.3.0, )",
|
||||||
@ -10,4 +16,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
replacements:
|
replacements:
|
||||||
- id: 22
|
- id: 22
|
||||||
text: |-
|
text: |-
|
||||||
It's been quiet
|
It's been
|
||||||
lately.
|
quiet lately.
|
||||||
|
Loading…
Reference in New Issue
Block a user