Merge branch 'main' of https://github.com/FNF-CNE-Devs/CodenameEngine-Dev
This commit is contained in:
@@ -6,6 +6,9 @@ import lime.utils.AssetLibrary;
|
||||
class AssetsLibraryList extends AssetLibrary {
|
||||
public var libraries:Array<AssetLibrary> = [];
|
||||
|
||||
public var rootLibs:Array<AssetLibrary> = [];
|
||||
public var assetsLibs:Array<AssetLibrary> = [];
|
||||
|
||||
@:allow(funkin.backend.system.Main)
|
||||
@:allow(funkin.backend.system.MainState)
|
||||
private var __defaultLibraries:Array<AssetLibrary> = [];
|
||||
@@ -16,6 +19,7 @@ class AssetsLibraryList extends AssetLibrary {
|
||||
libraries.remove(lib);
|
||||
return lib;
|
||||
}
|
||||
|
||||
public function existsSpecific(id:String, type:String, source:AssetSource = BOTH) {
|
||||
if (!id.startsWith("assets/") && exists('assets/$id', type))
|
||||
return true;
|
||||
@@ -94,20 +98,31 @@ class AssetsLibraryList extends AssetLibrary {
|
||||
return content;
|
||||
}
|
||||
|
||||
public function getSpecificAsset(id:String, type:String, source:AssetSource = BOTH):Dynamic {
|
||||
public function getSpecificAsset(id:String, type:String, source:AssetSource = BOTH, ?avoidRoot:Bool = false):Dynamic {
|
||||
try {
|
||||
if (!id.startsWith("assets/")) {
|
||||
var ass = getSpecificAsset('assets/$id', type, source);
|
||||
if (ass != null) {
|
||||
return ass;
|
||||
}
|
||||
}
|
||||
for(k=>e in libraries) {
|
||||
if (shouldSkipLib(k, source)) continue;
|
||||
var fileFromAssets:Bool = id.startsWith("assets/");
|
||||
|
||||
var asset = e.getAsset(id, type);
|
||||
if (asset != null) {
|
||||
return asset;
|
||||
if (!fileFromAssets) {
|
||||
var ass = getSpecificAsset('assets/$id', type, source);
|
||||
if (ass != null)
|
||||
return ass;
|
||||
}
|
||||
|
||||
if (fileFromAssets) {
|
||||
for (lib in assetsLibs) {
|
||||
if (shouldSkipLib(libraries.indexOf(lib), source)) continue;
|
||||
|
||||
var asset = lib.getAsset(id, type);
|
||||
if (asset != null)
|
||||
return asset;
|
||||
}
|
||||
} else if (!avoidRoot) {
|
||||
for (lib in rootLibs) {
|
||||
if (shouldSkipLib(libraries.indexOf(lib), source)) continue;
|
||||
|
||||
var asset = lib.getAsset(id, type);
|
||||
if (asset != null)
|
||||
return asset;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -127,6 +142,9 @@ class AssetsLibraryList extends AssetLibrary {
|
||||
public override inline function getAsset(id:String, type:String):Dynamic
|
||||
return getSpecificAsset(id, type, BOTH);
|
||||
|
||||
public inline function getAssetSafe(id:String, type:String):Dynamic
|
||||
return getSpecificAsset(id, type, BOTH, true);
|
||||
|
||||
public override function isLocal(id:String, type:String) {
|
||||
return true;
|
||||
}
|
||||
@@ -155,8 +173,17 @@ class AssetsLibraryList extends AssetLibrary {
|
||||
addLibrary(d);
|
||||
}
|
||||
|
||||
public function addLibrary(lib:AssetLibrary) {
|
||||
public function addLibrary(lib:AssetLibrary) @:privateAccess {
|
||||
libraries.insert(0, lib);
|
||||
|
||||
var finalLib:AssetLibrary = lib;
|
||||
if (finalLib is openfl.utils.AssetLibrary)
|
||||
finalLib = cast(finalLib, openfl.utils.AssetLibrary).__proxy;
|
||||
|
||||
if (finalLib is IModsAssetLibrary)
|
||||
assetsLibs.insert(0, finalLib);
|
||||
else
|
||||
rootLibs.insert(0, finalLib);
|
||||
return lib;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import hscript.Expr.ModuleDecl;
|
||||
import hscript.Expr.Error;
|
||||
import hscript.Parser;
|
||||
import openfl.Assets;
|
||||
import lime.utils.AssetType;
|
||||
import hscript.*;
|
||||
|
||||
class HScript extends Script {
|
||||
@@ -29,7 +30,8 @@ class HScript extends Script {
|
||||
|
||||
interp = new Interp();
|
||||
|
||||
code = Assets.exists(path) ? Assets.getText(path) : null;
|
||||
// We use getAssetSafe to prevent crash from empty file (null which would check root (big crash)) -lunar
|
||||
code = Assets.exists(path) ? Paths.assetsTree.getAssetSafe(path, TEXT) : null;
|
||||
parser = initParser();
|
||||
folderlessPath = Path.directory(path);
|
||||
__importedPaths = [path];
|
||||
@@ -53,8 +55,7 @@ class HScript extends Script {
|
||||
|
||||
public override function loadFromString(code:String) {
|
||||
try {
|
||||
if (code != null && code.trim() != "")
|
||||
expr = parser.parseString(code, fileName);
|
||||
expr = parser.parseString(code, fileName);
|
||||
} catch(e:Error) {
|
||||
_errorHandler(e);
|
||||
} catch(e) {
|
||||
|
||||
@@ -218,7 +218,7 @@ class StrumLineButton extends UIButton {
|
||||
|
||||
hudXStepper = new UINumericStepper(hudScaleStepper.x + 80 - 32 + 26, hudScaleStepper.y, startingPos.x, 0.01, 2, 0, 2, 84);
|
||||
members.push(hudXStepper);
|
||||
addLabelOn(hudXStepper, "Hud Position (X,Y)");
|
||||
addLabelOn(hudXStepper, "Hud Position (X [Ratio 0-1],Y)");
|
||||
|
||||
members.push(XYComma = new UIText(hudXStepper.x + 84 - 32 + 0, hudXStepper.y + 9, 0, ",", 22));
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import openfl.net.FileReference;
|
||||
|
||||
class Charter extends UIState {
|
||||
public static var __song:String;
|
||||
public static var __lastPos:Float;
|
||||
static var __diff:String;
|
||||
static var __reload:Bool;
|
||||
|
||||
@@ -456,10 +457,11 @@ class Charter extends UIState {
|
||||
|
||||
public function loadSong() {
|
||||
if (__reload) {
|
||||
EventsData.reloadEvents();
|
||||
EventsData.reloadEvents(); __lastPos = 0;
|
||||
PlayState.loadSong(__song, __diff, false, false);
|
||||
}
|
||||
Conductor.setupSong(PlayState.SONG);
|
||||
Conductor.songPosition = __lastPos;
|
||||
noteTypes = PlayState.SONG.noteTypes;
|
||||
// noteTypes = ["Hurt Note", "Bullet Note", "Penis Note", "Boobs Note"];
|
||||
|
||||
@@ -930,7 +932,7 @@ class Charter extends UIState {
|
||||
#end
|
||||
|
||||
var __crochet:Float;
|
||||
var __autosaveElapsed:Float;
|
||||
// var __autosaveElapsed:Float;
|
||||
public override function update(elapsed:Float) {
|
||||
updateNoteLogic(elapsed);
|
||||
|
||||
@@ -1011,6 +1013,7 @@ class Charter extends UIState {
|
||||
vocals.pause();
|
||||
for (strumLine in strumLines.members) strumLine.vocals.pause();
|
||||
}
|
||||
__lastPos = Conductor.songPosition;
|
||||
|
||||
songPosInfo.text = '${CoolUtil.timeToStr(Conductor.songPosition)} / ${CoolUtil.timeToStr(songLength)}'
|
||||
+ '\nStep: ${curStep}'
|
||||
@@ -1025,11 +1028,13 @@ class Charter extends UIState {
|
||||
WindowUtils.prefix = undos.unsaved ? "* " : "";
|
||||
SaveWarning.showWarning = undos.unsaved;
|
||||
|
||||
/*
|
||||
__autosaveElapsed += elapsed;
|
||||
if (__autosaveElapsed > 5) {
|
||||
// trace("some autosaves");
|
||||
__autosaveElapsed = 0;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public static var startTime:Float = 0;
|
||||
|
||||
@@ -118,7 +118,7 @@ class CharterStrumlineScreen extends UISubstateWindow {
|
||||
|
||||
hudXStepper = new UINumericStepper(hudScaleStepper.x + 80 - 32 + 26, hudScaleStepper.y, startingPos.x, 0.01, 2, 0, 2, 84);
|
||||
add(hudXStepper);
|
||||
addLabelOn(hudXStepper, "Hud Position (X,Y)");
|
||||
addLabelOn(hudXStepper, "Hud Position (X [Ratio 0-1],Y)");
|
||||
|
||||
add(new UIText(hudXStepper.x + 84 - 32 + 0, hudXStepper.y + 9, 0, ",", 22));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user