-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigPanel.cs
More file actions
120 lines (102 loc) · 4.89 KB
/
ConfigPanel.cs
File metadata and controls
120 lines (102 loc) · 4.89 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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ACTOBSPlugin
{
public partial class ConfigPanel : UserControl
{
private readonly PluginConfig config;
private readonly Dictionary<string, string> startRecordingRegexes = new Dictionary<string, string>() {
// FFXIV
{ "FFXIV - ACT Combat Start", @"^(?# FFXIV - ACT Combat Start)(?<type>260)\|(?<timestamp>[^|]*)\|(?<inACTCombat>1)\|" },
{ "FFXIV - Game Combat Start", @"^(?# FFXIV - Game Combat Start)(?<type>260)\|(?<timestamp>[^|]*)\|(?<inACTCombat>[^|]*)\|(?<inGameCombat>1)\|" },
{ "FFXIV - Countdown Start", @"^(?# FFXIV - Countdown Start)(?<type>00)\|(?<timestamp>[^|]*)\|[^|]*\|[^|]*\|Battle commencing in (?<time>[^ ]+) seconds! \((?<player>.*?)\)\|" },
{ "FFXIV - Area Seal", @"^(?# FFXIV - Area Seal)(?<type>00)\|(?<timestamp>[^|]*)\|[^|]*\|[^|]*\|(?<area>.*?) will be sealed off in (?<time>[^ ]+) seconds!" },
{ "FFXIV - Engage", @"^(?# FFXIV - Countdown Start)(?<type>00)\|(?<timestamp>[^|]*)\|[^|]*\|[^|]*\|Engage!\|" },
};
private readonly Dictionary<string, string> stopRecordingRegexes = new Dictionary<string, string>() {
// FFXIV
{ "FFXIV - ACT Combat End", @"^(?# FFXIV - ACT Combat End)(?<type>260)\|(?<timestamp>[^|]*)\|(?<inACTCombat>0)\|" },
{ "FFXIV - Game Combat End", @"^(?# FFXIV - Game Combat End)(?<type>260)\|(?<timestamp>[^|]*)\|(?<inACTCombat>[^|]*)\|(?<inGameCombat>0)\|" },
{ "FFXIV - Wipe", @"^(?# FFXIV - Wipe)(?<type>33)\|(?<timestamp>[^|]*)\|(?<instance>[^|]*)\|(?<command>4000000F)\|" },
{ "FFXIV - Area Unseal", @"(?# FFXIV - Area Unseal)(?<type>00)\|(?<timestamp>[^|]*)\|[^|]*\|[^|]*\|(?<area>.*?) is no longer sealed." },
};
public ConfigPanel(PluginConfig config)
{
this.config = config;
InitializeComponent();
chkEnabled.Checked = config.Enabled;
chkAutoRename.Checked = config.AutoRename;
txtIPPort.Text = config.IPPort;
txtPassword.Text = config.Password;
txtStartRecording.Text = string.Join("\r\n", config.StartRecording);
txtStopRecording.Text = string.Join("\r\n", config.StopRecording);
cmbStartRecording.Items.AddRange(startRecordingRegexes.Keys.ToArray());
cmbStopRecording.Items.AddRange(stopRecordingRegexes.Keys.ToArray());
}
private void ChkEnabled_CheckedChanged(object sender, EventArgs e)
{
config.Enabled = chkEnabled.Checked;
}
private void ChkAutoRename_CheckedChanged(object sender, EventArgs e)
{
config.AutoRename = chkAutoRename.Checked;
}
private void TxtIPPort_TextChanged(object sender, EventArgs e)
{
config.IPPort = txtIPPort.Text;
}
private void TxtPassword_TextChanged(object sender, EventArgs e)
{
config.Password = txtPassword.Text;
}
private void TxtStartRecording_TextChanged(object sender, EventArgs e)
{
config.StartRecording = txtStartRecording.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
}
private void TxtStopRecording_TextChanged(object sender, EventArgs e)
{
config.StopRecording = txtStopRecording.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
}
private void BtnAddStartRecording_Click(object sender, EventArgs e)
{
var key = cmbStartRecording.SelectedItem.ToString();
if (!startRecordingRegexes.TryGetValue(key, out string value))
{
return;
}
if (txtStartRecording.Text.Contains(value))
{
return;
}
txtStartRecording.Text = (txtStartRecording.Text + "\r\n" + value).Trim();
}
private void BtnAddStopRecording_Click(object sender, EventArgs e)
{
var key = cmbStopRecording.SelectedItem.ToString();
if (!stopRecordingRegexes.TryGetValue(key, out string value))
{
return;
}
if (txtStopRecording.Text.Contains(value))
{
return;
}
txtStopRecording.Text = (txtStopRecording.Text + "\r\n" + value).Trim();
}
public void SetStatus(string status)
{
lblStatus.Text = "Status: " + status;
}
public void SetLastFile(string lastFile)
{
lblLastFile.Text = "Last File: " + lastFile;
}
}
}