blob: 04557928e606686327616a8f7d932668fcd1ca35 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
using Dalamud.Game.Command;
using Dalamud.IoC;
using Dalamud.Plugin;
using Dalamud.Interface.Windowing;
using Dalamud.Plugin.Services;
using Malmstone.Windows;
namespace Malmstone;
public sealed class Plugin : IDalamudPlugin
{
[PluginService] internal static IDalamudPluginInterface PluginInterface { get; private set; } = null!;
[PluginService] internal static ITextureProvider TextureProvider { get; private set; } = null!;
[PluginService] internal static ICommandManager CommandManager { get; private set; } = null!;
private const string CommandName = "/pmalm";
public Configuration Configuration { get; init; }
public readonly WindowSystem WindowSystem = new("Malmstone");
private ConfigWindow ConfigWindow { get; init; }
private MainWindow MainWindow { get; init; }
public Plugin()
{
Configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
ConfigWindow = new ConfigWindow(this);
MainWindow = new MainWindow(this);
WindowSystem.AddWindow(ConfigWindow);
WindowSystem.AddWindow(MainWindow);
CommandManager.AddHandler(CommandName, new CommandInfo(OnCommand)
{
HelpMessage = "Open the Malmstone calculator main window"
});
PluginInterface.UiBuilder.Draw += DrawUI;
PluginInterface.UiBuilder.OpenConfigUi += ToggleConfigUI;
PluginInterface.UiBuilder.OpenMainUi += ToggleMainUI;
}
public void Dispose()
{
WindowSystem.RemoveAllWindows();
ConfigWindow.Dispose();
MainWindow.Dispose();
CommandManager.RemoveHandler(CommandName);
}
private void OnCommand(string command, string args)
{
ToggleMainUI();
}
private void DrawUI() => WindowSystem.Draw();
public void ToggleConfigUI() => ConfigWindow.Toggle();
public void ToggleMainUI() => MainWindow.Toggle();
}
|