diff --git a/buildnumber.txt b/buildnumber.txt index dfde4f32..28bffb95 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -1429 \ No newline at end of file +1431 \ No newline at end of file diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 182bfa0c..1c3caf2b 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -204,20 +204,16 @@ class PlayState extends MusicBeatState override public function create() { instance = this; + PauseSubState.script = ""; + if (FlxG.sound.music != null) FlxG.sound.music.stop(); - if (FlxG.sound.music != null) - FlxG.sound.music.stop(); - - scripts = new ScriptPack("PlayState"); - scripts.setParent(this); + (scripts = new ScriptPack("PlayState")).setParent(this); camGame = camera; - camHUD = new HudCamera(); + FlxG.cameras.add(camHUD = new HudCamera(), false); camHUD.bgColor.alpha = 0; - FlxG.cameras.add(camHUD, false); - downscroll = Options.downscroll; // camGame.widescreen = true; @@ -229,31 +225,19 @@ class PlayState extends MusicBeatState scrollSpeed = SONG.speed; - Conductor.reset(); - Conductor.mapBPMChanges(SONG); - Conductor.changeBPM(SONG.bpm); + Conductor.setupSong(SONG); #if desktop // TODO: Scriptable custom RPC iconRPC = SONG.player2; - // String that contains the mode defined here so it isn't necessary to call changePresence for each mode - if (isStoryMode) - { - detailsText = "Story Mode: " + storyWeek.name; - } - else - { - detailsText = "Freeplay"; - } + detailsText = isStoryMode ? ("Story Mode: " + storyWeek.name) : "Freeplay"; // Checks if cutscene files exists var cutscenePath = Paths.script('data/cutscenes/${SONG.song.toLowerCase()}'); var endCutscenePath = Paths.script('data/cutscenes/${SONG.song.toLowerCase()}-end'); - if (Assets.exists(cutscenePath)) - cutscene = cutscenePath; - if (Assets.exists(endCutscenePath)) - endCutscene = endCutscenePath; + if (Assets.exists(cutscenePath)) cutscene = cutscenePath; + if (Assets.exists(endCutscenePath)) endCutscene = endCutscenePath; // String for when the game is paused detailsPausedText = "Paused - " + detailsText; @@ -623,7 +607,7 @@ class PlayState extends MusicBeatState curSong = songData.song; inst = FlxG.sound.load(Paths.inst(PlayState.SONG.song)); - vocals = new FlxSound(); + vocals = FlxG.sound.list.recycle(FlxSound); if (SONG.needsVoices) vocals.loadEmbedded(Paths.voices(PlayState.SONG.song)); FlxG.sound.list.add(vocals); @@ -788,7 +772,7 @@ class PlayState extends MusicBeatState super.closeSubState(); } - var __wereVocalsPlaying:Bool = false; + var __songPlaying:Bool = false; var __wasAutoPause:Bool = false; override public function onFocus():Void { @@ -806,8 +790,10 @@ class PlayState extends MusicBeatState } } #end - if (__wasAutoPause && __wereVocalsPlaying) + if (__wasAutoPause && __songPlaying) { + inst.play(); vocals.play(); + } super.onFocus(); } @@ -822,7 +808,8 @@ class PlayState extends MusicBeatState } #end if (__wasAutoPause = FlxG.autoPause) { - __wereVocalsPlaying = vocals.playing; + __songPlaying = inst.playing; + inst.pause(); vocals.pause(); } diff --git a/source/funkin/system/Conductor.hx b/source/funkin/system/Conductor.hx index 32379449..9dc9bf61 100644 --- a/source/funkin/system/Conductor.hx +++ b/source/funkin/system/Conductor.hx @@ -88,6 +88,12 @@ class Conductor bpmChangeMap = []; changeBPM(0); } + + public static function setupSong(SONG:SwagSong) { + reset(); + mapBPMChanges(SONG); + changeBPM(SONG.bpm); + } /** * Maps BPM changes from a song. * @param song Song to map BPM changes from. diff --git a/source/funkin/system/MusicBeatState.hx b/source/funkin/system/MusicBeatState.hx index 58b9c9a5..0118a2bf 100644 --- a/source/funkin/system/MusicBeatState.hx +++ b/source/funkin/system/MusicBeatState.hx @@ -148,47 +148,7 @@ class MusicBeatState extends FlxUIState implements IBeatReceiver } call("update", [elapsed]); - #if sys - // 4 threads - var partLength = Math.ceil(members.length / 4); - var done = [for(i in 0...Main.gameThreads.length) false]; - for(part=>thread in Main.gameThreads) { - thread.events.run(function() { - var p:Int = part; - try { - var i:Int = partLength * p; - var num:Int = partLength * (p+1); - var basic:FlxBasic = null; - - while (i < num) - { - basic = members[i++]; - - if (basic != null && basic.exists && basic.active) - basic.update(elapsed); - } - done[p] = true; - } catch(e) { - trace(e); - done[p] = true; - } - }); - } - while(done.contains(false)) - Thread.current().events.wait(0.0001); - - if (tooltips != null) - tooltips.update(elapsed); - - if (_reload && _reload_countdown > 0) - { - _reload_countdown--; - if (_reload_countdown == 0) - reloadUI(); - } - #else super.update(elapsed); - #end } @:dox(hide) public function stepHit(curStep:Int):Void