Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 19 additions & 31 deletions source/funkin/states/editors/ChartEditorState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -969,10 +970,8 @@ class ChartEditorState extends haxe.ui.backend.flixel.UIState
function prepareEventsUI():Void
{
#if MODS_ALLOWED
var eventPushedMap:Map<String, Bool> = new Map<String, Bool>();
var directories:Array<String> = [];

#if MODS_ALLOWED
directories.push(Paths.mods('data/events/'));
directories.push(Paths.mods(Mods.currentModDirectory + '/data/events/'));
for (mod in Mods.globalMods)
Expand All @@ -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<String> = [];
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])}]);
Expand Down
52 changes: 20 additions & 32 deletions source/funkin/states/editors/OLDChartEditorState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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))))
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1368,10 +1369,8 @@ class OLDChartEditorState extends MusicBeatState
tab_group_event.name = 'Events';

#if MODS_ALLOWED
var eventPushedMap:Map<String, Bool> = new Map<String, Bool>();
var directories:Array<String> = [];

#if MODS_ALLOWED
directories.push(Paths.mods('data/events/'));
directories.push(Paths.mods(Mods.currentModDirectory + '/data/events/'));
for (mod in Mods.globalMods)
Expand All @@ -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<String> = [];
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]);
Expand Down
Loading