This repository has been archived by the owner on Mar 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathUI.cs
121 lines (107 loc) · 4.54 KB
/
UI.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
109
110
111
112
113
114
115
116
117
118
119
120
121
using System;
using System.Numerics;
using System.Reflection;
using Dalamud.Interface;
using Dalamud.Interface.Colors;
using ImGuiNET;
namespace SmartCast
{
class UI : IDisposable
{
private SmartCast plugin;
internal bool Visible;
public UI(SmartCast plugin)
{
this.plugin = plugin;
DalamuApi.DalamudApi.PluginInterface.UiBuilder.Draw += UiBuilder_OnBuildUi;
DalamuApi.DalamudApi.PluginInterface.UiBuilder.OpenConfigUi += UiBuilder_OnOpenConfigUi;
}
private void UiBuilder_OnOpenConfigUi()
{
Visible ^= true;
}
private void UiBuilder_OnBuildUi()
{
if (Visible)
{
var cn = (int)DalamuApi.DalamudApi.DataManager.Language == 4;
ImGui.SetNextWindowSize(new Vector2(480, 320), ImGuiCond.FirstUseEver);
if (ImGui.Begin("SmartCast Config", ref Visible))
{
var configChanged =
HelpCheckbox(cn ? "使用地面技能智能施法" : "Ground target actions smart cast", cn ? "当你使用地面目标技能时,将技能施放在当前鼠标位置。" : "When you use ground target actions, cast the action at current mouse cursor position.", ref plugin.config.EnableSmartCast) |
(plugin.config.EnableSmartCast && HelpCheckbox(cn ? "非玩家技能智能施法" : "Use smart cast for non-player ground target actions", cn ? "为非玩家地面目标技能(如坐骑技能、机甲技能、炮击等)使用智能施法。" : "Use smart cast for non-player ground target actions (such as mount actions, war machina actions, cannonfire, etc.).", ref plugin.config.GroundTargetSmartCastForNonPlayerSpell)) |
(plugin.config.EnableSmartCast && HelpCheckbox(cn ? "目标技能智能施法" : "Enable mouseover smart cast", cn ? "对大多数治疗/辅助技能启用鼠标悬停施法。" : "Enable mouseover cast for most healing/support skills.", ref plugin.config.MouseOverFriendly)) |
HelpCheckbox(cn ? "按下技能时下坐骑" : "Auto dismount when using action", cn ? "在骑乘状态按下任一战斗技能时自动下坐骑,不使用按下的技能。" : "Dismount when using any battle action.", ref plugin.config.AutoDismount) |
(plugin.config.AutoDismount && HelpCheckbox(cn ? "下坐骑并使用技能" : "Dismount and do action", cn ? "下坐骑并立即使用按下的技能。" : "Use the action immediately after dismounted.", ref plugin.config.AutoDismountAndCast)) |
HelpCheckbox(cn ? "宏技能队列" : "Queue macro actions", cn ? "将用户宏中通过“/ac”指令施放的技能插入技能队列中。" : "Insert actions cast by \"/ac\" commands into action queue.", ref plugin.config.QueueMacroAction);
if (configChanged)
{
plugin.SavePluginConfig();
}
unsafe
{
ImGui.TextUnformatted($"{(long)plugin.actionManager:X}");
ShowObject(*plugin.actionManager);
}
}
ImGui.End();
}
}
public static void ShowObject(object obj)
{
Type type = obj.GetType();
ImGui.Text(string.Format("Object Dump({0}) for {1}({2})", (object)type.Name, obj, (object)obj.GetHashCode()));
ImGuiHelpers.ScaledDummy(5f);
ImGui.TextColored(ImGuiColors.DalamudOrange, "-> Properties:");
ImGui.Indent();
foreach (PropertyInfo property in type.GetProperties())
{
try
{
ImGui.TextColored(ImGuiColors.DalamudOrange,
string.Format(" {0}: {1:X}", (object)property.Name, property.GetValue(obj)));
}
catch (Exception e)
{
ImGui.TextColored(ImGuiColors.DalamudOrange,
string.Format(" {0}: {1}", (object)property.Name, property.GetValue(obj)));
}
}
ImGui.Unindent();
ImGuiHelpers.ScaledDummy(5f);
ImGui.TextColored(ImGuiColors.HealerGreen, "-> Fields:");
ImGui.Indent();
foreach (FieldInfo field in type.GetFields())
{
try
{
ImGui.TextColored(ImGuiColors.HealerGreen,
string.Format(" {0}: {1:X}", (object)field.Name, field.GetValue(obj)));
}
catch (Exception e)
{
ImGui.TextColored(ImGuiColors.HealerGreen,
string.Format(" {0}: {1}", (object)field.Name, field.GetValue(obj)));
}
}
ImGui.Unindent();
}
private static bool HelpCheckbox(string label, string help, ref bool isChecked)
{
var ret = ImGui.Checkbox(label, ref isChecked);
ImGui.TreePush();
ImGui.PushTextWrapPos();
ImGui.TextUnformatted(help);
ImGui.PopTextWrapPos();
ImGui.TreePop();
ImGui.Spacing();
return ret;
}
public void Dispose()
{
DalamuApi.DalamudApi.PluginInterface.UiBuilder.Draw -= UiBuilder_OnBuildUi;
DalamuApi.DalamudApi.PluginInterface.UiBuilder.OpenConfigUi -= UiBuilder_OnOpenConfigUi;
}
}
}