Merge remote-tracking branch 'origin/main'

This commit is contained in:
Frakits
2025-08-02 14:20:30 +03:00
6 changed files with 73 additions and 36 deletions
+59 -22
View File
@@ -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
@@ -454,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;
inline function __readStream(startPos:Float, endPos:Float, callback:AudioAnalyzerCallback):Float @:privateAccess {
var backend = sound._source.__backend;
@@ -496,35 +504,64 @@ 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 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 || (pos < 0 && pos >= __bufferSize);
if (doRead) {
if (startPos < 1) {
__vorbis.rawSeek(0);
__bufferTime = 0;
}
else
__vorbis.timeSeek(__bufferTime = startPos / 1000);
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;
__bufferLastSize = pos = 0;
}
while (pos < result) {
callback(getByte(__buffer, pos, __wordSize), c);
if (++c > buffer.channels) c = 0;
if ((pos += __wordSize) >= n) break;
var isBigEndian = lime.system.System.endianness == lime.system.Endian.BIG_ENDIAN, ranOut = false, c = 0, result;
while (true) {
if (doRead) {
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) {
__bufferLastSize = pos = 0;
__bufferTime = __bufferLastTime;
}
}
pos = 0;
n -= result;
}
}
#end
+1 -4
View File
@@ -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.
}
/**
@@ -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);
@@ -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;
+5 -2
View File
@@ -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)));
+1 -1
View File
@@ -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);