From 48758c8176fdc531a7831a2d6dbc9f7d751eb809 Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Mon, 2 Sep 2024 19:00:16 +0200 Subject: [PATCH 01/17] Fix camera pausing + Fixes #317 --- assets/data/scripts/pixel.hx | 6 ++++-- assets/data/scripts/week6-pause.hx | 3 ++- source/funkin/backend/utils/FunkinParentDisabler.hx | 9 +++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/assets/data/scripts/pixel.hx b/assets/data/scripts/pixel.hx index cc8239cf..48dfb279 100644 --- a/assets/data/scripts/pixel.hx +++ b/assets/data/scripts/pixel.hx @@ -162,16 +162,18 @@ function postUpdate(elapsed) { if (enableCameraHacks) { for(p in strumLines) p.notes.forEach(function(n) { + if(n.isSustainNote) return; // hacky fix for hold n.y -= n.y % daPixelZoom; n.x -= n.x % daPixelZoom; }); } + var zoom = 1 / daPixelZoom / Math.min(FlxG.scaleMode.scale.x, FlxG.scaleMode.scale.y); for(e in pixellyCameras) { if (!e.exists) continue; - e.zoom = 1 / daPixelZoom / Math.min(FlxG.scaleMode.scale.x, FlxG.scaleMode.scale.y); + e.zoom = zoom; } for(e in pixellyShaders) { - e.pixelZoom = 1 / daPixelZoom / Math.min(FlxG.scaleMode.scale.x, FlxG.scaleMode.scale.y); + e.pixelZoom = zoom; } } \ No newline at end of file diff --git a/assets/data/scripts/week6-pause.hx b/assets/data/scripts/week6-pause.hx index b382af35..6a4455cd 100644 --- a/assets/data/scripts/week6-pause.hx +++ b/assets/data/scripts/week6-pause.hx @@ -73,7 +73,8 @@ function confText(text) { } function destroy() { - FlxG.cameras.remove(pauseCam); + if(FlxG.cameras.list.contains(pauseCam)) + FlxG.cameras.remove(pauseCam); } var canDoShit = true; diff --git a/source/funkin/backend/utils/FunkinParentDisabler.hx b/source/funkin/backend/utils/FunkinParentDisabler.hx index f0617f5d..29e076be 100644 --- a/source/funkin/backend/utils/FunkinParentDisabler.hx +++ b/source/funkin/backend/utils/FunkinParentDisabler.hx @@ -32,8 +32,8 @@ class FunkinParentDisabler extends FlxBasic { FlxTimer.globalManager._timers = []; // cameras - __cameras = [for(c in FlxG.cameras.list) if (c.active) c]; - for(c in __cameras) c.active = false; + __cameras = [for(c in FlxG.cameras.list) if (!c.paused) c]; + for(c in __cameras) c.paused = true; // sounds __sounds = [for(s in FlxG.sound.list) if (s.playing) s]; @@ -41,9 +41,6 @@ class FunkinParentDisabler extends FlxBasic { } } - public override function update(elapsed:Float) { - @:privateAccess for(c in __cameras) c.updateFlashSpritePosition(); - } public override function draw() {} public function reset() { @@ -63,7 +60,7 @@ class FunkinParentDisabler extends FlxBasic { for(t in __tweens) FlxTween.globalManager._tweens.push(t); for(t in __timers) FlxTimer.globalManager._timers.push(t); } - for(c in __cameras) c.active = true; + for(c in __cameras) c.paused = false; for(s in __sounds) s.play(); } } From aa22bd6e1db79fe67d893135353e156036184d78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Mon, 2 Sep 2024 23:47:11 +0200 Subject: [PATCH 02/17] fixing stuff --- .../system/framerate/FramerateCounter.hx | 29 ++----------------- .../editors/charter/SongCreationScreen.hx | 8 +---- 2 files changed, 4 insertions(+), 33 deletions(-) diff --git a/source/funkin/backend/system/framerate/FramerateCounter.hx b/source/funkin/backend/system/framerate/FramerateCounter.hx index 5658bd2b..c5641ee3 100644 --- a/source/funkin/backend/system/framerate/FramerateCounter.hx +++ b/source/funkin/backend/system/framerate/FramerateCounter.hx @@ -1,28 +1,17 @@ package funkin.backend.system.framerate; -import haxe.ds.Vector; import openfl.display.Sprite; import openfl.text.TextField; import openfl.text.TextFormat; -inline final FRAME_TIME_HISTORY = 20; - class FramerateCounter extends Sprite { public var fpsNum:TextField; public var fpsLabel:TextField; - - public var fpsHistoryIndex:Int = 0; - public var fpsHistory:Vector; + public var lastFPS:Float = 0; public function new() { super(); - fpsHistory = new Vector(FRAME_TIME_HISTORY); - // Initialize to 60 FPS, so that the initial estimation until we get enough data is always reasonable. - for(i in 0...FRAME_TIME_HISTORY) { - fpsHistory[i] = 1000.0 / 60.0; - } - fpsNum = new TextField(); fpsLabel = new TextField(); @@ -43,20 +32,8 @@ class FramerateCounter extends Sprite { if (alpha <= 0.05) return; super.__enterFrame(t); - // todo use gpu time - fpsHistory[fpsHistoryIndex] = FlxG.elapsed * 1000; - fpsHistoryIndex = (fpsHistoryIndex + 1) % FRAME_TIME_HISTORY; - - // Calculate average CPU time. - // Code based on Godot's FPS counter. - var cpuTime = 0.0; - for(i in 0...FRAME_TIME_HISTORY) { - cpuTime += fpsHistory[i]; - } - cpuTime /= FRAME_TIME_HISTORY; - cpuTime = Math.max(0.01, cpuTime); // Prevent unrealistically low values. - - fpsNum.text = Std.string(Math.floor(1000.0 / cpuTime)); + lastFPS = CoolUtil.fpsLerp(lastFPS, FlxG.elapsed == 0 ? 0 : (1 / FlxG.elapsed), 0.25); + fpsNum.text = Std.string(Math.floor(lastFPS)); fpsLabel.x = fpsNum.x + fpsNum.width; fpsLabel.y = (fpsNum.y + fpsNum.height) - fpsLabel.height; } diff --git a/source/funkin/editors/charter/SongCreationScreen.hx b/source/funkin/editors/charter/SongCreationScreen.hx index 7915cae0..80549cf7 100644 --- a/source/funkin/editors/charter/SongCreationScreen.hx +++ b/source/funkin/editors/charter/SongCreationScreen.hx @@ -80,8 +80,6 @@ class SongCreationScreen extends UISubstateWindow { stepsPerBeatStepper = new UINumericStepper(beatsPerMeasureStepper.x + 30 + 24, beatsPerMeasureStepper.y, 4, 1, 0, 1, null, 54); songDataGroup.add(stepsPerBeatStepper); - var voicesUIText:UIText = null; - instExplorer = new UIFileExplorer(songNameTextBox.x, songNameTextBox.y + 32 + 36, null, null, Paths.SOUND_EXT, function (res) { var audioPlayer:UIAudioPlayer = new UIAudioPlayer(instExplorer.x + 8, instExplorer.y + 8, res); instExplorer.members.push(audioPlayer); @@ -98,11 +96,7 @@ class SongCreationScreen extends UISubstateWindow { voicesExplorer.uiElement = audioPlayer; }); songDataGroup.add(voicesExplorer); - - voicesUIText = addLabelOn(voicesExplorer, "Vocal Audio File"); - voicesUIText.applyMarkup( - "Vocal Audio File $* Required$", - [new FlxTextFormatMarkerPair(new FlxTextFormat(0xFFAD1212), "$")]); + addLabelOn(voicesExplorer, "Vocal Audio File"); var menuTitle:UIText; menuDataGroup.add(menuTitle = new UIText(windowSpr.x + 20, windowSpr.y + 30 + 16, 0, "Menus Data (Freeplay/Story)", 28)); From 669645ed47fa6f12ab3d507f0bd3acea24ab08f7 Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Tue, 3 Sep 2024 15:28:46 +0200 Subject: [PATCH 03/17] Enabled Optimizations --- project.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/project.xml b/project.xml index 232f6159..f8848e03 100644 --- a/project.xml +++ b/project.xml @@ -150,6 +150,8 @@ + + From 623ac099504758bc4d040eb3e9d435209a476dfd Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Wed, 4 Sep 2024 12:25:19 +0200 Subject: [PATCH 04/17] Better limit --- source/funkin/game/StrumLine.hx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/funkin/game/StrumLine.hx b/source/funkin/game/StrumLine.hx index dd952d19..763210f8 100644 --- a/source/funkin/game/StrumLine.hx +++ b/source/funkin/game/StrumLine.hx @@ -152,7 +152,8 @@ class StrumLine extends FlxTypedGroup { var scrollSpeed = strumLine.scrollSpeed; if(scrollSpeed == null) if (PlayState.instance != null) scrollSpeed = PlayState.instance.scrollSpeed; if(scrollSpeed == null) scrollSpeed = 1; - notes.limit = 1500 / scrollSpeed; + var limit = FlxG.height / 0.45; + notes.limit = limit / scrollSpeed; } public override function update(elapsed:Float) { From b265b0abd54d6f7124151cb2c3c391812d458f49 Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Wed, 4 Sep 2024 14:00:39 +0200 Subject: [PATCH 05/17] Small cleanup --- source/funkin/game/PlayState.hx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index dcc205cd..8699b92e 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -653,10 +653,12 @@ class PlayState extends MusicBeatState chars.push(char); } - var strOffset:Float = strumLine.strumLinePos == null ? (strumLine.type == 1 ? 0.75 : 0.25) : strumLine.strumLinePos; - var startingPos:FlxPoint = strumLine.strumPos == null ? - FlxPoint.get((FlxG.width * strOffset) - ((Note.swagWidth * (strumLine.strumScale == null ? 1 : strumLine.strumScale)) * 2), this.strumLine.y) : - FlxPoint.get(strumLine.strumPos[0] == 0 ? ((FlxG.width * strOffset) - ((Note.swagWidth * (strumLine.strumScale == null ? 1 : strumLine.strumScale)) * 2)) : strumLine.strumPos[0], strumLine.strumPos[1]); + var strOffset:Float = strumLine.strumLinePos != null ? strumLine.strumLinePos : (strumLine.type == 1 ? 0.75 : 0.25); + var strScale:Float = strumLine.strumScale != null ? strumLine.strumScale : 1; + var strXPos:Float = (FlxG.width * strOffset) - (Note.swagWidth * strScale * 2); + var startingPos:FlxPoint = strumLine.strumPos != null ? + FlxPoint.get(strumLine.strumPos[0] == 0 ? strXPos : strumLine.strumPos[0], strumLine.strumPos[1]) : + FlxPoint.get(strXPos, this.strumLine.y); var strLine = new StrumLine(chars, startingPos, strumLine.strumScale == null ? 1 : strumLine.strumScale, From 16fa3046e2ad69164e7ee2c0ef0826884a54dbe2 Mon Sep 17 00:00:00 2001 From: FourLion4L <109489041+FourLion4L@users.noreply.github.com> Date: Fri, 6 Sep 2024 13:48:32 +0300 Subject: [PATCH 06/17] CoolUtil openURL fix for Linux users (#378) --- source/funkin/backend/utils/CoolUtil.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/funkin/backend/utils/CoolUtil.hx b/source/funkin/backend/utils/CoolUtil.hx index e624a566..70feb55f 100644 --- a/source/funkin/backend/utils/CoolUtil.hx +++ b/source/funkin/backend/utils/CoolUtil.hx @@ -706,7 +706,7 @@ class CoolUtil */ @:noUsing public static inline function openURL(url:String) { #if linux - Sys.command('/usr/bin/xdg-open', [url, "&"]); + Sys.command('/usr/bin/xdg-open', [url]); #else FlxG.openURL(url); #end @@ -874,4 +874,4 @@ enum abstract CoolSfx(Int) from Int { var CHECKED = 3; var UNCHECKED = 4; var WARNING = 5; -} \ No newline at end of file +} From d9968a8a87bb23957bb3e963e6e3a53c1b55b0d9 Mon Sep 17 00:00:00 2001 From: dix-nutz Date: Fri, 6 Sep 2024 23:35:04 +1100 Subject: [PATCH 07/17] disable framerate text selection (#377) * Update FramerateCategory.hx * Update MemoryCounter.hx * Update FramerateCounter.hx * Update CodenameBuildField.hx --- source/funkin/backend/system/framerate/CodenameBuildField.hx | 1 + source/funkin/backend/system/framerate/FramerateCategory.hx | 3 ++- source/funkin/backend/system/framerate/FramerateCounter.hx | 3 ++- source/funkin/backend/system/framerate/MemoryCounter.hx | 3 ++- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/source/funkin/backend/system/framerate/CodenameBuildField.hx b/source/funkin/backend/system/framerate/CodenameBuildField.hx index 2cef4a26..6cfb1b8b 100644 --- a/source/funkin/backend/system/framerate/CodenameBuildField.hx +++ b/source/funkin/backend/system/framerate/CodenameBuildField.hx @@ -12,5 +12,6 @@ class CodenameBuildField extends TextField { autoSize = LEFT; multiline = wordWrap = false; text = 'Codename Engine ${Main.releaseCycle}\nCommit ${GitCommitMacro.commitNumber} (${GitCommitMacro.commitHash})'; + selectable = false; } } diff --git a/source/funkin/backend/system/framerate/FramerateCategory.hx b/source/funkin/backend/system/framerate/FramerateCategory.hx index fcc44fde..541bf14a 100644 --- a/source/funkin/backend/system/framerate/FramerateCategory.hx +++ b/source/funkin/backend/system/framerate/FramerateCategory.hx @@ -29,6 +29,7 @@ class FramerateCategory extends Sprite { label.x = 0; label.y = 0; label.defaultTextFormat = new TextFormat(Framerate.fontName, label == this.title ? 18 : 12, -1); + label.selectable = false; addChild(label); } this.title.text = title; @@ -49,4 +50,4 @@ class FramerateCategory extends Sprite { bgSprite.scaleX = width; bgSprite.scaleY = height; } -} \ No newline at end of file +} diff --git a/source/funkin/backend/system/framerate/FramerateCounter.hx b/source/funkin/backend/system/framerate/FramerateCounter.hx index 55cc0f97..b683657b 100644 --- a/source/funkin/backend/system/framerate/FramerateCounter.hx +++ b/source/funkin/backend/system/framerate/FramerateCounter.hx @@ -22,6 +22,7 @@ class FramerateCounter extends Sprite { label.text = "FPS"; label.multiline = label.wordWrap = false; label.defaultTextFormat = new TextFormat(Framerate.fontName, label == fpsNum ? 18 : 12, -1); + label.selectable = false; addChild(label); } } @@ -35,4 +36,4 @@ class FramerateCounter extends Sprite { fpsLabel.x = fpsNum.x + fpsNum.width; fpsLabel.y = (fpsNum.y + fpsNum.height) - fpsLabel.height; } -} \ No newline at end of file +} diff --git a/source/funkin/backend/system/framerate/MemoryCounter.hx b/source/funkin/backend/system/framerate/MemoryCounter.hx index 01321f0d..63bbdd4f 100644 --- a/source/funkin/backend/system/framerate/MemoryCounter.hx +++ b/source/funkin/backend/system/framerate/MemoryCounter.hx @@ -24,6 +24,7 @@ class MemoryCounter extends Sprite { label.text = "FPS"; label.multiline = label.wordWrap = false; label.defaultTextFormat = new TextFormat(Framerate.fontName, 12, -1); + label.selectable = false; addChild(label); } memoryPeakText.alpha = 0.5; @@ -40,4 +41,4 @@ class MemoryCounter extends Sprite { memoryPeakText.x = memoryText.x + memoryText.width; } -} \ No newline at end of file +} From 097aae86e1cd07eddf95fc921b3e16ae0242825f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Fri, 6 Sep 2024 14:50:07 +0200 Subject: [PATCH 08/17] needs to be fixes later --- source/funkin/game/StrumLine.hx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/funkin/game/StrumLine.hx b/source/funkin/game/StrumLine.hx index 763210f8..cca45b51 100644 --- a/source/funkin/game/StrumLine.hx +++ b/source/funkin/game/StrumLine.hx @@ -152,8 +152,10 @@ class StrumLine extends FlxTypedGroup { var scrollSpeed = strumLine.scrollSpeed; if(scrollSpeed == null) if (PlayState.instance != null) scrollSpeed = PlayState.instance.scrollSpeed; if(scrollSpeed == null) scrollSpeed = 1; - var limit = FlxG.height / 0.45; - notes.limit = limit / scrollSpeed; + + // TODOD: Make this work by accounting zoom and scrollspeed changes - Nex + /*var limit = FlxG.height / 0.45; + notes.limit = limit / scrollSpeed;*/ } public override function update(elapsed:Float) { From e2c79bea7d2125e3ad26f671c500d245d3e77cd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Sat, 7 Sep 2024 04:26:12 +0200 Subject: [PATCH 09/17] @usb-port-2 im gonna throw you off a cliff before i fucking murder you --- BETAMESSAGE.md | 2 +- FEATURES.md | 2 +- source/funkin/backend/system/framerate/Framerate.hx | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/BETAMESSAGE.md b/BETAMESSAGE.md index 38685be3..cf86b374 100644 --- a/BETAMESSAGE.md +++ b/BETAMESSAGE.md @@ -35,7 +35,7 @@ Shoutout to the people who stuck with us throughout the alpha and supported us! - ### New Features - Opponent & Co-op modes - New volume change SFX (no more loud flixel beep, customizable) - - New FPS counter allowing you to see advanced info by pressing F3. + - New FPS counter allowing you to see advanced info by pressing F3 (infos can be selected and copied too when in advanced). - (Windows) FNF is no longer blurry on 125-150% DPI - FNF auto fixes audio on state change when you plug in/out your headphones. - FNF auto applies dark titlebar diff --git a/FEATURES.md b/FEATURES.md index 9d53fcaf..caa85417 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -17,7 +17,7 @@ _**QOL = Quality of Life**_ - Usage of [flxanimate](https://github.com/Dot-Stuff/flxanimate) on big sprites, such as Girlfriend to save memory. - You can further optimize it on certain stages by enabling `Low Memory Mode` in `Options > Appearance`. - New volume change SFX (no more loud flixel beep, customizable) -- New FPS counter allowing you to see advanced info by pressing F3. +- New FPS counter allowing you to see advanced info by pressing F3 (infos can be selected and copied too when in advanced). - Simple but advanced modding system (press TAB on main menu) - **Windows only:** - (Windows) FNF is no longer blurry on 125-150% DPI diff --git a/source/funkin/backend/system/framerate/Framerate.hx b/source/funkin/backend/system/framerate/Framerate.hx index e2e565b0..88680e89 100644 --- a/source/funkin/backend/system/framerate/Framerate.hx +++ b/source/funkin/backend/system/framerate/Framerate.hx @@ -116,9 +116,16 @@ class Framerate extends Sprite { bgSprite.scaleX = width; bgSprite.scaleY = height; - var y:Float = height + 4; + var selectable = debugMode == 2; + { // idk i tried to make it more lookable:sob: - Nex + memoryCounter.memoryText.selectable = memoryCounter.memoryPeakText.selectable = + fpsCounter.fpsNum.selectable = fpsCounter.fpsLabel.selectable = + #if SHOW_BUILD_ON_FPS codenameBuildField.selectable = #end selectable; + } + var y:Float = height + 4; for(c in categories) { + c.title.selectable = c.text.selectable = selectable; c.alpha = debugAlpha; c.x = FlxMath.lerp(-c.width - offset.x, 0, debugAlpha); c.y = y; From ae5fc555a815cf5c8d9081bc84c477e2e3a91195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Sun, 8 Sep 2024 16:30:27 +0200 Subject: [PATCH 10/17] "forced" anim attribute finally working big changes here maybe --- assets/data/stages/philly.hx | 1 + source/funkin/backend/FunkinSprite.hx | 11 ++++++++--- .../funkin/backend/scripting/events/NoteHitEvent.hx | 4 ++-- .../funkin/backend/scripting/events/NoteMissEvent.hx | 4 ++-- .../funkin/backend/scripting/events/PlayAnimEvent.hx | 4 ++-- source/funkin/game/Character.hx | 4 ++-- source/funkin/game/cutscenes/dialogue/DialogueBox.hx | 2 +- .../game/cutscenes/dialogue/DialogueCharacter.hx | 2 +- 8 files changed, 19 insertions(+), 13 deletions(-) diff --git a/assets/data/stages/philly.hx b/assets/data/stages/philly.hx index 989b29b5..6b120b51 100644 --- a/assets/data/stages/philly.hx +++ b/assets/data/stages/philly.hx @@ -1,3 +1,4 @@ +// import funkin.game.PlayState; // phillyTrain is automatically added by Stage.hx diff --git a/source/funkin/backend/FunkinSprite.hx b/source/funkin/backend/FunkinSprite.hx index 0d59650d..23304ce7 100644 --- a/source/funkin/backend/FunkinSprite.hx +++ b/source/funkin/backend/FunkinSprite.hx @@ -101,7 +101,7 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I if (!debugMode && isAnimFinished()) { var name = getAnimName() + '-loop'; if (hasAnimation(name)) - playAnim(name, false, lastAnimContext); + playAnim(name, null, lastAnimContext); } } @@ -133,7 +133,7 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I // TODO: find a solution without countedBeat var anim = beatAnims[FlxMath.wrap(countedBeat++, 0, beatAnims.length - 1)]; if (anim.name != null && anim.name != "null" && anim.name != "none") - playAnim(anim.name, anim.forced); + playAnim(anim.name); } } @@ -292,11 +292,16 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I #if REGION public var lastAnimContext:PlayAnimContext = DANCE; - public function playAnim(AnimName:String, Force:Bool = false, Context:PlayAnimContext = NONE, Reversed:Bool = false, Frame:Int = 0):Void + public function playAnim(AnimName:String, ?Force:Null, Context:PlayAnimContext = NONE, Reversed:Bool = false, Frame:Int = 0):Void { if (AnimName == null) return; + if (Force == null) { + var anim = animDatas.get(AnimName); + Force = anim != null && anim.forced; + } + if (animateAtlas != null) { @:privateAccess diff --git a/source/funkin/backend/scripting/events/NoteHitEvent.hx b/source/funkin/backend/scripting/events/NoteHitEvent.hx index e3c8bbc0..7a20fed0 100644 --- a/source/funkin/backend/scripting/events/NoteHitEvent.hx +++ b/source/funkin/backend/scripting/events/NoteHitEvent.hx @@ -100,9 +100,9 @@ final class NoteHitEvent extends CancellableEvent { */ public var ratingAntialiasing:Bool = true; /** - * Whenever the animation should be forced to play. + * Whenever the animation should be forced to play (if it's null it will be forced based on the sprite's data xml, if it has one). */ - public var forceAnim:Bool = true; + public var forceAnim:Null = true; /** * Prevents the default sing animation from being played. diff --git a/source/funkin/backend/scripting/events/NoteMissEvent.hx b/source/funkin/backend/scripting/events/NoteMissEvent.hx index 1b7d0901..d2aa971d 100644 --- a/source/funkin/backend/scripting/events/NoteMissEvent.hx +++ b/source/funkin/backend/scripting/events/NoteMissEvent.hx @@ -29,9 +29,9 @@ final class NoteMissEvent extends CancellableEvent { public var gfSadAnim:String; public var forceGfAnim:Bool; /** - * Whenever the animation should be forced to play. + * Whenever the animation should be forced to play (if it's null it will be forced based on the sprite's data xml, if it has one). */ - public var forceAnim:Bool; + public var forceAnim:Null; /** * Suffix of the animation. "miss" for miss notes, "-alt" for alt notes, "" for normal ones. */ diff --git a/source/funkin/backend/scripting/events/PlayAnimEvent.hx b/source/funkin/backend/scripting/events/PlayAnimEvent.hx index ca88c408..34dd998b 100644 --- a/source/funkin/backend/scripting/events/PlayAnimEvent.hx +++ b/source/funkin/backend/scripting/events/PlayAnimEvent.hx @@ -7,9 +7,9 @@ final class PlayAnimEvent extends CancellableEvent { public var animName:String; /** - Whenever the animation will be forced or not. + Whenever the animation will be forced or not (if it's null it will be forced based on the sprite's data xml, if it has one). **/ - public var force:Bool; + public var force:Null; /** Whenever the animation will play in reverse or not diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index d35e930d..da2c6282 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -207,14 +207,14 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset } public var singAnims = ["singLEFT", "singDOWN", "singUP", "singRIGHT"]; - public function playSingAnim(direction:Int, suffix:String = "", Context:PlayAnimContext = SING, Force:Bool = true, Reversed:Bool = false, Frame:Int = 0) { + public function playSingAnim(direction:Int, suffix:String = "", Context:PlayAnimContext = SING, ?Force:Bool = true, Reversed:Bool = false, Frame:Int = 0) { var event = EventManager.get(DirectionAnimEvent).recycle(singAnims[direction % singAnims.length] + suffix, direction, suffix, Context, Reversed, Frame, Force); script.call("onPlaySingAnim", [event]); if (!event.cancelled) playAnim(event.animName, event.force, event.context, event.reversed, event.frame); } - public override function playAnim(AnimName:String, Force:Bool = false, Context:PlayAnimContext = NONE, Reversed:Bool = false, Frame:Int = 0) { + public override function playAnim(AnimName:String, ?Force:Bool, Context:PlayAnimContext = NONE, Reversed:Bool = false, Frame:Int = 0) { var event = EventManager.get(PlayAnimEvent).recycle(AnimName, Force, Reversed, Frame, Context); script.call("onPlayAnim", [event]); if (event.cancelled) return; diff --git a/source/funkin/game/cutscenes/dialogue/DialogueBox.hx b/source/funkin/game/cutscenes/dialogue/DialogueBox.hx index caf45949..b4bb958b 100644 --- a/source/funkin/game/cutscenes/dialogue/DialogueBox.hx +++ b/source/funkin/game/cutscenes/dialogue/DialogueBox.hx @@ -97,7 +97,7 @@ class DialogueBox extends FunkinSprite { dialogueBoxScript.call("postCreate"); } - public override function playAnim(AnimName:String, Force:Bool = false, Context:PlayAnimContext = NONE, Reversed:Bool = false, Frame:Int = 0) { + public override function playAnim(AnimName:String, ?Force:Bool, Context:PlayAnimContext = NONE, Reversed:Bool = false, Frame:Int = 0) { var event = EventManager.get(PlayAnimEvent).recycle(AnimName, Force, Reversed, Frame, Context); dialogueBoxScript.call("onPlayAnim", [event]); if(event.cancelled) return; diff --git a/source/funkin/game/cutscenes/dialogue/DialogueCharacter.hx b/source/funkin/game/cutscenes/dialogue/DialogueCharacter.hx index 97701e1f..03139a4c 100644 --- a/source/funkin/game/cutscenes/dialogue/DialogueCharacter.hx +++ b/source/funkin/game/cutscenes/dialogue/DialogueCharacter.hx @@ -61,7 +61,7 @@ class DialogueCharacter extends FunkinSprite { dialogueCharScript.call("postCreate"); } - public override function playAnim(AnimName:String, Force:Bool = false, Context:PlayAnimContext = NONE, Reversed:Bool = false, Frame:Int = 0) { + public override function playAnim(AnimName:String, ?Force:Bool, Context:PlayAnimContext = NONE, Reversed:Bool = false, Frame:Int = 0) { var event = EventManager.get(PlayAnimEvent).recycle(AnimName, Force, Reversed, Frame, Context); dialogueCharScript.call("playAnim", [event]); if(event.cancelled) return; From 680cb973a1af367926a3562014970c5dd9331318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Tue, 10 Sep 2024 00:00:54 +0200 Subject: [PATCH 11/17] simple force event null bugfix idk we were bored and started a liveshare Co-Authored-By: Ne_Eo --- source/funkin/backend/scripting/events/DirectionAnimEvent.hx | 4 ++-- source/funkin/backend/scripting/events/NoteHitEvent.hx | 2 +- source/funkin/game/Character.hx | 2 +- source/funkin/game/PlayState.hx | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/funkin/backend/scripting/events/DirectionAnimEvent.hx b/source/funkin/backend/scripting/events/DirectionAnimEvent.hx index 9592e7d0..08b2d931 100644 --- a/source/funkin/backend/scripting/events/DirectionAnimEvent.hx +++ b/source/funkin/backend/scripting/events/DirectionAnimEvent.hx @@ -28,7 +28,7 @@ final class DirectionAnimEvent extends CancellableEvent { **/ public var frame:Int; /** - Force the animation to replay even if it's already playing. + Force the animation to replay even if it's already playing (if it's null it will be forced based on the sprite's data xml, if it has one). **/ - public var force:Bool = true; + public var force:Null; } diff --git a/source/funkin/backend/scripting/events/NoteHitEvent.hx b/source/funkin/backend/scripting/events/NoteHitEvent.hx index 7a20fed0..f0344ba0 100644 --- a/source/funkin/backend/scripting/events/NoteHitEvent.hx +++ b/source/funkin/backend/scripting/events/NoteHitEvent.hx @@ -102,7 +102,7 @@ final class NoteHitEvent extends CancellableEvent { /** * Whenever the animation should be forced to play (if it's null it will be forced based on the sprite's data xml, if it has one). */ - public var forceAnim:Null = true; + public var forceAnim:Null = null; /** * Prevents the default sing animation from being played. diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index da2c6282..c3fa20cc 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -207,7 +207,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset } public var singAnims = ["singLEFT", "singDOWN", "singUP", "singRIGHT"]; - public function playSingAnim(direction:Int, suffix:String = "", Context:PlayAnimContext = SING, ?Force:Bool = true, Reversed:Bool = false, Frame:Int = 0) { + public function playSingAnim(direction:Int, suffix:String = "", Context:PlayAnimContext = SING, ?Force:Null = null, Reversed:Bool = false, Frame:Int = 0) { var event = EventManager.get(DirectionAnimEvent).recycle(singAnims[direction % singAnims.length] + suffix, direction, suffix, Context, Reversed, Frame, Force); script.call("onPlaySingAnim", [event]); if (!event.cancelled) diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 225a4275..b36628b7 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -1919,7 +1919,7 @@ class PlayState extends MusicBeatState } } -class ComboRating { +final class ComboRating { public var percent:Float; public var rating:String; public var color:FlxColor; From 809f1f2840b085ad50b4ac89895607a7fcc16152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Tue, 10 Sep 2024 00:16:00 +0200 Subject: [PATCH 12/17] oopsies --- source/funkin/backend/scripting/events/NoteHitEvent.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/backend/scripting/events/NoteHitEvent.hx b/source/funkin/backend/scripting/events/NoteHitEvent.hx index f0344ba0..7a20fed0 100644 --- a/source/funkin/backend/scripting/events/NoteHitEvent.hx +++ b/source/funkin/backend/scripting/events/NoteHitEvent.hx @@ -102,7 +102,7 @@ final class NoteHitEvent extends CancellableEvent { /** * Whenever the animation should be forced to play (if it's null it will be forced based on the sprite's data xml, if it has one). */ - public var forceAnim:Null = null; + public var forceAnim:Null = true; /** * Prevents the default sing animation from being played. From dd4e8962d85bc9c65923418b576d622bdaf01bbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Tue, 10 Sep 2024 22:59:45 +0200 Subject: [PATCH 13/17] better default forced FINALLY i had the best idea to fix this shit --- source/funkin/backend/FunkinSprite.hx | 2 +- source/funkin/backend/utils/XMLUtil.hx | 21 ++++++++++++--------- source/funkin/game/Character.hx | 1 + 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/source/funkin/backend/FunkinSprite.hx b/source/funkin/backend/FunkinSprite.hx index 23304ce7..21a35962 100644 --- a/source/funkin/backend/FunkinSprite.hx +++ b/source/funkin/backend/FunkinSprite.hx @@ -133,7 +133,7 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I // TODO: find a solution without countedBeat var anim = beatAnims[FlxMath.wrap(countedBeat++, 0, beatAnims.length - 1)]; if (anim.name != null && anim.name != "null" && anim.name != "none") - playAnim(anim.name); + playAnim(anim.name, anim.forced); } } diff --git a/source/funkin/backend/utils/XMLUtil.hx b/source/funkin/backend/utils/XMLUtil.hx index 880cd96c..6143cf9d 100644 --- a/source/funkin/backend/utils/XMLUtil.hx +++ b/source/funkin/backend/utils/XMLUtil.hx @@ -1,6 +1,7 @@ package funkin.backend.utils; import funkin.backend.FunkinSprite; +import funkin.game.Character; import funkin.backend.system.ErrorCode; import funkin.backend.FunkinSprite.XMLAnimType; import flixel.util.FlxColor; @@ -170,8 +171,7 @@ class XMLUtil { animType: spr.spriteAnimType, x: 0, y: 0, - indices: [for(i in 0...spr.frames.frames.length) i], - forced: (node.has.forced && node.att.forced == "true") || (!node.has.forced && spr.spriteAnimType == BEAT) + indices: [for(i in 0...spr.frames.frames.length) i] }); } } @@ -188,7 +188,7 @@ class XMLUtil { return loadSpriteFromXML(Type.createInstance(cl, args), node, parentFolder, defaultAnimType); } - public static function extractAnimFromXML(anim:Access, animType:XMLAnimType = NONE, loop:Bool = false):AnimData { + public static function extractAnimFromXML(anim:Access, animType:XMLAnimType = NONE, loop:Bool = false, ?sprite:FunkinSprite):AnimData { var animData:AnimData = { name: null, anim: null, @@ -197,8 +197,7 @@ class XMLUtil { animType: animType, x: 0, y: 0, - indices: [], - forced: false, + indices: [] }; if (anim.has.name) animData.name = anim.att.name; @@ -254,24 +253,28 @@ class XMLUtil { if (sprite is FunkinSprite) { var xmlSpr = cast(sprite, FunkinSprite); + var name = animData.name; switch(animData.animType) { case BEAT: xmlSpr.beatAnims.push({ - name: animData.name, - forced: animData.forced.getDefault(false) + name: name, + forced: animData.forced.getDefault(defaultForcedCheck(name, xmlSpr)) }); case LOOP: - xmlSpr.animation.play(animData.name, animData.forced.getDefault(false)); + xmlSpr.animation.play(name, animData.forced.getDefault(defaultForcedCheck(name, xmlSpr))); default: // nothing } - xmlSpr.animDatas.set(animData.name, animData); + xmlSpr.animDatas.set(name, animData); } return OK; } return MISSING_PROPERTY; } + public static inline function defaultForcedCheck(animName:String, sprite:FunkinSprite):Bool + return sprite is Character && (animName.startsWith("idle") || animName.startsWith("danceLeft") || animName.startsWith("danceRight")) ? false : sprite.spriteAnimType == BEAT; + public static inline function fixXMLText(text:String) { var v:String; return [for(l in text.split("\n")) if ((v = l.trim()) != "") v].join("\n"); diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index c3fa20cc..ac13c820 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -283,6 +283,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset public inline function buildCharacter(xml:Access) { this.xml = xml; // Modders wassup :D sprite = curCharacter; + spriteAnimType = BEAT; if (xml.x.exists("isPlayer")) playerOffsets = (xml.x.get("isPlayer") == "true"); if (xml.x.exists("x")) globalOffset.x = Std.parseFloat(xml.x.get("x")); From f281cc6ee4d213ecd037ddd327e65568c3efbcb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Tue, 10 Sep 2024 23:11:39 +0200 Subject: [PATCH 14/17] forgor to remove this --- source/funkin/backend/utils/XMLUtil.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/backend/utils/XMLUtil.hx b/source/funkin/backend/utils/XMLUtil.hx index 6143cf9d..dc39244d 100644 --- a/source/funkin/backend/utils/XMLUtil.hx +++ b/source/funkin/backend/utils/XMLUtil.hx @@ -188,7 +188,7 @@ class XMLUtil { return loadSpriteFromXML(Type.createInstance(cl, args), node, parentFolder, defaultAnimType); } - public static function extractAnimFromXML(anim:Access, animType:XMLAnimType = NONE, loop:Bool = false, ?sprite:FunkinSprite):AnimData { + public static function extractAnimFromXML(anim:Access, animType:XMLAnimType = NONE, loop:Bool = false):AnimData { var animData:AnimData = { name: null, anim: null, From ec4515f4e21ea356fd298033100107d69c684a81 Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Wed, 11 Sep 2024 11:04:03 +0200 Subject: [PATCH 15/17] Improved dropdown event, to also allow arrays --- source/funkin/backend/chart/EventsData.hx | 31 ++++++++++++++++++----- source/funkin/backend/utils/CoolUtil.hx | 13 ++++++++++ 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/source/funkin/backend/chart/EventsData.hx b/source/funkin/backend/chart/EventsData.hx index eff3fd8e..64b8ce93 100644 --- a/source/funkin/backend/chart/EventsData.hx +++ b/source/funkin/backend/chart/EventsData.hx @@ -69,7 +69,11 @@ class EventsData { hscriptInterp.variables.set("String", TString); hscriptInterp.variables.set("StrumLine", TStrumLine); hscriptInterp.variables.set("ColorWheel", TColorWheel); - hscriptInterp.variables.set("DropDown", Reflect.makeVarArgs((args) -> {return args.length > 0 ? TDropDown([for (arg in args) Std.string(arg)]) : TDropDown(["null"]);})); + hscriptInterp.variables.set("DropDown", Reflect.makeVarArgs(function(args:Array):EventParamType { + var flatArgs = CoolUtil.deepFlatten(args); + if(flatArgs.length == 0) return TDropDown(["null"]); + return TDropDown([for (arg in flatArgs) Std.string(arg)]); + })); hscriptInterp.variables.set("Character", TCharacter); hscriptInterp.variables.set("Stage", TStage); @@ -77,11 +81,12 @@ class EventsData { hscriptParser.allowJSON = hscriptParser.allowMetadata = false; for (file in Paths.getFolderContent('data/events/', true, BOTH)) { - if (Path.extension(file) != "json" && Path.extension(file) != "pack") continue; - var eventName:String = Path.withoutExtension(Path.withoutDirectory(file)); + var ext = Path.extension(file); + if (ext != "json" && ext != "pack") continue; + var eventName:String = CoolUtil.getFilename(file); var fileTxt:String = Assets.getText(file); - if (Path.extension(file) == "pack") { + if (ext == "pack") { var arr = fileTxt.split("________PACKSEP________"); eventName = Path.withoutExtension(arr[0]); fileTxt = arr[2]; @@ -93,13 +98,17 @@ class EventsData { eventsParams.set(eventName, []); try { - var data:Dynamic = Json.parse(fileTxt); + var data:EventInfoFile = cast Json.parse(fileTxt); if (data == null || data.params == null) continue; var finalParams:Array = []; - for (paramData in cast(data.params, Array)) { + for (paramData in data.params) { try { - finalParams.push({name: paramData.name, type: hscriptInterp.expr(hscriptParser.parseString(paramData.type)), defValue: paramData.defaultValue}); + finalParams.push({ + name: paramData.name, + type: hscriptInterp.expr(hscriptParser.parseString(paramData.type)), + defValue: paramData.defaultValue + }); } catch (e) {trace('Error parsing event param ${paramData.name} - ${eventName}: $e'); finalParams.push(null);} } eventsParams.set(eventName, finalParams); @@ -110,6 +119,14 @@ class EventsData { } } +typedef EventInfoFile = { + var params:Array<{ + var name:String; + var type:String; + var defaultValue:Dynamic; + }>; +} + typedef EventInfo = { var params:Array; var paramValues:Array; diff --git a/source/funkin/backend/utils/CoolUtil.hx b/source/funkin/backend/utils/CoolUtil.hx index 4927874f..fe02f614 100644 --- a/source/funkin/backend/utils/CoolUtil.hx +++ b/source/funkin/backend/utils/CoolUtil.hx @@ -906,6 +906,19 @@ class CoolUtil return result.join(seperator); } + + public static function deepFlatten(arr:Array, ?result:Array):Array { + if(arr == null) return []; + if(result == null) result = []; + for (e in arr) { + if (Std.isOfType(e, Array)) { + deepFlatten(e, result); + } else { + result.push(e); + } + } + return result; + } } /** From dec2a126390faa60f3b458bfdaff312eb9ea355b Mon Sep 17 00:00:00 2001 From: Lily Date: Fri, 13 Sep 2024 23:08:28 +0300 Subject: [PATCH 16/17] fix for gles (#381) * fix for gles * Fix formatting --------- Co-authored-by: Ne_Eo --- assets/shaders/engine/editorBlur.frag | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/assets/shaders/engine/editorBlur.frag b/assets/shaders/engine/editorBlur.frag index ffcbc755..147aada3 100644 --- a/assets/shaders/engine/editorBlur.frag +++ b/assets/shaders/engine/editorBlur.frag @@ -21,17 +21,17 @@ void main() { return; vec4 color = getColor(camPos); - float fsteps = steps; - for(float inside = 1.0; inside < stepsInside+1.0; inside++) { + float fsteps = float(steps); + for(float inside = 1.0; inside < float(stepsInside)+1.0; inside++) { for(int i = 0; i < steps; i++) { - float fi = i; + float fi = float(i); color += getColor(camPos + vec2( - strength * (inside / stepsInside) * cos(fi / fsteps * (PI * 2.0)), - strength * (inside / stepsInside) * sin(fi / fsteps * (PI * 2.0)) + strength * (inside / float(stepsInside)) * cos(fi / fsteps * (PI * 2.0)), + strength * (inside / float(stepsInside)) * sin(fi / fsteps * (PI * 2.0)) )); } } - color /= steps * stepsInside; + color /= vec4(steps * stepsInside); gl_FragColor = color; -} \ No newline at end of file +} From fabdeb3fa11c7ae902ef8a90b7a2ecbd90c5037a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Fri, 13 Sep 2024 22:31:17 +0200 Subject: [PATCH 17/17] fixing actions + `HXCPP_CATCH_SEGV` credits to @mcagabe19 for the hxcpp suggestion! --- .github/workflows/linux.yml | 4 ++-- .github/workflows/macos.yml | 4 ++-- .github/workflows/windows.yml | 4 ++-- project.xml | 1 + 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 4e742b35..63a036bb 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -38,12 +38,12 @@ jobs: - name: Tar files run: tar -zcvf CodenameEngine.tar.gz -C export/release/linux/bin . - name: Uploading artifact (entire build) - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: Codename Engine path: CodenameEngine.tar.gz # - name: Uploading artifact (executable) - # uses: actions/upload-artifact@v2 + # uses: actions/upload-artifact@v4 # with: # name: Update-Linux # path: export/release/linux/bin/CodenameEngine diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 3dd28814..fa75491a 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -35,12 +35,12 @@ jobs: - name: Tar files run: tar -zcvf CodenameEngine.tar.gz -C export/release/macos/bin . - name: Uploading artifact (entire build) - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: Codename Engine path: CodenameEngine.tar.gz # - name: Uploading artifact (executable) - # uses: actions/upload-artifact@v2 + # uses: actions/upload-artifact@v4 # with: # name: Update-Mac # path: export/release/macos/bin/CodenameEngine diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index d89c1687..702bedc5 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -33,12 +33,12 @@ jobs: run: | haxelib run lime build windows - name: Uploading artifact (entire build) - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: Codename Engine path: export/release/windows/bin # - name: Uploading artifact (executable) - # uses: actions/upload-artifact@v2 + # uses: actions/upload-artifact@v4 # with: # name: Update-Windows # path: export/release/windows/bin/CodenameEngine.exe diff --git a/project.xml b/project.xml index 77ae6af6..9b396fa7 100644 --- a/project.xml +++ b/project.xml @@ -195,6 +195,7 @@ +