From 9f7ce52cb4ad81d44761f3265c89761506c30221 Mon Sep 17 00:00:00 2001 From: Bui Date: Tue, 24 Dec 2019 19:37:10 +0000 Subject: [PATCH] only load combo voices as needed --- public/src/js/assets.js | 52 ------------------------------------- public/src/js/controller.js | 17 ++++++++++++ 2 files changed, 17 insertions(+), 52 deletions(-) diff --git a/public/src/js/assets.js b/public/src/js/assets.js index 10967a6..dd94554 100644 --- a/public/src/js/assets.js +++ b/public/src/js/assets.js @@ -109,58 +109,6 @@ var assets = { "se_results_countup.wav", "se_results_crown.wav", - "v_combo_50.wav", - "v_combo_100.wav", - "v_combo_200.wav", - "v_combo_300.wav", - "v_combo_400.wav", - "v_combo_500.wav", - "v_combo_600.wav", - "v_combo_700.wav", - "v_combo_800.wav", - "v_combo_900.wav", - "v_combo_1000.wav", - "v_combo_1100.wav", - "v_combo_1200.wav", - "v_combo_1300.wav", - "v_combo_1400.wav", - "v_combo_1500.wav", - "v_combo_1600.wav", - "v_combo_1700.wav", - "v_combo_1800.wav", - "v_combo_1900.wav", - "v_combo_2000.wav", - "v_combo_2100.wav", - "v_combo_2200.wav", - "v_combo_2300.wav", - "v_combo_2400.wav", - "v_combo_2500.wav", - "v_combo_2600.wav", - "v_combo_2700.wav", - "v_combo_2800.wav", - "v_combo_2900.wav", - "v_combo_3000.wav", - "v_combo_3100.wav", - "v_combo_3200.wav", - "v_combo_3300.wav", - "v_combo_3400.wav", - "v_combo_3500.wav", - "v_combo_3600.wav", - "v_combo_3700.wav", - "v_combo_3800.wav", - "v_combo_3900.wav", - "v_combo_4000.wav", - "v_combo_4100.wav", - "v_combo_4200.wav", - "v_combo_4300.wav", - "v_combo_4400.wav", - "v_combo_4500.wav", - "v_combo_4600.wav", - "v_combo_4700.wav", - "v_combo_4800.wav", - "v_combo_4900.wav", - "v_combo_5000.wav", - "v_fullcombo.wav", "v_renda.wav", "v_results_fullcombo.wav", diff --git a/public/src/js/controller.js b/public/src/js/controller.js index d1d683d..2f922a0 100644 --- a/public/src/js/controller.js +++ b/public/src/js/controller.js @@ -27,6 +27,23 @@ class Controller{ this.parsedSongData = new ParseOsu(songData, selectedSong.difficulty, selectedSong.stars, selectedSong.offset) } this.offset = this.parsedSongData.soundOffset + + var maxCombo = this.parsedSongData.circles.filter(circle => ["don", "ka", "daiDon", "daiKa"].indexOf(circle.type) > -1 && (!circle.branch || circle.branch.name == "master")).length + if (maxCombo >= 50) { + var comboVoices = ["v_combo_50"].concat([...Array(Math.floor(maxCombo/100)).keys()].map(i => "v_combo_" + (i + 1)*100)) + var promises = [] + + comboVoices.forEach(name => { + if (!assets.sounds[name + "_p1"]) { + promises.push(loader.loadSound(name + ".wav", snd.sfxGain).then(sound => { + assets.sounds[name + "_p1"] = assets.sounds[name].copy(snd.sfxGainL) + assets.sounds[name + "_p2"] = assets.sounds[name].copy(snd.sfxGainR) + })) + } + }) + + Promise.all(this.promises) + } if(this.calibrationMode){ this.volume = 1