From 1f24f79d0b0b0d1d0f898936db86c6993fe19e12 Mon Sep 17 00:00:00 2001 From: CharlesCatYT Date: Mon, 26 Feb 2024 21:02:51 -0500 Subject: [PATCH] well it doesnt work anyway --- source/backend/Difficulty.hx | 19 ++-- source/objects/MusicPlayer.hx | 148 ++++++++++++------------------ source/options/BaseOptionsMenu.hx | 13 +-- source/psychlua/LuaUtils.hx | 2 +- source/states/FreeplayState.hx | 104 +++++++++++++-------- source/states/PlayState.hx | 51 +++++----- 6 files changed, 158 insertions(+), 179 deletions(-) diff --git a/source/backend/Difficulty.hx b/source/backend/Difficulty.hx index a7862b2..4196b5e 100644 --- a/source/backend/Difficulty.hx +++ b/source/backend/Difficulty.hx @@ -8,22 +8,15 @@ class Difficulty 'Hard' ]; public static var list:Array = []; - private static var defaultDifficulty(default, never):String = 'Normal'; //The chart that has no suffix and starting difficulty on Freeplay/Story Mode + private static var defaultDifficulty(default, never):String = 'Normal'; //The chart that has no postfix and starting difficulty on Freeplay/Story Mode - inline public static function getFilePath(num:Null = null) - { + inline public static function getFilePath(num:Null = null) { if(num == null) num = PlayState.storyDifficulty; - var fileSuffix:String = list[num].toLowerCase(); - if(fileSuffix != defaultDifficulty.toLowerCase()) - { - fileSuffix = '-' + fileSuffix; - } - else - { - fileSuffix = ''; - } - return Paths.formatToSongPath(fileSuffix); + var filePostfix:String = list[num]; + if(Paths.formatToSongPath(filePostfix) != Paths.formatToSongPath(defaultDifficulty)) filePostfix = '-' + filePostfix; + else filePostfix = ''; + return Paths.formatToSongPath(filePostfix); } inline public static function loadFromWeek(week:WeekData = null) diff --git a/source/objects/MusicPlayer.hx b/source/objects/MusicPlayer.hx index 5af2b07..3496421 100644 --- a/source/objects/MusicPlayer.hx +++ b/source/objects/MusicPlayer.hx @@ -13,13 +13,12 @@ import states.FreeplayState; class MusicPlayer extends FlxGroup { public var instance:FreeplayState; + public var controls:Controls; public var playing(get, never):Bool; - public var paused(get, never):Bool; public var playingMusic:Bool = false; public var curTime:Float; - var songBG:FlxSprite; var songTxt:FlxText; var timeTxt:FlxText; @@ -27,36 +26,30 @@ class MusicPlayer extends FlxGroup var playbackBG:FlxSprite; var playbackSymbols:Array = []; var playbackTxt:FlxText; - var wasPlaying:Bool; - var holdPitchTime:Float = 0; var playbackRate(default, set):Float = 1; - public function new(instance:FreeplayState) { super(); this.instance = instance; + this.controls = instance.controls; var xPos:Float = FlxG.width * 0.7; songBG = new FlxSprite(xPos - 6, 0).makeGraphic(1, 100, 0xFF000000); songBG.alpha = 0.6; add(songBG); - playbackBG = new FlxSprite(xPos - 6, 0).makeGraphic(1, 100, 0xFF000000); playbackBG.alpha = 0.6; add(playbackBG); - songTxt = new FlxText(FlxG.width * 0.7, 5, 0, "", 32); songTxt.setFormat(Paths.font("vcr.ttf"), 32, FlxColor.WHITE, RIGHT); add(songTxt); - timeTxt = new FlxText(xPos, songTxt.y + 60, 0, "", 32); timeTxt.setFormat(Paths.font("vcr.ttf"), 32, FlxColor.WHITE, RIGHT); add(timeTxt); - for (i in 0...2) { var text:FlxText = new FlxText(); @@ -68,77 +61,62 @@ class MusicPlayer extends FlxGroup playbackSymbols.push(text); add(text); } - progressBar = new FlxBar(timeTxt.x, timeTxt.y + timeTxt.height, LEFT_TO_RIGHT, Std.int(timeTxt.width), 8, null, "", 0, Math.POSITIVE_INFINITY); progressBar.createFilledBar(FlxColor.WHITE, FlxColor.BLACK); add(progressBar); - playbackTxt = new FlxText(FlxG.width * 0.6, 20, 0, "", 32); playbackTxt.setFormat(Paths.font("vcr.ttf"), 32, FlxColor.WHITE); add(playbackTxt); - switchPlayMusic(); } - override function update(elapsed:Float) { super.update(elapsed); - if (!playingMusic) { return; } - if (paused && !wasPlaying) - songTxt.text = 'PLAYING: ' + instance.songs[FreeplayState.curSelected].songName + ' (PAUSED)'; - else + if (playing && !wasPlaying) songTxt.text = 'PLAYING: ' + instance.songs[FreeplayState.curSelected].songName; + else + songTxt.text = 'PLAYING: ' + instance.songs[FreeplayState.curSelected].songName + ' (PAUSED)'; - positionSong(); + if(FlxG.keys.justPressed.K) trace('Time: ${FreeplayState.vocals.time}, Playing: ${FreeplayState.vocals.playing}'); - if (instance.controls.UI_LEFT_P) + if (controls.UI_LEFT_P) { if (playing) wasPlaying = true; - pauseOrResume(); - curTime = FlxG.sound.music.time - 1000; instance.holdTime = 0; - if (curTime < 0) curTime = 0; FlxG.sound.music.time = curTime; - if (FreeplayState.vocals != null) - FreeplayState.vocals.time = curTime; + setVocalsTime(curTime); } - if (instance.controls.UI_RIGHT_P) + if (controls.UI_RIGHT_P) { if (playing) wasPlaying = true; - pauseOrResume(); - curTime = FlxG.sound.music.time + 1000; instance.holdTime = 0; - if (curTime > FlxG.sound.music.length) curTime = FlxG.sound.music.length; FlxG.sound.music.time = curTime; - if (FreeplayState.vocals != null) - FreeplayState.vocals.time = curTime; + setVocalsTime(curTime); } - - updateTimeTxt(); - if(instance.controls.UI_LEFT || instance.controls.UI_RIGHT) + if(controls.UI_LEFT || controls.UI_RIGHT) { instance.holdTime += elapsed; if(instance.holdTime > 0.5) { - curTime += 40000 * elapsed * (instance.controls.UI_LEFT ? -1 : 1); + curTime += 40000 * elapsed * (controls.UI_LEFT ? -1 : 1); } var difference:Float = Math.abs(curTime - FlxG.sound.music.time); @@ -146,78 +124,91 @@ class MusicPlayer extends FlxGroup else if(curTime - difference < 0) curTime = 0; FlxG.sound.music.time = curTime; - if (FreeplayState.vocals != null) - FreeplayState.vocals.time = curTime; - - updateTimeTxt(); + setVocalsTime(curTime); } - if(instance.controls.UI_LEFT_R || instance.controls.UI_RIGHT_R) + if(controls.UI_LEFT_R || controls.UI_RIGHT_R) { FlxG.sound.music.time = curTime; - if (FreeplayState.vocals != null) - FreeplayState.vocals.time = curTime; + setVocalsTime(curTime); if (wasPlaying) { pauseOrResume(true); wasPlaying = false; } - - updateTimeTxt(); } - if (instance.controls.UI_UP_P) + if (controls.UI_UP_P) { holdPitchTime = 0; playbackRate += 0.05; setPlaybackRate(); } - else if (instance.controls.UI_DOWN_P) + else if (controls.UI_DOWN_P) { holdPitchTime = 0; playbackRate -= 0.05; setPlaybackRate(); } - if (instance.controls.UI_DOWN || instance.controls.UI_UP) + if (controls.UI_DOWN || controls.UI_UP) { holdPitchTime += elapsed; if (holdPitchTime > 0.6) { - playbackRate += 0.05 * (instance.controls.UI_UP ? 1 : -1); + playbackRate += 0.05 * (controls.UI_UP ? 1 : -1); setPlaybackRate(); } } - if (FreeplayState.vocals != null && FlxG.sound.music.time > 5) + + if (controls.RESET) { - var difference:Float = Math.abs(FlxG.sound.music.time - FreeplayState.vocals.time); - if (difference >= 5 && !paused) + playbackRate = 1; + setPlaybackRate(); + + FlxG.sound.music.time = 0; + setVocalsTime(0); + } + + if (playing) + { + if(FreeplayState.vocals != null) + FreeplayState.vocals.volume = (FreeplayState.vocals.length > FlxG.sound.music.time) ? 0.8 : 0; + if(FreeplayState.opponentVocals != null) + FreeplayState.opponentVocals.volume = (FreeplayState.opponentVocals.length > FlxG.sound.music.time) ? 0.8 : 0; + + if((FreeplayState.vocals != null && FreeplayState.vocals.length > FlxG.sound.music.time && Math.abs(FlxG.sound.music.time - FreeplayState.vocals.time) >= 25) || + (FreeplayState.opponentVocals != null && FreeplayState.opponentVocals.length > FlxG.sound.music.time && Math.abs(FlxG.sound.music.time - FreeplayState.opponentVocals.time) >= 25)) { pauseOrResume(); - FreeplayState.vocals.time = FlxG.sound.music.time; + setVocalsTime(FlxG.sound.music.time); pauseOrResume(true); } } - updatePlaybackTxt(); - - if(instance.controls.RESET){ - playbackRate = 1; - setPlaybackRate(); - FlxG.sound.music.time = 0; - if(FreeplayState.vocals != null) FreeplayState.vocals.time = 0; + positionSong(); + updateTimeTxt(); + updatePlaybackTxt(); + } - updateTimeTxt(); - } + function setVocalsTime(time:Float) + { + if (FreeplayState.vocals != null && FreeplayState.vocals.length > time) + FreeplayState.vocals.time = time; + if (FreeplayState.opponentVocals != null && FreeplayState.opponentVocals.length > time) + FreeplayState.opponentVocals.time = time; } public function pauseOrResume(resume:Bool = false) { if (resume) { - FlxG.sound.music.resume(); + if(!FlxG.sound.music.playing) + FlxG.sound.music.resume(); - if (FreeplayState.vocals != null) + if (FreeplayState.vocals != null && FreeplayState.vocals.length > FlxG.sound.music.time && !FreeplayState.vocals.playing) FreeplayState.vocals.resume(); + if (FreeplayState.opponentVocals != null && FreeplayState.opponentVocals.length > FlxG.sound.music.time && !FreeplayState.opponentVocals.playing) + FreeplayState.opponentVocals.resume(); } else { @@ -225,18 +216,17 @@ class MusicPlayer extends FlxGroup if (FreeplayState.vocals != null) FreeplayState.vocals.pause(); + if (FreeplayState.opponentVocals != null) + FreeplayState.opponentVocals.pause(); } - positionSong(); } public function switchPlayMusic() { FlxG.autoPause = (!playingMusic && ClientPrefs.data.autoPause); active = visible = playingMusic; - instance.scoreBG.visible = instance.diffText.visible = instance.scoreText.visible = !playingMusic; //Hide Freeplay texts and boxes if playingMusic is true songTxt.visible = timeTxt.visible = songBG.visible = playbackTxt.visible = playbackBG.visible = progressBar.visible = playingMusic; //Show Music Player texts and boxes if playingMusic is true - for (i in playbackSymbols) i.visible = playingMusic; @@ -244,16 +234,14 @@ class MusicPlayer extends FlxGroup instance.holdTime = 0; playbackRate = 1; updatePlaybackTxt(); - if (playingMusic) { - instance.bottomText.text = "[SPACE] - Pause / [ESCAPE] - Exit / [R] - Reset the Song"; + instance.bottomText.text = "Press SPACE to Pause / Press ESCAPE to Exit / Press R to Reset the Song"; positionSong(); progressBar.setRange(0, FlxG.sound.music.length); progressBar.setParent(FlxG.sound.music, "time"); progressBar.numDivisions = 1600; - updateTimeTxt(); } else @@ -261,13 +249,11 @@ class MusicPlayer extends FlxGroup progressBar.setRange(0, Math.POSITIVE_INFINITY); progressBar.setParent(null, ""); progressBar.numDivisions = 0; - instance.bottomText.text = instance.bottomString; instance.positionHighscore(); } progressBar.updateBar(); } - function updatePlaybackTxt() { var text = ""; @@ -278,12 +264,10 @@ class MusicPlayer extends FlxGroup var playbackRate = Std.string(playbackRate); if (playbackRate.split('.')[1].length < 2) // Playback rates for like 1.1, 1.2 etc playbackRate += '0'; - text = playbackRate; } playbackTxt.text = text + 'x'; } - function positionSong() { var length:Int = instance.songs[FreeplayState.curSelected].songName.length; @@ -299,14 +283,11 @@ class MusicPlayer extends FlxGroup timeTxt.x -= timeTxt.width / 2; if (shortName) timeTxt.x -= length - 5; - playbackBG.scale.x = playbackTxt.width + 30; playbackBG.x = songBG.x - (songBG.scale.x / 2); playbackBG.x -= playbackBG.scale.x; - playbackTxt.x = playbackBG.x - playbackTxt.width / 2; playbackTxt.y = playbackTxt.height; - progressBar.setGraphicSize(Std.int(songTxt.width), 5); progressBar.y = songTxt.y + songTxt.height + 10; progressBar.x = songTxt.x + songTxt.width / 2 - 15; @@ -315,31 +296,29 @@ class MusicPlayer extends FlxGroup progressBar.scale.x += length / 2; progressBar.x -= length - 10; } - for (i in 0...2) { var text = playbackSymbols[i]; text.x = playbackTxt.x + playbackTxt.width / 2 - 10; text.y = playbackTxt.y; - if (i == 0) text.y -= playbackTxt.height; else text.y += playbackTxt.height; } } - function updateTimeTxt() { var text = FlxStringUtil.formatTime(FlxG.sound.music.time / 1000, false) + ' / ' + FlxStringUtil.formatTime(FlxG.sound.music.length / 1000, false); timeTxt.text = '< ' + text + ' >'; } - function setPlaybackRate() { FlxG.sound.music.pitch = playbackRate; if (FreeplayState.vocals != null) FreeplayState.vocals.pitch = playbackRate; + if (FreeplayState.opponentVocals != null) + FreeplayState.opponentVocals.pitch = playbackRate; } function get_playing():Bool @@ -347,18 +326,11 @@ class MusicPlayer extends FlxGroup return FlxG.sound.music.playing; } - function get_paused():Bool - { - @:privateAccess return FlxG.sound.music._paused; - } - function set_playbackRate(value:Float):Float { var value = FlxMath.roundDecimal(value, 2); - if (value > 3) - value = 3; - else if (value <= 0.25) - value = 0.25; + if (value > 3) value = 3; + else if (value <= 0.25) value = 0.25; return playbackRate = value; } } \ No newline at end of file diff --git a/source/options/BaseOptionsMenu.hx b/source/options/BaseOptionsMenu.hx index b2757ea..b94aa96 100644 --- a/source/options/BaseOptionsMenu.hx +++ b/source/options/BaseOptionsMenu.hx @@ -471,25 +471,20 @@ class BaseOptionsMenu extends MusicBeatSubstate function changeSelection(change:Int = 0) { - curSelected += change; - if (curSelected < 0) - curSelected = optionsArray.length - 1; - else if (curSelected >= optionsArray.length) - curSelected = 0; + curSelected = FlxMath.wrap(curSelected + change, 0, optionsArray.length - 1); descText.text = optionsArray[curSelected].description; descText.screenCenter(Y).y += 270; var bullShit:Int = 0; - for (item in grpOptions.members) + for (num => item in grpOptions.members) { - item.targetY = bullShit - curSelected; - bullShit++; - + item.targetY = num - curSelected; item.alpha = 0.6; if (item.targetY == 0) item.alpha = 1; } + for (text in grpTexts) { text.alpha = 0.6; diff --git a/source/psychlua/LuaUtils.hx b/source/psychlua/LuaUtils.hx index fa0f5a5..0f24600 100644 --- a/source/psychlua/LuaUtils.hx +++ b/source/psychlua/LuaUtils.hx @@ -429,7 +429,7 @@ class LuaUtils case 'sineout': return FlxEase.sineOut; case 'smoothstepin': return FlxEase.smoothStepIn; case 'smoothstepinout': return FlxEase.smoothStepInOut; - case 'smoothstepout': return FlxEase.smoothStepInOut; + case 'smoothstepout': return FlxEase.smoothStepOut; case 'smootherstepin': return FlxEase.smootherStepIn; case 'smootherstepinout': return FlxEase.smootherStepInOut; case 'smootherstepout': return FlxEase.smootherStepOut; diff --git a/source/states/FreeplayState.hx b/source/states/FreeplayState.hx index f3e40cf..ba15de4 100644 --- a/source/states/FreeplayState.hx +++ b/source/states/FreeplayState.hx @@ -223,6 +223,7 @@ class FreeplayState extends MusicBeatState { var wasPlaying:Bool; var instPlaying:Int = -1; public static var vocals:FlxSound = null; + public static var opponentVocals:FlxSound = null; var holdTime:Float = 0; var holdPitchTime:Float = 0; var playbackRate(default, set):Float = 1; @@ -336,29 +337,55 @@ class FreeplayState extends MusicBeatState { var poop:String = Highscore.formatSong(songs[curSelected].songName.toLowerCase(), curDifficulty); PlayState.SONG = Song.loadFromJson(poop, songs[curSelected].songName.toLowerCase()); Conductor.bpm = PlayState.SONG.bpm; - if(PlayState.SONG.needsVoices){ - vocals = new FlxSound().loadEmbedded(Paths.voices(PlayState.SONG.song)); - FlxG.sound.list.add(vocals); - vocals.persist = true; - vocals.looped = true; - } - else if(vocals != null){ - vocals.stop(); - vocals.destroy(); - vocals = null; + if (PlayState.SONG.needsVoices) { + vocals = new FlxSound(); + try { + var playerVocals:String = getVocalFromCharacter(PlayState.SONG.player1); + var loadedVocals = Paths.voices(PlayState.SONG.song, (playerVocals != null && playerVocals.length > 0) ? playerVocals : 'Player'); + if (loadedVocals == null) loadedVocals = Paths.voices(PlayState.SONG.song); + + if (loadedVocals != null && loadedVocals.length > 0) { + vocals.loadEmbedded(loadedVocals); + FlxG.sound.list.add(vocals); + vocals.persist = vocals.looped = true; + vocals.volume = 0.8; + vocals.play(); + vocals.pause(); + } + else vocals = FlxDestroyUtil.destroy(vocals); + } + catch (e:Dynamic) {vocals = FlxDestroyUtil.destroy(vocals);} + + opponentVocals = new FlxSound(); + try { + // trace('please work...'); + var oppVocals:String = getVocalFromCharacter(PlayState.SONG.player2); + var loadedVocals = Paths.voices(PlayState.SONG.song, (oppVocals != null && oppVocals.length > 0) ? oppVocals : 'Opponent'); + + if (loadedVocals != null && loadedVocals.length > 0) { + opponentVocals.loadEmbedded(loadedVocals); + FlxG.sound.list.add(opponentVocals); + opponentVocals.persist = opponentVocals.looped = true; + opponentVocals.volume = 0.8; + opponentVocals.play(); + opponentVocals.pause(); + // trace('yaaay!!'); + } + else opponentVocals = FlxDestroyUtil.destroy(opponentVocals); + } + catch (e:Dynamic){opponentVocals = FlxDestroyUtil.destroy(opponentVocals);} } FlxG.sound.playMusic(Paths.inst(PlayState.SONG.song), 0.8); - if(vocals != null){ // Sync vocals to Inst - vocals.play(); - vocals.volume = 0.8; - } + FlxG.sound.music.pause(); instPlaying = curSelected; player.playingMusic = true; player.curTime = 0; player.switchPlayMusic(); + player.pauseOrResume(true); } + else if (instPlaying == curSelected && player.playingMusic) player.pauseOrResume(!player.playing); } else if(controls.ACCEPT && !player.playingMusic){ persistentUpdate = false; @@ -419,12 +446,21 @@ class FreeplayState extends MusicBeatState { updateIconsScale(elapsed); } - public static function destroyFreeplayVocals() { - if(vocals != null) { - vocals.stop(); - vocals.destroy(); + function getVocalFromCharacter(char:String) { + try { + var path:String = Paths.getPath('characters/$char.json', TEXT, null, true); + var character:Dynamic = #if MODS_ALLOWED Json.parse(File.getContent(path)); #else Json.parse(Assets.getText(path)); #end + return character.vocals_file; } - vocals = null; + return null; + } + + public static function destroyFreeplayVocals() { + if(vocals != null) vocals.stop(); + vocals = FlxDestroyUtil.destroy(vocals); + + if(opponentVocals != null) opponentVocals.stop(); + opponentVocals = FlxDestroyUtil.destroy(opponentVocals); } function setPlaybackRate() { @@ -452,8 +488,7 @@ class FreeplayState extends MusicBeatState { missingTextBG.visible = false; } - function changeSelection(change:Int = 0, playSound:Bool = true) - { + function changeSelection(change:Int = 0, playSound:Bool = true) { if(player.playingMusic) return; _updateSongLastDifficulty(); @@ -467,14 +502,10 @@ class FreeplayState extends MusicBeatState { var newColor:Int = songs[curSelected].color; if(newColor != intendedColor) { - if(colorTween != null) { - colorTween.cancel(); - } + if(colorTween != null) colorTween.cancel(); intendedColor = newColor; colorTween = FlxTween.color(bg, 1, bg.color, intendedColor, { - onComplete: function(twn:FlxTween) { - colorTween = null; - } + onComplete: function(twn:FlxTween) {colorTween = null;} }); } @@ -508,9 +539,7 @@ class FreeplayState extends MusicBeatState { _updateSongLastDifficulty(); } - inline private function _updateSongLastDifficulty() { - songs[curSelected].lastDifficulty = Difficulty.getString(curDifficulty); - } + inline private function _updateSongLastDifficulty() songs[curSelected].lastDifficulty = Difficulty.getString(curDifficulty); private function positionHighscore() { scoreText.x = FlxG.width - scoreText.width - 6; @@ -535,8 +564,7 @@ class FreeplayState extends MusicBeatState { override function beatHit() { - if (player.playingMusic && !player.paused) - { + if (player.playingMusic && !player.paused) { var icon:HealthIcon = iconArray[curSelected]; icon.scale.set(1.2, 1.2); icon.updateHitbox(); @@ -548,8 +576,7 @@ class FreeplayState extends MusicBeatState { override function sectionHit() { if (PlayState.SONG.notes[curSection] != null) - if (PlayState.SONG.notes[curSection].changeBPM) - Conductor.bpm = PlayState.SONG.notes[curSection].bpm; + if (PlayState.SONG.notes[curSection].changeBPM) Conductor.bpm = PlayState.SONG.notes[curSection].bpm; super.sectionHit(); } @@ -579,8 +606,7 @@ class FreeplayState extends MusicBeatState { } } - override function destroy():Void - { + override function destroy():Void { super.destroy(); FlxG.autoPause = ClientPrefs.data.autoPause; @@ -595,8 +621,7 @@ class FreeplayState extends MusicBeatState { } } -class SongMetadata -{ +class SongMetadata { public var songName:String = ""; public var week:Int = 0; public var songCharacter:String = ""; @@ -604,8 +629,7 @@ class SongMetadata public var folder:String = ""; public var lastDifficulty:String = null; - public function new(song:String, week:Int, songCharacter:String, color:Int) - { + public function new(song:String, week:Int, songCharacter:String, color:Int) { this.songName = song; this.week = week; this.songCharacter = songCharacter; diff --git a/source/states/PlayState.hx b/source/states/PlayState.hx index 3da50cb..b484a09 100644 --- a/source/states/PlayState.hx +++ b/source/states/PlayState.hx @@ -1304,7 +1304,7 @@ class PlayState extends MusicBeatState vocals.play(); opponentVocals.play(); - if(startOnTime > 0) setSongTime(startOnTime - 500); + setSongTime(Math.max(0, startOnTime - 500)); startOnTime = 0; if(paused) { @@ -1751,30 +1751,31 @@ class PlayState extends MusicBeatState if(ret != FunkinLua.Function_Stop) openPauseMenu(); } - if(!endingSong && !inCutscene && !SONG.disableDebugButtons) - { - if (controls.justPressed('debug_1')) - openChartEditor(); - else if (controls.justPressed('debug_2')) - openCharacterEditor(); + if(!endingSong && !inCutscene && !SONG.disableDebugButtons) { + if (controls.justPressed('debug_1')) openChartEditor(); + else if (controls.justPressed('debug_2')) openCharacterEditor(); } - if (healthBar.bounds.max != null && health > healthBar.bounds.max) - health = healthBar.bounds.max; + if (healthBar.bounds.max != null && health > healthBar.bounds.max) health = healthBar.bounds.max; updateIcons(elapsed); - if (startedCountdown && !paused) { + if (startedCountdown && !paused) + { Conductor.songPosition += elapsed * 1000 * playbackRate; - if (checkIfDesynced) { - var diff:Float = 20 * playbackRate; - var timeSub:Float = Conductor.songPosition - Conductor.offset; - if (Math.abs(FlxG.sound.music.time - timeSub) > diff - || (vocals.length > 0 && Math.abs(vocals.time - timeSub) > diff) - || (opponentVocals.length > 0 && Math.abs(opponentVocals.time - timeSub) > diff)) { - resyncVocals(); + if (Conductor.songPosition >= 0) { + var timeDiff:Float = Math.abs(FlxG.sound.music.time - Conductor.songPosition - Conductor.offset); + if(timeDiff > 15 * playbackRate) + Conductor.songPosition = FlxMath.lerp(Conductor.songPosition, FlxG.sound.music.time, FlxMath.bound(elapsed * 10, 0, 1)); + + if (timeDiff > 25 * playbackRate) trace('Warning! Delay is too fucking high!!'); + + #if debug + if(FlxG.keys.justPressed.K) { + trace('Times: ' + FlxG.sound.music.time, vocals.time, opponentVocals.time); + trace('Difference: ' + (FlxG.sound.music.time - Conductor.songPosition)); } - checkIfDesynced = false; + #end } } @@ -1797,7 +1798,7 @@ class PlayState extends MusicBeatState timeTxt.text = '${FlxStringUtil.formatTime(secondsTotal, false)}${(ClientPrefs.data.timeBarType.contains('/')) ? ' / ${FlxStringUtil.formatTime(songLength / 1000, false)}' : ''}'; } - if(camZooming){ + if(camZooming) { FlxG.camera.zoom = FlxMath.lerp(defaultCamZoom, FlxG.camera.zoom, Math.exp(-elapsed * 3.125 * camZoomingDecay * playbackRate)); camHUD.zoom = FlxMath.lerp(1, camHUD.zoom, Math.exp(-elapsed * 3.125 * camZoomingDecay * playbackRate)); } @@ -1810,7 +1811,6 @@ class PlayState extends MusicBeatState if(!ClientPrefs.data.noReset && controls.RESET && canReset && !inCutscene && startedCountdown && !endingSong){ //doDeathCheck(true); health = 0; - //trace("RESET = True"); } doDeathCheck(); @@ -1868,8 +1868,7 @@ class PlayState extends MusicBeatState // Kill extremely late notes and cause misses if (Conductor.songPosition - daNote.strumTime > noteKillOffset) { - if (daNote.mustPress && !cpuControlled && !daNote.ignoreNote && !endingSong && (daNote.tooLate || !daNote.wasGoodHit)) - noteMiss(daNote); + if (daNote.mustPress && !cpuControlled && !daNote.ignoreNote && !endingSong && (daNote.tooLate || !daNote.wasGoodHit)) noteMiss(daNote); daNote.active = daNote.visible = false; invalidateNote(daNote); @@ -1878,8 +1877,7 @@ class PlayState extends MusicBeatState } else { - notes.forEachAlive(function(daNote:Note) - { + notes.forEachAlive((daNote:Note) -> { daNote.canBeHit = false; daNote.wasGoodHit = false; }); @@ -3177,13 +3175,10 @@ class PlayState extends MusicBeatState FlxG.sound.music.fadeTween = null; } - var checkIfDesynced:Bool = false; var lastStepHit:Int = -1; override function stepHit() { - if (SONG.needsVoices && FlxG.sound.music.time >= -ClientPrefs.data.noteOffset) checkIfDesynced = true; - - super.stepHit(); + super.stepHit(); if(curStep == lastStepHit) return;