From ccabcd76221916c38d184fae93a2c9fa7db43a38 Mon Sep 17 00:00:00 2001 From: rushillbunny <131571752+lasystuff@users.noreply.github.com> Date: Sun, 19 Apr 2026 10:05:13 +0900 Subject: [PATCH 1/2] rework event loading on chart editor --- .../states/editors/OLDChartEditorState.hx | 52 +++++++------------ 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/source/funkin/states/editors/OLDChartEditorState.hx b/source/funkin/states/editors/OLDChartEditorState.hx index 05f65123..8b7a143b 100644 --- a/source/funkin/states/editors/OLDChartEditorState.hx +++ b/source/funkin/states/editors/OLDChartEditorState.hx @@ -5,6 +5,7 @@ import funkin.data.Chart; import haxe.ds.IntMap; import haxe.Json; import haxe.io.Bytes; +import haxe.io.Path; import lime.media.AudioBuffer; @@ -650,7 +651,7 @@ class OLDChartEditorState extends MusicBeatState { for (file in FunkinAssets.readDirectory(directory)) { - var path = haxe.io.Path.join([directory, file]); + var path = Path.join([directory, file]); var isXml = false; if (!FunkinAssets.isDirectory(path) && (file.endsWith('.json') || (file.endsWith('.xml') && (isXml = true)))) { @@ -1302,7 +1303,7 @@ class OLDChartEditorState extends MusicBeatState { for (file in FunkinAssets.readDirectory(directory)) { - var path = haxe.io.Path.join([directory, file]); + var path = Path.join([directory, file]); if (!FunkinAssets.isDirectory(path)) { for (ext in FunkinScript.H_EXTS) @@ -1368,10 +1369,8 @@ class OLDChartEditorState extends MusicBeatState tab_group_event.name = 'Events'; #if MODS_ALLOWED - var eventPushedMap:Map = new Map(); var directories:Array = []; - #if MODS_ALLOWED directories.push(Paths.mods('data/events/')); directories.push(Paths.mods(Mods.currentModDirectory + '/data/events/')); for (mod in Mods.globalMods) @@ -1381,49 +1380,38 @@ class OLDChartEditorState extends MusicBeatState directories.push(Paths.mods(Mods.currentModDirectory + '/events/')); for (mod in Mods.globalMods) directories.push(Paths.mods(mod + '/events/')); - #end - var eventexts = ['.txt', '.hx', '.hxs', '.hscript']; - var removeShit = [4, 3, 4, 8]; + var eventexts = FunkinScript.H_EXTS.concat(["txt"]); + + var pushedEvents:Array = []; + for (event in eventStuff) pushedEvents.push(event[0]); for (i in 0...directories.length) { var directory:String = directories[i]; if (FunkinAssets.exists(directory)) { - for (file in FunkinAssets.readDirectory(directory)) + var files = FunkinAssets.readDirectory(directory); + files.sort((a, b) -> return Path.extension(a) == "txt" ? 1 : 0); + + for (file in files) { - var path = haxe.io.Path.join([directory, file]); - for (ext in 0...eventexts.length) + var path = Path.join([directory, file]); + if (!FunkinAssets.isDirectory(path) && file != 'readme.txt' && eventexts.contains(Path.extension(file))) { - if (!FunkinAssets.isDirectory(path) && file != 'readme.txt' && file.endsWith(eventexts[ext])) + var fileToCheck:String = Path.withoutExtension(file); + if (!pushedEvents.contains(fileToCheck)) { - var fileToCheck:String = file.substr(0, file.length - removeShit[ext]); - if (!eventPushedMap.exists(fileToCheck)) - { - eventPushedMap.set(fileToCheck, true); - for (x in ['.hx', '.hxs', '.hscript']) - { - if (file.endsWith(x)) - { - eventStuff.push([fileToCheck, 'scripted description']); - break; - } - else - { - eventStuff.push([fileToCheck, File.getContent(path)]); - break; - } - } - } - break; + if (FunkinScript.H_EXTS.contains(Path.extension(file))) + eventStuff.push([fileToCheck, 'scripted description']); + else + eventStuff.push([fileToCheck, File.getContent(path)]); } + pushedEvents.push(fileToCheck); } } } } - eventPushedMap.clear(); - eventPushedMap = null; #end descText = new FlxText(20, 200, 0, eventStuff[0][0]); From bbed3b295a733f92b9ecd47ee1904e74d21827c8 Mon Sep 17 00:00:00 2001 From: rushillbunny <131571752+lasystuff@users.noreply.github.com> Date: Sun, 19 Apr 2026 10:05:29 +0900 Subject: [PATCH 2/2] also this --- .../funkin/states/editors/ChartEditorState.hx | 50 +++++++------------ 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/source/funkin/states/editors/ChartEditorState.hx b/source/funkin/states/editors/ChartEditorState.hx index 22c4770a..885a1fec 100644 --- a/source/funkin/states/editors/ChartEditorState.hx +++ b/source/funkin/states/editors/ChartEditorState.hx @@ -5,6 +5,7 @@ import funkin.data.Chart; import haxe.ds.IntMap; import haxe.Json; import haxe.io.Bytes; +import haxe.io.Path; import lime.media.AudioBuffer; @@ -969,10 +970,8 @@ class ChartEditorState extends haxe.ui.backend.flixel.UIState function prepareEventsUI():Void { #if MODS_ALLOWED - var eventPushedMap:Map = new Map(); var directories:Array = []; - #if MODS_ALLOWED directories.push(Paths.mods('data/events/')); directories.push(Paths.mods(Mods.currentModDirectory + '/data/events/')); for (mod in Mods.globalMods) @@ -982,49 +981,38 @@ class ChartEditorState extends haxe.ui.backend.flixel.UIState directories.push(Paths.mods(Mods.currentModDirectory + '/events/')); for (mod in Mods.globalMods) directories.push(Paths.mods(mod + '/events/')); - #end - var eventexts = ['.txt', '.hx', '.hxs', '.hscript']; - var removeShit = [4, 3, 4, 8]; + var eventexts = FunkinScript.H_EXTS.concat(["txt"]); + + var pushedEvents:Array = []; + for (event in eventStuff) pushedEvents.push(event[0]); for (i in 0...directories.length) { var directory:String = directories[i]; - if (!FunkinAssets.exists(directory)) continue; - - for (file in FunkinAssets.readDirectory(directory)) + if (FunkinAssets.exists(directory)) { - var path = haxe.io.Path.join([directory, file]); - for (ext in 0...eventexts.length) + var files = FunkinAssets.readDirectory(directory); + files.sort((a, b) -> return Path.extension(a) == "txt" ? 1 : 0); + + for (file in files) { - if (FunkinAssets.isDirectory(path) || file == 'readme.txt' || !file.endsWith(eventexts[ext])) continue; - - var fileToCheck:String = file.substr(0, file.length - removeShit[ext]); - - if (eventPushedMap.exists(fileToCheck)) break; - - eventPushedMap.set(fileToCheck, true); - - for (x in ['.hx', '.hxs', '.hscript']) + var path = Path.join([directory, file]); + if (!FunkinAssets.isDirectory(path) && file != 'readme.txt' && eventexts.contains(Path.extension(file))) { - if (file.endsWith(x)) + var fileToCheck:String = Path.withoutExtension(file); + if (!pushedEvents.contains(fileToCheck)) { - eventStuff.push([fileToCheck, 'scripted description']); - break; - } - else - { - eventStuff.push([fileToCheck, File.getContent(path)]); - break; + if (FunkinScript.H_EXTS.contains(Path.extension(file))) + eventStuff.push([fileToCheck, 'scripted description']); + else + eventStuff.push([fileToCheck, File.getContent(path)]); } + pushedEvents.push(fileToCheck); } - - break; } } } - eventPushedMap.clear(); - eventPushedMap = null; #end ui.songDialog.eventDropdown.populateList([for (ev in eventStuff) {id: ev[0], text: (ev[0].length == 0 ? 'None' : ev[0])}]);