p2 bugfixes

- fix songsel bgm playing when other player selects via random/search
- fix search button being disabled in p2
This commit is contained in:
Bui 2022-03-24 17:33:34 +00:00
parent 584aee13da
commit f45214225b
2 changed files with 10 additions and 7 deletions

View File

@ -587,7 +587,7 @@ class Search{
} }
} }
keyPress(pressed, name, event, repeat){ keyPress(pressed, name, event, repeat, ctrl){
if(name === "back" || (event && event.keyCode && event.keyCode === 70 && ctrl)) { if(name === "back" || (event && event.keyCode && event.keyCode === 70 && ctrl)) {
this.remove(true) this.remove(true)
if(event){ if(event){

View File

@ -128,13 +128,15 @@ class SongSelect{
skin: this.songSkin.random, skin: this.songSkin.random,
action: "random", action: "random",
category: strings.random, category: strings.random,
canJump: true canJump: true,
p2Enabled: true
}) })
this.songs.push({ this.songs.push({
title: strings.search.search, title: strings.search.search,
skin: this.songSkin.search, skin: this.songSkin.search,
action: "search", action: "search",
category: strings.random, category: strings.random,
p2Enabled: true
}) })
} }
if(touchEnabled){ if(touchEnabled){
@ -419,7 +421,7 @@ class SongSelect{
this.showWarning = false this.showWarning = false
} }
}else if(this.search.opened){ }else if(this.search.opened){
this.search.keyPress(pressed, name, event, repeat) this.search.keyPress(pressed, name, event, repeat, ctrl)
}else if(this.state.screen === "song"){ }else if(this.state.screen === "song"){
if(event && event.keyCode && event.keyCode === 70 && ctrl){ if(event && event.keyCode && event.keyCode === 70 && ctrl){
this.search.display() this.search.display()
@ -738,7 +740,7 @@ class SongSelect{
toSelectDifficulty(fromP2, playVoice=true){ toSelectDifficulty(fromP2, playVoice=true){
var currentSong = this.songs[this.selectedSong] var currentSong = this.songs[this.selectedSong]
if(p2.session && !fromP2 && currentSong.action !== "random"){ if(p2.session && !fromP2 && (!currentSong.action || !currentSong.p2Enabled)){
if(this.songs[this.selectedSong].courses){ if(this.songs[this.selectedSong].courses){
if(!this.state.selLock){ if(!this.state.selLock){
this.state.selLock = true this.state.selLock = true
@ -1390,7 +1392,7 @@ class SongSelect{
y: songTop, y: songTop,
song: this.songs[index], song: this.songs[index],
highlight: highlight, highlight: highlight,
disabled: p2.session && this.songs[index].action && this.songs[index].action !== "random" disabled: p2.session && this.songs[index].action && !this.songs[index].p2Enabled
}) })
} }
var startFrom var startFrom
@ -1415,7 +1417,7 @@ class SongSelect{
y: songTop, y: songTop,
song: this.songs[index], song: this.songs[index],
highlight: highlight, highlight: highlight,
disabled: p2.session && this.songs[index].action && this.songs[index].action !== "random" disabled: p2.session && this.songs[index].action && !this.songs[index].p2Enabled
}) })
} }
} }
@ -1473,7 +1475,7 @@ class SongSelect{
animateMS: Math.max(this.state.moveMS, this.state.mouseMoveMS), animateMS: Math.max(this.state.moveMS, this.state.mouseMoveMS),
cached: selectedWidth === this.songAsset.fullWidth ? 3 : (selectedWidth === this.songAsset.selectedWidth ? 2 : (selectedWidth === this.songAsset.width ? 1 : 0)), cached: selectedWidth === this.songAsset.fullWidth ? 3 : (selectedWidth === this.songAsset.selectedWidth ? 2 : (selectedWidth === this.songAsset.width ? 1 : 0)),
frameCache: this.songFrameCache, frameCache: this.songFrameCache,
disabled: p2.session && currentSong.action && currentSong.action !== "random", disabled: p2.session && currentSong.action && !currentSong.p2Enabled,
innerContent: (x, y, w, h) => { innerContent: (x, y, w, h) => {
ctx.strokeStyle = "#000" ctx.strokeStyle = "#000"
if(screen === "title" || screen === "titleFadeIn" || screen === "song"){ if(screen === "title" || screen === "titleFadeIn" || screen === "song"){
@ -2755,6 +2757,7 @@ class SongSelect{
this.setSelectedSong(song) this.setSelectedSong(song)
this.state.move = 0 this.state.move = 0
if(this.state.screen !== "difficulty"){ if(this.state.screen !== "difficulty"){
this.playBgm(false)
this.toSelectDifficulty({player: response.value.player}) this.toSelectDifficulty({player: response.value.player})
} }
} }