-
Notifications
You must be signed in to change notification settings - Fork 4
/
PlayMenu.cs
89 lines (74 loc) · 2.77 KB
/
PlayMenu.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
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
namespace CM0102_Starter_Kit {
public partial class PlayMenu : Form {
private readonly MainMenu mainMenu;
public PlayMenu(MainMenu mainMenu) {
this.mainMenu = mainMenu;
InitializeComponent();
}
private List<Control> GetButtonsToToggle() {
return new List<Control> {
this.standard_cm,
this.nick_patcher_cm,
this.exit
};
}
private void ShowLoader() {
Helper.ShowLoader(this, this.loader, GetButtonsToToggle());
}
private void HideLoader() {
Helper.HideLoader(this, this.loader, GetButtonsToToggle());
}
private void LaunchGame(string playGameExe, Boolean usesStubProcess) {
ShowLoader();
ProcessStartInfo playPsi = new ProcessStartInfo {
FileName = playGameExe,
UseShellExecute = false
};
Process playProcess = Process.Start(playPsi);
playProcess.WaitForExit();
playProcess.Close();
if (usesStubProcess) {
Process[] mainPlayProcesses = Process.GetProcessesByName("cm0102");
foreach (Process process in mainPlayProcesses) {
process.WaitForExit();
process.Close();
}
}
HideLoader();
}
private void StandardCm_Click(object sender, EventArgs e) {
LaunchGame(Path.Combine(Helper.GameFolder, Helper.GameExe), false);
}
private void NickPatcherCm_Click(object sender, EventArgs e) {
if (Helper.IsPatchInstalled()) {
LaunchGame(Helper.CmLoaderExeFile, true);
} else {
Helper.DisplayMessage(this, "The Official 3.9.68 Patch needs to be installed first!");
}
}
private void Cm93_Click(object sender, EventArgs e) {
LaunchGame(Path.Combine(Helper.GameFolder, "cm93.exe"), false);
}
private void BackButton_Click(object sender, EventArgs e) {
Helper.ShowNewScreen(this, mainMenu);
}
private void LeftArrow_Click(object sender, EventArgs e) {
Helper.ShowNewScreen(this, mainMenu);
}
private void Exit_Click(object sender, EventArgs e) {
mainMenu.Close();
}
private void Loader_Paint(object sender, PaintEventArgs e) {
Helper.RenderLoader(this, e);
}
private void PlayMenu_FormClosing(object sender, FormClosingEventArgs e) {
e.Cancel = true;
Exit_Click(sender, e);
}
}
}