-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLauncher.cpp
More file actions
133 lines (104 loc) · 4.88 KB
/
Launcher.cpp
File metadata and controls
133 lines (104 loc) · 4.88 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include <io.h>
#include <stdio.h>
#include <string.h>
#include <ShlObj.h>
#include <chrono>
#include <thread>
#include "ini.h"
using namespace mINI;
using namespace std;
using namespace this_thread; // sleep_for, sleep_until
using namespace chrono; // nanoseconds, system_clock, seconds
bool file_exists(const char* filename) {
return (_access(filename, 0) == 0);
}
void show_title() {
printf("\n");
printf(" ██╗ █████╗ ██╗ ██╗███╗ ██╗ ██████╗██╗ ██╗███████╗██████╗\n");
printf(" ██║ ██╔══██╗██║ ██║████╗ ██║██╔════╝██║ ██║██╔════╝██╔══██╗\n");
printf(" ██║ ███████║██║ ██║██╔██╗ ██║██║ ███████║█████╗ ██████╔╝\n");
printf(" ██║ ██╔══██║██║ ██║██║╚██╗██║██║ ██╔══██║██╔══╝ ██╔══██╗\n");
printf(" ███████╗██║ ██║╚██████╔╝██║ ╚████║╚██████╗██║ ██║███████╗██║ ██║");
printf(" V1.0.5\n");
printf(" ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝");
printf(" 鲸流(@cetaceaqua)\n\n");
}
int main()
{
show_title();
if (!IsUserAnAdmin()) {
printf("启动器必须以管理员身份运行!\n");
system("pause");
return 0;
}
if (!(file_exists((char*)"launcher.ini") && file_exists((char*)"netif.bat"))) {
printf("启动器目录中缺少必要的文件!\n");
system("pause");
return 0;
}
INIFile launcher("launcher.ini");
INIStructure launcher_structure;
launcher.read(launcher_structure);
string& enable_launch_chunithm = launcher_structure["Launcher"]["enableLaunchChunithm"];
string& pause_after_finish = launcher_structure["Launcher"]["pauseAfterFinish"];
string& shadowtenpo_path = launcher_structure["launcher"]["shadowtenpoPath"];
string& shadowtenpo_executable_filename = launcher_structure["launcher"]["shadowtenpoExeFilename"];
string& chunithm_path = launcher_structure["launcher"]["chunithmPath"];
string& chunithm_executable_filename = launcher_structure["launcher"]["chunithmExeFilename"];
if (!file_exists((shadowtenpo_path + "\\" + shadowtenpo_executable_filename).data())) {
printf("联机软件目录中缺少必要的文件!(\n");
system("pause");
return 0;
}
if (!(file_exists((chunithm_path + "\\segatools.ini").data()) && file_exists((chunithm_path + "\\" + chunithm_executable_filename).data()))) {
printf("游戏目录中缺少必要的文件!\n");
system("pause");
return 0;
}
if (file_exists((shadowtenpo_path + "\\segatools-override.ini").data())) {
system(("del /f /q " + shadowtenpo_path + "\\segatools-override.ini").data());
}
system("netif.bat");
system("cls");
show_title();
system(("cd /d " + shadowtenpo_path + " && start " + shadowtenpo_path + "\\" + shadowtenpo_executable_filename).data());
for (int i = 1; i < 11; i++) {
printf("正在等待 segatools-override.ini 生成, 第 %d 次尝试。\n", i);
if (file_exists((shadowtenpo_path + "\\segatools-override.ini").data())) {
break;
}
else {
sleep_for(seconds(3));
}
}
if (!file_exists((shadowtenpo_path + "\\segatools-override.ini").data())) {
printf("等待超时,启动失败!\n");
system("pause");
return 0;
}
INIFile segatools_override((shadowtenpo_path + "\\segatools-override.ini").data());
INIStructure segatools_override_structure;
segatools_override.read(segatools_override_structure);
string& segatools_override_enable = segatools_override_structure["netenv"]["enable"];
string& segatools_override_addrsuffix = segatools_override_structure["netenv"]["addrSuffix"];
string& segatools_override_subnet = segatools_override_structure["keychip"]["subnet"];
INIFile segatools((chunithm_path + "\\segatools.ini").data());
INIStructure segatools_structure;
segatools.read(segatools_structure);
segatools_structure["netenv"]["enable"] = segatools_override_enable;
segatools_structure["netenv"]["addrSuffix"] = segatools_override_addrsuffix;
segatools_structure["keychip"]["subnet"] = segatools_override_subnet;
segatools.write(segatools_structure);
system(("del /f /q " + shadowtenpo_path + "\\segatools-override.ini").data());
if (enable_launch_chunithm == "1") {
system(("cd /d " + chunithm_path + " && start " + chunithm_path + "\\" + chunithm_executable_filename).data());
printf("已启动游戏!\n");
}
else {
printf("启动器已完成作业!\n");
}
if (pause_after_finish == "1") {
system("pause");
}
return 0;
}