From 948383b0c5561b74639cbc7e2131524369771035 Mon Sep 17 00:00:00 2001 From: Infi Date: Wed, 10 Apr 2024 17:45:25 +0200 Subject: [PATCH] Remove this. everywhere, add small note to override style --- ChatTwo/ChatTwo.csproj | 2 +- ChatTwo/Chunk.cs | 22 ++--- ChatTwo/Code/ChatCode.cs | 24 ++--- ChatTwo/Commands.cs | 24 ++--- ChatTwo/GameFunctions/Context.cs | 28 +++--- ChatTwo/GameFunctions/GameFunctions.cs | 62 ++++++------- ChatTwo/GameFunctions/Party.cs | 28 +++--- .../GameFunctions/Types/ChannelSwitchInfo.cs | 8 +- .../GameFunctions/Types/ChatActivatedArgs.cs | 2 +- .../GameFunctions/Types/TellHistoryInfo.cs | 6 +- ChatTwo/GameFunctions/Types/TellTarget.cs | 8 +- ChatTwo/Ipc/ExtraChat.cs | 32 +++---- ChatTwo/IpcManager.cs | 28 +++--- ChatTwo/Message.cs | 92 +++++++++---------- ChatTwo/Resources/Language.Designer.cs | 9 ++ ChatTwo/Resources/Language.resx | 3 + ChatTwo/TextureCache.cs | 34 +++---- ChatTwo/Ui/AutoCompleteInfo.cs | 6 +- ChatTwo/Ui/Fonts.cs | 12 +-- ChatTwo/Ui/SettingsTabs/ChatColours.cs | 14 +-- ChatTwo/Ui/SettingsTabs/Database.cs | 28 +++--- ChatTwo/Ui/SettingsTabs/Display.cs | 4 +- ChatTwo/Ui/SettingsTabs/Fonts.cs | 56 +++++------ ChatTwo/Ui/SettingsTabs/Miscellaneous.cs | 20 ++-- ChatTwo/Ui/SettingsTabs/Tabs.cs | 38 ++++---- ChatTwo/Util/AutoTranslate.cs | 16 ++-- ChatTwo/Util/Lender.cs | 10 +- ChatTwo/Util/Payloads.cs | 4 +- 28 files changed, 316 insertions(+), 304 deletions(-) diff --git a/ChatTwo/ChatTwo.csproj b/ChatTwo/ChatTwo.csproj index c8a8829..a1b0450 100755 --- a/ChatTwo/ChatTwo.csproj +++ b/ChatTwo/ChatTwo.csproj @@ -1,7 +1,7 @@ - 1.20.2 + 1.20.3 net8.0-windows enable enable diff --git a/ChatTwo/Chunk.cs b/ChatTwo/Chunk.cs index fd755ba..245b26c 100755 --- a/ChatTwo/Chunk.cs +++ b/ChatTwo/Chunk.cs @@ -12,14 +12,14 @@ internal abstract class Chunk { internal Payload? Link { get; set; } protected Chunk(ChunkSource source, Payload? link) { - this.Source = source; - this.Link = link; + Source = source; + Link = link; } - internal SeString? GetSeString() => this.Source switch { + internal SeString? GetSeString() => Source switch { ChunkSource.None => null, - ChunkSource.Sender => this.Message?.SenderSource, - ChunkSource.Content => this.Message?.ContentSource, + ChunkSource.Sender => Message?.SenderSource, + ChunkSource.Content => Message?.ContentSource, _ => null, }; @@ -52,7 +52,7 @@ internal class TextChunk : Chunk { internal string Content { get; set; } internal TextChunk(ChunkSource source, Payload? link, string content) : base(source, link) { - this.Content = content; + Content = content; } #pragma warning disable CS8618 @@ -66,10 +66,10 @@ internal class TextChunk : Chunk { public TextChunk NewWithStyle(ChunkSource source, Payload? link, string content) { return new TextChunk(source, link, content) { - FallbackColour = this.FallbackColour, - Foreground = this.Foreground, - Glow = this.Glow, - Italic = this.Italic, + FallbackColour = FallbackColour, + Foreground = Foreground, + Glow = Glow, + Italic = Italic, }; } } @@ -78,7 +78,7 @@ internal class IconChunk : Chunk { internal BitmapFontIcon Icon { get; set; } public IconChunk(ChunkSource source, Payload? link, BitmapFontIcon icon) : base(source, link) { - this.Icon = icon; + Icon = icon; } public IconChunk() : base(ChunkSource.None, null) { diff --git a/ChatTwo/Code/ChatCode.cs b/ChatTwo/Code/ChatCode.cs index 2a7a411..c1ecffd 100755 --- a/ChatTwo/Code/ChatCode.cs +++ b/ChatTwo/Code/ChatCode.cs @@ -10,24 +10,24 @@ internal class ChatCode { internal ChatType Type { get; } internal ChatSource Source { get; } internal ChatSource Target { get; } - private ChatSource SourceFrom(ushort shift) => (ChatSource) (1 << ((this.Raw >> shift) & 0xF)); + private ChatSource SourceFrom(ushort shift) => (ChatSource) (1 << ((Raw >> shift) & 0xF)); internal ChatCode(ushort raw) { - this.Raw = raw; - this.Type = (ChatType) (this.Raw & Clear7); - this.Source = this.SourceFrom(11); - this.Target = this.SourceFrom(7); + Raw = raw; + Type = (ChatType) (Raw & Clear7); + Source = SourceFrom(11); + Target = SourceFrom(7); } [BsonCtor] public ChatCode(ushort raw, ChatType type, ChatSource source, ChatSource target) { - this.Raw = raw; - this.Type = type; - this.Source = source; - this.Target = target; + Raw = raw; + Type = type; + Source = source; + Target = target; } - internal ChatType Parent() => this.Type switch { + internal ChatType Parent() => Type switch { ChatType.Say => ChatType.Say, ChatType.GmSay => ChatType.Say, ChatType.Shout => ChatType.Shout, @@ -81,11 +81,11 @@ internal class ChatCode { ChatType.FreeCompanyLoginLogout => ChatType.FreeCompanyAnnouncement, ChatType.PvpTeamAnnouncement => ChatType.PvpTeamAnnouncement, ChatType.PvpTeamLoginLogout => ChatType.PvpTeamAnnouncement, - _ => this.Type, + _ => Type, }; internal bool IsBattle() { - switch (this.Type) { + switch (Type) { case ChatType.Damage: case ChatType.Miss: case ChatType.Action: diff --git a/ChatTwo/Commands.cs b/ChatTwo/Commands.cs index 7b84a3b..bda10e5 100755 --- a/ChatTwo/Commands.cs +++ b/ChatTwo/Commands.cs @@ -7,18 +7,18 @@ internal sealed class Commands : IDisposable { private Dictionary Registered { get; } = new(); internal Commands(Plugin plugin) { - this.Plugin = plugin; + Plugin = plugin; } public void Dispose() { - foreach (var name in this.Registered.Keys) { + foreach (var name in Registered.Keys) { Plugin.CommandManager.RemoveHandler(name); } } internal void Initialise() { - foreach (var wrapper in this.Registered.Values) { - Plugin.CommandManager.AddHandler(wrapper.Name, new CommandInfo(this.Invoke) { + foreach (var wrapper in Registered.Values) { + Plugin.CommandManager.AddHandler(wrapper.Name, new CommandInfo(Invoke) { HelpMessage = wrapper.Description ?? string.Empty, ShowInHelp = wrapper.ShowInHelp, }); @@ -26,7 +26,7 @@ internal sealed class Commands : IDisposable { } internal CommandWrapper Register(string name, string? description = null, bool? showInHelp = null) { - if (this.Registered.TryGetValue(name, out var wrapper)) { + if (Registered.TryGetValue(name, out var wrapper)) { if (description != null) { wrapper.Description = description; } @@ -38,12 +38,12 @@ internal sealed class Commands : IDisposable { return wrapper; } - this.Registered[name] = new CommandWrapper(name, description, showInHelp ?? true); - return this.Registered[name]; + Registered[name] = new CommandWrapper(name, description, showInHelp ?? true); + return Registered[name]; } private void Invoke(string command, string arguments) { - if (!this.Registered.TryGetValue(command, out var wrapper)) { + if (!Registered.TryGetValue(command, out var wrapper)) { Plugin.Log.Warning($"Missing registration for command {command}"); return; } @@ -64,12 +64,12 @@ internal sealed class CommandWrapper { internal event Action? Execute; internal CommandWrapper(string name, string? description, bool showInHelp) { - this.Name = name; - this.Description = description; - this.ShowInHelp = showInHelp; + Name = name; + Description = description; + ShowInHelp = showInHelp; } internal void Invoke(string command, string arguments) { - this.Execute?.Invoke(command, arguments); + Execute?.Invoke(command, arguments); } } diff --git a/ChatTwo/GameFunctions/Context.cs b/ChatTwo/GameFunctions/Context.cs index b51ca87..a2c4237 100755 --- a/ChatTwo/GameFunctions/Context.cs +++ b/ChatTwo/GameFunctions/Context.cs @@ -39,21 +39,21 @@ internal sealed unsafe class Context { private Plugin Plugin { get; } internal Context(Plugin plugin) { - this.Plugin = plugin; + Plugin = plugin; Plugin.GameInteropProvider.InitializeFromAttributes(this); } internal void InviteToNoviceNetwork(string name, ushort world) { - if (this._inviteToNoviceNetwork == null) { + if (_inviteToNoviceNetwork == null) { return; } // 6.3: 221EFD - var a1 = this.Plugin.Functions.GetInfoProxyByIndex(0x14); + var a1 = Plugin.Functions.GetInfoProxyByIndex(0x14); fixed (byte* namePtr = name.ToTerminatedBytes()) { // can specify content id if we have it, but there's no need - this._inviteToNoviceNetwork(a1, 0, world, namePtr); + _inviteToNoviceNetwork(a1, 0, world, namePtr); } } @@ -66,48 +66,48 @@ internal sealed unsafe class Context { // 0x10006: search recipes using this material internal void TryOn(uint itemId, byte stainId) { - if (this._tryOn == null) { + if (_tryOn == null) { return; } - this._tryOn(0xFF, itemId, stainId, 0, 0); + _tryOn(0xFF, itemId, stainId, 0, 0); } internal void LinkItem(uint itemId) { - if (this._linkItem == null) { + if (_linkItem == null) { return; } var agent = Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId(AgentId.ChatLog); - this._linkItem(agent, itemId); + _linkItem(agent, itemId); } internal void OpenItemComparison(uint itemId) { - if (this._itemComparison == null) { + if (_itemComparison == null) { return; } var agent = Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId(AgentId.ItemCompare); - this._itemComparison(agent, 0x4D, itemId, 0); + _itemComparison(agent, 0x4D, itemId, 0); } internal void SearchForRecipesUsingItem(uint itemId) { - if (this._searchForRecipesUsingItem == null || this._searchForRecipesUsingItemVfunc is not { } offset) { + if (_searchForRecipesUsingItem == null || _searchForRecipesUsingItemVfunc is not { } offset) { return; } var uiModule = Framework.Instance()->GetUiModule(); var vf = (delegate* unmanaged) uiModule->vfunc[offset / 8]; var a1 = vf(uiModule); - this._searchForRecipesUsingItem(a1, itemId); + _searchForRecipesUsingItem(a1, itemId); } internal void SearchForItem(uint itemId) { - if (this._searchForItem == null) { + if (_searchForItem == null) { return; } var itemFinder = Framework.Instance()->GetUiModule()->GetItemFinderModule(); - this._searchForItem(itemFinder, itemId, 1); + _searchForItem(itemFinder, itemId, 1); } } diff --git a/ChatTwo/GameFunctions/GameFunctions.cs b/ChatTwo/GameFunctions/GameFunctions.cs index 8a604fe..bb71eaa 100755 --- a/ChatTwo/GameFunctions/GameFunctions.cs +++ b/ChatTwo/GameFunctions/GameFunctions.cs @@ -66,26 +66,26 @@ internal unsafe class GameFunctions : IDisposable { internal Context Context { get; } internal GameFunctions(Plugin plugin) { - this.Plugin = plugin; - this.Party = new Party(this.Plugin); - this.Chat = new Chat(this.Plugin); - this.Context = new Context(this.Plugin); + Plugin = plugin; + Party = new Party(Plugin); + Chat = new Chat(Plugin); + Context = new Context(Plugin); Plugin.GameInteropProvider.InitializeFromAttributes(this); - this.ResolveTextCommandPlaceholderHook?.Enable(); + ResolveTextCommandPlaceholderHook?.Enable(); } public void Dispose() { - this.Chat.Dispose(); + Chat.Dispose(); - this.ResolveTextCommandPlaceholderHook?.Dispose(); + ResolveTextCommandPlaceholderHook?.Dispose(); - Marshal.FreeHGlobal(this._placeholderNamePtr); + Marshal.FreeHGlobal(_placeholderNamePtr); } private IntPtr GetInfoModule() { - if (this._infoModuleVfunc is not { } vfunc) { + if (_infoModuleVfunc is not { } vfunc) { return IntPtr.Zero; } @@ -95,25 +95,25 @@ internal unsafe class GameFunctions : IDisposable { } internal IntPtr GetInfoProxyByIndex(uint idx) { - var infoModule = this.GetInfoModule(); - return infoModule == IntPtr.Zero ? IntPtr.Zero : this._getInfoProxyByIndex(infoModule, idx); + var infoModule = GetInfoModule(); + return infoModule == IntPtr.Zero ? IntPtr.Zero : _getInfoProxyByIndex(infoModule, idx); } internal uint? GetCurrentChatLogEntryIndex() { - if (this._currentChatEntryOffset == null) { + if (_currentChatEntryOffset == null) { return null; } var log = (IntPtr) Framework.Instance()->GetUiModule()->GetRaptureLogModule(); - return *(uint*) (log + this._currentChatEntryOffset.Value); + return *(uint*) (log + _currentChatEntryOffset.Value); } internal void SendFriendRequest(string name, ushort world) { - this.ListCommand(name, world, "friendlist"); + ListCommand(name, world, "friendlist"); } internal void AddToBlacklist(string name, ushort world) { - this.ListCommand(name, world, "blist"); + ListCommand(name, world, "blist"); } private void ListCommand(string name, ushort world, string commandName) { @@ -123,8 +123,8 @@ internal unsafe class GameFunctions : IDisposable { } var worldName = row.Name.RawString; - this._replacementName = $"{name}@{worldName}"; - this.Plugin.Common.Functions.Chat.SendMessage($"/{commandName} add {this._placeholder}"); + _replacementName = $"{name}@{worldName}"; + Plugin.Common.Functions.Chat.SendMessage($"/{commandName} add {_placeholder}"); } internal static void SetAddonInteractable(string name, bool interactable) { @@ -236,41 +236,41 @@ internal unsafe class GameFunctions : IDisposable { } internal bool IsMentor() { - if (this._isMentor == null || this._isMentorA1 == null || this._isMentorA1.Value == IntPtr.Zero) { + if (_isMentor == null || _isMentorA1 == null || _isMentorA1.Value == IntPtr.Zero) { return false; } - return this._isMentor(this._isMentorA1.Value) > 0; + return _isMentor(_isMentorA1.Value) > 0; } internal void OpenPartyFinder(uint id) { - if (this._openPartyFinder == null) { + if (_openPartyFinder == null) { return; } var agent = Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId(AgentId.LookingForGroup); if (agent != null) { - this._openPartyFinder(agent, id); + _openPartyFinder(agent, id); } } internal void OpenAchievement(uint id) { - if (this._openAchievement == null) { + if (_openAchievement == null) { return; } var agent = Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId(AgentId.Achievement); if (agent != null) { - this._openAchievement(agent, id); + _openAchievement(agent, id); } } internal bool IsInInstance() { - if (this._inInstance == null) { + if (_inInstance == null) { return false; } - return this._inInstance() != 0; + return _inInstance() != 0; } internal bool TryOpenAdventurerPlate(ulong playerId) @@ -304,21 +304,21 @@ internal unsafe class GameFunctions : IDisposable { private string? _replacementName; private IntPtr ResolveTextCommandPlaceholderDetour(IntPtr a1, byte* placeholderText, byte a3, byte a4) { - if (this._replacementName == null) { + if (_replacementName == null) { goto Original; } var placeholder = MemoryHelper.ReadStringNullTerminated((IntPtr) placeholderText); - if (placeholder != this._placeholder) { + if (placeholder != _placeholder) { goto Original; } - MemoryHelper.WriteString(this._placeholderNamePtr, this._replacementName); - this._replacementName = null; + MemoryHelper.WriteString(_placeholderNamePtr, _replacementName); + _replacementName = null; - return this._placeholderNamePtr; + return _placeholderNamePtr; Original: - return this.ResolveTextCommandPlaceholderHook!.Original(a1, placeholderText, a3, a4); + return ResolveTextCommandPlaceholderHook!.Original(a1, placeholderText, a3, a4); } } diff --git a/ChatTwo/GameFunctions/Party.cs b/ChatTwo/GameFunctions/Party.cs index 3e582f8..55e9afd 100755 --- a/ChatTwo/GameFunctions/Party.cs +++ b/ChatTwo/GameFunctions/Party.cs @@ -25,57 +25,57 @@ internal sealed unsafe class Party { private Plugin Plugin { get; } internal Party(Plugin plugin) { - this.Plugin = plugin; + Plugin = plugin; Plugin.GameInteropProvider.InitializeFromAttributes(this); } internal void InviteSameWorld(string name, ushort world, ulong contentId) { - if (this._inviteToParty == null) { + if (_inviteToParty == null) { return; } // 6.11: 214A55 - var a1 = this.Plugin.Functions.GetInfoProxyByIndex(2); + var a1 = Plugin.Functions.GetInfoProxyByIndex(2); fixed (byte* namePtr = name.ToTerminatedBytes()) { // this only works if target is on the same world - this._inviteToParty(a1, contentId, namePtr, world); + _inviteToParty(a1, contentId, namePtr, world); } } internal void InviteOtherWorld(ulong contentId) { - if (this._inviteToPartyContentId == null) { + if (_inviteToPartyContentId == null) { return; } // 6.11: 214A55 - var a1 = this.Plugin.Functions.GetInfoProxyByIndex(2); + var a1 = Plugin.Functions.GetInfoProxyByIndex(2); if (contentId != 0) { // third param is world, but it requires a specific world // if they're not on that world, it will fail // pass 0 and it will work on any world EXCEPT for the world the // current player is on - this._inviteToPartyContentId(a1, contentId, 0); + _inviteToPartyContentId(a1, contentId, 0); } } internal void InviteInInstance(ulong contentId) { - if (this._inviteToPartyInInstance == null) { + if (_inviteToPartyInInstance == null) { return; } // 6.11: 214A55 - var a1 = this.Plugin.Functions.GetInfoProxyByIndex(2); + var a1 = Plugin.Functions.GetInfoProxyByIndex(2); if (contentId != 0) { // third param is world, but it requires a specific world // if they're not on that world, it will fail // pass 0 and it will work on any world EXCEPT for the world the // current player is on - this._inviteToPartyInInstance(a1, contentId); + _inviteToPartyInInstance(a1, contentId); } } internal void Kick(string name, ulong contentId) { - if (this._kick == null) { + if (_kick == null) { return; } @@ -85,12 +85,12 @@ internal sealed unsafe class Party { } fixed (byte* namePtr = name.ToTerminatedBytes()) { - this._kick(agent, namePtr, 0, contentId); + _kick(agent, namePtr, 0, contentId); } } internal void Promote(string name, ulong contentId) { - if (this._promote == null) { + if (_promote == null) { return; } @@ -100,7 +100,7 @@ internal sealed unsafe class Party { } fixed (byte* namePtr = name.ToTerminatedBytes()) { - this._promote(agent, namePtr, 0, contentId); + _promote(agent, namePtr, 0, contentId); } } } diff --git a/ChatTwo/GameFunctions/Types/ChannelSwitchInfo.cs b/ChatTwo/GameFunctions/Types/ChannelSwitchInfo.cs index f4d1c87..3d82528 100755 --- a/ChatTwo/GameFunctions/Types/ChannelSwitchInfo.cs +++ b/ChatTwo/GameFunctions/Types/ChannelSwitchInfo.cs @@ -9,9 +9,9 @@ internal class ChannelSwitchInfo { internal string? Text { get; } internal ChannelSwitchInfo(InputChannel? channel, bool permanent = false, RotateMode rotate = RotateMode.None, string? text = null) { - this.Channel = channel; - this.Permanent = permanent; - this.Rotate = rotate; - this.Text = text; + Channel = channel; + Permanent = permanent; + Rotate = rotate; + Text = text; } } diff --git a/ChatTwo/GameFunctions/Types/ChatActivatedArgs.cs b/ChatTwo/GameFunctions/Types/ChatActivatedArgs.cs index da753da..ada612a 100755 --- a/ChatTwo/GameFunctions/Types/ChatActivatedArgs.cs +++ b/ChatTwo/GameFunctions/Types/ChatActivatedArgs.cs @@ -8,6 +8,6 @@ internal sealed class ChatActivatedArgs { internal TellTarget? TellTarget { get; init; } internal ChatActivatedArgs(ChannelSwitchInfo channelSwitchInfo) { - this.ChannelSwitchInfo = channelSwitchInfo; + ChannelSwitchInfo = channelSwitchInfo; } } diff --git a/ChatTwo/GameFunctions/Types/TellHistoryInfo.cs b/ChatTwo/GameFunctions/Types/TellHistoryInfo.cs index 3804724..dc9d2f8 100755 --- a/ChatTwo/GameFunctions/Types/TellHistoryInfo.cs +++ b/ChatTwo/GameFunctions/Types/TellHistoryInfo.cs @@ -6,8 +6,8 @@ internal sealed class TellHistoryInfo { internal ulong ContentId { get; } internal TellHistoryInfo(string name, uint world, ulong contentId) { - this.Name = name; - this.World = world; - this.ContentId = contentId; + Name = name; + World = world; + ContentId = contentId; } } diff --git a/ChatTwo/GameFunctions/Types/TellTarget.cs b/ChatTwo/GameFunctions/Types/TellTarget.cs index 47b6324..a8705d1 100755 --- a/ChatTwo/GameFunctions/Types/TellTarget.cs +++ b/ChatTwo/GameFunctions/Types/TellTarget.cs @@ -7,9 +7,9 @@ internal sealed class TellTarget { internal TellReason Reason { get; } internal TellTarget(string name, ushort world, ulong contentId, TellReason reason) { - this.Name = name; - this.World = world; - this.ContentId = contentId; - this.Reason = reason; + Name = name; + World = world; + ContentId = contentId; + Reason = reason; } } diff --git a/ChatTwo/Ipc/ExtraChat.cs b/ChatTwo/Ipc/ExtraChat.cs index bfc607d..113a025 100644 --- a/ChatTwo/Ipc/ExtraChat.cs +++ b/ChatTwo/Ipc/ExtraChat.cs @@ -19,47 +19,47 @@ internal sealed class ExtraChat : IDisposable { internal (string, uint)? ChannelOverride { get; set; } private Dictionary ChannelCommandColoursInternal { get; set; } = new(); - internal IReadOnlyDictionary ChannelCommandColours => this.ChannelCommandColoursInternal; + internal IReadOnlyDictionary ChannelCommandColours => ChannelCommandColoursInternal; private Dictionary ChannelNamesInternal { get; set; } = new(); - internal IReadOnlyDictionary ChannelNames => this.ChannelNamesInternal; + internal IReadOnlyDictionary ChannelNames => ChannelNamesInternal; internal ExtraChat(Plugin plugin) { - this.Plugin = plugin; + Plugin = plugin; - this.OverrideChannelGate = Plugin.Interface.GetIpcSubscriber("ExtraChat.OverrideChannelColour"); - this.ChannelCommandColoursGate = Plugin.Interface.GetIpcSubscriber, Dictionary>("ExtraChat.ChannelCommandColours"); - this.ChannelNamesGate = Plugin.Interface.GetIpcSubscriber, Dictionary>("ExtraChat.ChannelNames"); + OverrideChannelGate = Plugin.Interface.GetIpcSubscriber("ExtraChat.OverrideChannelColour"); + ChannelCommandColoursGate = Plugin.Interface.GetIpcSubscriber, Dictionary>("ExtraChat.ChannelCommandColours"); + ChannelNamesGate = Plugin.Interface.GetIpcSubscriber, Dictionary>("ExtraChat.ChannelNames"); - this.OverrideChannelGate.Subscribe(this.OnOverrideChannel); - this.ChannelCommandColoursGate.Subscribe(this.OnChannelCommandColours); - this.ChannelNamesGate.Subscribe(this.OnChannelNames); + OverrideChannelGate.Subscribe(OnOverrideChannel); + ChannelCommandColoursGate.Subscribe(OnChannelCommandColours); + ChannelNamesGate.Subscribe(OnChannelNames); try { - this.ChannelCommandColoursInternal = this.ChannelCommandColoursGate.InvokeFunc(null!); - this.ChannelNamesInternal = this.ChannelNamesGate.InvokeFunc(null!); + ChannelCommandColoursInternal = ChannelCommandColoursGate.InvokeFunc(null!); + ChannelNamesInternal = ChannelNamesGate.InvokeFunc(null!); } catch (Exception) { // no-op } } public void Dispose() { - this.OverrideChannelGate.Unsubscribe(this.OnOverrideChannel); + OverrideChannelGate.Unsubscribe(OnOverrideChannel); } private void OnOverrideChannel(OverrideInfo info) { if (info.Channel == null) { - this.ChannelOverride = null; + ChannelOverride = null; return; } - this.ChannelOverride = (info.Channel, info.Rgba); + ChannelOverride = (info.Channel, info.Rgba); } private void OnChannelCommandColours(Dictionary obj) { - this.ChannelCommandColoursInternal = obj; + ChannelCommandColoursInternal = obj; } private void OnChannelNames(Dictionary obj) { - this.ChannelNamesInternal = obj; + ChannelNamesInternal = obj; } } diff --git a/ChatTwo/IpcManager.cs b/ChatTwo/IpcManager.cs index 0148d53..801b996 100755 --- a/ChatTwo/IpcManager.cs +++ b/ChatTwo/IpcManager.cs @@ -15,38 +15,38 @@ internal sealed class IpcManager : IDisposable { internal List Registered { get; } = new(); public IpcManager(DalamudPluginInterface pluginInterface) { - this.Interface = pluginInterface; + Interface = pluginInterface; - this.RegisterGate = this.Interface.GetIpcProvider("ChatTwo.Register"); - this.RegisterGate.RegisterFunc(this.Register); + RegisterGate = Interface.GetIpcProvider("ChatTwo.Register"); + RegisterGate.RegisterFunc(Register); - this.AvailableGate = this.Interface.GetIpcProvider("ChatTwo.Available"); + AvailableGate = Interface.GetIpcProvider("ChatTwo.Available"); - this.UnregisterGate = this.Interface.GetIpcProvider("ChatTwo.Unregister"); - this.UnregisterGate.RegisterAction(this.Unregister); + UnregisterGate = Interface.GetIpcProvider("ChatTwo.Unregister"); + UnregisterGate.RegisterAction(Unregister); - this.InvokeGate = this.Interface.GetIpcProvider("ChatTwo.Invoke"); + InvokeGate = Interface.GetIpcProvider("ChatTwo.Invoke"); - this.AvailableGate.SendMessage(); + AvailableGate.SendMessage(); } internal void Invoke(string id, PlayerPayload? sender, ulong contentId, Payload? payload, SeString? senderString, SeString? content) { - this.InvokeGate.SendMessage(id, sender, contentId, payload, senderString, content); + InvokeGate.SendMessage(id, sender, contentId, payload, senderString, content); } private string Register() { var id = Guid.NewGuid().ToString(); - this.Registered.Add(id); + Registered.Add(id); return id; } private void Unregister(string id) { - this.Registered.Remove(id); + Registered.Remove(id); } public void Dispose() { - this.UnregisterGate.UnregisterFunc(); - this.RegisterGate.UnregisterFunc(); - this.Registered.Clear(); + UnregisterGate.UnregisterFunc(); + RegisterGate.UnregisterFunc(); + Registered.Clear(); } } diff --git a/ChatTwo/Message.cs b/ChatTwo/Message.cs index 5a40276..4f5803e 100755 --- a/ChatTwo/Message.cs +++ b/ChatTwo/Message.cs @@ -12,15 +12,15 @@ internal class SortCode { internal ChatSource Source { get; set; } internal SortCode(ChatType type, ChatSource source) { - this.Type = type; - this.Source = source; + Type = type; + Source = source; } public SortCode() { } private bool Equals(SortCode other) { - return this.Type == other.Type && this.Source == other.Source; + return Type == other.Type && Source == other.Source; } public override bool Equals(object? obj) { @@ -32,12 +32,12 @@ internal class SortCode { return true; } - return obj.GetType() == this.GetType() && this.Equals((SortCode) obj); + return obj.GetType() == GetType() && Equals((SortCode) obj); } public override int GetHashCode() { unchecked { - return ((int) this.Type * 397) ^ (int) this.Source; + return ((int) Type * 397) ^ (int) Source; } } } @@ -68,16 +68,16 @@ internal class Message { internal int Hash { get; } internal Message(ulong receiver, ChatCode code, List sender, List content, SeString senderSource, SeString contentSource) { - this.Receiver = receiver; - this.Date = DateTime.UtcNow; - this.Code = code; - this.Sender = sender; - this.Content = ReplaceContentURLs(content); - this.SenderSource = senderSource; - this.ContentSource = contentSource; - this.SortCode = new SortCode(this.Code.Type, this.Code.Source); - this.ExtraChatChannel = this.ExtractExtraChatChannel(); - this.Hash = this.GenerateHash(); + Receiver = receiver; + Date = DateTime.UtcNow; + Code = code; + Sender = sender; + Content = ReplaceContentURLs(content); + SenderSource = senderSource; + ContentSource = contentSource; + SortCode = new SortCode(Code.Type, Code.Source); + ExtraChatChannel = ExtractExtraChatChannel(); + Hash = GenerateHash(); foreach (var chunk in sender.Concat(content)) { chunk.Message = this; @@ -85,56 +85,56 @@ internal class Message { } internal Message(ObjectId id, ulong receiver, ulong contentId, DateTime date, BsonDocument code, BsonArray sender, BsonArray content, BsonValue senderSource, BsonValue contentSource, BsonDocument sortCode) { - this.Id = id; - this.Receiver = receiver; - this.ContentId = contentId; - this.Date = date; - this.Code = BsonMapper.Global.ToObject(code); - this.Sender = BsonMapper.Global.Deserialize>(sender); + Id = id; + Receiver = receiver; + ContentId = contentId; + Date = date; + Code = BsonMapper.Global.ToObject(code); + Sender = BsonMapper.Global.Deserialize>(sender); // Don't call ReplaceContentURLs here since we're loading the message // from the database and it should already have parsed URL data. - this.Content = BsonMapper.Global.Deserialize>(content); - this.SenderSource = BsonMapper.Global.Deserialize(senderSource); - this.ContentSource = BsonMapper.Global.Deserialize(contentSource); - this.SortCode = BsonMapper.Global.ToObject(sortCode); - this.ExtraChatChannel = this.ExtractExtraChatChannel(); - this.Hash = this.GenerateHash(); + Content = BsonMapper.Global.Deserialize>(content); + SenderSource = BsonMapper.Global.Deserialize(senderSource); + ContentSource = BsonMapper.Global.Deserialize(contentSource); + SortCode = BsonMapper.Global.ToObject(sortCode); + ExtraChatChannel = ExtractExtraChatChannel(); + Hash = GenerateHash(); - foreach (var chunk in this.Sender.Concat(this.Content)) { + foreach (var chunk in Sender.Concat(Content)) { chunk.Message = this; } } internal Message(ObjectId id, ulong receiver, ulong contentId, DateTime date, BsonDocument code, BsonArray sender, BsonArray content, BsonValue senderSource, BsonValue contentSource, BsonDocument sortCode, BsonValue extraChatChannel) { - this.Id = id; - this.Receiver = receiver; - this.ContentId = contentId; - this.Date = date; - this.Code = BsonMapper.Global.ToObject(code); - this.Sender = BsonMapper.Global.Deserialize>(sender); + Id = id; + Receiver = receiver; + ContentId = contentId; + Date = date; + Code = BsonMapper.Global.ToObject(code); + Sender = BsonMapper.Global.Deserialize>(sender); // Don't call ReplaceContentURLs here since we're loading the message // from the database and it should already have parsed URL data. - this.Content = BsonMapper.Global.Deserialize>(content); - this.SenderSource = BsonMapper.Global.Deserialize(senderSource); - this.ContentSource = BsonMapper.Global.Deserialize(contentSource); - this.SortCode = BsonMapper.Global.ToObject(sortCode); - this.ExtraChatChannel = BsonMapper.Global.Deserialize(extraChatChannel); - this.Hash = this.GenerateHash(); + Content = BsonMapper.Global.Deserialize>(content); + SenderSource = BsonMapper.Global.Deserialize(senderSource); + ContentSource = BsonMapper.Global.Deserialize(contentSource); + SortCode = BsonMapper.Global.ToObject(sortCode); + ExtraChatChannel = BsonMapper.Global.Deserialize(extraChatChannel); + Hash = GenerateHash(); - foreach (var chunk in this.Sender.Concat(this.Content)) { + foreach (var chunk in Sender.Concat(Content)) { chunk.Message = this; } } private int GenerateHash() { - return this.SortCode.GetHashCode() - ^ this.ExtraChatChannel.GetHashCode() - ^ string.Join("", this.Sender.Select(c => c.StringValue())).GetHashCode() - ^ string.Join("", this.Content.Select(c => c.StringValue())).GetHashCode(); + return SortCode.GetHashCode() + ^ ExtraChatChannel.GetHashCode() + ^ string.Join("", Sender.Select(c => c.StringValue())).GetHashCode() + ^ string.Join("", Content.Select(c => c.StringValue())).GetHashCode(); } private Guid ExtractExtraChatChannel() { - if (this.ContentSource.Payloads.Count > 0 && this.ContentSource.Payloads[0] is RawPayload raw) { + if (ContentSource.Payloads.Count > 0 && ContentSource.Payloads[0] is RawPayload raw) { // this does an encode and clone every time it's accessed, so cache var data = raw.Data; if (data[1] == 0x27 && data[2] == 18 && data[3] == 0x20) { diff --git a/ChatTwo/Resources/Language.Designer.cs b/ChatTwo/Resources/Language.Designer.cs index d6749bd..785641f 100755 --- a/ChatTwo/Resources/Language.Designer.cs +++ b/ChatTwo/Resources/Language.Designer.cs @@ -1967,6 +1967,15 @@ namespace ChatTwo.Resources { } } + /// + /// Looks up a localized string similar to Override your selected dalamud style with a different one. + /// + internal static string Options_OverrideStyle_Name_Desc { + get { + return ResourceManager.GetString("Options_OverrideStyle_Name_Desc", resourceCulture); + } + } + /// /// Looks up a localized string similar to Styles. /// diff --git a/ChatTwo/Resources/Language.resx b/ChatTwo/Resources/Language.resx index 5fe2004..80236d4 100644 --- a/ChatTwo/Resources/Language.resx +++ b/ChatTwo/Resources/Language.resx @@ -920,4 +920,7 @@ Get help in the discord thread: + + Override your selected dalamud style with a different one + diff --git a/ChatTwo/TextureCache.cs b/ChatTwo/TextureCache.cs index 6c0caad..06ad9a4 100755 --- a/ChatTwo/TextureCache.cs +++ b/ChatTwo/TextureCache.cs @@ -11,17 +11,17 @@ internal class TextureCache : IDisposable { private readonly Dictionary<(uint, bool), IDalamudTextureWrap> _statusIcons = new(); private readonly Dictionary<(uint, bool), IDalamudTextureWrap> _eventItemIcons = new(); - 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 IReadOnlyDictionary<(uint, bool), IDalamudTextureWrap> ItemIcons => _itemIcons; + internal IReadOnlyDictionary<(uint, bool), IDalamudTextureWrap> StatusIcons => _statusIcons; + internal IReadOnlyDictionary<(uint, bool), IDalamudTextureWrap> EventItemIcons => _eventItemIcons; internal TextureCache(ITextureProvider textureProvider) { - this.TextureProvider = textureProvider; + TextureProvider = textureProvider; } public void Dispose() { - var allIcons = this.ItemIcons.Values - .Concat(this.StatusIcons.Values); + var allIcons = ItemIcons.Values + .Concat(StatusIcons.Values); foreach (var tex in allIcons) { tex.Dispose(); @@ -34,40 +34,40 @@ internal class TextureCache : IDisposable { } var tex = hq - ? this.TextureProvider.GetIcon(icon, ITextureProvider.IconFlags.ItemHighQuality) - : this.TextureProvider.GetIcon(icon); + ? TextureProvider.GetIcon(icon, ITextureProvider.IconFlags.ItemHighQuality) + : TextureProvider.GetIcon(icon); if (tex != null) { dict[(icon, hq)] = tex; } } internal void AddItem(Item item, bool hq) { - this.AddIcon(this._itemIcons, item.Icon, hq); + AddIcon(_itemIcons, item.Icon, hq); } internal void AddStatus(Status status) { - this.AddIcon(this._statusIcons, status.Icon); + AddIcon(_statusIcons, status.Icon); } internal void AddEventItem(EventItem item) { - this.AddIcon(this._eventItemIcons, item.Icon); + AddIcon(_eventItemIcons, item.Icon); } internal IDalamudTextureWrap? GetItem(Item item, bool hq = false) { - this.AddItem(item, hq); - this.ItemIcons.TryGetValue((item.Icon, hq), out var icon); + AddItem(item, hq); + ItemIcons.TryGetValue((item.Icon, hq), out var icon); return icon; } internal IDalamudTextureWrap? GetStatus(Status status) { - this.AddStatus(status); - this.StatusIcons.TryGetValue((status.Icon, false), out var icon); + AddStatus(status); + StatusIcons.TryGetValue((status.Icon, false), out var icon); return icon; } internal IDalamudTextureWrap? GetEventItem(EventItem item) { - this.AddEventItem(item); - this.EventItemIcons.TryGetValue((item.Icon, false), out var icon); + AddEventItem(item); + EventItemIcons.TryGetValue((item.Icon, false), out var icon); return icon; } } diff --git a/ChatTwo/Ui/AutoCompleteInfo.cs b/ChatTwo/Ui/AutoCompleteInfo.cs index 756c425..e0d7222 100755 --- a/ChatTwo/Ui/AutoCompleteInfo.cs +++ b/ChatTwo/Ui/AutoCompleteInfo.cs @@ -6,8 +6,8 @@ internal class AutoCompleteInfo { internal int EndPos { get; } internal AutoCompleteInfo(string toComplete, int startPos, int endPos) { - this.ToComplete = toComplete; - this.StartPos = startPos; - this.EndPos = endPos; + ToComplete = toComplete; + StartPos = startPos; + EndPos = endPos; } } diff --git a/ChatTwo/Ui/Fonts.cs b/ChatTwo/Ui/Fonts.cs index ceec9e1..2468152 100755 --- a/ChatTwo/Ui/Fonts.cs +++ b/ChatTwo/Ui/Fonts.cs @@ -169,7 +169,7 @@ internal sealed class FaceData { internal byte[] Data { get; } internal FaceData(byte[] data) { - this.Data = data; + Data = data; } } @@ -178,8 +178,8 @@ internal sealed class FontData { internal FaceData? Italic { get; } internal FontData(FaceData regular, FaceData? italic) { - this.Regular = regular; - this.Italic = italic; + Regular = regular; + Italic = italic; } } @@ -189,8 +189,8 @@ internal sealed class Font { internal string ResourcePathItalic { get; } internal Font(string name, string resourcePath, string resourcePathItalic) { - this.Name = name; - this.ResourcePath = resourcePath; - this.ResourcePathItalic = resourcePathItalic; + Name = name; + ResourcePath = resourcePath; + ResourcePathItalic = resourcePathItalic; } } diff --git a/ChatTwo/Ui/SettingsTabs/ChatColours.cs b/ChatTwo/Ui/SettingsTabs/ChatColours.cs index b49b21f..0571895 100755 --- a/ChatTwo/Ui/SettingsTabs/ChatColours.cs +++ b/ChatTwo/Ui/SettingsTabs/ChatColours.cs @@ -13,8 +13,8 @@ internal sealed class ChatColours : ISettingsTab { public string Name => Language.Options_ChatColours_Tab + "###tabs-chat-colours"; internal ChatColours(Configuration mutable, Plugin plugin) { - this.Mutable = mutable; - this.Plugin = plugin; + Mutable = mutable; + Plugin = plugin; #if DEBUG var sortable = ChatTypeExt.SortOrder @@ -36,23 +36,23 @@ internal sealed class ChatColours : ISettingsTab { foreach (var (_, types) in ChatTypeExt.SortOrder) { foreach (var type in types) { if (ImGuiUtil.IconButton(FontAwesomeIcon.UndoAlt, $"{type}", Language.Options_ChatColours_Reset)) { - this.Mutable.ChatColours.Remove(type); + Mutable.ChatColours.Remove(type); } ImGui.SameLine(); if (ImGuiUtil.IconButton(FontAwesomeIcon.LongArrowAltDown, $"{type}", Language.Options_ChatColours_Import)) { - var gameColour = this.Plugin.Functions.Chat.GetChannelColour(type); - this.Mutable.ChatColours[type] = gameColour ?? type.DefaultColour() ?? 0; + var gameColour = Plugin.Functions.Chat.GetChannelColour(type); + Mutable.ChatColours[type] = gameColour ?? type.DefaultColour() ?? 0; } ImGui.SameLine(); - var vec = this.Mutable.ChatColours.TryGetValue(type, out var colour) + var vec = Mutable.ChatColours.TryGetValue(type, out var colour) ? ColourUtil.RgbaToVector3(colour) : ColourUtil.RgbaToVector3(type.DefaultColour() ?? 0); if (ImGui.ColorEdit3(type.Name(), ref vec, ImGuiColorEditFlags.NoInputs)) { - this.Mutable.ChatColours[type] = ColourUtil.Vector3ToRgba(vec); + Mutable.ChatColours[type] = ColourUtil.Vector3ToRgba(vec); } } } diff --git a/ChatTwo/Ui/SettingsTabs/Database.cs b/ChatTwo/Ui/SettingsTabs/Database.cs index 97aa67b..f0814f5 100755 --- a/ChatTwo/Ui/SettingsTabs/Database.cs +++ b/ChatTwo/Ui/SettingsTabs/Database.cs @@ -11,36 +11,36 @@ internal sealed class Database : ISettingsTab { public string Name => Language.Options_Database_Tab + "###tabs-database"; internal Database(Configuration mutable, Store store) { - this.Store = store; - this.Mutable = mutable; + Store = store; + Mutable = mutable; } private bool _showAdvanced; public void Draw(bool changed) { if (changed) { - this._showAdvanced = ImGui.GetIO().KeyShift; + _showAdvanced = ImGui.GetIO().KeyShift; } - ImGuiUtil.OptionCheckbox(ref this.Mutable.DatabaseBattleMessages, Language.Options_DatabaseBattleMessages_Name, Language.Options_DatabaseBattleMessages_Description); + ImGuiUtil.OptionCheckbox(ref Mutable.DatabaseBattleMessages, Language.Options_DatabaseBattleMessages_Name, Language.Options_DatabaseBattleMessages_Description); ImGui.Spacing(); - if (ImGuiUtil.OptionCheckbox(ref this.Mutable.LoadPreviousSession, Language.Options_LoadPreviousSession_Name, Language.Options_LoadPreviousSession_Description)) { - if (this.Mutable.LoadPreviousSession) { - this.Mutable.FilterIncludePreviousSessions = true; + if (ImGuiUtil.OptionCheckbox(ref Mutable.LoadPreviousSession, Language.Options_LoadPreviousSession_Name, Language.Options_LoadPreviousSession_Description)) { + if (Mutable.LoadPreviousSession) { + Mutable.FilterIncludePreviousSessions = true; } } ImGui.Spacing(); - if (ImGuiUtil.OptionCheckbox(ref this.Mutable.FilterIncludePreviousSessions, Language.Options_FilterIncludePreviousSessions_Name, Language.Options_FilterIncludePreviousSessions_Description)) { - if (!this.Mutable.FilterIncludePreviousSessions) { - this.Mutable.LoadPreviousSession = false; + if (ImGuiUtil.OptionCheckbox(ref Mutable.FilterIncludePreviousSessions, Language.Options_FilterIncludePreviousSessions_Name, Language.Options_FilterIncludePreviousSessions_Description)) { + if (!Mutable.FilterIncludePreviousSessions) { + Mutable.LoadPreviousSession = false; } } ImGuiUtil.OptionCheckbox( - ref this.Mutable.SharedMode, + ref Mutable.SharedMode, Language.Options_SharedMode_Name, string.Format(Language.Options_SharedMode_Description, Plugin.PluginName) ); @@ -48,16 +48,16 @@ internal sealed class Database : ISettingsTab { ImGui.Spacing(); - if (this._showAdvanced && ImGui.TreeNodeEx(Language.Options_Database_Advanced)) { + if (_showAdvanced && ImGui.TreeNodeEx(Language.Options_Database_Advanced)) { ImGui.PushTextWrapPos(); ImGuiUtil.WarningText(Language.Options_Database_Advanced_Warning); if (ImGui.Button("Checkpoint")) { - this.Store.Database.Checkpoint(); + Store.Database.Checkpoint(); } if (ImGui.Button("Rebuild")) { - this.Store.Database.Rebuild(); + Store.Database.Rebuild(); } ImGui.PopTextWrapPos(); diff --git a/ChatTwo/Ui/SettingsTabs/Display.cs b/ChatTwo/Ui/SettingsTabs/Display.cs index 662d3a5..2c938c5 100755 --- a/ChatTwo/Ui/SettingsTabs/Display.cs +++ b/ChatTwo/Ui/SettingsTabs/Display.cs @@ -90,7 +90,7 @@ internal sealed class Display : ISettingsTab { ImGuiUtil.OptionCheckbox(ref Mutable.ShowPopOutTitleBar, Language.Options_ShowPopOutTitleBar_Name); ImGui.Spacing(); - ImGui.Checkbox(Language.Options_OverrideStyle_Name, ref Mutable.OverrideStyle); + ImGuiUtil.OptionCheckbox(ref Mutable.OverrideStyle, Language.Options_OverrideStyle_Name, Language.Options_OverrideStyle_Name_Desc); ImGui.Spacing(); if (Mutable.OverrideStyle) @@ -98,7 +98,7 @@ internal sealed class Display : ISettingsTab { var currentStyle = Mutable.ChosenStyle.Equals("") ? StyleModel.GetConfiguredStyle().Name : Mutable.ChosenStyle; if (ImGui.BeginCombo(Language.Options_OverrideStyleDropdown_Name, currentStyle)) { foreach (var style in StyleModel.GetConfiguredStyles()) { - if (ImGui.Selectable(style.Name, this.Mutable.ChosenStyle == style.Name)) { + if (ImGui.Selectable(style.Name, Mutable.ChosenStyle == style.Name)) { Mutable.ChosenStyle = style.Name; } } diff --git a/ChatTwo/Ui/SettingsTabs/Fonts.cs b/ChatTwo/Ui/SettingsTabs/Fonts.cs index db14ee8..95474f4 100755 --- a/ChatTwo/Ui/SettingsTabs/Fonts.cs +++ b/ChatTwo/Ui/SettingsTabs/Fonts.cs @@ -12,45 +12,45 @@ public class Fonts : ISettingsTab { private List JpFonts { get; set; } = new(); internal Fonts(Configuration mutable) { - this.Mutable = mutable; - this.UpdateFonts(); + Mutable = mutable; + UpdateFonts(); } private void UpdateFonts() { - this.GlobalFonts = Ui.Fonts.GetFonts(); - this.JpFonts = Ui.Fonts.GetJpFonts(); + GlobalFonts = Ui.Fonts.GetFonts(); + JpFonts = Ui.Fonts.GetJpFonts(); } public void Draw(bool changed) { if (changed) { - this.UpdateFonts(); + UpdateFonts(); } ImGui.PushTextWrapPos(); - ImGui.Checkbox(Language.Options_FontsEnabled, ref this.Mutable.FontsEnabled); + ImGui.Checkbox(Language.Options_FontsEnabled, ref Mutable.FontsEnabled); ImGui.Spacing(); - if (this.Mutable.FontsEnabled) { - if (ImGuiUtil.BeginComboVertical(Language.Options_Font_Name, this.Mutable.GlobalFont)) { + if (Mutable.FontsEnabled) { + if (ImGuiUtil.BeginComboVertical(Language.Options_Font_Name, Mutable.GlobalFont)) { foreach (var font in Ui.Fonts.GlobalFonts) { - if (ImGui.Selectable(font.Name, this.Mutable.GlobalFont == font.Name)) { - this.Mutable.GlobalFont = font.Name; + if (ImGui.Selectable(font.Name, Mutable.GlobalFont == font.Name)) { + Mutable.GlobalFont = font.Name; } - if (ImGui.IsWindowAppearing() && this.Mutable.GlobalFont == font.Name) { + if (ImGui.IsWindowAppearing() && Mutable.GlobalFont == font.Name) { ImGui.SetScrollHereY(0.5f); } } ImGui.Separator(); - foreach (var name in this.GlobalFonts) { - if (ImGui.Selectable(name, this.Mutable.GlobalFont == name)) { - this.Mutable.GlobalFont = name; + foreach (var name in GlobalFonts) { + if (ImGui.Selectable(name, Mutable.GlobalFont == name)) { + Mutable.GlobalFont = name; } - if (ImGui.IsWindowAppearing() && this.Mutable.GlobalFont == name) { + if (ImGui.IsWindowAppearing() && Mutable.GlobalFont == name) { ImGui.SetScrollHereY(0.5f); } } @@ -62,25 +62,25 @@ public class Fonts : ISettingsTab { ImGuiUtil.WarningText(Language.Options_Font_Warning); ImGui.Spacing(); - if (ImGuiUtil.BeginComboVertical(Language.Options_JapaneseFont_Name, this.Mutable.JapaneseFont)) { + if (ImGuiUtil.BeginComboVertical(Language.Options_JapaneseFont_Name, Mutable.JapaneseFont)) { foreach (var (name, _) in Ui.Fonts.JapaneseFonts) { - if (ImGui.Selectable(name, this.Mutable.JapaneseFont == name)) { - this.Mutable.JapaneseFont = name; + if (ImGui.Selectable(name, Mutable.JapaneseFont == name)) { + Mutable.JapaneseFont = name; } - if (ImGui.IsWindowAppearing() && this.Mutable.JapaneseFont == name) { + if (ImGui.IsWindowAppearing() && Mutable.JapaneseFont == name) { ImGui.SetScrollHereY(0.5f); } } ImGui.Separator(); - foreach (var family in this.JpFonts) { - if (ImGui.Selectable(family, this.Mutable.JapaneseFont == family)) { - this.Mutable.JapaneseFont = family; + foreach (var family in JpFonts) { + if (ImGui.Selectable(family, Mutable.JapaneseFont == family)) { + Mutable.JapaneseFont = family; } - if (ImGui.IsWindowAppearing() && this.Mutable.JapaneseFont == family) { + if (ImGui.IsWindowAppearing() && Mutable.JapaneseFont == family) { ImGui.SetScrollHereY(0.5f); } } @@ -94,12 +94,12 @@ public class Fonts : ISettingsTab { if (ImGui.CollapsingHeader(Language.Options_ExtraGlyphs_Name)) { ImGuiUtil.HelpText(string.Format(Language.Options_ExtraGlyphs_Description, Plugin.PluginName)); - var range = (int) this.Mutable.ExtraGlyphRanges; + var range = (int) Mutable.ExtraGlyphRanges; foreach (var extra in Enum.GetValues()) { ImGui.CheckboxFlags(extra.Name(), ref range, (int) extra); } - this.Mutable.ExtraGlyphRanges = (ExtraGlyphRanges) range; + Mutable.ExtraGlyphRanges = (ExtraGlyphRanges) range; } ImGui.Spacing(); @@ -108,9 +108,9 @@ public class Fonts : ISettingsTab { const float speed = .0125f; const float min = 8f; const float max = 36f; - ImGuiUtil.DragFloatVertical(Language.Options_FontSize_Name, ref this.Mutable.FontSize, speed, min, max, $"{this.Mutable.FontSize:N1}"); - ImGuiUtil.DragFloatVertical(Language.Options_JapaneseFontSize_Name, ref this.Mutable.JapaneseFontSize, speed, min, max, $"{this.Mutable.JapaneseFontSize:N1}"); - ImGuiUtil.DragFloatVertical(Language.Options_SymbolsFontSize_Name, ref this.Mutable.SymbolsFontSize, speed, min, max, $"{this.Mutable.SymbolsFontSize:N1}"); + ImGuiUtil.DragFloatVertical(Language.Options_FontSize_Name, ref Mutable.FontSize, speed, min, max, $"{Mutable.FontSize:N1}"); + ImGuiUtil.DragFloatVertical(Language.Options_JapaneseFontSize_Name, ref Mutable.JapaneseFontSize, speed, min, max, $"{Mutable.JapaneseFontSize:N1}"); + ImGuiUtil.DragFloatVertical(Language.Options_SymbolsFontSize_Name, ref Mutable.SymbolsFontSize, speed, min, max, $"{Mutable.SymbolsFontSize:N1}"); ImGuiUtil.HelpText(Language.Options_SymbolsFontSize_Description); ImGui.PopTextWrapPos(); diff --git a/ChatTwo/Ui/SettingsTabs/Miscellaneous.cs b/ChatTwo/Ui/SettingsTabs/Miscellaneous.cs index 5b9dceb..e03a795 100755 --- a/ChatTwo/Ui/SettingsTabs/Miscellaneous.cs +++ b/ChatTwo/Ui/SettingsTabs/Miscellaneous.cs @@ -10,14 +10,14 @@ internal sealed class Miscellaneous : ISettingsTab { public string Name => Language.Options_Miscellaneous_Tab + "###tabs-miscellaneous"; public Miscellaneous(Configuration mutable) { - this.Mutable = mutable; + Mutable = mutable; } public void Draw(bool changed) { - if (ImGuiUtil.BeginComboVertical(Language.Options_Language_Name, this.Mutable.LanguageOverride.Name())) { + if (ImGuiUtil.BeginComboVertical(Language.Options_Language_Name, Mutable.LanguageOverride.Name())) { foreach (var language in Enum.GetValues()) { if (ImGui.Selectable(language.Name())) { - this.Mutable.LanguageOverride = language; + Mutable.LanguageOverride = language; } } @@ -27,10 +27,10 @@ internal sealed class Miscellaneous : ISettingsTab { ImGuiUtil.HelpText(string.Format(Language.Options_Language_Description, Plugin.PluginName)); ImGui.Spacing(); - if (ImGuiUtil.BeginComboVertical(Language.Options_CommandHelpSide_Name, this.Mutable.CommandHelpSide.Name())) { + if (ImGuiUtil.BeginComboVertical(Language.Options_CommandHelpSide_Name, Mutable.CommandHelpSide.Name())) { foreach (var side in Enum.GetValues()) { - if (ImGui.Selectable(side.Name(), this.Mutable.CommandHelpSide == side)) { - this.Mutable.CommandHelpSide = side; + if (ImGui.Selectable(side.Name(), Mutable.CommandHelpSide == side)) { + Mutable.CommandHelpSide = side; } } @@ -40,10 +40,10 @@ internal sealed class Miscellaneous : ISettingsTab { ImGuiUtil.HelpText(string.Format(Language.Options_CommandHelpSide_Description, Plugin.PluginName)); ImGui.Spacing(); - if (ImGuiUtil.BeginComboVertical(Language.Options_KeybindMode_Name, this.Mutable.KeybindMode.Name())) { + if (ImGuiUtil.BeginComboVertical(Language.Options_KeybindMode_Name, Mutable.KeybindMode.Name())) { foreach (var mode in Enum.GetValues()) { - if (ImGui.Selectable(mode.Name(), this.Mutable.KeybindMode == mode)) { - this.Mutable.KeybindMode = mode; + if (ImGui.Selectable(mode.Name(), Mutable.KeybindMode == mode)) { + Mutable.KeybindMode = mode; } if (ImGui.IsItemHovered()) { @@ -59,7 +59,7 @@ internal sealed class Miscellaneous : ISettingsTab { ImGuiUtil.HelpText(string.Format(Language.Options_KeybindMode_Description, Plugin.PluginName)); ImGui.Spacing(); - ImGui.Checkbox(Language.Options_SortAutoTranslate_Name, ref this.Mutable.SortAutoTranslate); + ImGui.Checkbox(Language.Options_SortAutoTranslate_Name, ref Mutable.SortAutoTranslate); ImGuiUtil.HelpText(Language.Options_SortAutoTranslate_Description); ImGui.Spacing(); } diff --git a/ChatTwo/Ui/SettingsTabs/Tabs.cs b/ChatTwo/Ui/SettingsTabs/Tabs.cs index 711cc54..6c238a7 100755 --- a/ChatTwo/Ui/SettingsTabs/Tabs.cs +++ b/ChatTwo/Ui/SettingsTabs/Tabs.cs @@ -15,8 +15,8 @@ internal sealed class Tabs : ISettingsTab { private int _toOpen = -2; internal Tabs(Plugin plugin, Configuration mutable) { - this.Plugin = plugin; - this.Mutable = mutable; + Plugin = plugin; + Mutable = mutable; } public void Draw(bool changed) { @@ -28,29 +28,29 @@ internal sealed class Tabs : ISettingsTab { if (ImGui.BeginPopup(addTabPopup)) { if (ImGui.Selectable(Language.Options_Tabs_NewTab)) { - this.Mutable.Tabs.Add(new Tab()); + Mutable.Tabs.Add(new Tab()); } ImGui.Separator(); if (ImGui.Selectable(string.Format(Language.Options_Tabs_Preset, Language.Tabs_Presets_General))) { - this.Mutable.Tabs.Add(TabsUtil.VanillaGeneral); + Mutable.Tabs.Add(TabsUtil.VanillaGeneral); } if (ImGui.Selectable(string.Format(Language.Options_Tabs_Preset, Language.Tabs_Presets_Event))) { - this.Mutable.Tabs.Add(TabsUtil.VanillaEvent); + Mutable.Tabs.Add(TabsUtil.VanillaEvent); } ImGui.EndPopup(); } var toRemove = -1; - var doOpens = this._toOpen > -2; - for (var i = 0; i < this.Mutable.Tabs.Count; i++) { - var tab = this.Mutable.Tabs[i]; + var doOpens = _toOpen > -2; + for (var i = 0; i < Mutable.Tabs.Count; i++) { + var tab = Mutable.Tabs[i]; if (doOpens) { - ImGui.SetNextItemOpen(i == this._toOpen); + ImGui.SetNextItemOpen(i == _toOpen); } if (ImGui.TreeNodeEx($"{tab.Name}###tab-{i}")) { @@ -58,21 +58,21 @@ internal sealed class Tabs : ISettingsTab { if (ImGuiUtil.IconButton(FontAwesomeIcon.TrashAlt, tooltip: Language.Options_Tabs_Delete)) { toRemove = i; - this._toOpen = -1; + _toOpen = -1; } ImGui.SameLine(); if (ImGuiUtil.IconButton(FontAwesomeIcon.ArrowUp, tooltip: Language.Options_Tabs_MoveUp) && i > 0) { - (this.Mutable.Tabs[i - 1], this.Mutable.Tabs[i]) = (this.Mutable.Tabs[i], this.Mutable.Tabs[i - 1]); - this._toOpen = i - 1; + (Mutable.Tabs[i - 1], Mutable.Tabs[i]) = (Mutable.Tabs[i], Mutable.Tabs[i - 1]); + _toOpen = i - 1; } ImGui.SameLine(); - if (ImGuiUtil.IconButton(FontAwesomeIcon.ArrowDown, tooltip: Language.Options_Tabs_MoveDown) && i < this.Mutable.Tabs.Count - 1) { - (this.Mutable.Tabs[i + 1], this.Mutable.Tabs[i]) = (this.Mutable.Tabs[i], this.Mutable.Tabs[i + 1]); - this._toOpen = i + 1; + if (ImGuiUtil.IconButton(FontAwesomeIcon.ArrowDown, tooltip: Language.Options_Tabs_MoveDown) && i < Mutable.Tabs.Count - 1) { + (Mutable.Tabs[i + 1], Mutable.Tabs[i]) = (Mutable.Tabs[i], Mutable.Tabs[i + 1]); + _toOpen = i + 1; } ImGui.InputText(Language.Options_Tabs_Name, ref tab.Name, 512, ImGuiInputTextFlags.EnterReturnsTrue); @@ -160,7 +160,7 @@ internal sealed class Tabs : ISettingsTab { ImGui.TreePop(); } - if (this.Plugin.ExtraChat.ChannelNames.Count > 0 && ImGui.TreeNodeEx(Language.Options_Tabs_ExtraChatChannels)) { + if (Plugin.ExtraChat.ChannelNames.Count > 0 && ImGui.TreeNodeEx(Language.Options_Tabs_ExtraChatChannels)) { ImGui.Checkbox(Language.Options_Tabs_ExtraChatAll, ref tab.ExtraChatAll); ImGui.Separator(); @@ -169,7 +169,7 @@ internal sealed class Tabs : ISettingsTab { ImGui.BeginDisabled(); } - foreach (var (id, name) in this.Plugin.ExtraChat.ChannelNames) { + foreach (var (id, name) in Plugin.ExtraChat.ChannelNames) { var enabled = tab.ExtraChatChannels.Contains(id); if (!ImGui.Checkbox($"{name}##ec-{id}", ref enabled)) { continue; @@ -196,11 +196,11 @@ internal sealed class Tabs : ISettingsTab { } if (toRemove > -1) { - this.Mutable.Tabs.RemoveAt(toRemove); + Mutable.Tabs.RemoveAt(toRemove); } if (doOpens) { - this._toOpen = -2; + _toOpen = -2; } } } diff --git a/ChatTwo/Util/AutoTranslate.cs b/ChatTwo/Util/AutoTranslate.cs index 7c85e26..556521e 100644 --- a/ChatTwo/Util/AutoTranslate.cs +++ b/ChatTwo/Util/AutoTranslate.cs @@ -278,7 +278,7 @@ internal class SingleRow : ISelectorPart { public uint Row { get; } public SingleRow(uint row) { - this.Row = row; + Row = row; } } @@ -287,8 +287,8 @@ internal class IndexRange : ISelectorPart { public uint End { get; } public IndexRange(uint start, uint end) { - this.Start = start; - this.End = end; + Start = start; + End = end; } } @@ -299,7 +299,7 @@ internal class ColumnSpecifier : ISelectorPart { public uint Column { get; } public ColumnSpecifier(uint column) { - this.Column = column; + Column = column; } } @@ -310,9 +310,9 @@ internal class AutoTranslateEntry { internal SeString SeString { get; } public AutoTranslateEntry(uint group, uint row, string str, SeString seStr) { - this.Group = group; - this.Row = row; - this.String = str; - this.SeString = seStr; + Group = group; + Row = row; + String = str; + SeString = seStr; } } diff --git a/ChatTwo/Util/Lender.cs b/ChatTwo/Util/Lender.cs index a833683..456f9f4 100755 --- a/ChatTwo/Util/Lender.cs +++ b/ChatTwo/Util/Lender.cs @@ -6,18 +6,18 @@ internal class Lender { private int _counter; internal Lender(Func ctor) { - this._ctor = ctor; + _ctor = ctor; } internal void ResetCounter() { - this._counter = 0; + _counter = 0; } internal T Borrow() { - if (this._items.Count <= this._counter) { - this._items.Add(this._ctor()); + if (_items.Count <= _counter) { + _items.Add(_ctor()); } - return this._items[this._counter++]; + return _items[_counter++]; } } diff --git a/ChatTwo/Util/Payloads.cs b/ChatTwo/Util/Payloads.cs index 06d7028..92311d2 100755 --- a/ChatTwo/Util/Payloads.cs +++ b/ChatTwo/Util/Payloads.cs @@ -8,7 +8,7 @@ internal class PartyFinderPayload : Payload { internal uint Id { get; } internal PartyFinderPayload(uint id) { - this.Id = id; + Id = id; } protected override byte[] EncodeImpl() { @@ -26,7 +26,7 @@ internal class AchievementPayload : Payload { internal uint Id { get; } internal AchievementPayload(uint id) { - this.Id = id; + Id = id; } protected override byte[] EncodeImpl() {