This repository has been archived by the owner on Feb 11, 2024. It is now read-only.
/
Plugin.cs
108 lines (92 loc) · 3.26 KB
/
Plugin.cs
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
using System;
using Dalamud.Game.ClientState;
using Dalamud.Plugin;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Game.Command;
using Dalamud.Game;
namespace DeepDungeonDex
{
public class Plugin : IDalamudPlugin
{
private DalamudPluginInterface pluginInterface;
private Configuration config;
private PluginUI ui;
private ConfigUI cui;
private GameObject previousTarget;
private ClientState _clientState;
private Condition _condition;
private TargetManager _targetManager;
private Framework _framework;
private CommandManager _commands;
public string Name => "DeepDungeonDex";
public Plugin(
DalamudPluginInterface pluginInterface,
ClientState clientState,
CommandManager commands,
Condition condition,
Framework framework,
//SeStringManager seStringManager,
TargetManager targets)
{
this.pluginInterface = pluginInterface;
this._clientState = clientState;
this._condition = condition;
this._framework = framework;
this._commands = commands;
this._targetManager = targets;
this.config = (Configuration)this.pluginInterface.GetPluginConfig() ?? new Configuration();
this.config.Initialize(this.pluginInterface);
this.ui = new PluginUI(config, clientState);
this.cui = new ConfigUI(config.Opacity, config.IsClickthrough, config.HideRedVulns, config.HideBasedOnJob, config);
this.pluginInterface.UiBuilder.Draw += this.ui.Draw;
this.pluginInterface.UiBuilder.Draw += this.cui.Draw;
this._commands.AddHandler("/pddd", new CommandInfo(OpenConfig)
{
HelpMessage = "DeepDungeonDex config"
});
this._framework.Update += this.GetData;
}
public void OpenConfig(string command, string args)
{
cui.IsVisible = true;
}
public void GetData(Framework framework)
{
if (!this._condition[ConditionFlag.InDeepDungeon])
{
ui.IsVisible = false;
return;
}
GameObject target = _targetManager.Target;
TargetData t = new TargetData();
if (!t.IsValidTarget(target))
{
ui.IsVisible = false;
return;
}
else
{
previousTarget = target;
ui.IsVisible = true;
}
}
#region IDisposable Support
protected virtual void Dispose(bool disposing)
{
if (!disposing) return;
this._commands.RemoveHandler("/pddd");
this.pluginInterface.SavePluginConfig(this.config);
this.pluginInterface.UiBuilder.Draw -= this.ui.Draw;
this.pluginInterface.UiBuilder.Draw -= this.cui.Draw;
this._framework.Update -= this.GetData;
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
}
}