forked from Violet-CLM/MLLE
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathArguments.cs
More file actions
99 lines (88 loc) · 3.35 KB
/
Copy pathArguments.cs
File metadata and controls
99 lines (88 loc) · 3.35 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
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 MLLE
{
public partial class Arguments : Form
{
static readonly string[] possibleArguments = {
"-spaz", "-lori",
"-easy", "-hard", "-turbo",
"-coop", "-battle", "-capture", "-race", "-treasure",
"-dctf", "-dom", "-fr", "-head", "-jb", "-lrs", "-pest", "-rt", "-tb", "-tlrs", "-xlrs",
"-player 2", "-player 3", "-player 4",
"-server", "-list"
};
readonly Tuple<ComboBox, int, int>[] SimpleBoxes;
TextBox Source;
public Arguments(TextBox source)
{
Source = source;
InitializeComponent();
SimpleBoxes = new Tuple<ComboBox, int, int>[]{
new Tuple<ComboBox, int, int>(characters, 0, 1),
new Tuple<ComboBox, int, int>(difficulties, 2, 4),
new Tuple<ComboBox, int, int>(gamemodes, 5, 20),
new Tuple<ComboBox, int, int>(playernumber, 21, 23)
};
foreach (var simpleBox in SimpleBoxes)
{
simpleBox.Item1.SelectedIndex = 0;
int check = simpleBox.Item2;
int newIndex = 1;
do
{
if (Source.Text.IndexOf(possibleArguments[check], StringComparison.OrdinalIgnoreCase) >= 0)
{
simpleBox.Item1.SelectedIndex = newIndex;
break;
}
++newIndex;
} while (++check <= simpleBox.Item3);
}
if (Source.Text.IndexOf("-server", StringComparison.OrdinalIgnoreCase) >= 0)
{
if (Source.Text.IndexOf("-list", StringComparison.OrdinalIgnoreCase) >= 0)
online.SelectedIndex = 2;
else
online.SelectedIndex = 1;
}
else
online.SelectedIndex = 0;
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
characters.Enabled = online.SelectedIndex == 0;
}
private void gamemodes_SelectedIndexChanged(object sender, EventArgs e)
{
if (online.SelectedIndex == 0 && gamemodes.SelectedIndex >= 6)
online.SelectedIndex = 1;
}
private void ButtonOK_Click(object sender, EventArgs e)
{
string output = Source.Text.ToLower();
foreach (string old in possibleArguments)
output = output.Replace(old, "");
foreach (var simpleBox in SimpleBoxes)
if (simpleBox.Item1.SelectedIndex != 0)
output = possibleArguments[simpleBox.Item1.SelectedIndex + simpleBox.Item2 - 1] + " " + output;
if (online.SelectedIndex == 2)
output = "-list " + output;
if (online.SelectedIndex >= 1)
output = "-server " + output;
Source.Text = System.Text.RegularExpressions.Regex.Replace(output, @"\s+", " ");
Close();
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
Close();
}
}
}