Added song select music, more keys
This commit is contained in:
parent
f72c09f4a6
commit
b053dffec1
@ -91,6 +91,7 @@ var assets = {
|
||||
"renda.ogg"
|
||||
],
|
||||
"audioMusic": [
|
||||
"bgm_songsel.ogg",
|
||||
"bgm_result.ogg",
|
||||
"bgm_setsume.ogg"
|
||||
],
|
||||
|
@ -351,9 +351,13 @@ class Game{
|
||||
}
|
||||
}
|
||||
getAccurateTime(){
|
||||
if(this.isPaused()){
|
||||
return this.getElapsedTime().ms
|
||||
}else{
|
||||
var currentDate = new Date()
|
||||
return currentDate.getTime() - this.startDate.getTime() - this.elapsedTimeSincePause
|
||||
}
|
||||
}
|
||||
getCircles(){
|
||||
return this.songData.circles
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ class Keyboard{
|
||||
var ms = this.game.getAccurateTime()
|
||||
this.gamepadMenu.play((pressed, keyCode) => {
|
||||
if(pressed){
|
||||
if(this.game.isPaused()){
|
||||
if(paused){
|
||||
if(keyCode === "cancel"){
|
||||
return setTimeout(() => {
|
||||
this.controller.togglePauseMenu()
|
||||
@ -110,17 +110,30 @@ class Keyboard{
|
||||
this.controller.togglePauseMenu()
|
||||
})
|
||||
if(this.game.isPaused()){
|
||||
this.checkKey(this.kbd["previous"], "menu", () => {
|
||||
var moveMenuMinus = () => {
|
||||
moveMenu = -1
|
||||
})
|
||||
this.checkKey(this.kbd["next"], "menu", () => {
|
||||
}
|
||||
var moveMenuPlus = () => {
|
||||
moveMenu = 1
|
||||
})
|
||||
this.checkKey(this.kbd["confirm"], "menu", () => {
|
||||
}
|
||||
var moveMenuConfirm = () => {
|
||||
setTimeout(() => {
|
||||
document.getElementsByClassName("selected")[0].click()
|
||||
var selected = document.getElementsByClassName("selected")[0]
|
||||
if(selected){
|
||||
selected.click()
|
||||
}
|
||||
}, 200)
|
||||
})
|
||||
for(var key in this.keyTime){
|
||||
this.keyTime[key] = null
|
||||
}
|
||||
}
|
||||
this.checkKey(this.kbd["previous"], "menu", moveMenuMinus)
|
||||
this.checkKey(this.kbd["ka_l"], "menu", moveMenuMinus)
|
||||
this.checkKey(this.kbd["next"], "menu", moveMenuPlus)
|
||||
this.checkKey(this.kbd["ka_r"], "menu", moveMenuPlus)
|
||||
this.checkKey(this.kbd["confirm"], "menu", moveMenuConfirm)
|
||||
this.checkKey(this.kbd["don_l"], "menu", moveMenuConfirm)
|
||||
this.checkKey(this.kbd["don_r"], "menu", moveMenuConfirm)
|
||||
}
|
||||
if(moveMenu){
|
||||
assets.sounds["ka"].play()
|
||||
|
@ -116,11 +116,11 @@ class Scoresheet{
|
||||
code = event.keyCode
|
||||
}
|
||||
var selected = this.elem("selected", this.scoresheet)
|
||||
if(code == 13){
|
||||
// Enter
|
||||
if(code == 13 || code == 32 || code == 86 || code == 66){
|
||||
// Enter, Space, V, B
|
||||
selected.click()
|
||||
}else if(code == 37 || code == 39){
|
||||
// Left, Right
|
||||
}else if(code == 37 || code == 39 || code == 67 || code == 78){
|
||||
// Left, Right, C, N
|
||||
selected.classList.remove("selected")
|
||||
var next = selected.nextElementSibling
|
||||
if(!next){
|
||||
|
@ -177,7 +177,9 @@ class SongSelect{
|
||||
|
||||
this.selectedSong = 0
|
||||
this.selectedDiff = 0
|
||||
if(fromTutorial){
|
||||
assets.sounds["bgm_songsel"].playLoop(0.1, false, 0, 1.442, 3.506)
|
||||
|
||||
if(fromTutorial || !"selectedSong" in localStorage){
|
||||
this.selectedSong = this.songs.findIndex(song => song.action === "tutorial")
|
||||
}else{
|
||||
if("selectedSong" in localStorage){
|
||||
@ -636,8 +638,8 @@ class SongSelect{
|
||||
if(this.previewing !== null){
|
||||
this.endPreview()
|
||||
}
|
||||
}else if(screen !== "title"){
|
||||
if(this.previewing !== this.selectedSong){
|
||||
}else if(screen !== "title" && ms > this.state.moveMS + 100){
|
||||
if(this.previewing !== this.selectedSong && "id" in this.songs[this.selectedSong]){
|
||||
this.startPreview()
|
||||
}
|
||||
}
|
||||
@ -1478,7 +1480,7 @@ class SongSelect{
|
||||
var currentSong = this.songs[this.selectedSong]
|
||||
var id = currentSong.id
|
||||
var prvTime = currentSong.preview
|
||||
this.endPreview()
|
||||
this.endPreview(true)
|
||||
|
||||
if("id" in currentSong){
|
||||
var startLoad = this.getMS()
|
||||
@ -1508,13 +1510,17 @@ class SongSelect{
|
||||
}
|
||||
}
|
||||
previewLoaded(startLoad, prvtime){
|
||||
snd.musicGain.fadeOut(0.4)
|
||||
var endLoad = this.getMS()
|
||||
var difference = endLoad - startLoad
|
||||
var minDelay = 300
|
||||
var delay = minDelay - Math.min(minDelay, difference)
|
||||
this.preview.playLoop(delay / 1000, false, prvtime / 1000)
|
||||
}
|
||||
endPreview() {
|
||||
endPreview(noFadeIn){
|
||||
if(!noFadeIn){
|
||||
snd.musicGain.fadeIn(0.4)
|
||||
}
|
||||
this.previewId++
|
||||
this.previewing = null
|
||||
if(this.preview){
|
||||
@ -1559,6 +1565,11 @@ class SongSelect{
|
||||
}
|
||||
|
||||
clean(){
|
||||
assets.sounds["bgm_songsel"].stop()
|
||||
snd.musicGain.fadeIn()
|
||||
setTimeout(() => {
|
||||
snd.musicGain.fadeIn()
|
||||
}, 500)
|
||||
this.redrawRunning = false
|
||||
this.endPreview()
|
||||
pageEvents.keyRemove(this, "all")
|
||||
|
Loading…
Reference in New Issue
Block a user