mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-15 11:22:55 +00:00
Fix F5 chart not reloading
This commit is contained in:
parent
3f63bc35a4
commit
7b9e4a0542
|
@ -1347,64 +1347,13 @@ class PlayState extends MusicBeatSubState
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes any references to the current stage, then clears the stage cache,
|
|
||||||
* then reloads all the stages.
|
|
||||||
*
|
|
||||||
* This is useful for when you want to edit a stage without reloading the whole game.
|
|
||||||
* Reloading works on both the JSON and the HXC, if applicable.
|
|
||||||
*
|
|
||||||
* Call this by pressing F5 on a debug build.
|
* Call this by pressing F5 on a debug build.
|
||||||
*/
|
*/
|
||||||
override function debug_refreshModules():Void
|
override function reloadAssets():Void
|
||||||
{
|
{
|
||||||
// Prevent further gameplay updates, which will try to reference dead objects.
|
funkin.modding.PolymodHandler.forceReloadAssets();
|
||||||
criticalFailure = true;
|
lastParams.targetSong = SongRegistry.instance.fetchEntry(currentSong.id);
|
||||||
|
LoadingState.loadPlayState(lastParams);
|
||||||
// Remove the current stage. If the stage gets deleted while it's still in use,
|
|
||||||
// it'll probably crash the game or something.
|
|
||||||
if (this.currentStage != null)
|
|
||||||
{
|
|
||||||
remove(currentStage);
|
|
||||||
var event:ScriptEvent = new ScriptEvent(DESTROY, false);
|
|
||||||
ScriptEventDispatcher.callEvent(currentStage, event);
|
|
||||||
currentStage = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!overrideMusic)
|
|
||||||
{
|
|
||||||
// Stop the instrumental.
|
|
||||||
if (FlxG.sound.music != null)
|
|
||||||
{
|
|
||||||
FlxG.sound.music.destroy();
|
|
||||||
FlxG.sound.music = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stop the vocals.
|
|
||||||
if (vocals != null && vocals.exists)
|
|
||||||
{
|
|
||||||
vocals.destroy();
|
|
||||||
vocals = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Stop the instrumental.
|
|
||||||
if (FlxG.sound.music != null)
|
|
||||||
{
|
|
||||||
FlxG.sound.music.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stop the vocals.
|
|
||||||
if (vocals != null && vocals.exists)
|
|
||||||
{
|
|
||||||
vocals.stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
super.debug_refreshModules();
|
|
||||||
|
|
||||||
var event:ScriptEvent = new ScriptEvent(CREATE, false);
|
|
||||||
ScriptEventDispatcher.callEvent(currentSong, event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override function stepHit():Bool
|
override function stepHit():Bool
|
||||||
|
|
|
@ -78,9 +78,6 @@ class MusicBeatState extends FlxTransitionableState implements IEventHandler
|
||||||
{
|
{
|
||||||
// Emergency exit button.
|
// Emergency exit button.
|
||||||
if (FlxG.keys.justPressed.F4) FlxG.switchState(() -> new MainMenuState());
|
if (FlxG.keys.justPressed.F4) FlxG.switchState(() -> new MainMenuState());
|
||||||
|
|
||||||
// This can now be used in EVERY STATE YAY!
|
|
||||||
if (FlxG.keys.justPressed.F5) debug_refreshModules();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override function update(elapsed:Float)
|
override function update(elapsed:Float)
|
||||||
|
@ -114,12 +111,10 @@ class MusicBeatState extends FlxTransitionableState implements IEventHandler
|
||||||
ModuleHandler.callEvent(event);
|
ModuleHandler.callEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
function debug_refreshModules()
|
function reloadAssets()
|
||||||
{
|
{
|
||||||
PolymodHandler.forceReloadAssets();
|
PolymodHandler.forceReloadAssets();
|
||||||
|
|
||||||
this.destroy();
|
|
||||||
|
|
||||||
// Create a new instance of the current state, so old data is cleared.
|
// Create a new instance of the current state, so old data is cleared.
|
||||||
FlxG.resetState();
|
FlxG.resetState();
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,9 +72,6 @@ class MusicBeatSubState extends FlxSubState implements IEventHandler
|
||||||
// Emergency exit button.
|
// Emergency exit button.
|
||||||
if (FlxG.keys.justPressed.F4) FlxG.switchState(() -> new MainMenuState());
|
if (FlxG.keys.justPressed.F4) FlxG.switchState(() -> new MainMenuState());
|
||||||
|
|
||||||
// This can now be used in EVERY STATE YAY!
|
|
||||||
if (FlxG.keys.justPressed.F5) debug_refreshModules();
|
|
||||||
|
|
||||||
// Display Conductor info in the watch window.
|
// Display Conductor info in the watch window.
|
||||||
FlxG.watch.addQuick("musicTime", FlxG.sound.music?.time ?? 0.0);
|
FlxG.watch.addQuick("musicTime", FlxG.sound.music?.time ?? 0.0);
|
||||||
Conductor.watchQuick(conductorInUse);
|
Conductor.watchQuick(conductorInUse);
|
||||||
|
@ -82,7 +79,7 @@ class MusicBeatSubState extends FlxSubState implements IEventHandler
|
||||||
dispatchEvent(new UpdateScriptEvent(elapsed));
|
dispatchEvent(new UpdateScriptEvent(elapsed));
|
||||||
}
|
}
|
||||||
|
|
||||||
function debug_refreshModules()
|
function reloadAssets()
|
||||||
{
|
{
|
||||||
PolymodHandler.forceReloadAssets();
|
PolymodHandler.forceReloadAssets();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package funkin.util.plugins;
|
package funkin.util.plugins;
|
||||||
|
|
||||||
|
import flixel.FlxG;
|
||||||
import flixel.FlxBasic;
|
import flixel.FlxBasic;
|
||||||
|
import funkin.ui.MusicBeatState;
|
||||||
|
import funkin.ui.MusicBeatSubState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A plugin which adds functionality to press `F5` to reload all game assets, then reload the current state.
|
* A plugin which adds functionality to press `F5` to reload all game assets, then reload the current state.
|
||||||
|
@ -27,6 +30,10 @@ class ReloadAssetsDebugPlugin extends FlxBasic
|
||||||
#else
|
#else
|
||||||
if (FlxG.keys.justPressed.F5)
|
if (FlxG.keys.justPressed.F5)
|
||||||
#end
|
#end
|
||||||
|
{
|
||||||
|
var state:Dynamic = FlxG.state;
|
||||||
|
if (state is MusicBeatState || state is MusicBeatSubState) state.reloadAssets();
|
||||||
|
else
|
||||||
{
|
{
|
||||||
funkin.modding.PolymodHandler.forceReloadAssets();
|
funkin.modding.PolymodHandler.forceReloadAssets();
|
||||||
|
|
||||||
|
@ -34,6 +41,7 @@ class ReloadAssetsDebugPlugin extends FlxBasic
|
||||||
FlxG.resetState();
|
FlxG.resetState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override function destroy():Void
|
public override function destroy():Void
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue