Merge pull request #174 from bui/mark-feature

SongSelect: Add maker identification
This commit is contained in:
Bui 2019-11-25 01:47:25 +00:00 committed by GitHub
commit 01e1a1ad25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 144 additions and 4 deletions

10
app.py
View File

@ -107,7 +107,7 @@ def route_api_preview():
@app.route('/api/songs') @app.route('/api/songs')
@app.cache.cached(timeout=15) @app.cache.cached(timeout=15)
def route_api_songs(): def route_api_songs():
songs = query_db('select * from songs where enabled = 1') songs = query_db('select s.*, m.name, m.url from songs s left join makers m on s.maker_id = m.maker_id where enabled = 1')
raw_categories = query_db('select * from categories') raw_categories = query_db('select * from categories')
categories = {} categories = {}
@ -127,6 +127,11 @@ def route_api_songs():
category_out = categories[song[11]] if song[11] in categories else "" category_out = categories[song[11]] if song[11] in categories else ""
song_skin_out = song_skins[song[14]] if song[14] in song_skins else None song_skin_out = song_skins[song[14]] if song[14] in song_skins else None
maker = None
if song[17] == 0:
maker = 0
elif song[17] and song[17] > 0:
maker = {'name': song[18], 'url': song[19], 'id': song[17]}
songs_out.append({ songs_out.append({
'id': song_id, 'id': song_id,
@ -142,7 +147,8 @@ def route_api_songs():
'type': song_type, 'type': song_type,
'offset': song[13], 'offset': song[13],
'song_skin': song_skin_out, 'song_skin': song_skin_out,
'volume': song[16] 'volume': song[16],
'maker': maker
}) })
return jsonify(songs_out) return jsonify(songs_out)

View File

@ -231,6 +231,9 @@
if(meta.taikowebskin){ if(meta.taikowebskin){
songObj.song_skin = this.getSkin(dir, meta.taikowebskin) songObj.song_skin = this.getSkin(dir, meta.taikowebskin)
} }
if(meta.maker){
songObj.maker = {name: meta.maker, id: 1}
}
for(var id in allStrings){ for(var id in allStrings){
var songTitle = songObj.title var songTitle = songObj.title
var ura = "" var ura = ""

View File

@ -114,7 +114,8 @@ class SongSelect{
offset: song.offset, offset: song.offset,
songSkin: song.song_skin || {}, songSkin: song.song_skin || {},
music: song.music, music: song.music,
volume: song.volume volume: song.volume,
maker: song.maker
}) })
} }
this.songs.sort((a, b) => { this.songs.sort((a, b) => {
@ -431,6 +432,8 @@ class SongSelect{
this.toSongSelect() this.toSongSelect()
}else if(moveBy === 1){ }else if(moveBy === 1){
this.toOptions(1) this.toOptions(1)
}else if(moveBy === "maker"){
window.open(this.songs[this.selectedSong].maker.url)
}else if(moveBy === this.diffOptions.length + 4){ }else if(moveBy === this.diffOptions.length + 4){
this.state.ura = !this.state.ura this.state.ura = !this.state.ura
assets.sounds["se_ka"].play() assets.sounds["se_ka"].play()
@ -518,6 +521,8 @@ class SongSelect{
if(this.state.locked === 0){ if(this.state.locked === 0){
if(223 < x && x < 367 && 118 < y && y < 422){ if(223 < x && x < 367 && 118 < y && y < 422){
return Math.floor((x - 223) / ((367 - 223) / 2)) return Math.floor((x - 223) / ((367 - 223) / 2))
}else if(this.songs[this.selectedSong].maker && this.songs[this.selectedSong].maker.id > 0 && this.songs[this.selectedSong].maker.url && x > 230 && x < 485 && y > 432 && y < 519) {
return "maker"
}else if(550 < x && x < 1050 && 95 < y && y < 524){ }else if(550 < x && x < 1050 && 95 < y && y < 524){
var moveBy = Math.floor((x - 550) / ((1050 - 550) / 5)) + this.diffOptions.length var moveBy = Math.floor((x - 550) / ((1050 - 550) / 5)) + this.diffOptions.length
var currentSong = this.songs[this.selectedSong] var currentSong = this.songs[this.selectedSong]
@ -1474,6 +1479,112 @@ class SongSelect{
}) })
} }
if(currentSong.maker !== null){
if (songSel) {
var _x = x + 38
var _y = y + 10
ctx.lineWidth = 5
var grd = ctx.createLinearGradient(_x, _y, _x, _y+50);
grd.addColorStop(0, '#fa251a');
grd.addColorStop(1, '#ffdc33');
ctx.fillStyle = grd;
this.draw.roundedRect({
ctx: ctx,
x: _x - 28,
y: _y,
w: 130,
h: 50,
radius: 24
})
ctx.fill()
ctx.stroke()
ctx.beginPath()
ctx.arc(_x, _y + 28, 20, 0, Math.PI * 2)
ctx.fill()
this.draw.layeredText({
ctx: ctx,
text: strings.creative.creative,
fontSize: strings.id == "en" ? 30 : 34,
fontFamily: this.font,
align: "center",
baseline: "middle",
x: _x + 38,
y: _y + (["ja", "en"].indexOf(strings.id) >= 0 ? 25 : 28),
width: 110
}, [
{outline: "#fff", letterBorder: 8},
{fill: "#000"}
])
} else if(currentSong.maker && currentSong.maker.id > 0 && currentSong.maker.name){
var _x = x + 62
var _y = y + 380
ctx.lineWidth = 5
var grd = ctx.createLinearGradient(_x, _y, _x, _y+50);
grd.addColorStop(0, '#fa251a');
grd.addColorStop(1, '#ffdc33');
ctx.fillStyle = '#75E2EE';
this.draw.roundedRect({
ctx: ctx,
x: _x - 28,
y: _y,
w: 250,
h: 80,
radius: 15
})
ctx.fill()
ctx.stroke()
ctx.beginPath()
ctx.arc(_x, _y + 28, 20, 0, Math.PI * 2)
ctx.fill()
this.draw.layeredText({
ctx: ctx,
text: strings.creative.maker,
fontSize: 24,
fontFamily: this.font,
align: "left",
baseline: "middle",
x: _x - 15,
y: _y + 23
}, [
{outline: "#000", letterBorder: 8},
{fill: "#fff"}
])
this.draw.layeredText({
ctx: ctx,
text: currentSong.maker.name,
fontSize: 28,
fontFamily: this.font,
align: "center",
baseline: "middle",
x: _x + 100,
y: _y + 56,
width: 210
}, [
{outline: "#fff", letterBorder: 8},
{fill: "#000"}
])
if(this.state.moveHover === "maker"){
this.draw.highlight({
ctx: ctx,
x: _x - 32,
y: _y - 3,
w: 250 + 7,
h: 80 + 7,
opacity: 0.8,
radius: 15
})
}
}
}
if(!songSel && currentSong.stars[4]){ if(!songSel && currentSong.stars[4]){
var fade = ((ms - this.state.screenMS) % 1200) / 1200 var fade = ((ms - this.state.screenMS) % 1200) / 1200
var _x = x + 402 + 4 * 100 + fade * 25 var _x = x + 402 + 4 * 100 + fade * 25

View File

@ -137,6 +137,10 @@
failedTests: "このテストは失敗しました:", failedTests: "このテストは失敗しました:",
supportedBrowser: "%sなどのサポートされているブラウザを使用してください" supportedBrowser: "%sなどのサポートされているブラウザを使用してください"
} }
this.creative = {
creative: '創作',
maker: 'メーカー'
}
} }
function StringsEn(){ function StringsEn(){
this.id = "en" this.id = "en"
@ -277,6 +281,10 @@ function StringsEn(){
failedTests: "The following tests have failed:", failedTests: "The following tests have failed:",
supportedBrowser: "Please use a supported browser such as %s" supportedBrowser: "Please use a supported browser such as %s"
} }
this.creative = {
creative: 'Creative',
maker: 'Maker:'
}
} }
function StringsCn(){ function StringsCn(){
this.id = "cn" this.id = "cn"
@ -417,6 +425,10 @@ function StringsCn(){
failedTests: "The following tests have failed:", failedTests: "The following tests have failed:",
supportedBrowser: "Please use a supported browser such as %s" supportedBrowser: "Please use a supported browser such as %s"
} }
this.creative = {
creative: '创作',
maker: '制作者'
}
} }
function StringsTw(){ function StringsTw(){
this.id = "tw" this.id = "tw"
@ -557,6 +569,10 @@ function StringsTw(){
failedTests: "The following tests have failed:", failedTests: "The following tests have failed:",
supportedBrowser: "Please use a supported browser such as %s" supportedBrowser: "Please use a supported browser such as %s"
} }
this.creative = {
creative: '創作',
maker: '製作者'
}
} }
function StringsKo(){ function StringsKo(){
this.id = "ko" this.id = "ko"
@ -697,6 +713,10 @@ function StringsKo(){
failedTests: "The following tests have failed:", failedTests: "The following tests have failed:",
supportedBrowser: "Please use a supported browser such as %s" supportedBrowser: "Please use a supported browser such as %s"
} }
this.creative = {
creative: '창작',
maker: '만드는 사람'
}
} }
var allStrings = { var allStrings = {
"ja": new StringsJa(), "ja": new StringsJa(),