From 25b563066fc53ac92ebe3064175c80b5f1ae64bc Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Wed, 6 Nov 2024 19:54:15 +0100 Subject: [PATCH 1/5] Allow hold notes to be forced deleted --- source/funkin/backend/scripting/events/NoteHitEvent.hx | 7 +++++++ source/funkin/game/PlayState.hx | 8 +++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/source/funkin/backend/scripting/events/NoteHitEvent.hx b/source/funkin/backend/scripting/events/NoteHitEvent.hx index 7a20fed0..256c4c9f 100644 --- a/source/funkin/backend/scripting/events/NoteHitEvent.hx +++ b/source/funkin/backend/scripting/events/NoteHitEvent.hx @@ -123,6 +123,13 @@ final class NoteHitEvent extends CancellableEvent { @:dox(hide) public function cancelDeletion() {preventDeletion();} + /** + * Forces the note to be deleted. + **/ + public function forceDeletion() { + deleteNote = true; + } + /** * Prevents the vocals volume from being set to 1 after pressing the note. */ diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 77e39ca9..dbdb4392 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -1645,9 +1645,11 @@ class PlayState extends MusicBeatState var event:NoteHitEvent; if (strumLine != null && !strumLine.cpu) - event = scripts.event("onPlayerHit", EventManager.get(NoteHitEvent).recycle(false, !note.isSustainNote, !note.isSustainNote, note, strumLine.characters, true, note.noteType, note.animSuffix.getDefault(note.strumID < strumLine.members.length ? strumLine.members[note.strumID].animSuffix : strumLine.animSuffix), "game/score/", "", note.strumID, score, note.isSustainNote ? null : accuracy, 0.023, daRating, Options.splashesEnabled && !note.isSustainNote && daRating == "sick")); + event = EventManager.get(NoteHitEvent).recycle(false, !note.isSustainNote, !note.isSustainNote, note, strumLine.characters, true, note.noteType, note.animSuffix.getDefault(note.strumID < strumLine.members.length ? strumLine.members[note.strumID].animSuffix : strumLine.animSuffix), "game/score/", "", note.strumID, score, note.isSustainNote ? null : accuracy, 0.023, daRating, Options.splashesEnabled && !note.isSustainNote && daRating == "sick"); else - event = scripts.event("onDadHit", EventManager.get(NoteHitEvent).recycle(false, false, false, note, strumLine.characters, false, note.noteType, note.animSuffix.getDefault(note.strumID < strumLine.members.length ? strumLine.members[note.strumID].animSuffix : strumLine.animSuffix), "game/score/", "", note.strumID, 0, null, 0, daRating, false)); + event = EventManager.get(NoteHitEvent).recycle(false, false, false, note, strumLine.characters, false, note.noteType, note.animSuffix.getDefault(note.strumID < strumLine.members.length ? strumLine.members[note.strumID].animSuffix : strumLine.animSuffix), "game/score/", "", note.strumID, 0, null, 0, daRating, false); + event.deleteNote = !note.isSustainNote; // work around, to allow sustain notes to be deleted + event = scripts.event(strumLine != null && !strumLine.cpu ? "onPlayerHit" : "onDadHit", event); strumLine.onHit.dispatch(event); scripts.event("onNoteHit", event); @@ -1694,7 +1696,7 @@ class PlayState extends MusicBeatState } } - if (event.deleteNote && !note.isSustainNote) strumLine.deleteNote(note); + if (event.deleteNote) strumLine.deleteNote(note); } public function displayRating(myRating:String, ?evt:NoteHitEvent = null):Void { From 3de3c3f8286b2b07c9690334e2d85ce052a909c5 Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Fri, 8 Nov 2024 18:04:05 +0100 Subject: [PATCH 2/5] Allow tweening arrays and shaders Ignore the contents of this, its just to make it redownload flixel --- .../funkin/backend/system/framerate/FlixelInfo.hx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/source/funkin/backend/system/framerate/FlixelInfo.hx b/source/funkin/backend/system/framerate/FlixelInfo.hx index 259b7f8f..297fcde7 100644 --- a/source/funkin/backend/system/framerate/FlixelInfo.hx +++ b/source/funkin/backend/system/framerate/FlixelInfo.hx @@ -1,5 +1,7 @@ package funkin.backend.system.framerate; +import funkin.backend.scripting.ModState; + class FlixelInfo extends FramerateCategory { public function new() { super("Flixel Info"); @@ -14,7 +16,12 @@ class FlixelInfo extends FramerateCategory { for(_ in FlxG.bitmap._cache.keys()) c++; - _text = 'State: ${Type.getClassName(Type.getClass(FlxG.state))}'; + if((FlxG.state is ModState)) { + var state:ModState = cast FlxG.state; + _text = "Mod State: " + state.scriptName; + } else { + _text = 'State: ${Type.getClassName(Type.getClass(FlxG.state))}'; + } _text += '\nObject Count: ${FlxG.state.members.length}'; _text += '\nCamera Count: ${FlxG.cameras.list.length}'; _text += '\nBitmaps Count: ${c}'; @@ -22,9 +29,9 @@ class FlixelInfo extends FramerateCategory { _text += '\nFlxG.game Childs Count: ${FlxG.game.numChildren}'; // _text += '\nCached objects count: ${cachedObjects}'; #if FLX_POINT_POOL - var points = flixel.math.FlxPoint.FlxBasePoint.pool; + //var points = flixel.math.FlxPoint.FlxBasePoint.pool; //_text += '\nPoint Count: ${points._count} | +${points.made} | -${points.gotten} | ${points.balance} | >${points.putted}'; - _text += '\nPoint Count: ${points._count}'; + //_text += '\nPoint Count: ${points._count}'; #end } From f54c485d0c7cec1799a0a1a7921e2ff16ed35028 Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Fri, 8 Nov 2024 23:49:52 +0100 Subject: [PATCH 3/5] Important rendering bug fix + optimizations --- source/funkin/backend/system/updating/AsyncUpdater.hx | 2 +- source/funkin/editors/charter/Charter.hx | 2 +- source/funkin/editors/charter/CharterBackdropGroup.hx | 2 +- source/funkin/editors/ui/UISprite.hx | 2 +- source/funkin/game/Note.hx | 7 +++++-- source/funkin/game/Strum.hx | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/source/funkin/backend/system/updating/AsyncUpdater.hx b/source/funkin/backend/system/updating/AsyncUpdater.hx index af7cfff5..e742e92d 100644 --- a/source/funkin/backend/system/updating/AsyncUpdater.hx +++ b/source/funkin/backend/system/updating/AsyncUpdater.hx @@ -101,7 +101,7 @@ class AsyncUpdater { progress.files = files.length; progress.step = DOWNLOADING_ASSETS; trace('starting assets download'); - doFile([for(e in files) e], [for(e in fileNames) e], function() { + doFile(files.copy(), fileNames.copy(), function() { progress.curFile = -1; progress.curFileName = null; progress.files = 1; diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 2ff39aa0..99f6f690 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -1657,7 +1657,7 @@ class Charter extends UIState { changeNoteSustain(-1); function _note_selectall(_) { - selection = [for (note in notesGroup.members) note]; + selection = cast notesGroup.members.copy(); } function _note_selectmeasure(_) { diff --git a/source/funkin/editors/charter/CharterBackdropGroup.hx b/source/funkin/editors/charter/CharterBackdropGroup.hx index e9240ad1..21eeb90f 100644 --- a/source/funkin/editors/charter/CharterBackdropGroup.hx +++ b/source/funkin/editors/charter/CharterBackdropGroup.hx @@ -253,7 +253,7 @@ class CharterBackdropDummy extends UISprite { public override function draw() { @:privateAccess - __lastDrawCameras = [for(c in cameras) c]; + __lastDrawCameras = cameras.copy(); } } diff --git a/source/funkin/editors/ui/UISprite.hx b/source/funkin/editors/ui/UISprite.hx index 5a41cec3..1246e6de 100644 --- a/source/funkin/editors/ui/UISprite.hx +++ b/source/funkin/editors/ui/UISprite.hx @@ -69,7 +69,7 @@ class UISprite extends FlxSprite { public function drawSuper() { super.draw(); - __lastDrawCameras = [for(c in cameras) c]; + __lastDrawCameras = cameras.copy(); } public function drawMembers() { diff --git a/source/funkin/game/Note.hx b/source/funkin/game/Note.hx index b8baf48e..9b06fc81 100644 --- a/source/funkin/game/Note.hx +++ b/source/funkin/game/Note.hx @@ -98,6 +98,9 @@ class Note extends FlxSprite return __customNoteTypeExists[path]; return __customNoteTypeExists[path] = Assets.exists(path); } + + static var DEFAULT_FIELDS:Array = ["time", "id", "type", "sLen"]; + public function new(strumLine:StrumLine, noteData:ChartNote, sustain:Bool = false, sustainLength:Float = 0, sustainOffset:Float = 0, ?prev:Note) { super(); @@ -115,7 +118,7 @@ class Note extends FlxSprite this.sustainLength = sustainLength; this.strumLine = strumLine; for(field in Reflect.fields(noteData)) { - if(!["time", "id", "type", "sLen"].contains(field)) { + if(!DEFAULT_FIELDS.contains(field)) { this.extra.set(field, Reflect.field(noteData, field)); } } @@ -290,7 +293,7 @@ class Note extends FlxSprite setClipRect(swagRect); } - public function setClipRect(rect:FlxRect) { + public inline function setClipRect(rect:FlxRect) { this.clipRect = rect; } diff --git a/source/funkin/game/Strum.hx b/source/funkin/game/Strum.hx index e2b6ccd0..cbce2da4 100644 --- a/source/funkin/game/Strum.hx +++ b/source/funkin/game/Strum.hx @@ -74,7 +74,7 @@ class Strum extends FlxSprite { } public override function draw() { - lastDrawCameras = [for(c in cameras) c]; + lastDrawCameras = cameras.copy(); super.draw(); } From 74ce1756dc7e41b9273df33077fced1c9b9bdbed Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Sat, 9 Nov 2024 00:58:00 +0100 Subject: [PATCH 4/5] Fixed hashlink? I cant test on mac since FATAL ERROR : Failed to load library ssl.hdll and with define no_ssl IMUL(stack,cpu) JIT ERROR 0 (jit.c line 613) --- project.xml | 2 +- source/funkin/backend/system/github/GitHub.hx | 2 +- .../backend/system/macros/HashLinkFixer.hx | 91 +++++++++---------- source/funkin/backend/utils/DiscordUtil.hx | 4 +- 4 files changed, 47 insertions(+), 52 deletions(-) diff --git a/project.xml b/project.xml index 9b396fa7..6f01bc10 100644 --- a/project.xml +++ b/project.xml @@ -134,7 +134,7 @@ - + diff --git a/source/funkin/backend/system/github/GitHub.hx b/source/funkin/backend/system/github/GitHub.hx index 27ba825b..6a100f18 100644 --- a/source/funkin/backend/system/github/GitHub.hx +++ b/source/funkin/backend/system/github/GitHub.hx @@ -2,8 +2,8 @@ package funkin.backend.system.github; #if GITHUB_API import haxe.Json; -import haxe.Exception; #end +import haxe.Exception; // TODO: Document further and perhaps make this a Haxelib. class GitHub { diff --git a/source/funkin/backend/system/macros/HashLinkFixer.hx b/source/funkin/backend/system/macros/HashLinkFixer.hx index 046929e8..697d3c01 100644 --- a/source/funkin/backend/system/macros/HashLinkFixer.hx +++ b/source/funkin/backend/system/macros/HashLinkFixer.hx @@ -42,26 +42,12 @@ class HashLinkFixer { var cl = clRef.get(); if (cl.isAbstract || cl.isExtern || cl.isInterface) return fields; - if (!cl.name.endsWith("_Impl_") && !cl.name.endsWith("_HSX") && !cl.name.endsWith("_HSC") && !cl.name.endsWith("_HLFHelper")) { - var metas = cl.meta.get(); - + if (!cl.name.endsWith("_Impl_") && !cl.name.endsWith("_HSX") && !cl.name.endsWith("_HSC")) { if(cl.params.length > 0) return fields; - if(cl.module == "EReg") return fields; // private typedef in same class - if(cl.module == "hl.Format") return fields; // enum in same class - var definedFields = []; - var helperClass = macro class { - - }; - - helperClass.pos = cl.pos; - - var module = cl.module + "_HLFHelper"; - var hcClassName = cl.name + "_HLFHelper"; - for(f in fields.copy()) { if (f == null) continue; @@ -70,10 +56,12 @@ class HashLinkFixer { if(definedFields.contains(f.name)) continue; // no duplicate fields + var hlNativeMeta = null; var hasHlNative = false; for(m in f.meta) if (m.name == ":hlNative") { hasHlNative = true; + hlNativeMeta = m; break; } @@ -92,16 +80,39 @@ class HashLinkFixer { var overrideExpr:Expr; var returns:Bool = !fun.ret.match(TPath({name: "Void"})); + var printer = new haxe.macro.Printer(); + if(cl.module == "hl.Gc" && fun.ret == null) returns = false; // fix since they dont explicitly set :Void + if(cl.module == "hl.Format" && fun.ret == null) returns = false; // fix since they dont explicitly set :Void + var name = 'hlf_${f.name}'; var arguments = fun.args == null ? [] : [for(a in fun.args) macro $i{a.name}]; - var funcExpr:Expr = returns ? { - //macro return $i{name}($a{arguments}); - macro return @:privateAccess $i{hcClassName}.$name($a{arguments}); - } : { - macro @:privateAccess $i{hcClassName}.$name($a{arguments}); - }; + var funcExpr:Expr = macro @:privateAccess $i{name}($a{arguments}); + if(returns) funcExpr = macro return $funcExpr; + + var cleanMeta = f.meta.copy().filter(function(m) return m.name != ":hlNative"); + var hasBareMeta = hlNativeMeta.params.length == 0; + + var meta = f.meta.copy(); + switch hlNativeMeta { + case {params: []}: + meta = [{name: ":hlNative", params: [macro "std", macro $v{f.name}], pos: Context.currentPos()}].concat(cleanMeta); + case {params: [_.expr => EConst(CString(name))]}: + meta = [{name: ":hlNative", params: [macro "std", macro $v{name}], pos: Context.currentPos()}].concat(cleanMeta); + case {params: [_.expr => EConst(CFloat(version))]}: + var curVersion = Context.definedValue("hl_ver"); + if(curVersion == null) curVersion = ""; + if(version > curVersion) { + meta = cleanMeta; + if(f.meta.filter((m) -> m.name == ":noExpr").length > 0) + Context.error("Missing function body", f.pos); + funcExpr = fun.expr; // restore to default behaviour + } else { + meta = [{name: ":hlNative", params: [macro "std", macro $v{f.name}], pos: Context.currentPos()}].concat(cleanMeta); + } + default: + } var fiel:Field = { name: name, @@ -109,50 +120,32 @@ class HashLinkFixer { kind: FFun({ ret: fun.ret, params: fun.params.copy(), - expr: fun.expr, + expr: funcExpr, args: fun.args.copy() }), - access: f.access.copy(), - meta: f.meta.copy() + access: f.access.copy().filter(function(a) return a != APublic && a != APrivate).concat([APrivate]), + meta: meta }; - helperClass.fields.push(fiel); + fields.push(fiel); definedFields.push(f.name); + // Remove meta from original function for(m in f.meta.copy()) if (m.name == ":hlNative") { f.meta.remove(m); } - fun.expr = funcExpr; default: } } - helperClass.pack = cl.pack.copy(); - helperClass.pos = cl.pos; - helperClass.name = hcClassName; - - if(definedFields.length > 0) { + /*if(definedFields.length > 0) { trace(cl.module); - /*for(m in metas.copy()) { - trace(" " + m.name); - if(m.name == ":coreApi") { - metas.remove(m); - } - }*/ - - var imports = Context.getLocalImports().copy(); - Context.defineModule(module, [helperClass], imports); - - Context.getLocalImports().push({ - path: [for(m in module.split(".")) { - name: m, - pos: Context.currentPos() - }], - mode: INormal - }); - } + var printer = new haxe.macro.Printer(); + for(field in fields) if(field.name.startsWith("hlf_")) + Sys.println(printer.printField(field)); + }*/ } return fields; diff --git a/source/funkin/backend/utils/DiscordUtil.hx b/source/funkin/backend/utils/DiscordUtil.hx index a4c63f4f..c453a234 100644 --- a/source/funkin/backend/utils/DiscordUtil.hx +++ b/source/funkin/backend/utils/DiscordUtil.hx @@ -165,6 +165,7 @@ class DiscordUtil #end } + #if cpp @:noCompletion public static function fixString(str:String) { return new cpp.ConstCharStar(cast(str, String)); @@ -174,6 +175,7 @@ class DiscordUtil { return cast(str, String); } + #end public static function changePresenceAdvanced(data:DPresence) { @@ -469,7 +471,7 @@ typedef DPresence = var ?matchSecret:String; /* max 128 bytes */ var ?joinSecret:String; /* max 128 bytes */ var ?spectateSecret:String; /* max 128 bytes */ - var ?instance:OneOfTwo; + var ?instance:#if cpp OneOfTwo #else Int #end; var ?button1Label:String; /* max 32 bytes */ var ?button1Url:String; /* max 512 bytes */ var ?button2Label:String; /* max 32 bytes */ From 24ec000dfd32513756b29c35386bc2ab09ac9661 Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Sat, 9 Nov 2024 01:04:33 +0100 Subject: [PATCH 5/5] Fix activity type --- source/funkin/backend/utils/DiscordUtil.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/backend/utils/DiscordUtil.hx b/source/funkin/backend/utils/DiscordUtil.hx index 0ea8e5b3..8eb17bf2 100644 --- a/source/funkin/backend/utils/DiscordUtil.hx +++ b/source/funkin/backend/utils/DiscordUtil.hx @@ -525,7 +525,7 @@ typedef DPresence = var ?button1Url:String; /* max 512 bytes */ var ?button2Label:String; /* max 32 bytes */ var ?button2Url:String; /* max 512 bytes */ - var ?activityType:ActivityType; + var ?activityType:#if DISCORD_RPC ActivityType #else Dynamic #end; var ?streamUrl:String; /* max 512 bytes */ }