Skip to content

Commit 91abb37

Browse files
committed
Fix
1 parent 32bca04 commit 91abb37

File tree

5 files changed

+46
-33
lines changed

5 files changed

+46
-33
lines changed

source/funkin/backend/chart/Chart.hx

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,7 @@ class Chart {
220220
*/
221221
#if REGION
222222
var extraEvents:Array<ChartEvent> = loadEventsJson(songName);
223-
if (extraEvents != null)
224-
base.events = base.events.concat(extraEvents);
223+
if (extraEvents != null) base.events = base.events.concat(extraEvents);
225224
#end
226225

227226
/**
@@ -262,16 +261,17 @@ class Chart {
262261
var filteredChart = filterChartForSaving(chart, saveSettings.saveMetaInChart, saveSettings.saveLocalEvents, saveSettings.saveGlobalEvents && saveSettings.seperateGlobalEvents != true);
263262

264263
#if sys
265-
var prefix = 'assets/songs/', assetsRoot = Paths.getAssetsRoot() + '/';
266-
var songPath = saveSettings.songFolder == null ? '${chart.meta.name}' : saveSettings.songFolder, prettyPrint = saveSettings.prettyPrint == true ? Flags.JSON_PRETTY_PRINT : null;
267-
var metaPath = '$songPath/meta.json', temp:String;
268-
if ((temp = Paths.assetsTree.getPath(prefix + metaPath)) != null) metaPath = temp;
269-
else metaPath = assetsRoot + metaPath;
264+
var songPath = saveSettings.songFolder == null ? 'assets/songs/${chart.meta.name}' : saveSettings.songFolder;
265+
var metaPath = 'meta.json', prettyPrint = saveSettings.prettyPrint == true ? Flags.JSON_PRETTY_PRINT : null, temp:String;
266+
if ((temp = Paths.assetsTree.getPath('$songPath/$metaPath')) != null) {
267+
songPath = temp.substr(0, temp.length - metaPath.length - 1);
268+
metaPath = temp;
269+
}
270+
else if (saveSettings.songFolder == null)
271+
metaPath = (songPath = '${Paths.getAssetsRoot()}/$songPath') + '/$metaPath';
270272

271273
var chartFolder = saveSettings.folder == null ? ((variant == null || variant == '') ? 'charts' : 'charts/$variant') : saveSettings.folder;
272274
var chartPath = '$songPath/$chartFolder/${difficulty.trim()}.json';
273-
if ((temp = Paths.assetsTree.getPath(prefix + chartPath)) != null) chartPath = temp;
274-
else chartPath = assetsRoot + chartPath;
275275

276276
if (saveSettings.saveChart == null || saveSettings.saveChart == true)
277277
CoolUtil.safeSaveFile(chartPath, Json.stringify(filteredChart, null, prettyPrint));
@@ -280,11 +280,10 @@ class Chart {
280280
CoolUtil.safeSaveFile(metaPath, Json.stringify(filterMetaForSaving(chart.meta), null, prettyPrint));
281281

282282
if (saveSettings.seperateGlobalEvents == true) {
283-
var eventsPath = '$songPath/events.json';
284-
if ((temp = Paths.assetsTree.getPath(prefix + eventsPath)) != null) eventsPath = temp;
285-
else eventsPath = assetsRoot + eventsPath;
283+
var eventsPath = '$songPath/events.json', events = filterEventsForSaving(chart.events, false, true);
286284

287-
CoolUtil.safeSaveFile(eventsPath, Json.stringify({events: filterEventsForSaving(chart.events, false, true)}, null, prettyPrint));
285+
if (events.length != 0) CoolUtil.safeSaveFile(eventsPath, Json.stringify({events: events}, null, prettyPrint));
286+
else if (FileSystem.exists(eventsPath)) FileSystem.deleteFile(eventsPath);
288287
}
289288
#end
290289

@@ -335,6 +334,10 @@ class Chart {
335334
if (data.color != null) data.color = FlxColor.fromInt(data.color).toWebString(); // dont even ask me - Nex
336335
Reflect.deleteField(data, 'parsedColor');
337336
Reflect.deleteField(data, 'metas');
337+
Reflect.deleteField(data, "variant");
338+
if (data.instSuffix != null && data.instSuffix == "") Reflect.deleteField(data, "instSuffix");
339+
if (data.vocalsSuffix != null && data.vocalsSuffix == "") Reflect.deleteField(data, "vocalsSuffix");
340+
if (data.variants != null && data.variants.length == 0) Reflect.deleteField(data, "variants");
338341
return data;
339342
}
340343
}

source/funkin/editors/charter/Charter.hx

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -601,33 +601,32 @@ class Charter extends UIState {
601601
__resetStatics();
602602
}
603603

604-
var SONG = PlayState.SONG;
605-
Conductor.setupSong(SONG);
606-
noteTypes = SONG.noteTypes;
604+
Conductor.setupSong(PlayState.SONG);
605+
noteTypes = PlayState.SONG.noteTypes;
607606

608-
FlxG.sound.setMusic(FlxG.sound.load(Paths.inst(SONG.meta.name, __diff, SONG.meta.instSuffix)));
609-
if (Assets.exists(Paths.voices(SONG.meta.name, __diff, SONG.meta.vocalsSuffix)))
610-
vocals = FlxG.sound.load(Paths.voices(SONG.meta.name, __diff, SONG.meta.vocalsSuffix));
607+
FlxG.sound.setMusic(FlxG.sound.load(Paths.inst(__song, __diff, PlayState.SONG.meta.instSuffix)));
608+
if (Assets.exists(Paths.voices(__song, __diff, PlayState.SONG.meta.vocalsSuffix)))
609+
vocals = FlxG.sound.load(Paths.voices(__song, __diff, PlayState.SONG.meta.vocalsSuffix));
611610
else
612611
vocals = new FlxSound();
613612

614-
vocals.muted = !SONG.meta.needsVoices;
613+
vocals.muted = !PlayState.SONG.meta.needsVoices;
615614
vocals.group = FlxG.sound.defaultMusicGroup;
616615

617-
gridBackdrops.createGrids(SONG.strumLines.length);
616+
gridBackdrops.createGrids(PlayState.SONG.strumLines.length);
618617

619-
for(strL in SONG.strumLines)
618+
var noteCount:Int = 0;
619+
for (strL in PlayState.SONG.strumLines) {
620620
createStrumline(strumLines.members.length, strL, false, false);
621+
noteCount += strL.notes.length;
622+
}
621623

622624
// create notes
623625
notesGroup.autoSort = false;
624-
var noteCount:Int = 0;
625-
for (strL in SONG.strumLines)
626-
noteCount += strL.notes.length;
627626
notesGroup.preallocate(noteCount);
628627

629628
var notesCreated:Int = 0;
630-
for (i => strL in SONG.strumLines)
629+
for (i => strL in PlayState.SONG.strumLines)
631630
for (note in strL.notes) {
632631
var n = new CharterNote();
633632
var t = Conductor.getStepForTime(note.time);
@@ -641,7 +640,7 @@ class Charter extends UIState {
641640
rightEventsGroup.autoSort = leftEventsGroup.autoSort = false;
642641
var lastLeftEvents:CharterEvent = null, lastRightEvents:CharterEvent = null;
643642
var lastLeftTime = Math.NaN, lastRightTime = Math.NaN;
644-
for (e in SONG.events) if (e != null) {
643+
for (e in PlayState.SONG.events) if (e != null) {
645644
if (e.global) {
646645
if (lastRightEvents != null && lastRightTime == e.time) lastRightEvents.events.push(e);
647646
else rightEventsGroup.add(lastRightEvents = new CharterEvent(Conductor.getStepForTime(lastRightTime = e.time), [e], e.global));

source/funkin/editors/charter/CharterSelection.hx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ class CharterSelectionScreen extends EditorTreeMenuScreen {
2626
public var curSong:ChartMetaData;
2727

2828
inline public function makeChartOption(d:String, v:String, name:String):TextOption {
29-
return new TextOption(d, getID('acceptDifficulty'), FlxG.switchState.bind(new Charter(name, d, v)));
29+
return new TextOption(d, getID('acceptDifficulty'), () -> FlxG.switchState(new Charter(name, d, v)));
3030
}
3131

3232
inline public function makeVariationOption(s:ChartMetaData):TextOption {
33-
return new TextOption(s.variant, getID('acceptVariation'), " >", openSongOption.bind(s, false));
33+
return new TextOption(s.variant, getID('acceptVariation'), " >", () -> openSongOption(s, false));
3434
}
3535

3636
public function openSongOption(s:ChartMetaData, first = true) {
@@ -64,7 +64,7 @@ class CharterSelectionScreen extends EditorTreeMenuScreen {
6464
public function makeSongOption(s:ChartMetaData):IconOption {
6565
songList.push(s.name.toLowerCase());
6666

67-
var opt = new IconOption(s.name, getID('acceptSong'), s.icon, openSongOption.bind(s, true));
67+
var opt = new IconOption(s.name, getID('acceptSong'), s.icon, () -> openSongOption(s, true));
6868
opt.suffix = " >";
6969
opt.editorFlashColor = s.color.getDefault(FlxColor.WHITE);
7070

source/funkin/editors/charter/SongCreationScreen.hx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class SongCreationScreen extends UISubstateWindow {
4242
public var difficultiesTextBox:UITextBox;
4343

4444
public var engineDropdown:UIDropDown;
45+
public var createSong:UIButton;
4546

4647
public var importInstExplorer:UIFileExplorer;
4748
public var importVoicesExplorer:UIFileExplorer;
@@ -189,6 +190,14 @@ class SongCreationScreen extends UISubstateWindow {
189190
selectFormatGroup.add(engineDropdown);
190191
addLabelOn(engineDropdown, translate("importChartFormat"));
191192

193+
createSong = new UIButton(windowSpr.x + 20, windowSpr.y + windowSpr.bHeight - 16 - 32, "< " + translate("back"), function() {
194+
winTitle = translate("win-title");
195+
isImporting = false;
196+
updatePagesTexts();
197+
refreshPages();
198+
}, 120);
199+
selectFormatGroup.add(createSong);
200+
192201
var menuTitle:UIText;
193202
importAudioGroup.add(menuTitle = new UIText(windowSpr.x + 20, windowSpr.y + 30 + 16, 0, translate("importAudios"), 28));
194203

@@ -332,7 +341,7 @@ class SongCreationScreen extends UISubstateWindow {
332341
backButton.x = (saveButton.x = windowSpr.x + windowSpr.bWidth - 20 - 125) - 20 - saveButton.bWidth;
333342
closeButton.x = (curPage > 0 ? backButton : saveButton).x - 20 - saveButton.bWidth;
334343

335-
for (button in [saveButton, backButton, closeButton, importFrom])
344+
for (button in [saveButton, backButton, closeButton, importFrom, createSong])
336345
button.y = windowSpr.y + windowSpr.bHeight - 16 - 32;
337346
}
338347

source/funkin/game/PlayState.hx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,16 +2153,18 @@ class PlayState extends MusicBeatState
21532153
* @param opponentMode Whenever opponent mode is on
21542154
* @param coopMode Whenever co-op mode is on.
21552155
*/
2156-
public static function loadSong(_name:String, ?_difficulty:String, ?_variation:String, _opponentMode:Bool = false, _coopMode:Bool = false) {
2156+
public static function loadSong(_name:String, ?_difficulty:String, ?_variation:Dynamic, _opponentMode:Bool = false, _coopMode:Bool = false) {
21572157
if (_difficulty == null) difficulty = Flags.DEFAULT_DIFFICULTY;
21582158
if (_variation is Bool) { // vackward cumpatibshit
21592159
_coopMode = _opponentMode;
21602160
_opponentMode = cast _variation;
2161+
_variation = null;
21612162
}
2163+
else if (!(_variation is String)) _variation = null;
21622164
opponentMode = _opponentMode;
21632165
coopMode = _coopMode;
21642166
isStoryMode = chartingMode = false;
2165-
__loadSong(_name, _difficulty, _variation);
2167+
__loadSong(_name, _difficulty, cast _variation);
21662168
}
21672169

21682170
/**

0 commit comments

Comments
 (0)