Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions source/funkin/backend/utils/CoolUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ final class CoolUtil
*/
public static inline function browsePath(path:String) {
var formattedPath:String = Path.normalize(path);

#if windows
formattedPath = formattedPath.replace("/", "\\");
Sys.command("explorer", [formattedPath]);
Expand Down Expand Up @@ -1003,6 +1003,20 @@ final class CoolUtil
return result;
}

/**
* Returns if the mouse is overlapping the sprite on a given camera, taking the camera's position, scroll and zoom into account.
*
* @param sprite Any `FlxBasic`
* @param camera The camera you want to check overlap on. Uses the sprite's camera by default.
* @return Bool
*/
public static function mouseOverlaps(sprite:FlxBasic, ?camera:FlxCamera) {
var camToCheck:FlxCamera = camera ?? sprite.camera;
var posthing:FlxPoint = FlxG.mouse.getWorldPosition(camToCheck);

return posthing != null && FlxMath.inBounds(posthing.x, sprite.x, sprite.x + sprite.width) && FlxMath.inBounds(posthing.y, sprite.y, sprite.y + sprite.height);
}

/**
* Sorts an array alphabetically.
* @param array Array to sort
Expand Down Expand Up @@ -1053,7 +1067,7 @@ final class CoolUtil
r.add(str);
return r.toString();
}

public static inline function bound(Value:Float, Min:Float, Max:Float):Float {
#if cpp
var _hx_tmp1:Float = Value;
Expand Down Expand Up @@ -1200,8 +1214,8 @@ final class CoolUtil

/**
* ! REQUIRES FULL PATH!!!
* @param path
* @return Bool
* @param path
* @return Bool
*/
public static function imageHasFrameData(path:String):String {
if (FileSystem.exists(Path.withExtension(path, "xml"))) return "xml";
Expand Down Expand Up @@ -1267,7 +1281,7 @@ final class CoolUtil
public static function getAnimsListFromSprite(spr:FunkinSprite):Array<String> {
if (spr.animateAtlas != null) {
return [for (symbol => timeline in spr.animateAtlas.anim.symbolDictionary) symbol];
} else
} else
return getAnimsListFromFrames(spr.frames);
}

Expand Down