From 53c77466f5a09ce89913f38aec1859bd44dfb10a Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Mon, 16 Sep 2024 00:59:41 +0200 Subject: [PATCH 1/8] Added util function for shaders --- source/funkin/backend/shaders/FunkinShader.hx | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/source/funkin/backend/shaders/FunkinShader.hx b/source/funkin/backend/shaders/FunkinShader.hx index b676ae45..451afecd 100644 --- a/source/funkin/backend/shaders/FunkinShader.hx +++ b/source/funkin/backend/shaders/FunkinShader.hx @@ -438,29 +438,46 @@ uniform sampler2D bitmap; uniform bool hasTransform; uniform bool hasColorTransform; -vec4 flixel_texture2D(sampler2D bitmap, vec2 coord) -{ +vec4 flixel_texture2D(sampler2D bitmap, vec2 coord) { vec4 color = texture2D(bitmap, coord); - if (!hasTransform) - { + if (!hasTransform) { return color; } - if (color.a == 0.0) - { + if (color.a == 0.0) { return vec4(0.0, 0.0, 0.0, 0.0); } - if (!hasColorTransform) - { + if (!hasColorTransform) { return color * openfl_Alphav; } color = vec4(color.rgb / color.a, color.a); color = clamp(openfl_ColorOffsetv + (color * openfl_ColorMultiplierv), 0.0, 1.0); - if (color.a > 0.0) - { + if (color.a > 0.0) { + return vec4(color.rgb * color.a * openfl_Alphav, color.a * openfl_Alphav); + } + return vec4(0.0, 0.0, 0.0, 0.0); +} + +vec4 applyFlixelEffects(vec4 color) { + if (!hasTransform) { + return color; + } + + if (color.a == 0.0) { + return vec4(0.0, 0.0, 0.0, 0.0); + } + + if (!hasColorTransform) { + return color * openfl_Alphav; + } + + color = vec4(color.rgb / color.a, color.a); + color = clamp(openfl_ColorOffsetv + (color * openfl_ColorMultiplierv), 0.0, 1.0); + + if (color.a > 0.0) { return vec4(color.rgb * color.a * openfl_Alphav, color.a * openfl_Alphav); } return vec4(0.0, 0.0, 0.0, 0.0); From b2f0060558d75efa222a73453f4d13ac36c0cf76 Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Mon, 16 Sep 2024 01:10:36 +0200 Subject: [PATCH 2/8] Cleanup! --- source/funkin/backend/shaders/FunkinShader.hx | 22 ++----------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/source/funkin/backend/shaders/FunkinShader.hx b/source/funkin/backend/shaders/FunkinShader.hx index 451afecd..b9ef4658 100644 --- a/source/funkin/backend/shaders/FunkinShader.hx +++ b/source/funkin/backend/shaders/FunkinShader.hx @@ -440,25 +440,7 @@ uniform bool hasColorTransform; vec4 flixel_texture2D(sampler2D bitmap, vec2 coord) { vec4 color = texture2D(bitmap, coord); - if (!hasTransform) { - return color; - } - - if (color.a == 0.0) { - return vec4(0.0, 0.0, 0.0, 0.0); - } - - if (!hasColorTransform) { - return color * openfl_Alphav; - } - - color = vec4(color.rgb / color.a, color.a); - color = clamp(openfl_ColorOffsetv + (color * openfl_ColorMultiplierv), 0.0, 1.0); - - if (color.a > 0.0) { - return vec4(color.rgb * color.a * openfl_Alphav, color.a * openfl_Alphav); - } - return vec4(0.0, 0.0, 0.0, 0.0); + return applyFlixelEffects(color); } vec4 applyFlixelEffects(vec4 color) { @@ -474,7 +456,7 @@ vec4 applyFlixelEffects(vec4 color) { return color * openfl_Alphav; } - color = vec4(color.rgb / color.a, color.a); + color.rgb = color.rgb / color.a; color = clamp(openfl_ColorOffsetv + (color * openfl_ColorMultiplierv), 0.0, 1.0); if (color.a > 0.0) { From ff4c1491c16f5ea91dd138220220027896fa632a Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Tue, 17 Sep 2024 23:01:28 +0200 Subject: [PATCH 3/8] Small changes for documentation --- art/generateDoc.bat | 9 +++++---- source/hscript/Config.hx | 4 ++++ 2 files changed, 9 insertions(+), 4 deletions(-) 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/source/hscript/Config.hx b/source/hscript/Config.hx index d12ccb5f..d0667ab9 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 From 38f6e8676c36130a1a071e90ee1888244f8a405c Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Wed, 18 Sep 2024 15:42:35 +0200 Subject: [PATCH 4/8] Added more memory types --- source/funkin/backend/utils/MemoryUtil.hx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/source/funkin/backend/utils/MemoryUtil.hx b/source/funkin/backend/utils/MemoryUtil.hx index 85f7d145..ac807088 100644 --- a/source/funkin/backend/utils/MemoryUtil.hx +++ b/source/funkin/backend/utils/MemoryUtil.hx @@ -117,7 +117,17 @@ class MemoryUtil { 22 => "DDR2 FB-DIMM", 24 => "DDR3", 25 => "FBD2", - 26 => "DDR4" + 26 => "DDR4", + 27 => "LPDDR", + 28 => "LPDDR2", + 29 => "LPDDR3", + 30 => "LPDDR4", + 31 => "Logical Non-volatile device", + 32 => "HBM", + 33 => "HBM2", + 34 => "DDR5", + 35 => "LPDDR5", + 36 => "HBM3", ]; var memoryOutput:Int = -1; From 032c3a174f68aedd58760a100f2ce6b6e29dd9f0 Mon Sep 17 00:00:00 2001 From: TheZoroForce240 <86524550+TheZoroForce240@users.noreply.github.com> Date: Fri, 30 Aug 2024 11:49:40 +0100 Subject: [PATCH 5/8] splash show event --- .../scripting/events/SplashShowEvent.hx | 23 +++++++++++++++++++ source/funkin/game/SplashHandler.hx | 6 +++-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 source/funkin/backend/scripting/events/SplashShowEvent.hx diff --git a/source/funkin/backend/scripting/events/SplashShowEvent.hx b/source/funkin/backend/scripting/events/SplashShowEvent.hx new file mode 100644 index 00000000..46504d44 --- /dev/null +++ b/source/funkin/backend/scripting/events/SplashShowEvent.hx @@ -0,0 +1,23 @@ +package funkin.backend.scripting.events; + +import funkin.game.SplashGroup; +import funkin.game.Strum; + +final class SplashShowEvent extends CancellableEvent { + /** + Splash name/type + **/ + public var splashName:String; + /** + Splash that is shown + **/ + public var splash:FunkinSprite; + /** + Strum that the splash is shown on + **/ + public var strum:Strum; + /** + Splash group that the splash is from + **/ + public var group:SplashGroup; +} \ No newline at end of file diff --git a/source/funkin/game/SplashHandler.hx b/source/funkin/game/SplashHandler.hx index 1776bdb8..31a06234 100644 --- a/source/funkin/game/SplashHandler.hx +++ b/source/funkin/game/SplashHandler.hx @@ -1,5 +1,7 @@ package funkin.game; +import funkin.backend.scripting.events.SplashShowEvent; + class SplashHandler extends FlxTypedGroup { /** * Map containing all of the splashes group. @@ -40,10 +42,10 @@ class SplashHandler extends FlxTypedGroup { var __grp:SplashGroup; public function showSplash(name:String, strum:Strum) { __grp = getSplashGroup(name); - var event = funkin.backend.scripting.EventManager.get(funkin.backend.scripting.events.DynamicEvent).recycle(__grp.showOnStrum(strum), strum); + var event = EventManager.get(SplashShowEvent).recycle(name, __grp.showOnStrum(strum), strum, __grp); event = PlayState.instance.scripts.event("onSplashShown", event); if (!event.cancelled) - add(event.value1); + add(event.splash); // max 8 rendered splashes while(members.length > 8) From 71160f188e0abab627308547ccbf75eecd24a2fd Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Wed, 18 Sep 2024 16:09:56 +0200 Subject: [PATCH 6/8] hide UI Debug State in release --- source/funkin/editors/EditorPicker.hx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/funkin/editors/EditorPicker.hx b/source/funkin/editors/EditorPicker.hx index 8a2ebd89..50a93453 100644 --- a/source/funkin/editors/EditorPicker.hx +++ b/source/funkin/editors/EditorPicker.hx @@ -22,11 +22,13 @@ class EditorPicker extends MusicBeatSubstate { iconID: 2, state: null }, + #if debug { name: "UI Debug State", iconID: 3, state: UIDebugState }, + #end { name: "Debug Options", iconID: 4, From 15a18bb3daf21c920266afee968e55e0325458ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Wed, 18 Sep 2024 16:10:19 +0200 Subject: [PATCH 7/8] importable scripts through stage.xml + new call extensions feature --- assets/data/scripts/pixel.hx | 1 + assets/data/stages/school-evil.hx | 1 - assets/data/stages/school-evil.xml | 1 + assets/data/stages/school.hx | 2 +- assets/data/stages/school.xml | 2 ++ source/funkin/game/Stage.hx | 36 ++++++++++++++++++++++++++---- 6 files changed, 37 insertions(+), 6 deletions(-) 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 af36d445..10168945 100644 --- a/source/funkin/game/Stage.hx +++ b/source/funkin/game/Stage.hx @@ -6,6 +6,7 @@ import flixel.math.FlxPoint; import flixel.FlxState; import haxe.xml.Access; import funkin.backend.system.interfaces.IBeatReceiver; +import funkin.backend.scripting.DummyScript; import funkin.backend.scripting.Script; import haxe.io.Path; @@ -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 = folder + node.getAtt("script"); + var daScript = Script.create(Paths.script(path)); + if (daScript is DummyScript) throw 'Script at ${path} does not exist.'; + else { + xmlImportedScripts.set(daScript, node.getAtt("isShortLived") == "true"); + PlayState.instance.scripts.add(daScript); + daScript.load(); + } + + null; default: null; } @@ -173,8 +192,17 @@ 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 (s=>b in xmlImportedScripts) if (b) { + PlayState.instance.scripts.remove(s); + s.destroy(); } } From a296991259197d54ba9ec56c35cc763108695ae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Wed, 18 Sep 2024 17:04:47 +0200 Subject: [PATCH 8/8] wait this is safer --- source/funkin/game/Stage.hx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/source/funkin/game/Stage.hx b/source/funkin/game/Stage.hx index 10168945..bcfef901 100644 --- a/source/funkin/game/Stage.hx +++ b/source/funkin/game/Stage.hx @@ -19,7 +19,7 @@ class Stage extends FlxBasic implements IBeatReceiver { public var stageScript:Script; public var state:FlxState; public var characterPoses:Map = []; - public var xmlImportedScripts:Map = []; + public var xmlImportedScripts:Map = []; private var spritesParentFolder = ""; @@ -143,11 +143,11 @@ class Stage extends FlxBasic implements IBeatReceiver { var folder = node.getAtt("folder").getDefault("data/scripts/"); if (!folder.endsWith("/")) folder += "/"; - var path = folder + node.getAtt("script"); - var daScript = Script.create(Paths.script(path)); - if (daScript is DummyScript) throw 'Script at ${path} does not exist.'; + 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(daScript, node.getAtt("isShortLived") == "true"); + xmlImportedScripts.set(path, node.getAtt("isShortLived") == "true"); PlayState.instance.scripts.add(daScript); daScript.load(); } @@ -200,9 +200,12 @@ class Stage extends FlxBasic implements IBeatReceiver { if (event != null) PlayState.instance.scripts.event("onPostStageCreation", event); // shortlived scripts destroy when the stage finishes setting up - Nex - for (s=>b in xmlImportedScripts) if (b) { - PlayState.instance.scripts.remove(s); - s.destroy(); + 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(); } }