Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions source/engine/backend/BaseStage.hx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ enum Countdown
START;
}

@:nullSafety
class BaseStage extends FlxBasic
{
private var game(get, never):Dynamic;
Expand Down
4 changes: 3 additions & 1 deletion source/engine/backend/ClientPrefs.hx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import flixel.input.gamepad.FlxGamepadInputID;
import states.TitleState;

// Add a variable here and it will get automatically saved
@:structInit class SaveVariables
@:structInit
@:nullSafety
class SaveVariables
{
// Mobile and Mobile Controls Releated
public var extraButtons:String = "NONE"; // mobile extra button option
Expand Down
26 changes: 15 additions & 11 deletions source/engine/backend/Conductor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ typedef BPMChangeEvent =
@:optional var stepCrochet:Float;
}

@:nullSafety
class Conductor
{
public static var bpm(default, set):Float = 100;
Expand All @@ -25,13 +26,16 @@ class Conductor

public static var bpmChangeMap:Array<BPMChangeEvent> = [];

public static function getCrotchetAtTime(time:Float)
inline static function getStepCrochet(event:BPMChangeEvent):Float
return event.stepCrochet ?? stepCrochet;

public static function getCrotchetAtTime(time:Float):Float
{
var lastChange = getBPMFromSeconds(time);
return lastChange.stepCrochet * 4;
return getStepCrochet(lastChange) * 4;
}

public static function getBPMFromSeconds(time:Float)
public static function getBPMFromSeconds(time:Float):BPMChangeEvent
{
var lastChange:BPMChangeEvent = {
stepTime: 0,
Expand All @@ -48,7 +52,7 @@ class Conductor
return lastChange;
}

public static function getBPMFromStep(step:Float)
public static function getBPMFromStep(step:Float):BPMChangeEvent
{
var lastChange:BPMChangeEvent = {
stepTime: 0,
Expand All @@ -69,19 +73,19 @@ class Conductor
{
var step = beat * 4;
var lastChange = getBPMFromStep(step);
return lastChange.songTime + (step - lastChange.stepTime) * (lastChange.stepCrochet / 1000);
return lastChange.songTime + (step - lastChange.stepTime) * (getStepCrochet(lastChange) / 1000);
}

public static function getStep(time:Float)
public static function getStep(time:Float):Float
{
var lastChange = getBPMFromSeconds(time);
return lastChange.stepTime + (time - lastChange.songTime) / lastChange.stepCrochet;
return lastChange.stepTime + (time - lastChange.songTime) / getStepCrochet(lastChange);
}

public static function getStepRounded(time:Float)
public static function getStepRounded(time:Float):Float
{
var lastChange = getBPMFromSeconds(time);
return lastChange.stepTime + Math.floor(time - lastChange.songTime) / lastChange.stepCrochet;
return lastChange.stepTime + Math.floor(time - lastChange.songTime) / getStepCrochet(lastChange);
}

public static function getBeat(time:Float)
Expand Down Expand Up @@ -122,12 +126,12 @@ class Conductor
//trace("new BPM map BUDDY " + bpmChangeMap);
}

static function getSectionBeats(song:SwagSong, section:Int)
static function getSectionBeats(song:SwagSong, section:Int):Float
{
var val:Null<Float> = null;
if (song.notes[section] != null)
val = song.notes[section].sectionBeats;
return val != null ? val : 4;
return val ?? 4;
}

inline public static function calculateCrochet(bpm:Float)
Expand Down
Loading