Compare commits

...

4 Commits
v6.0 ... master

Author SHA1 Message Date
Liza 948028184f
API 10 2024-07-05 22:16:36 +02:00
Liza b86c30cb88
Update icon URL 2024-01-16 06:50:34 +01:00
Liza 59aa8c7dc7
API 9 2023-10-03 10:36:31 +02:00
Liza d425fa4040
Update README 2023-07-30 23:54:56 +02:00
9 changed files with 266 additions and 258 deletions

8
.gitignore vendored
View File

@ -1,4 +1,6 @@
.vs/ /dist
obj/ /obj
dist/ /bin
/.idea
/.vs
*.user *.user

View File

@ -1,25 +1,9 @@
using Dalamud.Configuration; 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 int Version { get; set; } = 0;
public bool ChatAlerts { get; set; } = false; 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);
}
}
} }

View File

@ -1,10 +1,7 @@
using Dalamud.Data; using Dalamud.Game.Network;
using Dalamud.Game.Gui;
using Dalamud.Game.Network;
using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Interface.Colors; using Dalamud.Interface.Colors;
using Dalamud.IoC; using Dalamud.IoC;
using Dalamud.Logging;
using Dalamud.Plugin; using Dalamud.Plugin;
using ImGuiNET; using ImGuiNET;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -13,32 +10,32 @@ using System.Collections.Generic;
using System.Net.Http; using System.Net.Http;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading.Tasks; using System.Threading.Tasks;
using Dalamud.Plugin.Services;
namespace FishNotify namespace FishNotify;
public sealed class FishNotifyPlugin : IDalamudPlugin
{ {
public sealed class FishNotifyPlugin : IDalamudPlugin [PluginService]
{ private IDalamudPluginInterface PluginInterface { get; set; } = null!;
public string Name => "FishNotify";
[PluginService] [PluginService]
[RequiredVersion("1.0")] private IGameNetwork Network { get; set; } = null!;
private DalamudPluginInterface PluginInterface { get; set; } = null!;
[PluginService] [PluginService]
private GameNetwork Network { get; set; } = null!; private IChatGui Chat { get; set; } = null!;
[PluginService] [PluginService]
public static ChatGui Chat { get; set; } = null!; private IPluginLog PluginLog { get; set; } = null!;
private Configuration configuration; private readonly Configuration _configuration;
private bool settingsVisible; private bool _settingsVisible;
private int expectedOpCode = -1; private int _expectedOpCode = -1;
private uint fishCount = 0; private uint _fishCount;
public FishNotifyPlugin() public FishNotifyPlugin()
{ {
configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration(); _configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
configuration.Initialize(PluginInterface);
Network.NetworkMessage += OnNetworkMessage; Network.NetworkMessage += OnNetworkMessage;
PluginInterface.UiBuilder.Draw += OnDrawUI; PluginInterface.UiBuilder.Draw += OnDrawUI;
@ -87,8 +84,8 @@ namespace FishNotify
return; return;
} }
expectedOpCode = eventPlay.Opcode; _expectedOpCode = eventPlay.Opcode;
PluginLog.Debug($"Found EventPlay opcode {expectedOpCode:X4}"); PluginLog.Debug($"Found EventPlay opcode {_expectedOpCode:X4}");
} }
catch (Exception e) catch (Exception e)
{ {
@ -98,7 +95,7 @@ namespace FishNotify
private void OnNetworkMessage(IntPtr dataPtr, ushort opCode, uint sourceActorId, uint targetActorId, NetworkMessageDirection direction) 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; return;
var data = new byte[32]; var data = new byte[32];
@ -121,21 +118,21 @@ namespace FishNotify
case 0x124: case 0x124:
// light tug (!) // light tug (!)
++fishCount; ++_fishCount;
Sounds.PlaySound(Resources.Info); Sounds.PlaySound(Resources.Info);
SendChatAlert("light"); SendChatAlert("light");
break; break;
case 0x125: case 0x125:
// medium tug (!!) // medium tug (!!)
++fishCount; ++_fishCount;
Sounds.PlaySound(Resources.Alert); Sounds.PlaySound(Resources.Alert);
SendChatAlert("medium"); SendChatAlert("medium");
break; break;
case 0x126: case 0x126:
// heavy tug (!!!) // heavy tug (!!!)
++fishCount; ++_fishCount;
Sounds.PlaySound(Resources.Alarm); Sounds.PlaySound(Resources.Alarm);
SendChatAlert("heavy"); SendChatAlert("heavy");
break; break;
@ -148,7 +145,7 @@ namespace FishNotify
private void SendChatAlert(string size) private void SendChatAlert(string size)
{ {
if (!configuration.ChatAlerts) if (!_configuration.ChatAlerts)
{ {
return; return;
} }
@ -157,7 +154,7 @@ namespace FishNotify
.AddUiForeground(514) .AddUiForeground(514)
.Append("[FishNotify]") .Append("[FishNotify]")
.AddUiForegroundOff() .AddUiForegroundOff()
.Append($" You hook a fish with a ") .Append(" You hook a fish with a ")
.AddUiForeground(514) .AddUiForeground(514)
.Append(size) .Append(size)
.AddUiForegroundOff() .AddUiForegroundOff()
@ -168,20 +165,20 @@ namespace FishNotify
private void OnDrawUI() private void OnDrawUI()
{ {
if (!settingsVisible) if (!_settingsVisible)
return; 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)) if (ImGui.Checkbox("Show chat message on hooking a fish", ref chatAlerts))
{ {
configuration.ChatAlerts = chatAlerts; _configuration.ChatAlerts = chatAlerts;
configuration.Save(); PluginInterface.SavePluginConfig(_configuration);
} }
if (expectedOpCode > -1) if (_expectedOpCode > -1)
ImGui.TextColored(ImGuiColors.HealerGreen, $"Status: {(fishCount == 0 ? "Unknown (not triggered yet)" : $"OK ({fishCount} fish hooked)")}, opcode = {expectedOpCode:X}"); ImGui.TextColored(ImGuiColors.HealerGreen, $"Status: {(_fishCount == 0 ? "Unknown (not triggered yet)" : $"OK ({_fishCount} fish hooked)")}, opcode = {_expectedOpCode:X}");
else else
ImGui.TextColored(ImGuiColors.DalamudRed, "Status: No opcode :("); ImGui.TextColored(ImGuiColors.DalamudRed, "Status: No opcode :(");
} }
@ -190,20 +187,6 @@ namespace FishNotify
private void OnOpenConfigUi() private void OnOpenConfigUi()
{ {
settingsVisible = !settingsVisible; _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; }
} }
} }

View File

@ -1,72 +1,17 @@
<?xml version="1.0" encoding="utf-8"?> <Project Sdk="Dalamud.NET.Sdk/9.0.2">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<Authors></Authors> <Version>7.0</Version>
<Company></Company>
<Version>5.0</Version>
<Description>Plays a sound effect when a fish bites</Description>
<Copyright></Copyright>
<PackageProjectUrl>https://github.com/carvelli/Fish-Notify</PackageProjectUrl>
<Configurations>Release</Configurations>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
<Platforms>x64</Platforms>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>dist</OutputPath> <OutputPath>dist</OutputPath>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Content Include="FishNotify.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<PropertyGroup>
<DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<DebugType>none</DebugType> <DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols> <DebugSymbols>false</DebugSymbols>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.10" /> <PackageReference Include="System.Windows.Extensions" Version="8.0.0" />
<PackageReference Include="System.Windows.Extensions" Version="7.0.0" />
<Reference Include="FFXIVClientStructs">
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>$(DalamudLibPath)Newtonsoft.Json.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Dalamud">
<HintPath>$(DalamudLibPath)Dalamud.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="ImGui.NET">
<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>
</Reference>
<Reference Include="Lumina.Excel">
<HintPath>$(DalamudLibPath)Lumina.Excel.dll</HintPath>
<Private>false</Private>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -8,5 +8,5 @@
"fishing" "fishing"
], ],
"RepoUrl": "https://git.carvel.li/liza/FishNotify", "RepoUrl": "https://git.carvel.li/liza/FishNotify",
"IconUrl": "https://git.carvel.li/liza/plugin-repo/raw/branch/master/dist/FishNotify.png" "IconUrl": "https://plugins.carvel.li/icons/FishNotify.png"
} }

7
OpcodeList.cs Normal file
View 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
View 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; }
}

View File

@ -5,4 +5,4 @@ watching YouTube during fishing.
## Installation ## Installation
[Installation Instructions](https://github.com/carvelli/Dalamud-Plugins#installation). [Installation Instructions](https://git.carvel.li/liza/plugin-repo/src/branch/master/README.md).

77
packages.lock.json Normal file
View File

@ -0,0 +1,77 @@
{
"version": 1,
"dependencies": {
"net8.0-windows7.0": {
"DalamudPackager": {
"type": "Direct",
"requested": "[2.1.13, )",
"resolved": "2.1.13",
"contentHash": "rMN1omGe8536f4xLMvx9NwfvpAc9YFFfeXJ1t4P4PE6Gu8WCIoFliR1sh07hM+bfODmesk/dvMbji7vNI+B/pQ=="
},
"DotNet.ReproducibleBuilds": {
"type": "Direct",
"requested": "[1.1.1, )",
"resolved": "1.1.1",
"contentHash": "+H2t/t34h6mhEoUvHi8yGXyuZ2GjSovcGYehJrS2MDm2XgmPfZL2Sdxg+uL2lKgZ4M6tTwKHIlxOob2bgh0NRQ==",
"dependencies": {
"Microsoft.SourceLink.AzureRepos.Git": "1.1.1",
"Microsoft.SourceLink.Bitbucket.Git": "1.1.1",
"Microsoft.SourceLink.GitHub": "1.1.1",
"Microsoft.SourceLink.GitLab": "1.1.1"
}
},
"System.Windows.Extensions": {
"type": "Direct",
"requested": "[8.0.0, )",
"resolved": "8.0.0",
"contentHash": "Obg3a90MkOw9mYKxrardLpY2u0axDMrSmy4JCdq2cYbelM2cUwmUir5Bomvd1yxmPL9h5LVHU1tuKBZpUjfASg=="
},
"Microsoft.Build.Tasks.Git": {
"type": "Transitive",
"resolved": "1.1.1",
"contentHash": "AT3HlgTjsqHnWpBHSNeR0KxbLZD7bztlZVj7I8vgeYG9SYqbeFGh0TM/KVtC6fg53nrWHl3VfZFvb5BiQFcY6Q=="
},
"Microsoft.SourceLink.AzureRepos.Git": {
"type": "Transitive",
"resolved": "1.1.1",
"contentHash": "qB5urvw9LO2bG3eVAkuL+2ughxz2rR7aYgm2iyrB8Rlk9cp2ndvGRCvehk3rNIhRuNtQaeKwctOl1KvWiklv5w==",
"dependencies": {
"Microsoft.Build.Tasks.Git": "1.1.1",
"Microsoft.SourceLink.Common": "1.1.1"
}
},
"Microsoft.SourceLink.Bitbucket.Git": {
"type": "Transitive",
"resolved": "1.1.1",
"contentHash": "cDzxXwlyWpLWaH0em4Idj0H3AmVo3L/6xRXKssYemx+7W52iNskj/SQ4FOmfCb8YQt39otTDNMveCZzYtMoucQ==",
"dependencies": {
"Microsoft.Build.Tasks.Git": "1.1.1",
"Microsoft.SourceLink.Common": "1.1.1"
}
},
"Microsoft.SourceLink.Common": {
"type": "Transitive",
"resolved": "1.1.1",
"contentHash": "WMcGpWKrmJmzrNeuaEb23bEMnbtR/vLmvZtkAP5qWu7vQsY59GqfRJd65sFpBszbd2k/bQ8cs8eWawQKAabkVg=="
},
"Microsoft.SourceLink.GitHub": {
"type": "Transitive",
"resolved": "1.1.1",
"contentHash": "IaJGnOv/M7UQjRJks7B6p7pbPnOwisYGOIzqCz5ilGFTApZ3ktOR+6zJ12ZRPInulBmdAf1SrGdDG2MU8g6XTw==",
"dependencies": {
"Microsoft.Build.Tasks.Git": "1.1.1",
"Microsoft.SourceLink.Common": "1.1.1"
}
},
"Microsoft.SourceLink.GitLab": {
"type": "Transitive",
"resolved": "1.1.1",
"contentHash": "tvsg47DDLqqedlPeYVE2lmiTpND8F0hkrealQ5hYltSmvruy/Gr5nHAKSsjyw5L3NeM/HLMI5ORv7on/M4qyZw==",
"dependencies": {
"Microsoft.Build.Tasks.Git": "1.1.1",
"Microsoft.SourceLink.Common": "1.1.1"
}
}
}
}
}