-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfrmOptions.cs
372 lines (296 loc) · 14.4 KB
/
frmOptions.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
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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace SC2Scrapbook
{
public partial class frmOptions : Form
{
public frmOptions()
{
InitializeComponent();
numOutlineSize.Value = Configuration.Instance.OverlayTextOutlineSize;
pnlOutlineColour.BackColor = Configuration.Instance.OverlayTextOutlineColour;
pnlTextColour.BackColor = Configuration.Instance.OverlayTextColour;
chkAdvancedEnabled.Checked = Configuration.Instance.UseAdvancedOptions;
chkIngameBOSelector.Checked = Configuration.Instance.BuildSelectionOverlay;
chkOpponentInfoOverlay.Checked = Configuration.Instance.OpponentInfoOverlay;
if (!string.IsNullOrEmpty(Program.SCDirectory))
{
string[] files = System.IO.Directory.GetFiles(Program.SCDirectory, "*.lnk");
System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"(\w+)\.\d\d\d.*");
foreach (string file in files)
{
System.Text.RegularExpressions.Match match = regex.Match(file);
if (match.Success)
{
if (!txtMySC2Name.Items.Contains(match.Groups[1].Value))
txtMySC2Name.Items.Add(match.Groups[1].Value);
}
}
}
if (!string.IsNullOrWhiteSpace(Configuration.Instance.MySC2Character))
{
foreach (string item in txtMySC2Name.Items)
{
if (item.ToLower() == Configuration.Instance.MySC2Character.ToLower())
{
txtMySC2Name.SelectedItem = item;
break;
}
}
if ((txtMySC2Name.SelectedItem == null) || ((string)txtMySC2Name.SelectedItem).ToLower() != Configuration.Instance.MySC2Character.ToLower())
{
txtMySC2Name.Items.Add(Configuration.Instance.MySC2Character);
txtMySC2Name.SelectedItem = Configuration.Instance.MySC2Character;
}
}
txtMySC2Name.SelectedItem = Configuration.Instance.MySC2Character;
chkUseRandomBuild.Checked = Configuration.Instance.SelectRandomBuild;
chkAllowVsX.Checked = Configuration.Instance.AllowVsXBuilds;
grpAdvancedOpponentInfo.Enabled = chkAdvancedEnabled.Checked;
numOverlayClose.Value = Configuration.Instance.OpponentInfoOverlayTimeout;
numImageScale.Value = Configuration.Instance.OverlayImageScale;
txtOverlayHotkey.Text = "";
if (Configuration.Instance.ToggleOverlayKey != Keys.None)
{
if (Configuration.Instance.ToggleOverlayModifier != Keys.None)
{
if ((Configuration.Instance.ToggleOverlayModifier & System.Windows.Forms.Keys.Control) == System.Windows.Forms.Keys.Control)
txtOverlayHotkey.Text += "CTRL + ";
if ((Configuration.Instance.ToggleOverlayModifier & System.Windows.Forms.Keys.Alt) == System.Windows.Forms.Keys.Alt)
txtOverlayHotkey.Text += "ALT + ";
if ((Configuration.Instance.ToggleOverlayModifier & System.Windows.Forms.Keys.Shift) == System.Windows.Forms.Keys.Shift)
txtOverlayHotkey.Text += "SHIFT + ";
}
txtOverlayHotkey.Text += Configuration.Instance.ToggleOverlayKey.ToString();
}
chkAutoRace.Checked = Configuration.Instance.RememberRace;
}
private void cmdEditTitle_Click(object sender, EventArgs e)
{
FontFamily fontFamily = new FontFamily(Configuration.Instance.OverlayTitleFont);
fontDialog.Font = new Font(fontFamily, Configuration.Instance.OverlayTitleSize);
if (fontDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
Configuration.Instance.OverlayTitleFont = fontDialog.Font.Name;
Configuration.Instance.OverlayTitleSize = fontDialog.Font.SizeInPoints;
}
}
private void cmdEditContentFont_Click(object sender, EventArgs e)
{
FontFamily fontFamily = new FontFamily(Configuration.Instance.OverlayContentFont);
fontDialog.Font = new Font(fontFamily, Configuration.Instance.OverlayContentSize);
if (fontDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
Configuration.Instance.OverlayContentFont = fontDialog.Font.Name;
Configuration.Instance.OverlayContentSize = fontDialog.Font.SizeInPoints;
}
}
private void label1_Click(object sender, EventArgs e)
{
}
private void cmdPreview_Click(object sender, EventArgs e)
{
Program.HideOverlay();
Models.Build.ClearCache();
Models.Build build = new Models.Build("Build Title", "TvP", "Normal Example Content\r\n#Italic Example Content\r\n*Bold Example Content\r\nContent with {minerals}{protoss}{zerg}icons\r\nContent with {protoss_unit_zealot} {terran_unit_marine} units", "");
frmBuildOverlay overlay = new frmBuildOverlay(build);
overlay.Show();
}
private void cmdExit_Click(object sender, EventArgs e)
{
if (chkAdvancedEnabled.Checked)
{
if (string.IsNullOrWhiteSpace(txtMySC2Name.Text))
{
if (MessageBox.Show("You have enabled advanced options but have not specified a character name. Advanced options will be disabled if you continue.", "Oh, you baddie.", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) != System.Windows.Forms.DialogResult.OK)
return;
chkAdvancedEnabled.Checked = false;
}
}
Models.Build.ClearCache();
Program.HideBuildSelection();
Program.SaveConfigurationXML();
Close();
}
private void pnlTextColour_Paint(object sender, PaintEventArgs e)
{
}
private void pnlTextColour_Click(object sender, EventArgs e)
{
colorDialog.Color = Configuration.Instance.OverlayTextColour;
if (colorDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
Configuration.Instance.OverlayTextColour = colorDialog.Color;
pnlTextColour.BackColor = colorDialog.Color;
}
}
private void pnlOutlineColour_Click(object sender, EventArgs e)
{
colorDialog.Color = Configuration.Instance.OverlayTextOutlineColour;
if (colorDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
Configuration.Instance.OverlayTextOutlineColour = colorDialog.Color;
pnlOutlineColour.BackColor = colorDialog.Color;
}
}
private void numOutlineSize_ValueChanged(object sender, EventArgs e)
{
Configuration.Instance.OverlayTextOutlineSize = (int)numOutlineSize.Value;
}
private void chkAdvancedEnabled_CheckedChanged(object sender, EventArgs e)
{
if (this.Visible)
{
if (chkAdvancedEnabled.Checked)
{
if (MessageBox.Show(@"Warning!
These options directly interface with the StarCraft II process.
No data is gathered from the game client except for the IDs of the players currently in game. Overlay data is harvested from the Battle.net website.
Other applications such as StarInfo for JTV and SC2 XSplit Screen Switcher (used by many pros) gather the same data. Although the many users of these applications do not face repercussions for doing so, it is still against the SC2 EULA and Blizzard can detect and ban their usage at any time if they deem it necessary.
Do you want to continue?", "Advanced Goodness.", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.No)
{
chkAdvancedEnabled.Checked = false;
return;
}
}
grpAdvancedOpponentInfo.Enabled = chkAdvancedEnabled.Checked;
if (!chkAdvancedEnabled.Checked)
{
chkIngameBOSelector.Checked = false;
chkOpponentInfoOverlay.Checked = false;
Program.KillSC2InteractionThread();
}
else
{
Program.StartSC2InteractionThread();
}
Configuration.Instance.UseAdvancedOptions = chkAdvancedEnabled.Checked;
Configuration.Instance.BuildSelectionOverlay = chkIngameBOSelector.Checked;
Configuration.Instance.OpponentInfoOverlay = chkOpponentInfoOverlay.Checked;
Configuration.Instance.SelectRandomBuild = chkUseRandomBuild.Checked;
Configuration.Instance.AllowVsXBuilds = chkAllowVsX.Checked;
}
}
private void chkOpponentInfoOverlay_CheckedChanged(object sender, EventArgs e)
{
Configuration.Instance.OpponentInfoOverlay = chkOpponentInfoOverlay.Checked;
}
private void chkIngameBOSelector_CheckedChanged(object sender, EventArgs e)
{
Configuration.Instance.BuildSelectionOverlay = chkIngameBOSelector.Checked;
if (!chkIngameBOSelector.Checked)
{
chkUseRandomBuild.Checked = false;
chkUseRandomBuild.Enabled = false;
chkAllowVsX.Checked = false;
chkAllowVsX.Enabled = false;
chkAutoRace.Enabled = false;
chkAutoRace.Checked = false;
}
else
{
chkUseRandomBuild.Enabled = true;
chkAllowVsX.Enabled = true;
chkAutoRace.Enabled = true;
}
}
private void frmOverlayOptions_Load(object sender, EventArgs e)
{
}
private void txtMySC2Name_TextChanged(object sender, EventArgs e)
{
Configuration.Instance.MySC2Character = txtMySC2Name.Text;
}
private void chkUseRandomBuild_CheckedChanged(object sender, EventArgs e)
{
Configuration.Instance.SelectRandomBuild = chkUseRandomBuild.Checked;
}
private void chkAllowVsX_CheckedChanged(object sender, EventArgs e)
{
Configuration.Instance.AllowVsXBuilds = chkAllowVsX.Checked;
}
private void llNameHelp_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
MessageBox.Show("Your SC2 account name is required to identify which player is the opponent.", "WHO ARE YA?", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void numOverlayClose_ValueChanged(object sender, EventArgs e)
{
Configuration.Instance.OpponentInfoOverlayTimeout = (int)numOverlayClose.Value;
}
private void numImageScale_ValueChanged(object sender, EventArgs e)
{
Configuration.Instance.OverlayImageScale = (int)numImageScale.Value;
}
private void txtOverlayHotkey_KeyDown(object sender, KeyEventArgs e)
{
Configuration.Instance.ToggleOverlayKey = Keys.None;
Configuration.Instance.ToggleOverlayModifier = Keys.None;
bool onlyModifier = false;
txtOverlayHotkey.Text = "";
//if ((e.KeyCode & Keys.ControlKey) == Keys.ControlKey)
if (e.KeyCode == Keys.ControlKey)
{
txtOverlayHotkey.Text += "CTRL + ";
if (e.Alt)
txtOverlayHotkey.Text += "ALT + ";
if (e.Shift)
txtOverlayHotkey.Text += "SHIFT + ";
onlyModifier = true;
}
//if ((e.KeyCode & Keys.Alt) == Keys.Alt)
if (e.KeyCode == Keys.Menu)
{
if (e.Control)
txtOverlayHotkey.Text += "CTRL + ";
txtOverlayHotkey.Text += "ALT + ";
if (e.Shift)
txtOverlayHotkey.Text += "SHIFT + ";
onlyModifier = true;
}
if (e.KeyCode == Keys.ShiftKey)
{
if (e.Control)
txtOverlayHotkey.Text += "CTRL + ";
if (e.Alt)
txtOverlayHotkey.Text += "ALT + ";
txtOverlayHotkey.Text += "SHIFT + ";
onlyModifier = true;
}
//if ((e.KeyCode & Keys.Menu) == Keys.Menu)
//{
// txtOverlayHotkey.Text += "ALT + ";
// onlyModifier = true;
//}
if (onlyModifier)
return;
txtOverlayHotkey.Text = "";
if (e.Control)
txtOverlayHotkey.Text += "CTRL + ";
if (e.Alt)
txtOverlayHotkey.Text += "ALT + ";
if (e.Shift)
txtOverlayHotkey.Text += "SHIFT + ";
txtOverlayHotkey.Text = string.Format("{0}{1}", txtOverlayHotkey.Text, e.KeyCode.ToString().ToUpper());
Configuration.Instance.ToggleOverlayKey = e.KeyCode;
Configuration.Instance.ToggleOverlayModifier = e.Modifiers;
}
private void txtOverlayHotkey_KeyUp(object sender, KeyEventArgs e)
{
if (Configuration.Instance.ToggleOverlayKey == Keys.None)
txtOverlayHotkey.Text = "";
}
private void txtOverlayHotkey_TextChanged(object sender, EventArgs e)
{
}
private void chkAutoRace_CheckedChanged(object sender, EventArgs e)
{
Configuration.Instance.RememberRace = chkAutoRace.Checked;
}
}
}