Skip to content

Commit

Permalink
Merge pull request #17 from avail/feature/7.0
Browse files Browse the repository at this point in the history
net8 & update for api 10
  • Loading branch information
Pythyu authored Jul 5, 2024
2 parents 452c3d3 + 15f011c commit c4d5347
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 54 deletions.
16 changes: 1 addition & 15 deletions WhereIsMyMouse/Configuration.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Dalamud.Configuration;
using Dalamud.Plugin;
using System;
using System.Diagnostics;
using System.Numerics;

namespace WhereIsMyMouse
Expand All @@ -25,20 +26,5 @@ public class Configuration : IPluginConfiguration
public float CycleSpeed = 0.10f;

public Vector4 Color = new Vector4(1, 0, 0, 1);

// the below exist just to make saving less cumbersome

[NonSerialized]
private DalamudPluginInterface? pluginInterface;

public void Initialize(DalamudPluginInterface pluginInterface)
{
this.pluginInterface = pluginInterface;
}

public void Save()
{
this.pluginInterface!.SavePluginConfig(this);
}
}
}
44 changes: 23 additions & 21 deletions WhereIsMyMouse/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.Reflection;
using Dalamud.Plugin.Services;
using static FFXIVClientStructs.FFXIV.Client.UI.UIModule.Delegates;

namespace WhereIsMyMouse
{
Expand All @@ -13,40 +14,37 @@ public sealed class Plugin : IDalamudPlugin

private const string commandName = "/wmm";

private DalamudPluginInterface PluginInterface { get; init; }
private ICommandManager CommandManager { get; init; }
[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; }
private ICondition Condition { get; init; }
[PluginService] internal static ICondition Condition { get; private set; } = null!;

public Plugin(
[RequiredVersion("1.0")] DalamudPluginInterface pluginInterface,
[RequiredVersion("1.0")] ICommandManager commandManager,
[RequiredVersion("1.0")] ICondition condition)
public Plugin()
{
this.PluginInterface = pluginInterface;
this.CommandManager = commandManager;
this.Condition = condition;

this.Configuration = this.PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
this.Configuration.Initialize(this.PluginInterface);
this.Configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();

this.PluginUi = new PluginUI(this.Configuration, this.PluginInterface, this.Condition);
this.PluginUi = new PluginUI(this.Configuration);

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

this.PluginInterface.UiBuilder.Draw += DrawUI;


PluginInterface.UiBuilder.OpenConfigUi += ToggleUI;
PluginInterface.UiBuilder.Draw += Draw;
}

public void Dispose()
{
// Save config
PluginInterface.SavePluginConfig(this.Configuration);
this.PluginInterface.UiBuilder.Draw -= DrawUI;
this.CommandManager.RemoveHandler(commandName);

PluginInterface.UiBuilder.OpenConfigUi -= ToggleUI;
PluginInterface.UiBuilder.Draw -= Draw;

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

Expand All @@ -56,10 +54,14 @@ private void OnCommand(string command, string args)
this.PluginUi.Visible = true;
}

private void DrawUI()
private void Draw()
{
this.PluginUi.Draw();
}


private void ToggleUI()
{
this.PluginUi.ToggleUI();
}
}
}
21 changes: 9 additions & 12 deletions WhereIsMyMouse/PluginUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game.UI;
using FFXIVClientStructs.Interop.Attributes;
using Lumina;
using Character = Dalamud.Game.ClientState.Objects.Types.Character;
using StructsCharacter = FFXIVClientStructs.FFXIV.Client.Game.Character.Character;

namespace WhereIsMyMouse
Expand All @@ -23,8 +21,6 @@ namespace WhereIsMyMouse
class PluginUI : IDisposable
{
private Configuration configuration;

private DalamudPluginInterface wmmInterface;

// this extra bool exists for ImGui, since you can't ref a property
private bool visible = false;
Expand All @@ -44,20 +40,16 @@ class PluginUI : IDisposable
private float cycleSpeed = 0.10f;

private Vector4 color = new Vector4(1, 0, 0, 1);

private ICondition condition { get; init; }

public bool Visible
{
get { return this.visible; }
set { this.visible = value; }
}

public PluginUI(Configuration configuration, DalamudPluginInterface wmmInterface, ICondition condition)
public PluginUI(Configuration configuration)
{
this.configuration = configuration;
this.wmmInterface = wmmInterface;
this.condition = condition;
this.thickness = this.configuration.Thickness;
this.color = this.configuration.Color;
this.size = this.configuration.Size;
Expand All @@ -74,8 +66,13 @@ public void Dispose()

public void Draw()
{
DrawMainWindow();
CursorAura();
DrawMainWindow();
}

public void ToggleUI()
{
Visible = !Visible;
}

public void CursorAura()
Expand All @@ -85,7 +82,7 @@ public void CursorAura()
return;
}

if (EnableInCombatOnly && !this.condition[ConditionFlag.InCombat])
if (EnableInCombatOnly && !Plugin.Condition[ConditionFlag.InCombat])
{
return;
}
Expand Down Expand Up @@ -127,7 +124,7 @@ public void SaveSettings()
this.configuration.ForegroundCursor = this.ForegroundCursor;
this.configuration.EnableInCombatOnly = this.EnableInCombatOnly;
this.configuration.Rainbow = this.Rainbow;
wmmInterface.SavePluginConfig(this.configuration);
Plugin.PluginInterface.SavePluginConfig(this.configuration);
}


Expand Down
4 changes: 2 additions & 2 deletions WhereIsMyMouse/WhereIsMyMouse.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<Platforms>x64</Platforms>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
Expand All @@ -26,7 +26,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.12" />
<PackageReference Include="DalamudPackager" Version="2.1.13" />
<Reference Include="FFXIVClientStructs">
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
<Private>false</Private>
Expand Down
8 changes: 4 additions & 4 deletions WhereIsMyMouse/packages.lock.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"version": 1,
"dependencies": {
"net7.0-windows7.0": {
"net8.0-windows7.0": {
"DalamudPackager": {
"type": "Direct",
"requested": "[2.1.12, )",
"resolved": "2.1.12",
"contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg=="
"requested": "[2.1.13, )",
"resolved": "2.1.13",
"contentHash": "rMN1omGe8536f4xLMvx9NwfvpAc9YFFfeXJ1t4P4PE6Gu8WCIoFliR1sh07hM+bfODmesk/dvMbji7vNI+B/pQ=="
}
}
}
Expand Down

0 comments on commit c4d5347

Please sign in to comment.