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 => {
assets.categories = JSON.parse(categories)
assets.categories.push({
title: "default",
songSkin: {
background: "#ececec",
border: ["#fbfbfb", "#8b8b8b"],
outline: "#656565"
}
})
}), "/api/categories")
this.addPromise(this.ajax("/api/songs").then(songs => {

View File

@ -26,97 +26,47 @@ class SongSelect{
outline: "#ad7723"
},
"random": {
sort: 7,
sort: 0,
background: "#fa91ff",
border: ["#ffdfff", "#b068b2"],
outline: "#b221bb"
},
"tutorial": {
sort: 7,
sort: 0,
background: "#29e8aa",
border: ["#86ffbd", "#009a8c"],
outline: "#08a28c"
},
"about": {
sort: 7,
sort: 0,
background: "#a2d0e7",
border: ["#c6dfff", "#4485d9"],
outline: "#2390d9"
},
"settings": {
sort: 7,
sort: 0,
background: "#ce93fa",
border: ["#dec4fd", "#a543ef"],
outline: "#a741ef"
},
"browse": {
sort: 7,
sort: 0,
background: "#fab5d3",
border: ["#ffe7ef", "#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){
if(!this.songSkin[category.title] && category.songSkin){
if(!category.songSkin.sort){
category.songSkin.sort = sortCount
sortCount += 1
if(!category.songSkin.sort == null){
category.songSkin.sort = Object.keys(this.songSkin).length + 1
}
this.songSkin[category.title] = category.songSkin
}
}
this.songSkin.default = {
sort: Object.keys(this.songSkin).length + 1,
background: "#ececec",
border: ["#fbfbfb", "#8b8b8b"],
outline: "#656565"
}
this.songSkin['default'].sort= Object.keys(this.songSkin).length + 1
this.font = strings.font

View File

@ -23,40 +23,6 @@
this.darkDonBg = false
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 = {
"easy": 0,
"normal": 1,
@ -329,10 +295,10 @@
var _h = 22
var _x = 628 - _w
var _y = 88 - _h
if(selectedSong.category in this.categories){
ctx.fillStyle = this.categories[selectedSong.category].infoFill
if(assets.categories.find(cat=>cat.title == selectedSong.category)){
ctx.fillStyle = assets.categories.find(cat=>cat.title == selectedSong.category).songSkin.outline
}else{
ctx.fillStyle = this.categories.default.infoFill
ctx.fillStyle = assets.categories.find(cat=>cat.title == 'default').songSkin.outline
}
this.draw.roundedRect({
ctx: ctx,
@ -1425,12 +1391,6 @@
var songLayers = [document.getElementById("layer1"), document.getElementById("layer2")]
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){
var id = selectedSong.songBg
this.songBg.classList.add("songbg-" + id)