mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-23 08:07:54 -05:00
Merge remote-tracking branch 'origin/feature/conductor-signal-rework' into feature/2hot-cutscenes
This commit is contained in:
commit
a9dd85c865
4 changed files with 105 additions and 39 deletions
2
art
2
art
|
@ -1 +1 @@
|
||||||
Subproject commit 00463685fa570f0c853d08e250b46ef80f30bc48
|
Subproject commit 03e7c2a2353b184e45955c96d763b7cdf1acbc34
|
2
assets
2
assets
|
@ -1 +1 @@
|
||||||
Subproject commit c25a4119d6c37fa5ff49533111bd797e6fe2d7b1
|
Subproject commit 77a7f44a89349d40a41b94c1d65381386759359b
|
|
@ -39,27 +39,39 @@ class Conductor
|
||||||
|
|
||||||
static var _instance:Null<Conductor> = null;
|
static var _instance:Null<Conductor> = null;
|
||||||
|
|
||||||
static function get_instance():Conductor
|
|
||||||
{
|
|
||||||
if (_instance == null) _instance = new Conductor();
|
|
||||||
return _instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signal fired when the current Conductor instance advances to a new measure.
|
* Signal fired when the current static Conductor instance advances to a new measure.
|
||||||
*/
|
*/
|
||||||
public static var measureHit(default, null):FlxSignal = new FlxSignal();
|
public static var measureHit(default, null):FlxSignal = new FlxSignal();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signal fired when THIS Conductor instance advances to a new measure.
|
||||||
|
* TODO: This naming sucks but we can't make a static and instance field with the same name!
|
||||||
|
*/
|
||||||
|
public var onMeasureHit(default, null):FlxSignal = new FlxSignal();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signal fired when the current Conductor instance advances to a new beat.
|
* Signal fired when the current Conductor instance advances to a new beat.
|
||||||
*/
|
*/
|
||||||
public static var beatHit(default, null):FlxSignal = new FlxSignal();
|
public static var beatHit(default, null):FlxSignal = new FlxSignal();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signal fired when THIS Conductor instance advances to a new beat.
|
||||||
|
* TODO: This naming sucks but we can't make a static and instance field with the same name!
|
||||||
|
*/
|
||||||
|
public var onBeatHit(default, null):FlxSignal = new FlxSignal();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signal fired when the current Conductor instance advances to a new step.
|
* Signal fired when the current Conductor instance advances to a new step.
|
||||||
*/
|
*/
|
||||||
public static var stepHit(default, null):FlxSignal = new FlxSignal();
|
public static var stepHit(default, null):FlxSignal = new FlxSignal();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signal fired when THIS Conductor instance advances to a new step.
|
||||||
|
* TODO: This naming sucks but we can't make a static and instance field with the same name!
|
||||||
|
*/
|
||||||
|
public var onStepHit(default, null):FlxSignal = new FlxSignal();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list of time changes in the song.
|
* The list of time changes in the song.
|
||||||
* There should be at least one time change (at the beginning of the song) to define the BPM.
|
* There should be at least one time change (at the beginning of the song) to define the BPM.
|
||||||
|
@ -247,6 +259,69 @@ class Conductor
|
||||||
return Std.int(timeSignatureNumerator / timeSignatureDenominator * Constants.STEPS_PER_BEAT * Constants.STEPS_PER_BEAT);
|
return Std.int(timeSignatureNumerator / timeSignatureDenominator * Constants.STEPS_PER_BEAT * Constants.STEPS_PER_BEAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the Conductor, replacing the current instance with a fresh one.
|
||||||
|
*/
|
||||||
|
public static function reset():Void
|
||||||
|
{
|
||||||
|
set_instance(new Conductor());
|
||||||
|
}
|
||||||
|
|
||||||
|
static function dispatchMeasureHit():Void
|
||||||
|
{
|
||||||
|
Conductor.measureHit.dispatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
static function dispatchBeatHit():Void
|
||||||
|
{
|
||||||
|
Conductor.beatHit.dispatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
static function dispatchStepHit():Void
|
||||||
|
{
|
||||||
|
Conductor.stepHit.dispatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
static function setupSingleton(input:Conductor):Void
|
||||||
|
{
|
||||||
|
input.onMeasureHit.add(dispatchMeasureHit);
|
||||||
|
|
||||||
|
input.onBeatHit.add(dispatchBeatHit);
|
||||||
|
|
||||||
|
input.onStepHit.add(dispatchStepHit);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function clearSingleton(input:Conductor):Void
|
||||||
|
{
|
||||||
|
input.onMeasureHit.remove(dispatchMeasureHit);
|
||||||
|
|
||||||
|
input.onBeatHit.remove(dispatchBeatHit);
|
||||||
|
|
||||||
|
input.onStepHit.remove(dispatchStepHit);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function get_instance():Conductor
|
||||||
|
{
|
||||||
|
if (Conductor._instance == null) set_instance(new Conductor());
|
||||||
|
if (Conductor._instance == null) throw "Could not initialize singleton Conductor!";
|
||||||
|
return Conductor._instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function set_instance(instance:Conductor):Conductor
|
||||||
|
{
|
||||||
|
// Use _instance in here to avoid recursion
|
||||||
|
if (Conductor._instance != null) clearSingleton(Conductor._instance);
|
||||||
|
|
||||||
|
Conductor._instance = instance;
|
||||||
|
|
||||||
|
if (Conductor._instance != null) setupSingleton(Conductor._instance);
|
||||||
|
|
||||||
|
return Conductor._instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constructor.
|
||||||
|
*/
|
||||||
public function new() {}
|
public function new() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -257,6 +332,7 @@ class Conductor
|
||||||
*
|
*
|
||||||
* WARNING: Avoid this for things like setting the BPM of the title screen music,
|
* WARNING: Avoid this for things like setting the BPM of the title screen music,
|
||||||
* you should have a metadata file for it instead.
|
* you should have a metadata file for it instead.
|
||||||
|
* We should probably deprecate this in the future.
|
||||||
*/
|
*/
|
||||||
public function forceBPM(?bpm:Float):Void
|
public function forceBPM(?bpm:Float):Void
|
||||||
{
|
{
|
||||||
|
@ -277,7 +353,7 @@ class Conductor
|
||||||
* BPM, current step, etc. will be re-calculated based on the song position.
|
* BPM, current step, etc. will be re-calculated based on the song position.
|
||||||
*
|
*
|
||||||
* @param songPosition The current position in the song in milliseconds.
|
* @param songPosition The current position in the song in milliseconds.
|
||||||
* Leave blank to use the FlxG.sound.music position.
|
* Leave blank to use the `FlxG.sound.music` position.
|
||||||
*/
|
*/
|
||||||
public function update(?songPos:Float):Void
|
public function update(?songPos:Float):Void
|
||||||
{
|
{
|
||||||
|
@ -330,24 +406,20 @@ class Conductor
|
||||||
this.currentMeasure = Math.floor(currentMeasureTime);
|
this.currentMeasure = Math.floor(currentMeasureTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only fire the signal if we are THE Conductor.
|
|
||||||
if (this == Conductor.instance)
|
|
||||||
{
|
|
||||||
// FlxSignals are really cool.
|
// FlxSignals are really cool.
|
||||||
if (currentStep != oldStep)
|
if (currentStep != oldStep)
|
||||||
{
|
{
|
||||||
Conductor.stepHit.dispatch();
|
this.onStepHit.dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentBeat != oldBeat)
|
if (currentBeat != oldBeat)
|
||||||
{
|
{
|
||||||
Conductor.beatHit.dispatch();
|
this.onBeatHit.dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentMeasure != oldMeasure)
|
if (currentMeasure != oldMeasure)
|
||||||
{
|
{
|
||||||
Conductor.measureHit.dispatch();
|
this.onMeasureHit.dispatch();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,20 +589,14 @@ class Conductor
|
||||||
/**
|
/**
|
||||||
* Add variables of the current Conductor instance to the Flixel debugger.
|
* Add variables of the current Conductor instance to the Flixel debugger.
|
||||||
*/
|
*/
|
||||||
public static function watchQuick():Void
|
public static function watchQuick(?target:Conductor):Void
|
||||||
{
|
{
|
||||||
FlxG.watch.addQuick('songPosition', Conductor.instance.songPosition);
|
if (target == null) target = Conductor.instance;
|
||||||
FlxG.watch.addQuick('bpm', Conductor.instance.bpm);
|
|
||||||
FlxG.watch.addQuick('currentMeasureTime', Conductor.instance.currentMeasureTime);
|
|
||||||
FlxG.watch.addQuick('currentBeatTime', Conductor.instance.currentBeatTime);
|
|
||||||
FlxG.watch.addQuick('currentStepTime', Conductor.instance.currentStepTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
FlxG.watch.addQuick('songPosition', target.songPosition);
|
||||||
* Reset the Conductor, replacing the current instance with a fresh one.
|
FlxG.watch.addQuick('bpm', target.bpm);
|
||||||
*/
|
FlxG.watch.addQuick('currentMeasureTime', target.currentMeasureTime);
|
||||||
public static function reset():Void
|
FlxG.watch.addQuick('currentBeatTime', target.currentBeatTime);
|
||||||
{
|
FlxG.watch.addQuick('currentStepTime', target.currentStepTime);
|
||||||
_instance = new Conductor();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,7 +218,7 @@ class Constants
|
||||||
public static final DEFAULT_VARIATION:String = 'default';
|
public static final DEFAULT_VARIATION:String = 'default';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard variations used by the game.
|
* Standardized variations for charts
|
||||||
*/
|
*/
|
||||||
public static final DEFAULT_VARIATION_LIST:Array<String> = ['default', 'erect', 'pico'];
|
public static final DEFAULT_VARIATION_LIST:Array<String> = ['default', 'erect', 'pico'];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue