From 91abb372813c7b6f11e7cd9e3514ed6845d91c83 Mon Sep 17 00:00:00 2001 From: Ralty <78720179+Raltyro@users.noreply.github.com> Date: Sat, 9 Aug 2025 13:23:02 +0700 Subject: [PATCH] Fix --- source/funkin/backend/chart/Chart.hx | 29 ++++++++++--------- source/funkin/editors/charter/Charter.hx | 27 +++++++++-------- .../editors/charter/CharterSelection.hx | 6 ++-- .../editors/charter/SongCreationScreen.hx | 11 ++++++- source/funkin/game/PlayState.hx | 6 ++-- 5 files changed, 46 insertions(+), 33 deletions(-) diff --git a/source/funkin/backend/chart/Chart.hx b/source/funkin/backend/chart/Chart.hx index 82d775b3..bf2fb50f 100644 --- a/source/funkin/backend/chart/Chart.hx +++ b/source/funkin/backend/chart/Chart.hx @@ -220,8 +220,7 @@ class Chart { */ #if REGION var extraEvents:Array = loadEventsJson(songName); - if (extraEvents != null) - base.events = base.events.concat(extraEvents); + if (extraEvents != null) base.events = base.events.concat(extraEvents); #end /** @@ -262,16 +261,17 @@ class Chart { var filteredChart = filterChartForSaving(chart, saveSettings.saveMetaInChart, saveSettings.saveLocalEvents, saveSettings.saveGlobalEvents && saveSettings.seperateGlobalEvents != true); #if sys - var prefix = 'assets/songs/', assetsRoot = Paths.getAssetsRoot() + '/'; - var songPath = saveSettings.songFolder == null ? '${chart.meta.name}' : saveSettings.songFolder, prettyPrint = saveSettings.prettyPrint == true ? Flags.JSON_PRETTY_PRINT : null; - var metaPath = '$songPath/meta.json', temp:String; - if ((temp = Paths.assetsTree.getPath(prefix + metaPath)) != null) metaPath = temp; - else metaPath = assetsRoot + metaPath; + var songPath = saveSettings.songFolder == null ? 'assets/songs/${chart.meta.name}' : saveSettings.songFolder; + var metaPath = 'meta.json', prettyPrint = saveSettings.prettyPrint == true ? Flags.JSON_PRETTY_PRINT : null, temp:String; + if ((temp = Paths.assetsTree.getPath('$songPath/$metaPath')) != null) { + songPath = temp.substr(0, temp.length - metaPath.length - 1); + metaPath = temp; + } + else if (saveSettings.songFolder == null) + metaPath = (songPath = '${Paths.getAssetsRoot()}/$songPath') + '/$metaPath'; var chartFolder = saveSettings.folder == null ? ((variant == null || variant == '') ? 'charts' : 'charts/$variant') : saveSettings.folder; var chartPath = '$songPath/$chartFolder/${difficulty.trim()}.json'; - if ((temp = Paths.assetsTree.getPath(prefix + chartPath)) != null) chartPath = temp; - else chartPath = assetsRoot + chartPath; if (saveSettings.saveChart == null || saveSettings.saveChart == true) CoolUtil.safeSaveFile(chartPath, Json.stringify(filteredChart, null, prettyPrint)); @@ -280,11 +280,10 @@ class Chart { CoolUtil.safeSaveFile(metaPath, Json.stringify(filterMetaForSaving(chart.meta), null, prettyPrint)); if (saveSettings.seperateGlobalEvents == true) { - var eventsPath = '$songPath/events.json'; - if ((temp = Paths.assetsTree.getPath(prefix + eventsPath)) != null) eventsPath = temp; - else eventsPath = assetsRoot + eventsPath; + var eventsPath = '$songPath/events.json', events = filterEventsForSaving(chart.events, false, true); - CoolUtil.safeSaveFile(eventsPath, Json.stringify({events: filterEventsForSaving(chart.events, false, true)}, null, prettyPrint)); + if (events.length != 0) CoolUtil.safeSaveFile(eventsPath, Json.stringify({events: events}, null, prettyPrint)); + else if (FileSystem.exists(eventsPath)) FileSystem.deleteFile(eventsPath); } #end @@ -335,6 +334,10 @@ class Chart { if (data.color != null) data.color = FlxColor.fromInt(data.color).toWebString(); // dont even ask me - Nex Reflect.deleteField(data, 'parsedColor'); Reflect.deleteField(data, 'metas'); + Reflect.deleteField(data, "variant"); + if (data.instSuffix != null && data.instSuffix == "") Reflect.deleteField(data, "instSuffix"); + if (data.vocalsSuffix != null && data.vocalsSuffix == "") Reflect.deleteField(data, "vocalsSuffix"); + if (data.variants != null && data.variants.length == 0) Reflect.deleteField(data, "variants"); return data; } } diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index c09bfebc..128e505b 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -601,33 +601,32 @@ class Charter extends UIState { __resetStatics(); } - var SONG = PlayState.SONG; - Conductor.setupSong(SONG); - noteTypes = SONG.noteTypes; + Conductor.setupSong(PlayState.SONG); + noteTypes = PlayState.SONG.noteTypes; - FlxG.sound.setMusic(FlxG.sound.load(Paths.inst(SONG.meta.name, __diff, SONG.meta.instSuffix))); - if (Assets.exists(Paths.voices(SONG.meta.name, __diff, SONG.meta.vocalsSuffix))) - vocals = FlxG.sound.load(Paths.voices(SONG.meta.name, __diff, SONG.meta.vocalsSuffix)); + FlxG.sound.setMusic(FlxG.sound.load(Paths.inst(__song, __diff, PlayState.SONG.meta.instSuffix))); + if (Assets.exists(Paths.voices(__song, __diff, PlayState.SONG.meta.vocalsSuffix))) + vocals = FlxG.sound.load(Paths.voices(__song, __diff, PlayState.SONG.meta.vocalsSuffix)); else vocals = new FlxSound(); - vocals.muted = !SONG.meta.needsVoices; + vocals.muted = !PlayState.SONG.meta.needsVoices; vocals.group = FlxG.sound.defaultMusicGroup; - gridBackdrops.createGrids(SONG.strumLines.length); + gridBackdrops.createGrids(PlayState.SONG.strumLines.length); - for(strL in SONG.strumLines) + var noteCount:Int = 0; + for (strL in PlayState.SONG.strumLines) { createStrumline(strumLines.members.length, strL, false, false); + noteCount += strL.notes.length; + } // create notes notesGroup.autoSort = false; - var noteCount:Int = 0; - for (strL in SONG.strumLines) - noteCount += strL.notes.length; notesGroup.preallocate(noteCount); var notesCreated:Int = 0; - for (i => strL in SONG.strumLines) + for (i => strL in PlayState.SONG.strumLines) for (note in strL.notes) { var n = new CharterNote(); var t = Conductor.getStepForTime(note.time); @@ -641,7 +640,7 @@ class Charter extends UIState { rightEventsGroup.autoSort = leftEventsGroup.autoSort = false; var lastLeftEvents:CharterEvent = null, lastRightEvents:CharterEvent = null; var lastLeftTime = Math.NaN, lastRightTime = Math.NaN; - for (e in SONG.events) if (e != null) { + for (e in PlayState.SONG.events) if (e != null) { if (e.global) { if (lastRightEvents != null && lastRightTime == e.time) lastRightEvents.events.push(e); else rightEventsGroup.add(lastRightEvents = new CharterEvent(Conductor.getStepForTime(lastRightTime = e.time), [e], e.global)); diff --git a/source/funkin/editors/charter/CharterSelection.hx b/source/funkin/editors/charter/CharterSelection.hx index 7e05867a..2b259d94 100644 --- a/source/funkin/editors/charter/CharterSelection.hx +++ b/source/funkin/editors/charter/CharterSelection.hx @@ -26,11 +26,11 @@ class CharterSelectionScreen extends EditorTreeMenuScreen { public var curSong:ChartMetaData; inline public function makeChartOption(d:String, v:String, name:String):TextOption { - return new TextOption(d, getID('acceptDifficulty'), FlxG.switchState.bind(new Charter(name, d, v))); + return new TextOption(d, getID('acceptDifficulty'), () -> FlxG.switchState(new Charter(name, d, v))); } inline public function makeVariationOption(s:ChartMetaData):TextOption { - return new TextOption(s.variant, getID('acceptVariation'), " >", openSongOption.bind(s, false)); + return new TextOption(s.variant, getID('acceptVariation'), " >", () -> openSongOption(s, false)); } public function openSongOption(s:ChartMetaData, first = true) { @@ -64,7 +64,7 @@ class CharterSelectionScreen extends EditorTreeMenuScreen { public function makeSongOption(s:ChartMetaData):IconOption { songList.push(s.name.toLowerCase()); - var opt = new IconOption(s.name, getID('acceptSong'), s.icon, openSongOption.bind(s, true)); + var opt = new IconOption(s.name, getID('acceptSong'), s.icon, () -> openSongOption(s, true)); opt.suffix = " >"; opt.editorFlashColor = s.color.getDefault(FlxColor.WHITE); diff --git a/source/funkin/editors/charter/SongCreationScreen.hx b/source/funkin/editors/charter/SongCreationScreen.hx index 869c7ba9..c6e9a8f3 100644 --- a/source/funkin/editors/charter/SongCreationScreen.hx +++ b/source/funkin/editors/charter/SongCreationScreen.hx @@ -42,6 +42,7 @@ class SongCreationScreen extends UISubstateWindow { public var difficultiesTextBox:UITextBox; public var engineDropdown:UIDropDown; + public var createSong:UIButton; public var importInstExplorer:UIFileExplorer; public var importVoicesExplorer:UIFileExplorer; @@ -189,6 +190,14 @@ class SongCreationScreen extends UISubstateWindow { selectFormatGroup.add(engineDropdown); addLabelOn(engineDropdown, translate("importChartFormat")); + createSong = new UIButton(windowSpr.x + 20, windowSpr.y + windowSpr.bHeight - 16 - 32, "< " + translate("back"), function() { + winTitle = translate("win-title"); + isImporting = false; + updatePagesTexts(); + refreshPages(); + }, 120); + selectFormatGroup.add(createSong); + var menuTitle:UIText; importAudioGroup.add(menuTitle = new UIText(windowSpr.x + 20, windowSpr.y + 30 + 16, 0, translate("importAudios"), 28)); @@ -332,7 +341,7 @@ class SongCreationScreen extends UISubstateWindow { backButton.x = (saveButton.x = windowSpr.x + windowSpr.bWidth - 20 - 125) - 20 - saveButton.bWidth; closeButton.x = (curPage > 0 ? backButton : saveButton).x - 20 - saveButton.bWidth; - for (button in [saveButton, backButton, closeButton, importFrom]) + for (button in [saveButton, backButton, closeButton, importFrom, createSong]) button.y = windowSpr.y + windowSpr.bHeight - 16 - 32; } diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index b5b9ca55..9e36b860 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -2153,16 +2153,18 @@ class PlayState extends MusicBeatState * @param opponentMode Whenever opponent mode is on * @param coopMode Whenever co-op mode is on. */ - public static function loadSong(_name:String, ?_difficulty:String, ?_variation:String, _opponentMode:Bool = false, _coopMode:Bool = false) { + public static function loadSong(_name:String, ?_difficulty:String, ?_variation:Dynamic, _opponentMode:Bool = false, _coopMode:Bool = false) { if (_difficulty == null) difficulty = Flags.DEFAULT_DIFFICULTY; if (_variation is Bool) { // vackward cumpatibshit _coopMode = _opponentMode; _opponentMode = cast _variation; + _variation = null; } + else if (!(_variation is String)) _variation = null; opponentMode = _opponentMode; coopMode = _coopMode; isStoryMode = chartingMode = false; - __loadSong(_name, _difficulty, _variation); + __loadSong(_name, _difficulty, cast _variation); } /**