-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cs
More file actions
309 lines (278 loc) · 9.02 KB
/
Main.cs
File metadata and controls
309 lines (278 loc) · 9.02 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
using Advanced_Combat_Tracker;
using FFXIV_ACT_Plugin.Common;
using PlaceKupo.Areas;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using Zodiark.Namazu;
[assembly: AssemblyTitle("库啵标点")]
[assembly: AssemblyDescription("在场地上标明安全点等提示")]
[assembly: AssemblyVersion("1.1.2.0")]
namespace PlaceKupo
{
internal interface IPlaceFunc
{
void AddDelegates();
void RemoveDelegates();
}
public class PlaceKupo : UserControl, IActPluginV1
{
#region 其它变量
private Label statusLabel;
//private static Offsets Offsets;
private IPlaceFunc area;
public static ListBox Logger;
private Panel panel2;
public ListBox LogList;
public static Regex Wipe = new Regex(@"^.{14} 21:.{8}:4000001[026]", RegexOptions.Compiled);
private static Namazu Namazu;
private Button CopyAll;
private Button ClearAll;
#endregion 其它变量
/// <summary>
/// 网络事件
/// </summary>
public static IDataSubscription subscription = Namazu.subscription;
/// <summary>
/// 获取玩家信息等
/// </summary>
public static IDataRepository repository = Namazu.repository;
/// <summary>
/// 存储区域和对应的标点方法
/// </summary>
private Dictionary<uint, Func<IPlaceFunc>> map;
public void InitMap()
{
map = new Dictionary<uint, Func<IPlaceFunc>>
{
//方法请在PlaceKupo.Areas中实现
//要添加新的方法,请按照 {区域ID,() => new 类名()} 的规范添加
//区域ID可在此地址查询: https://github.com/quisquous/cactbot/blob/main/resources/zone_info.js
//另外在安装此插件后切换区域时也会在聊天框显示区域ID
//自定义类请实现IPlaceFunc接口
//例:盛夏农庄
{ 134, () => new ExampleAction() },
#if DEBUG
{ 928, () => new Bunker() },
#endif
{ 917, () => new Bunker() }
};
}
/// <summary>
/// 向鲶鱼精发送指令
/// </summary>
/// <param name="s">一条游戏内指令</param>
public static void SendCommand(string s)
{
try
{
if (Namazu == null) Namazu = Namazu.Instance;
Namazu.SendCommand(s);
}
catch (Exception e)
{
Log(e.ToString());
}
}
/// <summary>
/// 向游戏内写入标点数据
/// </summary>
/// <param name="preset">一套标点</param>
public static void WriteWaymark(Preset preset)
{
try
{
if (Namazu == null) Namazu = Namazu.Instance;
Namazu.WriteWaymark(preset);
}
catch (Exception e)
{
Log(e.ToString());
}
}
/// <summary>
/// 记录一条日志。
/// </summary>
/// <param name="s"></param>
public static void Log(string s)
{
Logger.Items.Add(String.Format("[{0:HH:mm:ss}] ", DateTime.Now) + s);
Logger.SelectedIndex = Logger.Items.Count - 1;
Logger.SelectedIndex = -1;
}
/// <summary>
/// 使用TTS朗读一句文字。
/// </summary>
/// <param name="s"></param>
public static void TTS(string s)
{
ActGlobals.oFormActMain.TTS(s);
Log("TTS: " + s);
}
/// <summary>
/// 写入单个标点
/// </summary>
/// <param name="waymark">标点数据</param>
public static void WriteWaymark(Waymark waymark, int id = -1)
{
try
{
if (Namazu == null) Namazu = Namazu.Instance;
Namazu.WriteWaymark(waymark, id);
}
catch (Exception e)
{
Log(e.ToString());
}
}
/// <summary>
/// 读取游戏内的标点
/// </summary>
/// <returns>游戏内的标点预设</returns>
public static Preset ReadWaymark()
{
try
{
return Namazu.ReadWaymark();
}
catch (Exception e)
{
Log(e.ToString());
return Preset.Reset;
}
}
#region 其它
public PlaceKupo()
{
InitializeComponent();
Logger = LogList;
}
public void DeInitPlugin()
{
if (area != null)
area.RemoveDelegates();
subscription.ZoneChanged -= OnZoneChanged;
statusLabel.Text = "插件已退出";
}
public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
{
pluginScreenSpace.Text = "库啵标点工具";
InitMap();
pluginScreenSpace.Controls.Add(this);
subscription.ProcessChanged += OnProcessChanged;
subscription.ZoneChanged += OnZoneChanged;
statusLabel = pluginStatusText;
statusLabel.Text = "Working :D";
Log("库啵标点已启动");
uint id = repository.GetCurrentTerritoryID();
Log("当前区域ID: " + id.ToString());
if (map.ContainsKey(id))
{
Namazu = Namazu.Instance;
area = map[id]();
area.AddDelegates();
}
}
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PlaceKupo));
this.panel2 = new System.Windows.Forms.Panel();
this.LogList = new System.Windows.Forms.ListBox();
this.CopyAll = new System.Windows.Forms.Button();
this.ClearAll = new System.Windows.Forms.Button();
this.panel2.SuspendLayout();
this.SuspendLayout();
//
// panel2
//
resources.ApplyResources(this.panel2, "panel2");
this.panel2.Controls.Add(this.LogList);
this.panel2.Name = "panel2";
//
// LogList
//
resources.ApplyResources(this.LogList, "LogList");
this.LogList.FormattingEnabled = true;
this.LogList.Name = "LogList";
this.LogList.DoubleClick += new System.EventHandler(this.LogList_DoubleClick);
//
// CopyAll
//
resources.ApplyResources(this.CopyAll, "CopyAll");
this.CopyAll.Name = "CopyAll";
this.CopyAll.UseVisualStyleBackColor = true;
this.CopyAll.Click += new System.EventHandler(this.CopyAll_Click);
//
// ClearAll
//
resources.ApplyResources(this.ClearAll, "ClearAll");
this.ClearAll.Name = "ClearAll";
this.ClearAll.UseVisualStyleBackColor = true;
this.ClearAll.Click += new System.EventHandler(this.ClearAll_Click);
//
// PlaceKupo
//
resources.ApplyResources(this, "$this");
this.Controls.Add(this.ClearAll);
this.Controls.Add(this.CopyAll);
this.Controls.Add(this.panel2);
this.Name = "PlaceKupo";
this.panel2.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
private void OnZoneChanged(uint id, string name)
{
try
{
SendCommand(string.Format("/e {0}:{1}", id, name));
if (area != null)
{
area.RemoveDelegates();
area = null;
}
if (map.ContainsKey(id))
{
area = map[id]();
area.AddDelegates();
}
}
catch (Exception e)
{
Log(e.ToString());
}
}
private void OnProcessChanged(Process _)
{
Namazu = Namazu.Instance;
}
private void Portbox_KeyPress(object sender, KeyPressEventArgs e)
{
if (!Char.IsDigit(e.KeyChar) && e.KeyChar != '\b') e.KeyChar = (char)0;
}
private void Portbox_TextChanged(object sender, EventArgs e)
{
}
private void LogList_DoubleClick(object sender, EventArgs e)
{
Clipboard.SetDataObject(LogList.SelectedItem);
}
private void CopyAll_Click(object sender, EventArgs e)
{
var list = new List<object>();
foreach (var i in LogList.Items)
{
list.Add(i);
}
Clipboard.SetDataObject(string.Join("\n", list));
}
private void ClearAll_Click(object sender, EventArgs e)
{
LogList.Items.Clear();
}
#endregion 其它
}
}