remove ogg test

This commit is contained in:
Bui 2019-02-06 19:55:13 +00:00
parent 235a282d1e
commit 1fffb5fc13
2 changed files with 71 additions and 83 deletions

View File

@ -155,7 +155,6 @@ var assets = {
"bgm_result.mp3", "bgm_result.mp3",
"bgm_setsume.mp3" "bgm_setsume.mp3"
], ],
"audioOgg": "note_ka.ogg",
"fonts": [ "fonts": [
"Kozuka", "Kozuka",
"TnT" "TnT"

View File

@ -90,7 +90,7 @@ class Loader{
})) }))
this.afterJSCount = this.afterJSCount =
[assets.audioOgg, "blurPerformance", "P2Connection"].length + ["blurPerformance", "P2Connection"].length +
assets.fonts.length + assets.fonts.length +
assets.audioSfx.length + assets.audioSfx.length +
assets.audioMusic.length + assets.audioMusic.length +
@ -113,88 +113,80 @@ class Loader{
) )
snd.sfxLoudGain.setVolume(1.2) snd.sfxLoudGain.setVolume(1.2)
this.afterJSCount-- this.afterJSCount = 0
this.addPromise(snd.buffer.load(gameConfig.assets_baseurl + "audio/" + assets.audioOgg).then(() => { assets.fonts.forEach(name => {
this.oggNotSupported = false this.addPromise(new Promise(resolve => {
}, () => { FontDetect.onFontLoaded(name, resolve, resolve, {msTimeout: Infinity})
this.oggNotSupported = true
}).then(() => {
this.afterJSCount = 0
assets.fonts.forEach(name => {
this.addPromise(new Promise(resolve => {
FontDetect.onFontLoaded(name, resolve, resolve, {msTimeout: Infinity})
}))
})
assets.audioSfx.forEach(name => {
this.addPromise(this.loadSound(name, snd.sfxGain))
})
assets.audioMusic.forEach(name => {
this.addPromise(this.loadSound(name, snd.musicGain))
})
assets.audioSfxLR.forEach(name => {
this.addPromise(this.loadSound(name, snd.sfxGain).then(sound => {
var id = this.getFilename(name)
assets.sounds[id + "_p1"] = assets.sounds[id].copy(snd.sfxGainL)
assets.sounds[id + "_p2"] = assets.sounds[id].copy(snd.sfxGainR)
}))
})
assets.audioSfxLoud.forEach(name => {
this.addPromise(this.loadSound(name, snd.sfxLoudGain))
})
this.canvasTest = new CanvasTest()
this.addPromise(this.canvasTest.blurPerformance().then(result => {
perf.blur = result
if(result > 1000 / 50){
// Less than 50 fps with blur enabled
disableBlur = true
}
})) }))
})
p2 = new P2Connection()
if(location.hash.length === 6){ assets.audioSfx.forEach(name => {
p2.hashLock = true this.addPromise(this.loadSound(name, snd.sfxGain))
this.addPromise(new Promise(resolve => { })
p2.open() assets.audioMusic.forEach(name => {
pageEvents.add(p2, "message", response => { this.addPromise(this.loadSound(name, snd.musicGain))
if(response.type === "session"){ })
resolve() assets.audioSfxLR.forEach(name => {
}else if(response.type === "gameend"){ this.addPromise(this.loadSound(name, snd.sfxGain).then(sound => {
p2.hash("") var id = this.getFilename(name)
p2.hashLock = false assets.sounds[id + "_p1"] = assets.sounds[id].copy(snd.sfxGainL)
resolve() assets.sounds[id + "_p2"] = assets.sounds[id].copy(snd.sfxGainR)
} }))
}) })
p2.send("invite", location.hash.slice(1).toLowerCase()) assets.audioSfxLoud.forEach(name => {
setTimeout(() => { this.addPromise(this.loadSound(name, snd.sfxLoudGain))
if(p2.socket.readyState !== 1){ })
p2.hash("")
p2.hashLock = false this.canvasTest = new CanvasTest()
resolve() this.addPromise(this.canvasTest.blurPerformance().then(result => {
} perf.blur = result
}, 10000) if(result > 1000 / 50){
}).then(() => { // Less than 50 fps with blur enabled
pageEvents.remove(p2, "message") disableBlur = true
}))
}else{
p2.hash("")
} }
Promise.all(this.promises).then(() => {
this.canvasTest.drawAllImages().then(result => {
perf.allImg = result
perf.load = Date.now() - this.startTime
this.canvasTest.clean()
this.clean()
this.callback()
})
}, this.errorMsg.bind(this))
})) }))
p2 = new P2Connection()
if(location.hash.length === 6){
p2.hashLock = true
this.addPromise(new Promise(resolve => {
p2.open()
pageEvents.add(p2, "message", response => {
if(response.type === "session"){
resolve()
}else if(response.type === "gameend"){
p2.hash("")
p2.hashLock = false
resolve()
}
})
p2.send("invite", location.hash.slice(1).toLowerCase())
setTimeout(() => {
if(p2.socket.readyState !== 1){
p2.hash("")
p2.hashLock = false
resolve()
}
}, 10000)
}).then(() => {
pageEvents.remove(p2, "message")
}))
}else{
p2.hash("")
}
Promise.all(this.promises).then(() => {
this.canvasTest.drawAllImages().then(result => {
perf.allImg = result
perf.load = Date.now() - this.startTime
this.canvasTest.clean()
this.clean()
this.callback()
})
}, this.errorMsg.bind(this))
}) })
} }
@ -203,9 +195,6 @@ class Loader{
promise.then(this.assetLoaded.bind(this)) promise.then(this.assetLoaded.bind(this))
} }
loadSound(name, gain){ loadSound(name, gain){
if(this.oggNotSupported && name.endsWith(".ogg")){
name = name.slice(0, -4) + ".wav"
}
var id = this.getFilename(name) var id = this.getFilename(name)
return gain.load(gameConfig.assets_baseurl + "audio/" + name).then(sound => { return gain.load(gameConfig.assets_baseurl + "audio/" + name).then(sound => {
assets.sounds[id] = sound assets.sounds[id] = sound