Disable multiplayer for local song select

This commit is contained in:
LoveEevee 2018-12-06 00:23:00 +03:00
parent a435ed1a6d
commit f6660a8de0

View File

@ -211,7 +211,7 @@ class SongSelect{
this.selectedDiff = 0 this.selectedDiff = 0
assets.sounds["bgm_songsel"].playLoop(0.1, false, 0, 1.442, 3.506) assets.sounds["bgm_songsel"].playLoop(0.1, false, 0, 1.442, 3.506)
if(!fromTutorial && !("selectedSong" in localStorage)){ if(!assets.customSongs && !fromTutorial && !("selectedSong" in localStorage)){
fromTutorial = touchEnabled ? "about" : "tutorial" fromTutorial = touchEnabled ? "about" : "tutorial"
} }
if(p2.session){ if(p2.session){
@ -442,7 +442,7 @@ class SongSelect{
var mouse = this.mouseOffset(event.offsetX, event.offsetY) var mouse = this.mouseOffset(event.offsetX, event.offsetY)
var moveTo = null var moveTo = null
if(this.state.screen === "song"){ if(this.state.screen === "song"){
if(mouse.x > 641 && mouse.y > 603 && p2.socket.readyState === 1){ if(mouse.x > 641 && mouse.y > 603 && p2.socket.readyState === 1 && !assets.customSongs){
moveTo = "session" moveTo = "session"
}else{ }else{
var moveTo = this.songSelMouse(mouse.x, mouse.y) var moveTo = this.songSelMouse(mouse.x, mouse.y)
@ -557,6 +557,9 @@ class SongSelect{
} }
browseChange(event){ browseChange(event){
var loaderDiv = document.createElement("div")
loaderDiv.innerHTML = assets.pages["loadsong"]
loader.screen.appendChild(loaderDiv)
var files = event.target.files var files = event.target.files
var promises = [] var promises = []
var tjaFiles = [] var tjaFiles = []
@ -610,7 +613,7 @@ class SongSelect{
if(songObj.music && songObj.stars.filter(star => star).length !== 0){ if(songObj.music && songObj.stars.filter(star => star).length !== 0){
songs[index] = songObj songs[index] = songObj
} }
})) }).catch(() => {}))
reader.readAsText(file, "sjis") reader.readAsText(file, "sjis")
} }
for(var i = 0; i < osuFiles.length; i++){ for(var i = 0; i < osuFiles.length; i++){
@ -660,9 +663,11 @@ class SongSelect{
assets.sounds["don"].play() assets.sounds["don"].play()
this.clean() this.clean()
setTimeout(() => { setTimeout(() => {
loader.screen.removeChild(loaderDiv)
new SongSelect("browse", false, this.touchEnabled) new SongSelect("browse", false, this.touchEnabled)
}, 500) }, 500)
}else{ }else{
loader.screen.removeChild(loaderDiv)
this.browse.parentNode.reset() this.browse.parentNode.reset()
} }
}) })
@ -781,7 +786,7 @@ class SongSelect{
this.selectedDiff = 1 this.selectedDiff = 1
do{ do{
this.state.options = this.mod(this.optionsList.length, this.state.options + moveBy) this.state.options = this.mod(this.optionsList.length, this.state.options + moveBy)
}while(p2.socket.readyState !== 1 && this.state.options === 2) }while((p2.socket.readyState !== 1 || assets.customSongs) && this.state.options === 2)
} }
} }
toTitleScreen(){ toTitleScreen(){
@ -808,7 +813,7 @@ class SongSelect{
}, 500) }, 500)
} }
toSession(){ toSession(){
if(p2.socket.readyState !== 1){ if(p2.socket.readyState !== 1 || assets.customSongs){
return return
} }
if(p2.session){ if(p2.session){
@ -1667,7 +1672,7 @@ class SongSelect{
ctx.lineTo(x + 4, y + 4) ctx.lineTo(x + 4, y + 4)
ctx.lineTo(x + 4, y + h) ctx.lineTo(x + 4, y + h)
ctx.fill() ctx.fill()
if(screen !== "difficulty" && p2.socket.readyState === 1){ if(screen !== "difficulty" && p2.socket.readyState === 1 && !assets.customSongs){
var elapsed = (ms - this.state.screenMS) % 3100 var elapsed = (ms - this.state.screenMS) % 3100
var fade = 1 var fade = 1
if(!p2.session && screen === "song"){ if(!p2.session && screen === "song"){