diff --git a/art/generateDoc.bat b/art/generateDoc.bat index 5159ca88..e2d35e4f 100644 --- a/art/generateDoc.bat +++ b/art/generateDoc.bat @@ -1,7 +1,8 @@ @ECHO OFF cd .. echo Building Game... -lime build windows --haxeflag="--macro include('scripting')" --haxeflag="-xml docs/doc.xml" -echo Generating Documentation... -haxelib run dox -i docs --include funkin --include scripting -echo Done! \ No newline at end of file +lime build windows --haxeflag="--macro include('scripting')" --haxeflag="-xml docs/doc.xml" -D DOCUMENTATION --no-output +echo art + +echo Generated the api xml file at docs/doc.xml +echo Please put this in FNF-CNE-Devs.github.io/api-generator/api/doc.xml \ No newline at end of file diff --git a/assets/data/scripts/pixel.hx b/assets/data/scripts/pixel.hx index 48dfb279..8f1887c8 100644 --- a/assets/data/scripts/pixel.hx +++ b/assets/data/scripts/pixel.hx @@ -1,3 +1,4 @@ +// import funkin.game.HudCamera; import funkin.backend.scripting.events.NoteHitEvent; diff --git a/assets/data/stages/school-evil.hx b/assets/data/stages/school-evil.hx index af086dab..c29dbeea 100644 --- a/assets/data/stages/school-evil.hx +++ b/assets/data/stages/school-evil.hx @@ -1,5 +1,4 @@ function create() { - importScript("data/scripts/pixel"); isSpooky = true; // Make transition work between school types diff --git a/assets/data/stages/school-evil.xml b/assets/data/stages/school-evil.xml index 568b3aad..48ee14b7 100644 --- a/assets/data/stages/school-evil.xml +++ b/assets/data/stages/school-evil.xml @@ -1,5 +1,6 @@ + \ No newline at end of file diff --git a/assets/data/stages/school.hx b/assets/data/stages/school.hx index 5cba9421..dc55a69d 100644 --- a/assets/data/stages/school.hx +++ b/assets/data/stages/school.hx @@ -1,5 +1,5 @@ +// function create() { - importScript("data/scripts/pixel"); if (PlayState.SONG.meta.name.toLowerCase() == "roses") { bgGirls.animation.remove("danceLeft"); bgGirls.animation.remove("danceRight"); diff --git a/assets/data/stages/school.xml b/assets/data/stages/school.xml index dabf463b..7a2740ad 100644 --- a/assets/data/stages/school.xml +++ b/assets/data/stages/school.xml @@ -1,5 +1,7 @@ + + diff --git a/source/funkin/game/Stage.hx b/source/funkin/game/Stage.hx index f42cc90e..4a9ac940 100644 --- a/source/funkin/game/Stage.hx +++ b/source/funkin/game/Stage.hx @@ -2,6 +2,7 @@ package funkin.game; import flixel.FlxState; import flixel.math.FlxPoint; +import funkin.backend.scripting.DummyScript; import funkin.backend.scripting.Script; import funkin.backend.scripting.events.StageNodeEvent; import funkin.backend.scripting.events.StageXMLEvent; @@ -18,6 +19,7 @@ class Stage extends FlxBasic implements IBeatReceiver { public var stageScript:Script; public var state:FlxState; public var characterPoses:Map = []; + public var xmlImportedScripts:Map = []; private var spritesParentFolder = ""; @@ -45,6 +47,7 @@ class Stage extends FlxBasic implements IBeatReceiver { stageScript.load(); } + var event = null; if (stageXML != null) { if (PlayState.instance != null) { var parsed:Null; @@ -68,8 +71,8 @@ class Stage extends FlxBasic implements IBeatReceiver { } if (PlayState.instance != null) { - var event = PlayState.instance.scripts.event("onStageXMLParsed", EventManager.get(StageXMLEvent).recycle(this, stageXML, elems)); - elems = event.elems; + event = EventManager.get(StageXMLEvent).recycle(this, stageXML, elems); + elems = PlayState.instance.scripts.event("onStageXMLParsed", event).elems; } for(node in elems) { @@ -86,7 +89,7 @@ class Stage extends FlxBasic implements IBeatReceiver { state.add(spr); spr; case "box" | "solid": - if ( !node.has.name || !node.has.width || !node.has.height) continue; + if (!node.has.name || !node.has.width || !node.has.height) continue; var spr = new FlxSprite( (node.has.x) ? Std.parseFloat(node.att.x).getDefault(0) : 0, @@ -134,6 +137,22 @@ class Stage extends FlxBasic implements IBeatReceiver { ); PlayState.instance.add(PlayState.instance.comboGroup); PlayState.instance.comboGroup; + case "use-extension" | "extension" | "ext": + if (!node.has.script || PlayState.instance == null) continue; + + var folder = node.getAtt("folder").getDefault("data/scripts/"); + if (!folder.endsWith("/")) folder += "/"; + + var path = Paths.script(folder + node.getAtt("script")); + var daScript = Script.create(path); + if (daScript is DummyScript) Logs.trace('Script at ${path} does not exist.', ERROR); + else { + xmlImportedScripts.set(path, node.getAtt("isShortLived") == "true"); + PlayState.instance.scripts.add(daScript); + daScript.load(); + } + + null; default: null; } @@ -173,8 +192,20 @@ class Stage extends FlxBasic implements IBeatReceiver { }); if (PlayState.instance == null) return; - for(k=>e in stageSprites) { + + for (k=>e in stageSprites) stageScript.set(k, e); + + // idk lemme check anyways just in case scripts did smth - Nex + if (event != null) PlayState.instance.scripts.event("onPostStageCreation", event); + + // shortlived scripts destroy when the stage finishes setting up - Nex + for (p=>b in xmlImportedScripts) if (b) { + var script = PlayState.instance.scripts.getByPath(p); + if (script == null) continue; + + PlayState.instance.scripts.remove(script); + script.destroy(); } } diff --git a/source/hscript/Config.hx b/source/hscript/Config.hx index dcfcc10e..98fc7f7a 100644 --- a/source/hscript/Config.hx +++ b/source/hscript/Config.hx @@ -3,19 +3,23 @@ package hscript; class Config { // Runs support for custom classes in these public static final ALLOWED_CUSTOM_CLASSES = [ + #if !DOCUMENTATION "flixel", "funkin", + #end ]; // Runs support for abstract support in these public static final ALLOWED_ABSTRACT_AND_ENUM = [ + #if !DOCUMENTATION "flixel", "openfl", "haxe.xml", "haxe.CallStack", "funkin", + #end ]; // Incase any of your files fail