New pre-caching techniques should reduce stuttering on Weekend 1.

This commit is contained in:
EliteMasterEric 2024-02-23 00:16:11 -05:00
parent ddfb0c6a61
commit e349b0bb49
5 changed files with 22 additions and 8 deletions

View File

@ -2281,11 +2281,6 @@ class PlayState extends MusicBeatSubState
if (FlxG.keys.justPressed.H) camHUD.visible = !camHUD.visible;
#end
// Eject button
if (FlxG.keys.justPressed.F4) FlxG.switchState(() -> new MainMenuState());
if (FlxG.keys.justPressed.F5) debug_refreshModules();
// Open the stage editor overlaying the current state.
if (controls.DEBUG_STAGE)
{

View File

@ -35,6 +35,7 @@ class NoteSplash extends FlxSprite
*/
function setup():Void
{
if (frameCollection?.parent?.isDestroyed ?? false) frameCollection = null;
if (frameCollection == null) preloadFrames();
this.frames = frameCollection;
@ -75,6 +76,8 @@ class NoteSplash extends FlxSprite
this.playAnimation('splash${variant}Right');
}
if (animation.curAnim == null) return;
// Vary the speed of the animation a bit.
animation.curAnim.frameRate = FRAMERATE_DEFAULT + FlxG.random.int(-FRAMERATE_VARIANCE, FRAMERATE_VARIANCE);

View File

@ -106,6 +106,9 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
FlxG.log.warn('Note texture is not cached: ${getNoteAssetPath()}');
}
// Purge the note frames if the cached atlas is invalid.
if (noteFrames?.parent?.isDestroyed ?? false) noteFrames = null;
if (noteFrames != null && !force) return noteFrames;
noteFrames = Paths.getSparrowAtlas(getNoteAssetPath(), getNoteAssetLibrary());
@ -115,8 +118,6 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
throw 'Could not load note frames for note style: $id';
}
noteFrames.parent.persist = true;
return noteFrames;
}

View File

@ -225,6 +225,10 @@ class LoadingState extends MusicBeatState
FunkinSprite.cacheTexture(Paths.image('num7'));
FunkinSprite.cacheTexture(Paths.image('num8'));
FunkinSprite.cacheTexture(Paths.image('num9'));
FunkinSprite.cacheTexture(Paths.image('notes', 'shared'));
FunkinSprite.cacheTexture(Paths.image('noteSplashes', 'shared'));
FunkinSprite.cacheTexture(Paths.image('noteStrumline', 'shared'));
FunkinSprite.cacheTexture(Paths.image('NOTE_hold_assets'));
FunkinSprite.cacheTexture(Paths.image('ready', 'shared'));
FunkinSprite.cacheTexture(Paths.image('set', 'shared'));
FunkinSprite.cacheTexture(Paths.image('go', 'shared'));
@ -232,7 +236,14 @@ class LoadingState extends MusicBeatState
FunkinSprite.cacheTexture(Paths.image('good', 'shared'));
FunkinSprite.cacheTexture(Paths.image('bad', 'shared'));
FunkinSprite.cacheTexture(Paths.image('shit', 'shared'));
FunkinSprite.cacheTexture(Paths.image('miss', 'shared')); // TODO: Remove
FunkinSprite.cacheTexture(Paths.image('miss', 'shared')); // TODO: remove this
// FunkinSprite.cacheAllNoteStyleTextures(noteStyle) // This will replace the stuff above!
// FunkinSprite.cacheAllCharacterTextures(player)
// FunkinSprite.cacheAllCharacterTextures(girlfriend)
// FunkinSprite.cacheAllCharacterTextures(opponent)
// FunkinSprite.cacheAllStageTextures(stage)
FunkinSprite.purgeCache();
FlxG.switchState(playStateCtor);

View File

@ -246,6 +246,10 @@ class StickerSubState extends MusicBeatSubState
FlxTransitionableState.skipNextTransIn = true;
FlxTransitionableState.skipNextTransOut = true;
// TODO: Rework this asset caching stuff
FunkinSprite.preparePurgeCache();
FunkinSprite.purgeCache();
// I think this grabs the screen and puts it under the stickers?
// Leaving this commented out rather than stripping it out because it's cool...
/*