From d6ffe6fcdc8802defc0106a072dcbe2e97d86150 Mon Sep 17 00:00:00 2001 From: NotNite Date: Sat, 18 Mar 2023 22:00:40 -0400 Subject: [PATCH] testing this shit is nightmare fuel --- Dalamud/Fools/FoolsManager.cs | 4 +- Dalamud/Fools/IFoolsPlugin.cs | 6 +-- Dalamud/Fools/Plugins/PixelImperfectPlugin.cs | 53 +++++++++++++++++++ Dalamud/Fools/Plugins/TestFoolPlugin.cs | 2 +- .../PluginInstaller/PluginInstallerWindow.cs | 8 +-- 5 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 Dalamud/Fools/Plugins/PixelImperfectPlugin.cs diff --git a/Dalamud/Fools/FoolsManager.cs b/Dalamud/Fools/FoolsManager.cs index 4d58b7a03..73c3e0694 100644 --- a/Dalamud/Fools/FoolsManager.cs +++ b/Dalamud/Fools/FoolsManager.cs @@ -31,6 +31,8 @@ internal class FoolsManager : IDisposable, IServiceType this.FoolsPlugins = new List { new("Test Fool Plugin", "TestFoolPlugin", "this is a test", "NotNite", typeof(TestFoolPlugin)), + new("Pixel Imperfect", "PixelImperfectPlugin", "Whoops... we messed up the math on that one.", "Halpo", + typeof(PixelImperfectPlugin)), }; } @@ -87,7 +89,7 @@ internal class FoolsManager : IDisposable, IServiceType { foreach (var plugin in this.ActivatedPlugins.Values) { - plugin.DrawUI(); + plugin.DrawUi(); } } } diff --git a/Dalamud/Fools/IFoolsPlugin.cs b/Dalamud/Fools/IFoolsPlugin.cs index f2957508e..5764dd78d 100644 --- a/Dalamud/Fools/IFoolsPlugin.cs +++ b/Dalamud/Fools/IFoolsPlugin.cs @@ -1,8 +1,8 @@ -using Dalamud.Plugin; +using System; namespace Dalamud.Fools; -public interface IFoolsPlugin : IDalamudPlugin +public interface IFoolsPlugin : IDisposable { - public void DrawUI() { } + public void DrawUi() { } } diff --git a/Dalamud/Fools/Plugins/PixelImperfectPlugin.cs b/Dalamud/Fools/Plugins/PixelImperfectPlugin.cs new file mode 100644 index 000000000..7ac21624f --- /dev/null +++ b/Dalamud/Fools/Plugins/PixelImperfectPlugin.cs @@ -0,0 +1,53 @@ +using System; +using System.Numerics; +using Dalamud.Game.ClientState; +using Dalamud.Game.Gui; +using Dalamud.Interface; +using ImGuiNET; +using static ImGuiNET.ImGuiWindowFlags; + +namespace Dalamud.Fools.Plugins; + +public class PixelImperfectPlugin : IFoolsPlugin +{ + private ClientState clientState; + private GameGui gameGui; + + public PixelImperfectPlugin() + { + this.clientState = Service.Get(); + this.gameGui = Service.Get(); + } + + public void DrawUi() + { + if (this.clientState.LocalPlayer == null) return; + + // Copied directly from PixelPerfect + ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0, 0)); + ImGuiHelpers.ForceNextWindowMainViewport(); + ImGuiHelpers.SetNextWindowPosRelativeMainViewport(new Vector2(0, 0)); + ImGui.Begin("Canvas", NoInputs | NoNav | NoTitleBar | NoScrollbar | NoBackground); + ImGui.SetWindowSize(ImGui.GetIO().DisplaySize); + + var xOffset = Math.Sin(Environment.TickCount / 500.0); + var yOffset = Math.Sin(Environment.TickCount / 1500.0); + var actorPos = this.clientState.LocalPlayer.Position; + + this.gameGui.WorldToScreen( + new Vector3(actorPos.X + (float)xOffset, actorPos.Y, actorPos.Z + (float)yOffset), + out var pos); + + ImGui.GetWindowDrawList().AddCircle( + new Vector2(pos.X, pos.Y), + 2, + ImGui.GetColorU32(new Vector4(255, 255, 255, 255)), + 100, + 10); + + ImGui.End(); + ImGui.PopStyleVar(); + } + + public void Dispose() { } +} diff --git a/Dalamud/Fools/Plugins/TestFoolPlugin.cs b/Dalamud/Fools/Plugins/TestFoolPlugin.cs index 4eb36ed7a..57b36cc46 100644 --- a/Dalamud/Fools/Plugins/TestFoolPlugin.cs +++ b/Dalamud/Fools/Plugins/TestFoolPlugin.cs @@ -14,7 +14,7 @@ public class TestFoolPlugin : IFoolsPlugin public TestFoolPlugin() { } - public void DrawUI() + public void DrawUi() { if (ImGui.Begin("Nuts")) { diff --git a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs index bbc8d1d7c..42e016f57 100644 --- a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs +++ b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs @@ -1257,7 +1257,7 @@ internal class PluginInstallerWindow : Window, IDisposable foreach (var plugin in manager.FoolsPlugins) { // dropdown - if (ImGui.CollapsingHeader($"{plugin.Name}##AprilFools_{plugin.Name}")) + if (ImGui.CollapsingHeader($"{plugin.Name}##AprilFools_Header_{plugin.Name}")) { ImGui.Indent(); ImGui.Text(plugin.Name); @@ -1269,18 +1269,20 @@ internal class PluginInstallerWindow : Window, IDisposable if (manager.IsPluginActivated(plugin.InternalName)) { - if (ImGui.Button("Disable")) + if (ImGui.Button($"Disable##AprilFools_Disable_{plugin.Name}")) { manager.DeactivatePlugin(plugin.InternalName); } } else { - if (ImGui.Button("Install")) + if (ImGui.Button($"Install##AprilFools_Enable_{plugin.Name}")) { manager.ActivatePlugin(plugin.InternalName); } } + + ImGui.Unindent(); } } }