Skip to content

Commit be27447

Browse files
authored
Prevent empty difficulty strings from accidentally existing (#832)
* Prevent empty difficulty strings from being inputted * Also taking into account variants + making separator only show up when both difficulty and variant options are available
1 parent a8808be commit be27447

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

source/funkin/editors/charter/CharterSelection.hx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,21 @@ class CharterSelectionScreen extends EditorTreeMenuScreen {
4040
var screen = new EditorTreeMenuScreen((first || !isVariant) ? (s.name + (isVariant ? ' (${s.variant})' : '')) : s.variant, getID('selectDifficulty'));
4141

4242
for (d in s.difficulties) if (d != '') screen.add(makeChartOption(d, isVariant ? s.variant : null, s.name));
43-
screen.add(new Separator());
43+
if (s.difficulties.length > 0 && s.variants.length > 0) screen.add(new Separator()); // Create a separator only when there are both difficulty and variant options available.
4444
for (v in s.variants) if (s.metas.get(v) != null) screen.add(makeVariationOption(s.metas.get(v)));
4545

4646
#if sys
4747
screen.insert(0, new NewOption(getID('newDifficulty'), getID('newDifficultyDesc'), () -> {
4848
parent.openSubState(new ChartCreationScreen(saveChart));
4949
}));
5050

51-
if (!first) screen.curSelected = 1;
51+
if (!first) screen.curSelected = (s.difficulties.length + s.variants.length) > 0 ? 1 : 0;
5252
else {
5353
cast(screen.members[0], NewOption).itemHeight = 120;
5454
screen.insert(1, new NewOption(getID('newVariation'), getID('newVariationDesc'), () -> {
5555
parent.openSubState(new VariationCreationScreen(s, saveSong));
5656
}));
57-
screen.curSelected = 2;
57+
screen.curSelected = (s.difficulties.length + s.variants.length) > 0 ? 2 : 1;
5858
}
5959
#end
6060

source/funkin/editors/charter/SongCreationScreen.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ class SongCreationScreen extends UISubstateWindow {
435435
color: colorWheel.curColor,
436436
opponentModeAllowed: opponentModeCheckbox.checked,
437437
coopAllowed: coopAllowedCheckbox.checked,
438-
difficulties: [for (diff in difficultiesTextBox.label.text.split(",")) diff.trim()]
438+
difficulties: [for (diff in difficultiesTextBox.label.text.split(",")) if (diff.length > 0) diff.trim()]
439439
});
440440

441441
if (onSave != null) onSave({

0 commit comments

Comments
 (0)