From 7b8fbf2c58d21a8392fdb80e17a535e4073f37fb Mon Sep 17 00:00:00 2001 From: Ralty <78720179+Raltyro@users.noreply.github.com> Date: Fri, 1 Aug 2025 20:17:37 +0700 Subject: [PATCH 1/7] show real bounds instead --- source/funkin/editors/character/CharacterEditor.hx | 2 +- source/funkin/editors/character/CharacterGizmos.hx | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/source/funkin/editors/character/CharacterEditor.hx b/source/funkin/editors/character/CharacterEditor.hx index 68f167fd..b040d9bd 100644 --- a/source/funkin/editors/character/CharacterEditor.hx +++ b/source/funkin/editors/character/CharacterEditor.hx @@ -286,7 +286,6 @@ class CharacterEditor extends UIState { characterGizmo.boxGizmo = Options.characterHitbox; characterGizmo.cameraGizmo = Options.characterCamera; characterGizmo.cameras = [gizmosCamera]; - add(characterGizmo); uiCamera = new FlxCamera(); uiCamera.bgColor = 0; @@ -298,6 +297,7 @@ class CharacterEditor extends UIState { character.cameras = [charCamera]; characterGizmo.character = character; + add(characterGizmo); changeCharacterIsPlayer(character.playerOffsets); diff --git a/source/funkin/editors/character/CharacterGizmos.hx b/source/funkin/editors/character/CharacterGizmos.hx index acfd6382..e1df046e 100644 --- a/source/funkin/editors/character/CharacterGizmos.hx +++ b/source/funkin/editors/character/CharacterGizmos.hx @@ -21,13 +21,13 @@ class CharacterGizmos extends FlxSprite { public function drawHitbox() { for (camera in cameras) { - if (character.animateAtlas != null) { + //if (character.animateAtlas != null) { var bounds:FlxRect = cast character.extra.get(StageEditor.exID("bounds")); character._rect.copyFrom(bounds.getDefault(FlxRect.weak())); - character._rect.x -= character.cameras[0].viewX; - character._rect.y -= character.cameras[0].viewY; - } else if (character._matrix != null && character.frame != null) { + character._rect.x -= character.cameras[0].viewMarginLeft + character.cameras[0].scroll.x; + character._rect.y -= character.cameras[0].viewMarginTop + character.cameras[0].scroll.y; + /*} else if (character._matrix != null && character.frame != null) { character._rect.set( character._matrix.tx, character._matrix.ty, Math.abs(character.frame.frame.width * character._matrix.a), @@ -36,8 +36,8 @@ class CharacterGizmos extends FlxSprite { if (character._matrix.a < 0) character._rect.x -= character._rect.width; if (character._matrix.d < 0) character._rect.y -= character._rect.height; - character._rect.offset(-character.cameras[0].viewMarginLeft, -character.cameras[0].viewMarginTop); - } + character._rect.offset(-camera.viewMarginLeft, -camera.viewMarginTop); + }*/ character._rect.x *= character.cameras[0].zoom; character._rect.y *= character.cameras[0].zoom; From 581b5375329f37734571b99f1a74a7ee0c16a236 Mon Sep 17 00:00:00 2001 From: Hero Date: Fri, 1 Aug 2025 20:35:02 +0300 Subject: [PATCH 2/7] frakits pls --- source/funkin/backend/utils/WindowUtils.hx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/source/funkin/backend/utils/WindowUtils.hx b/source/funkin/backend/utils/WindowUtils.hx index 4c0c76bf..ddf14596 100644 --- a/source/funkin/backend/utils/WindowUtils.hx +++ b/source/funkin/backend/utils/WindowUtils.hx @@ -63,11 +63,8 @@ final class WindowUtils { * @param image The image to set as the icon. **/ public static inline function setWindow(?name:String, ?image:String) - { - // Coded by HeroEyad using Pigeon Text Editor v2.03 (E.G.E. Edition) - Lib.application.window.setIcon(lime.graphics.Image.fromBytes(Assets.getBytes(image != null ? image : Flags.MOD_ICON))); + { Lib.application.window.setIcon(lime.graphics.Image.fromBytes(Assets.getBytes(image != null ? image : Flags.MOD_ICON))); title = name != null ? name : Flags.MOD_NAME; - // End of HeroEyad Code. Coded by HeroEyad. } /** From 5c249fa13b364de38988afdcebaa8a8986ff546f Mon Sep 17 00:00:00 2001 From: Ralty <78720179+Raltyro@users.noreply.github.com> Date: Sat, 2 Aug 2025 03:09:08 +0700 Subject: [PATCH 3/7] Optimized __readDecoder --- source/funkin/backend/utils/AudioAnalyzer.hx | 85 +++++++++++++++----- 1 file changed, 63 insertions(+), 22 deletions(-) diff --git a/source/funkin/backend/utils/AudioAnalyzer.hx b/source/funkin/backend/utils/AudioAnalyzer.hx index 529aec5d..83d079b4 100644 --- a/source/funkin/backend/utils/AudioAnalyzer.hx +++ b/source/funkin/backend/utils/AudioAnalyzer.hx @@ -118,6 +118,9 @@ class AudioAnalyzer { var __vorbis:VorbisFile; var __buffer:ArrayBuffer; var __bufferSize:Int; + var __bufferLastSize:Int; + var __bufferTime:Float; + var __bufferLastTime:Float; #end // analyze @@ -160,7 +163,12 @@ class AudioAnalyzer { function __check() if (sound.buffer != buffer) { byteSize = 1 << ((buffer = sound.buffer).bitsPerSample - 1); - #if (lime_cffi && lime_vorbis) __vorbis = null; #end + #if (lime_cffi && lime_vorbis) + __vorbis = null; + __bufferLastSize = 0; + __bufferTime = Math.NaN; + __bufferLastTime = Math.NaN; + #end __toBits = buffer.sampleRate / 1000 * (__sampleSize = buffer.channels * (__wordSize = buffer.bitsPerSample >> 3)); __min.resize(buffer.channels); @@ -433,7 +441,7 @@ class AudioAnalyzer { inline function __read(startPos:Float, endPos:Float, callback:AudioAnalyzerCallback) { if (buffer.data != null) __readData(startPos, endPos, callback); #if lime_cffi - else if (__canReadStream() && (startPos += __readStream(startPos, endPos, callback)) >= endPos) return; + else if (__canReadStream() && (startPos += __readStream(startPos, endPos, callback)) >= endPos) {} #if lime_vorbis else if (__prepareDecoder()) __readDecoder(startPos, endPos, callback); #end @@ -496,35 +504,68 @@ class AudioAnalyzer { if (buffer.__srcVorbisFile == null) return __vorbis != null; if (__vorbis != null) return true; if ((__vorbis = buffer.__srcVorbisFile.clone()) != null) { // IM HOPING IT HAVE A GC CLOSURE. - __buffer = new ArrayBuffer(__bufferSize = 0x400 * __sampleSize); + __buffer = new ArrayBuffer(__bufferSize = (buffer.sampleRate >> 1) * __sampleSize); // 0.5 seconds of buffers. return true; } return false; } inline function __readDecoder(startPos:Float, endPos:Float, callback:AudioAnalyzerCallback) { - var time = startPos / 1000; - if (Math.abs(time - __vorbis.timeTell()) > 0.004) { - if (startPos < 1) __vorbis.rawSeek(0); - else __vorbis.timeSeek(time); - } + var n = Math.floor((endPos - startPos) * __toBits); + if ((n -= n % __sampleSize) > 0) { + var time = startPos / 1000, pos = Math.floor((startPos - __bufferTime * 1000) * __toBits); + pos -= pos % __sampleSize; - var isBigEndian = lime.system.System.endianness == lime.system.Endian.BIG_ENDIAN, result; - var n = Math.floor((endPos - startPos) * __toBits), pos = 0, c = 0; - n -= n % __sampleSize; + var doRead = __bufferLastSize == 0 || (time < __bufferTime && pos >= __bufferSize); + if (doRead) { + if (startPos < 1) { + __vorbis.rawSeek(0); + __bufferTime = 0; + } + else + __vorbis.timeSeek(__bufferTime = time); - while (n > 0) { - result = __vorbis.read(__buffer, 0, n < __bufferSize ? n : __bufferSize, isBigEndian, __wordSize, true); - if (result == Vorbis.HOLE) continue; - else if (result <= 0) break; - - while (pos < result) { - callback(getByte(__buffer, pos, __wordSize), c); - if (++c > buffer.channels) c = 0; - if ((pos += __wordSize) >= n) break; + __bufferLastSize = pos = 0; + } + + var isBigEndian = lime.system.System.endianness == lime.system.Endian.BIG_ENDIAN, ranOut = false, c = 0, result; + while (true) { + if (doRead) { + trace('reading', pos, __bufferLastTime); + + result = __vorbis.read(__buffer, pos, __bufferSize - pos, isBigEndian, __wordSize, true); + if (result == Vorbis.HOLE) continue; + else if (result < 0) break; + else if (!(ranOut = result == 0)) { + __bufferLastTime = __vorbis.timeTell(); + __bufferLastSize += result; + + while (pos < __bufferLastSize) { + callback(getByte(__buffer, pos, __wordSize), c); + if (++c > buffer.channels) c = 0; + pos += __wordSize; + if ((n -= __wordSize) <= 0) break; + } + } + } + else { + while (pos < __bufferLastSize) { + callback(getByte(__buffer, pos, __wordSize), c); + if (++c > buffer.channels) c = 0; + pos += __wordSize; + if ((n -= __wordSize) <= 0) break; + } + doRead = true; + ranOut = pos >= __bufferSize; + } + + if (n <= 0) break; + else if (doRead && ranOut) { + pos = 0; + __bufferTime = __bufferLastTime; + __bufferLastSize = 0; + } } - pos = 0; - n -= result; } } #end From 0aa30ef7812c25ca9f2956c5f256158a3c9174c5 Mon Sep 17 00:00:00 2001 From: Ralty <78720179+Raltyro@users.noreply.github.com> Date: Sat, 2 Aug 2025 03:18:34 +0700 Subject: [PATCH 4/7] FUCK --- source/funkin/backend/utils/AudioAnalyzer.hx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/source/funkin/backend/utils/AudioAnalyzer.hx b/source/funkin/backend/utils/AudioAnalyzer.hx index 83d079b4..4ff845f4 100644 --- a/source/funkin/backend/utils/AudioAnalyzer.hx +++ b/source/funkin/backend/utils/AudioAnalyzer.hx @@ -513,17 +513,17 @@ class AudioAnalyzer { inline function __readDecoder(startPos:Float, endPos:Float, callback:AudioAnalyzerCallback) { var n = Math.floor((endPos - startPos) * __toBits); if ((n -= n % __sampleSize) > 0) { - var time = startPos / 1000, pos = Math.floor((startPos - __bufferTime * 1000) * __toBits); + var pos = Math.floor((startPos - __bufferTime * 1000) * __toBits); pos -= pos % __sampleSize; - var doRead = __bufferLastSize == 0 || (time < __bufferTime && pos >= __bufferSize); + var doRead = __bufferLastSize == 0 || (pos < 0 && pos >= __bufferSize); if (doRead) { if (startPos < 1) { __vorbis.rawSeek(0); __bufferTime = 0; } else - __vorbis.timeSeek(__bufferTime = time); + __vorbis.timeSeek(__bufferTime = startPos / 1000); __bufferLastSize = pos = 0; } @@ -531,15 +531,12 @@ class AudioAnalyzer { var isBigEndian = lime.system.System.endianness == lime.system.Endian.BIG_ENDIAN, ranOut = false, c = 0, result; while (true) { if (doRead) { - trace('reading', pos, __bufferLastTime); - result = __vorbis.read(__buffer, pos, __bufferSize - pos, isBigEndian, __wordSize, true); if (result == Vorbis.HOLE) continue; else if (result < 0) break; else if (!(ranOut = result == 0)) { __bufferLastTime = __vorbis.timeTell(); __bufferLastSize += result; - while (pos < __bufferLastSize) { callback(getByte(__buffer, pos, __wordSize), c); if (++c > buffer.channels) c = 0; @@ -561,9 +558,8 @@ class AudioAnalyzer { if (n <= 0) break; else if (doRead && ranOut) { - pos = 0; + __bufferLastSize = pos = 0; __bufferTime = __bufferLastTime; - __bufferLastSize = 0; } } } From 828c17731de112caeb680555248b5e9e886b90cf Mon Sep 17 00:00:00 2001 From: Ralty <78720179+Raltyro@users.noreply.github.com> Date: Sat, 2 Aug 2025 03:36:03 +0700 Subject: [PATCH 5/7] Fix custom options crash --- source/funkin/options/OptionsMenu.hx | 7 +++++-- source/funkin/options/type/NumOption.hx | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/source/funkin/options/OptionsMenu.hx b/source/funkin/options/OptionsMenu.hx index 10484ce1..0cc170e6 100644 --- a/source/funkin/options/OptionsMenu.hx +++ b/source/funkin/options/OptionsMenu.hx @@ -171,7 +171,8 @@ class OptionsMenu extends TreeMenu { Logs.warn("A number option requires an \"id\" for option saving."); continue; } - options.push(new NumOption(name, desc, Std.parseFloat(node.att.min), Std.parseFloat(node.att.max), Std.parseFloat(node.att.step), node.att.id, null, FlxG.save.data)); + var step = node.has.change ? Std.parseFloat(node.att.change) : (node.has.step ? Std.parseFloat(node.att.step) : null); + options.push(new NumOption(name, desc, Std.parseFloat(node.att.min), Std.parseFloat(node.att.max), step, node.att.id, null, FlxG.save.data)); case "choice": if (!node.has.id) { Logs.warn("A choice option requires an \"id\" for option saving."); @@ -200,7 +201,9 @@ class OptionsMenu extends TreeMenu { Logs.warn("A slider option requires an \"id\" for option saving."); continue; } - options.push(new SliderOption(name, desc, Std.parseFloat(node.att.min), Std.parseFloat(node.att.max), Std.parseFloat(node.att.step), Std.parseInt(node.att.segments), node.att.id, Std.parseInt(node.att.barWidth), null, FlxG.save.data)); + var step = node.has.change ? Std.parseFloat(node.att.change) : (node.has.step ? Std.parseFloat(node.att.step) : null); + var segments = node.has.segments ? Std.parseInt(node.att.segments) : 5; + options.push(new SliderOption(name, desc, Std.parseFloat(node.att.min), Std.parseFloat(node.att.max), step, segments, node.att.id, Std.parseInt(node.att.barWidth), null, FlxG.save.data)); case 'separator': options.push(new Separator(Std.parseInt(node.att.height))); diff --git a/source/funkin/options/type/NumOption.hx b/source/funkin/options/type/NumOption.hx index f1d2a33e..27c92966 100644 --- a/source/funkin/options/type/NumOption.hx +++ b/source/funkin/options/type/NumOption.hx @@ -40,7 +40,7 @@ class NumOption extends TextOption { override function changeSelection(change:Int):Void { if (locked) return; - if (currentValue == (currentValue = FlxMath.bound(currentValue + change, min, max))) return; + if (currentValue == (currentValue = FlxMath.bound(currentValue + change * step, min, max))) return; __number.text = ': $currentValue'; Reflect.setField(parent, optionName, currentValue); From a00e8af5687775b46bda9c7683f5ac2a40157255 Mon Sep 17 00:00:00 2001 From: Ralty <78720179+Raltyro@users.noreply.github.com> Date: Sat, 2 Aug 2025 06:12:04 +0700 Subject: [PATCH 6/7] just to be safe --- source/funkin/backend/utils/AudioAnalyzer.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/backend/utils/AudioAnalyzer.hx b/source/funkin/backend/utils/AudioAnalyzer.hx index 4ff845f4..e2a8fb92 100644 --- a/source/funkin/backend/utils/AudioAnalyzer.hx +++ b/source/funkin/backend/utils/AudioAnalyzer.hx @@ -462,7 +462,7 @@ class AudioAnalyzer { #if lime_cffi inline function __canReadStream():Bool - @:privateAccess return sound._source != null && sound._source.__backend != null && sound._source.__backend.streamTimer != null; + @:privateAccess return sound._source != null && sound._source.__backend != null && sound._source.__backend.playing != null; inline function __readStream(startPos:Float, endPos:Float, callback:AudioAnalyzerCallback):Float @:privateAccess { var backend = sound._source.__backend; From 1018d3c214e0404e57250fd3590a5595f5f131f6 Mon Sep 17 00:00:00 2001 From: Ralty <78720179+Raltyro@users.noreply.github.com> Date: Sat, 2 Aug 2025 06:12:27 +0700 Subject: [PATCH 7/7] im an idiot --- source/funkin/backend/utils/AudioAnalyzer.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/backend/utils/AudioAnalyzer.hx b/source/funkin/backend/utils/AudioAnalyzer.hx index e2a8fb92..8d9cb098 100644 --- a/source/funkin/backend/utils/AudioAnalyzer.hx +++ b/source/funkin/backend/utils/AudioAnalyzer.hx @@ -462,7 +462,7 @@ class AudioAnalyzer { #if lime_cffi inline function __canReadStream():Bool - @:privateAccess return sound._source != null && sound._source.__backend != null && sound._source.__backend.playing != null; + @:privateAccess return sound._source != null && sound._source.__backend != null && sound._source.__backend.playing; inline function __readStream(startPos:Float, endPos:Float, callback:AudioAnalyzerCallback):Float @:privateAccess { var backend = sound._source.__backend;