Skip to content

Commit 1d022d5

Browse files
WWRSGuardevoir
andauthored
Change song folder to trackRef (#4)
Co-authored-by: Guarde <guardelola@gmx.at>
1 parent 388da9d commit 1d022d5

File tree

4 files changed

+30
-11
lines changed

4 files changed

+30
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.idea
2+
/.vs

index.html

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,15 @@ <h3>- Chart info -</h3>
138138

139139
<h3>- Other -</h3>
140140

141-
<abbr title="Name of the song folder, required for old versions of TrombLoader">i</abbr>
142-
<label for="foldername">Folder Name</label>
143-
<input type="text" id="foldername" name="foldername" placeholder="Auto">
141+
<abbr title="Name used by mods to identify your chart. Use only a-Z, 1-9, _, -, and space. Should be globally unique.">i</abbr>
142+
<label for="trackRef">trackRef</label>
143+
<input type="text" id="trackRef" name="trackRef">
144144

145-
<abbr
146-
title="The length of the song in measures. Leave this blank unless you need to manually set the endpoint.">i</abbr>
145+
<abbr title="Whether TCCC should generate a random prefix for trackRef. This ensures trackRef will be globally unique.">i</abbr>
146+
<label for="prefixTrackRef">Prefix trackRef?</label>
147+
<input type="checkbox" id="prefixTrackRef" name="prefixTrackRef" checked>
148+
149+
<abbr title="The length of the song in measures. Leave this blank unless you need to manually set the endpoint.">i</abbr>
147150
<label for="songendpoint">Song Endpoint</label>
148151
<input type="number" id="songendpoint" name="songendpoint" placeholder="Auto">
149152
</div>
@@ -174,8 +177,8 @@ <h2>About</h2>
174177
<li>
175178
Fill out the form
176179
<ul>
177-
<li>All fields must be filled in, except those in the Other section</li>
178-
<li>Only input whole numbers. Decimals are not guaranteed to work.</li>
180+
<li>All fields must be filled in, except Song Endpoint</li>
181+
<li>Use whole numbers whenever possible: Decimals are not guaranteed to work</li>
179182
<li>Hover over the names of each field to see detailed info</li>
180183
</ul>
181184
</li>
@@ -277,6 +280,11 @@ <h3>Examples</h3>
277280

278281
<div class="container">
279282
<h2>Version history</h2>
283+
<p>
284+
v1.8a:<br>
285+
Changed "Song Folder" to "trackRef"
286+
Added option to generate unique trackRef prefix
287+
</p>
280288
<p>
281289
v1.8:<br>
282290
Added support for converting MIDI pitch bend events into note pitch adjustments

src/generate.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const Generate = (function () {
88
if (!Inputs.verifyInputs() || MidiToNotes.notes.length === 0) {
99
alert(
1010
"Please ensure a valid midi is uploaded and all fields are filled\n" +
11-
"(Folder Name and Song Endpoint can be empty)"
11+
"(Song Endpoint can be empty)"
1212
);
1313
return;
1414
}
@@ -19,7 +19,8 @@ const Generate = (function () {
1919
...inputs,
2020
notes: MidiToNotes.notes,
2121
lyrics: MidiToNotes.lyrics,
22-
trackRef: inputs.trackRef || `${Math.random()}`,
22+
trackRef: (inputs.prefixTrackRef ? Math.random().toString().substring(2) + '_' : '') + inputs.trackRef,
23+
prefixTrackRef: undefined,
2324
endpoint: inputs.endpoint || MidiToNotes.calculatedEndpoint,
2425
UNK1: 0,
2526
};

src/inputs.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ const Inputs = (function () {
1616
notespacing: "savednotespacing",
1717
notestartcolor: "note_color_start",
1818
noteendcolor: "note_color_end",
19-
foldername: "trackRef",
19+
trackRef: "trackRef",
20+
prefixTrackRef: "prefixTrackRef",
2021
songendpoint: "endpoint",
2122
};
2223

2324
/** Inputs that are not required to be filled in */
24-
const optionalInputNames = new Set(["foldername", "songendpoint"]);
25+
const optionalInputNames = new Set(["songendpoint"]);
2526

2627
/** Inputs that need to be formatted as ints */
2728
const intInputNames = new Set([
@@ -39,6 +40,9 @@ const Inputs = (function () {
3940
/** Inputs that need to be formatted as colors */
4041
const colorInputNames = new Set(["notestartcolor", "noteendcolor"]);
4142

43+
/** Checkbox inputs fetch `checked` instead of `value` */
44+
const checkboxInputNames = new Set(["prefixTrackRef"]);
45+
4246
/** Returns whether all required fields are filled in */
4347
function verifyInputs() {
4448
for (const [inputName, input] of Object.entries(inputs)) {
@@ -59,6 +63,8 @@ const Inputs = (function () {
5963
result[inputMap[inputName]] = Number(input.value);
6064
} else if (colorInputNames.has(inputName)) {
6165
result[inputMap[inputName]] = Color.hexToFloats(input.value);
66+
} else if (checkboxInputNames.has(inputName)) {
67+
result[inputMap[inputName]] = input.checked;
6268
} else {
6369
result[inputMap[inputName]] = input.value;
6470
}
@@ -94,6 +100,9 @@ const Inputs = (function () {
94100
}
95101
input.dispatchEvent(new Event("change"));
96102
}
103+
104+
// Do not prefix if the trackRef was passed
105+
if (obj.trackRef) inputs.prefixTrackRef.checked = false;
97106
}
98107

99108
/** Converts a string to an number, warning if it's actually a float */

0 commit comments

Comments
 (0)