Removed more hardcoded instances of categories

This commit is contained in:
mnvdk 2020-04-16 00:40:13 +02:00
parent e1411bcd0d
commit 988c4cc734
3 changed files with 19 additions and 101 deletions

View File

@ -107,6 +107,14 @@ class Loader{
this.addPromise(this.ajax("/api/categories").then(categories => { this.addPromise(this.ajax("/api/categories").then(categories => {
assets.categories = JSON.parse(categories) assets.categories = JSON.parse(categories)
assets.categories.push({
title: "default",
songSkin: {
background: "#ececec",
border: ["#fbfbfb", "#8b8b8b"],
outline: "#656565"
}
})
}), "/api/categories") }), "/api/categories")
this.addPromise(this.ajax("/api/songs").then(songs => { this.addPromise(this.ajax("/api/songs").then(songs => {

View File

@ -26,97 +26,47 @@ class SongSelect{
outline: "#ad7723" outline: "#ad7723"
}, },
"random": { "random": {
sort: 7, sort: 0,
background: "#fa91ff", background: "#fa91ff",
border: ["#ffdfff", "#b068b2"], border: ["#ffdfff", "#b068b2"],
outline: "#b221bb" outline: "#b221bb"
}, },
"tutorial": { "tutorial": {
sort: 7, sort: 0,
background: "#29e8aa", background: "#29e8aa",
border: ["#86ffbd", "#009a8c"], border: ["#86ffbd", "#009a8c"],
outline: "#08a28c" outline: "#08a28c"
}, },
"about": { "about": {
sort: 7, sort: 0,
background: "#a2d0e7", background: "#a2d0e7",
border: ["#c6dfff", "#4485d9"], border: ["#c6dfff", "#4485d9"],
outline: "#2390d9" outline: "#2390d9"
}, },
"settings": { "settings": {
sort: 7, sort: 0,
background: "#ce93fa", background: "#ce93fa",
border: ["#dec4fd", "#a543ef"], border: ["#dec4fd", "#a543ef"],
outline: "#a741ef" outline: "#a741ef"
}, },
"browse": { "browse": {
sort: 7, sort: 0,
background: "#fab5d3", background: "#fab5d3",
border: ["#ffe7ef", "#d36aa2"], border: ["#ffe7ef", "#d36aa2"],
outline: "#d36aa2" outline: "#d36aa2"
},
"J-POP": {
sort: 0,
background: "#219fbb",
border: ["#7ec3d3", "#0b6773"],
outline: "#005058"
},
"アニメ": {
sort: 1,
background: "#ff9700",
border: ["#ffdb8c", "#e75500"],
outline: "#9c4100"
},
"ボーカロイド™曲": {
sort: 2,
background: "#def2ef",
border: ["#f7fbff", "#79919f"],
outline: "#5a6584"
},
"バラエティ": {
sort: 3,
background: "#8fd321",
border: ["#f7fbff", "#587d0b"],
outline: "#374c00"
},
"クラシック": {
sort: 4,
background: "#d1a016",
border: ["#e7cf6b", "#9a6b00"],
outline: "#734d00"
},
"ゲームミュージック": {
sort: 5,
background: "#9c72c0",
border: ["#bda2ce", "#63407e"],
outline: "#4b1c74"
},
"ナムコオリジナル": {
sort: 6,
background: "#ff5716",
border: ["#ffa66b", "#b53000"],
outline: "#9c2000"
} }
} }
let sortCount = 7;
for(let category of assets.categories){ for(let category of assets.categories){
if(!this.songSkin[category.title] && category.songSkin){ if(!this.songSkin[category.title] && category.songSkin){
if(!category.songSkin.sort){ if(!category.songSkin.sort == null){
category.songSkin.sort = sortCount category.songSkin.sort = Object.keys(this.songSkin).length + 1
sortCount += 1
} }
this.songSkin[category.title] = category.songSkin this.songSkin[category.title] = category.songSkin
} }
} }
this.songSkin.default = { this.songSkin['default'].sort= Object.keys(this.songSkin).length + 1
sort: Object.keys(this.songSkin).length + 1,
background: "#ececec",
border: ["#fbfbfb", "#8b8b8b"],
outline: "#656565"
}
this.font = strings.font this.font = strings.font

View File

@ -23,40 +23,6 @@
this.darkDonBg = false this.darkDonBg = false
this.pauseOptions = strings.pauseOptions this.pauseOptions = strings.pauseOptions
this.categories = {
"J-POP": {
sort: 0,
infoFill: "#004d68"
},
"アニメ": {
sort: 1,
infoFill: "#9c4002"
},
"ボーカロイド™曲": {
sort: 2,
infoFill: "#546184"
},
"バラエティ": {
sort: 3,
infoFill: "#3c6800"
},
"クラシック": {
sort: 4,
infoFill: "#865800"
},
"ゲームミュージック": {
sort: 5,
infoFill: "#4f2886"
},
"ナムコオリジナル": {
sort: 6,
infoFill: "#961e00"
},
"default": {
sort: 7,
infoFill: "#656565"
}
}
this.difficulty = { this.difficulty = {
"easy": 0, "easy": 0,
"normal": 1, "normal": 1,
@ -329,10 +295,10 @@
var _h = 22 var _h = 22
var _x = 628 - _w var _x = 628 - _w
var _y = 88 - _h var _y = 88 - _h
if(selectedSong.category in this.categories){ if(assets.categories.find(cat=>cat.title == selectedSong.category)){
ctx.fillStyle = this.categories[selectedSong.category].infoFill ctx.fillStyle = assets.categories.find(cat=>cat.title == selectedSong.category).songSkin.outline
}else{ }else{
ctx.fillStyle = this.categories.default.infoFill ctx.fillStyle = assets.categories.find(cat=>cat.title == 'default').songSkin.outline
} }
this.draw.roundedRect({ this.draw.roundedRect({
ctx: ctx, ctx: ctx,
@ -1425,12 +1391,6 @@
var songLayers = [document.getElementById("layer1"), document.getElementById("layer2")] var songLayers = [document.getElementById("layer1"), document.getElementById("layer2")]
var prefix = "" var prefix = ""
if(selectedSong.category in this.categories){
var catId = this.categories[selectedSong.category].sort
}else{
var catId = this.categories.default.sort
}
if(!selectedSong.songSkin.song){ if(!selectedSong.songSkin.song){
var id = selectedSong.songBg var id = selectedSong.songBg
this.songBg.classList.add("songbg-" + id) this.songBg.classList.add("songbg-" + id)