-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
executable file
·187 lines (179 loc) · 6.09 KB
/
main.cpp
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#include<bits/stdc++.h>
#include"sonolus/sonolus.h"
using namespace std;
const string dist = "./dist";
#include"engine/engine.cpp"
vector<string> explode(const char* seperator, const char* source) {
string src = source; vector<string> res;
while (src.find(seperator) != string::npos) {
int wh = src.find(seperator);
res.push_back(src.substr(0, src.find(seperator)));
src = src.substr(wh + string(seperator).size());
} res.push_back(src);
return res;
}
string readFile(string path) {
ifstream fin(path);
fin.seekg(0, ios::end);
int len = fin.tellg();
if (len == -1) {
cout << "No such file or directory: \"" << path << "\"" << endl;
exit(1);
} fin.seekg(0, ios::beg);
char* buffer = new char[len];
fin.read(buffer, len);
fin.close(); return string(buffer, len);
}
#include"convert.h"
void helpText(int argc, char** argv) {
cout << "Usage: " << endl;
cout << endl;
cout << "Create Engine Scripts: " << endl;
#ifdef play
cout << " EngineConfig & EnginePlayData: " << argv[0] << endl;
#elif tutorial
cout << " EngineConfig & EngineTutorialData: " << argv[0] << endl;
#elif preview
cout << " EngineConfig & EnginePreviewData: " << argv[0] << endl;
#elif watch
cout << " EngineConfig & EngineWatchData: " << argv[0] << endl;
#endif
cout << "Chart Convertor: " << endl;
cout << " Sirius TXT -> Sonolus LevelData: " << argv[0] << " txt2data <txt> <chart_info> <data>" << endl;
cout << " Ched SUS -> Sirius TXT: " << argv[0] << " sus2txt <sus> <txt>" << endl;
cout << " Ched SUS -> Sonolus LevelData: " << argv[0] << " sus2data <sus> <music_config> <data>" << endl;
exit(1);
}
int main(int argc, char** argv) {
// 谱面转换测试
if (argc >= 2) {
if (string(argv[1]) == "txt2data") {
if (argc != 5) helpText(argc, argv);
string info = readFile(argv[3]); string chart = readFile(argv[2]);
double chartOffset = fromMusicInfo(info);
string LevelData = fromSirius(chart, chartOffset);
cout << "Compressing..." << endl;
buffer data = compress_gzip(LevelData, 9);
cout << "Compress Finished." << endl;
ofstream fout(argv[4]);
for (int i = 0; i < data.size(); i++) fout << data.v[i];
fout.close();
return 0;
} else if (string(argv[1]) == "sus2txt") {
if (argc != 4) helpText(argc, argv);
string sus = readFile(argv[2]);
string txt = fromSUS(sus);
ofstream fout(argv[3]);
fout << txt; fout.close();
return 0;
} else if (string(argv[1]) == "sus2data") {
if (argc != 5) helpText(argc, argv);
string info = readFile(argv[3]); string chart = readFile(argv[2]);
double chartOffset = fromMusicInfo(info);
string LevelData = fromSirius(fromSUS(chart), chartOffset);
cout << "Compressing..." << endl;
buffer data = compress_gzip(LevelData, 9);
cout << "Compress Finished." << endl;
ofstream fout(argv[4]);
for (int i = 0; i < data.size(); i++) fout << data.v[i];
fout.close();
return 0;
} else helpText(argc, argv);
}
engineConfiguration.ui = configurationUI;
#ifdef play
buffer data, configuration;
build<
// Replace with your archetypes here
Initialization,
InputManager,
Stage,
NormalNote,
CriticalNote,
FlickNote,
SiriusHoldStart,
SiriusCriticalHoldStart,
SiriusScratchHoldStart,
SiriusCriticalScratchHoldStart,
SiriusHoldEighth,
SiriusSound,
SiriusHoldEnd,
SiriusScratchHoldEnd,
SiriusNontailHoldEnd,
SiriusNontailScratchHoldEnd,
SyncLine,
SplitLine,
SiriusHiSpeed
>(configuration, data);
ofstream fout((dist + "/EngineConfiguration"));
for (int i = 0; i < configuration.size(); i++) fout << configuration.v[i];
fout.close(); fout.open((dist + "/EngineData"));
// ofstream fout((dist + "/EngineData"));
for (int i = 0; i < data.size(); i++) fout << data.v[i];
// #elif tutorial
// buffer data, configuration;
// build(configuration, data);
// ofstream fout((dist + "/EngineConfiguration"));
// for (int i = 0; i < configuration.size(); i++) fout << configuration.v[i];
// fout.close(); fout.open((dist + "/EngineTutorialData"));
// for (int i = 0; i < data.size(); i++) fout << data.v[i];
#elif preview
buffer data, configuration;
build<
// Replace with your archetypes here
Initialization,
Stage,
NormalNote,
CriticalNote,
FlickNote,
SiriusHoldStart,
SiriusHoldEighth,
SiriusCriticalHoldStart,
SiriusScratchHoldStart,
SiriusCriticalScratchHoldStart,
SiriusSound,
SiriusHoldEnd,
SiriusScratchHoldEnd,
SiriusNontailHoldEnd,
SiriusNontailScratchHoldEnd,
SyncLine,
SplitLine,
SiriusHiSpeed
>(configuration, data);
ofstream fout((dist + "/EngineConfiguration"));
for (int i = 0; i < configuration.size(); i++) fout << configuration.v[i];
fout.close(); fout.open((dist + "/EnginePreviewData"));
for (int i = 0; i < data.size(); i++) fout << data.v[i];
#elif watch
buffer data, configuration;
build<
// Replace with your archetypes here
Initialization,
Stage,
UpdateJudgment,
NormalNote,
CriticalNote,
FlickNote,
SiriusHoldStart,
SiriusCriticalHoldStart,
SiriusScratchHoldStart,
SiriusCriticalScratchHoldStart,
SiriusHoldEighth,
SiriusSound,
SiriusHoldEnd,
SiriusScratchHoldEnd,
SiriusNontailHoldEnd,
SiriusNontailScratchHoldEnd,
SyncLine,
SplitLine
>(configuration, data);
ofstream fout((dist + "/EngineConfiguration"));
for (int i = 0; i < configuration.size(); i++) fout << configuration.v[i];
fout.close(); fout.open((dist + "/EngineWatchData"));
for (int i = 0; i < data.size(); i++) fout << data.v[i];
#endif
// 生成 Skin
packSkin(dist + "/SkinTexture", dist + "/SkinData");
// 生成 Effect
packEffect(dist + "/EffectAudio", dist + "/EffectData");
}