mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Implement service locator
This commit is contained in:
parent
06b1163a52
commit
ff1d7f2829
101 changed files with 1614 additions and 1436 deletions
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
using Dalamud.Game.Command;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using Dalamud.Logging;
|
||||
using Dalamud.Plugin;
|
||||
|
|
@ -14,7 +14,8 @@ namespace Dalamud.CorePlugin
|
|||
public sealed class PluginImpl : IDalamudPlugin
|
||||
{
|
||||
private readonly WindowSystem windowSystem = new("Dalamud.CorePlugin");
|
||||
private Localization localizationManager;
|
||||
|
||||
// private Localization localizationManager;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string Name => "Dalamud.CorePlugin";
|
||||
|
|
@ -29,16 +30,16 @@ namespace Dalamud.CorePlugin
|
|||
{
|
||||
try
|
||||
{
|
||||
this.InitLoc();
|
||||
|
||||
// this.InitLoc();
|
||||
this.Interface = pluginInterface;
|
||||
|
||||
this.windowSystem.AddWindow(new PluginWindow(Dalamud.Instance));
|
||||
this.windowSystem.AddWindow(new PluginWindow());
|
||||
|
||||
this.Interface.UiBuilder.Draw += this.OnDraw;
|
||||
this.Interface.UiBuilder.OpenConfigUi += this.OnOpenConfigUi;
|
||||
|
||||
this.Interface.CommandManager.AddHandler("/di", new(this.OnCommand) { HelpMessage = $"Access the {this.Name} plugin." });
|
||||
var commandManager = Service<CommandManager>.Get();
|
||||
commandManager.AddHandler("/di", new(this.OnCommand) { HelpMessage = $"Access the {this.Name} plugin." });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -58,20 +59,23 @@ 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();
|
||||
}
|
||||
}
|
||||
// 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();
|
||||
// }
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// Draw the window system.
|
||||
/// </summary>
|
||||
private void OnDraw()
|
||||
{
|
||||
try
|
||||
|
|
|
|||
|
|
@ -8,21 +8,16 @@ using ImGuiNET;
|
|||
namespace Dalamud.CorePlugin
|
||||
{
|
||||
/// <summary>
|
||||
/// Class responsible for drawing the plugin installer.
|
||||
/// Class responsible for drawing the main plugin window.
|
||||
/// </summary>
|
||||
internal class PluginWindow : Window, IDisposable
|
||||
{
|
||||
[SuppressMessage("CodeQuality", "IDE0052:Remove unread private members", Justification = "This is a placeholder.")]
|
||||
private readonly Dalamud dalamud;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PluginWindow"/> class.
|
||||
/// </summary>
|
||||
/// <param name="dalamud">The Dalamud instance.</param>
|
||||
public PluginWindow(Dalamud dalamud)
|
||||
public PluginWindow()
|
||||
: base("CorePlugin")
|
||||
{
|
||||
this.dalamud = dalamud;
|
||||
this.IsOpen = true;
|
||||
|
||||
this.Size = new Vector2(810, 520);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue