-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcustom.html
208 lines (203 loc) · 7.98 KB
/
custom.html
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Custom Chart Patcher</title>
<noscript>This page requires JavaScript to function.</noscript>
<link rel="stylesheet" href="css/style.css">
<!-- don't hate -->
<script type="text/javascript" src="js/FileSaver.min.js"></script>
<script type="text/javascript" src="js/SusPatcher.js"></script>
<script type="text/javascript" src="js/collapsible.js"></script>
<script type="text/javascript">
var patcher;
let chartfile;
function dropHandler(ev) {
ev.preventDefault();
let upload = document.getElementById("custom-chart-upload");
if (ev.dataTransfer.files.length) {
chartfile = ev.dataTransfer.files[0];
upload.innerHTML = `${chartfile.name}`;
}
let container = document.getElementById("song");
container.classList.remove("dragging");
}
function dragoverHandler(ev) {
ev.preventDefault();
let upload = document.getElementById("song");
if (!upload.classList.contains("dragging")) upload.classList.add("dragging");
}
function dragLeaveHandler(ev) {
ev.preventDefault();
let upload = document.getElementById("song");
upload.classList.remove("dragging");
}
window.addEventListener("load", function () {
let title = document.getElementsByTagName("title")[0];
let h1 = document.getElementsByTagName("h1")[0];
let content = document.getElementById("song");
patcher = new Patcher();
let metadata = document.getElementById("patch-custom-song");
metadata.addEventListener("submit", ev=>{
ev.preventDefault();
if (!chartfile) {
let upload = document.getElementById("custom-chart");
if (upload.files.length) {
chartfile = upload.files[0];
}
}
data = new FormData(metadata);
let reader = new FileReader();
reader.onload = (evt) => {
let sus = evt.target.result.split("\n");
metadata = {
id: data.get("songid"),
title: data.get("title"),
artist: data.get("artist"),
designer: data.get("designer"),
jacket: data.get("jacket"),
wave: data.get("wave"),
waveoffset: data.get("waveoffset"),
difficulty: data.get("difficulty"),
playlevel: data.get("playlevel"),
}
for (const key in metadata) {
if (metadata[key]===null) delete metadata[key];
}
if (metadata.difficulty === "") delete metadata.difficulty;
sus = patcher.patchMetadata(sus, metadata);
sus = patcher.patchOneChart(sus);
patcher.saveCustomChart(sus.join("\n"), `${chartfile.name.split(".")[0]} patched`);
}
reader.readAsText(chartfile);
})
})
</script>
</head>
<body>
<h1>Custom Chart Patcher</h1>
<div id="song" class="songContainer" ondrop="dropHandler(event);" ondragover="dragoverHandler(event);" ondragleave="dragLeaveHandler(event);">
<form id="patch-custom-song">
<div id="custom-chart-upload">
<input type="file" id="custom-chart" name="upload">
</div>
<table class="custom-song-metadata">
<tr>
<td class="label">
<label for="songid">Song ID: </label>
</td>
<td class="input">
<input type="text" id="songid" name="songid">
</td>
</tr>
<tr>
<td class="label">
<label for="title">Title: </label>
</td>
<td class="input">
<input type="text" id="title" name="title">
</td>
</tr>
<tr>
<td class="label">
<label for="artist">Artist: </label>
</td>
<td class="input">
<input type="text" id="artist" name="artist">
</td>
</tr>
<tr>
<td class="label">
<label for="designer">Charter: </label>
</td>
<td class="input">
<input type="text" id="designer" name="designer">
</td>
</tr>
<tr>
<td class="label">
<label for="jacket">Cover picture: </label>
</td>
<td class="input">
<input type="text" id="jacket" name="jacket">
</td>
</tr>
<tr>
<td class="label">
<label for="wave">Music file: </label>
</td>
<td class="input">
<input type="text" id="wave" name="wave">
</td>
</tr>
<tr>
<td class="label">
<label for="waveoffset">Music offset (seconds): </label>
</td>
<td class="input">
<input type="number" id="waveoffset" name="waveoffset">
</td>
</tr>
<tr>
<td class="label">
<label for="difficulty">Difficulty: </label>
</td>
<td class="input">
<select name="difficulty" id="difficulty">
<option value="">-- Select --</option>
<option value="0">Easy</option>
<option value="1">Normal</option>
<option value="2">Hard</option>
<option value="3">Expert</option>
<option value="4">Master</option>
</select>
</td>
</tr>
<tr>
<td class="label">
<label for="playlevel">Numeric difficulty level: </label>
</td>
<td class="input">
<input type="number" min="0" id="playlevel" name="playlevel">
</td>
</tr>
</table>
<br />
<button type="submit">Patch and download chart</button>
</form>
</div>
<div class="tips">
Difficulty naming in Project Sekai: Colorful Stage differs from SUS specifications, therefore when you try to play the scores on SUS-compatible players, the difficulty will not match. Plus, the numeric difficulty level also differs. <br />
<button class="collapsible show" data-colid="1" onclick="toggleCol(1)">Open conversion table</button>
<button class="collapsible hide" data-colid="1" onclick="toggleCol(1)">Close conversion table</button>
<div class="collapsible hide" data-colid="1">
<table>
<tr>
<th>Pjsk</th>
<th>SUS Specs</th>
</tr>
<tr>
<td>EASY</td>
<td>BASIC</td>
</tr>
<tr>
<td>NORMAL</td>
<td>ADVANCED</td>
</tr>
<tr>
<td>HARD</td>
<td>EXPERT</td>
</tr>
<tr>
<td>EXPERT</td>
<td>MASTER</td>
</tr>
<tr>
<td>MASTER</td>
<td>WORLD'S END</td>
</tr>
</table>
</div>
</div>
</body>
</html>