Skip to content

Commit b8536b4

Browse files
committed
Chart fix module complete
1 parent c9654e4 commit b8536b4

File tree

13 files changed

+745
-138
lines changed

13 files changed

+745
-138
lines changed

Dynamix_chart_width_control/chart_store.cpp

Lines changed: 159 additions & 59 deletions
Large diffs are not rendered by default.

Dynamix_chart_width_control/chart_store.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@
99
#include<sstream>
1010
#include<climits>
1111
#include<map>
12+
#include<set>
1213

1314
using std::vector;
1415
using std::string;
1516
using std::ofstream;
1617
using std::pair;
1718
using std::map;
19+
using std::set;
20+
1821
//added default note type: NULLTP
1922
enum types { NORMAL = 1, CHAIN, HOLD, SUB , NULLTP};
2023
//added default sides type: UNKNOWN
@@ -42,10 +45,19 @@ class chart_store
4245
//now we use map to store the notes, in order to deal with discrete note id
4346
//<note id,note>
4447
map<int, note> m_notes, m_left, m_right;//note list(the key is the note's id)
48+
//hold list and sub list(used for hold-sub checking)
49+
map<int, int> hold_mid, hold_left, hold_right;
50+
set<int> sub_mid, sub_left, sub_right;
51+
//mismatch note list(used for hold-sub autofix)
52+
vector<pair<int, string> > mismatched_notes;
4553

4654
bool to_file(string f);//print to XML
4755
int readfile(string fn);//read XML
4856
string chart_filename;//filename of the chart
57+
void set_barpm(double f) { barpm = f; }
58+
void set_lside(sides x) { ltype = x; }
59+
void set_rside(sides x) { rtype = x; }
60+
4961
private:
5062

5163
string name;//song name

Dynamix_chart_width_control/defs.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include<iomanip>
1010
#include<fstream>
11+
#include<algorithm>
1112
#include<sys/stat.h>
1213
#if defined(_WIN64)||defined(WIN32)||defined(_WIN32)
1314
#include<direct.h>
@@ -17,10 +18,17 @@
1718
#endif
1819

1920
#include<cstdio>
21+
//side change flags
2022
#define MID_CHANGE 0x4
2123
#define LEFT_CHANGE 0x2
2224
#define RIGHT_CHANGE 0x1
2325

26+
//chart read flags
27+
#define BARPM_MISSING 0x1
28+
#define LEFT_SIDE_MISSING 0x2
29+
#define RIGHT_SIDE_MISSING 0x4
30+
#define HOLD_SUB_MISMATCH 0x8
31+
2432
#include "chart_store.h"
2533
#include<string>
2634
using std::string;

Dynamix_chart_width_control/main.cpp

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,109 @@ int main(int argc, char* argv[])
231231
chart_store cs;//store the chart
232232
try {
233233
int fail_read = cs.readfile(filename);//open file
234+
//fixing stage
235+
//missing barpm
236+
if (fail_read & BARPM_MISSING) {
237+
double new_barpm = 0;
238+
string ll;
239+
istringstream istr;
240+
cout << "Illegal Barpm! Please enter a valid Barpm:" << endl;;
241+
getline(cin, ll);
242+
istr.str(ll);
243+
istr >> new_barpm;
234244

235-
if (fail_read != 1) {
245+
while (new_barpm <= 0) {
246+
cout << "Illegal Barpm! Please re-enter a valid Barpm:" << endl;
247+
getline(cin, ll);
248+
istr.clear();
249+
istr.str(ll);
250+
istr >> new_barpm;
251+
}
252+
char new_barpm_string[64];
253+
sprintf_s(new_barpm_string, "%f", new_barpm);
254+
cs.set_barpm(new_barpm);
255+
cout << "Barpm is set to " + string(new_barpm_string) + "." << endl;
256+
cout << "===============================" << endl;
257+
258+
fail_read &= (~(int)BARPM_MISSING);
259+
}
260+
//missing left side
261+
if (fail_read & LEFT_SIDE_MISSING) {
262+
sides s = sides::UNKNOWN;
263+
string side_string;
264+
cout << "Left side type is not specified! Please enter a valid side type:" << endl;
265+
while (s == sides::UNKNOWN) {
266+
cin >> side_string;
267+
//lowercase
268+
transform(side_string.begin(), side_string.end(), side_string.begin(), tolower);
269+
if (side_string == "pad") {
270+
s = sides::PAD;
271+
}
272+
else if (side_string == "mixer") {
273+
s = sides::MIXER;
274+
}
275+
else if (side_string == "multi") {
276+
s = sides::MULTI;
277+
}
278+
else {
279+
cout << "Invalid side type! Please enter again!" << endl;
280+
}
281+
}
282+
cs.set_lside(s);
283+
cout << "Left side fixed." << endl;
284+
cout << "===============================" << endl;
285+
fail_read &= (~(int)LEFT_SIDE_MISSING);
286+
}
287+
//missing right side
288+
if (fail_read & RIGHT_SIDE_MISSING) {
289+
sides s = sides::UNKNOWN;
290+
string side_string;
291+
cout << "Right side type is not specified! Please enter a valid side type:" << endl;
292+
while (s == sides::UNKNOWN) {
293+
cin >> side_string;
294+
//lowercase
295+
transform(side_string.begin(), side_string.end(), side_string.begin(), tolower);
296+
if (side_string == "pad") {
297+
s = sides::PAD;
298+
}
299+
else if (side_string == "mixer") {
300+
s = sides::MIXER;
301+
}
302+
else if (side_string == "multi") {
303+
s = sides::MULTI;
304+
}
305+
else {
306+
cout << "Invalid side type! Please enter again!" << endl;
307+
}
308+
}
309+
cs.set_rside(s);
310+
cout << "Right side fixed." << endl;
311+
cout << "===============================" << endl;
312+
fail_read &= (~(int)RIGHT_SIDE_MISSING);
313+
}
314+
//Hold-sub mismatch autofix
315+
if (fail_read & HOLD_SUB_MISMATCH) {
316+
cout << "mismatched notes found:" << endl;
317+
for (auto& ii : cs.mismatched_notes) {
318+
cout << ii.first << '\t' << ii.second << endl;
319+
//fix
320+
if (ii.second == "middle") {
321+
cs.m_notes.erase(ii.first);
322+
}
323+
else if (ii.second == "left") {
324+
cs.m_left.erase(ii.first);
325+
}
326+
else if (ii.second == "right") {
327+
cs.m_right.erase(ii.first);
328+
}
329+
}
330+
cout << "\nThe mismatching Holds and Subs have been fixed automatically." << endl;
331+
cout << "===============================" << endl;
332+
//set status to success
333+
fail_read &= (~(int)HOLD_SUB_MISMATCH);
334+
}
335+
336+
if (fail_read == 0) {
236337

237338
//this function now only processes chart store class
238339
int success = width_change(cs, width, start_time, end_time, side_mask, random_trigger);//width=1 as default width multiplier
@@ -290,6 +391,9 @@ int main(int argc, char* argv[])
290391
}
291392
}
292393
}
394+
else {
395+
cout << "Unknown error" << endl;
396+
}
293397
}
294398
catch (exception& ex) {
295399
cout << ex.what() << endl;
495 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)