Compare commits

..

1 Commits
master ... CN

Author SHA1 Message Date
2afb1933e3
Experimental CN support 2023-02-12 00:37:36 +01:00
11 changed files with 322 additions and 271 deletions

9
.gitignore vendored
View File

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

View File

@ -1,9 +1,25 @@
using Dalamud.Configuration;
using Dalamud.Plugin;
using System;
namespace FishNotify;
internal sealed class Configuration : IPluginConfiguration
namespace FishNotify
{
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);
}
}
}

View File

@ -8,4 +8,13 @@
MakeZip="true"
VersionComponents="2"/>
</Target>
<Target Name="PackagePlugin" AfterTargets="Build" Condition="'$(Configuration)' == 'Release-CN'">
<DalamudPackager
ProjectDir="$(ProjectDir)"
OutputPath="$(OutputPath)"
AssemblyName="$(AssemblyName)"
MakeZip="true"
VersionComponents="2"/>
</Target>
</Project>

View File

@ -1,7 +1,10 @@
using Dalamud.Game.Network;
using Dalamud;
using Dalamud.Game.Gui;
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;
@ -10,32 +13,32 @@ using System.Collections.Generic;
using System.Net.Http;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Dalamud.Plugin.Services;
namespace FishNotify;
public sealed class FishNotifyPlugin : IDalamudPlugin
namespace FishNotify
{
[PluginService]
private IDalamudPluginInterface PluginInterface { get; set; } = null!;
public sealed class FishNotifyPlugin : IDalamudPlugin
{
public string Name => "FishNotify";
[PluginService]
private IGameNetwork Network { get; set; } = null!;
[RequiredVersion("1.0")]
private DalamudPluginInterface PluginInterface { get; set; } = null!;
[PluginService]
private IChatGui Chat { get; set; } = null!;
private GameNetwork Network { get; set; } = null!;
[PluginService]
private IPluginLog PluginLog { get; set; } = null!;
public static ChatGui Chat { get; set; } = null!;
private readonly Configuration _configuration;
private bool _settingsVisible;
private int _expectedOpCode = -1;
private uint _fishCount;
private Configuration configuration;
private bool settingsVisible;
private int expectedOpCode = -1;
private uint fishCount = 0;
public FishNotifyPlugin()
{
_configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
configuration.Initialize(PluginInterface);
Network.NetworkMessage += OnNetworkMessage;
PluginInterface.UiBuilder.Draw += OnDrawUI;
@ -64,7 +67,7 @@ public sealed class FishNotifyPlugin : IDalamudPlugin
return;
}
var region = regions.Find(r => r.Region == "Global");
var region = regions.Find(r => r.Region == GetGameRegion());
if (region == null || region.Lists == null)
{
PluginLog.Warning("No global region found in opcode list");
@ -84,8 +87,8 @@ public sealed class FishNotifyPlugin : IDalamudPlugin
return;
}
_expectedOpCode = eventPlay.Opcode;
PluginLog.Debug($"Found EventPlay opcode {_expectedOpCode:X4}");
expectedOpCode = eventPlay.Opcode;
PluginLog.Debug($"Found EventPlay opcode {expectedOpCode:X4}");
}
catch (Exception e)
{
@ -93,9 +96,23 @@ public sealed class FishNotifyPlugin : IDalamudPlugin
}
}
/// <summary>
/// Both ClientLanguage.Korean and ClientLanguage.ChineseSimplified have value 4, but the string representation differs depending on the dalamud fork.
/// </summary>
/// <returns></returns>
private string GetGameRegion()
{
return Enum.GetName(typeof(ClientLanguage), 4) switch
{
"ChineseSimplified" => "CN",
"Korean" => "KR",
_ => "Global",
};
}
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];
@ -118,21 +135,21 @@ public sealed class FishNotifyPlugin : IDalamudPlugin
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;
@ -145,7 +162,7 @@ public sealed class FishNotifyPlugin : IDalamudPlugin
private void SendChatAlert(string size)
{
if (!_configuration.ChatAlerts)
if (!configuration.ChatAlerts)
{
return;
}
@ -154,7 +171,7 @@ public sealed class FishNotifyPlugin : IDalamudPlugin
.AddUiForeground(514)
.Append("[FishNotify]")
.AddUiForegroundOff()
.Append(" You hook a fish with a ")
.Append($" You hook a fish with a ")
.AddUiForeground(514)
.Append(size)
.AddUiForegroundOff()
@ -165,20 +182,20 @@ public sealed class FishNotifyPlugin : IDalamudPlugin
private void OnDrawUI()
{
if (!_settingsVisible)
if (!settingsVisible)
return;
if (ImGui.Begin("FishNotify", ref _settingsVisible, ImGuiWindowFlags.AlwaysAutoResize))
if (ImGui.Begin("FishNotify", ref this.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;
PluginInterface.SavePluginConfig(_configuration);
configuration.ChatAlerts = chatAlerts;
configuration.Save();
}
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 :(");
}
@ -187,6 +204,20 @@ public sealed class FishNotifyPlugin : IDalamudPlugin
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,17 +1,100 @@
<Project Sdk="Dalamud.NET.Sdk/9.0.2">
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>7.0</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<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;Release-CN</Configurations>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<TargetFramework>net7.0-windows</TargetFramework>
<DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
<OutputPath>dist</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<PropertyGroup Condition="'$(Configuration)'=='Release-CN'">
<TargetFramework>net6.0-windows</TargetFramework>
<DalamudLibPath>E:\ffxiv\CN-dalamud\XIVLauncherCN\Roaming\addon\Hooks\dev\</DalamudLibPath>
<OutputPath>dist-CN</OutputPath>
</PropertyGroup>
<PropertyGroup>
<Platforms>x64</Platforms>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<ItemGroup Condition="'$(Configuration)'=='Release'">
<Compile Remove="dist-CN\**" />
<EmbeddedResource Remove="dist-CN\**" />
<None Remove="dist-CN\**" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)'=='Release-CN'">
<Compile Remove="dist\**" />
<EmbeddedResource Remove="dist\**" />
<None Remove="dist\**" />
</ItemGroup>
<ItemGroup>
<Content Include="FishNotify.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release'">
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-CN'">
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>
<ItemGroup Condition="'$(Configuration)'=='Release'">
<PackageReference Include="DalamudPackager" Version="2.1.10" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)'=='Release-CN'">
<PackageReference Include="DalamudPackager" Version="2.1.8" />
</ItemGroup>
<ItemGroup>
<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>
@ -29,8 +112,12 @@
</EmbeddedResource>
</ItemGroup>
<Target Name="RenameLatestZip" AfterTargets="PackagePlugin">
<Target Name="RenameLatestZip" AfterTargets="PackagePlugin" Condition="'$(Configuration)'=='Release'">
<Exec Command="rename &quot;$(OutDir)$(AssemblyName)\latest.zip&quot; &quot;$(AssemblyName)-$(Version).zip&quot;" />
</Target>
<Target Name="RenameLatestZip" AfterTargets="PackagePlugin" Condition="'$(Configuration)'=='Release-CN'">
<Exec Command="rename &quot;$(OutDir)$(AssemblyName)\latest.zip&quot; &quot;$(AssemblyName)-$(Version)-CN.zip&quot;" />
</Target>
</Project>

View File

@ -7,6 +7,6 @@
"Tags": [
"fishing"
],
"RepoUrl": "https://git.carvel.li/liza/FishNotify",
"IconUrl": "https://plugins.carvel.li/icons/FishNotify.png"
"RepoUrl": "https://github.com/carvelli/Fish-Notify",
"IconUrl": "https://raw.githubusercontent.com/carvelli/Dalamud-Plugins/master/dist/FishNotify.png"
}

View File

@ -1,17 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29709.97
# Visual Studio Version 17
VisualStudioVersion = 17.4.33213.308
MinimumVisualStudioVersion = 10.0.40219.1
Project("{DFE2B530-7D7B-41FD-B03C-8E11371610E3}") = "FishNotify", "FishNotify.csproj", "{3F91A6A9-5F97-4F6D-864C-DA066F94121A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishNotify", "FishNotify.csproj", "{3F91A6A9-5F97-4F6D-864C-DA066F94121A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Release|x64 = Release|x64
Release-CN|x64 = Release-CN|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3F91A6A9-5F97-4F6D-864C-DA066F94121A}.Release|x64.ActiveCfg = Release|x64
{3F91A6A9-5F97-4F6D-864C-DA066F94121A}.Release|x64.Build.0 = Release|x64
{3F91A6A9-5F97-4F6D-864C-DA066F94121A}.Release-CN|x64.ActiveCfg = Release-CN|x64
{3F91A6A9-5F97-4F6D-864C-DA066F94121A}.Release-CN|x64.Build.0 = Release-CN|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -1,7 +0,0 @@
namespace FishNotify;
public class OpcodeList
{
public string? Name { get; set; }
public ushort Opcode { get; set; }
}

View File

@ -1,10 +0,0 @@
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 Instructions](https://git.carvel.li/liza/plugin-repo/src/branch/master/README.md).
[Installation Instructions](https://github.com/carvelli/Dalamud-Plugins#installation).

View File

@ -1,77 +0,0 @@
{
"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"
}
}
}
}
}