This commit is contained in:
Anna 2022-09-04 01:10:48 -04:00
parent ea4875c297
commit d5ffdd41e7
3 changed files with 22 additions and 18 deletions

View File

@ -55,7 +55,7 @@ internal class Messages : IDisposable {
this.SpawnVfx(); this.SpawnVfx();
} }
private void SpawnVfx() { internal void SpawnVfx() {
var territory = this.Plugin.ClientState.TerritoryType; var territory = this.Plugin.ClientState.TerritoryType;
if (territory == 0) { if (territory == 0) {
return; return;

View File

@ -24,6 +24,11 @@ internal class MessageList : ITab {
foreach (var message in this.Messages) { foreach (var message in this.Messages) {
ImGui.TextUnformatted(message.Text); ImGui.TextUnformatted(message.Text);
ImGui.TextUnformatted($"Likes: {message.PositiveVotes}");
ImGui.TextUnformatted($"Dislikes: {message.NegativeVotes}");
if (ImGui.Button($"Delete##{message.Id}")) {
this.Delete(message.Id);
}
} }
this.MessagesMutex.Release(); this.MessagesMutex.Release();
@ -45,6 +50,21 @@ internal class MessageList : ITab {
}); });
} }
private void Delete(Guid id) {
Task.Run(async () => {
var resp = await ServerHelper.SendRequest(
this.Plugin.Config.ApiKey,
HttpMethod.Delete,
$"/messages/{id}"
);
if (resp.IsSuccessStatusCode) {
this.Refresh();
this.Plugin.Messages.SpawnVfx();
}
});
}
internal void Add(MessageWithTerritory message) { internal void Add(MessageWithTerritory message) {
this.Messages.Clear(); this.Messages.Clear();
this.Messages.Add(message); this.Messages.Add(message);

View File

@ -1,7 +1,6 @@
using System.Numerics; using System.Numerics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using Dalamud.Game;
using Dalamud.Utility.Signatures; using Dalamud.Utility.Signatures;
namespace OrangeGuidanceTomestone; namespace OrangeGuidanceTomestone;
@ -21,37 +20,22 @@ internal unsafe class Vfx : IDisposable {
private delegate* unmanaged<VfxStruct*, void> _staticVfxRemove; private delegate* unmanaged<VfxStruct*, void> _staticVfxRemove;
private List<IntPtr> Spawned { get; } = new(); private List<IntPtr> Spawned { get; } = new();
private Queue<IntPtr> NeedToRun { get; } = new();
internal Vfx(Plugin plugin) { internal Vfx(Plugin plugin) {
this.Plugin = plugin; this.Plugin = plugin;
SignatureHelper.Initialise(this); SignatureHelper.Initialise(this);
this.Plugin.Framework.Update += this.Run;
} }
public void Dispose() { public void Dispose() {
this.Plugin.Framework.Update -= this.Run;
this.RemoveAll(); this.RemoveAll();
} }
private void Run(Framework framework) {
if (!this.NeedToRun.TryDequeue(out var ptr)) {
return;
}
if (this._staticVfxRun((VfxStruct*) ptr, 0.0f, 0xFFFFFFFF) != 0) {
this.NeedToRun.Enqueue(ptr);
}
}
internal void RemoveAll() { internal void RemoveAll() {
foreach (var spawned in this.Spawned) { foreach (var spawned in this.Spawned) {
this.RemoveStatic((VfxStruct*) spawned); this.RemoveStatic((VfxStruct*) spawned);
} }
this.Spawned.Clear(); this.Spawned.Clear();
this.NeedToRun.Clear();
} }
internal VfxStruct* SpawnStatic(string path, Vector3 pos) { internal VfxStruct* SpawnStatic(string path, Vector3 pos) {