Compare commits

...

No commits in common. "v1.18.3" and "main" have entirely different histories.

22 changed files with 162 additions and 141 deletions

View File

@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.18.3</Version>
<TargetFramework>net6.0-windows</TargetFramework>
<Version>1.18.10</Version>
<TargetFramework>net7.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@ -39,10 +39,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>
@ -54,11 +50,11 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.8"/>
<PackageReference Include="LiteDB" Version="5.0.12"/>
<PackageReference Include="Pidgin" Version="3.2.0"/>
<PackageReference Include="DalamudPackager" Version="2.1.12"/>
<PackageReference Include="LiteDB" Version="5.0.17"/>
<PackageReference Include="Pidgin" Version="3.2.2"/>
<PackageReference Include="SharpDX.Direct2D1" Version="4.2.0"/>
<PackageReference Include="XivCommon" Version="6.0.1"/>
<PackageReference Include="XivCommon" Version="9.0.0"/>
</ItemGroup>
<ItemGroup>

View File

@ -1,5 +1,5 @@
name: Chat 2
author: ascclemens
author: Anna
punchline: Electric Boogaloo - ♪ A whole new chat, a new fantastic chat window ♪
description: |-
Chat 2 is a complete rewrite of the in-game chat window as a plugin. It
@ -13,6 +13,6 @@ description: |-
- Sidebar tabs
- Unread counts
- Screenshot mode (obfuscate names)
repo_url: https://git.annaclemens.io/ascclemens/ChatTwo
repo_url: https://git.anna.lgbt/anna/ChatTwo
accepts_feedback: false
feedback_message: Submit only bugs to https://github.com/ascclemens/plugin-issues
feedback_message: Submit only bugs to https://github.com/anna/plugin-issues

View File

@ -1,4 +1,4 @@
using Dalamud.Data;
using Dalamud.Plugin.Services;
using Lumina.Excel.GeneratedSheets;
namespace ChatTwo.Code;
@ -82,7 +82,7 @@ internal static class InputChannelExt {
_ => "",
};
public static IEnumerable<TextCommand>? TextCommands(this InputChannel channel, DataManager data) {
public static IEnumerable<TextCommand>? TextCommands(this InputChannel channel, IDataManager data) {
var ids = channel switch {
InputChannel.Tell => new uint[] { 104, 118 },
InputChannel.Say => new uint[] { 102 },

View File

@ -1,5 +1,4 @@
using Dalamud.Game.Command;
using Dalamud.Logging;
namespace ChatTwo;
@ -45,14 +44,14 @@ internal sealed class Commands : IDisposable {
private void Invoke(string command, string arguments) {
if (!this.Registered.TryGetValue(command, out var wrapper)) {
PluginLog.Warning($"Missing registration for command {command}");
Plugin.Log.Warning($"Missing registration for command {command}");
return;
}
try {
wrapper.Invoke(command, arguments);
} catch (Exception ex) {
PluginLog.Error(ex, $"Error while executing command {command}");
Plugin.Log.Error(ex, $"Error while executing command {command}");
}
}
}

View File

@ -2,7 +2,6 @@ using ChatTwo.Code;
using ChatTwo.Resources;
using ChatTwo.Ui;
using Dalamud.Configuration;
using Dalamud.Logging;
using ImGuiNET;
namespace ChatTwo;
@ -124,7 +123,7 @@ internal class Configuration : IPluginConfiguration {
break;
default:
PluginLog.Warning($"Couldn't migrate config version {this.Version}");
Plugin.Log.Warning($"Couldn't migrate config version {this.Version}");
loop = false;
break;
}

View File

@ -3,10 +3,11 @@ using ChatTwo.Code;
using ChatTwo.GameFunctions.Types;
using ChatTwo.Util;
using Dalamud.Game.ClientState.Keys;
using Dalamud.Game.Config;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Hooking;
using Dalamud.Logging;
using Dalamud.Memory;
using Dalamud.Plugin.Services;
using Dalamud.Utility.Signatures;
using FFXIVClientStructs.FFXIV.Client.System.Framework;
using FFXIVClientStructs.FFXIV.Client.System.Memory;
@ -38,7 +39,7 @@ internal sealed unsafe class Chat : IDisposable {
[Signature("44 8B 89 ?? ?? ?? ?? 4C 8B C1 45 85 C9")]
private readonly delegate* unmanaged<void*, int, IntPtr> _getTellHistory = null!;
[Signature("E8 ?? ?? ?? ?? B8 ?? ?? ?? ?? 48 8D 4D 50")]
[Signature("E8 ?? ?? ?? ?? 48 8D 4D 50 E8 ?? ?? ?? ?? 48 8B 17")]
private readonly delegate* unmanaged<RaptureLogModule*, ushort, Utf8String*, Utf8String*, ulong, ushort, byte, int, byte, void> _printTell = null!;
[Signature("E8 ?? ?? ?? ?? 48 8D 4C 24 ?? E8 ?? ?? ?? ?? 48 8D 8C 24 ?? ?? ?? ?? E8 ?? ?? ?? ?? B0 01")]
@ -53,7 +54,7 @@ internal sealed unsafe class Chat : IDisposable {
[Signature("3B 51 10 73 0F 8B C2 48 83 C0 0B")]
private readonly delegate* unmanaged<IntPtr, uint, ulong*> _getLinkshellInfo = null!;
[Signature("E8 ?? ?? ?? ?? 4C 8B C0 FF C3")]
[Signature("E8 ?? ?? ?? ?? 4C 8B C8 44 8D 47 01")]
private readonly delegate* unmanaged<IntPtr, ulong, byte*> _getLinkshellName = null!;
[Signature("40 56 41 54 41 55 41 57 48 83 EC 28 48 8B 01", Fallibility = Fallibility.Fallible)]
@ -142,7 +143,7 @@ internal sealed unsafe class Chat : IDisposable {
internal Chat(Plugin plugin) {
this.Plugin = plugin;
SignatureHelper.Initialise(this);
this.Plugin.GameInteropProvider.InitializeFromAttributes(this);
this.ChatLogRefreshHook?.Enable();
this.ChangeChannelNameHook?.Enable();
@ -151,7 +152,7 @@ internal sealed unsafe class Chat : IDisposable {
this.Plugin.Framework.Update += this.InterceptKeybinds;
this.Plugin.ClientState.Login += this.Login;
this.Login(null, null);
this.Login();
}
public void Dispose() {
@ -368,7 +369,7 @@ internal sealed unsafe class Chat : IDisposable {
}
}
private void InterceptKeybinds(Dalamud.Game.Framework framework) {
private void InterceptKeybinds(IFramework framework1) {
this.CheckFocus();
this.UpdateKeybinds();
@ -430,12 +431,12 @@ internal sealed unsafe class Chat : IDisposable {
TellReason = TellReason.Reply,
});
} catch (Exception ex) {
PluginLog.LogError(ex, "Error in chat Activated event");
Plugin.Log.Error(ex, "Error in chat Activated event");
}
}
}
private void Login(object? sender, EventArgs? e) {
private void Login() {
if (this.ChangeChannelNameHook == null) {
return;
}
@ -454,10 +455,8 @@ internal sealed unsafe class Chat : IDisposable {
}
string? input = null;
var option = Framework.Instance()->GetUiModule()->GetConfigModule()->GetValue(ConfigOption.DirectChat);
if (option != null) {
var directChat = option->Int > 0;
if (directChat && this._currentCharacter != null) {
if (this.Plugin.GameConfig.TryGet(UiControlOption.DirectChat, out bool option) && option) {
if (this._currentCharacter != null) {
// FIXME: this whole system sucks
var c = *this._currentCharacter;
if (c != '\0' && !char.IsControl(c)) {
@ -483,7 +482,7 @@ internal sealed unsafe class Chat : IDisposable {
};
this.Activated?.Invoke(args);
} catch (Exception ex) {
PluginLog.LogError(ex, "Error in chat Activated event");
Plugin.Log.Error(ex, "Error in chat Activated event");
}
// prevent the game from focusing the chat log
@ -566,7 +565,7 @@ internal sealed unsafe class Chat : IDisposable {
TellTarget = target,
});
} catch (Exception ex) {
PluginLog.LogError(ex, "Error in chat Activated event");
Plugin.Log.Error(ex, "Error in chat Activated event");
}
}
@ -592,7 +591,7 @@ internal sealed unsafe class Chat : IDisposable {
idx = 0;
}
this._changeChatChannel(RaptureShellModule.Instance, (int) channel, idx, target, 1);
this._changeChatChannel(RaptureShellModule.Instance(), (int) channel, idx, target, 1);
target->Dtor();
IMemorySpace.Free(target);
}

View File

@ -20,7 +20,7 @@ internal sealed unsafe class Context {
[Signature("E8 ?? ?? ?? ?? EB 3F 83 F8 FE", Fallibility = Fallibility.Fallible)]
private readonly delegate* unmanaged<AgentInterface*, ushort, uint, byte, void> _itemComparison = null!;
[Signature("E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? 41 B4 01", Fallibility = Fallibility.Fallible)]
[Signature("E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? 48 83 F8 0F", Fallibility = Fallibility.Fallible)]
private readonly delegate* unmanaged<IntPtr, uint, void> _searchForRecipesUsingItem = null!;
[Signature("E8 ?? ?? ?? ?? EB 45 45 33 C9", Fallibility = Fallibility.Fallible)]
@ -29,7 +29,7 @@ internal sealed unsafe class Context {
#region Offsets
[Signature(
"FF 90 ?? ?? ?? ?? 8B 93 ?? ?? ?? ?? 48 8B C8 E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? 41 B4 01",
"FF 90 ?? ?? ?? ?? 8B 93 ?? ?? ?? ?? 48 8B C8 E8 ?? ?? ?? ?? 41 0F B6 D4 48 8B CB E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? 48 81 FF ?? ?? ?? ?? 0F 85",
Offset = 2
)]
private readonly int? _searchForRecipesUsingItemVfunc;
@ -40,7 +40,7 @@ internal sealed unsafe class Context {
internal Context(Plugin plugin) {
this.Plugin = plugin;
SignatureHelper.Initialise(this);
this.Plugin.GameInteropProvider.InitializeFromAttributes(this);
}
internal void InviteToNoviceNetwork(string name, ushort world) {
@ -48,7 +48,7 @@ internal sealed unsafe class Context {
return;
}
// 6.05: 20E4CB
// 6.3: 221EFD
var a1 = this.Plugin.Functions.GetInfoProxyByIndex(0x14);
fixed (byte* namePtr = name.ToTerminatedBytes()) {

View File

@ -71,7 +71,7 @@ internal unsafe class GameFunctions : IDisposable {
this.Chat = new Chat(this.Plugin);
this.Context = new Context(this.Plugin);
SignatureHelper.Initialise(this);
this.Plugin.GameInteropProvider.InitializeFromAttributes(this);
this.ResolveTextCommandPlaceholderHook?.Enable();
}
@ -207,7 +207,7 @@ internal unsafe class GameFunctions : IDisposable {
// hide addon first to prevent the "addon close" sound
var addon = AtkStage.GetSingleton()->RaptureAtkUnitManager->GetAddonByName("ItemDetail");
if (addon != null) {
addon->Hide(true);
addon->Hide(true, false, 0);
}
var agent = Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId(AgentId.ItemDetail);
@ -227,7 +227,7 @@ internal unsafe class GameFunctions : IDisposable {
vf27(atkModule, addonId, 1);
} else {
// 6.05: 8443DD
if (*(uint*) ((IntPtr) lfg + 0x2AB8) > 0) {
if (*(uint*) ((IntPtr) lfg + 0x2C20) > 0) {
lfg->Hide();
} else {
lfg->Show();

View File

@ -26,7 +26,7 @@ internal sealed unsafe class Party {
internal Party(Plugin plugin) {
this.Plugin = plugin;
SignatureHelper.Initialise(this);
this.Plugin.GameInteropProvider.InitializeFromAttributes(this);
}
internal void InviteSameWorld(string name, ushort world, ulong contentId) {

View File

@ -7,13 +7,14 @@ using ChatTwo.Util;
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Interface;
using Dalamud.Logging;
using Dalamud.Interface.Internal;
using Dalamud.Interface.Utility;
using Dalamud.Utility;
using ImGuiNET;
using ImGuiScene;
using Lumina.Excel.GeneratedSheets;
using Action = System.Action;
using DalamudPartyFinderPayload = Dalamud.Game.Text.SeStringHandling.Payloads.PartyFinderPayload;
using ChatTwoPartyFinderPayload = ChatTwo.Util.PartyFinderPayload;
namespace ChatTwo;
@ -99,7 +100,7 @@ internal sealed class PayloadHandler {
try {
this.Ui.Plugin.Ipc.Invoke(id, sender, contentId, payload, chunk.Message?.SenderSource, chunk.Message?.ContentSource);
} catch (Exception ex) {
PluginLog.Error(ex, "Error executing integration");
Plugin.Log.Error(ex, "Error executing integration");
}
}
@ -118,7 +119,7 @@ internal sealed class PayloadHandler {
ImGui.Separator();
}
if (!ImGui.BeginMenu(this.Ui.Plugin.Name)) {
if (!ImGui.BeginMenu(Plugin.Name)) {
return;
}
@ -214,7 +215,7 @@ internal sealed class PayloadHandler {
}
}
private static void InlineIcon(TextureWrap icon) {
private static void InlineIcon(IDalamudTextureWrap icon) {
var lineHeight = ImGui.CalcTextSize("A").Y;
var cursor = ImGui.GetCursorPos();
@ -294,7 +295,16 @@ internal sealed class PayloadHandler {
this.ClickLinkPayload(chunk, payload, link);
break;
}
case PartyFinderPayload pf: {
case DalamudPartyFinderPayload pf: {
if (pf.LinkType == DalamudPartyFinderPayload.PartyFinderLinkType.PartyFinderNotification) {
GameFunctions.GameFunctions.OpenPartyFinder();
} else {
this.Ui.Plugin.Functions.OpenPartyFinder(pf.ListingId);
}
break;
}
case ChatTwoPartyFinderPayload pf: {
this.Ui.Plugin.Functions.OpenPartyFinder(pf.Id);
break;
}
@ -325,16 +335,25 @@ internal sealed class PayloadHandler {
var payloads = source.Payloads.Skip(start).Take(end - start + 1).ToList();
var chatGui = this.Ui.Plugin.ChatGui;
var field = chatGui.GetType().GetField("dalamudLinkHandlers", BindingFlags.Instance | BindingFlags.NonPublic);
if (field == null || field.GetValue(chatGui) is not Dictionary<(string PluginName, uint CommandId), Action<uint, SeString>> dict || !dict.TryGetValue((link.Plugin, link.CommandId), out var action)) {
var chatGuiScoped = this.Ui.Plugin.ChatGui;
var chatGuiService = chatGuiScoped.GetType()
.GetField("chatGuiService", BindingFlags.Instance | BindingFlags.NonPublic)!
.GetValue(chatGuiScoped);
if (chatGuiService == null) {
Plugin.Log.Warning("could not find chatGuiService");
return;
}
var field = chatGuiService.GetType().GetField("dalamudLinkHandlers", BindingFlags.Instance | BindingFlags.NonPublic);
if (field == null || field.GetValue(chatGuiService) is not Dictionary<(string PluginName, uint CommandId), Action<uint, SeString>> dict || !dict.TryGetValue((link.Plugin, link.CommandId), out var action)) {
Plugin.Log.Warning("could not find dalamudLinkHandlers");
return;
}
try {
action(link.CommandId, new SeString(payloads));
} catch (Exception ex) {
PluginLog.LogError(ex, "Error executing DalamudLinkPayload handler");
Plugin.Log.Error(ex, "Error executing DalamudLinkPayload handler");
}
}
@ -520,7 +539,7 @@ internal sealed class PayloadHandler {
}
if (ImGui.Selectable(Language.Context_Target) && this.FindCharacterForPayload(player) is { } obj) {
this.Ui.Plugin.TargetManager.SetTarget(obj);
this.Ui.Plugin.TargetManager.Target = obj;
}
// View Party Finder 0x2E

View File

@ -3,17 +3,10 @@ using System.Globalization;
using ChatTwo.Ipc;
using ChatTwo.Resources;
using ChatTwo.Util;
using Dalamud.Data;
using Dalamud.Game;
using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Keys;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.ClientState.Party;
using Dalamud.Game.Command;
using Dalamud.Game.Gui;
using Dalamud.IoC;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using XivCommon;
namespace ChatTwo;
@ -22,43 +15,55 @@ namespace ChatTwo;
public sealed class Plugin : IDalamudPlugin {
internal const string PluginName = "Chat 2";
public string Name => PluginName;
internal static string Name => PluginName;
[PluginService]
internal static IPluginLog Log { get; private set; }
[PluginService]
internal DalamudPluginInterface Interface { get; init; }
[PluginService]
internal ChatGui ChatGui { get; init; }
internal IChatGui ChatGui { 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 Condition Condition { get; init; }
internal ICondition Condition { 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 KeyState KeyState { get; init; }
internal IKeyState KeyState { get; init; }
[PluginService]
internal ObjectTable ObjectTable { get; init; }
internal IObjectTable ObjectTable { get; init; }
[PluginService]
internal PartyList PartyList { get; init; }
internal IPartyList PartyList { get; init; }
[PluginService]
internal TargetManager TargetManager { get; init; }
internal ITargetManager TargetManager { get; init; }
[PluginService]
internal ITextureProvider TextureProvider { get; init; }
[PluginService]
internal IGameInteropProvider GameInteropProvider { get; init; }
[PluginService]
internal IGameConfig GameConfig { get; init; }
internal Configuration Config { get; }
internal Commands Commands { get; }
@ -88,8 +93,8 @@ public sealed class Plugin : IDalamudPlugin {
this.LanguageChanged(this.Interface.UiLanguage);
this.Commands = new Commands(this);
this.Common = new XivCommonBase();
this.TextureCache = new TextureCache(this.DataManager!);
this.Common = new XivCommonBase(this.Interface);
this.TextureCache = new TextureCache(this.TextureProvider!);
this.Functions = new GameFunctions.GameFunctions(this);
this.Store = new Store(this);
this.Ipc = new IpcManager(this.Interface);
@ -143,7 +148,7 @@ public sealed class Plugin : IDalamudPlugin {
"ChatLogPanel_3",
};
private void FrameworkUpdate(Framework framework) {
private void FrameworkUpdate(IFramework framework) {
if (this.DeferredSaveFrames >= 0 && this.DeferredSaveFrames-- == 0) {
this.SaveConfig();
}

View File

@ -3,7 +3,6 @@ using System.Runtime.InteropServices;
using ChatTwo.Ui;
using Dalamud.Interface;
using Dalamud.Interface.GameFonts;
using Dalamud.Logging;
using ImGuiNET;
namespace ChatTwo;
@ -151,7 +150,7 @@ internal sealed class PluginUi : IDisposable {
try {
component.Draw();
} catch (Exception ex) {
PluginLog.LogError(ex, "Error drawing component");
Plugin.Log.Error(ex, "Error drawing component");
}
}

View File

@ -4,10 +4,9 @@ using System.Numerics;
using ChatTwo.Code;
using ChatTwo.Resources;
using ChatTwo.Util;
using Dalamud.Game;
using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Logging;
using Dalamud.Plugin.Services;
using ImGuiNET;
using LiteDB;
using Lumina.Excel.GeneratedSheets;
@ -177,18 +176,18 @@ internal class Store : IDisposable {
this.Database = this.Connect();
}
private void Logout(object? sender, EventArgs eventArgs) {
private void Logout() {
this.LastContentId = 0;
}
private void UpdateReceiver(Framework framework) {
private void UpdateReceiver(IFramework framework) {
var contentId = this.Plugin.ClientState.LocalContentId;
if (contentId != 0) {
this.LastContentId = contentId;
}
}
private void GetMessageInfo(Framework framework) {
private void GetMessageInfo(IFramework framework) {
if (this.CheckpointTimer.Elapsed > TimeSpan.FromMinutes(5)) {
this.CheckpointTimer.Restart();
new Thread(() => this.Database.Checkpoint()).Start();
@ -210,7 +209,7 @@ internal class Store : IDisposable {
private void MigrateDraw() {
ImGui.SetNextWindowSizeConstraints(new Vector2(450, 0), new Vector2(450, float.MaxValue));
if (!ImGui.Begin($"{this.Plugin.Name}##migration-window", ImGuiWindowFlags.AlwaysAutoResize)) {
if (!ImGui.Begin($"{Plugin.Name}##migration-window", ImGuiWindowFlags.AlwaysAutoResize)) {
ImGui.End();
return;
}
@ -250,7 +249,7 @@ internal class Store : IDisposable {
var lastId = ObjectId.Empty;
for (var i = 0; i < rounds; i++) {
this._migrateCurrent = i + 1;
PluginLog.Log($"Update round {i + 1}/{rounds}");
Plugin.Log.Info($"Update round {i + 1}/{rounds}");
var messages = this.Messages.Query()
.OrderBy(msg => msg.Id)
.Where(msg => msg.Id > lastId)

View File

@ -1,22 +1,22 @@
using Dalamud.Data;
using ImGuiScene;
using Dalamud.Interface.Internal;
using Dalamud.Plugin.Services;
using Lumina.Excel.GeneratedSheets;
namespace ChatTwo;
internal class TextureCache : IDisposable {
private DataManager Data { get; }
private ITextureProvider TextureProvider { get; }
private readonly Dictionary<(uint, bool), TextureWrap> _itemIcons = new();
private readonly Dictionary<(uint, bool), TextureWrap> _statusIcons = new();
private readonly Dictionary<(uint, bool), TextureWrap> _eventItemIcons = new();
private readonly Dictionary<(uint, bool), IDalamudTextureWrap> _itemIcons = new();
private readonly Dictionary<(uint, bool), IDalamudTextureWrap> _statusIcons = new();
private readonly Dictionary<(uint, bool), IDalamudTextureWrap> _eventItemIcons = new();
internal IReadOnlyDictionary<(uint, bool), TextureWrap> ItemIcons => this._itemIcons;
internal IReadOnlyDictionary<(uint, bool), TextureWrap> StatusIcons => this._statusIcons;
internal IReadOnlyDictionary<(uint, bool), TextureWrap> EventItemIcons => this._eventItemIcons;
internal IReadOnlyDictionary<(uint, bool), IDalamudTextureWrap> ItemIcons => this._itemIcons;
internal IReadOnlyDictionary<(uint, bool), IDalamudTextureWrap> StatusIcons => this._statusIcons;
internal IReadOnlyDictionary<(uint, bool), IDalamudTextureWrap> EventItemIcons => this._eventItemIcons;
internal TextureCache(DataManager data) {
this.Data = data;
internal TextureCache(ITextureProvider textureProvider) {
this.TextureProvider = textureProvider;
}
public void Dispose() {
@ -28,14 +28,14 @@ internal class TextureCache : IDisposable {
}
}
private void AddIcon(IDictionary<(uint, bool), TextureWrap> dict, uint icon, bool hq = false) {
private void AddIcon(IDictionary<(uint, bool), IDalamudTextureWrap> dict, uint icon, bool hq = false) {
if (dict.ContainsKey((icon, hq))) {
return;
}
var tex = hq
? this.Data.GetImGuiTextureHqIcon(icon)
: this.Data.GetImGuiTextureIcon(icon);
? this.TextureProvider.GetIcon(icon, ITextureProvider.IconFlags.ItemHighQuality)
: this.TextureProvider.GetIcon(icon);
if (tex != null) {
dict[(icon, hq)] = tex;
}
@ -53,19 +53,19 @@ internal class TextureCache : IDisposable {
this.AddIcon(this._eventItemIcons, item.Icon);
}
internal TextureWrap? GetItem(Item item, bool hq = false) {
internal IDalamudTextureWrap? GetItem(Item item, bool hq = false) {
this.AddItem(item, hq);
this.ItemIcons.TryGetValue((item.Icon, hq), out var icon);
return icon;
}
internal TextureWrap? GetStatus(Status status) {
internal IDalamudTextureWrap? GetStatus(Status status) {
this.AddStatus(status);
this.StatusIcons.TryGetValue((status.Icon, false), out var icon);
return icon;
}
internal TextureWrap? GetEventItem(EventItem item) {
internal IDalamudTextureWrap? GetEventItem(EventItem item) {
this.AddEventItem(item);
this.EventItemIcons.TryGetValue((item.Icon, false), out var icon);
return icon;

View File

@ -11,10 +11,10 @@ using Dalamud.Game.ClientState.Keys;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Interface;
using Dalamud.Logging;
using Dalamud.Interface.Internal;
using Dalamud.Interface.Utility;
using Dalamud.Memory;
using ImGuiNET;
using ImGuiScene;
using Lumina.Excel.GeneratedSheets;
namespace ChatTwo.Ui;
@ -28,7 +28,7 @@ internal sealed class ChatLog : IUiComponent {
internal bool Activate;
private int _activatePos = -1;
internal string Chat = string.Empty;
private readonly TextureWrap? _fontIcon;
private readonly IDalamudTextureWrap? _fontIcon;
private readonly List<string> _inputBacklog = new();
private int _inputBacklogIdx = -1;
internal int LastTab { get; private set; }
@ -62,7 +62,7 @@ internal sealed class ChatLog : IUiComponent {
this.Ui.Plugin.Commands.Register("/clearlog2", "Clear the Chat 2 chat log").Execute += this.ClearLog;
this.Ui.Plugin.Commands.Register("/chat2").Execute += this.ToggleChat;
this._fontIcon = this.Ui.Plugin.DataManager.GetImGuiTexture("common/font/fonticon_ps5.tex");
this._fontIcon = this.Ui.Plugin.TextureProvider.GetTextureFromGame("common/font/fonticon_ps5.tex");
this.Ui.Plugin.Functions.Chat.Activated += this.Activated;
this.Ui.Plugin.ClientState.Login += this.Login;
@ -78,13 +78,13 @@ internal sealed class ChatLog : IUiComponent {
this.Ui.Plugin.Commands.Register("/clearlog2").Execute -= this.ClearLog;
}
private void Logout(object? sender, EventArgs e) {
private void Logout() {
foreach (var tab in this.Ui.Plugin.Config.Tabs) {
tab.Clear();
}
}
private void Login(object? sender, EventArgs e) {
private void Login() {
this.Ui.Plugin.Store.FilterAllTabs(false);
}
@ -327,7 +327,7 @@ internal sealed class ChatLog : IUiComponent {
TellReason = reason,
});
} catch (Exception ex) {
PluginLog.LogError(ex, "Error in chat Activated event");
Plugin.Log.Error(ex, "Error in chat Activated event");
}
}
}
@ -415,7 +415,7 @@ internal sealed class ChatLog : IUiComponent {
ImGui.SetNextWindowSize(new Vector2(500, 250) * ImGuiHelpers.GlobalScale, ImGuiCond.FirstUseEver);
if (!ImGui.Begin($"{this.Ui.Plugin.Name}###chat2", flags)) {
if (!ImGui.Begin($"{Plugin.Name}###chat2", flags)) {
this._lastViewport = ImGui.GetWindowViewport().NativePtr;
this._wasDocked = ImGui.IsWindowDocked();
ImGui.End();

View File

@ -1,6 +1,6 @@
using System.Numerics;
using ChatTwo.Util;
using Dalamud.Interface;
using Dalamud.Interface.Utility;
using Dalamud.Utility;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;

View File

@ -3,7 +3,7 @@ using System.Numerics;
using ChatTwo.Resources;
using ChatTwo.Ui.SettingsTabs;
using ChatTwo.Util;
using Dalamud.Interface;
using Dalamud.Interface.Utility;
using ImGuiNET;
namespace ChatTwo.Ui;
@ -13,7 +13,6 @@ internal sealed class Settings : IUiComponent {
private Configuration Mutable { get; }
private List<ISettingsTab> Tabs { get; }
private int _currentTab;
internal Settings(PluginUi ui) {
@ -62,7 +61,7 @@ internal sealed class Settings : IUiComponent {
ImGui.SetNextWindowSize(new Vector2(475, 600) * ImGuiHelpers.GlobalScale, ImGuiCond.FirstUseEver);
var name = string.Format(Language.Settings_Title, this.Ui.Plugin.Name);
var name = string.Format(Language.Settings_Title, Plugin.Name);
if (!ImGui.Begin($"{name}###chat2-settings", ref this.Ui.SettingsVisible, ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse)) {
ImGui.End();
return;
@ -118,7 +117,7 @@ internal sealed class Settings : IUiComponent {
this.Ui.SettingsVisible = false;
}
var buttonLabel = string.Format(Language.Settings_Kofi, this.Ui.Plugin.Name);
var buttonLabel = string.Format(Language.Settings_Kofi, Plugin.Name);
ImGui.PushStyleColor(ImGuiCol.Button, ColourUtil.RgbaToAbgr(0xFF5E5BFF));
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, ColourUtil.RgbaToAbgr(0xFF7775FF));
@ -130,7 +129,7 @@ internal sealed class Settings : IUiComponent {
ImGui.SameLine(ImGui.GetContentRegionAvail().X - buttonWidth);
if (ImGui.Button(buttonLabel)) {
Process.Start(new ProcessStartInfo("https://ko-fi.com/ascclemens") {
Process.Start(new ProcessStartInfo("https://ko-fi.com/lojewalo") {
UseShellExecute = true,
});
}

View File

@ -23,10 +23,10 @@ internal sealed class ChatColours : ISettingsTab {
.ToHashSet();
var total = Enum.GetValues<ChatType>().Where(type => !type.IsGm()).ToHashSet();
if (sortable.Count != total.Count) {
Dalamud.Logging.PluginLog.Warning($"There are {sortable.Count} sortable channels, but there are {total.Count} total channels.");
Dalamud.Logging.Plugin.Log.Warning($"There are {sortable.Count} sortable channels, but there are {total.Count} total channels.");
total.ExceptWith(sortable);
foreach (var missing in total) {
Dalamud.Logging.PluginLog.Log($"Missing {missing}");
Dalamud.Logging.Plugin.Log.Log($"Missing {missing}");
}
}
#endif

View File

@ -1,9 +1,9 @@
using System.Runtime.InteropServices;
using System.Text;
using Dalamud;
using Dalamud.Data;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Plugin.Services;
using Dalamud.Utility;
using Lumina.Excel;
using Lumina.Excel.GeneratedSheets;
@ -89,7 +89,7 @@ internal static class AutoTranslate {
return string.Join("", payloads);
}
private static List<AutoTranslateEntry> AllEntries(DataManager data) {
private static List<AutoTranslateEntry> AllEntries(IDataManager data) {
if (Entries.TryGetValue(data.Language, out var entries)) {
return entries;
}
@ -197,7 +197,7 @@ internal static class AutoTranslate {
return list;
}
internal static List<AutoTranslateEntry> Matching(DataManager data, string prefix, bool sort) {
internal static List<AutoTranslateEntry> Matching(IDataManager data, string prefix, bool sort) {
var wholeMatches = new List<AutoTranslateEntry>();
var prefixMatches = new List<AutoTranslateEntry>();
var otherMatches = new List<AutoTranslateEntry>();
@ -227,7 +227,7 @@ internal static class AutoTranslate {
[DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern int memcmp(byte[] b1, byte[] b2, UIntPtr count);
internal static void ReplaceWithPayload(DataManager data, ref byte[] bytes) {
internal static void ReplaceWithPayload(IDataManager data, ref byte[] bytes) {
var search = Encoding.UTF8.GetBytes("<at:");
if (bytes.Length <= search.Length) {
return;

View File

@ -63,11 +63,19 @@ internal static class ChunkUtil {
case PayloadType.Player:
link = payload;
break;
case PayloadType.PartyFinder:
link = payload;
break;
case PayloadType.Unknown:
var rawPayload = (RawPayload) payload;
if (rawPayload.Data.Length > 1 && rawPayload.Data[1] == 0x13) {
foreground.Pop();
glow.Pop();
if (foreground.Count > 0) {
foreground.Pop();
}
if (glow.Count > 0) {
glow.Pop();
}
} else if (rawPayload.Data.Length > 7 && rawPayload.Data[1] == 0x27 && rawPayload.Data[3] == 0x0A) {
// pf payload
var reader = new BinaryReader(new MemoryStream(rawPayload.Data[4..]));
@ -80,8 +88,6 @@ internal static class ChunkUtil {
link = new AchievementPayload(id);
} else if (Equals(rawPayload, RawPayload.LinkTerminator)) {
link = null;
} else if (Equals(rawPayload, PeriodicRecruitmentLink)) {
link = rawPayload;
}
break;

View File

@ -4,6 +4,7 @@ using Dalamud.Game.ClientState.Keys;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Interface;
using Dalamud.Interface.Style;
using Dalamud.Interface.Utility;
using ImGuiNET;
namespace ChatTwo.Util;

26
ChatTwo/packages.lock.json Executable file → Normal file
View File

@ -1,24 +1,24 @@
{
"version": 1,
"dependencies": {
"net6.0-windows7.0": {
"net7.0-windows7.0": {
"DalamudPackager": {
"type": "Direct",
"requested": "[2.1.8, )",
"resolved": "2.1.8",
"contentHash": "YqagNXs9InxmqkXzq7kLveImxnodkBEicAhydMXVp7dFjC7xb76U6zGgAax4/BWIWfZeWzr5DJyQSev31kj81A=="
"requested": "[2.1.12, )",
"resolved": "2.1.12",
"contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg=="
},
"LiteDB": {
"type": "Direct",
"requested": "[5.0.12, )",
"resolved": "5.0.12",
"contentHash": "HaOjSIGS9BRm7dw42qcHd5NGYl5wdjsFB31pImt3QQNLKUNEmRAr7ADos5VsujwBc9c4otJgb+G6NA4MlzKyAw=="
"requested": "[5.0.17, )",
"resolved": "5.0.17",
"contentHash": "cKPvkdlzIts3ZKu/BzoIc/Y71e4VFKlij4LyioPFATZMot+wB7EAm1FFbZSJez6coJmQUoIg/3yHE1MMU+zOdg=="
},
"Pidgin": {
"type": "Direct",
"requested": "[3.2.0, )",
"resolved": "3.2.0",
"contentHash": "pUm2B95hRRvcPO50mCMUST2B3/M6b99CUHaZOIpFJpnD2twgKea83ZqYyllvwxr64EIhch9o/xy02zfbisg1Kw=="
"requested": "[3.2.2, )",
"resolved": "3.2.2",
"contentHash": "imvuRt8fzxJCJs9kCk7s418NRyEdP6aDtz2qL9XYcn1ywTkpnrSq4IORVTQ879HNoTfJkyGkFadmEoCZEsebGg=="
},
"SharpDX.Direct2D1": {
"type": "Direct",
@ -33,9 +33,9 @@
},
"XivCommon": {
"type": "Direct",
"requested": "[6.0.1, )",
"resolved": "6.0.1",
"contentHash": "X58/iHscbwzF9JziooBKYE4S0XDYuGYI7Eg5Er1LhdQSjGwMLes0whRdKtH591wIhefFiS5G14W6EEL3Qt76wg=="
"requested": "[9.0.0, )",
"resolved": "9.0.0",
"contentHash": "avaBp3FmSCi/PiQhntCeBDYOHejdyTWmFtz4pRBVQQ8vHkmRx+YTk1la9dkYBMlXxRXKckEdH1iI1Fu61JlE7w=="
},
"Microsoft.NETCore.Platforms": {
"type": "Transitive",