commit
6d07afaa11
1
.gitignore
vendored
1
.gitignore
vendored
@ -46,3 +46,4 @@ public/api
|
|||||||
taiko.db
|
taiko.db
|
||||||
version.json
|
version.json
|
||||||
public/index.html
|
public/index.html
|
||||||
|
config.json
|
16
app.py
16
app.py
@ -163,6 +163,22 @@ def route_api_songs():
|
|||||||
return jsonify(songs_out)
|
return jsonify(songs_out)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/config')
|
||||||
|
def route_api_config():
|
||||||
|
if os.path.isfile('config.json'):
|
||||||
|
config = json.load(open('config.json', 'r'))
|
||||||
|
else:
|
||||||
|
print 'WARNING: No config.json found, using default values'
|
||||||
|
config = {
|
||||||
|
'songs_baseurl': ''.join([request.host_url, 'songs']) + '/'
|
||||||
|
}
|
||||||
|
|
||||||
|
if not config.get('songs_baseurl'):
|
||||||
|
config['songs_baseurl'] = ''.join([request.host_url, 'songs']) + '/'
|
||||||
|
|
||||||
|
return jsonify(config)
|
||||||
|
|
||||||
|
|
||||||
def make_preview(song_id, song_type):
|
def make_preview(song_id, song_type):
|
||||||
song_path = 'public/songs/%s/main.mp3' % song_id
|
song_path = 'public/songs/%s/main.mp3' % song_id
|
||||||
prev_path = 'public/songs/%s/preview.mp3' % song_id
|
prev_path = 'public/songs/%s/preview.mp3' % song_id
|
||||||
|
3
config.example.json
Normal file
3
config.example.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"songs_baseurl": ""
|
||||||
|
}
|
@ -125,3 +125,5 @@ var assets = {
|
|||||||
"image": {},
|
"image": {},
|
||||||
"pages": {}
|
"pages": {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var gameConfig = {}
|
||||||
|
@ -7,7 +7,7 @@ class Controller{
|
|||||||
this.touchEnabled = touchEnabled
|
this.touchEnabled = touchEnabled
|
||||||
this.snd = this.multiplayer ? "_p" + this.multiplayer : ""
|
this.snd = this.multiplayer ? "_p" + this.multiplayer : ""
|
||||||
|
|
||||||
var backgroundURL = "/songs/" + this.selectedSong.folder + "/bg.png"
|
var backgroundURL = gameConfig.songs_baseurl + this.selectedSong.folder + "/bg.png"
|
||||||
|
|
||||||
if(selectedSong.type === "tja"){
|
if(selectedSong.type === "tja"){
|
||||||
this.parsedSongData = new ParseTja(songData, selectedSong.difficulty, selectedSong.offset)
|
this.parsedSongData = new ParseTja(songData, selectedSong.difficulty, selectedSong.offset)
|
||||||
|
@ -78,6 +78,10 @@ class Loader{
|
|||||||
this.promises.push(this.ajax("/api/songs").then(songs => {
|
this.promises.push(this.ajax("/api/songs").then(songs => {
|
||||||
assets.songs = JSON.parse(songs)
|
assets.songs = JSON.parse(songs)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
this.promises.push(this.ajax("/api/config").then(conf => {
|
||||||
|
gameConfig = JSON.parse(conf)
|
||||||
|
}))
|
||||||
|
|
||||||
assets.views.forEach(name => {
|
assets.views.forEach(name => {
|
||||||
var id = this.getFilename(name)
|
var id = this.getFilename(name)
|
||||||
|
@ -19,7 +19,7 @@ class loadSong{
|
|||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
img.id = "music-bg"
|
img.id = "music-bg"
|
||||||
img.src = "/songs/" + id + "/bg.png"
|
img.src = gameConfig.songs_baseurl + id + "/bg.png"
|
||||||
document.getElementById("assets").appendChild(img)
|
document.getElementById("assets").appendChild(img)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ class loadSong{
|
|||||||
songObj.sound.gain = snd.musicGain
|
songObj.sound.gain = snd.musicGain
|
||||||
resolve()
|
resolve()
|
||||||
}else{
|
}else{
|
||||||
snd.musicGain.load("/songs/" + id + "/main.mp3").then(sound => {
|
snd.musicGain.load(gameConfig.songs_baseurl + id + "/main.mp3").then(sound => {
|
||||||
songObj.sound = sound
|
songObj.sound = sound
|
||||||
resolve()
|
resolve()
|
||||||
}, reject)
|
}, reject)
|
||||||
@ -51,7 +51,7 @@ class loadSong{
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
getSongPath(selectedSong){
|
getSongPath(selectedSong){
|
||||||
var directory = "/songs/" + selectedSong.folder + "/"
|
var directory = gameConfig.songs_baseurl + selectedSong.folder + "/"
|
||||||
if(selectedSong.type === "tja"){
|
if(selectedSong.type === "tja"){
|
||||||
return directory + "main.tja"
|
return directory + "main.tja"
|
||||||
}else{
|
}else{
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
class SongSelect{
|
class SongSelect{
|
||||||
constructor(fromTutorial, fadeIn, touchEnabled){
|
constructor(fromTutorial, fadeIn, touchEnabled){
|
||||||
this.touchEnabled = touchEnabled
|
this.touchEnabled = touchEnabled
|
||||||
|
|
||||||
loader.changePage("songselect")
|
loader.changePage("songselect")
|
||||||
this.canvas = document.getElementById("song-sel-canvas")
|
this.canvas = document.getElementById("song-sel-canvas")
|
||||||
this.ctx = this.canvas.getContext("2d")
|
this.ctx = this.canvas.getContext("2d")
|
||||||
|
|
||||||
this.songSkin = {
|
this.songSkin = {
|
||||||
"selected": {
|
"selected": {
|
||||||
background: "#ffdb2c",
|
background: "#ffdb2c",
|
||||||
@ -1363,7 +1363,7 @@ class SongSelect{
|
|||||||
var previewFilename = prvTime > 0.1 ? "/preview.mp3" : "/main.mp3"
|
var previewFilename = prvTime > 0.1 ? "/preview.mp3" : "/main.mp3"
|
||||||
|
|
||||||
var loadPreview = previewFilename => {
|
var loadPreview = previewFilename => {
|
||||||
return snd.previewGain.load("/songs/" + id + previewFilename)
|
return snd.previewGain.load(gameConfig.songs_baseurl + id + previewFilename)
|
||||||
}
|
}
|
||||||
|
|
||||||
songObj.preview_time = 0
|
songObj.preview_time = 0
|
||||||
|
@ -751,7 +751,7 @@
|
|||||||
setBackground(){
|
setBackground(){
|
||||||
var gameDiv = document.getElementById("game")
|
var gameDiv = document.getElementById("game")
|
||||||
var selectedSong = this.controller.selectedSong
|
var selectedSong = this.controller.selectedSong
|
||||||
var bg = "/songs/" + selectedSong.folder + "/bg.png"
|
var bg = gameConfig.songs_baseurl + selectedSong.folder + "/bg.png"
|
||||||
if(selectedSong.defaultBg){
|
if(selectedSong.defaultBg){
|
||||||
var categories = {
|
var categories = {
|
||||||
"J-POP": 0,
|
"J-POP": 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user