refactor: update for api 9

This commit is contained in:
Anna 2023-10-03 02:59:51 -04:00
parent 32e7fbe586
commit c9cd28589b
Signed by: anna
GPG Key ID: D0943384CD9F87D1
15 changed files with 85 additions and 82 deletions

View File

@ -39,10 +39,6 @@
<HintPath>$(DalamudLibPath)\ImGui.NET.dll</HintPath> <HintPath>$(DalamudLibPath)\ImGui.NET.dll</HintPath>
<Private>false</Private> <Private>false</Private>
</Reference> </Reference>
<Reference Include="ImGuiScene">
<HintPath>$(DalamudLibPath)\ImGuiScene.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Lumina"> <Reference Include="Lumina">
<HintPath>$(DalamudLibPath)\Lumina.dll</HintPath> <HintPath>$(DalamudLibPath)\Lumina.dll</HintPath>
<Private>false</Private> <Private>false</Private>

View File

@ -1,4 +1,4 @@
using Dalamud.Data; using Dalamud.Plugin.Services;
using Lumina.Excel.GeneratedSheets; using Lumina.Excel.GeneratedSheets;
namespace ChatTwo.Code; 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 { var ids = channel switch {
InputChannel.Tell => new uint[] { 104, 118 }, InputChannel.Tell => new uint[] { 104, 118 },
InputChannel.Say => new uint[] { 102 }, InputChannel.Say => new uint[] { 102 },

View File

@ -3,10 +3,12 @@ using ChatTwo.Code;
using ChatTwo.GameFunctions.Types; using ChatTwo.GameFunctions.Types;
using ChatTwo.Util; using ChatTwo.Util;
using Dalamud.Game.ClientState.Keys; using Dalamud.Game.ClientState.Keys;
using Dalamud.Game.Config;
using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Hooking; using Dalamud.Hooking;
using Dalamud.Logging; using Dalamud.Logging;
using Dalamud.Memory; using Dalamud.Memory;
using Dalamud.Plugin.Services;
using Dalamud.Utility.Signatures; using Dalamud.Utility.Signatures;
using FFXIVClientStructs.FFXIV.Client.System.Framework; using FFXIVClientStructs.FFXIV.Client.System.Framework;
using FFXIVClientStructs.FFXIV.Client.System.Memory; using FFXIVClientStructs.FFXIV.Client.System.Memory;
@ -142,7 +144,7 @@ internal sealed unsafe class Chat : IDisposable {
internal Chat(Plugin plugin) { internal Chat(Plugin plugin) {
this.Plugin = plugin; this.Plugin = plugin;
SignatureHelper.Initialise(this); this.Plugin.GameInteropProvider.InitializeFromAttributes(this);
this.ChatLogRefreshHook?.Enable(); this.ChatLogRefreshHook?.Enable();
this.ChangeChannelNameHook?.Enable(); this.ChangeChannelNameHook?.Enable();
@ -151,7 +153,7 @@ internal sealed unsafe class Chat : IDisposable {
this.Plugin.Framework.Update += this.InterceptKeybinds; this.Plugin.Framework.Update += this.InterceptKeybinds;
this.Plugin.ClientState.Login += this.Login; this.Plugin.ClientState.Login += this.Login;
this.Login(null, null); this.Login();
} }
public void Dispose() { public void Dispose() {
@ -368,7 +370,7 @@ internal sealed unsafe class Chat : IDisposable {
} }
} }
private void InterceptKeybinds(Dalamud.Game.Framework framework) { private void InterceptKeybinds(IFramework framework1) {
this.CheckFocus(); this.CheckFocus();
this.UpdateKeybinds(); this.UpdateKeybinds();
@ -435,7 +437,7 @@ internal sealed unsafe class Chat : IDisposable {
} }
} }
private void Login(object? sender, EventArgs? e) { private void Login() {
if (this.ChangeChannelNameHook == null) { if (this.ChangeChannelNameHook == null) {
return; return;
} }
@ -454,10 +456,8 @@ internal sealed unsafe class Chat : IDisposable {
} }
string? input = null; string? input = null;
var option = Framework.Instance()->GetUiModule()->GetConfigModule()->GetValue(ConfigOption.DirectChat); if (this.Plugin.GameConfig.TryGet(UiControlOption.DirectChat, out bool option) && option) {
if (option != null) { if (this._currentCharacter != null) {
var directChat = option->Int > 0;
if (directChat && this._currentCharacter != null) {
// FIXME: this whole system sucks // FIXME: this whole system sucks
var c = *this._currentCharacter; var c = *this._currentCharacter;
if (c != '\0' && !char.IsControl(c)) { if (c != '\0' && !char.IsControl(c)) {
@ -592,7 +592,7 @@ internal sealed unsafe class Chat : IDisposable {
idx = 0; idx = 0;
} }
this._changeChatChannel(RaptureShellModule.Instance, (int) channel, idx, target, 1); this._changeChatChannel(RaptureShellModule.Instance(), (int) channel, idx, target, 1);
target->Dtor(); target->Dtor();
IMemorySpace.Free(target); IMemorySpace.Free(target);
} }

View File

@ -40,7 +40,7 @@ internal sealed unsafe class Context {
internal Context(Plugin plugin) { internal Context(Plugin plugin) {
this.Plugin = plugin; this.Plugin = plugin;
SignatureHelper.Initialise(this); this.Plugin.GameInteropProvider.InitializeFromAttributes(this);
} }
internal void InviteToNoviceNetwork(string name, ushort world) { internal void InviteToNoviceNetwork(string name, ushort world) {

View File

@ -71,7 +71,7 @@ internal unsafe class GameFunctions : IDisposable {
this.Chat = new Chat(this.Plugin); this.Chat = new Chat(this.Plugin);
this.Context = new Context(this.Plugin); this.Context = new Context(this.Plugin);
SignatureHelper.Initialise(this); this.Plugin.GameInteropProvider.InitializeFromAttributes(this);
this.ResolveTextCommandPlaceholderHook?.Enable(); this.ResolveTextCommandPlaceholderHook?.Enable();
} }
@ -207,7 +207,7 @@ internal unsafe class GameFunctions : IDisposable {
// hide addon first to prevent the "addon close" sound // hide addon first to prevent the "addon close" sound
var addon = AtkStage.GetSingleton()->RaptureAtkUnitManager->GetAddonByName("ItemDetail"); var addon = AtkStage.GetSingleton()->RaptureAtkUnitManager->GetAddonByName("ItemDetail");
if (addon != null) { if (addon != null) {
addon->Hide(true); addon->Hide(true, false, 0);
} }
var agent = Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId(AgentId.ItemDetail); var agent = Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId(AgentId.ItemDetail);

View File

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

View File

@ -7,11 +7,11 @@ using ChatTwo.Util;
using Dalamud.Game.ClientState.Objects.SubKinds; using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Interface; using Dalamud.Interface.Internal;
using Dalamud.Interface.Utility;
using Dalamud.Logging; using Dalamud.Logging;
using Dalamud.Utility; using Dalamud.Utility;
using ImGuiNET; using ImGuiNET;
using ImGuiScene;
using Lumina.Excel.GeneratedSheets; using Lumina.Excel.GeneratedSheets;
using Action = System.Action; using Action = System.Action;
using DalamudPartyFinderPayload = Dalamud.Game.Text.SeStringHandling.Payloads.PartyFinderPayload; using DalamudPartyFinderPayload = Dalamud.Game.Text.SeStringHandling.Payloads.PartyFinderPayload;
@ -120,7 +120,7 @@ internal sealed class PayloadHandler {
ImGui.Separator(); ImGui.Separator();
} }
if (!ImGui.BeginMenu(this.Ui.Plugin.Name)) { if (!ImGui.BeginMenu(Plugin.Name)) {
return; return;
} }
@ -216,7 +216,7 @@ internal sealed class PayloadHandler {
} }
} }
private static void InlineIcon(TextureWrap icon) { private static void InlineIcon(IDalamudTextureWrap icon) {
var lineHeight = ImGui.CalcTextSize("A").Y; var lineHeight = ImGui.CalcTextSize("A").Y;
var cursor = ImGui.GetCursorPos(); var cursor = ImGui.GetCursorPos();
@ -531,7 +531,7 @@ internal sealed class PayloadHandler {
} }
if (ImGui.Selectable(Language.Context_Target) && this.FindCharacterForPayload(player) is { } obj) { 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 Party Finder 0x2E

View File

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

View File

@ -4,10 +4,10 @@ using System.Numerics;
using ChatTwo.Code; using ChatTwo.Code;
using ChatTwo.Resources; using ChatTwo.Resources;
using ChatTwo.Util; using ChatTwo.Util;
using Dalamud.Game;
using Dalamud.Game.Text; using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Logging; using Dalamud.Logging;
using Dalamud.Plugin.Services;
using ImGuiNET; using ImGuiNET;
using LiteDB; using LiteDB;
using Lumina.Excel.GeneratedSheets; using Lumina.Excel.GeneratedSheets;
@ -177,18 +177,18 @@ internal class Store : IDisposable {
this.Database = this.Connect(); this.Database = this.Connect();
} }
private void Logout(object? sender, EventArgs eventArgs) { private void Logout() {
this.LastContentId = 0; this.LastContentId = 0;
} }
private void UpdateReceiver(Framework framework) { private void UpdateReceiver(IFramework framework) {
var contentId = this.Plugin.ClientState.LocalContentId; var contentId = this.Plugin.ClientState.LocalContentId;
if (contentId != 0) { if (contentId != 0) {
this.LastContentId = contentId; this.LastContentId = contentId;
} }
} }
private void GetMessageInfo(Framework framework) { private void GetMessageInfo(IFramework framework) {
if (this.CheckpointTimer.Elapsed > TimeSpan.FromMinutes(5)) { if (this.CheckpointTimer.Elapsed > TimeSpan.FromMinutes(5)) {
this.CheckpointTimer.Restart(); this.CheckpointTimer.Restart();
new Thread(() => this.Database.Checkpoint()).Start(); new Thread(() => this.Database.Checkpoint()).Start();
@ -210,7 +210,7 @@ internal class Store : IDisposable {
private void MigrateDraw() { private void MigrateDraw() {
ImGui.SetNextWindowSizeConstraints(new Vector2(450, 0), new Vector2(450, float.MaxValue)); 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(); ImGui.End();
return; return;
} }

View File

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

View File

@ -11,10 +11,11 @@ using Dalamud.Game.ClientState.Keys;
using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Interface; using Dalamud.Interface;
using Dalamud.Interface.Internal;
using Dalamud.Interface.Utility;
using Dalamud.Logging; using Dalamud.Logging;
using Dalamud.Memory; using Dalamud.Memory;
using ImGuiNET; using ImGuiNET;
using ImGuiScene;
using Lumina.Excel.GeneratedSheets; using Lumina.Excel.GeneratedSheets;
namespace ChatTwo.Ui; namespace ChatTwo.Ui;
@ -28,7 +29,7 @@ internal sealed class ChatLog : IUiComponent {
internal bool Activate; internal bool Activate;
private int _activatePos = -1; private int _activatePos = -1;
internal string Chat = string.Empty; internal string Chat = string.Empty;
private readonly TextureWrap? _fontIcon; private readonly IDalamudTextureWrap? _fontIcon;
private readonly List<string> _inputBacklog = new(); private readonly List<string> _inputBacklog = new();
private int _inputBacklogIdx = -1; private int _inputBacklogIdx = -1;
internal int LastTab { get; private set; } internal int LastTab { get; private set; }
@ -62,7 +63,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("/clearlog2", "Clear the Chat 2 chat log").Execute += this.ClearLog;
this.Ui.Plugin.Commands.Register("/chat2").Execute += this.ToggleChat; 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.Functions.Chat.Activated += this.Activated;
this.Ui.Plugin.ClientState.Login += this.Login; this.Ui.Plugin.ClientState.Login += this.Login;
@ -78,13 +79,13 @@ internal sealed class ChatLog : IUiComponent {
this.Ui.Plugin.Commands.Register("/clearlog2").Execute -= this.ClearLog; 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) { foreach (var tab in this.Ui.Plugin.Config.Tabs) {
tab.Clear(); tab.Clear();
} }
} }
private void Login(object? sender, EventArgs e) { private void Login() {
this.Ui.Plugin.Store.FilterAllTabs(false); this.Ui.Plugin.Store.FilterAllTabs(false);
} }
@ -415,7 +416,7 @@ internal sealed class ChatLog : IUiComponent {
ImGui.SetNextWindowSize(new Vector2(500, 250) * ImGuiHelpers.GlobalScale, ImGuiCond.FirstUseEver); 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._lastViewport = ImGui.GetWindowViewport().NativePtr;
this._wasDocked = ImGui.IsWindowDocked(); this._wasDocked = ImGui.IsWindowDocked();
ImGui.End(); ImGui.End();

View File

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

View File

@ -3,7 +3,7 @@ using System.Numerics;
using ChatTwo.Resources; using ChatTwo.Resources;
using ChatTwo.Ui.SettingsTabs; using ChatTwo.Ui.SettingsTabs;
using ChatTwo.Util; using ChatTwo.Util;
using Dalamud.Interface; using Dalamud.Interface.Utility;
using ImGuiNET; using ImGuiNET;
namespace ChatTwo.Ui; namespace ChatTwo.Ui;
@ -61,7 +61,7 @@ internal sealed class Settings : IUiComponent {
ImGui.SetNextWindowSize(new Vector2(475, 600) * ImGuiHelpers.GlobalScale, ImGuiCond.FirstUseEver); 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)) { if (!ImGui.Begin($"{name}###chat2-settings", ref this.Ui.SettingsVisible, ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse)) {
ImGui.End(); ImGui.End();
return; return;
@ -117,7 +117,7 @@ internal sealed class Settings : IUiComponent {
this.Ui.SettingsVisible = false; 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.Button, ColourUtil.RgbaToAbgr(0xFF5E5BFF));
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, ColourUtil.RgbaToAbgr(0xFF7775FF)); ImGui.PushStyleColor(ImGuiCol.ButtonHovered, ColourUtil.RgbaToAbgr(0xFF7775FF));

View File

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

View File

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