Skip to content
Permalink
Browse files

Merge pull request #294 from bui/bug-fixes

Bug fixes
  • Loading branch information
bui committed Dec 5, 2020
2 parents bd8e219 + 13d6aaa commit 665fc57929b48c895f208b497ae71c84cd8cee57
10 app.py
@@ -191,10 +191,10 @@ def route_admin():
@app.route('/admin/songs')
@admin_required(level=50)
def route_admin_songs():
songs = db.songs.find({})
songs = sorted(list(db.songs.find({})), key=lambda x: x['id'])
categories = db.categories.find({})
user = db.users.find_one({'username': session['username']})
return render_template('admin_songs.html', songs=list(songs), admin=user, categories=list(categories))
return render_template('admin_songs.html', songs=songs, admin=user, categories=list(categories), config=get_config())


@app.route('/admin/songs/<int:id>')
@@ -210,7 +210,7 @@ def route_admin_songs_id(id):
user = db.users.find_one({'username': session['username']})

return render_template('admin_song_detail.html',
song=song, categories=categories, song_skins=song_skins, makers=makers, admin=user)
song=song, categories=categories, song_skins=song_skins, makers=makers, admin=user, config=get_config())


@app.route('/admin/songs/new')
@@ -219,8 +219,10 @@ def route_admin_songs_new():
categories = list(db.categories.find({}))
song_skins = list(db.song_skins.find({}))
makers = list(db.makers.find({}))
seq = db.seq.find_one({'name': 'songs'})
seq_new = seq['value'] + 1 if seq else 1

return render_template('admin_song_new.html', categories=categories, song_skins=song_skins, makers=makers)
return render_template('admin_song_new.html', categories=categories, song_skins=song_skins, makers=makers, config=get_config(), id=seq_new)


@app.route('/admin/songs/new', methods=['POST'])
@@ -15,6 +15,7 @@
z-index: 1;
width: 100%;
height: 100%;
touch-action: none;
}
#touch-drum{
display: none;
@@ -55,6 +55,9 @@
white-space: nowrap;
transition: background-image 0.5s;
}
#song-select.unfocused{
animation-play-state: paused;
}
#song-sel-canvas{
position: absolute;
right: 0;
@@ -59,6 +59,9 @@ kbd{
line-height: 1.4;
white-space: nowrap;
}
.key-join{
font-size: 0.6em;
}
.taibtn{
display: inline-block;
background: #f6ead4;
@@ -53,6 +53,9 @@ function browserSupport(){
},
"OGG or WebAssembly": function(){
return new Audio().canPlayType("audio/ogg;codecs=vorbis") || "WebAssembly" in window
},
"KeyboardEvent.key": function(){
return "key" in KeyboardEvent.prototype
}
}
failedTests = []
@@ -25,7 +25,7 @@ class Controller{
this.videoLatency = 0
if(!this.calibrationMode){
var latency = settings.getItem("latency")
if(!autoPlayEnabled){
if(!autoPlayEnabled || this.multiplayer){
this.audioLatency = Math.round(latency.audio) || 0
}
this.videoLatency = Math.round(latency.video) || 0 + this.audioLatency
@@ -218,6 +218,9 @@ class Controller{
}
displayResults(){
if(this.multiplayer !== 2){
if(this.view.cursorHidden){
this.view.canvas.style.cursor = ""
}
this.scoresheet = new Scoresheet(this, this.getGlobalScore(), this.multiplayer, this.touchEnabled)
}
}
@@ -251,15 +254,15 @@ class Controller{
var chartDiff = this.selectedSong.difficulty
chart = chart[chartDiff]
}
promises.push(chart.read(this.selectedSong.type === "tja" ? "sjis" : undefined).then(data => {
this.addPromise(promises, chart.read(this.selectedSong.type === "tja" ? "sjis" : undefined).then(data => {
this.songData = data.replace(/\0/g, "").split("\n")
return Promise.resolve()
}))
}), chart.url)
}
if(songObj.lyricsFile){
promises.push(songObj.lyricsFile.read().then(result => {
this.addPromise(promises, songObj.lyricsFile.read().then(result => {
songObj.lyricsData = result
}, () => Promise.resolve()), songObj.lyricsFile.path)
}, () => Promise.resolve()), songObj.lyricsFile.url)
}
Promise.all(promises).then(resolve)
}
@@ -269,6 +272,32 @@ class Controller{
})
}
}
addPromise(promises, promise, url){
promises.push(promise.catch(error => {
if(this.restartSongError){
return
}
this.restartSongError = true
if(url){
error = (Array.isArray(error) ? error[0] + ": " : (error ? error + ": " : "")) + url
}
pageEvents.send("load-song-error", error)
errorMessage(new Error(error).stack)
var title = this.selectedSong.title
if(title !== this.selectedSong.originalTitle){
title += " (" + this.selectedSong.originalTitle + ")"
}
setTimeout(() => {
new SongSelect(false, false, this.touchEnabled, null, {
name: "loadSongError",
title: title,
id: this.selectedSong.folder,
error: error
})
}, 500)
return Promise.reject(error)
}))
}
playSound(id, time, noSnd){
if(!this.drumSounds && (id === "neiro_1_don" || id === "neiro_1_ka" || id === "se_don" || id === "se_ka")){
return
@@ -20,12 +20,18 @@ class CustomSongs{
this.items = []
this.linkLocalFolder = document.getElementById("link-localfolder")
this.hasLocal = "webkitdirectory" in HTMLInputElement.prototype && !(/Android|iPhone|iPad/.test(navigator.userAgent))
this.selected = -1

if(this.hasLocal){
this.browse = document.getElementById("browse")
pageEvents.add(this.browse, "change", this.browseChange.bind(this))
this.setAltText(this.linkLocalFolder, strings.customSongs.localFolder)
pageEvents.add(this.linkLocalFolder, ["mousedown", "touchstart"], this.localFolder.bind(this))
this.items.push(this.linkLocalFolder)
if(this.selected === -1){
this.linkLocalFolder.classList.add("selected")
this.selected = this.items.length - 1
}
}else{
this.linkLocalFolder.parentNode.removeChild(this.linkLocalFolder)
}
@@ -35,6 +41,10 @@ class CustomSongs{
this.setAltText(this.linkGdriveFolder, strings.customSongs.gdriveFolder)
pageEvents.add(this.linkGdriveFolder, ["mousedown", "touchstart"], this.gdriveFolder.bind(this))
this.items.push(this.linkGdriveFolder)
if(this.selected === -1){
this.linkGdriveFolder.classList.add("selected")
this.selected = this.items.length - 1
}
}else{
this.linkGdriveFolder.parentNode.removeChild(this.linkGdriveFolder)
}
@@ -43,7 +53,10 @@ class CustomSongs{
this.setAltText(this.endButton, strings.session.cancel)
pageEvents.add(this.endButton, ["mousedown", "touchstart"], event => this.onEnd(event, true))
this.items.push(this.endButton)
this.selected = this.items.length - 1
if(this.selected === -1){
this.endButton.classList.add("selected")
this.selected = this.items.length - 1
}

this.loaderDiv = document.createElement("div")
this.loaderDiv.innerHTML = assets.pages["loadsong"]
@@ -212,11 +212,6 @@ class GameInput{
}
this.keyboardEvents++
}
}else{
this.keys[name] = false
this.waitKeyupScore[name] = false
this.waitKeyupSound[name] = false
this.waitKeyupMenu[name] = false
}
}
isWaiting(name, type){
@@ -110,15 +110,15 @@ class LoadSong{
if(songObj.custom){
this.addPromise(song.songSkin[filename + ".png"].blob().then(blob => {
img.src = URL.createObjectURL(blob)
}))
}), song.songSkin[filename + ".png"].url)
}else{
img.src = skinBase + filename + ".png"
}
}
}
this.loadSongBg(id)

if(songObj.sound){
if(songObj.sound && songObj.sound.buffer){
songObj.sound.gain = snd.musicGain
}else if(songObj.music !== "muted"){
this.addPromise(snd.musicGain.load(songObj.music).then(sound => {
@@ -4,6 +4,7 @@ class Mekadon{
this.game = game
this.lr = false
this.lastHit = -Infinity
this.delay = controller.audioLatency
}
play(circle){
var type = circle.type
@@ -24,7 +25,7 @@ class Mekadon{
}
}
playAt(circle, ms, score, dai, reverse){
var currentMs = circle.ms - this.getMS()
var currentMs = circle.ms - this.getMS() + this.delay
if(ms > currentMs - 10){
return this.playNow(circle, score, dai, reverse)
}
@@ -218,7 +218,7 @@ class P2Connection{
var type = circle.type
var drumrollNotes = type === "balloon" || type === "drumroll" || type === "daiDrumroll"

if(drumrollNotes && mekadon.getMS() > circle.endTime){
if(drumrollNotes && mekadon.getMS() > circle.endTime + mekadon.delay){
circle.played(-1, false)
mekadon.game.updateCurrentCircle()
}
@@ -226,21 +226,21 @@
for (var i = 0; i < currentMeasure.length; i++){
//console.log(note_chain.length);
var note = currentMeasure[i]
circleID++
var circleObj = new Circle({
id: circleID,
start: note.start,
type: note.type,
txt: note.txt,
speed: note.bpm * note.scroll / 60,
gogoTime: note.gogo,
endTime: note.endTime,
requiredHits: note.requiredHits,
beatMS: 60000 / note.bpm,
branch: currentBranch,
section: note.section
})
if (note.type) {
circleID++
var circleObj = new Circle({
id: circleID,
start: note.start,
type: note.type,
txt: note.txt,
speed: note.bpm * note.scroll / 60,
gogoTime: note.gogo,
endTime: note.endTime,
requiredHits: note.requiredHits,
beatMS: 60000 / note.bpm,
branch: currentBranch,
section: note.section
})
if (note.type === "don" || note.type === "ka" || note.type === "daiDon" || note.type === "daiKa") {
note_chain.push(circleObj);
} else {
@@ -253,9 +253,6 @@
lastDrumroll = circleObj
}

if(note.event){
this.events.push(circleObj)
}
if(note.type !== "event"){
circles.push(circleObj)
}
@@ -266,6 +263,9 @@
}
note_chain = [];
}
if(note.event){
this.events.push(circleObj)
}
if("lyricsLine" in note){
if(!this.lyrics){
this.lyrics = []
@@ -488,8 +488,9 @@
sectionBegin = false
if(lastDrumroll){
if(symbol === "9"){
insertBlankNote({
insertNote({
endDrumroll: lastDrumroll,
gogo: gogo,
bpm: bpm,
scroll: scroll,
section: sectionBegin
@@ -514,19 +515,17 @@
break
case "8":
if(lastDrumroll){
insertBlankNote({
insertNote({
endDrumroll: lastDrumroll,
gogo: gogo,
bpm: bpm,
scroll: scroll,
section: sectionBegin
})
sectionBegin = false
lastDrumroll = false
}else{
insertBlankNote({
bpm: bpm,
scroll: scroll
})
insertBlankNote()
}
break
case ",":
@@ -236,6 +236,12 @@ class Scoresheet{
}
}
}else if(!document.hasFocus() && this.state.screen === "scoresShown"){
if(this.state["countup0"]){
this.stopSound("se_results_countup", 0)
}
if(this.state["countup1"]){
this.stopSound("se_results_countup", 1)
}
return
}else{
ctx.clearRect(0, 0, winW / ratio, winH / ratio)

0 comments on commit 665fc57

Please sign in to comment.
You can’t perform that action at this time.