Merge pull request #509 from daemitus/misc

Small misc stuff + client structs bump
This commit is contained in:
goaaats 2021-08-27 23:20:56 +02:00 committed by GitHub
commit 873d0c6305
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 44 additions and 32 deletions

View file

@ -1,11 +1,12 @@
using System; using System;
using System.IO;
using Dalamud.Configuration.Internal;
using Dalamud.Game.Command; using Dalamud.Game.Command;
using Dalamud.Game.Gui;
using Dalamud.Interface.Windowing; using Dalamud.Interface.Windowing;
using Dalamud.IoC;
using Dalamud.Logging; using Dalamud.Logging;
using Dalamud.Plugin; using Dalamud.Plugin;
using Dalamud.Utility;
namespace Dalamud.CorePlugin 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. /// 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. /// Be careful to not commit anything extra.
/// </summary> /// </summary>
/// <remarks>
/// ██████╗ ███████╗ █████╗ ██████╗ ████████╗██╗ ██╗██╗███████╗
/// ██╔══██╗██╔════╝██╔══██╗██╔══██╗ ╚══██╔══╝██║ ██║██║██╔════╝
/// ██████╔╝█████╗ ███████║██║ ██║ ██║ ███████║██║███████╗
/// ██╔══██╗██╔══╝ ██╔══██║██║ ██║ ██║ ██╔══██║██║╚════██║
/// ██║ ██║███████╗██║ ██║██████╔╝ ██║ ██║ ██║██║███████║
/// ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝ ╚═╝╚═╝╚══════╝
/// 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.
/// </remarks>
public sealed class PluginImpl : IDalamudPlugin public sealed class PluginImpl : IDalamudPlugin
{ {
private readonly WindowSystem windowSystem = new("Dalamud.CorePlugin"); private readonly WindowSystem windowSystem = new("Dalamud.CorePlugin");
private Localization localization;
// private Localization localizationManager;
[PluginService]
public static CommandManager CmdManager { get; private set; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="PluginImpl"/> class. /// Initializes a new instance of the <see cref="PluginImpl"/> class.
/// </summary> /// </summary>
/// <param name="pluginInterface">Dalamud plugin interface.</param> /// <param name="pluginInterface">Dalamud plugin interface.</param>
public PluginImpl(DalamudPluginInterface pluginInterface, ChatGui chatGui) public PluginImpl(DalamudPluginInterface pluginInterface)
{ {
try try
{ {
@ -38,7 +46,7 @@ namespace Dalamud.CorePlugin
this.Interface.UiBuilder.Draw += this.OnDraw; this.Interface.UiBuilder.Draw += this.OnDraw;
this.Interface.UiBuilder.OpenConfigUi += this.OnOpenConfigUi; this.Interface.UiBuilder.OpenConfigUi += this.OnOpenConfigUi;
CmdManager.AddHandler("/coreplug", new(this.OnCommand) { HelpMessage = $"Access the {this.Name} plugin." }); Service<CommandManager>.Get().AddHandler("/coreplug", new(this.OnCommand) { HelpMessage = $"Access the {this.Name} plugin." });
PluginLog.Information("CorePlugin ctor!"); PluginLog.Information("CorePlugin ctor!");
} }
@ -59,7 +67,7 @@ namespace Dalamud.CorePlugin
/// <inheritdoc/> /// <inheritdoc/>
public void Dispose() public void Dispose()
{ {
CmdManager.RemoveHandler("/coreplug"); Service<CommandManager>.Get().RemoveHandler("/coreplug");
this.Interface.UiBuilder.Draw -= this.OnDraw; this.Interface.UiBuilder.Draw -= this.OnDraw;
@ -68,19 +76,24 @@ namespace Dalamud.CorePlugin
this.Interface.Dispose(); this.Interface.Dispose();
} }
// private void InitLoc() /// <summary>
// { /// CheapLoc needs to be reinitialized here because it tracks the setup by assembly name. New assembly, new setup.
// // CheapLoc needs to be reinitialized here because it tracks the setup by assembly name. New assembly, new setup. /// </summary>
// this.localizationManager = new Localization(Path.Combine(Dalamud.Instance.AssetDirectory.FullName, "UIRes", "loc", "dalamud"), "dalamud_"); public void InitLoc()
// if (!string.IsNullOrEmpty(Dalamud.Instance.Configuration.LanguageOverride)) {
// { var dalamud = Service<Dalamud>.Get();
// this.localizationManager.SetupWithLangCode(Dalamud.Instance.Configuration.LanguageOverride); var dalamudConfig = Service<DalamudConfiguration>.Get();
// }
// else this.localization = new Localization(Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "loc", "dalamud"), "dalamud_");
// { if (!dalamudConfig.LanguageOverride.IsNullOrEmpty())
// this.localizationManager.SetupWithUiCulture(); {
// } this.localization.SetupWithLangCode(dalamudConfig.LanguageOverride);
// } }
else
{
this.localization.SetupWithUiCulture();
}
}
/// <summary> /// <summary>
/// Draw the window system. /// Draw the window system.
@ -100,6 +113,7 @@ namespace Dalamud.CorePlugin
private void OnCommand(string command, string args) private void OnCommand(string command, string args)
{ {
PluginLog.Information("Command called!"); PluginLog.Information("Command called!");
// this.window.IsOpen = true; // this.window.IsOpen = true;
} }

View file

@ -198,8 +198,7 @@ namespace Dalamud
var info = "Further information could not be obtained"; var info = "Further information could not be obtained";
if (ex.TargetSite != null && ex.TargetSite.DeclaringType != null) if (ex.TargetSite != null && ex.TargetSite.DeclaringType != null)
{ {
info = info = $"{ex.TargetSite.DeclaringType.Assembly.GetName().Name}, {ex.TargetSite.DeclaringType.FullName}::{ex.TargetSite.Name}";
$"{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; const MessageBoxType flags = NativeFunctions.MessageBoxType.YesNo | NativeFunctions.MessageBoxType.IconError | NativeFunctions.MessageBoxType.SystemModal;

View file

@ -25,6 +25,6 @@ namespace Dalamud.Game.ClientState.Objects.Types
public BattleNpcSubKind BattleNpcKind => (BattleNpcSubKind)this.Struct->Character.GameObject.SubKind; public BattleNpcSubKind BattleNpcKind => (BattleNpcSubKind)this.Struct->Character.GameObject.SubKind;
/// <inheritdoc/> /// <inheritdoc/>
public override uint TargetObjectId => this.Struct->BattleNpcTargetObjectId; public override uint TargetObjectId => this.Struct->Character.TargetObjectID;
} }
} }

View file

@ -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; private protected FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* Struct => (FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)this.Address;
/// <inheritdoc/> /// <inheritdoc/>
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}";
} }
} }

View file

@ -41,8 +41,7 @@ namespace Dalamud.Interface.Internal.Windows
private const int PluginIconHeight = 512; private const int PluginIconHeight = 512;
// TODO: Change back to master after release // TODO: Change back to master after release
private const string MainRepoImageUrl = private const string MainRepoImageUrl = "https://raw.githubusercontent.com/goatcorp/DalamudPlugins/api4/{0}/{1}/images/{2}";
"https://raw.githubusercontent.com/goatcorp/DalamudPlugins/api4/{0}/{1}/images/{2}";
private static readonly ModuleLog Log = new("PLUGINW"); private static readonly ModuleLog Log = new("PLUGINW");

View file

@ -958,7 +958,7 @@ namespace Dalamud.Plugin.Internal
{ {
this.AvailablePlugins = ImmutableList.CreateRange(this.availablePlugins); this.AvailablePlugins = ImmutableList.CreateRange(this.availablePlugins);
this.UpdatablePlugins = ImmutableList.CreateRange(this.updatablePlugins); this.UpdatablePlugins = ImmutableList.CreateRange(this.updatablePlugins);
this.OnAvailablePluginsChanged.Invoke(); this.OnAvailablePluginsChanged?.Invoke();
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -974,7 +974,7 @@ namespace Dalamud.Plugin.Internal
{ {
this.InstalledPlugins = ImmutableList.CreateRange(this.installedPlugins); this.InstalledPlugins = ImmutableList.CreateRange(this.installedPlugins);
this.UpdatablePlugins = ImmutableList.CreateRange(this.updatablePlugins); this.UpdatablePlugins = ImmutableList.CreateRange(this.updatablePlugins);
this.OnInstalledPluginsChanged.Invoke(); this.OnInstalledPluginsChanged?.Invoke();
} }
catch (Exception ex) catch (Exception ex)
{ {

@ -1 +1 @@
Subproject commit 47802afd09afe2cf3bd4c92bedc433c8a5bb9ab3 Subproject commit dbc0bcfb01e32a1b53986ecf9e56f594731b1ea5