Add Show Lyrics option to settings

This commit is contained in:
LoveEevee 2020-03-31 16:44:54 +03:00
parent 51bd6cec63
commit de284d204d
5 changed files with 17 additions and 6 deletions

View File

@ -57,7 +57,7 @@ class Controller{
if(song.id == this.selectedSong.folder){ if(song.id == this.selectedSong.folder){
this.mainAsset = song.sound this.mainAsset = song.sound
this.volume = song.volume || 1 this.volume = song.volume || 1
if(!multiplayer && (!this.touchEnabled || this.autoPlayEnabled)){ if(!multiplayer && (!this.touchEnabled || this.autoPlayEnabled) && settings.getItem("showLyrics")){
if(song.lyricsData){ if(song.lyricsData){
var lyricsDiv = document.getElementById("song-lyrics") var lyricsDiv = document.getElementById("song-lyrics")
this.lyrics = new Lyrics(song.lyricsData, selectedSong.offset, lyricsDiv) this.lyrics = new Lyrics(song.lyricsData, selectedSong.offset, lyricsDiv)
@ -253,7 +253,7 @@ class Controller{
var reader = new FileReader() var reader = new FileReader()
promises.push(pageEvents.load(reader).then(event => { promises.push(pageEvents.load(reader).then(event => {
songObj.lyricsData = event.target.result songObj.lyricsData = event.target.result
}), songObj.lyricsFile.webkitRelativePath) }, () => Promise.resolve()), songObj.lyricsFile.webkitRelativePath)
reader.readAsText(songObj.lyricsFile) reader.readAsText(songObj.lyricsFile)
} }
Promise.all(promises).then(resolve) Promise.all(promises).then(resolve)

View File

@ -137,11 +137,11 @@ class LoadSong{
reader.readAsText(songObj.chart) reader.readAsText(songObj.chart)
} }
} }
if(songObj.lyricsFile){ if(songObj.lyricsFile && settings.getItem("showLyrics")){
var reader = new FileReader() var reader = new FileReader()
this.addPromise(pageEvents.load(reader).then(event => { this.addPromise(pageEvents.load(reader).then(event => {
songObj.lyricsData = event.target.result songObj.lyricsData = event.target.result
}), songObj.lyricsFile.webkitRelativePath) }, () => Promise.resolve()), songObj.lyricsFile.webkitRelativePath)
reader.readAsText(songObj.lyricsFile) reader.readAsText(songObj.lyricsFile)
} }
}else{ }else{
@ -149,7 +149,7 @@ class LoadSong{
this.addPromise(loader.ajax(url).then(data => { this.addPromise(loader.ajax(url).then(data => {
this.songData = data.replace(/\0/g, "").split("\n") this.songData = data.replace(/\0/g, "").split("\n")
}), url) }), 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" var url = this.getSongDir(song) + "main.vtt"
this.addPromise(loader.ajax(url).then(data => { this.addPromise(loader.ajax(url).then(data => {
songObj.lyricsData = data songObj.lyricsData = data

View File

@ -160,6 +160,7 @@
var circleID = 0 var circleID = 0
var regexAZ = /[A-Z]/ var regexAZ = /[A-Z]/
var regexSpace = /\s/ var regexSpace = /\s/
var regexLinebreak = /\\n/g
var isAllDon = (note_chain, start_pos) => { var isAllDon = (note_chain, start_pos) => {
for (var i = start_pos; i < note_chain.length; ++i) { for (var i = start_pos; i < note_chain.length; ++i) {
var note = note_chain[i]; var note = note_chain[i];
@ -422,7 +423,7 @@
} }
this.lyrics.push({ this.lyrics.push({
start: ms, start: ms,
text: value.trim() text: value.trim().replace(regexLinebreak, "\n")
}) })
break break
} }

View File

@ -50,6 +50,10 @@ class Settings{
easierBigNotes: { easierBigNotes: {
type: "toggle", type: "toggle",
default: false default: false
},
showLyrics: {
type: "toggle",
default: true
} }
} }

View File

@ -780,6 +780,12 @@ var translations = {
ko: "쉬운 큰 음표" ko: "쉬운 큰 음표"
} }
}, },
showLyrics: {
name: {
ja: "歌詞の表示",
en: "Show Lyrics"
}
},
on: { on: {
ja: "オン", ja: "オン",
en: "On", en: "On",