Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions WhereIsMyMouse/ConfigWindow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using System;
using System.Numerics;
using Dalamud.Bindings.ImGui;
using Dalamud.Interface.Windowing;

namespace WhereIsMyMouse;

internal class ConfigWindow : Window, IDisposable
{
private readonly Configuration _configuration;

private bool _cursorOn;
private bool _foregroundCursor;
private bool _enableInCombatOnly;
private bool _rainbow;
private float _size;
private float _thickness;
private float _cycleSpeed;
private Vector4 _color;

public ConfigWindow(Plugin plugin) : base("Where'sMyMouse Configuration###wheresmymouseconfig")
{
Flags = ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse;

Size = new Vector2(375, 600);
SizeConstraints = new WindowSizeConstraints
{
MinimumSize = new Vector2(375, 600),
MaximumSize = new Vector2(float.MaxValue, float.MaxValue)
};
SizeCondition = ImGuiCond.Appearing;

_configuration = plugin.Configuration;

_thickness = _configuration.Thickness;
_color = _configuration.Color;
_size = _configuration.Size;
_cycleSpeed = _configuration.CycleSpeed;
_cursorOn = _configuration.CursorOn;
_foregroundCursor = _configuration.ForegroundCursor;
_enableInCombatOnly = _configuration.EnableInCombatOnly;
_rainbow = _configuration.Rainbow;
}

public void Dispose() { }

public override void PreDraw() { }

public override void Draw()
{
ImGui.Text("Cursor Aura : ");
ImGui.SameLine();
ImGui.Checkbox("###CursorAura", ref _cursorOn);
ImGui.Text("Circle drawn in foreground : ");
ImGui.SameLine();
ImGui.Checkbox("###ForegroundCursor", ref _foregroundCursor);
ImGui.Text("Circle Size : ");
ImGui.SameLine();
ImGui.SliderFloat("###sizeslide", ref _size, 0f, 100f);
ImGui.Text("Thickness : ");
ImGui.SameLine();
ImGui.SliderFloat("###thickslide", ref _thickness, 0f, 50f);
ImGui.ColorPicker4("###ColorPicker", ref _color);
ImGui.Text("Enable only in combat : ");
ImGui.SameLine();
ImGui.Checkbox("###CombatOnlyEnable", ref _enableInCombatOnly);
ImGui.Text("Rainbow : ");
ImGui.SameLine();
ImGui.Checkbox("###Rainbow", ref _rainbow);
ImGui.Text("Rainbow Cycle Speed : ");
ImGui.SliderFloat("###cyclespeedslide", ref _cycleSpeed, 0.01f, 1f);
// ReSharper disable once InvertIf
if (ImGui.Button("Save Settings"))
{
_configuration.Color = _color;
_configuration.Size = _size;
_configuration.Thickness = _thickness;
_configuration.CycleSpeed = _cycleSpeed;
_configuration.CursorOn = _cursorOn;
_configuration.ForegroundCursor = _foregroundCursor;
_configuration.EnableInCombatOnly = _enableInCombatOnly;
_configuration.Rainbow = _rainbow;
_configuration.Save();
}
}
}
41 changes: 18 additions & 23 deletions WhereIsMyMouse/Configuration.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
using Dalamud.Configuration;
using Dalamud.Plugin;
using System;
using System.Diagnostics;
using System.Numerics;

namespace WhereIsMyMouse
namespace WhereIsMyMouse;

[Serializable]
public class Configuration : IPluginConfiguration
{
[Serializable]
public class Configuration : IPluginConfiguration
public int Version { get; set; } = 0;

public bool CursorOn { get; set; }
public bool ForegroundCursor { get; set; }
public bool EnableInCombatOnly { get; set; }
public bool Rainbow { get; set; }
public float Size { get; set; } = 15;
public float Thickness { get; set; } = 2;
public float CycleSpeed { get; set; } = 0.10f;
public Vector4 Color { get; set; } = new(1, 0, 0, 1);

public void Save()
{
public int Version { get; set; } = 0;

public bool CursorOn = false;

public bool ForegroundCursor = false;

public bool EnableInCombatOnly = false;

public bool Rainbow = false;

public float Size = 15;

public float Thickness = 2;

public float CycleSpeed = 0.10f;

public Vector4 Color = new Vector4(1, 0, 0, 1);
Plugin.PluginInterface.SavePluginConfig(this);
}
}
}
61 changes: 61 additions & 0 deletions WhereIsMyMouse/MouseWindow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using System.Numerics;
using Dalamud.Bindings.ImGui;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Windowing;

namespace WhereIsMyMouse;

internal class MouseWindow : Window, IDisposable
{
private readonly Plugin _plugin;

public MouseWindow(Plugin plugin) : base("Mouse Window###CursorWindow", ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoFocusOnAppearing)
{
Size = new Vector2(300, 300);

_plugin = plugin;
}

public void Dispose() { }

public override void Draw()
{
if (!_plugin.Configuration.CursorOn)
{
return;
}

if (_plugin.Configuration.EnableInCombatOnly && !Plugin.Condition[ConditionFlag.InCombat])
{
return;
}

var color = _plugin.Configuration.Color;
if (_plugin.Configuration.Rainbow)
{
float h = 0, s = 0, v = 0;
float outr = 0, outg = 0, outb = 0;
ImGui.ColorConvertRGBtoHSV(color.X, color.Y, color.Z, ref h, ref s, ref v);
if (h >= 1)
{
h = 0;
}
h += _plugin.Configuration.CycleSpeed * ImGui.GetIO().DeltaTime;
ImGui.ColorConvertHSVtoRGB(h, s, v, ref outr, ref outg, ref outb);
color.X = outr;
color.Y = outg;
color.Z = outb;
_plugin.Configuration.Color = color;
}

var cursorPos = ImGui.GetMousePos();
ImGuiHelpers.ForceNextWindowMainViewport();
ImGui.SetWindowPos(cursorPos - new Vector2(150,150));

var draw = _plugin.Configuration.ForegroundCursor ? ImGui.GetForegroundDrawList() : ImGui.GetWindowDrawList();

draw.AddCircle(cursorPos, _plugin.Configuration.Size, ImGui.ColorConvertFloat4ToU32(color), 0, _plugin.Configuration.Thickness);
}
}
100 changes: 53 additions & 47 deletions WhereIsMyMouse/Plugin.cs
Original file line number Diff line number Diff line change
@@ -1,67 +1,73 @@
using Dalamud.Game.Command;
using Dalamud.IoC;
using Dalamud.Plugin;
using System.IO;
using System.Reflection;
using Dalamud.Plugin.Services;
using static FFXIVClientStructs.FFXIV.Client.UI.UIModule.Delegates;
using Dalamud.Interface.Windowing;

namespace WhereIsMyMouse
namespace WhereIsMyMouse;

public sealed class Plugin : IDalamudPlugin
{
public sealed class Plugin : IDalamudPlugin
{
public string Name => "Where's my mouse";
[PluginService] internal static IDalamudPluginInterface PluginInterface { get; private set; } = null!;
[PluginService] internal static ICommandManager CommandManager { get; private set; } = null!;
[PluginService] internal static ICondition Condition { get; private set; } = null!;

private const string commandName = "/wmm";
private const string CommandName = "/wmm";

[PluginService] internal static IDalamudPluginInterface PluginInterface { get; private set; } = null!;
[PluginService] internal static ICommandManager CommandManager { get; private set; } = null!;
private Configuration Configuration { get; init; }
private PluginUI PluginUi { get; init; }
[PluginService] internal static ICondition Condition { get; private set; } = null!;
public Configuration Configuration { get; init; }

public Plugin()
{
this.Configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
private readonly WindowSystem _windowSystem = new("WheresMyMouse");
private ConfigWindow ConfigWindow { get; init; }
private MouseWindow MouseWindow { get; init; }

public Plugin()
{
Configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();

this.PluginUi = new PluginUI(this.Configuration);
MouseWindow = new MouseWindow(this);

CommandManager.AddHandler(commandName, new CommandInfo(OnCommand)
{
HelpMessage = "Open Where's my mouse setting menu"
});
ConfigWindow = new ConfigWindow(this);
CommandManager.AddHandler(CommandName, new CommandInfo(OnCommand)
{
HelpMessage = "Open Where's my mouse setting menu"
});

_windowSystem.AddWindow(ConfigWindow);

PluginInterface.UiBuilder.OpenConfigUi += ToggleUI;
PluginInterface.UiBuilder.Draw += Draw;
}
PluginInterface.UiBuilder.OpenConfigUi += ToggleConfigUi;
PluginInterface.UiBuilder.OpenMainUi += ToggleConfigUi;
PluginInterface.UiBuilder.Draw += _windowSystem.Draw;
PluginInterface.UiBuilder.Draw += Draw;
}

public void Dispose()
{
// Save config
PluginInterface.SavePluginConfig(this.Configuration);
public void Dispose()
{
// Save config
PluginInterface.SavePluginConfig(Configuration);

PluginInterface.UiBuilder.OpenConfigUi -= ToggleUI;
PluginInterface.UiBuilder.Draw -= Draw;
PluginInterface.UiBuilder.OpenConfigUi -= ToggleConfigUi;
PluginInterface.UiBuilder.OpenMainUi -= ToggleConfigUi;
PluginInterface.UiBuilder.Draw -= _windowSystem.Draw;
PluginInterface.UiBuilder.Draw -= Draw;

CommandManager.RemoveHandler(commandName);
this.PluginUi.Dispose();
}
_windowSystem.RemoveAllWindows();

private void OnCommand(string command, string args)
{
// in response to the slash command, just display our main ui
this.PluginUi.Visible = true;
}
ConfigWindow.Dispose();
MouseWindow.Dispose();

private void Draw()
{
this.PluginUi.Draw();
}
CommandManager.RemoveHandler(CommandName);
}

private void ToggleUI()
{
this.PluginUi.ToggleUI();
}
private void OnCommand(string command, string args)
{
// in response to the slash command, just display our main ui
ConfigWindow.Toggle();
}
}

private void Draw()
{
MouseWindow.Draw();
}

private void ToggleConfigUi() => ConfigWindow.Toggle();
}
Loading