Compare commits

...

6 Commits

Author SHA1 Message Date
Anna dc0e23c3da
chore: bump version to 1.3.5 2023-11-18 11:04:28 -05:00
Anna a373ed8897
fix: allow larger messages 2023-11-18 11:04:04 -05:00
Anna 01ee2e3535
chore: update dependencies 2023-11-18 11:03:52 -05:00
Anna bcbcf8d61a
chore: bump version to 1.3.4 2023-10-03 03:15:51 -04:00
Anna 3e479b3347
fix: handle new dalamud context menu 2023-10-03 03:15:40 -04:00
Anna c76be2aaad
refactor: update for api 9 2023-09-27 21:44:39 -04:00
11 changed files with 68 additions and 77 deletions

View File

@ -7,7 +7,6 @@ using ASodium;
using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Logging;
using Dalamud.Utility;
using ExtraChat.Protocol;
using ExtraChat.Protocol.Channels;
@ -72,11 +71,11 @@ internal class Client : IDisposable {
this._waitersSemaphore.Dispose();
}
private void Login(object? sender, EventArgs e) {
private void Login() {
this.StartLoop();
}
private void Logout(object? sender, EventArgs e) {
private void Logout() {
this.StopLoop();
}
@ -98,9 +97,9 @@ internal class Client : IDisposable {
try {
await this.Loop();
} catch (Exception ex) {
PluginLog.LogError(ex, "Error in client loop");
Plugin.Log.Error(ex, "Error in client loop");
if (this._wasConnected) {
this.Plugin.ChatGui.PrintChat(new XivChatEntry {
this.Plugin.ChatGui.Print(new XivChatEntry {
Message = "Disconnected from ExtraChat. Trying to reconnect.",
Type = XivChatType.Urgent,
});
@ -164,7 +163,7 @@ internal class Client : IDisposable {
if (await this.Authenticate()) {
this._wasConnected = true;
this.Plugin.ChatGui.PrintChat(new XivChatEntry {
this.Plugin.ChatGui.Print(new XivChatEntry {
Message = "Connected to ExtraChat.",
Type = XivChatType.Notice,
});
@ -663,7 +662,7 @@ internal class Client : IDisposable {
#pragma warning restore CS4014
private void HandleAnnounce(AnnounceResponse resp) {
this.Plugin.ChatGui.PrintChat(new XivChatEntry {
this.Plugin.ChatGui.Print(new XivChatEntry {
Type = XivChatType.Notice,
Message = $"[ExtraChat] {resp.Announcement}",
});
@ -706,7 +705,7 @@ internal class Client : IDisposable {
break;
}
default: {
PluginLog.LogWarning($"Unhandled update kind: {resp.Kind}");
Plugin.Log.Warning($"Unhandled update kind: {resp.Kind}");
break;
}
}
@ -993,7 +992,7 @@ internal class Client : IDisposable {
outputChannel = XivChatType.Debug;
}
this.Plugin.ChatGui.PrintChat(new XivChatEntry {
this.Plugin.ChatGui.Print(new XivChatEntry {
Message = output.Build(),
Name = isSelf
? resp.Sender

View File

@ -1,5 +1,4 @@
using Dalamud.Game.Command;
using Dalamud.Logging;
using ExtraChat.Util;
namespace ExtraChat;
@ -23,7 +22,7 @@ internal class Commands : IDisposable {
this.RegisterAll();
}
private void OnLogout(object? sender, EventArgs e) {
private void OnLogout() {
this.UnregisterAll();
}
@ -74,7 +73,7 @@ internal class Commands : IDisposable {
this.RegisteredInternal[command] = id;
void Handler(string _, string arguments) {
PluginLog.LogWarning("Command handler actually invoked");
Plugin.Log.Warning("Command handler actually invoked");
}
this.Plugin.CommandManager.AddHandler(command, new CommandInfo(Handler) {

View File

@ -16,7 +16,7 @@ public static class Ext {
}
public static async Task<ResponseContainer> ReceiveMessage(this ClientWebSocket client) {
var bytes = new ArraySegment<byte>(new byte[2048]);
var bytes = new ArraySegment<byte>(new byte[64 * 1024]);
WebSocketReceiveResult result;
var i = 0;

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.3.3</Version>
<Version>1.3.5</Version>
<TargetFramework>net7.0-windows</TargetFramework>
<LangVersion>preview</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
@ -55,11 +55,11 @@
<ItemGroup>
<PackageReference Include="ASodium" Version="0.5.6"/>
<PackageReference Include="Dalamud.ContextMenu" Version="1.2.3"/>
<PackageReference Include="DalamudPackager" Version="2.1.11"/>
<PackageReference Include="MessagePack" Version="2.5.108"/>
<PackageReference Include="Dalamud.ContextMenu" Version="1.3.1"/>
<PackageReference Include="DalamudPackager" Version="2.1.12"/>
<PackageReference Include="MessagePack" Version="2.5.129"/>
<PackageReference Include="System.Net.WebSockets.Client" Version="4.3.2"/>
<PackageReference Include="System.Threading.Channels" Version="7.0.0"/>
<PackageReference Include="System.Threading.Channels" Version="8.0.0"/>
</ItemGroup>
</Project>

View File

@ -2,7 +2,6 @@
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Hooking;
using Dalamud.Logging;
using Dalamud.Memory;
using Dalamud.Utility.Signatures;
using FFXIVClientStructs.FFXIV.Client.System.Framework;
@ -89,8 +88,8 @@ internal unsafe class GameFunctions : IDisposable {
private bool _shouldForceNameLookup;
internal GameFunctions(Plugin plugin) {
SignatureHelper.Initialise(this);
this.Plugin = plugin;
this.Plugin.GameInteropProvider.InitializeFromAttributes(this);
this.SendMessageHook!.Enable();
this.SetChatChannelHook!.Enable();
@ -158,7 +157,7 @@ internal unsafe class GameFunctions : IDisposable {
this.SendMessageHook.Original(a1, message, a3);
}
} catch (Exception ex) {
PluginLog.LogError(ex, "Error in message detour");
Plugin.Log.Error(ex, "Error in message detour");
}
}
@ -272,7 +271,7 @@ internal unsafe class GameFunctions : IDisposable {
}
}
} catch (Exception ex) {
PluginLog.LogError(ex, "Error in get chat colour detour");
Plugin.Log.Error(ex, "Error in get chat colour detour");
}
return this.GetChatColourHook.Original(a1, a2);

View File

@ -1,17 +1,12 @@
using ASodium;
using Dalamud.ContextMenu;
using Dalamud.Data;
using Dalamud.Game;
using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.Command;
using Dalamud.Game.Gui;
using Dalamud.Game.Gui.Toast;
using Dalamud.Game.Text;
using Dalamud.Interface.Internal.Notifications;
using Dalamud.IoC;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using ExtraChat.Integrations;
using ExtraChat.Ui;
using ExtraChat.Util;
@ -20,40 +15,45 @@ namespace ExtraChat;
// ReSharper disable once ClassNeverInstantiated.Global
public class Plugin : IDalamudPlugin {
internal const string PluginName = "ExtraChat";
internal const ushort DefaultColour = 578;
public string Name => PluginName;
internal static string Name => "ExtraChat";
[PluginService]
internal static IPluginLog Log { get; private set; }
[PluginService]
internal DalamudPluginInterface Interface { get; init; }
[PluginService]
internal ClientState ClientState { get; init; }
internal IClientState ClientState { get; init; }
[PluginService]
internal CommandManager CommandManager { get; init; }
internal ICommandManager CommandManager { get; init; }
[PluginService]
internal ChatGui ChatGui { get; init; }
internal IChatGui ChatGui { get; init; }
[PluginService]
internal DataManager DataManager { get; init; }
internal IDataManager DataManager { get; init; }
[PluginService]
internal Framework Framework { get; init; }
internal IFramework Framework { get; init; }
[PluginService]
internal GameGui GameGui { get; init; }
internal IGameGui GameGui { get; init; }
[PluginService]
internal ObjectTable ObjectTable { get; init; }
internal IObjectTable ObjectTable { get; init; }
[PluginService]
internal TargetManager TargetManager { get; init; }
internal ITargetManager TargetManager { get; init; }
[PluginService]
private ToastGui ToastGui { get; init; }
internal IGameInteropProvider GameInteropProvider { get; init; }
[PluginService]
private IToastGui ToastGui { get; init; }
internal Configuration Config { get; }
internal ConfigInfo ConfigInfo => this.Config.GetConfig(this.ClientState.LocalContentId);
@ -85,7 +85,7 @@ public class Plugin : IDalamudPlugin {
public Plugin() {
SodiumInit.Init();
WorldUtil.Initialise(this.DataManager!);
this.ContextMenu = new DalamudContextMenu();
this.ContextMenu = new DalamudContextMenu(this.Interface);
this.Config = this.Interface!.GetPluginConfig() as Configuration ?? new Configuration();
this.Client = new Client(this);
this.Commands = new Commands(this);
@ -120,7 +120,7 @@ public class Plugin : IDalamudPlugin {
this.ContextMenu.Dispose();
}
private void FrameworkUpdate(Framework framework) {
private void FrameworkUpdate(IFramework framework) {
if (this.ClientState.LocalPlayer is { } player) {
this.LocalPlayer = player;
} else if (!this.ClientState.IsLoggedIn) {
@ -173,10 +173,10 @@ public class Plugin : IDalamudPlugin {
if (this.Config.UseNativeToasts) {
this.ToastGui.ShowNormal(message);
} else {
this.Interface.UiBuilder.AddNotification(message, this.Name, NotificationType.Info);
this.Interface.UiBuilder.AddNotification(message, Name, NotificationType.Info);
}
this.ChatGui.PrintChat(new XivChatEntry {
this.ChatGui.Print(new XivChatEntry {
Type = XivChatType.SystemMessage,
Message = message,
});
@ -186,10 +186,10 @@ public class Plugin : IDalamudPlugin {
if (this.Config.UseNativeToasts) {
this.ToastGui.ShowError(message);
} else {
this.Interface.UiBuilder.AddNotification(message, this.Name, NotificationType.Error);
this.Interface.UiBuilder.AddNotification(message, Name, NotificationType.Error);
}
this.ChatGui.PrintChat(new XivChatEntry {
this.ChatGui.Print(new XivChatEntry {
Type = XivChatType.ErrorMessage,
Message = message,
});

View File

@ -1,6 +1,7 @@
using System.Numerics;
using System.Text;
using Dalamud.Interface;
using Dalamud.Interface.Utility;
using ExtraChat.Protocol;
using ExtraChat.Protocol.Channels;
using ExtraChat.Util;
@ -40,10 +41,10 @@ internal class ChannelList {
var syncButton = ImGui.CalcTextSize(FontAwesomeIcon.Sync.ToIconString()).X
+ ImGui.GetStyle().FramePadding.X * 2;
// PluginLog.Log($"syncButton: {syncButton}");
// Plugin.Log.Info($"syncButton: {syncButton}");
var addButton = ImGui.CalcTextSize(FontAwesomeIcon.Plus.ToIconString()).X
+ ImGui.GetStyle().FramePadding.X * 2;
// PluginLog.Log($"addButton: {addButton}");
// Plugin.Log.Info($"addButton: {addButton}");
var syncOffset = ImGui.GetContentRegionAvail().X - syncButton;
var addOffset = ImGui.GetContentRegionAvail().X - syncButton - ImGui.GetStyle().ItemSpacing.X - addButton;
ImGui.SameLine(syncOffset);

View File

@ -3,6 +3,7 @@ using System.Numerics;
using System.Threading.Channels;
using Dalamud;
using Dalamud.Interface;
using Dalamud.Interface.Utility;
using Dalamud.Plugin;
using ExtraChat.Protocol.Channels;
using ExtraChat.Util;
@ -77,7 +78,7 @@ internal class PluginUi : IDisposable {
ImGui.SetNextWindowSize(new Vector2(500, 325) * ImGuiHelpers.GlobalScale, ImGuiCond.FirstUseEver);
if (!ImGui.Begin(this.Plugin.Name, ref this.Visible)) {
if (!ImGui.Begin(Plugin.Name, ref this.Visible)) {
ImGui.End();
return;
}

View File

@ -1,6 +1,7 @@
using System.Numerics;
using System.Text;
using Dalamud.Interface;
using Dalamud.Interface.Utility;
using ImGuiNET;
namespace ExtraChat.Util;

View File

@ -1,4 +1,4 @@
using Dalamud.Data;
using Dalamud.Plugin.Services;
using Lumina.Excel.GeneratedSheets;
namespace ExtraChat.Util;
@ -6,7 +6,7 @@ namespace ExtraChat.Util;
internal static class WorldUtil {
private static readonly Dictionary<ushort, string> WorldNames = new();
internal static void Initialise(DataManager data) {
internal static void Initialise(IDataManager data) {
WorldNames.Clear();
var worlds = data.GetExcelSheet<World>();

View File

@ -13,24 +13,24 @@
},
"Dalamud.ContextMenu": {
"type": "Direct",
"requested": "[1.2.3, )",
"resolved": "1.2.3",
"contentHash": "ydemplF7DNcA/LLeongDVzWUD/JV0Fw3EwA2+P0jYq3Le2ZYSt4U8qyJq4FyoChqt0lFG8BxYCAzfeWp4Jmnqw=="
"requested": "[1.3.1, )",
"resolved": "1.3.1",
"contentHash": "ptAxut5PiLnzZ4G/KQdHJVcyklC/BF3otHJ7zYVUPiKBjsOCoF0n/6h2jK7e+8ev2Y1yAY3Wtx2GuXLFQgt9Uw=="
},
"DalamudPackager": {
"type": "Direct",
"requested": "[2.1.11, )",
"resolved": "2.1.11",
"contentHash": "9qlAWoRRTiL/geAvuwR/g6Bcbrd/bJJgVnB/RurBiyKs6srsP0bvpoo8IK+Eg8EA6jWeM6/YJWs66w4FIAzqPw=="
"requested": "[2.1.12, )",
"resolved": "2.1.12",
"contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg=="
},
"MessagePack": {
"type": "Direct",
"requested": "[2.5.108, )",
"resolved": "2.5.108",
"contentHash": "kcVRbdWP3xNWLZmmpm4DFO+kuXf6mUR2mHZ27WoZIEFIv9hazuUd80injXhNrZnlq/FklAdCsLOil5M76I4Ndg==",
"requested": "[2.5.129, )",
"resolved": "2.5.129",
"contentHash": "1jBW0Q3qvv+PJBwer8lQ2l26/fKptJIqFgVdyKfn4zW+LSYE8xEcvd4svfh0erI5f4d+rQRIAN229I2ARI/A5w==",
"dependencies": {
"MessagePack.Annotations": "2.5.108",
"Microsoft.NET.StringTools": "17.4.0",
"MessagePack.Annotations": "2.5.129",
"Microsoft.NET.StringTools": "17.6.3",
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
}
},
@ -70,9 +70,9 @@
},
"System.Threading.Channels": {
"type": "Direct",
"requested": "[7.0.0, )",
"resolved": "7.0.0",
"contentHash": "qmeeYNROMsONF6ndEZcIQ+VxR4Q/TX/7uIVLJqtwIWL7dDWeh0l1UIqgo4wYyjG//5lUNhwkLDSFl+pAWO6oiA=="
"requested": "[8.0.0, )",
"resolved": "8.0.0",
"contentHash": "CMaFr7v+57RW7uZfZkPExsPB6ljwzhjACWW1gfU35Y56rk72B/Wu+sTqxVmGSk4SFUlPc3cjeKND0zktziyjBA=="
},
"libsodium": {
"type": "Transitive",
@ -81,17 +81,13 @@
},
"MessagePack.Annotations": {
"type": "Transitive",
"resolved": "2.5.108",
"contentHash": "28aNCvfJClgwaKr26gf2S6LT+C1PNyPxiG+ihYpy8uCJsRLJEDoCt2I0Uk5hqOPQ8P8hI0ESy520oMkZkPmsOQ=="
"resolved": "2.5.129",
"contentHash": "wNJB3EaJKjq+5pti+0T8b444fEb2PRw3hFefp9+of/BvDdTWO0iIUWfYNZbKx5aAIrpFzhLEfMAEJnGWWq3OFQ=="
},
"Microsoft.NET.StringTools": {
"type": "Transitive",
"resolved": "17.4.0",
"contentHash": "06T6Hqfs3JDIaBvJaBRFFMIdU7oE0OMab5Xl8LKQjWPxBQr3BgVFKMQPTC+GsSEuYREWmK6g5eOd7Xqd9p1YCA==",
"dependencies": {
"System.Memory": "4.5.5",
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
}
"resolved": "17.6.3",
"contentHash": "N0ZIanl1QCgvUumEL1laasU0a7sOE5ZwLZVTn0pAePnfhq8P7SvTjF8Axq+CnavuQkmdQpGNXQ1efZtu5kDFbA=="
},
"Microsoft.NETCore.Platforms": {
"type": "Transitive",
@ -348,11 +344,6 @@
"System.Runtime.Extensions": "4.3.0"
}
},
"System.Memory": {
"type": "Transitive",
"resolved": "4.5.5",
"contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw=="
},
"System.Net.NameResolution": {
"type": "Transitive",
"resolved": "4.3.0",