forked from UnknownX7/ReAction
-
Notifications
You must be signed in to change notification settings - Fork 4
/
ReActionEx.cs
77 lines (66 loc) · 2.86 KB
/
ReActionEx.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
using System;
using System.Collections.Generic;
using System.Linq;
using Dalamud.Plugin;
namespace ReActionEx;
public class ReActionEx(IDalamudPluginInterface pluginInterface) : DalamudPlugin<Configuration>(pluginInterface), IDalamudPlugin
{
public static Dictionary<uint, Lumina.Excel.Sheets.Action> actionSheet;
public static Dictionary<uint, Lumina.Excel.Sheets.Action> mountActionsSheet;
protected override void Initialize()
{
Game.Initialize();
PronounManager.Initialize();
actionSheet = DalamudApi.DataManager.GetExcelSheet<Lumina.Excel.Sheets.Action>()?.Where(i => i.ClassJobCategory.RowId > 0 && (i.ActionCategory.RowId <= 4 || i.ActionCategory.RowId == 9 || i.ActionCategory.RowId == 15) && i.RowId > 8).ToDictionary(i => i.RowId, i => i);
mountActionsSheet = DalamudApi.DataManager.GetExcelSheet<Lumina.Excel.Sheets.Action>()?.Where(i => i.ActionCategory.RowId == 12).ToDictionary(i => i.RowId, i => i);
if (actionSheet == null || mountActionsSheet == null)
throw new ApplicationException("Action sheet failed to load!");
}
protected override void ToggleConfig() => PluginUI.IsVisible ^= true;
[PluginCommand("/reaction", HelpMessage = "Opens / closes the config.")]
private void ToggleConfig(string command, string argument) => ToggleConfig();
[PluginCommand("/macroqueue", "/mqueue", HelpMessage = "[on|off] - Toggles (with no argument specified), enables or disables /ac queueing in the current macro.")]
private void OnMacroQueue(string command, string argument)
{
if (!Common.IsMacroRunning)
{
DalamudApi.PrintError("This command requires a macro to be running.");
return;
}
switch (argument)
{
case "on":
Game.queueACCommandPatch.Enable();
break;
case "off":
Game.queueACCommandPatch.Disable();
break;
case "":
if (!Config.EnableMacroQueue) // Bug, users could use two /macroqueue and would expect the second to disable it, but scenario is very unlikely
Game.queueACCommandPatch.Toggle();
break;
default:
DalamudApi.PrintError("Invalid usage.");
break;
}
}
protected override void Update()
{
if (Config.EnableMacroQueue)
{
if (!Game.queueACCommandPatch.IsEnabled && !Common.IsMacroRunning)
Game.queueACCommandPatch.Enable();
}
else
{
if (Game.queueACCommandPatch.IsEnabled && !Common.IsMacroRunning)
Game.queueACCommandPatch.Disable();
}
}
protected override void Draw() => PluginUI.Draw();
protected override void Dispose(bool disposing)
{
if (!disposing) return;
Game.Dispose();
}
}