parent
22b1f46e1d
commit
3bacccd216
25
Configuration.cs
Normal file
25
Configuration.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using Dalamud.Configuration;
|
||||||
|
using Dalamud.Plugin;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
using Dalamud.Data;
|
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.Interface.Colors;
|
||||||
using Dalamud.IoC;
|
using Dalamud.IoC;
|
||||||
using Dalamud.Logging;
|
using Dalamud.Logging;
|
||||||
@ -20,18 +22,27 @@ namespace FishNotify
|
|||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
[RequiredVersion("1.0")]
|
[RequiredVersion("1.0")]
|
||||||
private DalamudPluginInterface PluginInterface { get; set; }
|
private DalamudPluginInterface PluginInterface { get; set; } = null!;
|
||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
private GameNetwork Network { get; set; }
|
private GameNetwork Network { get; set; } = null!;
|
||||||
|
|
||||||
|
[PluginService]
|
||||||
|
public static ChatGui Chat { get; set; } = null!;
|
||||||
|
|
||||||
|
private Configuration configuration;
|
||||||
private bool settingsVisible;
|
private bool settingsVisible;
|
||||||
private int expectedOpCode = -1;
|
private int expectedOpCode = -1;
|
||||||
|
private uint fishCount = 0;
|
||||||
|
|
||||||
public FishNotifyPlugin()
|
public FishNotifyPlugin()
|
||||||
{
|
{
|
||||||
Network!.NetworkMessage += OnNetworkMessage;
|
configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
|
||||||
PluginInterface!.UiBuilder.Draw += OnDrawUI;
|
configuration.Initialize(PluginInterface);
|
||||||
PluginInterface!.UiBuilder.OpenConfigUi += OnOpenConfigUi;
|
|
||||||
|
Network.NetworkMessage += OnNetworkMessage;
|
||||||
|
PluginInterface.UiBuilder.Draw += OnDrawUI;
|
||||||
|
PluginInterface.UiBuilder.OpenConfigUi += OnOpenConfigUi;
|
||||||
|
|
||||||
var client = new HttpClient();
|
var client = new HttpClient();
|
||||||
client.GetStringAsync("https://raw.githubusercontent.com/karashiiro/FFXIVOpcodes/master/opcodes.min.json")
|
client.GetStringAsync("https://raw.githubusercontent.com/karashiiro/FFXIVOpcodes/master/opcodes.min.json")
|
||||||
@ -41,7 +52,7 @@ namespace FishNotify
|
|||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Network.NetworkMessage -= OnNetworkMessage;
|
Network.NetworkMessage -= OnNetworkMessage;
|
||||||
PluginInterface!.UiBuilder.Draw -= OnDrawUI;
|
PluginInterface.UiBuilder.Draw -= OnDrawUI;
|
||||||
PluginInterface.UiBuilder.OpenConfigUi -= OnOpenConfigUi;
|
PluginInterface.UiBuilder.OpenConfigUi -= OnOpenConfigUi;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +74,7 @@ namespace FishNotify
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!region.Lists.TryGetValue("ServerZoneIpcType", out List<OpcodeList> serverZoneIpcTypes))
|
if (!region.Lists.TryGetValue("ServerZoneIpcType", out List<OpcodeList>? serverZoneIpcTypes) || serverZoneIpcTypes == null)
|
||||||
{
|
{
|
||||||
PluginLog.Warning("No ServerZoneIpcType in opcode list");
|
PluginLog.Warning("No ServerZoneIpcType in opcode list");
|
||||||
return;
|
return;
|
||||||
@ -110,17 +121,23 @@ namespace FishNotify
|
|||||||
|
|
||||||
case 0x124:
|
case 0x124:
|
||||||
// light tug (!)
|
// light tug (!)
|
||||||
|
++fishCount;
|
||||||
Sounds.PlaySound(Resources.Info);
|
Sounds.PlaySound(Resources.Info);
|
||||||
|
SendChatAlert("light");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x125:
|
case 0x125:
|
||||||
// medium tug (!!)
|
// medium tug (!!)
|
||||||
|
++fishCount;
|
||||||
Sounds.PlaySound(Resources.Alert);
|
Sounds.PlaySound(Resources.Alert);
|
||||||
|
SendChatAlert("medium");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x126:
|
case 0x126:
|
||||||
// heavy tug (!!!)
|
// heavy tug (!!!)
|
||||||
|
++fishCount;
|
||||||
Sounds.PlaySound(Resources.Alarm);
|
Sounds.PlaySound(Resources.Alarm);
|
||||||
|
SendChatAlert("heavy");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -129,6 +146,26 @@ namespace FishNotify
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SendChatAlert(string size)
|
||||||
|
{
|
||||||
|
if (!configuration.ChatAlerts)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SeString message = new SeStringBuilder()
|
||||||
|
.AddUiForeground(514)
|
||||||
|
.Append("[FishNotify]")
|
||||||
|
.AddUiForegroundOff()
|
||||||
|
.Append($" You hook a fish with a ")
|
||||||
|
.AddUiForeground(514)
|
||||||
|
.Append(size)
|
||||||
|
.AddUiForegroundOff()
|
||||||
|
.Append(" bite.")
|
||||||
|
.Build();
|
||||||
|
Chat.Print(message);
|
||||||
|
}
|
||||||
|
|
||||||
private void OnDrawUI()
|
private void OnDrawUI()
|
||||||
{
|
{
|
||||||
if (!settingsVisible)
|
if (!settingsVisible)
|
||||||
@ -136,13 +173,21 @@ namespace FishNotify
|
|||||||
|
|
||||||
if (ImGui.Begin("FishNotify", ref this.settingsVisible, ImGuiWindowFlags.AlwaysAutoResize))
|
if (ImGui.Begin("FishNotify", ref this.settingsVisible, ImGuiWindowFlags.AlwaysAutoResize))
|
||||||
{
|
{
|
||||||
|
var chatAlerts = configuration.ChatAlerts;
|
||||||
|
if (ImGui.Checkbox("Show chat message on hooking a fish", ref chatAlerts))
|
||||||
|
{
|
||||||
|
configuration.ChatAlerts = chatAlerts;
|
||||||
|
configuration.Save();
|
||||||
|
}
|
||||||
|
|
||||||
if (expectedOpCode > -1)
|
if (expectedOpCode > -1)
|
||||||
ImGui.TextColored(ImGuiColors.HealerGreen, $"Status: OK, 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 :(");
|
||||||
}
|
}
|
||||||
ImGui.End();
|
ImGui.End();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnOpenConfigUi()
|
private void OnOpenConfigUi()
|
||||||
{
|
{
|
||||||
settingsVisible = !settingsVisible;
|
settingsVisible = !settingsVisible;
|
||||||
@ -151,14 +196,14 @@ namespace FishNotify
|
|||||||
|
|
||||||
public class OpcodeRegion
|
public class OpcodeRegion
|
||||||
{
|
{
|
||||||
public string Version { get; set; }
|
public string? Version { get; set; }
|
||||||
public string Region { get; set; }
|
public string? Region { get; set; }
|
||||||
public Dictionary<string, List<OpcodeList>> Lists { get; set; }
|
public Dictionary<string, List<OpcodeList>>? Lists { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class OpcodeList
|
public class OpcodeList
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string? Name { get; set; }
|
||||||
public ushort Opcode { get; set; }
|
public ushort Opcode { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Authors></Authors>
|
<Authors></Authors>
|
||||||
<Company></Company>
|
<Company></Company>
|
||||||
<Version>3.0.0.0</Version>
|
<Version>3.1.0.0</Version>
|
||||||
<Description>Plays a sound effect when a fish bites</Description>
|
<Description>Plays a sound effect when a fish bites</Description>
|
||||||
<Copyright></Copyright>
|
<Copyright></Copyright>
|
||||||
<PackageProjectUrl>https://github.com/carvelli/Fish-Notify</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/carvelli/Fish-Notify</PackageProjectUrl>
|
||||||
|
Loading…
Reference in New Issue
Block a user