event/script packing wip
This commit is contained in:
@@ -48,6 +48,9 @@ class Paths
|
||||
inline static public function txt(key:String, ?library:String)
|
||||
return getPath('data/$key.txt', library);
|
||||
|
||||
inline static public function pack(key:String, ?library:String)
|
||||
return getPath('data/$key.pack', library);
|
||||
|
||||
inline static public function ini(key:String, ?library:String)
|
||||
return getPath('data/$key.ini', library);
|
||||
|
||||
|
||||
@@ -42,15 +42,18 @@ class EventsData {
|
||||
hscriptParser.allowJSON = hscriptParser.allowMetadata = false;
|
||||
|
||||
for (file in Paths.getFolderContent('data/events/', true, BOTH)) {
|
||||
if (Path.extension(file) != "json") continue;
|
||||
if (Path.extension(file) != "json" && Path.extension(file) != "pack") continue;
|
||||
var eventName:String = Path.withoutExtension(Path.withoutDirectory(file));
|
||||
var fileTxt:String = Assets.getText(file);
|
||||
if (fileTxt.trim() == "") continue;
|
||||
if (Path.extension(file) == "pack") {
|
||||
eventName = Path.withoutExtension(fileTxt.split("________PACKSEP________")[0]);
|
||||
fileTxt = fileTxt.split("________PACKSEP________")[2];
|
||||
}
|
||||
|
||||
eventsList.push(eventName);
|
||||
eventsParams.set(eventName, []);
|
||||
|
||||
var fileTxt:String = Assets.getText(file);
|
||||
if (fileTxt.trim() == "") continue;
|
||||
|
||||
try {
|
||||
var data:Dynamic = Json.parse(fileTxt);
|
||||
if (data == null || data.params == null) continue;
|
||||
|
||||
@@ -45,10 +45,15 @@ class CharterEvent extends UISliceSprite implements ICharterSelectable {
|
||||
}
|
||||
|
||||
private static function generateDefaultIcon(name:String) {
|
||||
var isBase64:Bool = false;
|
||||
var path:String = Paths.image('editors/charter/event-icons/$name');
|
||||
if (!Assets.exists(path)) path = Paths.image('editors/charter/event-icons/Unknown');
|
||||
if (!Assets.exists(path) && Assets.exists(Paths.pack('events/$name'))) {
|
||||
path = Assets.getText(Paths.pack('events/$name')).split('________PACKSEP________')[3];
|
||||
isBase64 = true;
|
||||
}
|
||||
else if (!Assets.exists(path)) path = Paths.image('editors/charter/event-icons/Unknown');
|
||||
|
||||
var spr = new FlxSprite().loadGraphic(path);
|
||||
var spr = new FlxSprite().loadGraphic(isBase64 ? openfl.display.BitmapData.fromBase64(path.trim(), 'UTF8') : path);
|
||||
return spr;
|
||||
}
|
||||
|
||||
|
||||
@@ -576,7 +576,13 @@ class PlayState extends MusicBeatState
|
||||
|
||||
for (file in Paths.getFolderContent('data/events/', true, fromMods ? MODS : BOTH)) {
|
||||
var fileName:String = Path.withoutExtension(Path.withoutDirectory(file));
|
||||
if (EventsData.eventsList.contains(fileName) && songEvents.contains(fileName)) addScript(file);
|
||||
if (EventsData.eventsList.contains(fileName) && songEvents.contains(fileName)) {
|
||||
if (Path.extension(file) == "pack"){
|
||||
var txtArray:Array<String> = Assets.getText(Paths.pack('events/$fileName')).split("________PACKSEP________");
|
||||
scripts.add(Script.fromString(txtArray[1], Path.extension(txtArray[0]), Path.withoutExtension(txtArray[0])));
|
||||
}
|
||||
else addScript(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user