From f83fab41e3870eebdb189cb9149329d80ffe968d Mon Sep 17 00:00:00 2001 From: LoveEevee Date: Fri, 17 Apr 2020 04:53:53 +0300 Subject: [PATCH] Bug fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fixed touch multiplayer drum being too small and nameplate drawing on top of it - Fixed #lyric lines being forced to be lowercase and appearing too early - Fixed exiting session while someone else is using netplay sending you to difficulty selection of the song that the netplay person has selected - Fixed ≠MM title on song select not having the first symbol rotated - Fixed nameplate cache in song select and in game not getting cleared - Increased ping timeout for multiplayer Admin page fixes - Add meta viewport tag so that the admin pages can be opened on mobile - On song list, songs that are not enabled are now marked - Disable tabbing through diverge notes checkboxes in courses when adding or editing a song - Add Hash to song adding - Display an error if a local chart file has not been found while calculating hash - If calculating the hash results in an error, do not discard all other changes --- app.py | 39 +++++++++++++++-------- public/src/js/canvasdraw.js | 2 +- public/src/js/loader.js | 4 --- public/src/js/parsetja.js | 53 ++++++++++++++++++++------------ public/src/js/songselect.js | 1 + public/src/js/view.js | 7 +++-- server.py | 8 +++-- templates/admin.html | 3 +- templates/admin_song_detail.html | 10 +++--- templates/admin_song_new.html | 19 +++++++----- templates/admin_songs.html | 10 ++++-- 11 files changed, 97 insertions(+), 59 deletions(-) diff --git a/app.py b/app.py index b167014..4519357 100644 --- a/app.py +++ b/app.py @@ -67,7 +67,10 @@ def generate_hash(id, form): else: if url.startswith("/"): url = url[1:] - with open(os.path.join("public", url), "rb") as file: + path = os.path.normpath(os.path.join("public", url)) + if not os.path.isfile(path): + raise HashException("File not found: %s" % (os.path.abspath(path))) + with open(path, "rb") as file: md5.update(file.read()) return base64.b64encode(md5.digest())[:-2].decode('utf-8') @@ -244,18 +247,28 @@ def route_admin_songs_new_post(): output['volume'] = float(request.form.get('volume')) or None output['maker_id'] = int(request.form.get('maker_id')) or None output['lyrics'] = True if request.form.get('lyrics') else False - output['hash'] = None - + output['hash'] = request.form.get('hash') + seq = db.seq.find_one({'name': 'songs'}) seq_new = seq['value'] + 1 if seq else 1 + + hash_error = False + if request.form.get('gen_hash'): + try: + output['hash'] = generate_hash(seq_new, request.form) + except HashException as e: + hash_error = True + flash('An error occurred: %s' % str(e), 'error') + output['id'] = seq_new output['order'] = seq_new - + db.songs.insert_one(output) - flash('Song created.') - + if not hash_error: + flash('Song created.') + db.seq.update_one({'name': 'songs'}, {'$set': {'value': seq_new}}, upsert=True) - + return redirect('/admin/songs/%s' % str(seq_new)) @@ -295,17 +308,19 @@ def route_admin_songs_id_post(id): output['maker_id'] = int(request.form.get('maker_id')) or None output['lyrics'] = True if request.form.get('lyrics') else False output['hash'] = request.form.get('hash') - + + hash_error = False if request.form.get('gen_hash'): try: output['hash'] = generate_hash(id, request.form) except HashException as e: + hash_error = True flash('An error occurred: %s' % str(e), 'error') - return redirect('/admin/songs/%s' % id) - + db.songs.update_one({'id': id}, {'$set': output}) - flash('Changes saved.') - + if not hash_error: + flash('Changes saved.') + return redirect('/admin/songs/%s' % id) diff --git a/public/src/js/canvasdraw.js b/public/src/js/canvasdraw.js index bb38f1b..fc2f444 100644 --- a/public/src/js/canvasdraw.js +++ b/public/src/js/canvasdraw.js @@ -56,7 +56,7 @@ ideographicComma: /[、。]/, apostrophe: /[''’]/, degree: /[゚°]/, - brackets: /[\((\))\[\]「」『』【】::;;]/, + brackets: /[\((\))\[\]「」『』【】::;;≠]/, tilde: /[\--~~〜_]/, tall: /[bbddffgghhj-lj-ltt♪]/, i: /[ii]/, diff --git a/public/src/js/loader.js b/public/src/js/loader.js index e574b00..8bb00ef 100644 --- a/public/src/js/loader.js +++ b/public/src/js/loader.js @@ -409,10 +409,6 @@ class Loader{ }) } clean(error){ - var fontDetectDiv = document.getElementById("fontdetectHelper") - if(fontDetectDiv){ - fontDetectDiv.parentNode.removeChild(fontDetectDiv) - } delete this.loaderDiv delete this.loaderPercentage delete this.loaderProgress diff --git a/public/src/js/parsetja.js b/public/src/js/parsetja.js index 97b51fa..07a11b9 100644 --- a/public/src/js/parsetja.js +++ b/public/src/js/parsetja.js @@ -153,6 +153,7 @@ var sectionBegin = true var lastBpm = bpm var lastGogo = gogo + var lyricsLine = null var currentMeasure = [] var firstNote = true @@ -265,6 +266,18 @@ } note_chain = []; } + if("lyricsLine" in note){ + if(!this.lyrics){ + this.lyrics = [] + } + if(this.lyrics.length !== 0){ + this.lyrics[this.lyrics.length - 1].end = note.start + } + this.lyrics.push({ + start: note.start, + text: note.lyricsLine + }) + } } if (note_chain.length > 1 && currentMeasure.length >= 8) { checkChain(note_chain, currentMeasure.length, false); @@ -281,6 +294,10 @@ lastBpm = bpm lastGogo = gogo } + if(lyricsLine !== null){ + circleObj.lyricsLine = lyricsLine + lyricsLine = null + } currentMeasure.push(circleObj) } } @@ -293,12 +310,21 @@ gogo: gogo }) }else if(!circleObj){ - currentMeasure.push({ + var circleObj2 = { bpm: bpm, scroll: scroll - }) + } + if(lyricsLine !== null){ + circleObj2.lyricsLine = lyricsLine + lyricsLine = null + } + currentMeasure.push(circleObj2) } if(circleObj){ + if(lyricsLine !== null){ + circleObj.lyricsLine = lyricsLine + lyricsLine = null + } currentMeasure.push(circleObj) } } @@ -307,8 +333,9 @@ var line = this.data[lineNum] if(line.slice(0, 1) === "#"){ - var line = line.slice(1).toLowerCase() + var line = line.slice(1) var [name, value] = this.split(line, " ") + name = name.toLowerCase() switch(name){ case "gogostart": @@ -415,16 +442,7 @@ branchObj[branchName] = currentBranch break case "lyric": - if(!this.lyrics){ - this.lyrics = [] - } - if(this.lyrics.length !== 0){ - this.lyrics[this.lyrics.length - 1].end = ms - } - this.lyrics.push({ - start: ms, - text: value.trim().replace(regexLinebreak, "\n") - }) + lyricsLine = value.replace(regexLinebreak, "\n").trim() break } @@ -512,13 +530,8 @@ } break case ",": - if(currentMeasure.length === 0 && (bpm !== lastBpm || gogo !== lastGogo)){ - insertNote({ - type: "event", - bpm: bpm, - scroll: scroll, - gogo: gogo - }) + if(currentMeasure.length === 0 && (bpm !== lastBpm || gogo !== lastGogo || lyricsLine !== null)){ + insertBlankNote() } pushMeasure() currentMeasure = [] diff --git a/public/src/js/songselect.js b/public/src/js/songselect.js index 4532057..b8836bc 100644 --- a/public/src/js/songselect.js +++ b/public/src/js/songselect.js @@ -2642,6 +2642,7 @@ class SongSelect{ this.difficultyCache.clean() this.sessionCache.clean() this.currentSongCache.clean() + this.nameplateCache.clean() assets.sounds["bgm_songsel"].stop() if(!this.bgmEnabled){ snd.musicGain.fadeIn() diff --git a/public/src/js/view.js b/public/src/js/view.js index 4326379..21ab405 100644 --- a/public/src/js/view.js +++ b/public/src/js/view.js @@ -591,8 +591,8 @@ this.nameplateCache.get({ ctx: ctx, - x: 320, - y: this.player === 2 ? 460 : 20, + x: touchMultiplayer ? 47 : 320, + y: touchMultiplayer ? (this.player === 2 ? 361 : 119) : (this.player === 2 ? 460 : 20), w: 273, h: 66, id: "1p", @@ -743,7 +743,7 @@ y: animPos.y2 }] - var touchTop = frameTop + (touchMultiplayer ? 135 : 0) + var touchTop = frameTop + (touchMultiplayer ? 135 : 0) + (this.player === 2 ? -165 : 0) this.touchDrum = (() => { var sw = 842 var sh = 340 @@ -2263,6 +2263,7 @@ this.comboCache.clean() this.pauseCache.clean() this.branchCache.clean() + this.nameplateCache.clean() versionDiv.classList.remove("version-hide") loader.screen.parentNode.appendChild(versionDiv) diff --git a/server.py b/server.py index 754f958..85ee590 100644 --- a/server.py +++ b/server.py @@ -52,12 +52,12 @@ async def connection(ws, path): await ws.send(status_event()) while True: try: - message = await asyncio.wait_for(ws.recv(), timeout=5) + message = await asyncio.wait_for(ws.recv(), timeout=10) except asyncio.TimeoutError: # Keep user connected pong_waiter = await ws.ping() try: - await asyncio.wait_for(pong_waiter, timeout=5) + await asyncio.wait_for(pong_waiter, timeout=10) except asyncio.TimeoutError: # Disconnect break @@ -338,8 +338,10 @@ async def connection(ws, path): sent_msg2 = status_event() await asyncio.wait([ ws.send(sent_msg1), + user["other_user"]["ws"].send(sent_msg1) + ]) + await asyncio.wait([ ws.send(sent_msg2), - user["other_user"]["ws"].send(sent_msg1), user["other_user"]["ws"].send(sent_msg2) ]) del user["other_user"]["other_user"] diff --git a/templates/admin.html b/templates/admin.html index 6080e06..410182d 100644 --- a/templates/admin.html +++ b/templates/admin.html @@ -3,7 +3,8 @@ Taiko Web Admin - + + diff --git a/templates/admin_song_detail.html b/templates/admin_song_detail.html index d7bffd4..85edf5a 100644 --- a/templates/admin_song_detail.html +++ b/templates/admin_song_detail.html @@ -52,19 +52,19 @@

Courses

- + - + - + - + - +
diff --git a/templates/admin_song_new.html b/templates/admin_song_new.html index f4a57b4..3e7344b 100644 --- a/templates/admin_song_new.html +++ b/templates/admin_song_new.html @@ -48,19 +48,19 @@

Courses

- + - + - + - + - +
@@ -83,7 +83,7 @@

- +
@@ -103,7 +103,7 @@

- +
@@ -121,6 +121,11 @@
+
+

+ +
+
diff --git a/templates/admin_songs.html b/templates/admin_songs.html index 3f0d0da..2f3bca4 100644 --- a/templates/admin_songs.html +++ b/templates/admin_songs.html @@ -10,10 +10,14 @@ {% for song in songs %}
- {% if song.title_lang.en %} -

{{ song.id }}. {{ song.title_lang.en }} ({{ song.title }})

+ {% if song.title_lang.en and song.title_lang.en != song.title %} +

{{ song.id }}. + {% if not song.enabled %}(Not enabled){% endif %} + {{ song.title_lang.en }} ({{ song.title }})

{% else %} -

{{ song.id }}. {{ song.title }}

+

{{ song.id }}. + {% if not song.enabled %}(Not enabled){% endif %} + {{ song.title }}

{% endif %}