API 9
This commit is contained in:
parent
d425fa4040
commit
59aa8c7dc7
8
.gitignore
vendored
8
.gitignore
vendored
@ -1,4 +1,6 @@
|
||||
.vs/
|
||||
obj/
|
||||
dist/
|
||||
/dist
|
||||
/obj
|
||||
/bin
|
||||
/.idea
|
||||
/.vs
|
||||
*.user
|
@ -1,25 +1,9 @@
|
||||
using Dalamud.Configuration;
|
||||
using Dalamud.Plugin;
|
||||
using System;
|
||||
|
||||
namespace FishNotify
|
||||
namespace FishNotify;
|
||||
|
||||
internal sealed class Configuration : IPluginConfiguration
|
||||
{
|
||||
internal class Configuration : IPluginConfiguration
|
||||
{
|
||||
public int Version { get; set; } = 0;
|
||||
public bool ChatAlerts { get; set; } = false;
|
||||
|
||||
[NonSerialized]
|
||||
private DalamudPluginInterface pluginInterface = null!;
|
||||
|
||||
public void Initialize(DalamudPluginInterface pluginInterface)
|
||||
{
|
||||
this.pluginInterface = pluginInterface;
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
this.pluginInterface.SavePluginConfig(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,7 @@
|
||||
using Dalamud.Data;
|
||||
using Dalamud.Game.Gui;
|
||||
using Dalamud.Game.Network;
|
||||
using Dalamud.Game.Network;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.Logging;
|
||||
using Dalamud.Plugin;
|
||||
using ImGuiNET;
|
||||
using Newtonsoft.Json;
|
||||
@ -13,32 +10,33 @@ using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using Dalamud.Plugin.Services;
|
||||
|
||||
namespace FishNotify
|
||||
namespace FishNotify;
|
||||
|
||||
public sealed class FishNotifyPlugin : IDalamudPlugin
|
||||
{
|
||||
public sealed class FishNotifyPlugin : IDalamudPlugin
|
||||
{
|
||||
public string Name => "FishNotify";
|
||||
|
||||
[PluginService]
|
||||
[RequiredVersion("1.0")]
|
||||
private DalamudPluginInterface PluginInterface { get; set; } = null!;
|
||||
|
||||
[PluginService]
|
||||
private GameNetwork Network { get; set; } = null!;
|
||||
private IGameNetwork Network { get; set; } = null!;
|
||||
|
||||
[PluginService]
|
||||
public static ChatGui Chat { get; set; } = null!;
|
||||
private IChatGui Chat { get; set; } = null!;
|
||||
|
||||
private Configuration configuration;
|
||||
private bool settingsVisible;
|
||||
private int expectedOpCode = -1;
|
||||
private uint fishCount = 0;
|
||||
[PluginService]
|
||||
private IPluginLog PluginLog { get; set; } = null!;
|
||||
|
||||
private readonly Configuration _configuration;
|
||||
private bool _settingsVisible;
|
||||
private int _expectedOpCode = -1;
|
||||
private uint _fishCount;
|
||||
|
||||
public FishNotifyPlugin()
|
||||
{
|
||||
configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
|
||||
configuration.Initialize(PluginInterface);
|
||||
_configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
|
||||
|
||||
Network.NetworkMessage += OnNetworkMessage;
|
||||
PluginInterface.UiBuilder.Draw += OnDrawUI;
|
||||
@ -87,8 +85,8 @@ namespace FishNotify
|
||||
return;
|
||||
}
|
||||
|
||||
expectedOpCode = eventPlay.Opcode;
|
||||
PluginLog.Debug($"Found EventPlay opcode {expectedOpCode:X4}");
|
||||
_expectedOpCode = eventPlay.Opcode;
|
||||
PluginLog.Debug($"Found EventPlay opcode {_expectedOpCode:X4}");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -98,7 +96,7 @@ namespace FishNotify
|
||||
|
||||
private void OnNetworkMessage(IntPtr dataPtr, ushort opCode, uint sourceActorId, uint targetActorId, NetworkMessageDirection direction)
|
||||
{
|
||||
if (direction != NetworkMessageDirection.ZoneDown || opCode != expectedOpCode)
|
||||
if (direction != NetworkMessageDirection.ZoneDown || opCode != _expectedOpCode)
|
||||
return;
|
||||
|
||||
var data = new byte[32];
|
||||
@ -121,21 +119,21 @@ namespace FishNotify
|
||||
|
||||
case 0x124:
|
||||
// light tug (!)
|
||||
++fishCount;
|
||||
++_fishCount;
|
||||
Sounds.PlaySound(Resources.Info);
|
||||
SendChatAlert("light");
|
||||
break;
|
||||
|
||||
case 0x125:
|
||||
// medium tug (!!)
|
||||
++fishCount;
|
||||
++_fishCount;
|
||||
Sounds.PlaySound(Resources.Alert);
|
||||
SendChatAlert("medium");
|
||||
break;
|
||||
|
||||
case 0x126:
|
||||
// heavy tug (!!!)
|
||||
++fishCount;
|
||||
++_fishCount;
|
||||
Sounds.PlaySound(Resources.Alarm);
|
||||
SendChatAlert("heavy");
|
||||
break;
|
||||
@ -148,7 +146,7 @@ namespace FishNotify
|
||||
|
||||
private void SendChatAlert(string size)
|
||||
{
|
||||
if (!configuration.ChatAlerts)
|
||||
if (!_configuration.ChatAlerts)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -157,7 +155,7 @@ namespace FishNotify
|
||||
.AddUiForeground(514)
|
||||
.Append("[FishNotify]")
|
||||
.AddUiForegroundOff()
|
||||
.Append($" You hook a fish with a ")
|
||||
.Append(" You hook a fish with a ")
|
||||
.AddUiForeground(514)
|
||||
.Append(size)
|
||||
.AddUiForegroundOff()
|
||||
@ -168,20 +166,20 @@ namespace FishNotify
|
||||
|
||||
private void OnDrawUI()
|
||||
{
|
||||
if (!settingsVisible)
|
||||
if (!_settingsVisible)
|
||||
return;
|
||||
|
||||
if (ImGui.Begin("FishNotify", ref this.settingsVisible, ImGuiWindowFlags.AlwaysAutoResize))
|
||||
if (ImGui.Begin("FishNotify", ref _settingsVisible, ImGuiWindowFlags.AlwaysAutoResize))
|
||||
{
|
||||
var chatAlerts = configuration.ChatAlerts;
|
||||
var chatAlerts = _configuration.ChatAlerts;
|
||||
if (ImGui.Checkbox("Show chat message on hooking a fish", ref chatAlerts))
|
||||
{
|
||||
configuration.ChatAlerts = chatAlerts;
|
||||
configuration.Save();
|
||||
_configuration.ChatAlerts = chatAlerts;
|
||||
PluginInterface.SavePluginConfig(_configuration);
|
||||
}
|
||||
|
||||
if (expectedOpCode > -1)
|
||||
ImGui.TextColored(ImGuiColors.HealerGreen, $"Status: {(fishCount == 0 ? "Unknown (not triggered yet)" : $"OK ({fishCount} fish hooked)")}, opcode = {expectedOpCode:X}");
|
||||
if (_expectedOpCode > -1)
|
||||
ImGui.TextColored(ImGuiColors.HealerGreen, $"Status: {(_fishCount == 0 ? "Unknown (not triggered yet)" : $"OK ({_fishCount} fish hooked)")}, opcode = {_expectedOpCode:X}");
|
||||
else
|
||||
ImGui.TextColored(ImGuiColors.DalamudRed, "Status: No opcode :(");
|
||||
}
|
||||
@ -190,20 +188,6 @@ namespace FishNotify
|
||||
|
||||
private void OnOpenConfigUi()
|
||||
{
|
||||
settingsVisible = !settingsVisible;
|
||||
}
|
||||
}
|
||||
|
||||
public class OpcodeRegion
|
||||
{
|
||||
public string? Version { get; set; }
|
||||
public string? Region { get; set; }
|
||||
public Dictionary<string, List<OpcodeList>>? Lists { get; set; }
|
||||
}
|
||||
|
||||
public class OpcodeList
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
public ushort Opcode { get; set; }
|
||||
_settingsVisible = !_settingsVisible;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<Authors></Authors>
|
||||
<Company></Company>
|
||||
<Version>5.0</Version>
|
||||
<Version>6.0</Version>
|
||||
<Description>Plays a sound effect when a fish bites</Description>
|
||||
<Copyright></Copyright>
|
||||
<PackageProjectUrl>https://github.com/carvelli/Fish-Notify</PackageProjectUrl>
|
||||
@ -37,7 +37,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DalamudPackager" Version="2.1.10" />
|
||||
<PackageReference Include="DalamudPackager" Version="2.1.12" />
|
||||
<PackageReference Include="System.Windows.Extensions" Version="7.0.0" />
|
||||
<Reference Include="FFXIVClientStructs">
|
||||
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
|
||||
@ -55,10 +55,6 @@
|
||||
<HintPath>$(DalamudLibPath)ImGui.NET.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="ImGuiScene">
|
||||
<HintPath>$(DalamudLibPath)ImGuiScene.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="Lumina">
|
||||
<HintPath>$(DalamudLibPath)Lumina.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
|
7
OpcodeList.cs
Normal file
7
OpcodeList.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace FishNotify;
|
||||
|
||||
public class OpcodeList
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
public ushort Opcode { get; set; }
|
||||
}
|
10
OpcodeRegion.cs
Normal file
10
OpcodeRegion.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FishNotify;
|
||||
|
||||
public class OpcodeRegion
|
||||
{
|
||||
public string? Version { get; set; }
|
||||
public string? Region { get; set; }
|
||||
public Dictionary<string, List<OpcodeList>>? Lists { get; set; }
|
||||
}
|
Loading…
Reference in New Issue
Block a user