SongSelect: Translatable song titles
This commit is contained in:
parent
93d70dabb3
commit
05720b27f9
9
app.py
9
app.py
@ -166,7 +166,7 @@ def route_api_songs():
|
|||||||
categories = {}
|
categories = {}
|
||||||
def_category = {'title': None, 'title_en': None}
|
def_category = {'title': None, 'title_en': None}
|
||||||
for cat in raw_categories:
|
for cat in raw_categories:
|
||||||
categories[cat[0]] = {'title': cat[1], 'title_en': cat[2]}
|
categories[cat[0]] = cat[1]
|
||||||
|
|
||||||
raw_song_skins = query_db('select * from song_skins')
|
raw_song_skins = query_db('select * from song_skins')
|
||||||
song_skins = {}
|
song_skins = {}
|
||||||
@ -185,15 +185,14 @@ def route_api_songs():
|
|||||||
songs_out.append({
|
songs_out.append({
|
||||||
'id': song_id,
|
'id': song_id,
|
||||||
'title': song[1],
|
'title': song[1],
|
||||||
'title_en': song[2],
|
'title_lang': song[2],
|
||||||
'subtitle': song[3],
|
'subtitle': song[3],
|
||||||
'subtitle_en': song[4],
|
'subtitle_lang': song[4],
|
||||||
'stars': [
|
'stars': [
|
||||||
song[5], song[6], song[7], song[8], song[9]
|
song[5], song[6], song[7], song[8], song[9]
|
||||||
],
|
],
|
||||||
'preview': preview,
|
'preview': preview,
|
||||||
'category': category_out['title'],
|
'category': category_out,
|
||||||
'category_en': category_out['title_en'],
|
|
||||||
'type': song_type,
|
'type': song_type,
|
||||||
'offset': song[13],
|
'offset': song[13],
|
||||||
'song_skin': song_skin_out
|
'song_skin': song_skin_out
|
||||||
|
@ -33,7 +33,8 @@
|
|||||||
max-height: calc(50% + 24vw);
|
max-height: calc(50% + 24vw);
|
||||||
}
|
}
|
||||||
.touchp2 #songbg{
|
.touchp2 #songbg{
|
||||||
height: calc(50% - 5.5vw);
|
height: calc(50% - 5.9vw);
|
||||||
|
min-height: 39.5%;
|
||||||
}
|
}
|
||||||
.multiplayer.portrait #songbg{
|
.multiplayer.portrait #songbg{
|
||||||
height: calc(50% - 37vw);
|
height: calc(50% - 37vw);
|
||||||
@ -89,6 +90,9 @@
|
|||||||
height: calc(50% - 13.7vw);
|
height: calc(50% - 13.7vw);
|
||||||
min-height: 25.6%;
|
min-height: 25.6%;
|
||||||
}
|
}
|
||||||
|
.multiplayer .donbg{
|
||||||
|
min-height: 27.2%;
|
||||||
|
}
|
||||||
.portrait .donbg{
|
.portrait .donbg{
|
||||||
height: calc(50% - 48.9vw);
|
height: calc(50% - 48.9vw);
|
||||||
min-height: 22.5%;
|
min-height: 22.5%;
|
||||||
|
@ -32,13 +32,15 @@ class Controller{
|
|||||||
this.playedSounds = {}
|
this.playedSounds = {}
|
||||||
}
|
}
|
||||||
run(syncWith){
|
run(syncWith){
|
||||||
|
if(syncWith){
|
||||||
|
this.syncWith = syncWith
|
||||||
|
}
|
||||||
this.game.run()
|
this.game.run()
|
||||||
this.view.run()
|
this.view.run()
|
||||||
if(syncWith){
|
if(this.multiplayer === 1){
|
||||||
syncWith.run()
|
syncWith.run(this)
|
||||||
syncWith.game.elapsedTime = this.game.elapsedTime
|
syncWith.game.elapsedTime = this.game.elapsedTime
|
||||||
syncWith.game.startDate = this.game.startDate
|
syncWith.game.startDate = this.game.startDate
|
||||||
this.syncWith = syncWith
|
|
||||||
}
|
}
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
this.startMainLoop()
|
this.startMainLoop()
|
||||||
@ -54,16 +56,20 @@ class Controller{
|
|||||||
this.mainLoopRunning = true
|
this.mainLoopRunning = true
|
||||||
this.gameLoop()
|
this.gameLoop()
|
||||||
this.viewLoop()
|
this.viewLoop()
|
||||||
this.gameInterval = setInterval(this.gameLoop.bind(this), 1000 / 60)
|
if(this.multiplayer !== 2){
|
||||||
|
this.gameInterval = setInterval(this.gameLoop.bind(this), 1000 / 60)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
stopMainLoop(){
|
stopMainLoop(){
|
||||||
this.mainLoopRunning = false
|
this.mainLoopRunning = false
|
||||||
this.mainAsset.stop()
|
this.mainAsset.stop()
|
||||||
clearInterval(this.gameInterval)
|
if(this.multiplayer !== 2){
|
||||||
|
clearInterval(this.gameInterval)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
gameLoop(){
|
gameLoop(){
|
||||||
if(this.mainLoopRunning){
|
if(this.mainLoopRunning){
|
||||||
if(this.syncWith){
|
if(this.multiplayer === 1){
|
||||||
this.syncWith.game.elapsedTime = this.game.elapsedTime
|
this.syncWith.game.elapsedTime = this.game.elapsedTime
|
||||||
this.syncWith.game.startDate = this.game.startDate
|
this.syncWith.game.startDate = this.game.startDate
|
||||||
}
|
}
|
||||||
@ -83,6 +89,9 @@ class Controller{
|
|||||||
this.game.playMainMusic()
|
this.game.playMainMusic()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(this.multiplayer === 1){
|
||||||
|
this.syncWith.gameLoop()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
viewLoop(){
|
viewLoop(){
|
||||||
@ -90,7 +99,7 @@ class Controller{
|
|||||||
if(this.multiplayer !== 2){
|
if(this.multiplayer !== 2){
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
this.viewLoop()
|
this.viewLoop()
|
||||||
if(this.syncWith){
|
if(this.multiplayer === 1){
|
||||||
this.syncWith.viewLoop()
|
this.syncWith.viewLoop()
|
||||||
}
|
}
|
||||||
if(this.scoresheet){
|
if(this.scoresheet){
|
||||||
@ -161,7 +170,7 @@ class Controller{
|
|||||||
this.playSound(soundID + meka, time)
|
this.playSound(soundID + meka, time)
|
||||||
}
|
}
|
||||||
togglePause(){
|
togglePause(){
|
||||||
if(this.syncWith){
|
if(this.multiplayer === 1){
|
||||||
this.syncWith.game.togglePause()
|
this.syncWith.game.togglePause()
|
||||||
}
|
}
|
||||||
this.game.togglePause()
|
this.game.togglePause()
|
||||||
@ -207,7 +216,7 @@ class Controller{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
clean(){
|
clean(){
|
||||||
if(this.syncWith){
|
if(this.multiplayer === 1){
|
||||||
this.syncWith.clean()
|
this.syncWith.clean()
|
||||||
}
|
}
|
||||||
this.stopMainLoop()
|
this.stopMainLoop()
|
||||||
|
@ -43,6 +43,12 @@ class Game{
|
|||||||
initTiming(){
|
initTiming(){
|
||||||
// Date when the chrono is started (before the game begins)
|
// Date when the chrono is started (before the game begins)
|
||||||
var offsetTime = Math.max(0, this.timeForDistanceCircle - this.songData.circles[0].ms) |0
|
var offsetTime = Math.max(0, this.timeForDistanceCircle - this.songData.circles[0].ms) |0
|
||||||
|
if(this.controller.multiplayer){
|
||||||
|
var syncWith = this.controller.syncWith
|
||||||
|
var syncCircles = syncWith.game.songData.circles
|
||||||
|
var syncOffsetTime = Math.max(0, this.timeForDistanceCircle - syncCircles[0].ms) |0
|
||||||
|
offsetTime = Math.max(offsetTime, syncOffsetTime)
|
||||||
|
}
|
||||||
this.elapsedTime = -offsetTime
|
this.elapsedTime = -offsetTime
|
||||||
// The real start for the game will start when chrono will reach 0
|
// The real start for the game will start when chrono will reach 0
|
||||||
this.startDate = Date.now() + offsetTime
|
this.startDate = Date.now() + offsetTime
|
||||||
@ -320,7 +326,7 @@ class Game{
|
|||||||
this.musicFadeOut++
|
this.musicFadeOut++
|
||||||
}else if(this.musicFadeOut === 1 && ms >= started + 1600){
|
}else if(this.musicFadeOut === 1 && ms >= started + 1600){
|
||||||
this.controller.gameEnded()
|
this.controller.gameEnded()
|
||||||
if(!p2.session){
|
if(!p2.session && this.controller.multiplayer === 1){
|
||||||
p2.send("gameend")
|
p2.send("gameend")
|
||||||
}
|
}
|
||||||
this.musicFadeOut++
|
this.musicFadeOut++
|
||||||
|
@ -35,33 +35,23 @@
|
|||||||
"ura": 4
|
"ura": 4
|
||||||
}
|
}
|
||||||
this.categories = {
|
this.categories = {
|
||||||
"j-pop": "J-POP",
|
|
||||||
"pop": "J-POP",
|
|
||||||
"アニメ": "アニメ",
|
|
||||||
"anime": "アニメ",
|
|
||||||
"アニメ": "アニメ",
|
|
||||||
"ボーカロイド™曲": "ボーカロイド™曲",
|
|
||||||
"ボーカロイド曲": "ボーカロイド™曲",
|
"ボーカロイド曲": "ボーカロイド™曲",
|
||||||
"ボーカロイド": "ボーカロイド™曲",
|
"ボーカロイド": "ボーカロイド™曲",
|
||||||
"vocaloid™ music": "ボーカロイド™曲",
|
|
||||||
"vocaloid music": "ボーカロイド™曲",
|
"vocaloid music": "ボーカロイド™曲",
|
||||||
"vocaloid": "ボーカロイド™曲",
|
"vocaloid": "ボーカロイド™曲",
|
||||||
"バラエティ": "バラエティ",
|
|
||||||
"バラエティー": "バラエティ",
|
"バラエティー": "バラエティ",
|
||||||
"どうよう": "バラエティ",
|
"どうよう": "バラエティ",
|
||||||
"童謡・民謡": "バラエティ",
|
"童謡・民謡": "バラエティ",
|
||||||
"variety": "バラエティ",
|
|
||||||
"children": "バラエティ",
|
"children": "バラエティ",
|
||||||
"children/folk": "バラエティ",
|
"children/folk": "バラエティ",
|
||||||
"children-folk": "バラエティ",
|
"children-folk": "バラエティ",
|
||||||
"クラシック": "クラシック",
|
|
||||||
"クラッシック": "クラシック",
|
"クラッシック": "クラシック",
|
||||||
"classical": "クラシック",
|
"classic": "クラシック"
|
||||||
"classic": "クラシック",
|
}
|
||||||
"ゲームミュージック": "ゲームミュージック",
|
for(var i in allStrings){
|
||||||
"game music": "ゲームミュージック",
|
for(var ja in allStrings[i].categories){
|
||||||
"ナムコオリジナル": "ナムコオリジナル",
|
this.categories[allStrings[i].categories[ja].toLowerCase()] = ja
|
||||||
"namco original": "ナムコオリジナル"
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(var i = 0; i < files.length; i++){
|
for(var i = 0; i < files.length; i++){
|
||||||
|
@ -94,11 +94,12 @@ class SongSelect{
|
|||||||
|
|
||||||
this.songs = []
|
this.songs = []
|
||||||
for(let song of assets.songs){
|
for(let song of assets.songs){
|
||||||
var en = strings.id === "en" && song.title_en
|
var title = this.getLocalTitle(song.title, song.title_lang)
|
||||||
|
var subtitle = this.getLocalTitle(title === song.title ? song.subtitle : "", song.subtitle_lang)
|
||||||
this.songs.push({
|
this.songs.push({
|
||||||
id: song.id,
|
id: song.id,
|
||||||
title: en ? song.title_en : song.title,
|
title: title,
|
||||||
subtitle: en ? song.subtitle_en : song.subtitle,
|
subtitle: subtitle,
|
||||||
skin: song.category in this.songSkin ? this.songSkin[song.category] : this.songSkin.default,
|
skin: song.category in this.songSkin ? this.songSkin[song.category] : this.songSkin.default,
|
||||||
stars: song.stars,
|
stars: song.stars,
|
||||||
category: song.category,
|
category: song.category,
|
||||||
@ -1325,7 +1326,7 @@ class SongSelect{
|
|||||||
if(this.selectedDiff === 4 + this.diffOptions.length){
|
if(this.selectedDiff === 4 + this.diffOptions.length){
|
||||||
currentDiff = 3
|
currentDiff = 3
|
||||||
}
|
}
|
||||||
if(i === currentSong.p2Cursor){
|
if(i === currentSong.p2Cursor && p2.socket.readyState === 1){
|
||||||
this.draw.diffCursor({
|
this.draw.diffCursor({
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
font: this.font,
|
font: this.font,
|
||||||
@ -1349,7 +1350,7 @@ class SongSelect{
|
|||||||
font: this.font,
|
font: this.font,
|
||||||
x: _x,
|
x: _x,
|
||||||
y: _y - 65,
|
y: _y - 65,
|
||||||
side: currentSong.p2Cursor === currentDiff
|
side: currentSong.p2Cursor === currentDiff && p2.socket.readyState === 1
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if(highlight){
|
if(highlight){
|
||||||
@ -1664,7 +1665,7 @@ class SongSelect{
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.draw.songFrame(config)
|
this.draw.songFrame(config)
|
||||||
if(config.song.p2Cursor){
|
if(config.song.p2Cursor && p2.socket.readyState === 1){
|
||||||
this.draw.diffCursor({
|
this.draw.diffCursor({
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
font: this.font,
|
font: this.font,
|
||||||
@ -1853,6 +1854,22 @@ class SongSelect{
|
|||||||
return ((index % length) + length) % length
|
return ((index % length) + length) % length
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getLocalTitle(title, titleLang){
|
||||||
|
if(titleLang){
|
||||||
|
titleLang = titleLang.split("\n")
|
||||||
|
titleLang.forEach(line => {
|
||||||
|
var space = line.indexOf(" ")
|
||||||
|
var id = line.slice(0, space)
|
||||||
|
if(id === strings.id){
|
||||||
|
title = line.slice(space + 1)
|
||||||
|
}else if(titleLang.length === 1 && strings.id === "en" && !(id in allStrings)){
|
||||||
|
title = line
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return title
|
||||||
|
}
|
||||||
|
|
||||||
getMS(){
|
getMS(){
|
||||||
return Date.now()
|
return Date.now()
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,7 @@
|
|||||||
|
|
||||||
this.drawGogoTime()
|
this.drawGogoTime()
|
||||||
|
|
||||||
if(!touchMultiplayer){
|
if(!touchMultiplayer || this.multiplayer === 1 && frameTop >= 0){
|
||||||
this.assets.drawAssets("background")
|
this.assets.drawAssets("background")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user