-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMainForm.cs
More file actions
117 lines (105 loc) · 4.72 KB
/
MainForm.cs
File metadata and controls
117 lines (105 loc) · 4.72 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
using System;
using System.IO;
using System.Windows.Forms;
namespace MTSRCDS {
#pragma warning disable IDE0022
public partial class MainForm : Form {
MTLibrary.DictionaryFile ArgumentsFile;
MTLibrary.DictionaryFile SettingsFile;
public MainForm() {
this.InitializeComponent();
this.SettingsFile = new("settings.bin", true);
this.ArgumentsFile = new("arguments.bin", true);
foreach (String arg in this.CBArgument.Items)
if (!this.ArgumentsFile.IsKey(arg)) {
this.ArgumentsFile.Set(arg);
}
}
private void MainForm_Load(Object sender, EventArgs e) {
this.CBArgument.SelectedIndex = 0; this.CBOperation.SelectedIndex = 0;
this.TBWorkingDir.Text = this.SettingsFile.Get("WorkingDirectory");
if (this.TBWorkingDir.Text == String.Empty) {
this.TBWorkingDir.Text = Environment.CurrentDirectory + @"\";
}
this.TBHostname.Text = this.SettingsFile.Get("Hostname");
this.TBLoadingURL.Text = this.SettingsFile.Get("LoadingURL");
}
private void BExit_Click(Object sender, EventArgs e) => this.Close();
private void CBArgument_SelectedIndexChanged(Object sender, EventArgs e) {
if (!this.CBLockAssigner.Checked) {
String selectedArg = this.CBArgument.Text.Trim();
this.TBArgValue.Text = this.ArgumentsFile.Get(selectedArg);
}
}
private void BInterpArg_Click(Object sender, EventArgs e) {
String selectedArg = this.CBArgument.Text.Trim();
String storedArg = this.ArgumentsFile.Get(selectedArg);
String candidateArg = this.TBArgValue.Text.Trim();
if (candidateArg.Equals(storedArg) == false
&& candidateArg.Equals(String.Empty) == false) {
this.ArgumentsFile.Set(selectedArg, candidateArg);
} else {
if (CBLockAssigner.Checked) {
this.ArgumentsFile.Set(selectedArg, String.Empty);
} else {
this.TBArgValue.Text = storedArg;
}
}
}
private void CBLockAssigner_CheckedChanged(Object sender, EventArgs e) {
this.TBArgValue.Enabled = !this.CBLockAssigner.Checked;
}
private void TBLoadingURL_TextChanged(Object sender, EventArgs e) {
this.SettingsFile.Set("LoadingURL", this.TBLoadingURL.Text);
}
private void TBHostname_TextChanged(Object sender, EventArgs e) {
this.SettingsFile.Set("Hostname", this.TBHostname.Text);
}
private void MainForm_FormClosing(Object sender, FormClosingEventArgs e) {
this.ArgumentsFile.Save();
this.SettingsFile.Save();
}
private void TBWorkingDir_TextChanged(Object sender, EventArgs e) {
String currentDir = this.TBWorkingDir.Text;
Boolean isValidDir =
Directory.Exists(currentDir +@"\SteamCMD")
&&
File.Exists(currentDir + @"\SteamCMD\steamcmd.exe");
this.CBWorkspaceValid.Checked = isValidDir;
this.SettingsFile.Set("WorkingDirectory", currentDir);
}
private void CBWorkspaceValid_CheckedChanged(Object sender, EventArgs e) {
this.BOpenLogs.Enabled = this.CBWorkspaceValid.Checked;
this.BAddonMan.Enabled = this.CBWorkspaceValid.Checked;
}
private void BExecute_Click(Object sender, EventArgs e) {
this.ArgumentsFile.Save();
String currentDir = this.TBWorkingDir.Text;
Boolean hasApp = File.Exists(currentDir +@"\srcds.exe");
if (this.CBWorkspaceValid.Checked) {
switch (this.CBOperation.Text) {
case "Update":
// TODO
return;
case "Start":
if (hasApp) {
return;
} else { break; }
case "Stop":
if (hasApp) {
return;
} else { break; }
}
} else {
String title = "Invalid Workspace", msg = "Cannot Execute an invalid workspace." +
"Try Updating the Server first.";
MessageBox.Show(msg, title, MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
}
private void BSendInput_Click(Object sender, EventArgs e) {
String command = this.TBInput.Text.Trim();
this.TBOutput.Text += command + Environment.NewLine;
}
}
#pragma warning restore IDE0022
}