Merge branch 'rewrite/master' into bugfix/chart-editor-modifies-freeplay

This commit is contained in:
Cameron Taylor 2024-01-05 17:41:07 -05:00
commit 1e07b6ae22
59 changed files with 1020 additions and 751 deletions

View file

@ -4,8 +4,7 @@
"editor.formatOnSave": true, "editor.formatOnSave": true,
"editor.formatOnPaste": true, "editor.formatOnPaste": true,
"editor.codeActionsOnSave": { "editor.codeActionsOnSave": {
// Compilation server issues can cause auto-cleanup to remove valid imports. "source.organizeImports": "never"
"source.organizeImports": false
}, },
"editor.defaultFormatter": "nadako.vshaxe", "editor.defaultFormatter": "nadako.vshaxe",
"editor.tabSize": 2 "editor.tabSize": 2

View file

@ -99,18 +99,20 @@
<haxelib name="flixel-addons" /> <!-- Additional utilities for Flixel --> <haxelib name="flixel-addons" /> <!-- Additional utilities for Flixel -->
<haxelib name="hscript" /> <!-- Scripting --> <haxelib name="hscript" /> <!-- Scripting -->
<haxelib name="flixel-ui" /> <!-- UI framework (deprecate this? --> <haxelib name="flixel-ui" /> <!-- UI framework (DEPRECATED) -->
<haxelib name="haxeui-core" /> <!-- UI framework --> <haxelib name="haxeui-core" /> <!-- UI framework -->
<haxelib name="haxeui-flixel" /> <!-- Integrate HaxeUI with Flixel --> <haxelib name="haxeui-flixel" /> <!-- Integrate HaxeUI with Flixel -->
<haxelib name="flixel-text-input" /> <!-- Improved text field rendering for HaxeUI -->
<haxelib name="polymod" /> <!-- Modding framework --> <haxelib name="polymod" /> <!-- Modding framework -->
<haxelib name="flxanimate" /> <!-- Texture atlas rendering --> <haxelib name="flxanimate" /> <!-- Texture atlas rendering -->
<haxelib name="hxCodec" /> <!-- Video playback --> <haxelib name="hxCodec" /> <!-- Video playback -->
<haxelib name="json2object" /> <!-- JSON parsing --> <haxelib name="json2object" /> <!-- JSON parsing -->
<haxelib name="tink_json" /> <!-- JSON parsing --> <haxelib name="tink_json" /> <!-- JSON parsing (DEPRECATED) -->
<haxelib name="thx.semver" /> <!-- Version string handling -->
<haxelib name="hxcpp-debug-server" if="desktop debug" /> <!-- VSCode debug support -->
<haxelib name="thx.semver" />
<haxelib name="hxcpp-debug-server" if="desktop debug" />
<!--Disable the Flixel core focus lost screen--> <!--Disable the Flixel core focus lost screen-->
<haxedef name="FLX_NO_FOCUS_LOST_SCREEN" /> <haxedef name="FLX_NO_FOCUS_LOST_SCREEN" />
<!--Disable the Flixel core debugger. Automatically gets set whenever you compile in release mode!--> <!--Disable the Flixel core debugger. Automatically gets set whenever you compile in release mode!-->

2
art

@ -1 +1 @@
Subproject commit 1656bea5370c65879aaeb323e329f403c78071c5 Subproject commit 03e7c2a2353b184e45955c96d763b7cdf1acbc34

2
assets

@ -1 +1 @@
Subproject commit dfaf23dfa11ff67be2eea9113a80ff5dc0040f76 Subproject commit b551cb29078e3599a5d608a22238450f9380a3fc

View file

@ -11,15 +11,20 @@
"name": "flixel", "name": "flixel",
"type": "git", "type": "git",
"dir": null, "dir": null,
"ref": "da04cbda49a4c5eebe93fb61296dbaf4f0f1b556", "ref": "a83738673e7edbf8acba3a1426af284dfe6719fe",
"url": "https://github.com/EliteMasterEric/flixel" "url": "https://github.com/FunkinCrew/flixel"
}, },
{ {
"name": "flixel-addons", "name": "flixel-addons",
"type": "git", "type": "git",
"dir": null, "dir": null,
"ref": "c8c41e26d463aaf2edc0582fb23b6e228235bd16", "ref": "fd3aecdeb5635fa0428dffee204fc78fc26b5885",
"url": "https://github.com/EliteMasterEric/flixel-addons" "url": "https://github.com/FunkinCrew/flixel-addons"
},
{
"name": "flixel-text-input",
"type": "haxelib",
"version": "1.1.0"
}, },
{ {
"name": "flixel-ui", "name": "flixel-ui",
@ -32,8 +37,8 @@
"name": "flxanimate", "name": "flxanimate",
"type": "git", "type": "git",
"dir": null, "dir": null,
"ref": "dd2903f7dc7024335b981edf2a770760cec912e1", "ref": "d7c5621be742e2c98d523dfe5af7528835eaff1e",
"url": "https://github.com/ninjamuffin99/flxanimate" "url": "https://github.com/FunkinCrew/flxanimate"
}, },
{ {
"name": "format", "name": "format",
@ -49,14 +54,14 @@
"name": "haxeui-core", "name": "haxeui-core",
"type": "git", "type": "git",
"dir": null, "dir": null,
"ref": "032192e849cdb7d1070c0a3241c58ee555ffaccc", "ref": "5086e59e7551d775ed4d1fb0188e31de22d1312b",
"url": "https://github.com/haxeui/haxeui-core" "url": "https://github.com/haxeui/haxeui-core"
}, },
{ {
"name": "haxeui-flixel", "name": "haxeui-flixel",
"type": "git", "type": "git",
"dir": null, "dir": null,
"ref": "d90758b229d05206400df867d333c79d9fdbd478", "ref": "2b9cff727999b53ed292b1675ac1c9089ac77600",
"url": "https://github.com/haxeui/haxeui-flixel" "url": "https://github.com/haxeui/haxeui-flixel"
}, },
{ {
@ -95,15 +100,15 @@
"name": "json2object", "name": "json2object",
"type": "git", "type": "git",
"dir": null, "dir": null,
"ref": "f4df19cfa196f85eece55c3367021fc965f1fa9a", "ref": "a8c26f18463c98da32f744c214fe02273e1823fa",
"url": "https://github.com/EliteMasterEric/json2object" "url": "https://github.com/FunkinCrew/json2object"
}, },
{ {
"name": "lime", "name": "lime",
"type": "git", "type": "git",
"dir": null, "dir": null,
"ref": "737b86f121cdc90358d59e2e527934f267c94a2c", "ref": "737b86f121cdc90358d59e2e527934f267c94a2c",
"url": "https://github.com/EliteMasterEric/lime" "url": "https://github.com/FunkinCrew/lime"
}, },
{ {
"name": "mconsole", "name": "mconsole",
@ -124,21 +129,21 @@
"type": "git", "type": "git",
"dir": "src", "dir": "src",
"ref": "master", "ref": "master",
"url": "https://github.com/EliteMasterEric/mockatoo" "url": "https://github.com/FunkinCrew/mockatoo"
}, },
{ {
"name": "munit", "name": "munit",
"type": "git", "type": "git",
"dir": "src", "dir": "src",
"ref": "master", "ref": "master",
"url": "https://github.com/EliteMasterEric/MassiveUnit" "url": "https://github.com/FunkinCrew/MassiveUnit"
}, },
{ {
"name": "openfl", "name": "openfl",
"type": "git", "type": "git",
"dir": null, "dir": null,
"ref": "f229d76361c7e31025a048fe7909847f75bb5d5e", "ref": "f229d76361c7e31025a048fe7909847f75bb5d5e",
"url": "https://github.com/EliteMasterEric/openfl" "url": "https://github.com/FunkinCrew/openfl"
}, },
{ {
"name": "polymod", "name": "polymod",

View file

@ -11,6 +11,7 @@ import funkin.data.song.SongDataUtils;
* A core class which handles musical timing throughout the game, * A core class which handles musical timing throughout the game,
* both in gameplay and in menus. * both in gameplay and in menus.
*/ */
@:nullSafety
class Conductor class Conductor
{ {
// onBeatHit is called every quarter note // onBeatHit is called every quarter note
@ -28,29 +29,53 @@ class Conductor
// 60 BPM = 240 sixteenth notes per minute = 4 onStepHit per second // 60 BPM = 240 sixteenth notes per minute = 4 onStepHit per second
// 7/8 = 3.5 beats per measure = 14 steps per measure // 7/8 = 3.5 beats per measure = 14 steps per measure
/**
* The current instance of the Conductor.
* If one doesn't currently exist, a new one will be created.
*
* You can also do stuff like store a reference to the Conductor and pass it around or temporarily replace it,
* or have a second Conductor running at the same time, or other weird stuff like that if you need to.
*/
public static var instance:Conductor = new Conductor();
/**
* Signal fired when the current Conductor instance advances to a new measure.
*/
public static var measureHit(default, null):FlxSignal = new FlxSignal();
/**
* Signal fired when the current Conductor instance advances to a new beat.
*/
public static var beatHit(default, null):FlxSignal = new FlxSignal();
/**
* Signal fired when the current Conductor instance advances to a new step.
*/
public static var stepHit(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.
*/ */
static var timeChanges:Array<SongTimeChange> = []; var timeChanges:Array<SongTimeChange> = [];
/** /**
* The most recent time change for the current song position. * The most recent time change for the current song position.
*/ */
public static var currentTimeChange(default, null):SongTimeChange; public var currentTimeChange(default, null):Null<SongTimeChange>;
/** /**
* The current position in the song in milliseconds. * The current position in the song in milliseconds.
* Update this every frame based on the audio position using `Conductor.update()`. * Update this every frame based on the audio position using `Conductor.instance.update()`.
*/ */
public static var songPosition(default, null):Float = 0; public var songPosition(default, null):Float = 0;
/** /**
* Beats per minute of the current song at the current time. * Beats per minute of the current song at the current time.
*/ */
public static var bpm(get, never):Float; public var bpm(get, never):Float;
static function get_bpm():Float function get_bpm():Float
{ {
if (bpmOverride != null) return bpmOverride; if (bpmOverride != null) return bpmOverride;
@ -62,9 +87,9 @@ class Conductor
/** /**
* Beats per minute of the current song at the start time. * Beats per minute of the current song at the start time.
*/ */
public static var startingBPM(get, never):Float; public var startingBPM(get, never):Float;
static function get_startingBPM():Float function get_startingBPM():Float
{ {
if (bpmOverride != null) return bpmOverride; if (bpmOverride != null) return bpmOverride;
@ -78,14 +103,14 @@ class Conductor
* The current value set by `forceBPM`. * The current value set by `forceBPM`.
* If false, BPM is determined by time changes. * If false, BPM is determined by time changes.
*/ */
static var bpmOverride:Null<Float> = null; var bpmOverride:Null<Float> = null;
/** /**
* Duration of a measure in milliseconds. Calculated based on bpm. * Duration of a measure in milliseconds. Calculated based on bpm.
*/ */
public static var measureLengthMs(get, never):Float; public var measureLengthMs(get, never):Float;
static function get_measureLengthMs():Float function get_measureLengthMs():Float
{ {
return beatLengthMs * timeSignatureNumerator; return beatLengthMs * timeSignatureNumerator;
} }
@ -93,9 +118,9 @@ class Conductor
/** /**
* Duration of a beat (quarter note) in milliseconds. Calculated based on bpm. * Duration of a beat (quarter note) in milliseconds. Calculated based on bpm.
*/ */
public static var beatLengthMs(get, never):Float; public var beatLengthMs(get, never):Float;
static function get_beatLengthMs():Float function get_beatLengthMs():Float
{ {
// Tied directly to BPM. // Tied directly to BPM.
return ((Constants.SECS_PER_MIN / bpm) * Constants.MS_PER_SEC); return ((Constants.SECS_PER_MIN / bpm) * Constants.MS_PER_SEC);
@ -104,25 +129,25 @@ class Conductor
/** /**
* Duration of a step (sixtennth note) in milliseconds. Calculated based on bpm. * Duration of a step (sixtennth note) in milliseconds. Calculated based on bpm.
*/ */
public static var stepLengthMs(get, never):Float; public var stepLengthMs(get, never):Float;
static function get_stepLengthMs():Float function get_stepLengthMs():Float
{ {
return beatLengthMs / timeSignatureNumerator; return beatLengthMs / timeSignatureNumerator;
} }
public static var timeSignatureNumerator(get, never):Int; public var timeSignatureNumerator(get, never):Int;
static function get_timeSignatureNumerator():Int function get_timeSignatureNumerator():Int
{ {
if (currentTimeChange == null) return Constants.DEFAULT_TIME_SIGNATURE_NUM; if (currentTimeChange == null) return Constants.DEFAULT_TIME_SIGNATURE_NUM;
return currentTimeChange.timeSignatureNum; return currentTimeChange.timeSignatureNum;
} }
public static var timeSignatureDenominator(get, never):Int; public var timeSignatureDenominator(get, never):Int;
static function get_timeSignatureDenominator():Int function get_timeSignatureDenominator():Int
{ {
if (currentTimeChange == null) return Constants.DEFAULT_TIME_SIGNATURE_DEN; if (currentTimeChange == null) return Constants.DEFAULT_TIME_SIGNATURE_DEN;
@ -132,44 +157,44 @@ class Conductor
/** /**
* Current position in the song, in measures. * Current position in the song, in measures.
*/ */
public static var currentMeasure(default, null):Int; public var currentMeasure(default, null):Int = 0;
/** /**
* Current position in the song, in beats. * Current position in the song, in beats.
*/ */
public static var currentBeat(default, null):Int; public var currentBeat(default, null):Int = 0;
/** /**
* Current position in the song, in steps. * Current position in the song, in steps.
*/ */
public static var currentStep(default, null):Int; public var currentStep(default, null):Int = 0;
/** /**
* Current position in the song, in measures and fractions of a measure. * Current position in the song, in measures and fractions of a measure.
*/ */
public static var currentMeasureTime(default, null):Float; public var currentMeasureTime(default, null):Float = 0;
/** /**
* Current position in the song, in beats and fractions of a measure. * Current position in the song, in beats and fractions of a measure.
*/ */
public static var currentBeatTime(default, null):Float; public var currentBeatTime(default, null):Float = 0;
/** /**
* Current position in the song, in steps and fractions of a step. * Current position in the song, in steps and fractions of a step.
*/ */
public static var currentStepTime(default, null):Float; public var currentStepTime(default, null):Float = 0;
/** /**
* An offset tied to the current chart file to compensate for a delay in the instrumental. * An offset tied to the current chart file to compensate for a delay in the instrumental.
*/ */
public static var instrumentalOffset:Float = 0; public var instrumentalOffset:Float = 0;
/** /**
* The instrumental offset, in terms of steps. * The instrumental offset, in terms of steps.
*/ */
public static var instrumentalOffsetSteps(get, never):Float; public var instrumentalOffsetSteps(get, never):Float;
static function get_instrumentalOffsetSteps():Float function get_instrumentalOffsetSteps():Float
{ {
var startingStepLengthMs:Float = ((Constants.SECS_PER_MIN / startingBPM) * Constants.MS_PER_SEC) / timeSignatureNumerator; var startingStepLengthMs:Float = ((Constants.SECS_PER_MIN / startingBPM) * Constants.MS_PER_SEC) / timeSignatureNumerator;
@ -179,19 +204,19 @@ class Conductor
/** /**
* An offset tied to the file format of the audio file being played. * An offset tied to the file format of the audio file being played.
*/ */
public static var formatOffset:Float = 0; public var formatOffset:Float = 0;
/** /**
* An offset set by the user to compensate for input lag. * An offset set by the user to compensate for input lag.
*/ */
public static var inputOffset:Float = 0; public var inputOffset:Float = 0;
/** /**
* The number of beats in a measure. May be fractional depending on the time signature. * The number of beats in a measure. May be fractional depending on the time signature.
*/ */
public static var beatsPerMeasure(get, never):Float; public var beatsPerMeasure(get, never):Float;
static function get_beatsPerMeasure():Float function get_beatsPerMeasure():Float
{ {
// NOTE: Not always an integer, for example 7/8 is 3.5 beats per measure // NOTE: Not always an integer, for example 7/8 is 3.5 beats per measure
return stepsPerMeasure / Constants.STEPS_PER_BEAT; return stepsPerMeasure / Constants.STEPS_PER_BEAT;
@ -201,30 +226,15 @@ class Conductor
* The number of steps in a measure. * The number of steps in a measure.
* TODO: I don't think this can be fractional? * TODO: I don't think this can be fractional?
*/ */
public static var stepsPerMeasure(get, never):Int; public var stepsPerMeasure(get, never):Int;
static function get_stepsPerMeasure():Int function get_stepsPerMeasure():Int
{ {
// TODO: Is this always an integer? // TODO: Is this always an integer?
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);
} }
/** public function new() {}
* Signal fired when the Conductor advances to a new measure.
*/
public static var measureHit(default, null):FlxSignal = new FlxSignal();
/**
* Signal fired when the Conductor advances to a new beat.
*/
public static var beatHit(default, null):FlxSignal = new FlxSignal();
/**
* Signal fired when the Conductor advances to a new step.
*/
public static var stepHit(default, null):FlxSignal = new FlxSignal();
function new() {}
/** /**
* Forcibly defines the current BPM of the song. * Forcibly defines the current BPM of the song.
@ -235,7 +245,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.
*/ */
public static function forceBPM(?bpm:Float = null) public function forceBPM(?bpm:Float = null)
{ {
if (bpm != null) if (bpm != null)
{ {
@ -246,7 +256,7 @@ class Conductor
// trace('[CONDUCTOR] Resetting BPM to default'); // trace('[CONDUCTOR] Resetting BPM to default');
} }
Conductor.bpmOverride = bpm; this.bpmOverride = bpm;
} }
/** /**
@ -256,29 +266,29 @@ class Conductor
* @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 static function update(?songPosition:Float) public function update(?songPos:Float)
{ {
if (songPosition == null) if (songPos == null)
{ {
// Take into account instrumental and file format song offsets. // Take into account instrumental and file format song offsets.
songPosition = (FlxG.sound.music != null) ? (FlxG.sound.music.time + instrumentalOffset + formatOffset) : 0.0; songPos = (FlxG.sound.music != null) ? (FlxG.sound.music.time + instrumentalOffset + formatOffset) : 0.0;
} }
var oldMeasure = currentMeasure; var oldMeasure = this.currentMeasure;
var oldBeat = currentBeat; var oldBeat = this.currentBeat;
var oldStep = currentStep; var oldStep = this.currentStep;
// Set the song position we are at (for purposes of calculating note positions, etc). // Set the song position we are at (for purposes of calculating note positions, etc).
Conductor.songPosition = songPosition; this.songPosition = songPos;
currentTimeChange = timeChanges[0]; currentTimeChange = timeChanges[0];
if (Conductor.songPosition > 0.0) if (this.songPosition > 0.0)
{ {
for (i in 0...timeChanges.length) for (i in 0...timeChanges.length)
{ {
if (songPosition >= timeChanges[i].timeStamp) currentTimeChange = timeChanges[i]; if (this.songPosition >= timeChanges[i].timeStamp) currentTimeChange = timeChanges[i];
if (songPosition < timeChanges[i].timeStamp) break; if (this.songPosition < timeChanges[i].timeStamp) break;
} }
} }
@ -286,45 +296,49 @@ class Conductor
{ {
trace('WARNING: Conductor is broken, timeChanges is empty.'); trace('WARNING: Conductor is broken, timeChanges is empty.');
} }
else if (currentTimeChange != null && Conductor.songPosition > 0.0) else if (currentTimeChange != null && this.songPosition > 0.0)
{ {
// roundDecimal prevents representing 8 as 7.9999999 // roundDecimal prevents representing 8 as 7.9999999
currentStepTime = FlxMath.roundDecimal((currentTimeChange.beatTime * 4) + (songPosition - currentTimeChange.timeStamp) / stepLengthMs, 6); this.currentStepTime = FlxMath.roundDecimal((currentTimeChange.beatTime * 4) + (this.songPosition - currentTimeChange.timeStamp) / stepLengthMs, 6);
currentBeatTime = currentStepTime / Constants.STEPS_PER_BEAT; this.currentBeatTime = currentStepTime / Constants.STEPS_PER_BEAT;
currentMeasureTime = currentStepTime / stepsPerMeasure; this.currentMeasureTime = currentStepTime / stepsPerMeasure;
currentStep = Math.floor(currentStepTime); this.currentStep = Math.floor(currentStepTime);
currentBeat = Math.floor(currentBeatTime); this.currentBeat = Math.floor(currentBeatTime);
currentMeasure = Math.floor(currentMeasureTime); this.currentMeasure = Math.floor(currentMeasureTime);
} }
else else
{ {
// Assume a constant BPM equal to the forced value. // Assume a constant BPM equal to the forced value.
currentStepTime = FlxMath.roundDecimal((songPosition / stepLengthMs), 4); this.currentStepTime = FlxMath.roundDecimal((songPosition / stepLengthMs), 4);
currentBeatTime = currentStepTime / Constants.STEPS_PER_BEAT; this.currentBeatTime = currentStepTime / Constants.STEPS_PER_BEAT;
currentMeasureTime = currentStepTime / stepsPerMeasure; this.currentMeasureTime = currentStepTime / stepsPerMeasure;
currentStep = Math.floor(currentStepTime); this.currentStep = Math.floor(currentStepTime);
currentBeat = Math.floor(currentBeatTime); this.currentBeat = Math.floor(currentBeatTime);
currentMeasure = Math.floor(currentMeasureTime); this.currentMeasure = Math.floor(currentMeasureTime);
} }
// FlxSignals are really cool. // Only fire the signal if we are THE Conductor.
if (currentStep != oldStep) if (this == Conductor.instance)
{ {
stepHit.dispatch(); // FlxSignals are really cool.
} if (currentStep != oldStep)
{
Conductor.stepHit.dispatch();
}
if (currentBeat != oldBeat) if (currentBeat != oldBeat)
{ {
beatHit.dispatch(); Conductor.beatHit.dispatch();
} }
if (currentMeasure != oldMeasure) if (currentMeasure != oldMeasure)
{ {
measureHit.dispatch(); Conductor.measureHit.dispatch();
}
} }
} }
public static function mapTimeChanges(songTimeChanges:Array<SongTimeChange>) public function mapTimeChanges(songTimeChanges:Array<SongTimeChange>)
{ {
timeChanges = []; timeChanges = [];
@ -338,24 +352,21 @@ class Conductor
// Without any custom handling, `currentStepTime` becomes non-zero at `songPosition = 0`. // Without any custom handling, `currentStepTime` becomes non-zero at `songPosition = 0`.
if (currentTimeChange.timeStamp < 0.0) currentTimeChange.timeStamp = 0.0; if (currentTimeChange.timeStamp < 0.0) currentTimeChange.timeStamp = 0.0;
if (currentTimeChange.beatTime == null) if (currentTimeChange.timeStamp <= 0.0)
{ {
if (currentTimeChange.timeStamp <= 0.0) currentTimeChange.beatTime = 0.0;
{ }
currentTimeChange.beatTime = 0.0; else
} {
else // Calculate the beat time of this timestamp.
{ currentTimeChange.beatTime = 0.0;
// Calculate the beat time of this timestamp.
currentTimeChange.beatTime = 0.0;
if (currentTimeChange.timeStamp > 0.0 && timeChanges.length > 0) if (currentTimeChange.timeStamp > 0.0 && timeChanges.length > 0)
{ {
var prevTimeChange:SongTimeChange = timeChanges[timeChanges.length - 1]; var prevTimeChange:SongTimeChange = timeChanges[timeChanges.length - 1];
currentTimeChange.beatTime = FlxMath.roundDecimal(prevTimeChange.beatTime currentTimeChange.beatTime = FlxMath.roundDecimal(prevTimeChange.beatTime
+ ((currentTimeChange.timeStamp - prevTimeChange.timeStamp) * prevTimeChange.bpm / Constants.SECS_PER_MIN / Constants.MS_PER_SEC), + ((currentTimeChange.timeStamp - prevTimeChange.timeStamp) * prevTimeChange.bpm / Constants.SECS_PER_MIN / Constants.MS_PER_SEC),
4); 4);
}
} }
} }
@ -368,13 +379,13 @@ class Conductor
} }
// Update currentStepTime // Update currentStepTime
Conductor.update(Conductor.songPosition); this.update(Conductor.instance.songPosition);
} }
/** /**
* Given a time in milliseconds, return a time in steps. * Given a time in milliseconds, return a time in steps.
*/ */
public static function getTimeInSteps(ms:Float):Float public function getTimeInSteps(ms:Float):Float
{ {
if (timeChanges.length == 0) if (timeChanges.length == 0)
{ {
@ -411,7 +422,7 @@ class Conductor
/** /**
* Given a time in steps and fractional steps, return a time in milliseconds. * Given a time in steps and fractional steps, return a time in milliseconds.
*/ */
public static function getStepTimeInMs(stepTime:Float):Float public function getStepTimeInMs(stepTime:Float):Float
{ {
if (timeChanges.length == 0) if (timeChanges.length == 0)
{ {
@ -447,7 +458,7 @@ class Conductor
/** /**
* Given a time in beats and fractional beats, return a time in milliseconds. * Given a time in beats and fractional beats, return a time in milliseconds.
*/ */
public static function getBeatTimeInMs(beatTime:Float):Float public function getBeatTimeInMs(beatTime:Float):Float
{ {
if (timeChanges.length == 0) if (timeChanges.length == 0)
{ {
@ -480,13 +491,20 @@ class Conductor
} }
} }
public static function watchQuick():Void
{
FlxG.watch.addQuick("songPosition", Conductor.instance.songPosition);
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);
}
/**
* Reset the Conductor, replacing the current instance with a fresh one.
*/
public static function reset():Void public static function reset():Void
{ {
beatHit.removeAll(); Conductor.instance = new Conductor();
stepHit.removeAll();
mapTimeChanges([]);
forceBPM(null);
update(0);
} }
} }

View file

@ -64,7 +64,7 @@ class ABotVis extends FlxTypedSpriteGroup<FlxSprite>
if (vis.snd.playing) remappedShit = Std.int(FlxMath.remapToRange(vis.snd.time, 0, vis.snd.length, 0, vis.numSamples)); if (vis.snd.playing) remappedShit = Std.int(FlxMath.remapToRange(vis.snd.time, 0, vis.snd.length, 0, vis.numSamples));
else else
remappedShit = Std.int(FlxMath.remapToRange(Conductor.songPosition, 0, vis.snd.length, 0, vis.numSamples)); remappedShit = Std.int(FlxMath.remapToRange(Conductor.instance.songPosition, 0, vis.snd.length, 0, vis.numSamples));
var fftSamples:Array<Float> = []; var fftSamples:Array<Float> = [];

View file

@ -164,7 +164,7 @@ class SpectogramSprite extends FlxTypedSpriteGroup<FlxSprite>
if (vis.snd.playing) remappedShit = Std.int(FlxMath.remapToRange(vis.snd.time, 0, vis.snd.length, 0, numSamples)); if (vis.snd.playing) remappedShit = Std.int(FlxMath.remapToRange(vis.snd.time, 0, vis.snd.length, 0, numSamples));
else else
remappedShit = Std.int(FlxMath.remapToRange(Conductor.songPosition, 0, vis.snd.length, 0, numSamples)); remappedShit = Std.int(FlxMath.remapToRange(Conductor.instance.songPosition, 0, vis.snd.length, 0, numSamples));
var fftSamples:Array<Float> = []; var fftSamples:Array<Float> = [];
var i = remappedShit; var i = remappedShit;
@ -235,15 +235,15 @@ class SpectogramSprite extends FlxTypedSpriteGroup<FlxSprite>
if (vis.snd.playing) remappedShit = Std.int(FlxMath.remapToRange(vis.snd.time, 0, vis.snd.length, 0, numSamples)); if (vis.snd.playing) remappedShit = Std.int(FlxMath.remapToRange(vis.snd.time, 0, vis.snd.length, 0, numSamples));
else else
{ {
if (curTime == Conductor.songPosition) if (curTime == Conductor.instance.songPosition)
{ {
wavOptimiz = 3; wavOptimiz = 3;
return; // already did shit, so finishes function early return; // already did shit, so finishes function early
} }
curTime = Conductor.songPosition; curTime = Conductor.instance.songPosition;
remappedShit = Std.int(FlxMath.remapToRange(Conductor.songPosition, 0, vis.snd.length, 0, numSamples)); remappedShit = Std.int(FlxMath.remapToRange(Conductor.instance.songPosition, 0, vis.snd.length, 0, numSamples));
} }
wavOptimiz = 8; wavOptimiz = 8;

View file

@ -178,7 +178,31 @@ class DataParse
switch (json.value) switch (json.value)
{ {
case JObject(fields): case JObject(fields):
return cast Tools.getValue(json); var result:LegacyNoteSection =
{
mustHitSection: false,
sectionNotes: [],
};
for (field in fields)
{
switch (field.name)
{
case 'sectionNotes':
result.sectionNotes = legacyNotes(field.value, field.name);
case 'mustHitSection':
result.mustHitSection = Tools.getValue(field.value);
case 'typeOfSection':
result.typeOfSection = Tools.getValue(field.value);
case 'lengthInSteps':
result.lengthInSteps = Tools.getValue(field.value);
case 'changeBPM':
result.changeBPM = Tools.getValue(field.value);
case 'bpm':
result.bpm = Tools.getValue(field.value);
}
}
return result;
default: default:
throw 'Expected property $name to be an object, but it was ${json.value}.'; throw 'Expected property $name to be an object, but it was ${json.value}.';
} }
@ -189,7 +213,12 @@ class DataParse
switch (json.value) switch (json.value)
{ {
case JObject(fields): case JObject(fields):
return cast Tools.getValue(json); var result = {};
for (field in fields)
{
Reflect.setField(result, field.name, legacyNoteSectionArray(field.value, field.name));
}
return result;
default: default:
throw 'Expected property $name to be an object, but it was ${json.value}.'; throw 'Expected property $name to be an object, but it was ${json.value}.';
} }
@ -211,13 +240,13 @@ class DataParse
switch (json.value) switch (json.value)
{ {
case JArray(values): case JArray(values):
// var time:Null<Float> = values[0] == null ? null : Tools.getValue(values[0]); var time:Null<Float> = values[0] == null ? null : Tools.getValue(values[0]);
// var data:Null<Int> = values[1] == null ? null : Tools.getValue(values[1]); var data:Null<Int> = values[1] == null ? null : Tools.getValue(values[1]);
// var length:Null<Float> = values[2] == null ? null : Tools.getValue(values[2]); var length:Null<Float> = values[2] == null ? null : Tools.getValue(values[2]);
// var alt:Null<Bool> = values[3] == null ? null : Tools.getValue(values[3]); var alt:Null<Bool> = values[3] == null ? null : Tools.getValue(values[3]);
// return new LegacyNote(time, data, length, alt); return new LegacyNote(time, data, length, alt);
return null; // return null;
default: default:
throw 'Expected property $name to be a note, but it was ${json.value}.'; throw 'Expected property $name to be a note, but it was ${json.value}.';
} }

View file

@ -30,6 +30,7 @@ class LevelRegistry extends BaseRegistry<Level, LevelData>
// JsonParser does not take type parameters, // JsonParser does not take type parameters,
// otherwise this function would be in BaseRegistry. // otherwise this function would be in BaseRegistry.
var parser = new json2object.JsonParser<LevelData>(); var parser = new json2object.JsonParser<LevelData>();
parser.ignoreUnknownVariables = false;
switch (loadEntryFile(id)) switch (loadEntryFile(id))
{ {
@ -57,6 +58,7 @@ class LevelRegistry extends BaseRegistry<Level, LevelData>
public function parseEntryDataRaw(contents:String, ?fileName:String):Null<LevelData> public function parseEntryDataRaw(contents:String, ?fileName:String):Null<LevelData>
{ {
var parser = new json2object.JsonParser<LevelData>(); var parser = new json2object.JsonParser<LevelData>();
parser.ignoreUnknownVariables = false;
parser.fromJson(contents, fileName); parser.fromJson(contents, fileName);
if (parser.errors.length > 0) if (parser.errors.length > 0)

View file

@ -35,6 +35,7 @@ class NoteStyleRegistry extends BaseRegistry<NoteStyle, NoteStyleData>
// JsonParser does not take type parameters, // JsonParser does not take type parameters,
// otherwise this function would be in BaseRegistry. // otherwise this function would be in BaseRegistry.
var parser = new json2object.JsonParser<NoteStyleData>(); var parser = new json2object.JsonParser<NoteStyleData>();
parser.ignoreUnknownVariables = false;
switch (loadEntryFile(id)) switch (loadEntryFile(id))
{ {
@ -62,6 +63,7 @@ class NoteStyleRegistry extends BaseRegistry<NoteStyle, NoteStyleData>
public function parseEntryDataRaw(contents:String, ?fileName:String):Null<NoteStyleData> public function parseEntryDataRaw(contents:String, ?fileName:String):Null<NoteStyleData>
{ {
var parser = new json2object.JsonParser<NoteStyleData>(); var parser = new json2object.JsonParser<NoteStyleData>();
parser.ignoreUnknownVariables = false;
parser.fromJson(contents, fileName); parser.fromJson(contents, fileName);
if (parser.errors.length > 0) if (parser.errors.length > 0)

View file

@ -150,7 +150,7 @@ class SongTimeChange implements ICloneable<SongTimeChange>
*/ */
@:optional @:optional
@:alias("b") @:alias("b")
public var beatTime:Null<Float>; public var beatTime:Float;
/** /**
* Quarter notes per minute (float). Cannot be empty in the first element of the list, * Quarter notes per minute (float). Cannot be empty in the first element of the list,
@ -657,7 +657,7 @@ class SongEventDataRaw implements ICloneable<SongEventDataRaw>
{ {
if (_stepTime != null && !force) return _stepTime; if (_stepTime != null && !force) return _stepTime;
return _stepTime = Conductor.getTimeInSteps(this.time); return _stepTime = Conductor.instance.getTimeInSteps(this.time);
} }
public function clone():SongEventDataRaw public function clone():SongEventDataRaw
@ -802,7 +802,7 @@ class SongNoteDataRaw implements ICloneable<SongNoteDataRaw>
/** /**
* The kind of the note. * The kind of the note.
* This can allow the note to include information used for custom behavior. * This can allow the note to include information used for custom behavior.
* Defaults to blank or `"normal"`. * Defaults to blank or `Constants.DEFAULT_DIFFICULTY`.
*/ */
@:alias("k") @:alias("k")
@:default("normal") @:default("normal")
@ -851,7 +851,7 @@ class SongNoteDataRaw implements ICloneable<SongNoteDataRaw>
{ {
if (_stepTime != null && !force) return _stepTime; if (_stepTime != null && !force) return _stepTime;
return _stepTime = Conductor.getTimeInSteps(this.time); return _stepTime = Conductor.instance.getTimeInSteps(this.time);
} }
@:jignored @:jignored
@ -867,7 +867,7 @@ class SongNoteDataRaw implements ICloneable<SongNoteDataRaw>
if (_stepLength != null && !force) return _stepLength; if (_stepLength != null && !force) return _stepLength;
return _stepLength = Conductor.getTimeInSteps(this.time + this.length) - getStepTime(); return _stepLength = Conductor.instance.getTimeInSteps(this.time + this.length) - getStepTime();
} }
public function setStepLength(value:Float):Void public function setStepLength(value:Float):Void
@ -878,7 +878,7 @@ class SongNoteDataRaw implements ICloneable<SongNoteDataRaw>
} }
else else
{ {
var lengthMs:Float = Conductor.getStepTimeInMs(value) - this.time; var lengthMs:Float = Conductor.instance.getStepTimeInMs(value) - this.time;
this.length = lengthMs; this.length = lengthMs;
} }
_stepLength = null; _stepLength = null;

View file

@ -230,6 +230,7 @@ class SongDataUtils
trace('Read ${notesString.length} characters from clipboard.'); trace('Read ${notesString.length} characters from clipboard.');
var parser = new json2object.JsonParser<SongClipboardItems>(); var parser = new json2object.JsonParser<SongClipboardItems>();
parser.ignoreUnknownVariables = false;
parser.fromJson(notesString, 'clipboard'); parser.fromJson(notesString, 'clipboard');
if (parser.errors.length > 0) if (parser.errors.length > 0)
{ {

View file

@ -126,6 +126,8 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>
variation = variation == null ? Constants.DEFAULT_VARIATION : variation; variation = variation == null ? Constants.DEFAULT_VARIATION : variation;
var parser = new json2object.JsonParser<SongMetadata>(); var parser = new json2object.JsonParser<SongMetadata>();
parser.ignoreUnknownVariables = false;
switch (loadEntryMetadataFile(id, variation)) switch (loadEntryMetadataFile(id, variation))
{ {
case {fileName: fileName, contents: contents}: case {fileName: fileName, contents: contents}:
@ -147,6 +149,7 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>
variation = variation == null ? Constants.DEFAULT_VARIATION : variation; variation = variation == null ? Constants.DEFAULT_VARIATION : variation;
var parser = new json2object.JsonParser<SongMetadata>(); var parser = new json2object.JsonParser<SongMetadata>();
parser.ignoreUnknownVariables = false;
parser.fromJson(contents, fileName); parser.fromJson(contents, fileName);
if (parser.errors.length > 0) if (parser.errors.length > 0)
@ -206,6 +209,8 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>
variation = variation == null ? Constants.DEFAULT_VARIATION : variation; variation = variation == null ? Constants.DEFAULT_VARIATION : variation;
var parser = new json2object.JsonParser<SongMetadata_v2_1_0>(); var parser = new json2object.JsonParser<SongMetadata_v2_1_0>();
parser.ignoreUnknownVariables = false;
switch (loadEntryMetadataFile(id, variation)) switch (loadEntryMetadataFile(id, variation))
{ {
case {fileName: fileName, contents: contents}: case {fileName: fileName, contents: contents}:
@ -226,6 +231,8 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>
variation = variation == null ? Constants.DEFAULT_VARIATION : variation; variation = variation == null ? Constants.DEFAULT_VARIATION : variation;
var parser = new json2object.JsonParser<SongMetadata_v2_0_0>(); var parser = new json2object.JsonParser<SongMetadata_v2_0_0>();
parser.ignoreUnknownVariables = false;
switch (loadEntryMetadataFile(id, variation)) switch (loadEntryMetadataFile(id, variation))
{ {
case {fileName: fileName, contents: contents}: case {fileName: fileName, contents: contents}:
@ -244,6 +251,7 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>
function parseEntryMetadataRaw_v2_1_0(contents:String, ?fileName:String = 'raw'):Null<SongMetadata> function parseEntryMetadataRaw_v2_1_0(contents:String, ?fileName:String = 'raw'):Null<SongMetadata>
{ {
var parser = new json2object.JsonParser<SongMetadata_v2_1_0>(); var parser = new json2object.JsonParser<SongMetadata_v2_1_0>();
parser.ignoreUnknownVariables = false;
parser.fromJson(contents, fileName); parser.fromJson(contents, fileName);
if (parser.errors.length > 0) if (parser.errors.length > 0)
@ -257,6 +265,7 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>
function parseEntryMetadataRaw_v2_0_0(contents:String, ?fileName:String = 'raw'):Null<SongMetadata> function parseEntryMetadataRaw_v2_0_0(contents:String, ?fileName:String = 'raw'):Null<SongMetadata>
{ {
var parser = new json2object.JsonParser<SongMetadata_v2_0_0>(); var parser = new json2object.JsonParser<SongMetadata_v2_0_0>();
parser.ignoreUnknownVariables = false;
parser.fromJson(contents, fileName); parser.fromJson(contents, fileName);
if (parser.errors.length > 0) if (parser.errors.length > 0)
@ -272,6 +281,8 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>
variation = variation == null ? Constants.DEFAULT_VARIATION : variation; variation = variation == null ? Constants.DEFAULT_VARIATION : variation;
var parser = new json2object.JsonParser<SongMusicData>(); var parser = new json2object.JsonParser<SongMusicData>();
parser.ignoreUnknownVariables = false;
switch (loadMusicDataFile(id, variation)) switch (loadMusicDataFile(id, variation))
{ {
case {fileName: fileName, contents: contents}: case {fileName: fileName, contents: contents}:
@ -291,6 +302,7 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>
public function parseMusicDataRaw(contents:String, ?fileName:String = 'raw'):Null<SongMusicData> public function parseMusicDataRaw(contents:String, ?fileName:String = 'raw'):Null<SongMusicData>
{ {
var parser = new json2object.JsonParser<SongMusicData>(); var parser = new json2object.JsonParser<SongMusicData>();
parser.ignoreUnknownVariables = false;
parser.fromJson(contents, fileName); parser.fromJson(contents, fileName);
if (parser.errors.length > 0) if (parser.errors.length > 0)
@ -334,6 +346,7 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>
variation = variation == null ? Constants.DEFAULT_VARIATION : variation; variation = variation == null ? Constants.DEFAULT_VARIATION : variation;
var parser = new json2object.JsonParser<SongChartData>(); var parser = new json2object.JsonParser<SongChartData>();
parser.ignoreUnknownVariables = false;
switch (loadEntryChartFile(id, variation)) switch (loadEntryChartFile(id, variation))
{ {
@ -356,6 +369,7 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>
variation = variation == null ? Constants.DEFAULT_VARIATION : variation; variation = variation == null ? Constants.DEFAULT_VARIATION : variation;
var parser = new json2object.JsonParser<SongChartData>(); var parser = new json2object.JsonParser<SongChartData>();
parser.ignoreUnknownVariables = false;
parser.fromJson(contents, fileName); parser.fromJson(contents, fileName);
if (parser.errors.length > 0) if (parser.errors.length > 0)

View file

@ -68,6 +68,7 @@ class ChartManifestData
public static function deserialize(contents:String):Null<ChartManifestData> public static function deserialize(contents:String):Null<ChartManifestData>
{ {
var parser = new json2object.JsonParser<ChartManifestData>(); var parser = new json2object.JsonParser<ChartManifestData>();
parser.ignoreUnknownVariables = false;
parser.fromJson(contents, 'manifest.json'); parser.fromJson(contents, 'manifest.json');
if (parser.errors.length > 0) if (parser.errors.length > 0)

View file

@ -19,7 +19,8 @@ class LegacySongData
@:jcustomparse(funkin.data.DataParse.eitherLegacyScrollSpeeds) @:jcustomparse(funkin.data.DataParse.eitherLegacyScrollSpeeds)
public var speed:Either<Float, LegacyScrollSpeeds>; public var speed:Either<Float, LegacyScrollSpeeds>;
public var stageDefault:String; @:optional
public var stageDefault:Null<String>;
public var bpm:Float; public var bpm:Float;
@:jcustomparse(funkin.data.DataParse.eitherLegacyNoteData) @:jcustomparse(funkin.data.DataParse.eitherLegacyNoteData)

View file

@ -14,6 +14,7 @@ class FNFLegacyImporter
public static function parseLegacyDataRaw(input:String, fileName:String = 'raw'):FNFLegacyData public static function parseLegacyDataRaw(input:String, fileName:String = 'raw'):FNFLegacyData
{ {
var parser = new json2object.JsonParser<FNFLegacyData>(); var parser = new json2object.JsonParser<FNFLegacyData>();
parser.ignoreUnknownVariables = true; // Set to true to ignore extra variables that might be included in the JSON.
parser.fromJson(input, fileName); parser.fromJson(input, fileName);
if (parser.errors.length > 0) if (parser.errors.length > 0)
@ -185,15 +186,34 @@ class FNFLegacyImporter
return result; return result;
} }
static final STRUMLINE_SIZE = 4;
static function migrateNoteSections(input:Array<LegacyNoteSection>):Array<SongNoteData> static function migrateNoteSections(input:Array<LegacyNoteSection>):Array<SongNoteData>
{ {
var result:Array<SongNoteData> = []; var result:Array<SongNoteData> = [];
for (section in input) for (section in input)
{ {
var mustHitSection = section.mustHitSection ?? false;
for (note in section.sectionNotes) for (note in section.sectionNotes)
{ {
result.push(new SongNoteData(note.time, note.data, note.length, note.getKind())); // Handle the dumb logic for mustHitSection.
var noteData = note.data;
// Flip notes if mustHitSection is FALSE (not true lol).
if (!mustHitSection)
{
if (noteData >= STRUMLINE_SIZE)
{
noteData -= STRUMLINE_SIZE;
}
else
{
noteData += STRUMLINE_SIZE;
}
}
result.push(new SongNoteData(note.time, noteData, note.length, note.getKind()));
} }
} }

View file

@ -34,6 +34,18 @@ class Cursor
Cursor.cursorMode = null; Cursor.cursorMode = null;
} }
public static inline function toggle():Void
{
if (FlxG.mouse.visible)
{
hide();
}
else
{
show();
}
}
public static final CURSOR_DEFAULT_PARAMS:CursorParams = public static final CURSOR_DEFAULT_PARAMS:CursorParams =
{ {
graphic: "assets/images/cursor/cursor-default.png", graphic: "assets/images/cursor/cursor-default.png",

View file

@ -40,7 +40,7 @@ class Countdown
stopCountdown(); stopCountdown();
PlayState.instance.isInCountdown = true; PlayState.instance.isInCountdown = true;
Conductor.update(PlayState.instance.startTimestamp + Conductor.beatLengthMs * -5); Conductor.instance.update(PlayState.instance.startTimestamp + Conductor.instance.beatLengthMs * -5);
// Handle onBeatHit events manually // Handle onBeatHit events manually
// @:privateAccess // @:privateAccess
// PlayState.instance.dispatchEvent(new SongTimeScriptEvent(SONG_BEAT_HIT, 0, 0)); // PlayState.instance.dispatchEvent(new SongTimeScriptEvent(SONG_BEAT_HIT, 0, 0));
@ -48,7 +48,7 @@ class Countdown
// The timer function gets called based on the beat of the song. // The timer function gets called based on the beat of the song.
countdownTimer = new FlxTimer(); countdownTimer = new FlxTimer();
countdownTimer.start(Conductor.beatLengthMs / 1000, function(tmr:FlxTimer) { countdownTimer.start(Conductor.instance.beatLengthMs / 1000, function(tmr:FlxTimer) {
if (PlayState.instance == null) if (PlayState.instance == null)
{ {
tmr.cancel(); tmr.cancel();
@ -158,7 +158,7 @@ class Countdown
{ {
stopCountdown(); stopCountdown();
// This will trigger PlayState.startSong() // This will trigger PlayState.startSong()
Conductor.update(0); Conductor.instance.update(0);
// PlayState.isInCountdown = false; // PlayState.isInCountdown = false;
} }
@ -225,7 +225,7 @@ class Countdown
countdownSprite.screenCenter(); countdownSprite.screenCenter();
// Fade sprite in, then out, then destroy it. // Fade sprite in, then out, then destroy it.
FlxTween.tween(countdownSprite, {y: countdownSprite.y += 100, alpha: 0}, Conductor.beatLengthMs / 1000, FlxTween.tween(countdownSprite, {y: countdownSprite.y += 100, alpha: 0}, Conductor.instance.beatLengthMs / 1000,
{ {
ease: FlxEase.cubeInOut, ease: FlxEase.cubeInOut,
onComplete: function(twn:FlxTween) { onComplete: function(twn:FlxTween) {

View file

@ -64,9 +64,16 @@ class GameOverSubState extends MusicBeatSubState
*/ */
var isEnding:Bool = false; var isEnding:Bool = false;
public function new() var isChartingMode:Bool = false;
var transparent:Bool;
public function new(params:GameOverParams)
{ {
super(); super();
this.isChartingMode = params?.isChartingMode ?? false;
transparent = params.transparent;
} }
/** /**
@ -87,9 +94,10 @@ class GameOverSubState extends MusicBeatSubState
// //
// Add a black background to the screen. // Add a black background to the screen.
// We make this transparent so that we can see the stage underneath during debugging.
var bg = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK); var bg = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK);
bg.alpha = 0.25; // We make this transparent so that we can see the stage underneath during debugging,
// but it's normally opaque.
bg.alpha = transparent ? 0.25 : 1.0;
bg.scrollFactor.set(); bg.scrollFactor.set();
add(bg); add(bg);
@ -121,7 +129,7 @@ class GameOverSubState extends MusicBeatSubState
gameOverMusic.stop(); gameOverMusic.stop();
// The conductor now represents the BPM of the game over music. // The conductor now represents the BPM of the game over music.
Conductor.update(0); Conductor.instance.update(0);
} }
var hasStartedAnimation:Bool = false; var hasStartedAnimation:Bool = false;
@ -176,16 +184,27 @@ class GameOverSubState extends MusicBeatSubState
// PlayState.seenCutscene = false; // old thing... // PlayState.seenCutscene = false; // old thing...
gameOverMusic.stop(); gameOverMusic.stop();
if (PlayStatePlaylist.isStoryMode) FlxG.switchState(new StoryMenuState()); if (isChartingMode)
{
this.close();
if (FlxG.sound.music != null) FlxG.sound.music.pause(); // Don't reset song position!
PlayState.instance.close(); // This only works because PlayState is a substate!
}
else if (PlayStatePlaylist.isStoryMode)
{
FlxG.switchState(new StoryMenuState());
}
else else
{
FlxG.switchState(new FreeplayState()); FlxG.switchState(new FreeplayState());
}
} }
if (gameOverMusic.playing) if (gameOverMusic.playing)
{ {
// Match the conductor to the music. // Match the conductor to the music.
// This enables the stepHit and beatHit events. // This enables the stepHit and beatHit events.
Conductor.update(gameOverMusic.time); Conductor.instance.update(gameOverMusic.time);
} }
else else
{ {
@ -270,6 +289,7 @@ class GameOverSubState extends MusicBeatSubState
{ {
gameOverMusic.loadEmbedded(musicPath); gameOverMusic.loadEmbedded(musicPath);
gameOverMusic.volume = startingVolume; gameOverMusic.volume = startingVolume;
gameOverMusic.looped = !isEnding;
gameOverMusic.play(); gameOverMusic.play();
} }
} }
@ -307,3 +327,9 @@ class GameOverSubState extends MusicBeatSubState
}); });
} }
} }
typedef GameOverParams =
{
var isChartingMode:Bool;
var transparent:Bool;
}

View file

@ -561,15 +561,15 @@ class PlayState extends MusicBeatSubState
} }
// Prepare the Conductor. // Prepare the Conductor.
Conductor.forceBPM(null); Conductor.instance.forceBPM(null);
if (currentChart.offsets != null) if (currentChart.offsets != null)
{ {
Conductor.instrumentalOffset = currentChart.offsets.getInstrumentalOffset(); Conductor.instance.instrumentalOffset = currentChart.offsets.getInstrumentalOffset();
} }
Conductor.mapTimeChanges(currentChart.timeChanges); Conductor.instance.mapTimeChanges(currentChart.timeChanges);
Conductor.update((Conductor.beatLengthMs * -5) + startTimestamp); Conductor.instance.update((Conductor.instance.beatLengthMs * -5) + startTimestamp);
// The song is now loaded. We can continue to initialize the play state. // The song is now loaded. We can continue to initialize the play state.
initCameras(); initCameras();
@ -734,7 +734,7 @@ class PlayState extends MusicBeatSubState
// Reset music properly. // Reset music properly.
FlxG.sound.music.time = Math.max(0, startTimestamp - Conductor.instrumentalOffset); FlxG.sound.music.time = Math.max(0, startTimestamp - Conductor.instance.instrumentalOffset);
FlxG.sound.music.pause(); FlxG.sound.music.pause();
if (!overrideMusic) if (!overrideMusic)
@ -785,22 +785,22 @@ class PlayState extends MusicBeatSubState
{ {
if (isInCountdown) if (isInCountdown)
{ {
Conductor.update(Conductor.songPosition + elapsed * 1000); Conductor.instance.update(Conductor.instance.songPosition + elapsed * 1000);
if (Conductor.songPosition >= (startTimestamp)) startSong(); if (Conductor.instance.songPosition >= (startTimestamp)) startSong();
} }
} }
else else
{ {
if (Constants.EXT_SOUND == 'mp3') if (Constants.EXT_SOUND == 'mp3')
{ {
Conductor.formatOffset = Constants.MP3_DELAY_MS; Conductor.instance.formatOffset = Constants.MP3_DELAY_MS;
} }
else else
{ {
Conductor.formatOffset = 0.0; Conductor.instance.formatOffset = 0.0;
} }
Conductor.update(); // Normal conductor update. Conductor.instance.update(); // Normal conductor update.
} }
var androidPause:Bool = false; var androidPause:Bool = false;
@ -922,7 +922,11 @@ class PlayState extends MusicBeatSubState
} }
#end #end
var gameOverSubState = new GameOverSubState(); var gameOverSubState = new GameOverSubState(
{
isChartingMode: isChartingMode,
transparent: persistentDraw
});
FlxTransitionableSubState.skipNextTransIn = true; FlxTransitionableSubState.skipNextTransIn = true;
FlxTransitionableSubState.skipNextTransOut = true; FlxTransitionableSubState.skipNextTransOut = true;
openSubState(gameOverSubState); openSubState(gameOverSubState);
@ -938,7 +942,7 @@ class PlayState extends MusicBeatSubState
// TODO: Check that these work even when songPosition is less than 0. // TODO: Check that these work even when songPosition is less than 0.
if (songEvents != null && songEvents.length > 0) if (songEvents != null && songEvents.length > 0)
{ {
var songEventsToActivate:Array<SongEventData> = SongEventParser.queryEvents(songEvents, Conductor.songPosition); var songEventsToActivate:Array<SongEventData> = SongEventParser.queryEvents(songEvents, Conductor.instance.songPosition);
if (songEventsToActivate.length > 0) if (songEventsToActivate.length > 0)
{ {
@ -946,7 +950,7 @@ class PlayState extends MusicBeatSubState
for (event in songEventsToActivate) for (event in songEventsToActivate)
{ {
// If an event is trying to play, but it's over 5 seconds old, skip it. // If an event is trying to play, but it's over 5 seconds old, skip it.
if (event.time - Conductor.songPosition < -5000) if (event.time - Conductor.instance.songPosition < -5000)
{ {
event.activated = true; event.activated = true;
continue; continue;
@ -1048,7 +1052,7 @@ class PlayState extends MusicBeatSubState
if (startTimer.finished) if (startTimer.finished)
{ {
DiscordClient.changePresence(detailsText, '${currentChart.songName} ($storyDifficultyText)', iconRPC, true, DiscordClient.changePresence(detailsText, '${currentChart.songName} ($storyDifficultyText)', iconRPC, true,
currentSongLengthMs - Conductor.songPosition); currentSongLengthMs - Conductor.instance.songPosition);
} }
else else
{ {
@ -1072,12 +1076,12 @@ class PlayState extends MusicBeatSubState
{ {
if (health > Constants.HEALTH_MIN && !paused && FlxG.autoPause) if (health > Constants.HEALTH_MIN && !paused && FlxG.autoPause)
{ {
if (Conductor.songPosition > 0.0) DiscordClient.changePresence(detailsText, currentSong.song if (Conductor.instance.songPosition > 0.0) DiscordClient.changePresence(detailsText, currentSong.song
+ ' (' + ' ('
+ storyDifficultyText + storyDifficultyText
+ ')', iconRPC, true, + ')', iconRPC, true,
currentSongLengthMs currentSongLengthMs
- Conductor.songPosition); - Conductor.instance.songPosition);
else else
DiscordClient.changePresence(detailsText, currentSong.song + ' (' + storyDifficultyText + ')', iconRPC); DiscordClient.changePresence(detailsText, currentSong.song + ' (' + storyDifficultyText + ')', iconRPC);
} }
@ -1097,23 +1101,6 @@ class PlayState extends MusicBeatSubState
} }
#end #end
/**
* This function is called whenever Flixel switches switching to a new FlxState.
* @return Whether to actually switch to the new state.
*/
@:haxe.warning("-WDeprecated")
override function switchTo(nextState:FlxState):Bool
{
var result:Bool = super.switchTo(nextState);
if (result)
{
performCleanup();
}
return result;
}
/** /**
* Removes any references to the current stage, then clears the stage cache, * Removes any references to the current stage, then clears the stage cache,
* then reloads all the stages. * then reloads all the stages.
@ -1167,17 +1154,17 @@ class PlayState extends MusicBeatSubState
if (!startingSong if (!startingSong
&& FlxG.sound.music != null && FlxG.sound.music != null
&& (Math.abs(FlxG.sound.music.time - (Conductor.songPosition + Conductor.instrumentalOffset)) > 200 && (Math.abs(FlxG.sound.music.time - (Conductor.instance.songPosition + Conductor.instance.instrumentalOffset)) > 200
|| Math.abs(vocals.checkSyncError(Conductor.songPosition + Conductor.instrumentalOffset)) > 200)) || Math.abs(vocals.checkSyncError(Conductor.instance.songPosition + Conductor.instance.instrumentalOffset)) > 200))
{ {
trace("VOCALS NEED RESYNC"); trace("VOCALS NEED RESYNC");
if (vocals != null) trace(vocals.checkSyncError(Conductor.songPosition + Conductor.instrumentalOffset)); if (vocals != null) trace(vocals.checkSyncError(Conductor.instance.songPosition + Conductor.instance.instrumentalOffset));
trace(FlxG.sound.music.time - (Conductor.songPosition + Conductor.instrumentalOffset)); trace(FlxG.sound.music.time - (Conductor.instance.songPosition + Conductor.instance.instrumentalOffset));
resyncVocals(); resyncVocals();
} }
if (iconP1 != null) iconP1.onStepHit(Std.int(Conductor.currentStep)); if (iconP1 != null) iconP1.onStepHit(Std.int(Conductor.instance.currentStep));
if (iconP2 != null) iconP2.onStepHit(Std.int(Conductor.currentStep)); if (iconP2 != null) iconP2.onStepHit(Std.int(Conductor.instance.currentStep));
return true; return true;
} }
@ -1198,14 +1185,14 @@ class PlayState extends MusicBeatSubState
} }
// Only zoom camera if we are zoomed by less than 35%. // Only zoom camera if we are zoomed by less than 35%.
if (FlxG.camera.zoom < (1.35 * defaultCameraZoom) && cameraZoomRate > 0 && Conductor.currentBeat % cameraZoomRate == 0) if (FlxG.camera.zoom < (1.35 * defaultCameraZoom) && cameraZoomRate > 0 && Conductor.instance.currentBeat % cameraZoomRate == 0)
{ {
// Zoom camera in (1.5%) // Zoom camera in (1.5%)
FlxG.camera.zoom += cameraZoomIntensity * defaultCameraZoom; FlxG.camera.zoom += cameraZoomIntensity * defaultCameraZoom;
// Hud zooms double (3%) // Hud zooms double (3%)
camHUD.zoom += hudCameraZoomIntensity * defaultHUDCameraZoom; camHUD.zoom += hudCameraZoomIntensity * defaultHUDCameraZoom;
} }
// trace('Not bopping camera: ${FlxG.camera.zoom} < ${(1.35 * defaultCameraZoom)} && ${cameraZoomRate} > 0 && ${Conductor.currentBeat} % ${cameraZoomRate} == ${Conductor.currentBeat % cameraZoomRate}}'); // trace('Not bopping camera: ${FlxG.camera.zoom} < ${(1.35 * defaultCameraZoom)} && ${cameraZoomRate} > 0 && ${Conductor.instance.currentBeat} % ${cameraZoomRate} == ${Conductor.instance.currentBeat % cameraZoomRate}}');
// That combo milestones that got spoiled that one time. // That combo milestones that got spoiled that one time.
// Comes with NEAT visual and audio effects. // Comes with NEAT visual and audio effects.
@ -1218,13 +1205,13 @@ class PlayState extends MusicBeatSubState
// TODO: Re-enable combo text (how to do this without sections?). // TODO: Re-enable combo text (how to do this without sections?).
// if (currentSong != null) // if (currentSong != null)
// { // {
// shouldShowComboText = (Conductor.currentBeat % 8 == 7); // shouldShowComboText = (Conductor.instance.currentBeat % 8 == 7);
// var daSection = .getSong()[Std.int(Conductor.currentBeat / 16)]; // var daSection = .getSong()[Std.int(Conductor.instance.currentBeat / 16)];
// shouldShowComboText = shouldShowComboText && (daSection != null && daSection.mustHitSection); // shouldShowComboText = shouldShowComboText && (daSection != null && daSection.mustHitSection);
// shouldShowComboText = shouldShowComboText && (Highscore.tallies.combo > 5); // shouldShowComboText = shouldShowComboText && (Highscore.tallies.combo > 5);
// //
// var daNextSection = .getSong()[Std.int(Conductor.currentBeat / 16) + 1]; // var daNextSection = .getSong()[Std.int(Conductor.instance.currentBeat / 16) + 1];
// var isEndOfSong = .getSong().length < Std.int(Conductor.currentBeat / 16); // var isEndOfSong = .getSong().length < Std.int(Conductor.instance.currentBeat / 16);
// shouldShowComboText = shouldShowComboText && (isEndOfSong || (daNextSection != null && !daNextSection.mustHitSection)); // shouldShowComboText = shouldShowComboText && (isEndOfSong || (daNextSection != null && !daNextSection.mustHitSection));
// } // }
@ -1237,7 +1224,7 @@ class PlayState extends MusicBeatSubState
var frameShit:Float = (1 / 24) * 2; // equals 2 frames in the animation var frameShit:Float = (1 / 24) * 2; // equals 2 frames in the animation
new FlxTimer().start(((Conductor.beatLengthMs / 1000) * 1.25) - frameShit, function(tmr) { new FlxTimer().start(((Conductor.instance.beatLengthMs / 1000) * 1.25) - frameShit, function(tmr) {
animShit.forceFinish(); animShit.forceFinish();
}); });
} }
@ -1251,7 +1238,7 @@ class PlayState extends MusicBeatSubState
return true; return true;
} }
override function destroy():Void public override function destroy():Void
{ {
if (currentConversation != null) if (currentConversation != null)
{ {
@ -1259,6 +1246,8 @@ class PlayState extends MusicBeatSubState
currentConversation.kill(); currentConversation.kill();
} }
performCleanup();
super.destroy(); super.destroy();
} }
@ -1272,10 +1261,10 @@ class PlayState extends MusicBeatSubState
if (currentStage == null) return; if (currentStage == null) return;
// TODO: Add HEY! song events to Tutorial. // TODO: Add HEY! song events to Tutorial.
if (Conductor.currentBeat % 16 == 15 if (Conductor.instance.currentBeat % 16 == 15
&& currentStage.getDad().characterId == 'gf' && currentStage.getDad().characterId == 'gf'
&& Conductor.currentBeat > 16 && Conductor.instance.currentBeat > 16
&& Conductor.currentBeat < 48) && Conductor.instance.currentBeat < 48)
{ {
currentStage.getBoyfriend().playAnimation('hey', true); currentStage.getBoyfriend().playAnimation('hey', true);
currentStage.getDad().playAnimation('cheer', true); currentStage.getDad().playAnimation('cheer', true);
@ -1586,7 +1575,7 @@ class PlayState extends MusicBeatSubState
trace('Song difficulty could not be loaded.'); trace('Song difficulty could not be loaded.');
} }
// Conductor.forceBPM(currentChart.getStartingBPM()); // Conductor.instance.forceBPM(currentChart.getStartingBPM());
if (!overrideMusic) if (!overrideMusic)
{ {
@ -1717,7 +1706,7 @@ class PlayState extends MusicBeatSubState
FlxG.sound.music.onComplete = endSong; FlxG.sound.music.onComplete = endSong;
// A negative instrumental offset means the song skips the first few milliseconds of the track. // A negative instrumental offset means the song skips the first few milliseconds of the track.
// This just gets added into the startTimestamp behavior so we don't need to do anything extra. // This just gets added into the startTimestamp behavior so we don't need to do anything extra.
FlxG.sound.music.time = startTimestamp - Conductor.instrumentalOffset; FlxG.sound.music.time = startTimestamp - Conductor.instance.instrumentalOffset;
trace('Playing vocals...'); trace('Playing vocals...');
add(vocals); add(vocals);
@ -1733,7 +1722,7 @@ class PlayState extends MusicBeatSubState
if (startTimestamp > 0) if (startTimestamp > 0)
{ {
// FlxG.sound.music.time = startTimestamp - Conductor.instrumentalOffset; // FlxG.sound.music.time = startTimestamp - Conductor.instance.instrumentalOffset;
handleSkippedNotes(); handleSkippedNotes();
} }
} }
@ -1811,7 +1800,7 @@ class PlayState extends MusicBeatSubState
var hitWindowCenter = note.strumTime; var hitWindowCenter = note.strumTime;
var hitWindowEnd = note.strumTime + Constants.HIT_WINDOW_MS; var hitWindowEnd = note.strumTime + Constants.HIT_WINDOW_MS;
if (Conductor.songPosition > hitWindowEnd) if (Conductor.instance.songPosition > hitWindowEnd)
{ {
if (note.hasMissed) continue; if (note.hasMissed) continue;
@ -1821,7 +1810,7 @@ class PlayState extends MusicBeatSubState
if (note.holdNoteSprite != null) note.holdNoteSprite.missedNote = true; if (note.holdNoteSprite != null) note.holdNoteSprite.missedNote = true;
} }
else if (Conductor.songPosition > hitWindowCenter) else if (Conductor.instance.songPosition > hitWindowCenter)
{ {
if (note.hasBeenHit) continue; if (note.hasBeenHit) continue;
@ -1842,7 +1831,7 @@ class PlayState extends MusicBeatSubState
opponentStrumline.playNoteHoldCover(note.holdNoteSprite); opponentStrumline.playNoteHoldCover(note.holdNoteSprite);
} }
} }
else if (Conductor.songPosition > hitWindowStart) else if (Conductor.instance.songPosition > hitWindowStart)
{ {
if (note.hasBeenHit || note.hasMissed) continue; if (note.hasBeenHit || note.hasMissed) continue;
@ -1888,14 +1877,14 @@ class PlayState extends MusicBeatSubState
var hitWindowCenter = note.strumTime; var hitWindowCenter = note.strumTime;
var hitWindowEnd = note.strumTime + Constants.HIT_WINDOW_MS; var hitWindowEnd = note.strumTime + Constants.HIT_WINDOW_MS;
if (Conductor.songPosition > hitWindowEnd) if (Conductor.instance.songPosition > hitWindowEnd)
{ {
note.tooEarly = false; note.tooEarly = false;
note.mayHit = false; note.mayHit = false;
note.hasMissed = true; note.hasMissed = true;
if (note.holdNoteSprite != null) note.holdNoteSprite.missedNote = true; if (note.holdNoteSprite != null) note.holdNoteSprite.missedNote = true;
} }
else if (Conductor.songPosition > hitWindowStart) else if (Conductor.instance.songPosition > hitWindowStart)
{ {
note.tooEarly = false; note.tooEarly = false;
note.mayHit = true; note.mayHit = true;
@ -1962,7 +1951,7 @@ class PlayState extends MusicBeatSubState
if (note == null || note.hasBeenHit) continue; if (note == null || note.hasBeenHit) continue;
var hitWindowEnd = note.strumTime + Constants.HIT_WINDOW_MS; var hitWindowEnd = note.strumTime + Constants.HIT_WINDOW_MS;
if (Conductor.songPosition > hitWindowEnd) if (Conductor.instance.songPosition > hitWindowEnd)
{ {
// We have passed this note. // We have passed this note.
// Flag the note for deletion without actually penalizing the player. // Flag the note for deletion without actually penalizing the player.
@ -2126,7 +2115,7 @@ class PlayState extends MusicBeatSubState
{ {
inputSpitter.push( inputSpitter.push(
{ {
t: Std.int(Conductor.songPosition), t: Std.int(Conductor.instance.songPosition),
d: indices[i], d: indices[i],
l: 20 l: 20
}); });
@ -2136,7 +2125,7 @@ class PlayState extends MusicBeatSubState
{ {
inputSpitter.push( inputSpitter.push(
{ {
t: Std.int(Conductor.songPosition), t: Std.int(Conductor.instance.songPosition),
d: -1, d: -1,
l: 20 l: 20
}); });
@ -2197,7 +2186,7 @@ class PlayState extends MusicBeatSubState
{ {
inputSpitter.push( inputSpitter.push(
{ {
t: Std.int(Conductor.songPosition), t: Std.int(Conductor.instance.songPosition),
d: indices[i], d: indices[i],
l: 20 l: 20
}); });
@ -2286,7 +2275,7 @@ class PlayState extends MusicBeatSubState
// Get the offset and compensate for input latency. // Get the offset and compensate for input latency.
// Round inward (trim remainder) for consistency. // Round inward (trim remainder) for consistency.
var noteDiff:Int = Std.int(Conductor.songPosition - daNote.noteData.time - inputLatencyMs); var noteDiff:Int = Std.int(Conductor.instance.songPosition - daNote.noteData.time - inputLatencyMs);
var score = Scoring.scoreNote(noteDiff, PBOT1); var score = Scoring.scoreNote(noteDiff, PBOT1);
var daRating = Scoring.judgeNote(noteDiff, PBOT1); var daRating = Scoring.judgeNote(noteDiff, PBOT1);
@ -2341,7 +2330,7 @@ class PlayState extends MusicBeatSubState
{ {
inputSpitter.push( inputSpitter.push(
{ {
t: Std.int(Conductor.songPosition), t: Std.int(Conductor.instance.songPosition),
d: indices[i], d: indices[i],
l: 20 l: 20
}); });
@ -2351,7 +2340,7 @@ class PlayState extends MusicBeatSubState
{ {
inputSpitter.push( inputSpitter.push(
{ {
t: Std.int(Conductor.songPosition), t: Std.int(Conductor.instance.songPosition),
d: -1, d: -1,
l: 20 l: 20
}); });
@ -2750,15 +2739,15 @@ class PlayState extends MusicBeatSubState
{ {
FlxG.sound.music.pause(); FlxG.sound.music.pause();
var targetTimeSteps:Float = Conductor.currentStepTime + (Conductor.timeSignatureNumerator * Constants.STEPS_PER_BEAT * sections); var targetTimeSteps:Float = Conductor.instance.currentStepTime + (Conductor.instance.timeSignatureNumerator * Constants.STEPS_PER_BEAT * sections);
var targetTimeMs:Float = Conductor.getStepTimeInMs(targetTimeSteps); var targetTimeMs:Float = Conductor.instance.getStepTimeInMs(targetTimeSteps);
FlxG.sound.music.time = targetTimeMs; FlxG.sound.music.time = targetTimeMs;
handleSkippedNotes(); handleSkippedNotes();
// regenNoteData(FlxG.sound.music.time); // regenNoteData(FlxG.sound.music.time);
Conductor.update(FlxG.sound.music.time); Conductor.instance.update(FlxG.sound.music.time);
resyncVocals(); resyncVocals();
} }

View file

@ -367,7 +367,7 @@ class BaseCharacter extends Bopper
// This lets you add frames to the end of the sing animation to ease back into the idle! // This lets you add frames to the end of the sing animation to ease back into the idle!
holdTimer += event.elapsed; holdTimer += event.elapsed;
var singTimeSec:Float = singTimeSec * (Conductor.beatLengthMs * 0.001); // x beats, to ms. var singTimeSec:Float = singTimeSec * (Conductor.instance.beatLengthMs * 0.001); // x beats, to ms.
if (getCurrentAnimation().endsWith('miss')) singTimeSec *= 2; // makes it feel more awkward when you miss if (getCurrentAnimation().endsWith('miss')) singTimeSec *= 2; // makes it feel more awkward when you miss

View file

@ -205,7 +205,7 @@ class MultiSparrowCharacter extends BaseCharacter
graphic = value.parent; graphic = value.parent;
this.frames = value; this.frames = value;
this.frame = value.getByIndex(0); this.frame = value.getByIndex(0);
this.numFrames = value.numFrames; // this.numFrames = value.numFrames;
resetHelpers(); resetHelpers();
this.bakedRotationAngle = 0; this.bakedRotationAngle = 0;
this.animation.frameIndex = 0; this.animation.frameIndex = 0;

View file

@ -40,7 +40,7 @@ class ComboMilestone extends FlxTypedSpriteGroup<FlxSprite>
{ {
if (onScreenTime < 0.9) if (onScreenTime < 0.9)
{ {
new FlxTimer().start((Conductor.beatLengthMs / 1000) * 0.25, function(tmr) { new FlxTimer().start((Conductor.instance.beatLengthMs / 1000) * 0.25, function(tmr) {
forceFinish(); forceFinish();
}); });
} }

View file

@ -59,7 +59,7 @@ class PopUpStuff extends FlxTypedGroup<FlxSprite>
remove(rating, true); remove(rating, true);
rating.destroy(); rating.destroy();
}, },
startDelay: Conductor.beatLengthMs * 0.001 startDelay: Conductor.instance.beatLengthMs * 0.001
}); });
} }
@ -110,7 +110,7 @@ class PopUpStuff extends FlxTypedGroup<FlxSprite>
remove(comboSpr, true); remove(comboSpr, true);
comboSpr.destroy(); comboSpr.destroy();
}, },
startDelay: Conductor.beatLengthMs * 0.001 startDelay: Conductor.instance.beatLengthMs * 0.001
}); });
var seperatedScore:Array<Int> = []; var seperatedScore:Array<Int> = [];
@ -157,7 +157,7 @@ class PopUpStuff extends FlxTypedGroup<FlxSprite>
remove(numScore, true); remove(numScore, true);
numScore.destroy(); numScore.destroy();
}, },
startDelay: Conductor.beatLengthMs * 0.002 startDelay: Conductor.instance.beatLengthMs * 0.002
}); });
daLoop++; daLoop++;

View file

@ -79,7 +79,8 @@ class ZoomCameraSongEvent extends SongEvent
return; return;
} }
FlxTween.tween(PlayState.instance, {defaultCameraZoom: zoom * FlxCamera.defaultZoom}, (Conductor.stepLengthMs * duration / 1000), {ease: easeFunction}); FlxTween.tween(PlayState.instance, {defaultCameraZoom: zoom * FlxCamera.defaultZoom}, (Conductor.instance.stepLengthMs * duration / 1000),
{ease: easeFunction});
} }
} }

View file

@ -274,10 +274,12 @@ class Strumline extends FlxSpriteGroup
static function calculateNoteYPos(strumTime:Float, vwoosh:Bool = true):Float static function calculateNoteYPos(strumTime:Float, vwoosh:Bool = true):Float
{ {
// Make the note move faster visually as it moves offscreen. // Make the note move faster visually as it moves offscreen.
var vwoosh:Float = (strumTime < Conductor.songPosition) && vwoosh ? 2.0 : 1.0; // var vwoosh:Float = (strumTime < Conductor.songPosition) && vwoosh ? 2.0 : 1.0;
// ^^^ commented this out... do NOT make it move faster as it moves offscreen!
var vwoosh:Float = 1.0;
var scrollSpeed:Float = PlayState.instance?.currentChart?.scrollSpeed ?? 1.0; var scrollSpeed:Float = PlayState.instance?.currentChart?.scrollSpeed ?? 1.0;
return Constants.PIXELS_PER_MS * (Conductor.songPosition - strumTime) * scrollSpeed * vwoosh * (Preferences.downscroll ? 1 : -1); return Constants.PIXELS_PER_MS * (Conductor.instance.songPosition - strumTime) * scrollSpeed * vwoosh * (Preferences.downscroll ? 1 : -1);
} }
function updateNotes():Void function updateNotes():Void
@ -285,8 +287,8 @@ class Strumline extends FlxSpriteGroup
if (noteData.length == 0) return; if (noteData.length == 0) return;
var songStart:Float = PlayState.instance?.startTimestamp ?? 0.0; var songStart:Float = PlayState.instance?.startTimestamp ?? 0.0;
var hitWindowStart:Float = Conductor.songPosition - Constants.HIT_WINDOW_MS; var hitWindowStart:Float = Conductor.instance.songPosition - Constants.HIT_WINDOW_MS;
var renderWindowStart:Float = Conductor.songPosition + RENDER_DISTANCE_MS; var renderWindowStart:Float = Conductor.instance.songPosition + RENDER_DISTANCE_MS;
for (noteIndex in nextNoteIndex...noteData.length) for (noteIndex in nextNoteIndex...noteData.length)
{ {
@ -333,7 +335,7 @@ class Strumline extends FlxSpriteGroup
{ {
if (holdNote == null || !holdNote.alive) continue; if (holdNote == null || !holdNote.alive) continue;
if (Conductor.songPosition > holdNote.strumTime && holdNote.hitNote && !holdNote.missedNote) if (Conductor.instance.songPosition > holdNote.strumTime && holdNote.hitNote && !holdNote.missedNote)
{ {
if (isPlayer && !isKeyHeld(holdNote.noteDirection)) if (isPlayer && !isKeyHeld(holdNote.noteDirection))
{ {
@ -347,7 +349,7 @@ class Strumline extends FlxSpriteGroup
var renderWindowEnd = holdNote.strumTime + holdNote.fullSustainLength + Constants.HIT_WINDOW_MS + RENDER_DISTANCE_MS / 8; var renderWindowEnd = holdNote.strumTime + holdNote.fullSustainLength + Constants.HIT_WINDOW_MS + RENDER_DISTANCE_MS / 8;
if (holdNote.missedNote && Conductor.songPosition >= renderWindowEnd) if (holdNote.missedNote && Conductor.instance.songPosition >= renderWindowEnd)
{ {
// Hold note is offscreen, kill it. // Hold note is offscreen, kill it.
holdNote.visible = false; holdNote.visible = false;
@ -397,13 +399,13 @@ class Strumline extends FlxSpriteGroup
holdNote.y = this.y - INITIAL_OFFSET + calculateNoteYPos(holdNote.strumTime, vwoosh) + yOffset + STRUMLINE_SIZE / 2; holdNote.y = this.y - INITIAL_OFFSET + calculateNoteYPos(holdNote.strumTime, vwoosh) + yOffset + STRUMLINE_SIZE / 2;
} }
} }
else if (Conductor.songPosition > holdNote.strumTime && holdNote.hitNote) else if (Conductor.instance.songPosition > holdNote.strumTime && holdNote.hitNote)
{ {
// Hold note is currently being hit, clip it off. // Hold note is currently being hit, clip it off.
holdConfirm(holdNote.noteDirection); holdConfirm(holdNote.noteDirection);
holdNote.visible = true; holdNote.visible = true;
holdNote.sustainLength = (holdNote.strumTime + holdNote.fullSustainLength) - Conductor.songPosition; holdNote.sustainLength = (holdNote.strumTime + holdNote.fullSustainLength) - Conductor.instance.songPosition;
if (holdNote.sustainLength <= 10) if (holdNote.sustainLength <= 10)
{ {

View file

@ -149,9 +149,9 @@ class SustainTrail extends FlxSprite
if (sustainLength == s) return s; if (sustainLength == s) return s;
height = sustainHeight(s, getScrollSpeed()); height = sustainHeight(s, getScrollSpeed());
// updateColorTransform(); this.sustainLength = s;
updateClipping(); updateClipping();
return sustainLength = s; return this.sustainLength;
} }
/** /**
@ -162,13 +162,15 @@ class SustainTrail extends FlxSprite
public function updateClipping(songTime:Float = 0):Void public function updateClipping(songTime:Float = 0):Void
{ {
var clipHeight:Float = FlxMath.bound(sustainHeight(sustainLength - (songTime - strumTime), getScrollSpeed()), 0, height); var clipHeight:Float = FlxMath.bound(sustainHeight(sustainLength - (songTime - strumTime), getScrollSpeed()), 0, height);
if (clipHeight == 0) if (clipHeight <= 0.1)
{ {
visible = false; visible = false;
return; return;
} }
else else
{
visible = true; visible = true;
}
var bottomHeight:Float = graphic.height * zoom * endOffset; var bottomHeight:Float = graphic.height * zoom * endOffset;
var partHeight:Float = clipHeight - bottomHeight; var partHeight:Float = clipHeight - bottomHeight;

View file

@ -164,6 +164,7 @@ class StageDataParser
try try
{ {
var parser = new json2object.JsonParser<StageData>(); var parser = new json2object.JsonParser<StageData>();
parser.ignoreUnknownVariables = false;
parser.fromJson(rawJson, '$stageId.json'); parser.fromJson(rawJson, '$stageId.json');
if (parser.errors.length > 0) if (parser.errors.length > 0)

View file

@ -83,13 +83,13 @@ class MusicBeatState extends FlxTransitionableState implements IEventHandler
function handleQuickWatch():Void function handleQuickWatch():Void
{ {
// Display Conductor info in the watch window. // Display Conductor info in the watch window.
FlxG.watch.addQuick("songPosition", Conductor.songPosition); FlxG.watch.addQuick("songPosition", Conductor.instance.songPosition);
FlxG.watch.addQuick("songPositionNoOffset", Conductor.songPosition + Conductor.instrumentalOffset); FlxG.watch.addQuick("songPositionNoOffset", Conductor.instance.songPosition + Conductor.instance.instrumentalOffset);
FlxG.watch.addQuick("musicTime", FlxG.sound.music?.time ?? 0.0); FlxG.watch.addQuick("musicTime", FlxG.sound.music?.time ?? 0.0);
FlxG.watch.addQuick("bpm", Conductor.bpm); FlxG.watch.addQuick("bpm", Conductor.instance.bpm);
FlxG.watch.addQuick("currentMeasureTime", Conductor.currentBeatTime); FlxG.watch.addQuick("currentMeasureTime", Conductor.instance.currentBeatTime);
FlxG.watch.addQuick("currentBeatTime", Conductor.currentBeatTime); FlxG.watch.addQuick("currentBeatTime", Conductor.instance.currentBeatTime);
FlxG.watch.addQuick("currentStepTime", Conductor.currentStepTime); FlxG.watch.addQuick("currentStepTime", Conductor.instance.currentStepTime);
} }
override function update(elapsed:Float) override function update(elapsed:Float)
@ -139,7 +139,7 @@ class MusicBeatState extends FlxTransitionableState implements IEventHandler
public function stepHit():Bool public function stepHit():Bool
{ {
var event = new SongTimeScriptEvent(SONG_STEP_HIT, Conductor.currentBeat, Conductor.currentStep); var event = new SongTimeScriptEvent(SONG_STEP_HIT, Conductor.instance.currentBeat, Conductor.instance.currentStep);
dispatchEvent(event); dispatchEvent(event);
@ -150,7 +150,7 @@ class MusicBeatState extends FlxTransitionableState implements IEventHandler
public function beatHit():Bool public function beatHit():Bool
{ {
var event = new SongTimeScriptEvent(SONG_BEAT_HIT, Conductor.currentBeat, Conductor.currentStep); var event = new SongTimeScriptEvent(SONG_BEAT_HIT, Conductor.instance.currentBeat, Conductor.instance.currentStep);
dispatchEvent(event); dispatchEvent(event);

View file

@ -65,12 +65,8 @@ class MusicBeatSubState extends FlxTransitionableSubState implements IEventHandl
if (FlxG.keys.justPressed.F5) debug_refreshModules(); if (FlxG.keys.justPressed.F5) debug_refreshModules();
// Display Conductor info in the watch window. // Display Conductor info in the watch window.
FlxG.watch.addQuick("songPosition", Conductor.songPosition);
FlxG.watch.addQuick("musicTime", FlxG.sound.music?.time ?? 0.0); FlxG.watch.addQuick("musicTime", FlxG.sound.music?.time ?? 0.0);
FlxG.watch.addQuick("bpm", Conductor.bpm); Conductor.watchQuick();
FlxG.watch.addQuick("currentMeasureTime", Conductor.currentBeatTime);
FlxG.watch.addQuick("currentBeatTime", Conductor.currentBeatTime);
FlxG.watch.addQuick("currentStepTime", Conductor.currentStepTime);
dispatchEvent(new UpdateScriptEvent(elapsed)); dispatchEvent(new UpdateScriptEvent(elapsed));
} }
@ -99,7 +95,7 @@ class MusicBeatSubState extends FlxTransitionableSubState implements IEventHandl
*/ */
public function stepHit():Bool public function stepHit():Bool
{ {
var event:ScriptEvent = new SongTimeScriptEvent(SONG_STEP_HIT, Conductor.currentBeat, Conductor.currentStep); var event:ScriptEvent = new SongTimeScriptEvent(SONG_STEP_HIT, Conductor.instance.currentBeat, Conductor.instance.currentStep);
dispatchEvent(event); dispatchEvent(event);
@ -115,7 +111,7 @@ class MusicBeatSubState extends FlxTransitionableSubState implements IEventHandl
*/ */
public function beatHit():Bool public function beatHit():Bool
{ {
var event:ScriptEvent = new SongTimeScriptEvent(SONG_BEAT_HIT, Conductor.currentBeat, Conductor.currentStep); var event:ScriptEvent = new SongTimeScriptEvent(SONG_BEAT_HIT, Conductor.instance.currentBeat, Conductor.instance.currentStep);
dispatchEvent(event); dispatchEvent(event);

View file

@ -21,6 +21,7 @@ import flixel.system.FlxAssets.FlxSoundAsset;
import flixel.tweens.FlxEase; import flixel.tweens.FlxEase;
import flixel.tweens.FlxTween; import flixel.tweens.FlxTween;
import flixel.tweens.misc.VarTween; import flixel.tweens.misc.VarTween;
import haxe.ui.Toolkit;
import flixel.util.FlxColor; import flixel.util.FlxColor;
import flixel.util.FlxSort; import flixel.util.FlxSort;
import flixel.util.FlxTimer; import flixel.util.FlxTimer;
@ -124,6 +125,7 @@ import flixel.group.FlxGroup.FlxTypedGroup;
import funkin.audio.visualize.PolygonVisGroup; import funkin.audio.visualize.PolygonVisGroup;
import flixel.input.mouse.FlxMouseEvent; import flixel.input.mouse.FlxMouseEvent;
import flixel.text.FlxText; import flixel.text.FlxText;
import flixel.system.debug.log.LogStyle;
using Lambda; using Lambda;
@ -273,13 +275,13 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
function get_songLengthInSteps():Float function get_songLengthInSteps():Float
{ {
return Conductor.getTimeInSteps(songLengthInMs); return Conductor.instance.getTimeInSteps(songLengthInMs);
} }
function set_songLengthInSteps(value:Float):Float function set_songLengthInSteps(value:Float):Float
{ {
// Getting a reasonable result from setting songLengthInSteps requires that Conductor.mapBPMChanges be called first. // Getting a reasonable result from setting songLengthInSteps requires that Conductor.instance.mapBPMChanges be called first.
songLengthInMs = Conductor.getStepTimeInMs(value); songLengthInMs = Conductor.instance.getStepTimeInMs(value);
return value; return value;
} }
@ -393,12 +395,12 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
function get_scrollPositionInMs():Float function get_scrollPositionInMs():Float
{ {
return Conductor.getStepTimeInMs(scrollPositionInSteps); return Conductor.instance.getStepTimeInMs(scrollPositionInSteps);
} }
function set_scrollPositionInMs(value:Float):Float function set_scrollPositionInMs(value:Float):Float
{ {
scrollPositionInSteps = Conductor.getTimeInSteps(value); scrollPositionInSteps = Conductor.instance.getTimeInSteps(value);
return value; return value;
} }
@ -452,13 +454,13 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
function get_playheadPositionInMs():Float function get_playheadPositionInMs():Float
{ {
if (audioVisGroup != null && audioVisGroup.playerVis != null) if (audioVisGroup != null && audioVisGroup.playerVis != null)
audioVisGroup.playerVis.realtimeStartOffset = -Conductor.getStepTimeInMs(playheadPositionInSteps); audioVisGroup.playerVis.realtimeStartOffset = -Conductor.instance.getStepTimeInMs(playheadPositionInSteps);
return Conductor.getStepTimeInMs(playheadPositionInSteps); return Conductor.instance.getStepTimeInMs(playheadPositionInSteps);
} }
function set_playheadPositionInMs(value:Float):Float function set_playheadPositionInMs(value:Float):Float
{ {
playheadPositionInSteps = Conductor.getTimeInSteps(value); playheadPositionInSteps = Conductor.instance.getTimeInSteps(value);
if (audioVisGroup != null && audioVisGroup.playerVis != null) audioVisGroup.playerVis.realtimeStartOffset = -value; if (audioVisGroup != null && audioVisGroup.playerVis != null) audioVisGroup.playerVis.realtimeStartOffset = -value;
return value; return value;
@ -544,6 +546,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
*/ */
var playtestPracticeMode:Bool = false; var playtestPracticeMode:Bool = false;
/**
* Enables or disables the "debugger" popup that appears when you run into a flixel error.
*/
var enabledDebuggerPopup:Bool = true;
// Visuals // Visuals
/** /**
@ -753,15 +760,23 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
function set_currentNoteSelection(value:Array<SongNoteData>):Array<SongNoteData> function set_currentNoteSelection(value:Array<SongNoteData>):Array<SongNoteData>
{ {
// This value is true if all elements of the current selection are also in the new selection.
var isSuperset:Bool = currentNoteSelection.isSubset(value);
var isEqual:Bool = currentNoteSelection.isEqualUnordered(value);
currentNoteSelection = value; currentNoteSelection = value;
if (currentNoteSelection.length > 0) if (!isEqual)
{ {
notePreview.addNotes(currentNoteSelection, Std.int(songLengthInMs), true); if (currentNoteSelection.length > 0 && isSuperset)
} {
else notePreview.addSelectedNotes(currentNoteSelection, Std.int(songLengthInMs));
{ }
notePreviewDirty = true; else
{
// The new selection removes elements from the old selection, so we have to redraw the note preview.
notePreviewDirty = true;
}
} }
return currentNoteSelection; return currentNoteSelection;
@ -1080,7 +1095,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
function get_availableDifficulties():Array<String> function get_availableDifficulties():Array<String>
{ {
var m:Null<SongMetadata> = songMetadata.get(selectedVariation); var m:Null<SongMetadata> = songMetadata.get(selectedVariation);
return m?.playData?.difficulties ?? []; return m?.playData?.difficulties ?? [Constants.DEFAULT_DIFFICULTY];
} }
/** /**
@ -1139,7 +1154,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
var result:Null<SongChartData> = songChartData.get(selectedVariation); var result:Null<SongChartData> = songChartData.get(selectedVariation);
if (result == null) if (result == null)
{ {
result = new SongChartData(["normal" => 1.0], [], ["normal" => []]); result = new SongChartData([Constants.DEFAULT_DIFFICULTY => 1.0], [], [Constants.DEFAULT_DIFFICULTY => []]);
songChartData.set(selectedVariation, result); songChartData.set(selectedVariation, result);
} }
return result; return result;
@ -1363,6 +1378,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
function set_selectedDifficulty(value:String):String function set_selectedDifficulty(value:String):String
{ {
if (value == null) value = availableDifficulties[0] ?? Constants.DEFAULT_DIFFICULTY;
selectedDifficulty = value; selectedDifficulty = value;
// Make sure view is updated when the difficulty changes. // Make sure view is updated when the difficulty changes.
@ -2408,16 +2425,33 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
} }
else else
{ {
Conductor.currentTimeChange.bpm += 1; Conductor.instance.currentTimeChange.bpm += 1;
this.refreshToolbox(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT); this.refreshToolbox(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT);
} }
} }
playbarBPM.onRightClick = _ -> { playbarBPM.onRightClick = _ -> {
Conductor.currentTimeChange.bpm -= 1; Conductor.instance.currentTimeChange.bpm -= 1;
this.refreshToolbox(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT); this.refreshToolbox(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT);
} }
playbarDifficulty.onClick = _ -> {
if (FlxG.keys.pressed.CONTROL)
{
this.setToolboxState(CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT, true);
}
else
{
incrementDifficulty(-1);
this.refreshToolbox(CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT);
}
}
playbarDifficulty.onRightClick = _ -> {
incrementDifficulty(1);
this.refreshToolbox(CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT);
}
// Add functionality to the menu items. // Add functionality to the menu items.
// File // File
@ -2462,9 +2496,9 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
menubarItemPaste.onClick = _ -> { menubarItemPaste.onClick = _ -> {
var targetMs:Float = scrollPositionInMs + playheadPositionInMs; var targetMs:Float = scrollPositionInMs + playheadPositionInMs;
var targetStep:Float = Conductor.getTimeInSteps(targetMs); var targetStep:Float = Conductor.instance.getTimeInSteps(targetMs);
var targetSnappedStep:Float = Math.floor(targetStep / noteSnapRatio) * noteSnapRatio; var targetSnappedStep:Float = Math.floor(targetStep / noteSnapRatio) * noteSnapRatio;
var targetSnappedMs:Float = Conductor.getStepTimeInMs(targetSnappedStep); var targetSnappedMs:Float = Conductor.instance.getStepTimeInMs(targetSnappedStep);
performCommand(new PasteItemsCommand(targetSnappedMs)); performCommand(new PasteItemsCommand(targetSnappedMs));
}; };
@ -2552,8 +2586,25 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
menubarItemPlayPause.onClick = _ -> toggleAudioPlayback(); menubarItemPlayPause.onClick = _ -> toggleAudioPlayback();
menubarItemLoadInstrumental.onClick = _ -> this.openUploadInstDialog(true); menubarItemLoadInstrumental.onClick = _ -> {
menubarItemLoadVocals.onClick = _ -> this.openUploadVocalsDialog(true); var dialog = this.openUploadInstDialog(true);
// Ensure instrumental and vocals are reloaded properly.
dialog.onDialogClosed = function(_) {
this.isHaxeUIDialogOpen = false;
this.switchToCurrentInstrumental();
this.postLoadInstrumental();
}
};
menubarItemLoadVocals.onClick = _ -> {
var dialog = this.openUploadVocalsDialog(true);
// Ensure instrumental and vocals are reloaded properly.
dialog.onDialogClosed = function(_) {
this.isHaxeUIDialogOpen = false;
this.switchToCurrentInstrumental();
this.postLoadInstrumental();
}
};
menubarItemVolumeMetronome.onChange = event -> { menubarItemVolumeMetronome.onChange = event -> {
var volume:Float = event.value.toFloat() / 100.0; var volume:Float = event.value.toFloat() / 100.0;
@ -2598,10 +2649,6 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
menubarLabelPlaybackSpeed.text = 'Playback Speed - ${pitchDisplay}x'; menubarLabelPlaybackSpeed.text = 'Playback Speed - ${pitchDisplay}x';
} }
playbarDifficulty.onClick = _ -> {
this.setToolboxState(CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT, true);
}
menubarItemToggleToolboxDifficulty.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT, event.value); menubarItemToggleToolboxDifficulty.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT, event.value);
menubarItemToggleToolboxMetadata.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT, event.value); menubarItemToggleToolboxMetadata.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT, event.value);
menubarItemToggleToolboxNotes.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_NOTEDATA_LAYOUT, event.value); menubarItemToggleToolboxNotes.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_NOTEDATA_LAYOUT, event.value);
@ -2645,10 +2692,12 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
saveDataDirty = false; saveDataDirty = false;
} }
var displayAutosavePopup:Bool = false;
/** /**
* UPDATE FUNCTIONS * UPDATE FUNCTIONS
*/ */
function autoSave():Void function autoSave(?beforePlaytest:Bool = false):Void
{ {
var needsAutoSave:Bool = saveDataDirty; var needsAutoSave:Bool = saveDataDirty;
@ -2666,13 +2715,21 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
if (needsAutoSave) if (needsAutoSave)
{ {
this.exportAllSongData(true, null); this.exportAllSongData(true, null);
var absoluteBackupsPath:String = Path.join([Sys.getCwd(), ChartEditorImportExportHandler.BACKUPS_PATH]); if (beforePlaytest)
this.infoWithActions('Auto-Save', 'Chart auto-saved to ${absoluteBackupsPath}.', [ {
{ displayAutosavePopup = true;
text: "Take Me There", }
callback: openBackupsFolder, else
} {
]); displayAutosavePopup = false;
var absoluteBackupsPath:String = Path.join([Sys.getCwd(), ChartEditorImportExportHandler.BACKUPS_PATH]);
this.infoWithActions('Auto-Save', 'Chart auto-saved to ${absoluteBackupsPath}.', [
{
text: "Take Me There",
callback: openBackupsFolder,
}
]);
}
} }
#end #end
} }
@ -2681,14 +2738,16 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
* Open the backups folder in the file explorer. * Open the backups folder in the file explorer.
* Don't call this on HTML5. * Don't call this on HTML5.
*/ */
function openBackupsFolder(?_):Void function openBackupsFolder(?_):Bool
{ {
#if sys #if sys
// TODO: Is there a way to open a folder and highlight a file in it? // TODO: Is there a way to open a folder and highlight a file in it?
var absoluteBackupsPath:String = Path.join([Sys.getCwd(), ChartEditorImportExportHandler.BACKUPS_PATH]); var absoluteBackupsPath:String = Path.join([Sys.getCwd(), ChartEditorImportExportHandler.BACKUPS_PATH]);
WindowUtil.openFolder(absoluteBackupsPath); WindowUtil.openFolder(absoluteBackupsPath);
return true;
#else #else
trace('No file system access, cannot open backups folder.'); trace('No file system access, cannot open backups folder.');
return false;
#end #end
} }
@ -2788,7 +2847,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
if (metronomeVolume > 0.0 && this.subState == null && (audioInstTrack != null && audioInstTrack.isPlaying)) if (metronomeVolume > 0.0 && this.subState == null && (audioInstTrack != null && audioInstTrack.isPlaying))
{ {
playMetronomeTick(Conductor.currentBeat % 4 == 0); playMetronomeTick(Conductor.instance.currentBeat % 4 == 0);
} }
return true; return true;
@ -2804,8 +2863,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
if (audioInstTrack != null && audioInstTrack.isPlaying) if (audioInstTrack != null && audioInstTrack.isPlaying)
{ {
if (healthIconDad != null) healthIconDad.onStepHit(Conductor.currentStep); if (healthIconDad != null) healthIconDad.onStepHit(Conductor.instance.currentStep);
if (healthIconBF != null) healthIconBF.onStepHit(Conductor.currentStep); if (healthIconBF != null) healthIconBF.onStepHit(Conductor.instance.currentStep);
} }
// Updating these every step keeps it more accurate. // Updating these every step keeps it more accurate.
@ -2833,12 +2892,12 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
audioInstTrack.update(elapsed); audioInstTrack.update(elapsed);
// If the song starts 50ms in, make sure we start the song there. // If the song starts 50ms in, make sure we start the song there.
if (Conductor.instrumentalOffset < 0) if (Conductor.instance.instrumentalOffset < 0)
{ {
if (audioInstTrack.time < -Conductor.instrumentalOffset) if (audioInstTrack.time < -Conductor.instance.instrumentalOffset)
{ {
trace('Resetting instrumental time to ${- Conductor.instrumentalOffset}ms'); trace('Resetting instrumental time to ${- Conductor.instance.instrumentalOffset}ms');
audioInstTrack.time = -Conductor.instrumentalOffset; audioInstTrack.time = -Conductor.instance.instrumentalOffset;
} }
} }
} }
@ -2849,16 +2908,16 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
{ {
// If middle mouse panning during song playback, we move ONLY the playhead, without scrolling. Neat! // If middle mouse panning during song playback, we move ONLY the playhead, without scrolling. Neat!
var oldStepTime:Float = Conductor.currentStepTime; var oldStepTime:Float = Conductor.instance.currentStepTime;
var oldSongPosition:Float = Conductor.songPosition + Conductor.instrumentalOffset; var oldSongPosition:Float = Conductor.instance.songPosition + Conductor.instance.instrumentalOffset;
Conductor.update(audioInstTrack.time); Conductor.instance.update(audioInstTrack.time);
handleHitsounds(oldSongPosition, Conductor.songPosition + Conductor.instrumentalOffset); handleHitsounds(oldSongPosition, Conductor.instance.songPosition + Conductor.instance.instrumentalOffset);
// Resync vocals. // Resync vocals.
if (audioVocalTrackGroup != null && Math.abs(audioInstTrack.time - audioVocalTrackGroup.time) > 100) if (audioVocalTrackGroup != null && Math.abs(audioInstTrack.time - audioVocalTrackGroup.time) > 100)
{ {
audioVocalTrackGroup.time = audioInstTrack.time; audioVocalTrackGroup.time = audioInstTrack.time;
} }
var diffStepTime:Float = Conductor.currentStepTime - oldStepTime; var diffStepTime:Float = Conductor.instance.currentStepTime - oldStepTime;
// Move the playhead. // Move the playhead.
playheadPositionInPixels += diffStepTime * GRID_SIZE; playheadPositionInPixels += diffStepTime * GRID_SIZE;
@ -2868,9 +2927,9 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
else else
{ {
// Else, move the entire view. // Else, move the entire view.
var oldSongPosition:Float = Conductor.songPosition + Conductor.instrumentalOffset; var oldSongPosition:Float = Conductor.instance.songPosition + Conductor.instance.instrumentalOffset;
Conductor.update(audioInstTrack.time); Conductor.instance.update(audioInstTrack.time);
handleHitsounds(oldSongPosition, Conductor.songPosition + Conductor.instrumentalOffset); handleHitsounds(oldSongPosition, Conductor.instance.songPosition + Conductor.instance.instrumentalOffset);
// Resync vocals. // Resync vocals.
if (audioVocalTrackGroup != null && Math.abs(audioInstTrack.time - audioVocalTrackGroup.time) > 100) if (audioVocalTrackGroup != null && Math.abs(audioInstTrack.time - audioVocalTrackGroup.time) > 100)
{ {
@ -2879,7 +2938,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
// We need time in fractional steps here to allow the song to actually play. // We need time in fractional steps here to allow the song to actually play.
// Also account for a potentially offset playhead. // Also account for a potentially offset playhead.
scrollPositionInPixels = (Conductor.currentStepTime + Conductor.instrumentalOffsetSteps) * GRID_SIZE - playheadPositionInPixels; scrollPositionInPixels = (Conductor.instance.currentStepTime + Conductor.instance.instrumentalOffsetSteps) * GRID_SIZE - playheadPositionInPixels;
// DO NOT move song to scroll position here specifically. // DO NOT move song to scroll position here specifically.
@ -3008,8 +3067,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
// Let's try testing only notes within a certain range of the view area. // Let's try testing only notes within a certain range of the view area.
// TODO: I don't think this messes up really long sustains, does it? // TODO: I don't think this messes up really long sustains, does it?
var viewAreaTopMs:Float = scrollPositionInMs - (Conductor.measureLengthMs * 2); // Is 2 measures enough? var viewAreaTopMs:Float = scrollPositionInMs - (Conductor.instance.measureLengthMs * 2); // Is 2 measures enough?
var viewAreaBottomMs:Float = scrollPositionInMs + (Conductor.measureLengthMs * 2); // Is 2 measures enough? var viewAreaBottomMs:Float = scrollPositionInMs + (Conductor.instance.measureLengthMs * 2); // Is 2 measures enough?
// Add notes that are now visible. // Add notes that are now visible.
for (noteData in currentSongChartNoteData) for (noteData in currentSongChartNoteData)
@ -3296,14 +3355,14 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
// PAGE UP = Jump up to nearest measure // PAGE UP = Jump up to nearest measure
if (pageUpKeyHandler.activated) if (pageUpKeyHandler.activated)
{ {
var measureHeight:Float = GRID_SIZE * 4 * Conductor.beatsPerMeasure; var measureHeight:Float = GRID_SIZE * 4 * Conductor.instance.beatsPerMeasure;
var playheadPos:Float = scrollPositionInPixels + playheadPositionInPixels; var playheadPos:Float = scrollPositionInPixels + playheadPositionInPixels;
var targetScrollPosition:Float = Math.floor(playheadPos / measureHeight) * measureHeight; var targetScrollPosition:Float = Math.floor(playheadPos / measureHeight) * measureHeight;
// If we would move less than one grid, instead move to the top of the previous measure. // If we would move less than one grid, instead move to the top of the previous measure.
var targetScrollAmount = Math.abs(targetScrollPosition - playheadPos); var targetScrollAmount = Math.abs(targetScrollPosition - playheadPos);
if (targetScrollAmount < GRID_SIZE) if (targetScrollAmount < GRID_SIZE)
{ {
targetScrollPosition -= GRID_SIZE * Constants.STEPS_PER_BEAT * Conductor.beatsPerMeasure; targetScrollPosition -= GRID_SIZE * Constants.STEPS_PER_BEAT * Conductor.instance.beatsPerMeasure;
} }
scrollAmount = targetScrollPosition - playheadPos; scrollAmount = targetScrollPosition - playheadPos;
@ -3312,21 +3371,21 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
if (playbarButtonPressed == 'playbarBack') if (playbarButtonPressed == 'playbarBack')
{ {
playbarButtonPressed = ''; playbarButtonPressed = '';
scrollAmount = -GRID_SIZE * 4 * Conductor.beatsPerMeasure; scrollAmount = -GRID_SIZE * 4 * Conductor.instance.beatsPerMeasure;
shouldPause = true; shouldPause = true;
} }
// PAGE DOWN = Jump down to nearest measure // PAGE DOWN = Jump down to nearest measure
if (pageDownKeyHandler.activated) if (pageDownKeyHandler.activated)
{ {
var measureHeight:Float = GRID_SIZE * 4 * Conductor.beatsPerMeasure; var measureHeight:Float = GRID_SIZE * 4 * Conductor.instance.beatsPerMeasure;
var playheadPos:Float = scrollPositionInPixels + playheadPositionInPixels; var playheadPos:Float = scrollPositionInPixels + playheadPositionInPixels;
var targetScrollPosition:Float = Math.ceil(playheadPos / measureHeight) * measureHeight; var targetScrollPosition:Float = Math.ceil(playheadPos / measureHeight) * measureHeight;
// If we would move less than one grid, instead move to the top of the next measure. // If we would move less than one grid, instead move to the top of the next measure.
var targetScrollAmount = Math.abs(targetScrollPosition - playheadPos); var targetScrollAmount = Math.abs(targetScrollPosition - playheadPos);
if (targetScrollAmount < GRID_SIZE) if (targetScrollAmount < GRID_SIZE)
{ {
targetScrollPosition += GRID_SIZE * Constants.STEPS_PER_BEAT * Conductor.beatsPerMeasure; targetScrollPosition += GRID_SIZE * Constants.STEPS_PER_BEAT * Conductor.instance.beatsPerMeasure;
} }
scrollAmount = targetScrollPosition - playheadPos; scrollAmount = targetScrollPosition - playheadPos;
@ -3335,7 +3394,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
if (playbarButtonPressed == 'playbarForward') if (playbarButtonPressed == 'playbarForward')
{ {
playbarButtonPressed = ''; playbarButtonPressed = '';
scrollAmount = GRID_SIZE * 4 * Conductor.beatsPerMeasure; scrollAmount = GRID_SIZE * 4 * Conductor.instance.beatsPerMeasure;
shouldPause = true; shouldPause = true;
} }
@ -3538,10 +3597,10 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
// The song position of the cursor, in steps. // The song position of the cursor, in steps.
var cursorFractionalStep:Float = cursorY / GRID_SIZE; var cursorFractionalStep:Float = cursorY / GRID_SIZE;
var cursorMs:Float = Conductor.getStepTimeInMs(cursorFractionalStep); var cursorMs:Float = Conductor.instance.getStepTimeInMs(cursorFractionalStep);
// Round the cursor step to the nearest snap quant. // Round the cursor step to the nearest snap quant.
var cursorSnappedStep:Float = Math.floor(cursorFractionalStep / noteSnapRatio) * noteSnapRatio; var cursorSnappedStep:Float = Math.floor(cursorFractionalStep / noteSnapRatio) * noteSnapRatio;
var cursorSnappedMs:Float = Conductor.getStepTimeInMs(cursorSnappedStep); var cursorSnappedMs:Float = Conductor.instance.getStepTimeInMs(cursorSnappedStep);
// The direction value for the column at the cursor. // The direction value for the column at the cursor.
var cursorGridPos:Int = Math.floor(cursorX / GRID_SIZE); var cursorGridPos:Int = Math.floor(cursorX / GRID_SIZE);
@ -3563,7 +3622,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
// We released the mouse. Select the notes in the box. // We released the mouse. Select the notes in the box.
var cursorFractionalStepStart:Float = cursorYStart / GRID_SIZE; var cursorFractionalStepStart:Float = cursorYStart / GRID_SIZE;
var cursorStepStart:Int = Math.floor(cursorFractionalStepStart); var cursorStepStart:Int = Math.floor(cursorFractionalStepStart);
var cursorMsStart:Float = Conductor.getStepTimeInMs(cursorStepStart); var cursorMsStart:Float = Conductor.instance.getStepTimeInMs(cursorStepStart);
var cursorColumnBase:Int = Math.floor(cursorX / GRID_SIZE); var cursorColumnBase:Int = Math.floor(cursorX / GRID_SIZE);
var cursorColumnBaseStart:Int = Math.floor(cursorXStart / GRID_SIZE); var cursorColumnBaseStart:Int = Math.floor(cursorXStart / GRID_SIZE);
@ -3799,11 +3858,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
var dragDistanceMs:Float = 0; var dragDistanceMs:Float = 0;
if (dragTargetNote != null && dragTargetNote.noteData != null) if (dragTargetNote != null && dragTargetNote.noteData != null)
{ {
dragDistanceMs = Conductor.getStepTimeInMs(dragTargetNote.noteData.getStepTime() + dragDistanceSteps) - dragTargetNote.noteData.time; dragDistanceMs = Conductor.instance.getStepTimeInMs(dragTargetNote.noteData.getStepTime() + dragDistanceSteps) - dragTargetNote.noteData.time;
} }
else if (dragTargetEvent != null && dragTargetEvent.eventData != null) else if (dragTargetEvent != null && dragTargetEvent.eventData != null)
{ {
dragDistanceMs = Conductor.getStepTimeInMs(dragTargetEvent.eventData.getStepTime() + dragDistanceSteps) - dragTargetEvent.eventData.time; dragDistanceMs = Conductor.instance.getStepTimeInMs(dragTargetEvent.eventData.getStepTime() + dragDistanceSteps) - dragTargetEvent.eventData.time;
} }
var dragDistanceColumns:Int = dragTargetCurrentColumn; var dragDistanceColumns:Int = dragTargetCurrentColumn;
@ -3863,7 +3922,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
{ {
stepTime = dragTargetEvent.eventData.getStepTime(); stepTime = dragTargetEvent.eventData.getStepTime();
} }
var dragDistanceSteps:Float = Conductor.getTimeInSteps(cursorSnappedMs).clamp(0, songLengthInSteps - (1 * noteSnapRatio)) - stepTime; var dragDistanceSteps:Float = Conductor.instance.getTimeInSteps(cursorSnappedMs).clamp(0, songLengthInSteps - (1 * noteSnapRatio)) - stepTime;
var data:Int = 0; var data:Int = 0;
var noteGridPos:Int = 0; var noteGridPos:Int = 0;
if (dragTargetNote != null && dragTargetNote.noteData != null) if (dragTargetNote != null && dragTargetNote.noteData != null)
@ -3895,8 +3954,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
// Handle extending the note as you drag. // Handle extending the note as you drag.
var stepTime:Float = inline currentPlaceNoteData.getStepTime(); var stepTime:Float = inline currentPlaceNoteData.getStepTime();
var dragLengthSteps:Float = Conductor.getTimeInSteps(cursorSnappedMs) - stepTime; var dragLengthSteps:Float = Conductor.instance.getTimeInSteps(cursorSnappedMs) - stepTime;
var dragLengthMs:Float = dragLengthSteps * Conductor.stepLengthMs; var dragLengthMs:Float = dragLengthSteps * Conductor.instance.stepLengthMs;
var dragLengthPixels:Float = dragLengthSteps * GRID_SIZE; var dragLengthPixels:Float = dragLengthSteps * GRID_SIZE;
if (gridGhostNote != null && gridGhostNote.noteData != null && gridGhostHoldNote != null) if (gridGhostNote != null && gridGhostNote.noteData != null && gridGhostHoldNote != null)
@ -4051,7 +4110,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
} }
else else
{ {
// If we clicked and released outside the grid, do nothing. // If we clicked and released outside the grid (or on HaxeUI), do nothing.
} }
} }
@ -4357,7 +4416,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
if (playbarHeadLayout.playbarHead.value != songPosPercent) playbarHeadLayout.playbarHead.value = songPosPercent; if (playbarHeadLayout.playbarHead.value != songPosPercent) playbarHeadLayout.playbarHead.value = songPosPercent;
} }
var songPos:Float = Conductor.songPosition + Conductor.instrumentalOffset; var songPos:Float = Conductor.instance.songPosition + Conductor.instance.instrumentalOffset;
var songPosSeconds:String = Std.string(Math.floor((Math.abs(songPos) / 1000) % 60)).lpad('0', 2); var songPosSeconds:String = Std.string(Math.floor((Math.abs(songPos) / 1000) % 60)).lpad('0', 2);
var songPosMinutes:String = Std.string(Math.floor((Math.abs(songPos) / 1000) / 60)).lpad('0', 2); var songPosMinutes:String = Std.string(Math.floor((Math.abs(songPos) / 1000) / 60)).lpad('0', 2);
if (songPos < 0) songPosMinutes = '-' + songPosMinutes; if (songPos < 0) songPosMinutes = '-' + songPosMinutes;
@ -4373,8 +4432,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
if (playbarSongRemaining.value != songRemainingString) playbarSongRemaining.value = songRemainingString; if (playbarSongRemaining.value != songRemainingString) playbarSongRemaining.value = songRemainingString;
playbarNoteSnap.text = '1/${noteSnapQuant}'; playbarNoteSnap.text = '1/${noteSnapQuant}';
playbarDifficulty.text = "Difficulty: " + selectedDifficulty.toTitleCase(); playbarDifficulty.text = '${selectedDifficulty.toTitleCase()}';
playbarBPM.text = "BPM: " + Conductor.currentTimeChange.bpm; // playbarBPM.text = 'BPM: ${(Conductor.currentTimeChange?.bpm ?? 0.0)}';
} }
function handlePlayhead():Void function handlePlayhead():Void
@ -4413,11 +4472,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
var playheadPos:Float = scrollPositionInPixels + playheadPositionInPixels; var playheadPos:Float = scrollPositionInPixels + playheadPositionInPixels;
var playheadPosFractionalStep:Float = playheadPos / GRID_SIZE / noteSnapRatio; var playheadPosFractionalStep:Float = playheadPos / GRID_SIZE / noteSnapRatio;
var playheadPosStep:Int = Std.int(Math.floor(playheadPosFractionalStep)); var playheadPosStep:Int = Std.int(Math.floor(playheadPosFractionalStep));
var playheadPosSnappedMs:Float = playheadPosStep * Conductor.stepLengthMs * noteSnapRatio; var playheadPosSnappedMs:Float = playheadPosStep * Conductor.instance.stepLengthMs * noteSnapRatio;
// Look for notes within 1 step of the playhead. // Look for notes within 1 step of the playhead.
var notesAtPos:Array<SongNoteData> = SongDataUtils.getNotesInTimeRange(currentSongChartNoteData, playheadPosSnappedMs, var notesAtPos:Array<SongNoteData> = SongDataUtils.getNotesInTimeRange(currentSongChartNoteData, playheadPosSnappedMs,
playheadPosSnappedMs + Conductor.stepLengthMs * noteSnapRatio); playheadPosSnappedMs + Conductor.instance.stepLengthMs * noteSnapRatio);
notesAtPos = SongDataUtils.getNotesWithData(notesAtPos, [column]); notesAtPos = SongDataUtils.getNotesWithData(notesAtPos, [column]);
if (notesAtPos.length == 0) if (notesAtPos.length == 0)
@ -4616,9 +4675,9 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
else else
{ {
var targetMs:Float = scrollPositionInMs + playheadPositionInMs; var targetMs:Float = scrollPositionInMs + playheadPositionInMs;
var targetStep:Float = Conductor.getTimeInSteps(targetMs); var targetStep:Float = Conductor.instance.getTimeInSteps(targetMs);
var targetSnappedStep:Float = Math.floor(targetStep / noteSnapRatio) * noteSnapRatio; var targetSnappedStep:Float = Math.floor(targetStep / noteSnapRatio) * noteSnapRatio;
var targetSnappedMs:Float = Conductor.getStepTimeInMs(targetSnappedStep); var targetSnappedMs:Float = Conductor.instance.getStepTimeInMs(targetSnappedStep);
targetSnappedMs; targetSnappedMs;
} }
performCommand(new PasteItemsCommand(targetMs)); performCommand(new PasteItemsCommand(targetMs));
@ -4731,16 +4790,16 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
{ {
super.handleQuickWatch(); super.handleQuickWatch();
FlxG.watch.addQuick('musicTime', audioInstTrack?.time ?? 0.0); FlxG.watch.addQuick('musicTime', audioInstTrack?.time);
FlxG.watch.addQuick('scrollPosInPixels', scrollPositionInPixels); FlxG.watch.addQuick('scrollPosInPixels', scrollPositionInPixels);
FlxG.watch.addQuick('playheadPosInPixels', playheadPositionInPixels); FlxG.watch.addQuick('playheadPosInPixels', playheadPositionInPixels);
FlxG.watch.addQuick("tapNotesRendered", renderedNotes.members.length); FlxG.watch.addQuick("tapNotesRendered", renderedNotes?.members?.length);
FlxG.watch.addQuick("holdNotesRendered", renderedHoldNotes.members.length); FlxG.watch.addQuick("holdNotesRendered", renderedHoldNotes?.members?.length);
FlxG.watch.addQuick("eventsRendered", renderedEvents.members.length); FlxG.watch.addQuick("eventsRendered", renderedEvents?.members?.length);
FlxG.watch.addQuick("notesSelected", currentNoteSelection.length); FlxG.watch.addQuick("notesSelected", currentNoteSelection?.length);
FlxG.watch.addQuick("eventsSelected", currentEventSelection.length); FlxG.watch.addQuick("eventsSelected", currentEventSelection?.length);
} }
function handlePostUpdate():Void function handlePostUpdate():Void
@ -4758,7 +4817,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
*/ */
function testSongInPlayState(minimal:Bool = false):Void function testSongInPlayState(minimal:Bool = false):Void
{ {
autoSave(); autoSave(true);
stopWelcomeMusic(); stopWelcomeMusic();
@ -4776,6 +4835,9 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
return; return;
} }
LogStyle.WARNING.openConsole = enabledDebuggerPopup;
LogStyle.ERROR.openConsole = enabledDebuggerPopup;
// TODO: Rework asset system so we can remove this. // TODO: Rework asset system so we can remove this.
switch (currentSongStage) switch (currentSongStage)
{ {
@ -4959,7 +5021,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
// Remove any notes past the end of the song. // Remove any notes past the end of the song.
var songCutoffPointSteps:Float = songLengthInSteps - 0.1; var songCutoffPointSteps:Float = songLengthInSteps - 0.1;
var songCutoffPointMs:Float = Conductor.getStepTimeInMs(songCutoffPointSteps); var songCutoffPointMs:Float = Conductor.instance.getStepTimeInMs(songCutoffPointSteps);
currentSongChartNoteData = SongDataUtils.clampSongNoteData(currentSongChartNoteData, 0.0, songCutoffPointMs); currentSongChartNoteData = SongDataUtils.clampSongNoteData(currentSongChartNoteData, 0.0, songCutoffPointMs);
currentSongChartEventData = SongDataUtils.clampSongEventData(currentSongChartEventData, 0.0, songCutoffPointMs); currentSongChartEventData = SongDataUtils.clampSongEventData(currentSongChartEventData, 0.0, songCutoffPointMs);
@ -5061,7 +5123,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
var prevDifficulty = availableDifficulties[availableDifficulties.length - 1]; var prevDifficulty = availableDifficulties[availableDifficulties.length - 1];
selectedDifficulty = prevDifficulty; selectedDifficulty = prevDifficulty;
Conductor.mapTimeChanges(this.currentSongMetadata.timeChanges); Conductor.instance.mapTimeChanges(this.currentSongMetadata.timeChanges);
refreshDifficultyTreeSelection(); refreshDifficultyTreeSelection();
this.refreshToolbox(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT); this.refreshToolbox(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT);
@ -5105,7 +5167,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
} }
} }
this.success('Switch Difficulty', 'Switched difficulty to ${selectedDifficulty.toTitleCase()}'); // Removed this notification because you can see your difficulty in the playbar now.
// this.success('Switch Difficulty', 'Switched difficulty to ${selectedDifficulty.toTitleCase()}');
} }
/** /**
@ -5122,9 +5185,9 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
// Update the songPosition in the audio tracks. // Update the songPosition in the audio tracks.
if (audioInstTrack != null) if (audioInstTrack != null)
{ {
audioInstTrack.time = scrollPositionInMs + playheadPositionInMs - Conductor.instrumentalOffset; audioInstTrack.time = scrollPositionInMs + playheadPositionInMs - Conductor.instance.instrumentalOffset;
// Update the songPosition in the Conductor. // Update the songPosition in the Conductor.
Conductor.update(audioInstTrack.time); Conductor.instance.update(audioInstTrack.time);
if (audioVocalTrackGroup != null) audioVocalTrackGroup.time = audioInstTrack.time; if (audioVocalTrackGroup != null) audioVocalTrackGroup.time = audioInstTrack.time;
} }
@ -5184,6 +5247,20 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
this.persistentUpdate = true; this.persistentUpdate = true;
this.persistentDraw = true; this.persistentDraw = true;
if (displayAutosavePopup)
{
displayAutosavePopup = false;
Toolkit.callLater(() -> {
var absoluteBackupsPath:String = Path.join([Sys.getCwd(), ChartEditorImportExportHandler.BACKUPS_PATH]);
this.infoWithActions('Auto-Save', 'Chart auto-saved to ${absoluteBackupsPath}.', [
{
text: "Take Me There",
callback: openBackupsFolder,
}
]);
});
}
moveSongToScrollPosition(); moveSongToScrollPosition();
fadeInWelcomeMusic(7, 10); fadeInWelcomeMusic(7, 10);
@ -5305,6 +5382,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
// TODO: Only update the notes that have changed. // TODO: Only update the notes that have changed.
notePreview.erase(); notePreview.erase();
notePreview.addNotes(currentSongChartNoteData, Std.int(songLengthInMs)); notePreview.addNotes(currentSongChartNoteData, Std.int(songLengthInMs));
notePreview.addSelectedNotes(currentNoteSelection, Std.int(songLengthInMs));
notePreview.addEvents(currentSongChartEventData, Std.int(songLengthInMs)); notePreview.addEvents(currentSongChartEventData, Std.int(songLengthInMs));
} }
@ -5442,7 +5520,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
trace('ERROR: Instrumental track is null!'); trace('ERROR: Instrumental track is null!');
} }
this.songLengthInMs = (audioInstTrack?.length ?? 1000.0) + Conductor.instrumentalOffset; this.songLengthInMs = (audioInstTrack?.length ?? 1000.0) + Conductor.instance.instrumentalOffset;
// Many things get reset when song length changes. // Many things get reset when song length changes.
healthIconsDirty = true; healthIconsDirty = true;

View file

@ -39,7 +39,7 @@ class ChangeStartingBPMCommand implements ChartEditorCommand
state.notePreviewViewportBoundsDirty = true; state.notePreviewViewportBoundsDirty = true;
state.scrollPositionInPixels = 0; state.scrollPositionInPixels = 0;
Conductor.mapTimeChanges(state.currentSongMetadata.timeChanges); Conductor.instance.mapTimeChanges(state.currentSongMetadata.timeChanges);
} }
public function undo(state:ChartEditorState):Void public function undo(state:ChartEditorState):Void
@ -61,7 +61,7 @@ class ChangeStartingBPMCommand implements ChartEditorCommand
state.notePreviewViewportBoundsDirty = true; state.notePreviewViewportBoundsDirty = true;
state.scrollPositionInPixels = 0; state.scrollPositionInPixels = 0;
Conductor.mapTimeChanges(state.currentSongMetadata.timeChanges); Conductor.instance.mapTimeChanges(state.currentSongMetadata.timeChanges);
} }
public function toString():String public function toString():String

View file

@ -33,7 +33,7 @@ class MoveEventsCommand implements ChartEditorCommand
{ {
// Clone the notes to prevent editing from affecting the history. // Clone the notes to prevent editing from affecting the history.
var resultEvent = event.clone(); var resultEvent = event.clone();
resultEvent.time = (resultEvent.time + offset).clamp(0, Conductor.getStepTimeInMs(state.songLengthInSteps - (1 * state.noteSnapRatio))); resultEvent.time = (resultEvent.time + offset).clamp(0, Conductor.instance.getStepTimeInMs(state.songLengthInSteps - (1 * state.noteSnapRatio)));
movedEvents.push(resultEvent); movedEvents.push(resultEvent);
} }

View file

@ -41,7 +41,7 @@ class MoveItemsCommand implements ChartEditorCommand
{ {
// Clone the notes to prevent editing from affecting the history. // Clone the notes to prevent editing from affecting the history.
var resultNote = note.clone(); var resultNote = note.clone();
resultNote.time = (resultNote.time + offset).clamp(0, Conductor.getStepTimeInMs(state.songLengthInSteps - (1 * state.noteSnapRatio))); resultNote.time = (resultNote.time + offset).clamp(0, Conductor.instance.getStepTimeInMs(state.songLengthInSteps - (1 * state.noteSnapRatio)));
resultNote.data = ChartEditorState.gridColumnToNoteData((ChartEditorState.noteDataToGridColumn(resultNote.data) + columns).clamp(0, resultNote.data = ChartEditorState.gridColumnToNoteData((ChartEditorState.noteDataToGridColumn(resultNote.data) + columns).clamp(0,
ChartEditorState.STRUMLINE_SIZE * 2 - 1)); ChartEditorState.STRUMLINE_SIZE * 2 - 1));
@ -52,7 +52,7 @@ class MoveItemsCommand implements ChartEditorCommand
{ {
// Clone the notes to prevent editing from affecting the history. // Clone the notes to prevent editing from affecting the history.
var resultEvent = event.clone(); var resultEvent = event.clone();
resultEvent.time = (resultEvent.time + offset).clamp(0, Conductor.getStepTimeInMs(state.songLengthInSteps - (1 * state.noteSnapRatio))); resultEvent.time = (resultEvent.time + offset).clamp(0, Conductor.instance.getStepTimeInMs(state.songLengthInSteps - (1 * state.noteSnapRatio)));
movedEvents.push(resultEvent); movedEvents.push(resultEvent);
} }

View file

@ -34,7 +34,7 @@ class MoveNotesCommand implements ChartEditorCommand
{ {
// Clone the notes to prevent editing from affecting the history. // Clone the notes to prevent editing from affecting the history.
var resultNote = note.clone(); var resultNote = note.clone();
resultNote.time = (resultNote.time + offset).clamp(0, Conductor.getStepTimeInMs(state.songLengthInSteps - (1 * state.noteSnapRatio))); resultNote.time = (resultNote.time + offset).clamp(0, Conductor.instance.getStepTimeInMs(state.songLengthInSteps - (1 * state.noteSnapRatio)));
resultNote.data = ChartEditorState.gridColumnToNoteData((ChartEditorState.noteDataToGridColumn(resultNote.data) + columns).clamp(0, resultNote.data = ChartEditorState.gridColumnToNoteData((ChartEditorState.noteDataToGridColumn(resultNote.data) + columns).clamp(0,
ChartEditorState.STRUMLINE_SIZE * 2 - 1)); ChartEditorState.STRUMLINE_SIZE * 2 - 1));

View file

@ -32,9 +32,9 @@ class PasteItemsCommand implements ChartEditorCommand
return; return;
} }
var stepEndOfSong:Float = Conductor.getTimeInSteps(state.songLengthInMs); var stepEndOfSong:Float = Conductor.instance.getTimeInSteps(state.songLengthInMs);
var stepCutoff:Float = stepEndOfSong - 1.0; var stepCutoff:Float = stepEndOfSong - 1.0;
var msCutoff:Float = Conductor.getStepTimeInMs(stepCutoff); var msCutoff:Float = Conductor.instance.getStepTimeInMs(stepCutoff);
addedNotes = SongDataUtils.offsetSongNoteData(currentClipboard.notes, Std.int(targetTimestamp)); addedNotes = SongDataUtils.offsetSongNoteData(currentClipboard.notes, Std.int(targetTimestamp));
addedNotes = SongDataUtils.clampSongNoteData(addedNotes, 0.0, msCutoff); addedNotes = SongDataUtils.clampSongNoteData(addedNotes, 0.0, msCutoff);

View file

@ -80,11 +80,24 @@ class ChartEditorNotePreview extends FlxSprite
* @param notes The data for the notes. * @param notes The data for the notes.
* @param songLengthInMs The total length of the song in milliseconds. * @param songLengthInMs The total length of the song in milliseconds.
*/ */
public function addNotes(notes:Array<SongNoteData>, songLengthInMs:Int, ?isSelection:Bool = false):Void public function addNotes(notes:Array<SongNoteData>, songLengthInMs:Int):Void
{ {
for (note in notes) for (note in notes)
{ {
addNote(note, songLengthInMs, isSelection); addNote(note, songLengthInMs, false);
}
}
/**
* Add an array of selected notes to the preview.
* @param notes The data for the notes.
* @param songLengthInMs The total length of the song in milliseconds.
*/
public function addSelectedNotes(notes:Array<SongNoteData>, songLengthInMs:Int):Void
{
for (note in notes)
{
addNote(note, songLengthInMs, true);
} }
} }

View file

@ -5,14 +5,14 @@ import funkin.ui.debug.charting.dialogs.ChartEditorBaseDialog.DialogParams;
@:build(haxe.ui.ComponentBuilder.build("assets/exclude/data/ui/chart-editor/dialogs/about.xml")) @:build(haxe.ui.ComponentBuilder.build("assets/exclude/data/ui/chart-editor/dialogs/about.xml"))
class ChartEditorAboutDialog extends ChartEditorBaseDialog class ChartEditorAboutDialog extends ChartEditorBaseDialog
{ {
public function new(state2:ChartEditorState, params2:DialogParams) public function new(chartEditorState2:ChartEditorState, params2:DialogParams)
{ {
super(state2, params2); super(chartEditorState2, params2);
} }
public static function build(state:ChartEditorState, ?closable:Bool, ?modal:Bool):ChartEditorAboutDialog public static function build(chartEditorState:ChartEditorState, ?closable:Bool, ?modal:Bool):ChartEditorAboutDialog
{ {
var dialog = new ChartEditorAboutDialog(state, var dialog = new ChartEditorAboutDialog(chartEditorState,
{ {
closable: closable ?? true, closable: closable ?? true,
modal: modal ?? true modal: modal ?? true

View file

@ -11,16 +11,16 @@ import haxe.ui.core.Component;
@:access(funkin.ui.debug.charting.ChartEditorState) @:access(funkin.ui.debug.charting.ChartEditorState)
class ChartEditorBaseDialog extends Dialog class ChartEditorBaseDialog extends Dialog
{ {
var state:ChartEditorState; var chartEditorState:ChartEditorState;
var params:DialogParams; var params:DialogParams;
var locked:Bool = false; var locked:Bool = false;
public function new(state:ChartEditorState, params:DialogParams) public function new(chartEditorState:ChartEditorState, params:DialogParams)
{ {
super(); super();
this.state = state; this.chartEditorState = chartEditorState;
this.params = params; this.params = params;
this.destroyOnClose = true; this.destroyOnClose = true;
@ -47,7 +47,7 @@ class ChartEditorBaseDialog extends Dialog
*/ */
public function onClose(event:DialogEvent):Void public function onClose(event:DialogEvent):Void
{ {
state.isHaxeUIDialogOpen = false; chartEditorState.isHaxeUIDialogOpen = false;
} }
/** /**

View file

@ -11,13 +11,13 @@ import haxe.ui.containers.menus.Menu;
@:access(funkin.ui.debug.charting.ChartEditorState) @:access(funkin.ui.debug.charting.ChartEditorState)
class ChartEditorBaseMenu extends Menu class ChartEditorBaseMenu extends Menu
{ {
var state:ChartEditorState; var chartEditorState:ChartEditorState;
public function new(state:ChartEditorState) public function new(chartEditorState:ChartEditorState)
{ {
super(); super();
this.state = state; this.chartEditorState = chartEditorState;
// this.destroyOnClose = true; // this.destroyOnClose = true;
} }

View file

@ -24,9 +24,9 @@ class ChartEditorCharacterIconSelectorMenu extends ChartEditorBaseMenu
public var charSelectScroll:ScrollView; public var charSelectScroll:ScrollView;
public var charIconName:Label; public var charIconName:Label;
public function new(state2:ChartEditorState, charType:CharacterType, lockPosition:Bool = false) public function new(chartEditorState2:ChartEditorState, charType:CharacterType, lockPosition:Bool = false)
{ {
super(state2); super(chartEditorState2);
initialize(charType, lockPosition); initialize(charType, lockPosition);
this.alpha = 0; this.alpha = 0;
@ -38,17 +38,17 @@ class ChartEditorCharacterIconSelectorMenu extends ChartEditorBaseMenu
{ {
var currentCharId:String = switch (charType) var currentCharId:String = switch (charType)
{ {
case BF: state.currentSongMetadata.playData.characters.player; case BF: chartEditorState.currentSongMetadata.playData.characters.player;
case GF: state.currentSongMetadata.playData.characters.girlfriend; case GF: chartEditorState.currentSongMetadata.playData.characters.girlfriend;
case DAD: state.currentSongMetadata.playData.characters.opponent; case DAD: chartEditorState.currentSongMetadata.playData.characters.opponent;
default: throw 'Invalid charType: ' + charType; default: throw 'Invalid charType: ' + charType;
}; };
// Position this menu. // Position this menu.
var targetHealthIcon:Null<HealthIcon> = switch (charType) var targetHealthIcon:Null<HealthIcon> = switch (charType)
{ {
case BF: state.healthIconBF; case BF: chartEditorState.healthIconBF;
case DAD: state.healthIconDad; case DAD: chartEditorState.healthIconDad;
default: null; default: null;
}; };
@ -101,14 +101,14 @@ class ChartEditorCharacterIconSelectorMenu extends ChartEditorBaseMenu
charButton.onClick = _ -> { charButton.onClick = _ -> {
switch (charType) switch (charType)
{ {
case BF: state.currentSongMetadata.playData.characters.player = charId; case BF: chartEditorState.currentSongMetadata.playData.characters.player = charId;
case GF: state.currentSongMetadata.playData.characters.girlfriend = charId; case GF: chartEditorState.currentSongMetadata.playData.characters.girlfriend = charId;
case DAD: state.currentSongMetadata.playData.characters.opponent = charId; case DAD: chartEditorState.currentSongMetadata.playData.characters.opponent = charId;
default: throw 'Invalid charType: ' + charType; default: throw 'Invalid charType: ' + charType;
}; };
state.healthIconsDirty = true; chartEditorState.healthIconsDirty = true;
state.refreshToolbox(ChartEditorState.CHART_EDITOR_TOOLBOX_METADATA_LAYOUT); chartEditorState.refreshToolbox(ChartEditorState.CHART_EDITOR_TOOLBOX_METADATA_LAYOUT);
}; };
charButton.onMouseOver = _ -> { charButton.onMouseOver = _ -> {
@ -123,9 +123,9 @@ class ChartEditorCharacterIconSelectorMenu extends ChartEditorBaseMenu
charIconName.text = defaultText; charIconName.text = defaultText;
} }
public static function build(state2:ChartEditorState, charType:CharacterType, lockPosition:Bool = false):ChartEditorCharacterIconSelectorMenu public static function build(chartEditorState:ChartEditorState, charType:CharacterType, lockPosition:Bool = false):ChartEditorCharacterIconSelectorMenu
{ {
var menu = new ChartEditorCharacterIconSelectorMenu(state2, charType, lockPosition); var menu = new ChartEditorCharacterIconSelectorMenu(chartEditorState, charType, lockPosition);
Screen.instance.addComponent(menu); Screen.instance.addComponent(menu);

View file

@ -64,12 +64,12 @@ class ChartEditorUploadChartDialog extends ChartEditorBaseDialog
if (event.button != DialogButton.APPLY && !this.closable) if (event.button != DialogButton.APPLY && !this.closable)
{ {
// User cancelled the wizard! Back to the welcome dialog. // User cancelled the wizard! Back to the welcome dialog.
state.openWelcomeDialog(this.closable); chartEditorState.openWelcomeDialog(this.closable);
} }
for (dropTarget in dropHandlers) for (dropTarget in dropHandlers)
{ {
state.removeDropHandler(dropTarget); chartEditorState.removeDropHandler(dropTarget);
} }
} }
@ -111,20 +111,21 @@ class ChartEditorUploadChartDialog extends ChartEditorBaseDialog
try try
{ {
var result:Null<Array<String>> = ChartEditorImportExportHandler.loadFromFNFCPath(state, path.toString()); var result:Null<Array<String>> = ChartEditorImportExportHandler.loadFromFNFCPath(chartEditorState, path.toString());
if (result != null) if (result != null)
{ {
state.success('Loaded Chart', result.length == 0 ? 'Loaded chart (${path.toString()})' : 'Loaded chart (${path.toString()})\n${result.join("\n")}'); chartEditorState.success('Loaded Chart',
result.length == 0 ? 'Loaded chart (${path.toString()})' : 'Loaded chart (${path.toString()})\n${result.join("\n")}');
this.hideDialog(DialogButton.APPLY); this.hideDialog(DialogButton.APPLY);
} }
else else
{ {
state.failure('Failed to Load Chart', 'Failed to load chart (${path.toString()})'); chartEditorState.failure('Failed to Load Chart', 'Failed to load chart (${path.toString()})');
} }
} }
catch (err) catch (err)
{ {
state.failure('Failed to Load Chart', 'Failed to load chart (${path.toString()}): ${err}'); chartEditorState.failure('Failed to Load Chart', 'Failed to load chart (${path.toString()}): ${err}');
} }
} }
@ -139,19 +140,19 @@ class ChartEditorUploadChartDialog extends ChartEditorBaseDialog
{ {
try try
{ {
var result:Null<Array<String>> = ChartEditorImportExportHandler.loadFromFNFC(state, selectedFile.bytes); var result:Null<Array<String>> = ChartEditorImportExportHandler.loadFromFNFC(chartEditorState, selectedFile.bytes);
if (result != null) if (result != null)
{ {
state.success('Loaded Chart', chartEditorState.success('Loaded Chart',
result.length == 0 ? 'Loaded chart (${selectedFile.name})' : 'Loaded chart (${selectedFile.name})\n${result.join("\n")}'); result.length == 0 ? 'Loaded chart (${selectedFile.name})' : 'Loaded chart (${selectedFile.name})\n${result.join("\n")}');
if (selectedFile.fullPath != null) state.currentWorkingFilePath = selectedFile.fullPath; if (selectedFile.fullPath != null) chartEditorState.currentWorkingFilePath = selectedFile.fullPath;
this.hideDialog(DialogButton.APPLY); this.hideDialog(DialogButton.APPLY);
} }
} }
catch (err) catch (err)
{ {
state.failure('Failed to Load Chart', 'Failed to load chart (${selectedFile.name}): ${err}'); chartEditorState.failure('Failed to Load Chart', 'Failed to load chart (${selectedFile.name}): ${err}');
} }
} }
} }

View file

@ -41,26 +41,26 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
// Add items to the Recent Charts list // Add items to the Recent Charts list
#if sys #if sys
for (chartPath in state.previousWorkingFilePaths) for (chartPath in chartEditorState.previousWorkingFilePaths)
{ {
if (chartPath == null) continue; if (chartPath == null) continue;
this.addRecentFilePath(state, chartPath); this.addRecentFilePath(chartEditorState, chartPath);
} }
#else #else
this.addHTML5RecentFileMessage(); this.addHTML5RecentFileMessage();
#end #end
// Add items to the Load From Template list // Add items to the Load From Template list
this.buildTemplateSongList(state); this.buildTemplateSongList(chartEditorState);
} }
/** /**
* @param state The current state of the chart editor. * @param state The current state of the chart editor.
* @return A newly created `ChartEditorWelcomeDialog`. * @return A newly created `ChartEditorWelcomeDialog`.
*/ */
public static function build(state:ChartEditorState, ?closable:Bool, ?modal:Bool):ChartEditorWelcomeDialog public static function build(chartEditorState:ChartEditorState, ?closable:Bool, ?modal:Bool):ChartEditorWelcomeDialog
{ {
var dialog = new ChartEditorWelcomeDialog(state, var dialog = new ChartEditorWelcomeDialog(chartEditorState,
{ {
closable: closable ?? false, closable: closable ?? false,
modal: modal ?? true modal: modal ?? true
@ -102,12 +102,12 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
var result:Null<Array<String>> = ChartEditorImportExportHandler.loadFromFNFCPath(state, chartPath); var result:Null<Array<String>> = ChartEditorImportExportHandler.loadFromFNFCPath(state, chartPath);
if (result != null) if (result != null)
{ {
state.success('Loaded Chart', chartEditorState.success('Loaded Chart',
result.length == 0 ? 'Loaded chart (${chartPath.toString()})' : 'Loaded chart (${chartPath.toString()})\n${result.join("\n")}'); result.length == 0 ? 'Loaded chart (${chartPath.toString()})' : 'Loaded chart (${chartPath.toString()})\n${result.join("\n")}');
} }
else else
{ {
state.error('Failed to Load Chart', 'Failed to load chart (${chartPath.toString()})'); chartEditorState.error('Failed to Load Chart', 'Failed to load chart (${chartPath.toString()})');
} }
} }
@ -157,7 +157,7 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
this.hideDialog(DialogButton.CANCEL); this.hideDialog(DialogButton.CANCEL);
// Load song from template // Load song from template
state.loadSongAsTemplate(targetSongId); chartEditorState.loadSongAsTemplate(targetSongId);
}); });
} }
} }
@ -184,7 +184,7 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
this.hideDialog(DialogButton.CANCEL); this.hideDialog(DialogButton.CANCEL);
// Open the "Open Chart" dialog // Open the "Open Chart" dialog
state.openBrowseFNFC(false); chartEditorState.openBrowseFNFC(false);
} }
/** /**
@ -199,7 +199,7 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
// //
// Create Song Wizard // Create Song Wizard
// //
state.openCreateSongWizardBasicOnly(false); chartEditorState.openCreateSongWizardBasicOnly(false);
} }
/** /**
@ -214,7 +214,7 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
// //
// Create Song Wizard // Create Song Wizard
// //
state.openCreateSongWizardErectOnly(false); chartEditorState.openCreateSongWizardErectOnly(false);
} }
/** /**
@ -229,7 +229,7 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
// //
// Create Song Wizard // Create Song Wizard
// //
state.openCreateSongWizardBasicErect(false); chartEditorState.openCreateSongWizardBasicErect(false);
} }
/** /**
@ -242,6 +242,6 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
this.hideDialog(DialogButton.CANCEL); this.hideDialog(DialogButton.CANCEL);
// Open the "Import Chart" dialog // Open the "Import Chart" dialog
state.openImportChartWizard('legacy', false); chartEditorState.openImportChartWizard('legacy', false);
} }
} }

View file

@ -28,11 +28,11 @@ class ChartEditorAudioHandler
* @param instId The instrumental this vocal track will be for. * @param instId The instrumental this vocal track will be for.
* @return Success or failure. * @return Success or failure.
*/ */
public static function loadVocalsFromPath(state:ChartEditorState, path:Path, charId:String, instId:String = ''):Bool public static function loadVocalsFromPath(state:ChartEditorState, path:Path, charId:String, instId:String = '', wipeFirst:Bool = false):Bool
{ {
#if sys #if sys
var fileBytes:Bytes = sys.io.File.getBytes(path.toString()); var fileBytes:Bytes = sys.io.File.getBytes(path.toString());
return loadVocalsFromBytes(state, fileBytes, charId, instId); return loadVocalsFromBytes(state, fileBytes, charId, instId, wipeFirst);
#else #else
trace("[WARN] This platform can't load audio from a file path, you'll need to fetch the bytes some other way."); trace("[WARN] This platform can't load audio from a file path, you'll need to fetch the bytes some other way.");
return false; return false;
@ -47,12 +47,12 @@ class ChartEditorAudioHandler
* @param instId The instrumental this vocal track will be for. * @param instId The instrumental this vocal track will be for.
* @return Success or failure. * @return Success or failure.
*/ */
public static function loadVocalsFromAsset(state:ChartEditorState, path:String, charId:String, instId:String = ''):Bool public static function loadVocalsFromAsset(state:ChartEditorState, path:String, charId:String, instId:String = '', wipeFirst:Bool = false):Bool
{ {
var trackData:Null<Bytes> = Assets.getBytes(path); var trackData:Null<Bytes> = Assets.getBytes(path);
if (trackData != null) if (trackData != null)
{ {
return loadVocalsFromBytes(state, trackData, charId, instId); return loadVocalsFromBytes(state, trackData, charId, instId, wipeFirst);
} }
return false; return false;
} }
@ -63,10 +63,12 @@ class ChartEditorAudioHandler
* @param bytes The audio byte data. * @param bytes The audio byte data.
* @param charId The character this vocal track will be for. * @param charId The character this vocal track will be for.
* @param instId The instrumental this vocal track will be for. * @param instId The instrumental this vocal track will be for.
* @param wipeFirst Whether to wipe the existing vocal data before loading.
*/ */
public static function loadVocalsFromBytes(state:ChartEditorState, bytes:Bytes, charId:String, instId:String = ''):Bool public static function loadVocalsFromBytes(state:ChartEditorState, bytes:Bytes, charId:String, instId:String = '', wipeFirst:Bool = false):Bool
{ {
var trackId:String = '${charId}${instId == '' ? '' : '-${instId}'}'; var trackId:String = '${charId}${instId == '' ? '' : '-${instId}'}';
if (wipeFirst) wipeVocalData(state);
state.audioVocalTrackData.set(trackId, bytes); state.audioVocalTrackData.set(trackId, bytes);
return true; return true;
} }
@ -78,11 +80,11 @@ class ChartEditorAudioHandler
* @param instId The instrumental this vocal track will be for. * @param instId The instrumental this vocal track will be for.
* @return Success or failure. * @return Success or failure.
*/ */
public static function loadInstFromPath(state:ChartEditorState, path:Path, instId:String = ''):Bool public static function loadInstFromPath(state:ChartEditorState, path:Path, instId:String = '', wipeFirst:Bool = false):Bool
{ {
#if sys #if sys
var fileBytes:Bytes = sys.io.File.getBytes(path.toString()); var fileBytes:Bytes = sys.io.File.getBytes(path.toString());
return loadInstFromBytes(state, fileBytes, instId); return loadInstFromBytes(state, fileBytes, instId, wipeFirst);
#else #else
trace("[WARN] This platform can't load audio from a file path, you'll need to fetch the bytes some other way."); trace("[WARN] This platform can't load audio from a file path, you'll need to fetch the bytes some other way.");
return false; return false;
@ -96,12 +98,12 @@ class ChartEditorAudioHandler
* @param instId The instrumental this vocal track will be for. * @param instId The instrumental this vocal track will be for.
* @return Success or failure. * @return Success or failure.
*/ */
public static function loadInstFromAsset(state:ChartEditorState, path:String, instId:String = ''):Bool public static function loadInstFromAsset(state:ChartEditorState, path:String, instId:String = '', wipeFirst:Bool = false):Bool
{ {
var trackData:Null<Bytes> = Assets.getBytes(path); var trackData:Null<Bytes> = Assets.getBytes(path);
if (trackData != null) if (trackData != null)
{ {
return loadInstFromBytes(state, trackData, instId); return loadInstFromBytes(state, trackData, instId, wipeFirst);
} }
return false; return false;
} }
@ -113,9 +115,10 @@ class ChartEditorAudioHandler
* @param charId The character this vocal track will be for. * @param charId The character this vocal track will be for.
* @param instId The instrumental this vocal track will be for. * @param instId The instrumental this vocal track will be for.
*/ */
public static function loadInstFromBytes(state:ChartEditorState, bytes:Bytes, instId:String = ''):Bool public static function loadInstFromBytes(state:ChartEditorState, bytes:Bytes, instId:String = '', wipeFirst:Bool = false):Bool
{ {
if (instId == '') instId = 'default'; if (instId == '') instId = 'default';
if (wipeFirst) wipeInstrumentalData(state);
state.audioInstTrackData.set(instId, bytes); state.audioInstTrackData.set(instId, bytes);
return true; return true;
} }
@ -127,9 +130,9 @@ class ChartEditorAudioHandler
stopExistingVocals(state); stopExistingVocals(state);
result = playVocals(state, BF, playerId, instId); result = playVocals(state, BF, playerId, instId);
if (!result) return false; // if (!result) return false;
result = playVocals(state, DAD, opponentId, instId); result = playVocals(state, DAD, opponentId, instId);
if (!result) return false; // if (!result) return false;
return true; return true;
} }
@ -182,7 +185,7 @@ class ChartEditorAudioHandler
state.audioVocalTrackGroup.addPlayerVoice(vocalTrack); state.audioVocalTrackGroup.addPlayerVoice(vocalTrack);
state.audioVisGroup.addPlayerVis(vocalTrack); state.audioVisGroup.addPlayerVis(vocalTrack);
state.audioVisGroup.playerVis.x = 885; state.audioVisGroup.playerVis.x = 885;
state.audioVisGroup.playerVis.realtimeVisLenght = Conductor.getStepTimeInMs(16) * 0.00195; state.audioVisGroup.playerVis.realtimeVisLenght = Conductor.instance.getStepTimeInMs(16) * 0.00195;
state.audioVisGroup.playerVis.daHeight = (ChartEditorState.GRID_SIZE) * 16; state.audioVisGroup.playerVis.daHeight = (ChartEditorState.GRID_SIZE) * 16;
state.audioVisGroup.playerVis.detail = 1; state.audioVisGroup.playerVis.detail = 1;
@ -193,7 +196,7 @@ class ChartEditorAudioHandler
state.audioVisGroup.addOpponentVis(vocalTrack); state.audioVisGroup.addOpponentVis(vocalTrack);
state.audioVisGroup.opponentVis.x = 435; state.audioVisGroup.opponentVis.x = 435;
state.audioVisGroup.opponentVis.realtimeVisLenght = Conductor.getStepTimeInMs(16) * 0.00195; state.audioVisGroup.opponentVis.realtimeVisLenght = Conductor.instance.getStepTimeInMs(16) * 0.00195;
state.audioVisGroup.opponentVis.daHeight = (ChartEditorState.GRID_SIZE) * 16; state.audioVisGroup.opponentVis.daHeight = (ChartEditorState.GRID_SIZE) * 16;
state.audioVisGroup.opponentVis.detail = 1; state.audioVisGroup.opponentVis.detail = 1;

View file

@ -684,8 +684,11 @@ class ChartEditorDialogHandler
state.songMetadata.set(targetVariation, newSongMetadata); state.songMetadata.set(targetVariation, newSongMetadata);
Conductor.instrumentalOffset = state.currentInstrumentalOffset; // Loads from the metadata. Conductor.instance.instrumentalOffset = state.currentInstrumentalOffset; // Loads from the metadata.
Conductor.mapTimeChanges(state.currentSongMetadata.timeChanges); Conductor.instance.mapTimeChanges(state.currentSongMetadata.timeChanges);
state.selectedVariation = Constants.DEFAULT_VARIATION;
state.selectedDifficulty = state.availableDifficulties[0];
state.difficultySelectDirty = true; state.difficultySelectDirty = true;
@ -755,14 +758,9 @@ class ChartEditorDialogHandler
trace('Selected file: $pathStr'); trace('Selected file: $pathStr');
var path:Path = new Path(pathStr); var path:Path = new Path(pathStr);
if (!hasClearedVocals) if (state.loadVocalsFromPath(path, charKey, instId, !hasClearedVocals))
{ {
hasClearedVocals = true; hasClearedVocals = true;
state.stopExistingVocals();
}
if (state.loadVocalsFromPath(path, charKey, instId))
{
// Tell the user the load was successful. // Tell the user the load was successful.
state.success('Loaded Vocals', 'Loaded vocals for $charName (${path.file}.${path.ext}), variation ${state.selectedVariation}'); state.success('Loaded Vocals', 'Loaded vocals for $charName (${path.file}.${path.ext}), variation ${state.selectedVariation}');
#if FILE_DROP_SUPPORTED #if FILE_DROP_SUPPORTED
@ -796,13 +794,10 @@ class ChartEditorDialogHandler
if (selectedFile != null && selectedFile.bytes != null) if (selectedFile != null && selectedFile.bytes != null)
{ {
trace('Selected file: ' + selectedFile.name); trace('Selected file: ' + selectedFile.name);
if (!hasClearedVocals)
if (state.loadVocalsFromBytes(selectedFile.bytes, charKey, instId, !hasClearedVocals))
{ {
hasClearedVocals = true; hasClearedVocals = true;
state.stopExistingVocals();
}
if (state.loadVocalsFromBytes(selectedFile.bytes, charKey, instId))
{
// Tell the user the load was successful. // Tell the user the load was successful.
state.success('Loaded Vocals', 'Loaded vocals for $charName (${selectedFile.name}), variation ${state.selectedVariation}'); state.success('Loaded Vocals', 'Loaded vocals for $charName (${selectedFile.name}), variation ${state.selectedVariation}');

View file

@ -115,9 +115,9 @@ class ChartEditorImportExportHandler
state.songMetadata = newSongMetadata; state.songMetadata = newSongMetadata;
state.songChartData = newSongChartData; state.songChartData = newSongChartData;
Conductor.forceBPM(null); // Disable the forced BPM. Conductor.instance.forceBPM(null); // Disable the forced BPM.
Conductor.instrumentalOffset = state.currentInstrumentalOffset; // Loads from the metadata. Conductor.instance.instrumentalOffset = state.currentInstrumentalOffset; // Loads from the metadata.
Conductor.mapTimeChanges(state.currentSongMetadata.timeChanges); Conductor.instance.mapTimeChanges(state.currentSongMetadata.timeChanges);
state.notePreviewDirty = true; state.notePreviewDirty = true;
state.notePreviewViewportBoundsDirty = true; state.notePreviewViewportBoundsDirty = true;
@ -316,6 +316,8 @@ class ChartEditorImportExportHandler
public static function getLatestBackupPath():Null<String> public static function getLatestBackupPath():Null<String>
{ {
#if sys #if sys
if (!sys.FileSystem.exists(BACKUPS_PATH)) sys.FileSystem.createDirectory(BACKUPS_PATH);
var entries:Array<String> = sys.FileSystem.readDirectory(BACKUPS_PATH); var entries:Array<String> = sys.FileSystem.readDirectory(BACKUPS_PATH);
entries.sort(SortUtil.alphabetically); entries.sort(SortUtil.alphabetically);
@ -414,16 +416,34 @@ class ChartEditorImportExportHandler
]); ]);
// We have to force write because the program will die before the save dialog is closed. // We have to force write because the program will die before the save dialog is closed.
trace('Force exporting to $targetPath...'); trace('Force exporting to $targetPath...');
FileUtil.saveFilesAsZIPToPath(zipEntries, targetPath, targetMode); try
if (onSaveCb != null) onSaveCb(targetPath); {
FileUtil.saveFilesAsZIPToPath(zipEntries, targetPath, targetMode);
// On success.
if (onSaveCb != null) onSaveCb(targetPath);
}
catch (e)
{
// On failure.
if (onCancelCb != null) onCancelCb();
}
} }
else else
{ {
// Force write since we know what file the user wants to overwrite. // Force write since we know what file the user wants to overwrite.
trace('Force exporting to $targetPath...'); trace('Force exporting to $targetPath...');
FileUtil.saveFilesAsZIPToPath(zipEntries, targetPath, targetMode); try
state.saveDataDirty = false; {
if (onSaveCb != null) onSaveCb(targetPath); // On success.
FileUtil.saveFilesAsZIPToPath(zipEntries, targetPath, targetMode);
state.saveDataDirty = false;
if (onSaveCb != null) onSaveCb(targetPath);
}
catch (e)
{
// On failure.
if (onCancelCb != null) onCancelCb();
}
} }
} }
else else

View file

@ -125,7 +125,7 @@ class ChartEditorThemeHandler
// 2 * (Strumline Size) + 1 grid squares wide, by (4 * quarter notes per measure) grid squares tall. // 2 * (Strumline Size) + 1 grid squares wide, by (4 * quarter notes per measure) grid squares tall.
// This gets reused to fill the screen. // This gets reused to fill the screen.
var gridWidth:Int = Std.int(ChartEditorState.GRID_SIZE * TOTAL_COLUMN_COUNT); var gridWidth:Int = Std.int(ChartEditorState.GRID_SIZE * TOTAL_COLUMN_COUNT);
var gridHeight:Int = Std.int(ChartEditorState.GRID_SIZE * Conductor.stepsPerMeasure); var gridHeight:Int = Std.int(ChartEditorState.GRID_SIZE * Conductor.instance.stepsPerMeasure);
state.gridBitmap = FlxGridOverlay.createGrid(ChartEditorState.GRID_SIZE, ChartEditorState.GRID_SIZE, gridWidth, gridHeight, true, gridColor1, gridColor2); state.gridBitmap = FlxGridOverlay.createGrid(ChartEditorState.GRID_SIZE, ChartEditorState.GRID_SIZE, gridWidth, gridHeight, true, gridColor1, gridColor2);
// Selection borders // Selection borders
@ -142,7 +142,7 @@ class ChartEditorThemeHandler
selectionBorderColor); selectionBorderColor);
// Selection borders horizontally along the middle. // Selection borders horizontally along the middle.
for (i in 1...(Conductor.stepsPerMeasure)) for (i in 1...(Conductor.instance.stepsPerMeasure))
{ {
state.gridBitmap.fillRect(new Rectangle(0, (ChartEditorState.GRID_SIZE * i) - (ChartEditorState.GRID_SELECTION_BORDER_WIDTH / 2), state.gridBitmap.fillRect(new Rectangle(0, (ChartEditorState.GRID_SIZE * i) - (ChartEditorState.GRID_SELECTION_BORDER_WIDTH / 2),
state.gridBitmap.width, ChartEditorState.GRID_SELECTION_BORDER_WIDTH), state.gridBitmap.width, ChartEditorState.GRID_SELECTION_BORDER_WIDTH),
@ -197,9 +197,9 @@ class ChartEditorThemeHandler
}; };
// Selection borders horizontally in the middle. // Selection borders horizontally in the middle.
for (i in 1...(Conductor.stepsPerMeasure)) for (i in 1...(Conductor.instance.stepsPerMeasure))
{ {
if ((i % Conductor.beatsPerMeasure) == 0) if ((i % Conductor.instance.beatsPerMeasure) == 0)
{ {
state.gridBitmap.fillRect(new Rectangle(0, (ChartEditorState.GRID_SIZE * i) - (GRID_BEAT_DIVIDER_WIDTH / 2), state.gridBitmap.width, state.gridBitmap.fillRect(new Rectangle(0, (ChartEditorState.GRID_SIZE * i) - (GRID_BEAT_DIVIDER_WIDTH / 2), state.gridBitmap.width,
GRID_BEAT_DIVIDER_WIDTH), GRID_BEAT_DIVIDER_WIDTH),

View file

@ -488,6 +488,16 @@ class ChartEditorToolboxHandler
state.playtestStartTime = checkboxStartTime.selected; state.playtestStartTime = checkboxStartTime.selected;
}; };
var checkboxDebugger:Null<CheckBox> = toolbox.findComponent('playtestDebuggerCheckbox', CheckBox);
if (checkboxDebugger == null) throw 'ChartEditorToolboxHandler.buildToolboxPlaytestPropertiesLayout() - Could not find playtestDebuggerCheckbox component.';
state.enabledDebuggerPopup = checkboxDebugger.selected;
checkboxDebugger.onClick = _ -> {
state.enabledDebuggerPopup = checkboxDebugger.selected;
};
return toolbox; return toolbox;
} }

View file

@ -12,13 +12,13 @@ import haxe.ui.core.Component;
@:access(funkin.ui.debug.charting.ChartEditorState) @:access(funkin.ui.debug.charting.ChartEditorState)
class ChartEditorBaseToolbox extends CollapsibleDialog class ChartEditorBaseToolbox extends CollapsibleDialog
{ {
var state:ChartEditorState; var chartEditorState:ChartEditorState;
private function new(state:ChartEditorState) private function new(chartEditorState:ChartEditorState)
{ {
super(); super();
this.state = state; this.chartEditorState = chartEditorState;
} }
/** /**

View file

@ -40,9 +40,9 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox
var frameVariation:Frame; var frameVariation:Frame;
var frameDifficulty:Frame; var frameDifficulty:Frame;
public function new(state2:ChartEditorState) public function new(chartEditorState2:ChartEditorState)
{ {
super(state2); super(chartEditorState2);
initialize(); initialize();
@ -51,7 +51,7 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox
function onClose(event:UIEvent) function onClose(event:UIEvent)
{ {
state.menubarItemToggleToolboxMetadata.selected = false; chartEditorState.menubarItemToggleToolboxMetadata.selected = false;
} }
function initialize():Void function initialize():Void
@ -67,11 +67,11 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox
if (valid) if (valid)
{ {
inputSongName.removeClass('invalid-value'); inputSongName.removeClass('invalid-value');
state.currentSongMetadata.songName = event.target.text; chartEditorState.currentSongMetadata.songName = event.target.text;
} }
else else
{ {
state.currentSongMetadata.songName = ''; chartEditorState.currentSongMetadata.songName = '';
} }
}; };
@ -81,11 +81,11 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox
if (valid) if (valid)
{ {
inputSongArtist.removeClass('invalid-value'); inputSongArtist.removeClass('invalid-value');
state.currentSongMetadata.artist = event.target.text; chartEditorState.currentSongMetadata.artist = event.target.text;
} }
else else
{ {
state.currentSongMetadata.artist = ''; chartEditorState.currentSongMetadata.artist = '';
} }
}; };
@ -94,41 +94,41 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox
if (valid) if (valid)
{ {
state.currentSongMetadata.playData.stage = event.data.id; chartEditorState.currentSongMetadata.playData.stage = event.data.id;
} }
}; };
var startingValueStage = ChartEditorDropdowns.populateDropdownWithStages(inputStage, state.currentSongMetadata.playData.stage); var startingValueStage = ChartEditorDropdowns.populateDropdownWithStages(inputStage, chartEditorState.currentSongMetadata.playData.stage);
inputStage.value = startingValueStage; inputStage.value = startingValueStage;
inputNoteStyle.onChange = function(event:UIEvent) { inputNoteStyle.onChange = function(event:UIEvent) {
if (event.data?.id == null) return; if (event.data?.id == null) return;
state.currentSongNoteStyle = event.data.id; chartEditorState.currentSongNoteStyle = event.data.id;
}; };
inputBPM.onChange = function(event:UIEvent) { inputBPM.onChange = function(event:UIEvent) {
if (event.value == null || event.value <= 0) return; if (event.value == null || event.value <= 0) return;
// Use a command so we can undo/redo this action. // Use a command so we can undo/redo this action.
var startingBPM = state.currentSongMetadata.timeChanges[0].bpm; var startingBPM = chartEditorState.currentSongMetadata.timeChanges[0].bpm;
if (event.value != startingBPM) if (event.value != startingBPM)
{ {
state.performCommand(new ChangeStartingBPMCommand(event.value)); chartEditorState.performCommand(new ChangeStartingBPMCommand(event.value));
} }
}; };
inputOffsetInst.onChange = function(event:UIEvent) { inputOffsetInst.onChange = function(event:UIEvent) {
if (event.value == null) return; if (event.value == null) return;
state.currentInstrumentalOffset = event.value; chartEditorState.currentInstrumentalOffset = event.value;
Conductor.instrumentalOffset = event.value; Conductor.instance.instrumentalOffset = event.value;
// Update song length. // Update song length.
state.songLengthInMs = (state.audioInstTrack?.length ?? 1000.0) + Conductor.instrumentalOffset; chartEditorState.songLengthInMs = (chartEditorState.audioInstTrack?.length ?? 1000.0) + Conductor.instance.instrumentalOffset;
}; };
inputOffsetVocal.onChange = function(event:UIEvent) { inputOffsetVocal.onChange = function(event:UIEvent) {
if (event.value == null) return; if (event.value == null) return;
state.currentSongMetadata.offsets.setVocalOffset(state.currentSongMetadata.playData.characters.player, event.value); chartEditorState.currentSongMetadata.offsets.setVocalOffset(chartEditorState.currentSongMetadata.playData.characters.player, event.value);
}; };
inputScrollSpeed.onChange = function(event:UIEvent) { inputScrollSpeed.onChange = function(event:UIEvent) {
var valid:Bool = event.target.value != null && event.target.value > 0; var valid:Bool = event.target.value != null && event.target.value > 0;
@ -136,25 +136,25 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox
if (valid) if (valid)
{ {
inputScrollSpeed.removeClass('invalid-value'); inputScrollSpeed.removeClass('invalid-value');
state.currentSongChartScrollSpeed = event.target.value; chartEditorState.currentSongChartScrollSpeed = event.target.value;
} }
else else
{ {
state.currentSongChartScrollSpeed = 1.0; chartEditorState.currentSongChartScrollSpeed = 1.0;
} }
labelScrollSpeed.text = 'Scroll Speed: ${state.currentSongChartScrollSpeed}x'; labelScrollSpeed.text = 'Scroll Speed: ${chartEditorState.currentSongChartScrollSpeed}x';
}; };
buttonCharacterOpponent.onClick = function(_) { buttonCharacterOpponent.onClick = function(_) {
state.openCharacterDropdown(CharacterType.DAD, false); chartEditorState.openCharacterDropdown(CharacterType.DAD, false);
}; };
buttonCharacterGirlfriend.onClick = function(_) { buttonCharacterGirlfriend.onClick = function(_) {
state.openCharacterDropdown(CharacterType.GF, false); chartEditorState.openCharacterDropdown(CharacterType.GF, false);
}; };
buttonCharacterPlayer.onClick = function(_) { buttonCharacterPlayer.onClick = function(_) {
state.openCharacterDropdown(CharacterType.BF, false); chartEditorState.openCharacterDropdown(CharacterType.BF, false);
}; };
refresh(); refresh();
@ -162,17 +162,17 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox
public override function refresh():Void public override function refresh():Void
{ {
inputSongName.value = state.currentSongMetadata.songName; inputSongName.value = chartEditorState.currentSongMetadata.songName;
inputSongArtist.value = state.currentSongMetadata.artist; inputSongArtist.value = chartEditorState.currentSongMetadata.artist;
inputStage.value = state.currentSongMetadata.playData.stage; inputStage.value = chartEditorState.currentSongMetadata.playData.stage;
inputNoteStyle.value = state.currentSongMetadata.playData.noteStyle; inputNoteStyle.value = chartEditorState.currentSongMetadata.playData.noteStyle;
inputBPM.value = state.currentSongMetadata.timeChanges[0].bpm; inputBPM.value = chartEditorState.currentSongMetadata.timeChanges[0].bpm;
inputScrollSpeed.value = state.currentSongChartScrollSpeed; inputScrollSpeed.value = chartEditorState.currentSongChartScrollSpeed;
labelScrollSpeed.text = 'Scroll Speed: ${state.currentSongChartScrollSpeed}x'; labelScrollSpeed.text = 'Scroll Speed: ${chartEditorState.currentSongChartScrollSpeed}x';
frameVariation.text = 'Variation: ${state.selectedVariation.toTitleCase()}'; frameVariation.text = 'Variation: ${chartEditorState.selectedVariation.toTitleCase()}';
frameDifficulty.text = 'Difficulty: ${state.selectedDifficulty.toTitleCase()}'; frameDifficulty.text = 'Difficulty: ${chartEditorState.selectedDifficulty.toTitleCase()}';
var stageId:String = state.currentSongMetadata.playData.stage; var stageId:String = chartEditorState.currentSongMetadata.playData.stage;
var stageData:Null<StageData> = StageDataParser.parseStageData(stageId); var stageData:Null<StageData> = StageDataParser.parseStageData(stageId);
if (inputStage != null) if (inputStage != null)
{ {
@ -183,21 +183,45 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox
var LIMIT = 6; var LIMIT = 6;
var charDataOpponent:CharacterData = CharacterDataParser.fetchCharacterData(state.currentSongMetadata.playData.characters.opponent); var charDataOpponent:Null<CharacterData> = CharacterDataParser.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.opponent);
buttonCharacterOpponent.icon = CharacterDataParser.getCharPixelIconAsset(state.currentSongMetadata.playData.characters.opponent); if (charDataOpponent != null)
buttonCharacterOpponent.text = charDataOpponent.name.length > LIMIT ? '${charDataOpponent.name.substr(0, LIMIT)}.' : '${charDataOpponent.name}'; {
buttonCharacterOpponent.icon = CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.opponent);
buttonCharacterOpponent.text = charDataOpponent.name.length > LIMIT ? '${charDataOpponent.name.substr(0, LIMIT)}.' : '${charDataOpponent.name}';
}
else
{
buttonCharacterOpponent.icon = null;
buttonCharacterOpponent.text = "None";
}
var charDataGirlfriend:CharacterData = CharacterDataParser.fetchCharacterData(state.currentSongMetadata.playData.characters.girlfriend); var charDataGirlfriend:Null<CharacterData> = CharacterDataParser.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.girlfriend);
buttonCharacterGirlfriend.icon = CharacterDataParser.getCharPixelIconAsset(state.currentSongMetadata.playData.characters.girlfriend); if (charDataGirlfriend != null)
buttonCharacterGirlfriend.text = charDataGirlfriend.name.length > LIMIT ? '${charDataGirlfriend.name.substr(0, LIMIT)}.' : '${charDataGirlfriend.name}'; {
buttonCharacterGirlfriend.icon = CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.girlfriend);
buttonCharacterGirlfriend.text = charDataGirlfriend.name.length > LIMIT ? '${charDataGirlfriend.name.substr(0, LIMIT)}.' : '${charDataGirlfriend.name}';
}
else
{
buttonCharacterGirlfriend.icon = null;
buttonCharacterGirlfriend.text = "None";
}
var charDataPlayer:CharacterData = CharacterDataParser.fetchCharacterData(state.currentSongMetadata.playData.characters.player); var charDataPlayer:Null<CharacterData> = CharacterDataParser.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.player);
buttonCharacterPlayer.icon = CharacterDataParser.getCharPixelIconAsset(state.currentSongMetadata.playData.characters.player); if (charDataPlayer != null)
buttonCharacterPlayer.text = charDataPlayer.name.length > LIMIT ? '${charDataPlayer.name.substr(0, LIMIT)}.' : '${charDataPlayer.name}'; {
buttonCharacterPlayer.icon = CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.player);
buttonCharacterPlayer.text = charDataPlayer.name.length > LIMIT ? '${charDataPlayer.name.substr(0, LIMIT)}.' : '${charDataPlayer.name}';
}
else
{
buttonCharacterPlayer.icon = null;
buttonCharacterPlayer.text = "None";
}
} }
public static function build(state:ChartEditorState):ChartEditorMetadataToolbox public static function build(chartEditorState:ChartEditorState):ChartEditorMetadataToolbox
{ {
return new ChartEditorMetadataToolbox(state); return new ChartEditorMetadataToolbox(chartEditorState);
} }
} }

View file

@ -75,7 +75,7 @@ class LatencyState extends MusicBeatSubState
// funnyStatsGraph.hi // funnyStatsGraph.hi
Conductor.forceBPM(60); Conductor.instance.forceBPM(60);
noteGrp = new FlxTypedGroup<NoteSprite>(); noteGrp = new FlxTypedGroup<NoteSprite>();
add(noteGrp); add(noteGrp);
@ -91,14 +91,14 @@ class LatencyState extends MusicBeatSubState
// // musSpec.visType = FREQUENCIES; // // musSpec.visType = FREQUENCIES;
// add(musSpec); // add(musSpec);
for (beat in 0...Math.floor(FlxG.sound.music.length / Conductor.beatLengthMs)) for (beat in 0...Math.floor(FlxG.sound.music.length / Conductor.instance.beatLengthMs))
{ {
var beatTick:FlxSprite = new FlxSprite(songPosToX(beat * Conductor.beatLengthMs), FlxG.height - 15); var beatTick:FlxSprite = new FlxSprite(songPosToX(beat * Conductor.instance.beatLengthMs), FlxG.height - 15);
beatTick.makeGraphic(2, 15); beatTick.makeGraphic(2, 15);
beatTick.alpha = 0.3; beatTick.alpha = 0.3;
add(beatTick); add(beatTick);
var offsetTxt:FlxText = new FlxText(songPosToX(beat * Conductor.beatLengthMs), FlxG.height - 26, 0, "swag"); var offsetTxt:FlxText = new FlxText(songPosToX(beat * Conductor.instance.beatLengthMs), FlxG.height - 26, 0, "swag");
offsetTxt.alpha = 0.5; offsetTxt.alpha = 0.5;
diffGrp.add(offsetTxt); diffGrp.add(offsetTxt);
@ -130,7 +130,7 @@ class LatencyState extends MusicBeatSubState
for (i in 0...32) for (i in 0...32)
{ {
var note:NoteSprite = new NoteSprite(NoteStyleRegistry.instance.fetchDefault(), Conductor.beatLengthMs * i); var note:NoteSprite = new NoteSprite(NoteStyleRegistry.instance.fetchDefault(), Conductor.instance.beatLengthMs * i);
noteGrp.add(note); noteGrp.add(note);
} }
@ -146,9 +146,9 @@ class LatencyState extends MusicBeatSubState
override function stepHit():Bool override function stepHit():Bool
{ {
if (Conductor.currentStep % 4 == 2) if (Conductor.instance.currentStep % 4 == 2)
{ {
blocks.members[((Conductor.currentBeat % 8) + 1) % 8].alpha = 0.5; blocks.members[((Conductor.instance.currentBeat % 8) + 1) % 8].alpha = 0.5;
} }
return super.stepHit(); return super.stepHit();
@ -156,11 +156,11 @@ class LatencyState extends MusicBeatSubState
override function beatHit():Bool override function beatHit():Bool
{ {
if (Conductor.currentBeat % 8 == 0) blocks.forEach(blok -> { if (Conductor.instance.currentBeat % 8 == 0) blocks.forEach(blok -> {
blok.alpha = 0; blok.alpha = 0;
}); });
blocks.members[Conductor.currentBeat % 8].alpha = 1; blocks.members[Conductor.instance.currentBeat % 8].alpha = 1;
// block.visible = !block.visible; // block.visible = !block.visible;
return super.beatHit(); return super.beatHit();
@ -192,17 +192,17 @@ class LatencyState extends MusicBeatSubState
if (FlxG.keys.pressed.D) FlxG.sound.music.time += 1000 * FlxG.elapsed; if (FlxG.keys.pressed.D) FlxG.sound.music.time += 1000 * FlxG.elapsed;
Conductor.update(swagSong.getTimeWithDiff() - Conductor.inputOffset); Conductor.instance.update(swagSong.getTimeWithDiff() - Conductor.instance.inputOffset);
// Conductor.songPosition += (Timer.stamp() * 1000) - FlxG.sound.music.prevTimestamp; // Conductor.instance.songPosition += (Timer.stamp() * 1000) - FlxG.sound.music.prevTimestamp;
songPosVis.x = songPosToX(Conductor.songPosition); songPosVis.x = songPosToX(Conductor.instance.songPosition);
songVisFollowAudio.x = songPosToX(Conductor.songPosition - Conductor.instrumentalOffset); songVisFollowAudio.x = songPosToX(Conductor.instance.songPosition - Conductor.instance.instrumentalOffset);
songVisFollowVideo.x = songPosToX(Conductor.songPosition - Conductor.inputOffset); songVisFollowVideo.x = songPosToX(Conductor.instance.songPosition - Conductor.instance.inputOffset);
offsetText.text = "INST Offset: " + Conductor.instrumentalOffset + "ms"; offsetText.text = "INST Offset: " + Conductor.instance.instrumentalOffset + "ms";
offsetText.text += "\nINPUT Offset: " + Conductor.inputOffset + "ms"; offsetText.text += "\nINPUT Offset: " + Conductor.instance.inputOffset + "ms";
offsetText.text += "\ncurrentStep: " + Conductor.currentStep; offsetText.text += "\ncurrentStep: " + Conductor.instance.currentStep;
offsetText.text += "\ncurrentBeat: " + Conductor.currentBeat; offsetText.text += "\ncurrentBeat: " + Conductor.instance.currentBeat;
var avgOffsetInput:Float = 0; var avgOffsetInput:Float = 0;
@ -221,24 +221,24 @@ class LatencyState extends MusicBeatSubState
{ {
if (FlxG.keys.justPressed.RIGHT) if (FlxG.keys.justPressed.RIGHT)
{ {
Conductor.instrumentalOffset += 1.0 * multiply; Conductor.instance.instrumentalOffset += 1.0 * multiply;
} }
if (FlxG.keys.justPressed.LEFT) if (FlxG.keys.justPressed.LEFT)
{ {
Conductor.instrumentalOffset -= 1.0 * multiply; Conductor.instance.instrumentalOffset -= 1.0 * multiply;
} }
} }
else else
{ {
if (FlxG.keys.justPressed.RIGHT) if (FlxG.keys.justPressed.RIGHT)
{ {
Conductor.inputOffset += 1.0 * multiply; Conductor.instance.inputOffset += 1.0 * multiply;
} }
if (FlxG.keys.justPressed.LEFT) if (FlxG.keys.justPressed.LEFT)
{ {
Conductor.inputOffset -= 1.0 * multiply; Conductor.instance.inputOffset -= 1.0 * multiply;
} }
} }
@ -250,7 +250,7 @@ class LatencyState extends MusicBeatSubState
}*/ }*/
noteGrp.forEach(function(daNote:NoteSprite) { noteGrp.forEach(function(daNote:NoteSprite) {
daNote.y = (strumLine.y - ((Conductor.songPosition - Conductor.instrumentalOffset) - daNote.noteData.time) * 0.45); daNote.y = (strumLine.y - ((Conductor.instance.songPosition - Conductor.instance.instrumentalOffset) - daNote.noteData.time) * 0.45);
daNote.x = strumLine.x + 30; daNote.x = strumLine.x + 30;
if (daNote.y < strumLine.y) daNote.alpha = 0.5; if (daNote.y < strumLine.y) daNote.alpha = 0.5;
@ -258,7 +258,7 @@ class LatencyState extends MusicBeatSubState
if (daNote.y < 0 - daNote.height) if (daNote.y < 0 - daNote.height)
{ {
daNote.alpha = 1; daNote.alpha = 1;
// daNote.data.strumTime += Conductor.beatLengthMs * 8; // daNote.data.strumTime += Conductor.instance.beatLengthMs * 8;
} }
}); });
@ -267,14 +267,14 @@ class LatencyState extends MusicBeatSubState
function generateBeatStuff() function generateBeatStuff()
{ {
Conductor.update(swagSong.getTimeWithDiff()); Conductor.instance.update(swagSong.getTimeWithDiff());
var closestBeat:Int = Math.round(Conductor.songPosition / Conductor.beatLengthMs) % diffGrp.members.length; var closestBeat:Int = Math.round(Conductor.instance.songPosition / Conductor.instance.beatLengthMs) % diffGrp.members.length;
var getDiff:Float = Conductor.songPosition - (closestBeat * Conductor.beatLengthMs); var getDiff:Float = Conductor.instance.songPosition - (closestBeat * Conductor.instance.beatLengthMs);
getDiff -= Conductor.inputOffset; getDiff -= Conductor.instance.inputOffset;
// lil fix for end of song // lil fix for end of song
if (closestBeat == 0 && getDiff >= Conductor.beatLengthMs * 2) getDiff -= FlxG.sound.music.length; if (closestBeat == 0 && getDiff >= Conductor.instance.beatLengthMs * 2) getDiff -= FlxG.sound.music.length;
trace("\tDISTANCE TO CLOSEST BEAT: " + getDiff + "ms"); trace("\tDISTANCE TO CLOSEST BEAT: " + getDiff + "ms");
trace("\tCLOSEST BEAT: " + closestBeat); trace("\tCLOSEST BEAT: " + closestBeat);

View file

@ -97,7 +97,7 @@ class FreeplayState extends MusicBeatSubState
var stickerSubState:StickerSubState; var stickerSubState:StickerSubState;
// //
static var rememberedDifficulty:Null<String> = "normal"; static var rememberedDifficulty:Null<String> = Constants.DEFAULT_DIFFICULTY;
static var rememberedSongId:Null<String> = null; static var rememberedSongId:Null<String> = null;
public function new(?stickers:StickerSubState = null) public function new(?stickers:StickerSubState = null)
@ -874,15 +874,14 @@ class FreeplayState extends MusicBeatSubState
} }
} }
@:haxe.warning("-WDeprecated") public override function destroy():Void
override function switchTo(nextState:FlxState):Bool
{ {
super.destroy();
var daSong = songs[curSelected]; var daSong = songs[curSelected];
if (daSong != null) if (daSong != null)
{ {
clearDaCache(daSong.songName); clearDaCache(daSong.songName);
} }
return super.switchTo(nextState);
} }
function changeDiff(change:Int = 0) function changeDiff(change:Int = 0)

View file

@ -35,7 +35,7 @@ class CharacterPlayer extends Box
public function new(defaultToBf:Bool = true) public function new(defaultToBf:Bool = true)
{ {
super(); super();
_overrideSkipTransformChildren = false; // _overrideSkipTransformChildren = false;
if (defaultToBf) if (defaultToBf)
{ {

View file

@ -106,7 +106,7 @@ class StoryMenuState extends MusicBeatState
var stickerSubState:StickerSubState; var stickerSubState:StickerSubState;
static var rememberedLevelId:Null<String> = null; static var rememberedLevelId:Null<String> = null;
static var rememberedDifficulty:Null<String> = "normal"; static var rememberedDifficulty:Null<String> = Constants.DEFAULT_DIFFICULTY;
public function new(?stickers:StickerSubState = null) public function new(?stickers:StickerSubState = null)
{ {
@ -238,7 +238,7 @@ class StoryMenuState extends MusicBeatState
var freakyMenuMetadata:Null<SongMusicData> = SongRegistry.instance.parseMusicData('freakyMenu'); var freakyMenuMetadata:Null<SongMusicData> = SongRegistry.instance.parseMusicData('freakyMenu');
if (freakyMenuMetadata != null) if (freakyMenuMetadata != null)
{ {
Conductor.mapTimeChanges(freakyMenuMetadata.timeChanges); Conductor.instance.mapTimeChanges(freakyMenuMetadata.timeChanges);
} }
FlxG.sound.playMusic(Paths.music('freakyMenu/freakyMenu'), 0); FlxG.sound.playMusic(Paths.music('freakyMenu/freakyMenu'), 0);
@ -317,7 +317,7 @@ class StoryMenuState extends MusicBeatState
override function update(elapsed:Float) override function update(elapsed:Float)
{ {
Conductor.update(); Conductor.instance.update();
highScoreLerp = Std.int(MathUtil.coolLerp(highScoreLerp, highScore, 0.5)); highScoreLerp = Std.int(MathUtil.coolLerp(highScoreLerp, highScore, 0.5));

View file

@ -221,7 +221,7 @@ class TitleState extends MusicBeatState
var freakyMenuMetadata:Null<SongMusicData> = SongRegistry.instance.parseMusicData('freakyMenu'); var freakyMenuMetadata:Null<SongMusicData> = SongRegistry.instance.parseMusicData('freakyMenu');
if (freakyMenuMetadata != null) if (freakyMenuMetadata != null)
{ {
Conductor.mapTimeChanges(freakyMenuMetadata.timeChanges); Conductor.instance.mapTimeChanges(freakyMenuMetadata.timeChanges);
} }
FlxG.sound.playMusic(Paths.music('freakyMenu/freakyMenu'), 0); FlxG.sound.playMusic(Paths.music('freakyMenu/freakyMenu'), 0);
FlxG.sound.music.fadeIn(4, 0, 0.7); FlxG.sound.music.fadeIn(4, 0, 0.7);
@ -256,7 +256,7 @@ class TitleState extends MusicBeatState
if (FlxG.keys.pressed.DOWN) FlxG.sound.music.pitch -= 0.5 * elapsed; if (FlxG.keys.pressed.DOWN) FlxG.sound.music.pitch -= 0.5 * elapsed;
#end #end
Conductor.update(); Conductor.instance.update();
/* if (FlxG.onMobile) /* if (FlxG.onMobile)
{ {
@ -280,7 +280,7 @@ class TitleState extends MusicBeatState
FlxTween.tween(FlxG.stage.window, {y: FlxG.stage.window.y + 100}, 0.7, {ease: FlxEase.quadInOut, type: PINGPONG}); FlxTween.tween(FlxG.stage.window, {y: FlxG.stage.window.y + 100}, 0.7, {ease: FlxEase.quadInOut, type: PINGPONG});
} }
if (FlxG.sound.music != null) Conductor.update(FlxG.sound.music.time); if (FlxG.sound.music != null) Conductor.instance.update(FlxG.sound.music.time);
if (FlxG.keys.justPressed.F) FlxG.fullscreen = !FlxG.fullscreen; if (FlxG.keys.justPressed.F) FlxG.fullscreen = !FlxG.fullscreen;
// do controls.PAUSE | controls.ACCEPT instead? // do controls.PAUSE | controls.ACCEPT instead?
@ -390,7 +390,7 @@ class TitleState extends MusicBeatState
var spec:SpectogramSprite = new SpectogramSprite(FlxG.sound.music); var spec:SpectogramSprite = new SpectogramSprite(FlxG.sound.music);
add(spec); add(spec);
Conductor.forceBPM(190); Conductor.instance.forceBPM(190);
FlxG.camera.flash(FlxColor.WHITE, 1); FlxG.camera.flash(FlxColor.WHITE, 1);
FlxG.sound.play(Paths.sound('confirmMenu'), 0.7); FlxG.sound.play(Paths.sound('confirmMenu'), 0.7);
} }
@ -442,13 +442,13 @@ class TitleState extends MusicBeatState
if (!skippedIntro) if (!skippedIntro)
{ {
// FlxG.log.add(Conductor.currentBeat); // FlxG.log.add(Conductor.instance.currentBeat);
// if the user is draggin the window some beats will // if the user is draggin the window some beats will
// be missed so this is just to compensate // be missed so this is just to compensate
if (Conductor.currentBeat > lastBeat) if (Conductor.instance.currentBeat > lastBeat)
{ {
// TODO: Why does it perform ALL the previous steps each beat? // TODO: Why does it perform ALL the previous steps each beat?
for (i in lastBeat...Conductor.currentBeat) for (i in lastBeat...Conductor.instance.currentBeat)
{ {
switch (i + 1) switch (i + 1)
{ {
@ -483,11 +483,11 @@ class TitleState extends MusicBeatState
} }
} }
} }
lastBeat = Conductor.currentBeat; lastBeat = Conductor.instance.currentBeat;
} }
if (skippedIntro) if (skippedIntro)
{ {
if (cheatActive && Conductor.currentBeat % 2 == 0) swagShader.update(0.125); if (cheatActive && Conductor.instance.currentBeat % 2 == 0) swagShader.update(0.125);
if (logoBl != null && logoBl.animation != null) logoBl.animation.play('bump', true); if (logoBl != null && logoBl.animation != null) logoBl.animation.play('bump', true);

View file

@ -123,6 +123,7 @@ class Constants
/** /**
* Default list of difficulties for charts. * Default list of difficulties for charts.
* Assumes no Erect mode, etc.
*/ */
public static final DEFAULT_DIFFICULTY_LIST:Array<String> = ['easy', 'normal', 'hard']; public static final DEFAULT_DIFFICULTY_LIST:Array<String> = ['easy', 'normal', 'hard'];

View file

@ -31,23 +31,23 @@ class ConductorTest extends FunkinTest
{ {
// NOTE: Expected value comes first. // NOTE: Expected value comes first.
Assert.areEqual([], Conductor.timeChanges); Assert.areEqual([], Conductor.instance.timeChanges);
Assert.areEqual(null, Conductor.currentTimeChange); Assert.areEqual(null, Conductor.instance.currentTimeChange);
Assert.areEqual(0, Conductor.songPosition); Assert.areEqual(0, Conductor.instance.songPosition);
Assert.areEqual(Constants.DEFAULT_BPM, Conductor.bpm); Assert.areEqual(Constants.DEFAULT_BPM, Conductor.instance.bpm);
Assert.areEqual(null, Conductor.bpmOverride); Assert.areEqual(null, Conductor.instance.bpmOverride);
Assert.areEqual(600, Conductor.beatLengthMs); Assert.areEqual(600, Conductor.instance.beatLengthMs);
Assert.areEqual(4, Conductor.timeSignatureNumerator); Assert.areEqual(4, Conductor.instance.timeSignatureNumerator);
Assert.areEqual(4, Conductor.timeSignatureDenominator); Assert.areEqual(4, Conductor.instance.timeSignatureDenominator);
Assert.areEqual(0, Conductor.currentBeat); Assert.areEqual(0, Conductor.instance.currentBeat);
Assert.areEqual(0, Conductor.currentStep); Assert.areEqual(0, Conductor.instance.currentStep);
Assert.areEqual(0.0, Conductor.currentStepTime); Assert.areEqual(0.0, Conductor.instance.currentStepTime);
Assert.areEqual(150, Conductor.stepLengthMs); Assert.areEqual(150, Conductor.instance.stepLengthMs);
} }
/** /**
@ -60,23 +60,23 @@ class ConductorTest extends FunkinTest
var currentConductorState:Null<ConductorState> = conductorState; var currentConductorState:Null<ConductorState> = conductorState;
Assert.isNotNull(currentConductorState); Assert.isNotNull(currentConductorState);
Assert.areEqual(0, Conductor.songPosition); Assert.areEqual(0, Conductor.instance.songPosition);
step(); // 1 step(); // 1
var BPM_100_STEP_TIME = 1 / 9; var BPM_100_STEP_TIME = 1 / 9;
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 1, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 1, Conductor.instance.songPosition);
Assert.areEqual(0, Conductor.currentBeat); Assert.areEqual(0, Conductor.instance.currentBeat);
Assert.areEqual(0, Conductor.currentStep); Assert.areEqual(0, Conductor.instance.currentStep);
FunkinAssert.areNear(1 / 9, Conductor.currentStepTime); FunkinAssert.areNear(1 / 9, Conductor.instance.currentStepTime);
step(7); // 8 step(7); // 8
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 8, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 8, Conductor.instance.songPosition);
Assert.areEqual(0, Conductor.currentBeat); Assert.areEqual(0, Conductor.instance.currentBeat);
Assert.areEqual(0, Conductor.currentStep); Assert.areEqual(0, Conductor.instance.currentStep);
FunkinAssert.areNear(8 / 9, Conductor.currentStepTime); FunkinAssert.areNear(8 / 9, Conductor.instance.currentStepTime);
Assert.areEqual(0, currentConductorState.beatsHit); Assert.areEqual(0, currentConductorState.beatsHit);
Assert.areEqual(0, currentConductorState.stepsHit); Assert.areEqual(0, currentConductorState.stepsHit);
@ -88,10 +88,10 @@ class ConductorTest extends FunkinTest
currentConductorState.beatsHit = 0; currentConductorState.beatsHit = 0;
currentConductorState.stepsHit = 0; currentConductorState.stepsHit = 0;
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 9, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 9, Conductor.instance.songPosition);
Assert.areEqual(0, Conductor.currentBeat); Assert.areEqual(0, Conductor.instance.currentBeat);
Assert.areEqual(1, Conductor.currentStep); Assert.areEqual(1, Conductor.instance.currentStep);
FunkinAssert.areNear(1.0, Conductor.currentStepTime); FunkinAssert.areNear(1.0, Conductor.instance.currentStepTime);
step(35 - 9); // 35 step(35 - 9); // 35
@ -100,10 +100,10 @@ class ConductorTest extends FunkinTest
currentConductorState.beatsHit = 0; currentConductorState.beatsHit = 0;
currentConductorState.stepsHit = 0; currentConductorState.stepsHit = 0;
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 35, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 35, Conductor.instance.songPosition);
Assert.areEqual(0, Conductor.currentBeat); Assert.areEqual(0, Conductor.instance.currentBeat);
Assert.areEqual(3, Conductor.currentStep); Assert.areEqual(3, Conductor.instance.currentStep);
FunkinAssert.areNear(3.0 + 8 / 9, Conductor.currentStepTime); FunkinAssert.areNear(3.0 + 8 / 9, Conductor.instance.currentStepTime);
step(); // 36 step(); // 36
@ -112,83 +112,83 @@ class ConductorTest extends FunkinTest
currentConductorState.beatsHit = 0; currentConductorState.beatsHit = 0;
currentConductorState.stepsHit = 0; currentConductorState.stepsHit = 0;
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 36, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 36, Conductor.instance.songPosition);
Assert.areEqual(1, Conductor.currentBeat); Assert.areEqual(1, Conductor.instance.currentBeat);
Assert.areEqual(4, Conductor.currentStep); Assert.areEqual(4, Conductor.instance.currentStep);
FunkinAssert.areNear(4.0, Conductor.currentStepTime); FunkinAssert.areNear(4.0, Conductor.instance.currentStepTime);
step(50 - 36); // 50 step(50 - 36); // 50
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 50, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 50, Conductor.instance.songPosition);
Assert.areEqual(1, Conductor.currentBeat); Assert.areEqual(1, Conductor.instance.currentBeat);
Assert.areEqual(5, Conductor.currentStep); Assert.areEqual(5, Conductor.instance.currentStep);
FunkinAssert.areNear(5.555555, Conductor.currentStepTime); FunkinAssert.areNear(5.555555, Conductor.instance.currentStepTime);
step(49); // 99 step(49); // 99
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 99, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 99, Conductor.instance.songPosition);
Assert.areEqual(2, Conductor.currentBeat); Assert.areEqual(2, Conductor.instance.currentBeat);
Assert.areEqual(11, Conductor.currentStep); Assert.areEqual(11, Conductor.instance.currentStep);
FunkinAssert.areNear(11.0, Conductor.currentStepTime); FunkinAssert.areNear(11.0, Conductor.instance.currentStepTime);
step(1); // 100 step(1); // 100
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 100, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 100, Conductor.instance.songPosition);
Assert.areEqual(2, Conductor.currentBeat); Assert.areEqual(2, Conductor.instance.currentBeat);
Assert.areEqual(11, Conductor.currentStep); Assert.areEqual(11, Conductor.instance.currentStep);
FunkinAssert.areNear(11.111111, Conductor.currentStepTime); FunkinAssert.areNear(11.111111, Conductor.instance.currentStepTime);
} }
@Test @Test
function testUpdateForcedBPM():Void function testUpdateForcedBPM():Void
{ {
Conductor.forceBPM(60); Conductor.instance.forceBPM(60);
Assert.areEqual(0, Conductor.songPosition); Assert.areEqual(0, Conductor.instance.songPosition);
// 60 beats per minute = 1 beat per second // 60 beats per minute = 1 beat per second
// 1 beat per second = 1/60 beats per frame = 4/60 steps per frame // 1 beat per second = 1/60 beats per frame = 4/60 steps per frame
step(); // Advances time 1/60 of 1 second. step(); // Advances time 1/60 of 1 second.
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 1, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 1, Conductor.instance.songPosition);
Assert.areEqual(0, Conductor.currentBeat); Assert.areEqual(0, Conductor.instance.currentBeat);
Assert.areEqual(0, Conductor.currentStep); Assert.areEqual(0, Conductor.instance.currentStep);
FunkinAssert.areNear(4 / 60, Conductor.currentStepTime); // 1/60 of 1 beat = 4/60 of 1 step FunkinAssert.areNear(4 / 60, Conductor.instance.currentStepTime); // 1/60 of 1 beat = 4/60 of 1 step
step(14 - 1); // 14 step(14 - 1); // 14
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 14, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 14, Conductor.instance.songPosition);
Assert.areEqual(0, Conductor.currentBeat); Assert.areEqual(0, Conductor.instance.currentBeat);
Assert.areEqual(0, Conductor.currentStep); Assert.areEqual(0, Conductor.instance.currentStep);
FunkinAssert.areNear(1.0 - 4 / 60, Conductor.currentStepTime); // 1/60 of 1 beat = 4/60 of 1 step FunkinAssert.areNear(1.0 - 4 / 60, Conductor.instance.currentStepTime); // 1/60 of 1 beat = 4/60 of 1 step
step(); // 15 step(); // 15
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 15, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 15, Conductor.instance.songPosition);
Assert.areEqual(0, Conductor.currentBeat); Assert.areEqual(0, Conductor.instance.currentBeat);
Assert.areEqual(1, Conductor.currentStep); Assert.areEqual(1, Conductor.instance.currentStep);
FunkinAssert.areNear(1.0, Conductor.currentStepTime); // 1/60 of 1 beat = 4/60 of 1 step FunkinAssert.areNear(1.0, Conductor.instance.currentStepTime); // 1/60 of 1 beat = 4/60 of 1 step
step(45 - 1); // 59 step(45 - 1); // 59
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 59, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 59, Conductor.instance.songPosition);
Assert.areEqual(0, Conductor.currentBeat); Assert.areEqual(0, Conductor.instance.currentBeat);
Assert.areEqual(3, Conductor.currentStep); Assert.areEqual(3, Conductor.instance.currentStep);
FunkinAssert.areNear(4.0 - 4 / 60, Conductor.currentStepTime); FunkinAssert.areNear(4.0 - 4 / 60, Conductor.instance.currentStepTime);
step(); // 60 step(); // 60
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 60, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 60, Conductor.instance.songPosition);
Assert.areEqual(1, Conductor.currentBeat); Assert.areEqual(1, Conductor.instance.currentBeat);
Assert.areEqual(4, Conductor.currentStep); Assert.areEqual(4, Conductor.instance.currentStep);
FunkinAssert.areNear(4.0, Conductor.currentStepTime); FunkinAssert.areNear(4.0, Conductor.instance.currentStepTime);
step(); // 61 step(); // 61
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 61, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 61, Conductor.instance.songPosition);
Assert.areEqual(1, Conductor.currentBeat); Assert.areEqual(1, Conductor.instance.currentBeat);
Assert.areEqual(4, Conductor.currentStep); Assert.areEqual(4, Conductor.instance.currentStep);
FunkinAssert.areNear(4.0 + 4 / 60, Conductor.currentStepTime); FunkinAssert.areNear(4.0 + 4 / 60, Conductor.instance.currentStepTime);
} }
@Test @Test
@ -196,50 +196,50 @@ class ConductorTest extends FunkinTest
{ {
// Start the song with a BPM of 120. // Start the song with a BPM of 120.
var songTimeChanges:Array<SongTimeChange> = [new SongTimeChange(0, 120)]; var songTimeChanges:Array<SongTimeChange> = [new SongTimeChange(0, 120)];
Conductor.mapTimeChanges(songTimeChanges); Conductor.instance.mapTimeChanges(songTimeChanges);
// All should be at 0. // All should be at 0.
FunkinAssert.areNear(0, Conductor.songPosition); FunkinAssert.areNear(0, Conductor.instance.songPosition);
Assert.areEqual(0, Conductor.currentBeat); Assert.areEqual(0, Conductor.instance.currentBeat);
Assert.areEqual(0, Conductor.currentStep); Assert.areEqual(0, Conductor.instance.currentStep);
FunkinAssert.areNear(0.0, Conductor.currentStepTime); // 2/120 of 1 beat = 8/120 of 1 step FunkinAssert.areNear(0.0, Conductor.instance.currentStepTime); // 2/120 of 1 beat = 8/120 of 1 step
// 120 beats per minute = 2 beat per second // 120 beats per minute = 2 beat per second
// 2 beat per second = 2/60 beats per frame = 16/120 steps per frame // 2 beat per second = 2/60 beats per frame = 16/120 steps per frame
step(); // Advances time 1/60 of 1 second. step(); // Advances time 1/60 of 1 second.
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 1, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 1, Conductor.instance.songPosition);
Assert.areEqual(0, Conductor.currentBeat); Assert.areEqual(0, Conductor.instance.currentBeat);
Assert.areEqual(0, Conductor.currentStep); Assert.areEqual(0, Conductor.instance.currentStep);
FunkinAssert.areNear(16 / 120, Conductor.currentStepTime); // 2/120 of 1 beat = 8/120 of 1 step FunkinAssert.areNear(16 / 120, Conductor.instance.currentStepTime); // 2/120 of 1 beat = 8/120 of 1 step
step(15 - 1); // 15 step(15 - 1); // 15
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 15, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 15, Conductor.instance.songPosition);
Assert.areEqual(0, Conductor.currentBeat); Assert.areEqual(0, Conductor.instance.currentBeat);
Assert.areEqual(2, Conductor.currentStep); Assert.areEqual(2, Conductor.instance.currentStep);
FunkinAssert.areNear(2.0, Conductor.currentStepTime); // 2/60 of 1 beat = 8/60 of 1 step FunkinAssert.areNear(2.0, Conductor.instance.currentStepTime); // 2/60 of 1 beat = 8/60 of 1 step
step(45 - 1); // 59 step(45 - 1); // 59
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 59, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 59, Conductor.instance.songPosition);
Assert.areEqual(1, Conductor.currentBeat); Assert.areEqual(1, Conductor.instance.currentBeat);
Assert.areEqual(7, Conductor.currentStep); Assert.areEqual(7, Conductor.instance.currentStep);
FunkinAssert.areNear(7.0 + 104 / 120, Conductor.currentStepTime); FunkinAssert.areNear(7.0 + 104 / 120, Conductor.instance.currentStepTime);
step(); // 60 step(); // 60
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 60, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 60, Conductor.instance.songPosition);
Assert.areEqual(2, Conductor.currentBeat); Assert.areEqual(2, Conductor.instance.currentBeat);
Assert.areEqual(8, Conductor.currentStep); Assert.areEqual(8, Conductor.instance.currentStep);
FunkinAssert.areNear(8.0, Conductor.currentStepTime); FunkinAssert.areNear(8.0, Conductor.instance.currentStepTime);
step(); // 61 step(); // 61
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 61, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 61, Conductor.instance.songPosition);
Assert.areEqual(2, Conductor.currentBeat); Assert.areEqual(2, Conductor.instance.currentBeat);
Assert.areEqual(8, Conductor.currentStep); Assert.areEqual(8, Conductor.instance.currentStep);
FunkinAssert.areNear(8.0 + 8 / 60, Conductor.currentStepTime); FunkinAssert.areNear(8.0 + 8 / 60, Conductor.instance.currentStepTime);
} }
@Test @Test
@ -247,57 +247,57 @@ class ConductorTest extends FunkinTest
{ {
// Start the song with a BPM of 120. // Start the song with a BPM of 120.
var songTimeChanges:Array<SongTimeChange> = [new SongTimeChange(0, 120), new SongTimeChange(3000, 90)]; var songTimeChanges:Array<SongTimeChange> = [new SongTimeChange(0, 120), new SongTimeChange(3000, 90)];
Conductor.mapTimeChanges(songTimeChanges); Conductor.instance.mapTimeChanges(songTimeChanges);
// All should be at 0. // All should be at 0.
FunkinAssert.areNear(0, Conductor.songPosition); FunkinAssert.areNear(0, Conductor.instance.songPosition);
Assert.areEqual(0, Conductor.currentBeat); Assert.areEqual(0, Conductor.instance.currentBeat);
Assert.areEqual(0, Conductor.currentStep); Assert.areEqual(0, Conductor.instance.currentStep);
FunkinAssert.areNear(0.0, Conductor.currentStepTime); // 2/120 of 1 beat = 8/120 of 1 step FunkinAssert.areNear(0.0, Conductor.instance.currentStepTime); // 2/120 of 1 beat = 8/120 of 1 step
// 120 beats per minute = 2 beat per second // 120 beats per minute = 2 beat per second
// 2 beat per second = 2/60 beats per frame = 16/120 steps per frame // 2 beat per second = 2/60 beats per frame = 16/120 steps per frame
step(); // Advances time 1/60 of 1 second. step(); // Advances time 1/60 of 1 second.
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 1, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 1, Conductor.instance.songPosition);
Assert.areEqual(0, Conductor.currentBeat); Assert.areEqual(0, Conductor.instance.currentBeat);
Assert.areEqual(0, Conductor.currentStep); Assert.areEqual(0, Conductor.instance.currentStep);
FunkinAssert.areNear(16 / 120, Conductor.currentStepTime); // 4/120 of 1 beat = 16/120 of 1 step FunkinAssert.areNear(16 / 120, Conductor.instance.currentStepTime); // 4/120 of 1 beat = 16/120 of 1 step
step(60 - 1 - 1); // 59 step(60 - 1 - 1); // 59
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 59, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 59, Conductor.instance.songPosition);
Assert.areEqual(1, Conductor.currentBeat); Assert.areEqual(1, Conductor.instance.currentBeat);
Assert.areEqual(7, Conductor.currentStep); Assert.areEqual(7, Conductor.instance.currentStep);
FunkinAssert.areNear(7.0 + 104 / 120, Conductor.currentStepTime); FunkinAssert.areNear(7.0 + 104 / 120, Conductor.instance.currentStepTime);
step(); // 60 step(); // 60
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 60, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 60, Conductor.instance.songPosition);
Assert.areEqual(2, Conductor.currentBeat); Assert.areEqual(2, Conductor.instance.currentBeat);
Assert.areEqual(8, Conductor.currentStep); Assert.areEqual(8, Conductor.instance.currentStep);
FunkinAssert.areNear(8.0, Conductor.currentStepTime); FunkinAssert.areNear(8.0, Conductor.instance.currentStepTime);
step(); // 61 step(); // 61
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 61, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 61, Conductor.instance.songPosition);
Assert.areEqual(2, Conductor.currentBeat); Assert.areEqual(2, Conductor.instance.currentBeat);
Assert.areEqual(8, Conductor.currentStep); Assert.areEqual(8, Conductor.instance.currentStep);
FunkinAssert.areNear(8.0 + 8 / 60, Conductor.currentStepTime); FunkinAssert.areNear(8.0 + 8 / 60, Conductor.instance.currentStepTime);
step(179 - 61); // 179 step(179 - 61); // 179
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 179, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 179, Conductor.instance.songPosition);
Assert.areEqual(5, Conductor.currentBeat); Assert.areEqual(5, Conductor.instance.currentBeat);
Assert.areEqual(23, Conductor.currentStep); Assert.areEqual(23, Conductor.instance.currentStep);
FunkinAssert.areNear(23.0 + 52 / 60, Conductor.currentStepTime); FunkinAssert.areNear(23.0 + 52 / 60, Conductor.instance.currentStepTime);
step(); // 180 (3 seconds) step(); // 180 (3 seconds)
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 180, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 180, Conductor.instance.songPosition);
Assert.areEqual(6, Conductor.currentBeat); Assert.areEqual(6, Conductor.instance.currentBeat);
Assert.areEqual(24, Conductor.currentStep); Assert.areEqual(24, Conductor.instance.currentStep);
FunkinAssert.areNear(24.0, Conductor.currentStepTime); FunkinAssert.areNear(24.0, Conductor.instance.currentStepTime);
step(); // 181 (3 + 1/60 seconds) step(); // 181 (3 + 1/60 seconds)
// BPM has switched to 90! // BPM has switched to 90!
@ -305,24 +305,24 @@ class ConductorTest extends FunkinTest
// 1.5 beat per second = 1.5/60 beats per frame = 3/120 beats per frame // 1.5 beat per second = 1.5/60 beats per frame = 3/120 beats per frame
// = 12/120 steps per frame // = 12/120 steps per frame
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 181, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 181, Conductor.instance.songPosition);
Assert.areEqual(6, Conductor.currentBeat); Assert.areEqual(6, Conductor.instance.currentBeat);
Assert.areEqual(24, Conductor.currentStep); Assert.areEqual(24, Conductor.instance.currentStep);
FunkinAssert.areNear(24.0 + 12 / 120, Conductor.currentStepTime); FunkinAssert.areNear(24.0 + 12 / 120, Conductor.instance.currentStepTime);
step(59); // 240 (4 seconds) step(59); // 240 (4 seconds)
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 240, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 240, Conductor.instance.songPosition);
Assert.areEqual(7, Conductor.currentBeat); Assert.areEqual(7, Conductor.instance.currentBeat);
Assert.areEqual(30, Conductor.currentStep); Assert.areEqual(30, Conductor.instance.currentStep);
FunkinAssert.areNear(30.0, Conductor.currentStepTime); FunkinAssert.areNear(30.0, Conductor.instance.currentStepTime);
step(); // 241 (4 + 1/60 seconds) step(); // 241 (4 + 1/60 seconds)
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 241, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 241, Conductor.instance.songPosition);
Assert.areEqual(7, Conductor.currentBeat); Assert.areEqual(7, Conductor.instance.currentBeat);
Assert.areEqual(30, Conductor.currentStep); Assert.areEqual(30, Conductor.instance.currentStep);
FunkinAssert.areNear(30.0 + 12 / 120, Conductor.currentStepTime); FunkinAssert.areNear(30.0 + 12 / 120, Conductor.instance.currentStepTime);
} }
@Test @Test
@ -334,63 +334,63 @@ class ConductorTest extends FunkinTest
new SongTimeChange(3000, 90), new SongTimeChange(3000, 90),
new SongTimeChange(6000, 180) new SongTimeChange(6000, 180)
]; ];
Conductor.mapTimeChanges(songTimeChanges); Conductor.instance.mapTimeChanges(songTimeChanges);
// Verify time changes. // Verify time changes.
Assert.areEqual(3, Conductor.timeChanges.length); Assert.areEqual(3, Conductor.instance.timeChanges.length);
FunkinAssert.areNear(0, Conductor.timeChanges[0].beatTime); FunkinAssert.areNear(0, Conductor.instance.timeChanges[0].beatTime);
FunkinAssert.areNear(6, Conductor.timeChanges[1].beatTime); FunkinAssert.areNear(6, Conductor.instance.timeChanges[1].beatTime);
FunkinAssert.areNear(10.5, Conductor.timeChanges[2].beatTime); FunkinAssert.areNear(10.5, Conductor.instance.timeChanges[2].beatTime);
// All should be at 0. // All should be at 0.
FunkinAssert.areNear(0, Conductor.songPosition); FunkinAssert.areNear(0, Conductor.instance.songPosition);
Assert.areEqual(0, Conductor.currentBeat); Assert.areEqual(0, Conductor.instance.currentBeat);
Assert.areEqual(0, Conductor.currentStep); Assert.areEqual(0, Conductor.instance.currentStep);
FunkinAssert.areNear(0.0, Conductor.currentStepTime); // 2/120 of 1 beat = 8/120 of 1 step FunkinAssert.areNear(0.0, Conductor.instance.currentStepTime); // 2/120 of 1 beat = 8/120 of 1 step
// 120 beats per minute = 2 beat per second // 120 beats per minute = 2 beat per second
// 2 beat per second = 2/60 beats per frame = 16/120 steps per frame // 2 beat per second = 2/60 beats per frame = 16/120 steps per frame
step(); // Advances time 1/60 of 1 second. step(); // Advances time 1/60 of 1 second.
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 1, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 1, Conductor.instance.songPosition);
Assert.areEqual(0, Conductor.currentBeat); Assert.areEqual(0, Conductor.instance.currentBeat);
Assert.areEqual(0, Conductor.currentStep); Assert.areEqual(0, Conductor.instance.currentStep);
FunkinAssert.areNear(16 / 120, Conductor.currentStepTime); // 4/120 of 1 beat = 16/120 of 1 step FunkinAssert.areNear(16 / 120, Conductor.instance.currentStepTime); // 4/120 of 1 beat = 16/120 of 1 step
step(60 - 1 - 1); // 59 step(60 - 1 - 1); // 59
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 59, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 59, Conductor.instance.songPosition);
Assert.areEqual(1, Conductor.currentBeat); Assert.areEqual(1, Conductor.instance.currentBeat);
Assert.areEqual(7, Conductor.currentStep); Assert.areEqual(7, Conductor.instance.currentStep);
FunkinAssert.areNear(7 + 104 / 120, Conductor.currentStepTime); FunkinAssert.areNear(7 + 104 / 120, Conductor.instance.currentStepTime);
step(); // 60 step(); // 60
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 60, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 60, Conductor.instance.songPosition);
Assert.areEqual(2, Conductor.currentBeat); Assert.areEqual(2, Conductor.instance.currentBeat);
Assert.areEqual(8, Conductor.currentStep); Assert.areEqual(8, Conductor.instance.currentStep);
FunkinAssert.areNear(8.0, Conductor.currentStepTime); FunkinAssert.areNear(8.0, Conductor.instance.currentStepTime);
step(); // 61 step(); // 61
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 61, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 61, Conductor.instance.songPosition);
Assert.areEqual(2, Conductor.currentBeat); Assert.areEqual(2, Conductor.instance.currentBeat);
Assert.areEqual(8, Conductor.currentStep); Assert.areEqual(8, Conductor.instance.currentStep);
FunkinAssert.areNear(8.0 + 8 / 60, Conductor.currentStepTime); FunkinAssert.areNear(8.0 + 8 / 60, Conductor.instance.currentStepTime);
step(179 - 61); // 179 step(179 - 61); // 179
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 179, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 179, Conductor.instance.songPosition);
Assert.areEqual(5, Conductor.currentBeat); Assert.areEqual(5, Conductor.instance.currentBeat);
Assert.areEqual(23, Conductor.currentStep); Assert.areEqual(23, Conductor.instance.currentStep);
FunkinAssert.areNear(23.0 + 52 / 60, Conductor.currentStepTime); FunkinAssert.areNear(23.0 + 52 / 60, Conductor.instance.currentStepTime);
step(); // 180 (3 seconds) step(); // 180 (3 seconds)
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 180, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 180, Conductor.instance.songPosition);
Assert.areEqual(6, Conductor.currentBeat); Assert.areEqual(6, Conductor.instance.currentBeat);
Assert.areEqual(24, Conductor.currentStep); // 23.999 => 24 Assert.areEqual(24, Conductor.instance.currentStep); // 23.999 => 24
FunkinAssert.areNear(24.0, Conductor.currentStepTime); FunkinAssert.areNear(24.0, Conductor.instance.currentStepTime);
step(); // 181 (3 + 1/60 seconds) step(); // 181 (3 + 1/60 seconds)
// BPM has switched to 90! // BPM has switched to 90!
@ -398,45 +398,45 @@ class ConductorTest extends FunkinTest
// 1.5 beat per second = 1.5/60 beats per frame = 3/120 beats per frame // 1.5 beat per second = 1.5/60 beats per frame = 3/120 beats per frame
// = 12/120 steps per frame // = 12/120 steps per frame
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 181, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 181, Conductor.instance.songPosition);
Assert.areEqual(6, Conductor.currentBeat); Assert.areEqual(6, Conductor.instance.currentBeat);
Assert.areEqual(24, Conductor.currentStep); Assert.areEqual(24, Conductor.instance.currentStep);
FunkinAssert.areNear(24.0 + 12 / 120, Conductor.currentStepTime); FunkinAssert.areNear(24.0 + 12 / 120, Conductor.instance.currentStepTime);
step(60 - 1 - 1); // 240 (4 seconds) step(60 - 1 - 1); // 240 (4 seconds)
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 239, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 239, Conductor.instance.songPosition);
Assert.areEqual(7, Conductor.currentBeat); Assert.areEqual(7, Conductor.instance.currentBeat);
Assert.areEqual(29, Conductor.currentStep); Assert.areEqual(29, Conductor.instance.currentStep);
FunkinAssert.areNear(29.0 + 108 / 120, Conductor.currentStepTime); FunkinAssert.areNear(29.0 + 108 / 120, Conductor.instance.currentStepTime);
step(); // 240 (4 seconds) step(); // 240 (4 seconds)
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 240, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 240, Conductor.instance.songPosition);
Assert.areEqual(7, Conductor.currentBeat); Assert.areEqual(7, Conductor.instance.currentBeat);
Assert.areEqual(30, Conductor.currentStep); Assert.areEqual(30, Conductor.instance.currentStep);
FunkinAssert.areNear(30.0, Conductor.currentStepTime); FunkinAssert.areNear(30.0, Conductor.instance.currentStepTime);
step(); // 241 (4 + 1/60 seconds) step(); // 241 (4 + 1/60 seconds)
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 241, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 241, Conductor.instance.songPosition);
Assert.areEqual(7, Conductor.currentBeat); Assert.areEqual(7, Conductor.instance.currentBeat);
Assert.areEqual(30, Conductor.currentStep); Assert.areEqual(30, Conductor.instance.currentStep);
FunkinAssert.areNear(30.0 + 12 / 120, Conductor.currentStepTime); FunkinAssert.areNear(30.0 + 12 / 120, Conductor.instance.currentStepTime);
step(359 - 241); // 359 (5 + 59/60 seconds) step(359 - 241); // 359 (5 + 59/60 seconds)
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 359, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 359, Conductor.instance.songPosition);
Assert.areEqual(10, Conductor.currentBeat); Assert.areEqual(10, Conductor.instance.currentBeat);
Assert.areEqual(41, Conductor.currentStep); Assert.areEqual(41, Conductor.instance.currentStep);
FunkinAssert.areNear(41 + 108 / 120, Conductor.currentStepTime); FunkinAssert.areNear(41 + 108 / 120, Conductor.instance.currentStepTime);
step(); // 360 step(); // 360
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 360, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 360, Conductor.instance.songPosition);
Assert.areEqual(10, Conductor.currentBeat); Assert.areEqual(10, Conductor.instance.currentBeat);
Assert.areEqual(42, Conductor.currentStep); // 41.999 Assert.areEqual(42, Conductor.instance.currentStep); // 41.999
FunkinAssert.areNear(42.0, Conductor.currentStepTime); FunkinAssert.areNear(42.0, Conductor.instance.currentStepTime);
step(); // 361 step(); // 361
// BPM has switched to 180! // BPM has switched to 180!
@ -444,24 +444,24 @@ class ConductorTest extends FunkinTest
// 3 beat per second = 3/60 beats per frame // 3 beat per second = 3/60 beats per frame
// = 12/60 steps per frame // = 12/60 steps per frame
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 361, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 361, Conductor.instance.songPosition);
Assert.areEqual(10, Conductor.currentBeat); Assert.areEqual(10, Conductor.instance.currentBeat);
Assert.areEqual(42, Conductor.currentStep); Assert.areEqual(42, Conductor.instance.currentStep);
FunkinAssert.areNear(42.0 + 12 / 60, Conductor.currentStepTime); FunkinAssert.areNear(42.0 + 12 / 60, Conductor.instance.currentStepTime);
step(); // 362 step(); // 362
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 362, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 362, Conductor.instance.songPosition);
Assert.areEqual(10, Conductor.currentBeat); Assert.areEqual(10, Conductor.instance.currentBeat);
Assert.areEqual(42, Conductor.currentStep); Assert.areEqual(42, Conductor.instance.currentStep);
FunkinAssert.areNear(42.0 + 24 / 60, Conductor.currentStepTime); FunkinAssert.areNear(42.0 + 24 / 60, Conductor.instance.currentStepTime);
step(3); // 365 step(3); // 365
FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 365, Conductor.songPosition); FunkinAssert.areNear(FunkinTest.MS_PER_STEP * 365, Conductor.instance.songPosition);
Assert.areEqual(10, Conductor.currentBeat); Assert.areEqual(10, Conductor.instance.currentBeat);
Assert.areEqual(43, Conductor.currentStep); // 42.999 => 42 Assert.areEqual(43, Conductor.instance.currentStep); // 42.999 => 42
FunkinAssert.areNear(43.0, Conductor.currentStepTime); FunkinAssert.areNear(43.0, Conductor.instance.currentStepTime);
} }
} }
@ -504,6 +504,6 @@ class ConductorState extends FlxState
super.update(elapsed); super.update(elapsed);
// On each step, increment the Conductor as though the song was playing. // On each step, increment the Conductor as though the song was playing.
Conductor.update(Conductor.songPosition + elapsed * Constants.MS_PER_SEC); Conductor.instance.update(Conductor.instance.songPosition + elapsed * Constants.MS_PER_SEC);
} }
} }

View file

@ -156,6 +156,7 @@ class MyTypeRegistry extends BaseRegistry<MyType, MyTypeData>
// JsonParser does not take type parameters, // JsonParser does not take type parameters,
// otherwise this function would be in BaseRegistry. // otherwise this function would be in BaseRegistry.
var parser = new json2object.JsonParser<MyTypeData>(); var parser = new json2object.JsonParser<MyTypeData>();
parser.ignoreUnknownVariables = false;
switch (loadEntryFile(id)) switch (loadEntryFile(id))
{ {
@ -181,6 +182,7 @@ class MyTypeRegistry extends BaseRegistry<MyType, MyTypeData>
// JsonParser does not take type parameters, // JsonParser does not take type parameters,
// otherwise this function would be in BaseRegistry. // otherwise this function would be in BaseRegistry.
var parser = new json2object.JsonParser<MyTypeData_v0_1_x>(); var parser = new json2object.JsonParser<MyTypeData_v0_1_x>();
parser.ignoreUnknownVariables = false;
switch (loadEntryFile(id)) switch (loadEntryFile(id))
{ {