stuff i forgot to push a week ago

This commit is contained in:
Yoshman29
2023-05-05 17:01:06 +02:00
parent 90bc513adf
commit aa8dab3b1a
4 changed files with 48 additions and 103 deletions
+1 -63
View File
@@ -165,68 +165,6 @@ class HScript extends Script {
}
public override function onDestroy() {
@:privateAccess {
// INTERP
if (interp != null) {
interp.scriptObject = null;
interp.errorHandler = null;
interp.variables.clear();
interp.variables = null;
interp.publicVariables = null;
interp.staticVariables = null;
for(l in interp.locals)
if (l != null)
l.r = null;
interp.locals.clear();
interp.locals = null;
interp.binops.clear();
interp.binops = null;
interp.depth = 0;
interp.inTry = false;
while(interp.declared.length > 0)
interp.declared.shift();
interp.declared = null;
interp.returnValue = null;
interp.isBypassAccessor = false;
interp.importEnabled = false;
interp.allowStaticVariables = false;
interp.allowPublicVariables = false;
while(interp.importBlocklist.length > 0)
interp.importBlocklist.shift();
interp.importBlocklist = null;
while(interp.__instanceFields.length > 0)
interp.importBlocklist.shift();
interp.__instanceFields = null;
interp.curExpr = null;
}
if (parser != null) {
parser.line = 0;
parser.opChars = null;
parser.identChars = null;
parser.opPriority.clear();
parser.opPriority = null;
parser.opRightAssoc.clear();
parser.opRightAssoc = null;
parser.preprocesorValues.clear();
parser.preprocesorValues = null;
parser.input = null;
parser.readPos = 0;
parser.char = 0;
parser.ops = null;
parser.idents = null;
parser.uid = 0;
parser.origin = null;
parser.tokenMin = 0;
parser.tokenMax = 0;
parser.oldTokenMin = 0;
parser.oldTokenMax = 0;
parser.tokens = null;
}
expr = null;
parser = null;
interp = null;
}
super.onDestroy();
}
}
+27 -12
View File
@@ -287,7 +287,7 @@ class CoolUtil
* @param menuSFX Menu SFX to play
* @param volume At which volume it should play
*/
public static function playMenuSFX(menuSFX:CoolSfx = SCROLL, volume:Float = 1) {
public static inline function playMenuSFX(menuSFX:CoolSfx = SCROLL, volume:Float = 1) {
FlxG.sound.play(Paths.sound(switch(menuSFX) {
case CONFIRM: 'menu/confirm';
case CANCEL: 'menu/cancel';
@@ -346,7 +346,7 @@ class CoolUtil
* @param fill Whenever the sprite should fill instead of shrinking (true)
* @param maxScale Maximum scale (0 / none)
*/
public static function setUnstretchedGraphicSize(sprite:FlxSprite, width:Int, height:Int, fill:Bool = true, maxScale:Float = 0) {
public static inline function setUnstretchedGraphicSize(sprite:FlxSprite, width:Int, height:Int, fill:Bool = true, maxScale:Float = 0) {
sprite.setGraphicSize(width, height);
sprite.updateHitbox();
var nScale = (fill ? Math.max : Math.min)(sprite.scale.x, sprite.scale.y);
@@ -402,7 +402,7 @@ class CoolUtil
* @param cam Camera
* @param axes Axes (XY)
*/
public static function cameraCenter(obj:FlxObject, cam:FlxCamera, axes:FlxAxes = XY) {
public static inline function cameraCenter(obj:FlxObject, cam:FlxCamera, axes:FlxAxes = XY) {
switch(axes) {
case XY:
obj.setPosition((cam.width - obj.width) / 2, (cam.height - obj.height) / 2);
@@ -421,7 +421,7 @@ class CoolUtil
* @param width Width
* @param height Height
*/
public static function setSpriteSize(sprite:FlxSprite, width:Float, height:Float) {
public static inline function setSpriteSize(sprite:FlxSprite, width:Float, height:Float) {
sprite.scale.set(width / sprite.frameWidth, height / sprite.frameHeight);
sprite.updateHitbox();
}
@@ -491,16 +491,31 @@ class CoolUtil
/**
* Gets the macro class created by hscript-improved for an abstract / enum
*/
public static function getMacroAbstractClass(className:String) {
public static inline function getMacroAbstractClass(className:String) {
return Type.resolveClass('${className}_HSC');
}
/**
* Basically indexOf, but starts from the end.
* @param array Array to scan
* @param element Element
* @return Index, or -1 if unsuccessful.
*/
public static inline function indexOfFromLast<T>(array:Array<T>, element:T):Int {
var i = array.length - 1;
while(i >= 0)
if (array[i] == element)
return i;
return -1;
}
/**
* Clears the content of an array
*/
public static function clear<T>(array:Array<T>):Array<T> {
while(array.length > 0)
array.shift();
public static inline function clear<T>(array:Array<T>):Array<T> {
// while(array.length > 0)
// array.shift();
array.resize(0);
return array;
}
@@ -510,7 +525,7 @@ class CoolUtil
* @param ...args Group entries
* @return Array<T>
*/
public static function pushGroup<T>(array:Array<T>, ...args:T):Array<T> {
public static inline function pushGroup<T>(array:Array<T>, ...args:T):Array<T> {
for(a in args)
array.push(a);
return array;
@@ -520,7 +535,7 @@ class CoolUtil
* Opens an URL in the browser.
* @param url
*/
public static function openURL(url:String) {
public static inline function openURL(url:String) {
#if linux
Sys.command('/usr/bin/xdg-open', [url, "&"]);
#else
@@ -538,7 +553,7 @@ class CoolUtil
* Stops a sound, set its time to 0 then play it again.
* @param sound Sound to replay.
*/
public static function replay(sound:FlxSound) {
public static inline function replay(sound:FlxSound) {
sound.stop();
sound.time = 0;
sound.play();
@@ -570,7 +585,7 @@ class CoolUtil
* @param frontEnd SoundFrontEnd to set the music of
* @param music Music
*/
public static function setMusic(frontEnd:SoundFrontEnd, music:FlxSound) {
public static inline function setMusic(frontEnd:SoundFrontEnd, music:FlxSound) {
if (frontEnd.music != null)
@:privateAccess frontEnd.destroySound(frontEnd.music);
frontEnd.list.remove(music);
+17 -25
View File
@@ -16,44 +16,39 @@ class NoteGroup extends FlxTypedGroup<Note> {
public inline function sortNotes() {
sort(function(i, n1, n2) {
if (n1.strumTime == n2.strumTime)
return n1.isSustainNote ? -1 : 1;
return FlxSort.byValues(FlxSort.ASCENDING, n1.strumTime, n2.strumTime);
return n1.isSustainNote ? 1 : -1;
return FlxSort.byValues(FlxSort.DESCENDING, n1.strumTime, n2.strumTime);
});
}
public override function update(elapsed:Float) {
i = 0;
i = length-1;
__loopSprite = null;
while(i < length) {
__loopSprite = members[i];
while(i >= 0) {
__loopSprite = members[i--];
if (__loopSprite == null || !__loopSprite.exists || !__loopSprite.active) {
i++;
continue;
}
if (__loopSprite.strumTime - Conductor.songPosition > 1500)
break;
__loopSprite.update(elapsed);
i++;
}
}
public override function draw() {
@:privateAccess var oldDefaultCameras = FlxCamera._defaultCameras;
@:privateAccess if (cameras != null) FlxCamera._defaultCameras = cameras;
i = 0;
__loopSprite = null;
var oldCur = __currentlyLooping;
__currentlyLooping = true;
while(i < length) {
__loopSprite = members[i];
if (__loopSprite == null || !__loopSprite.exists || !__loopSprite.visible) {
i++;
i = length-1;
__loopSprite = null;
while(i >= 0) {
__loopSprite = members[i--];
if (__loopSprite == null || !__loopSprite.exists || !__loopSprite.visible)
continue;
}
if (__loopSprite.strumTime - Conductor.songPosition > 1500) break;
__loopSprite.draw();
i++;
}
__currentlyLooping = oldCur;
@@ -61,21 +56,18 @@ class NoteGroup extends FlxTypedGroup<Note> {
}
public override function forEach(noteFunc:Note->Void, recursive:Bool = false) {
i = 0;
i = length-1;
__loopSprite = null;
var oldCur = __currentlyLooping;
__currentlyLooping = true;
while(i < length) {
__loopSprite = members[i];
if (__loopSprite == null || !__loopSprite.exists) {
i++;
while(i >= 0) {
__loopSprite = members[i--];
if (__loopSprite == null || !__loopSprite.exists)
continue;
}
if (__loopSprite.strumTime - Conductor.songPosition > 1500) break;
noteFunc(__loopSprite);
i++;
}
__currentlyLooping = oldCur;
}
@@ -90,14 +82,14 @@ class NoteGroup extends FlxTypedGroup<Note> {
if (members == null)
return null;
var index:Int = members.indexOf(Object);
var index:Int = members.indexOfFromLast(Object);
if (index < 0)
return null;
// doesnt prevent looping from breaking
if (Splice && __currentlyLooping && i >= index)
i--;
i++;
if (Splice)
{
+3 -3
View File
@@ -903,7 +903,7 @@ class PlayState extends MusicBeatState
}
}
events.sort(function(p1, p2) {
return FlxSort.byValues(FlxSort.ASCENDING, p1.time, p2.time);
return FlxSort.byValues(FlxSort.DESCENDING, p1.time, p2.time);
});
camZoomingInterval = cast songData.meta.beatsPerMesure.getDefault(4);
@@ -1112,8 +1112,8 @@ class PlayState extends MusicBeatState
}
}
while(events.length > 0 && events[0].time <= Conductor.songPosition)
executeEvent(events.shift());
while(events.length > 0 && events.last().time <= Conductor.songPosition)
executeEvent(events.pop());
if (generatedMusic && strumLines.members[curCameraTarget] != null)
{