From 1e9e3b3f16b2e9bccea99ed4b4bb90074b62551d Mon Sep 17 00:00:00 2001 From: Raymond Date: Tue, 24 Aug 2021 22:00:51 -0400 Subject: [PATCH 1/7] Formatting --- Dalamud/EntryPoint.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dalamud/EntryPoint.cs b/Dalamud/EntryPoint.cs index 445d4bcac..775937a75 100644 --- a/Dalamud/EntryPoint.cs +++ b/Dalamud/EntryPoint.cs @@ -198,8 +198,7 @@ namespace Dalamud var info = "Further information could not be obtained"; if (ex.TargetSite != null && ex.TargetSite.DeclaringType != null) { - info = - $"{ex.TargetSite.DeclaringType.Assembly.GetName().Name}, {ex.TargetSite.DeclaringType.FullName}::{ex.TargetSite.Name}"; + info = $"{ex.TargetSite.DeclaringType.Assembly.GetName().Name}, {ex.TargetSite.DeclaringType.FullName}::{ex.TargetSite.Name}"; } const MessageBoxType flags = NativeFunctions.MessageBoxType.YesNo | NativeFunctions.MessageBoxType.IconError | NativeFunctions.MessageBoxType.SystemModal; From d457726100e85dfbf9688b86a52dd8ba4416e754 Mon Sep 17 00:00:00 2001 From: Raymond Date: Tue, 24 Aug 2021 22:59:32 -0400 Subject: [PATCH 2/7] Formatting --- Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs index 4ca59b8e9..74a6afc51 100644 --- a/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs +++ b/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs @@ -41,8 +41,7 @@ namespace Dalamud.Interface.Internal.Windows private const int PluginIconHeight = 512; // TODO: Change back to master after release - private const string MainRepoImageUrl = - "https://raw.githubusercontent.com/goatcorp/DalamudPlugins/api4/{0}/{1}/images/{2}"; + private const string MainRepoImageUrl = "https://raw.githubusercontent.com/goatcorp/DalamudPlugins/api4/{0}/{1}/images/{2}"; private static readonly ModuleLog Log = new("PLUGINW"); From e21f71be442dd7766e08892b4a795835641bc582 Mon Sep 17 00:00:00 2001 From: Raymond Date: Wed, 25 Aug 2021 10:24:34 -0400 Subject: [PATCH 3/7] Add nullable check on event invoke --- Dalamud/Plugin/Internal/PluginManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dalamud/Plugin/Internal/PluginManager.cs b/Dalamud/Plugin/Internal/PluginManager.cs index ca7c69fa2..d1d168d46 100644 --- a/Dalamud/Plugin/Internal/PluginManager.cs +++ b/Dalamud/Plugin/Internal/PluginManager.cs @@ -957,7 +957,7 @@ namespace Dalamud.Plugin.Internal { this.AvailablePlugins = ImmutableList.CreateRange(this.availablePlugins); this.UpdatablePlugins = ImmutableList.CreateRange(this.updatablePlugins); - this.OnAvailablePluginsChanged.Invoke(); + this.OnAvailablePluginsChanged?.Invoke(); } catch (Exception ex) { @@ -973,7 +973,7 @@ namespace Dalamud.Plugin.Internal { this.InstalledPlugins = ImmutableList.CreateRange(this.installedPlugins); this.UpdatablePlugins = ImmutableList.CreateRange(this.updatablePlugins); - this.OnInstalledPluginsChanged.Invoke(); + this.OnInstalledPluginsChanged?.Invoke(); } catch (Exception ex) { From a81681834c2531b83e7ee5ff0f049db4455c6d8b Mon Sep 17 00:00:00 2001 From: Raymond Date: Thu, 26 Aug 2021 09:43:52 -0400 Subject: [PATCH 4/7] Update CorePlugin --- Dalamud.CorePlugin/PluginImpl.cs | 60 ++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/Dalamud.CorePlugin/PluginImpl.cs b/Dalamud.CorePlugin/PluginImpl.cs index 722c3d7b9..c3a9694e6 100644 --- a/Dalamud.CorePlugin/PluginImpl.cs +++ b/Dalamud.CorePlugin/PluginImpl.cs @@ -1,11 +1,12 @@ using System; +using System.IO; +using Dalamud.Configuration.Internal; using Dalamud.Game.Command; -using Dalamud.Game.Gui; using Dalamud.Interface.Windowing; -using Dalamud.IoC; using Dalamud.Logging; using Dalamud.Plugin; +using Dalamud.Utility; namespace Dalamud.CorePlugin { @@ -13,20 +14,27 @@ namespace Dalamud.CorePlugin /// This class is a a plugin testbed for developing new Dalamud features with easy access to Dalamud itself. /// Be careful to not commit anything extra. /// + /// + /// ██████╗ ███████╗ █████╗ ██████╗ ████████╗██╗ ██╗██╗███████╗ + /// ██╔══██╗██╔════╝██╔══██╗██╔══██╗ ╚══██╔══╝██║ ██║██║██╔════╝ + /// ██████╔╝█████╗ ███████║██║ ██║ ██║ ███████║██║███████╗ + /// ██╔══██╗██╔══╝ ██╔══██║██║ ██║ ██║ ██╔══██║██║╚════██║ + /// ██║ ██║███████╗██║ ██║██████╔╝ ██║ ██║ ██║██║███████║ + /// ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝ ╚═╝╚═╝╚══════╝ + /// CorePlugin should not be used as a base for new plugins. Use this instead https://github.com/goatcorp/SamplePlugin. + /// While it may have similarities, it is compiled with access to Dalamud internals, which may cause confusion when + /// some things work and others don't in normal operations. + /// public sealed class PluginImpl : IDalamudPlugin { private readonly WindowSystem windowSystem = new("Dalamud.CorePlugin"); - - // private Localization localizationManager; - - [PluginService] - public static CommandManager CmdManager { get; private set; } + private Localization localization; /// /// Initializes a new instance of the class. /// /// Dalamud plugin interface. - public PluginImpl(DalamudPluginInterface pluginInterface, ChatGui chatGui) + public PluginImpl(DalamudPluginInterface pluginInterface) { try { @@ -38,7 +46,7 @@ namespace Dalamud.CorePlugin this.Interface.UiBuilder.Draw += this.OnDraw; this.Interface.UiBuilder.OpenConfigUi += this.OnOpenConfigUi; - CmdManager.AddHandler("/coreplug", new(this.OnCommand) { HelpMessage = $"Access the {this.Name} plugin." }); + Service.Get().AddHandler("/coreplug", new(this.OnCommand) { HelpMessage = $"Access the {this.Name} plugin." }); PluginLog.Information("CorePlugin ctor!"); } @@ -59,7 +67,7 @@ namespace Dalamud.CorePlugin /// public void Dispose() { - CmdManager.RemoveHandler("/coreplug"); + Service.Get().RemoveHandler("/coreplug"); this.Interface.UiBuilder.Draw -= this.OnDraw; @@ -68,19 +76,24 @@ namespace Dalamud.CorePlugin this.Interface.Dispose(); } - // private void InitLoc() - // { - // // CheapLoc needs to be reinitialized here because it tracks the setup by assembly name. New assembly, new setup. - // this.localizationManager = new Localization(Path.Combine(Dalamud.Instance.AssetDirectory.FullName, "UIRes", "loc", "dalamud"), "dalamud_"); - // if (!string.IsNullOrEmpty(Dalamud.Instance.Configuration.LanguageOverride)) - // { - // this.localizationManager.SetupWithLangCode(Dalamud.Instance.Configuration.LanguageOverride); - // } - // else - // { - // this.localizationManager.SetupWithUiCulture(); - // } - // } + /// + /// CheapLoc needs to be reinitialized here because it tracks the setup by assembly name. New assembly, new setup. + /// + public void InitLoc() + { + var dalamud = Service.Get(); + var dalamudConfig = Service.Get(); + + this.localization = new Localization(Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "loc", "dalamud"), "dalamud_"); + if (!dalamudConfig.LanguageOverride.IsNullOrEmpty()) + { + this.localization.SetupWithLangCode(dalamudConfig.LanguageOverride); + } + else + { + this.localization.SetupWithUiCulture(); + } + } /// /// Draw the window system. @@ -100,6 +113,7 @@ namespace Dalamud.CorePlugin private void OnCommand(string command, string args) { PluginLog.Information("Command called!"); + // this.window.IsOpen = true; } From a6f351ad36067f7cc4652e1392a678708a156bf9 Mon Sep 17 00:00:00 2001 From: Raymond Date: Fri, 27 Aug 2021 08:58:23 -0400 Subject: [PATCH 5/7] Bump client structs again --- lib/FFXIVClientStructs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/FFXIVClientStructs b/lib/FFXIVClientStructs index 47802afd0..dbc0bcfb0 160000 --- a/lib/FFXIVClientStructs +++ b/lib/FFXIVClientStructs @@ -1 +1 @@ -Subproject commit 47802afd09afe2cf3bd4c92bedc433c8a5bb9ab3 +Subproject commit dbc0bcfb01e32a1b53986ecf9e56f594731b1ea5 From 5f8e309bd64cb9261870e7f22dbbda29b5766fd8 Mon Sep 17 00:00:00 2001 From: Raymond Date: Fri, 27 Aug 2021 08:58:44 -0400 Subject: [PATCH 6/7] Fix target --- Dalamud/Game/ClientState/Objects/SubKinds/BattleNpc.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dalamud/Game/ClientState/Objects/SubKinds/BattleNpc.cs b/Dalamud/Game/ClientState/Objects/SubKinds/BattleNpc.cs index 611a00f8d..42bf16f15 100644 --- a/Dalamud/Game/ClientState/Objects/SubKinds/BattleNpc.cs +++ b/Dalamud/Game/ClientState/Objects/SubKinds/BattleNpc.cs @@ -25,6 +25,6 @@ namespace Dalamud.Game.ClientState.Objects.Types public BattleNpcSubKind BattleNpcKind => (BattleNpcSubKind)this.Struct->Character.GameObject.SubKind; /// - public override uint TargetObjectId => this.Struct->BattleNpcTargetObjectId; + public override uint TargetObjectId => this.Struct->Character.TargetObjectID; } } From 606b910db6acc7c4acaab9e34879b8d25a0738be Mon Sep 17 00:00:00 2001 From: Raymond Date: Fri, 27 Aug 2021 08:01:17 -0400 Subject: [PATCH 7/7] Simplify interpolation --- Dalamud/Game/ClientState/Objects/Types/GameObject.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dalamud/Game/ClientState/Objects/Types/GameObject.cs b/Dalamud/Game/ClientState/Objects/Types/GameObject.cs index da4794109..6cd84e92b 100644 --- a/Dalamud/Game/ClientState/Objects/Types/GameObject.cs +++ b/Dalamud/Game/ClientState/Objects/Types/GameObject.cs @@ -170,6 +170,6 @@ namespace Dalamud.Game.ClientState.Objects.Types private protected FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* Struct => (FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)this.Address; /// - public override string ToString() => $"{this.ObjectId:X}({this.Name.TextValue} - {this.ObjectKind.ToString()}) at {this.Address:X}"; + public override string ToString() => $"{this.ObjectId:X}({this.Name.TextValue} - {this.ObjectKind}) at {this.Address:X}"; } }