removed hardcoded categories from stringsjs and moved the language block to mongo

This commit is contained in:
mnvdk 2020-04-16 21:39:23 +02:00
parent 7d810a27ce
commit 2c4fdab4f9
3 changed files with 14 additions and 58 deletions

View File

@ -107,6 +107,14 @@ class Loader{
this.addPromise(this.ajax("/api/categories").then(categories => {
assets.categories = JSON.parse(categories)
assets.categories.forEach(cat => {
let title = cat.title
// if(cat.title_lang){
translations.categories[title] = cat.title_lang
// }
});
separateStrings()
assets.categories.push({
title: "default",
songSkin: {

View File

@ -256,8 +256,7 @@ class SongSelect{
this.songSelect = document.getElementById("song-select")
var cat = this.songs[this.selectedSong].category
var sort = cat in this.songSkin ? this.songSkin[cat].sort : 7
this.drawBackground(cat, sort)
this.drawBackground(cat)
this.previewId = 0
this.previewList = Array(5)
@ -1165,9 +1164,7 @@ class SongSelect{
if(this.songs[this.selectedSong].action !== "back"){
var cat = this.songs[this.selectedSong].category
var sort = cat in this.songSkin ? this.songSkin[cat].sort : 7
this.drawBackground(cat, sort)
this.drawBackground(cat)
}
}
if(this.state.moveMS && ms < this.state.moveMS + changeSpeed){
@ -2273,18 +2270,14 @@ class SongSelect{
}
}
drawBackground(cat, sort){
drawBackground(cat){
if(this.songSkin[cat] && this.songSkin[cat].bg_img){
let filename = this.songSkin[cat].bg_img.slice(0, this.songSkin[cat].bg_img.lastIndexOf("."))
this.songSelect.style.backgroundImage = "url('" + assets.image[filename].src + "')"
}else{
if(assets.image["bg_genre_" + sort]){
this.songSelect.style.backgroundImage = "url('" + assets.image["bg_genre_" + sort].src + "')"
}else{
this.songSelect.style.backgroundImage = "url('" + assets.image["bg_genre_def"].src + "')"
this.songSelect.style.backgroundImage = "url('" + assets.image["bg_genre_def"].src + "')"
}
}
}
drawClosedSong(config){
var ctx = config.ctx

View File

@ -47,52 +47,7 @@ var translations = {
en: "Taiko no Tatsujin ©&™ 2011 BANDAI NAMCO Entertainment Inc."
},
categories: {
"J-POP": {
ja: "J-POP",
en: "Pop",
cn: "流行音乐",
tw: "流行音樂",
ko: "POP"
},
"アニメ": {
ja: "アニメ",
en: "Anime",
cn: "卡通动画音乐",
tw: "卡通動畫音樂",
ko: "애니메이션"
},
"ボーカロイド™曲": {
ja: "ボーカロイド™曲",
en: "VOCALOID™ Music"
},
"バラエティ": {
ja: "バラエティ",
en: "Variety",
cn: "综合音乐",
tw: "綜合音樂",
ko: "버라이어티"
},
"クラシック": {
ja: "クラシック",
en: "Classical",
cn: "古典音乐",
tw: "古典音樂",
ko: "클래식"
},
"ゲームミュージック": {
ja: "ゲームミュージック",
en: "Game Music",
cn: "游戏音乐",
tw: "遊戲音樂",
ko: "게임"
},
"ナムコオリジナル": {
ja: "ナムコオリジナル",
en: "NAMCO Original",
cn: "NAMCO原创音乐",
tw: "NAMCO原創音樂",
ko: "남코 오리지널"
}
},
selectSong: {
ja: "曲をえらぶ",
@ -1130,7 +1085,7 @@ function separateStrings(){
}
var str = allStrings[lang]
var translateObj = function(obj, name, str){
if("en" in obj){
if(obj != null && "en" in obj && obj["en"] != null){
for(var i in obj){
str[name] = obj[lang] || obj.en
}