Merge pull request #81 from WorstAquaPlayer/master

Slightly more accurate and smooth Song Position bar
This commit is contained in:
Kade M 2021-03-28 19:46:15 -07:00 committed by GitHub
commit a78b74d2f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -67,11 +67,12 @@ class PlayState extends MusicBeatState
var halloweenLevel:Bool = false; var halloweenLevel:Bool = false;
var songLength:Float = 0;
#if desktop #if desktop
// Discord RPC variables // Discord RPC variables
var storyDifficultyText:String = ""; var storyDifficultyText:String = "";
var iconRPC:String = ""; var iconRPC:String = "";
var songLength:Float = 0;
var detailsText:String = ""; var detailsText:String = "";
var detailsPausedText:String = ""; var detailsPausedText:String = "";
#end #end
@ -1139,6 +1140,9 @@ class PlayState extends MusicBeatState
FlxG.sound.music.onComplete = endSong; FlxG.sound.music.onComplete = endSong;
vocals.play(); vocals.play();
// Song duration in a float, useful for the time left feature
songLength = FlxG.sound.music.length;
if (FlxG.save.data.songPosition) if (FlxG.save.data.songPosition)
{ {
remove(songPosBG); remove(songPosBG);
@ -1153,7 +1157,8 @@ class PlayState extends MusicBeatState
add(songPosBG); add(songPosBG);
songPosBar = new FlxBar(songPosBG.x + 4, songPosBG.y + 4, LEFT_TO_RIGHT, Std.int(songPosBG.width - 8), Std.int(songPosBG.height - 8), this, songPosBar = new FlxBar(songPosBG.x + 4, songPosBG.y + 4, LEFT_TO_RIGHT, Std.int(songPosBG.width - 8), Std.int(songPosBG.height - 8), this,
'songPositionBar', 0, 90000); 'songPositionBar', 0, songLength - 1000);
songPosBar.numDivisions = 1000;
songPosBar.scrollFactor.set(); songPosBar.scrollFactor.set();
songPosBar.createFilledBar(FlxColor.GRAY, FlxColor.LIME); songPosBar.createFilledBar(FlxColor.GRAY, FlxColor.LIME);
add(songPosBar); add(songPosBar);
@ -1171,9 +1176,6 @@ class PlayState extends MusicBeatState
} }
#if desktop #if desktop
// Song duration in a float, useful for the time left feature
songLength = FlxG.sound.music.length;
// Updating Discord Rich Presence (with Time Left) // Updating Discord Rich Presence (with Time Left)