mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-12-24 06:06:47 +00:00
Merge branch 'rewrite/master' into lemz1/note-kind-scripts
This commit is contained in:
commit
4164329ca9
|
@ -252,6 +252,10 @@ class PolymodHandler
|
|||
// Lib.load() can load malicious DLLs
|
||||
Polymod.blacklistImport('cpp.Lib');
|
||||
|
||||
// `Unserializer`
|
||||
// Unserializerr.DEFAULT_RESOLVER.resolveClass() can access blacklisted packages
|
||||
Polymod.blacklistImport('Unserializer');
|
||||
|
||||
// `polymod.*`
|
||||
// You can probably unblacklist a module
|
||||
for (cls in ClassMacro.listClassesInPackage('polymod'))
|
||||
|
|
|
@ -504,7 +504,7 @@ class PlayState extends MusicBeatSubState
|
|||
public var camGame:FlxCamera;
|
||||
|
||||
/**
|
||||
* The camera which contains, and controls visibility of, a video cutscene.
|
||||
* The camera which contains, and controls visibility of, a video cutscene, dialogue, pause menu and sticker transition.
|
||||
*/
|
||||
public var camCutscene:FlxCamera;
|
||||
|
||||
|
@ -579,7 +579,6 @@ class PlayState extends MusicBeatSubState
|
|||
|
||||
// TODO: Refactor or document
|
||||
var generatedMusic:Bool = false;
|
||||
var perfectMode:Bool = false;
|
||||
|
||||
static final BACKGROUND_COLOR:FlxColor = FlxColor.BLACK;
|
||||
|
||||
|
@ -976,7 +975,7 @@ class PlayState extends MusicBeatSubState
|
|||
|
||||
FlxTransitionableState.skipNextTransIn = true;
|
||||
FlxTransitionableState.skipNextTransOut = true;
|
||||
pauseSubState.camera = camHUD;
|
||||
pauseSubState.camera = camCutscene;
|
||||
openSubState(pauseSubState);
|
||||
// boyfriendPos.put(); // TODO: Why is this here?
|
||||
}
|
||||
|
@ -1350,64 +1349,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.
|
||||
*/
|
||||
override function debug_refreshModules():Void
|
||||
override function reloadAssets():Void
|
||||
{
|
||||
// Prevent further gameplay updates, which will try to reference dead objects.
|
||||
criticalFailure = true;
|
||||
|
||||
// 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);
|
||||
funkin.modding.PolymodHandler.forceReloadAssets();
|
||||
lastParams.targetSong = SongRegistry.instance.fetchEntry(currentSong.id);
|
||||
LoadingState.loadPlayState(lastParams);
|
||||
}
|
||||
|
||||
override function stepHit():Bool
|
||||
|
@ -1503,9 +1451,6 @@ class PlayState extends MusicBeatSubState
|
|||
if (playerStrumline != null) playerStrumline.onBeatHit();
|
||||
if (opponentStrumline != null) opponentStrumline.onBeatHit();
|
||||
|
||||
// Make the characters dance on the beat
|
||||
danceOnBeat();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1516,26 +1461,6 @@ class PlayState extends MusicBeatSubState
|
|||
super.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles characters dancing to the beat of the current song.
|
||||
*
|
||||
* TODO: Move some of this logic into `Bopper.hx`, or individual character scripts.
|
||||
*/
|
||||
function danceOnBeat():Void
|
||||
{
|
||||
if (currentStage == null) return;
|
||||
|
||||
// TODO: Add HEY! song events to Tutorial.
|
||||
if (Conductor.instance.currentBeat % 16 == 15
|
||||
&& currentStage.getDad().characterId == 'gf'
|
||||
&& Conductor.instance.currentBeat > 16
|
||||
&& Conductor.instance.currentBeat < 48)
|
||||
{
|
||||
currentStage.getBoyfriend().playAnimation('hey', true);
|
||||
currentStage.getDad().playAnimation('cheer', true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the game and HUD cameras.
|
||||
*/
|
||||
|
@ -1936,7 +1861,6 @@ class PlayState extends MusicBeatSubState
|
|||
if (!result) return;
|
||||
|
||||
isInCutscene = false;
|
||||
camCutscene.visible = false;
|
||||
|
||||
// TODO: Maybe tween in the camera after any cutscenes.
|
||||
camHUD.visible = true;
|
||||
|
@ -2612,12 +2536,6 @@ class PlayState extends MusicBeatSubState
|
|||
*/
|
||||
function debugKeyShit():Void
|
||||
{
|
||||
#if !debug
|
||||
perfectMode = false;
|
||||
#else
|
||||
if (FlxG.keys.justPressed.H) camHUD.visible = !camHUD.visible;
|
||||
#end
|
||||
|
||||
#if CHART_EDITOR_SUPPORTED
|
||||
// Open the stage editor overlaying the current state.
|
||||
if (controls.DEBUG_STAGE)
|
||||
|
@ -2649,6 +2567,9 @@ class PlayState extends MusicBeatSubState
|
|||
#end
|
||||
|
||||
#if (debug || FORCE_DEBUG_VERSION)
|
||||
// H: Hide the HUD.
|
||||
if (FlxG.keys.justPressed.H) camHUD.visible = !camHUD.visible;
|
||||
|
||||
// 1: End the song immediately.
|
||||
if (FlxG.keys.justPressed.ONE) endSong(true);
|
||||
|
||||
|
|
|
@ -81,7 +81,6 @@ class VideoCutscene
|
|||
// Trigger the cutscene. Don't play the song in the background.
|
||||
PlayState.instance.isInCutscene = true;
|
||||
PlayState.instance.camHUD.visible = false;
|
||||
PlayState.instance.camCutscene.visible = true;
|
||||
|
||||
// Display a black screen to hide the game while the video is playing.
|
||||
blackScreen = new FlxSprite(-200, -200).makeGraphic(FlxG.width * 2, FlxG.height * 2, FlxColor.BLACK);
|
||||
|
@ -305,7 +304,6 @@ class VideoCutscene
|
|||
vid = null;
|
||||
#end
|
||||
|
||||
PlayState.instance.camCutscene.visible = true;
|
||||
PlayState.instance.camHUD.visible = true;
|
||||
|
||||
FlxTween.tween(blackScreen, {alpha: 0}, transitionTime,
|
||||
|
|
|
@ -277,7 +277,7 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry<SongMeta
|
|||
// If there are no difficulties in the metadata, there's a problem.
|
||||
if (metadata.playData.difficulties.length == 0)
|
||||
{
|
||||
throw 'Song $id has no difficulties listed in metadata!';
|
||||
trace('[WARN] Song $id has no difficulties listed in metadata!');
|
||||
}
|
||||
|
||||
// There may be more difficulties in the chart file than in the metadata,
|
||||
|
|
|
@ -78,9 +78,6 @@ class MusicBeatState extends FlxTransitionableState implements IEventHandler
|
|||
{
|
||||
// Emergency exit button.
|
||||
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)
|
||||
|
@ -114,12 +111,10 @@ class MusicBeatState extends FlxTransitionableState implements IEventHandler
|
|||
ModuleHandler.callEvent(event);
|
||||
}
|
||||
|
||||
function debug_refreshModules()
|
||||
function reloadAssets()
|
||||
{
|
||||
PolymodHandler.forceReloadAssets();
|
||||
|
||||
this.destroy();
|
||||
|
||||
// Create a new instance of the current state, so old data is cleared.
|
||||
FlxG.resetState();
|
||||
}
|
||||
|
|
|
@ -72,9 +72,6 @@ class MusicBeatSubState extends FlxSubState implements IEventHandler
|
|||
// Emergency exit button.
|
||||
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.
|
||||
FlxG.watch.addQuick("musicTime", FlxG.sound.music?.time ?? 0.0);
|
||||
Conductor.watchQuick(conductorInUse);
|
||||
|
@ -82,7 +79,7 @@ class MusicBeatSubState extends FlxSubState implements IEventHandler
|
|||
dispatchEvent(new UpdateScriptEvent(elapsed));
|
||||
}
|
||||
|
||||
function debug_refreshModules()
|
||||
function reloadAssets()
|
||||
{
|
||||
PolymodHandler.forceReloadAssets();
|
||||
|
||||
|
|
|
@ -284,6 +284,21 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
|||
*/
|
||||
public static final WELCOME_MUSIC_FADE_IN_DURATION:Float = 10.0;
|
||||
|
||||
/**
|
||||
* A map of the keys for every live input style.
|
||||
*/
|
||||
public static final LIVE_INPUT_KEYS:Map<ChartEditorLiveInputStyle, Array<FlxKey>> = [
|
||||
NumberKeys => [
|
||||
FIVE, SIX, SEVEN, EIGHT,
|
||||
ONE, TWO, THREE, FOUR
|
||||
],
|
||||
WASDKeys => [
|
||||
LEFT, DOWN, UP, RIGHT,
|
||||
A, S, W, D
|
||||
],
|
||||
None => []
|
||||
];
|
||||
|
||||
/**
|
||||
* INSTANCE DATA
|
||||
*/
|
||||
|
@ -5146,46 +5161,10 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
|||
function handlePlayhead():Void
|
||||
{
|
||||
// Place notes at the playhead with the keyboard.
|
||||
switch (currentLiveInputStyle)
|
||||
for (note => key in LIVE_INPUT_KEYS[currentLiveInputStyle])
|
||||
{
|
||||
case ChartEditorLiveInputStyle.WASDKeys:
|
||||
if (FlxG.keys.justPressed.A) placeNoteAtPlayhead(4);
|
||||
if (FlxG.keys.justReleased.A) finishPlaceNoteAtPlayhead(4);
|
||||
if (FlxG.keys.justPressed.S) placeNoteAtPlayhead(5);
|
||||
if (FlxG.keys.justReleased.S) finishPlaceNoteAtPlayhead(5);
|
||||
if (FlxG.keys.justPressed.W) placeNoteAtPlayhead(6);
|
||||
if (FlxG.keys.justReleased.W) finishPlaceNoteAtPlayhead(6);
|
||||
if (FlxG.keys.justPressed.D) placeNoteAtPlayhead(7);
|
||||
if (FlxG.keys.justReleased.D) finishPlaceNoteAtPlayhead(7);
|
||||
|
||||
if (FlxG.keys.justPressed.LEFT) placeNoteAtPlayhead(0);
|
||||
if (FlxG.keys.justReleased.LEFT) finishPlaceNoteAtPlayhead(0);
|
||||
if (FlxG.keys.justPressed.DOWN) placeNoteAtPlayhead(1);
|
||||
if (FlxG.keys.justReleased.DOWN) finishPlaceNoteAtPlayhead(1);
|
||||
if (FlxG.keys.justPressed.UP) placeNoteAtPlayhead(2);
|
||||
if (FlxG.keys.justReleased.UP) finishPlaceNoteAtPlayhead(2);
|
||||
if (FlxG.keys.justPressed.RIGHT) placeNoteAtPlayhead(3);
|
||||
if (FlxG.keys.justReleased.RIGHT) finishPlaceNoteAtPlayhead(3);
|
||||
case ChartEditorLiveInputStyle.NumberKeys:
|
||||
// Flipped because Dad is on the left but represents data 0-3.
|
||||
if (FlxG.keys.justPressed.ONE) placeNoteAtPlayhead(4);
|
||||
if (FlxG.keys.justReleased.ONE) finishPlaceNoteAtPlayhead(4);
|
||||
if (FlxG.keys.justPressed.TWO) placeNoteAtPlayhead(5);
|
||||
if (FlxG.keys.justReleased.TWO) finishPlaceNoteAtPlayhead(5);
|
||||
if (FlxG.keys.justPressed.THREE) placeNoteAtPlayhead(6);
|
||||
if (FlxG.keys.justReleased.THREE) finishPlaceNoteAtPlayhead(6);
|
||||
if (FlxG.keys.justPressed.FOUR) placeNoteAtPlayhead(7);
|
||||
if (FlxG.keys.justReleased.FOUR) finishPlaceNoteAtPlayhead(7);
|
||||
|
||||
if (FlxG.keys.justPressed.FIVE) placeNoteAtPlayhead(0);
|
||||
if (FlxG.keys.justReleased.FIVE) finishPlaceNoteAtPlayhead(0);
|
||||
if (FlxG.keys.justPressed.SIX) placeNoteAtPlayhead(1);
|
||||
if (FlxG.keys.justPressed.SEVEN) placeNoteAtPlayhead(2);
|
||||
if (FlxG.keys.justReleased.SEVEN) finishPlaceNoteAtPlayhead(2);
|
||||
if (FlxG.keys.justPressed.EIGHT) placeNoteAtPlayhead(3);
|
||||
if (FlxG.keys.justReleased.EIGHT) finishPlaceNoteAtPlayhead(3);
|
||||
case ChartEditorLiveInputStyle.None:
|
||||
// Do nothing.
|
||||
if (FlxG.keys.checkStatus(key, JUST_PRESSED)) placeNoteAtPlayhead(note)
|
||||
else if (FlxG.keys.checkStatus(key, JUST_RELEASED)) finishPlaceNoteAtPlayhead(note);
|
||||
}
|
||||
|
||||
// Place events at playhead.
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package funkin.util.plugins;
|
||||
|
||||
import flixel.FlxG;
|
||||
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.
|
||||
|
@ -28,10 +31,15 @@ class ReloadAssetsDebugPlugin extends FlxBasic
|
|||
if (FlxG.keys.justPressed.F5)
|
||||
#end
|
||||
{
|
||||
funkin.modding.PolymodHandler.forceReloadAssets();
|
||||
var state:Dynamic = FlxG.state;
|
||||
if (state is MusicBeatState || state is MusicBeatSubState) state.reloadAssets();
|
||||
else
|
||||
{
|
||||
funkin.modding.PolymodHandler.forceReloadAssets();
|
||||
|
||||
// Create a new instance of the current state, so old data is cleared.
|
||||
FlxG.resetState();
|
||||
// Create a new instance of the current state, so old data is cleared.
|
||||
FlxG.resetState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue