Skip to content

Commit

Permalink
Fixed modded files preload and health icon sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowMario committed Sep 15, 2024
1 parent 256f915 commit a6369c7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion source/objects/HealthIcon.hx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class HealthIcon extends FlxSprite
if(!Paths.fileExists('images/' + name + '.png', IMAGE)) name = 'icons/icon-face'; //Prevents crash from missing icon

var graphic = Paths.image(name, allowGPU);
var iSize:Float = Math.floor(graphic.width / graphic.height);
var iSize:Float = Math.round(graphic.width / graphic.height);
loadGraphic(graphic, true, Math.floor(graphic.width / iSize), Math.floor(graphic.height));
iconOffsets[0] = (width - 150) / iSize;
iconOffsets[1] = (height - 150) / iSize;
Expand Down
10 changes: 7 additions & 3 deletions source/states/LoadingState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class LoadingState extends MusicBeatState

static var originalBitmapKeys:Map<String, String> = [];
static var requestedBitmaps:Map<String, BitmapData> = [];
static var mutex:Mutex = new Mutex();
static var mutex:Mutex;

function new(target:FlxState, stopMusic:Bool)
{
Expand Down Expand Up @@ -244,19 +244,18 @@ class LoadingState extends MusicBeatState
MusicBeatState.switchState(target);
transitioning = true;
finishedLoading = true;
mutex = null;
}

public static function checkLoaded():Bool
{
mutex.acquire();
for (key => bitmap in requestedBitmaps)
{
if (bitmap != null && Paths.cacheBitmap(originalBitmapKeys.get(key), bitmap) != null) trace('finished preloading image $key');
else trace('failed to cache image $key');
}
requestedBitmaps.clear();
originalBitmapKeys.clear();
mutex.release();
return (loaded == loadMax && initialThreadCompleted);
}

Expand Down Expand Up @@ -522,6 +521,7 @@ class LoadingState extends MusicBeatState

public static function startThreads()
{
mutex = new Mutex();
loadMax = imagesToPrepare.length + soundsToPrepare.length + musicToPrepare.length + songsToPrepare.length;
loaded = 0;

Expand Down Expand Up @@ -650,7 +650,11 @@ class LoadingState extends MusicBeatState
var file:String = Paths.getPath(requestKey, IMAGE);
if (#if sys FileSystem.exists(file) || #end OpenFlAssets.exists(file, IMAGE))
{
#if sys
var bitmap:BitmapData = BitmapData.fromFile(file);
#else
var bitmap:BitmapData = OpenFlAssets.getBitmapData(file, false);
#end
mutex.acquire();
requestedBitmaps.set(file, bitmap);
originalBitmapKeys.set(file, requestKey);
Expand Down

0 comments on commit a6369c7

Please sign in to comment.