From de284d204d52bb8e09e210871833fde9a8ac927a Mon Sep 17 00:00:00 2001 From: LoveEevee Date: Tue, 31 Mar 2020 16:44:54 +0300 Subject: [PATCH] Add Show Lyrics option to settings --- public/src/js/controller.js | 4 ++-- public/src/js/loadsong.js | 6 +++--- public/src/js/parsetja.js | 3 ++- public/src/js/settings.js | 4 ++++ public/src/js/strings.js | 6 ++++++ 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/public/src/js/controller.js b/public/src/js/controller.js index af8e9a3..58d9315 100644 --- a/public/src/js/controller.js +++ b/public/src/js/controller.js @@ -57,7 +57,7 @@ class Controller{ if(song.id == this.selectedSong.folder){ this.mainAsset = song.sound this.volume = song.volume || 1 - if(!multiplayer && (!this.touchEnabled || this.autoPlayEnabled)){ + if(!multiplayer && (!this.touchEnabled || this.autoPlayEnabled) && settings.getItem("showLyrics")){ if(song.lyricsData){ var lyricsDiv = document.getElementById("song-lyrics") this.lyrics = new Lyrics(song.lyricsData, selectedSong.offset, lyricsDiv) @@ -253,7 +253,7 @@ class Controller{ var reader = new FileReader() promises.push(pageEvents.load(reader).then(event => { songObj.lyricsData = event.target.result - }), songObj.lyricsFile.webkitRelativePath) + }, () => Promise.resolve()), songObj.lyricsFile.webkitRelativePath) reader.readAsText(songObj.lyricsFile) } Promise.all(promises).then(resolve) diff --git a/public/src/js/loadsong.js b/public/src/js/loadsong.js index 28285dc..b2e3f98 100644 --- a/public/src/js/loadsong.js +++ b/public/src/js/loadsong.js @@ -137,11 +137,11 @@ class LoadSong{ reader.readAsText(songObj.chart) } } - if(songObj.lyricsFile){ + if(songObj.lyricsFile && settings.getItem("showLyrics")){ var reader = new FileReader() this.addPromise(pageEvents.load(reader).then(event => { songObj.lyricsData = event.target.result - }), songObj.lyricsFile.webkitRelativePath) + }, () => Promise.resolve()), songObj.lyricsFile.webkitRelativePath) reader.readAsText(songObj.lyricsFile) } }else{ @@ -149,7 +149,7 @@ class LoadSong{ this.addPromise(loader.ajax(url).then(data => { this.songData = data.replace(/\0/g, "").split("\n") }), url) - if(song.lyrics && !songObj.lyricsData){ + if(song.lyrics && !songObj.lyricsData && !this.multiplayer && (!this.touchEnabled || this.autoPlayEnabled) && settings.getItem("showLyrics")){ var url = this.getSongDir(song) + "main.vtt" this.addPromise(loader.ajax(url).then(data => { songObj.lyricsData = data diff --git a/public/src/js/parsetja.js b/public/src/js/parsetja.js index 2296dbc..97b51fa 100644 --- a/public/src/js/parsetja.js +++ b/public/src/js/parsetja.js @@ -160,6 +160,7 @@ var circleID = 0 var regexAZ = /[A-Z]/ var regexSpace = /\s/ + var regexLinebreak = /\\n/g var isAllDon = (note_chain, start_pos) => { for (var i = start_pos; i < note_chain.length; ++i) { var note = note_chain[i]; @@ -422,7 +423,7 @@ } this.lyrics.push({ start: ms, - text: value.trim() + text: value.trim().replace(regexLinebreak, "\n") }) break } diff --git a/public/src/js/settings.js b/public/src/js/settings.js index e2c2f4d..1f7a9bb 100644 --- a/public/src/js/settings.js +++ b/public/src/js/settings.js @@ -50,6 +50,10 @@ class Settings{ easierBigNotes: { type: "toggle", default: false + }, + showLyrics: { + type: "toggle", + default: true } } diff --git a/public/src/js/strings.js b/public/src/js/strings.js index 6edf481..5dd8ddd 100644 --- a/public/src/js/strings.js +++ b/public/src/js/strings.js @@ -780,6 +780,12 @@ var translations = { ko: "쉬운 큰 음표" } }, + showLyrics: { + name: { + ja: "歌詞の表示", + en: "Show Lyrics" + } + }, on: { ja: "オン", en: "On",