-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAndroidMenu.cs
107 lines (95 loc) · 4.43 KB
/
AndroidMenu.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
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Windows.Forms;
using static CM0102_Starter_Kit.Helper;
namespace CM0102_Starter_Kit {
partial class AndroidMenu : HidableForm {
public AndroidMenu(MainMenu mainMenu) {
this.mainMenu = mainMenu;
this.SuspendLayout();
InitialiseSharedControls("Android Setup Instructions", 270, true);
InitializeComponent();
this.ResumeLayout(false);
this.PerformLayout();
}
protected override List<Button> GetButtons() {
return new List<Button> {
this.generate_files
};
}
private void CopyFolder(string folderName) {
string newFolder = Path.Combine(ExagearFolder, folderName);
if (Directory.Exists(newFolder)) {
Directory.Delete(newFolder, true);
Thread.Sleep(2000);
}
if (!Directory.Exists(newFolder)) {
Directory.CreateDirectory(newFolder);
Thread.Sleep(2000);
string originalFolder = Path.Combine(GameFolder, folderName);
FileInfo[] files = new DirectoryInfo(originalFolder).GetFiles();
if (files.Length > 0) {
foreach (FileInfo file in files) {
File.Copy(file.FullName, Path.Combine(newFolder, file.Name), true);
}
}
}
}
private void GenerateFiles_Click(object sender, EventArgs e) {
ProgressWindow progressWindow = new ProgressWindow("Generating files for Android", 75);
progressWindow.Show();
progressWindow.Refresh();
progressWindow.SetProgressPercentage(0);
Database database = GetCurrentDatabase();
// Copy correct CM exe file across
File.Copy(database.ExeFile, Path.Combine(ExagearFolder, Cm0102Exe), true);
// Copy CM loader exe file across
File.Copy(CmLoader, Path.Combine(ExagearFolder, CmLoaderExe), true);
progressWindow.SetProgressPercentage(5);
// Copy correct CM loader config file across
string androidConfigFile = Path.Combine(ExagearFolder, CmLoaderAndroidConfig);
string configFile = CmLoaderConfig;
bool copyPatchesFolder = false;
if (this.nick_patcher.Checked) {
configFile = CmLoaderCustomConfig;
copyPatchesFolder = true;
}
File.Copy(Path.Combine(GameFolder, configFile), androidConfigFile, true);
progressWindow.SetProgressPercentage(10);
// We need to ensure certain patches are not applied to the Android version, even if they were selected
List<string> defaultLines = GetDefaultConfigFileLines(androidConfigFile, database, true);
WriteConfigFile(defaultLines, androidConfigFile);
progressWindow.SetProgressPercentage(15);
// Only copy Patches folder across if the user wants to use Nick's Patcher - otherwise just create an empty folder
if (copyPatchesFolder) {
CopyFolder(PatchesFolderName);
} else {
string newPatchesFolder = Path.Combine(ExagearFolder, PatchesFolderName);
if (Directory.Exists(newPatchesFolder)) {
Directory.Delete(newPatchesFolder, true);
}
Directory.CreateDirectory(newPatchesFolder);
}
progressWindow.SetProgressPercentage(25);
// Copy generic folders across
CopyFolder(DataFolderName);
progressWindow.SetProgressPercentage(45);
CopyFolder(PicturesFolderName);
progressWindow.SetProgressPercentage(65);
CopyFolder(SoundsFolderName);
progressWindow.SetProgressPercentage(85);
Thread.Sleep(2000);
if (this.android_11.Checked) {
File.Copy(Path.Combine(OptionalPatchesFolder, Android11Patch), Path.Combine(Path.Combine(ExagearFolder, PatchesFolderName), Android11Patch));
}
progressWindow.SetProgressPercentage(100);
progressWindow.Close();
DisplayMessage("Files successfully generated!");
}
private void AndroidMenu_FormClosed(object sender, FormClosedEventArgs e) {
Application.Exit();
}
}
}