Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
Taiko Web
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Taiko Web
Commits
d1ae38e9
Commit
d1ae38e9
authored
Oct 28, 2018
by
Bui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add assets_baseurl config option
parent
6d07afaa
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
106 additions
and
102 deletions
+106
-102
app.py
app.py
+21
-12
config.example.json
config.example.json
+2
-1
public/src/css/main.css
public/src/css/main.css
+0
-8
public/src/js/loader.js
public/src/js/loader.js
+82
-81
templates/index.html
templates/index.html
+1
-0
No files found.
app.py
View file @
d1ae38e9
...
...
@@ -27,6 +27,25 @@ def query_db(query, args=(), one=False):
return
(
rv
[
0
]
if
rv
else
None
)
if
one
else
rv
def
get_config
():
if
os
.
path
.
isfile
(
'config.json'
):
try
:
config
=
json
.
load
(
open
(
'config.json'
,
'r'
))
except
ValueError
:
print
'WARNING: Invalid config.json, using default values'
config
=
{}
else
:
print
'WARNING: No config.json found, using default values'
config
=
{}
if
not
config
.
get
(
'songs_baseurl'
):
config
[
'songs_baseurl'
]
=
''
.
join
([
request
.
host_url
,
'songs'
])
+
'/'
if
not
config
.
get
(
'assets_baseurl'
):
config
[
'assets_baseurl'
]
=
''
.
join
([
request
.
host_url
,
'assets'
])
+
'/'
return
config
def
parse_osu
(
osu
):
osu_lines
=
open
(
osu
,
'r'
)
.
read
()
.
replace
(
'
\x00
'
,
''
)
.
split
(
'
\n
'
)
sections
=
{}
...
...
@@ -110,7 +129,7 @@ def route_index():
version
=
None
if
os
.
path
.
isfile
(
'version.json'
):
version
=
json
.
load
(
open
(
'version.json'
,
'r'
))
return
render_template
(
'index.html'
,
version
=
version
)
return
render_template
(
'index.html'
,
version
=
version
,
config
=
get_config
()
)
@
app
.
route
(
'/api/preview'
)
...
...
@@ -165,17 +184,7 @@ def route_api_songs():
@
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'
])
+
'/'
config
=
get_config
()
return
jsonify
(
config
)
...
...
config.example.json
View file @
d1ae38e9
{
"songs_baseurl"
:
""
"songs_baseurl"
:
""
,
"assets_baseurl"
:
""
}
public/src/css/main.css
View file @
d1ae38e9
@font-face
{
font-family
:
TnT
;
src
:
url("/assets/fonts/TnT.ttf")
format
(
"truetype"
);
}
@font-face
{
font-family
:
Kozuka
;
src
:
url("/assets/fonts/Kozuka.otf")
format
(
"truetype"
);
}
html
,
body
{
margin
:
0
;
...
...
public/src/js/loader.js
View file @
d1ae38e9
...
...
@@ -15,7 +15,7 @@ class Loader{
this
.
screen
.
innerHTML
=
page
this
.
loaderPercentage
=
document
.
querySelector
(
"
#loader .percentage
"
)
this
.
loaderProgress
=
document
.
querySelector
(
"
#loader .progress
"
)
snd
.
buffer
=
new
SoundBuffer
()
snd
.
musicGain
=
snd
.
buffer
.
createGain
()
snd
.
sfxGain
=
snd
.
buffer
.
createGain
()
...
...
@@ -29,97 +29,98 @@ class Loader{
0.5
)
snd
.
sfxLoudGain
.
setVolume
(
1.2
)
snd
.
buffer
.
load
(
"
/assets/audio/
"
+
assets
.
audioOgg
).
then
(()
=>
{
this
.
oggNotSupported
=
false
},
()
=>
{
this
.
oggNotSupported
=
true
}).
then
(()
=>
{
assets
.
fonts
.
forEach
(
name
=>
{
var
font
=
document
.
createElement
(
"
h1
"
)
font
.
style
.
fontFamily
=
name
font
.
appendChild
(
document
.
createTextNode
(
"
I am a font
"
))
this
.
assetsDiv
.
appendChild
(
font
)
this
.
promises
.
push
(
new
Promise
((
resolve
,
reject
)
=>
{
FontDetect
.
onFontLoaded
(
name
,
resolve
,
reject
,
{
msTimeout
:
90000
})
}))
})
var
fontDetectDiv
=
document
.
getElementById
(
"
fontdetectHelper
"
)
fontDetectDiv
.
parentNode
.
removeChild
(
fontDetectDiv
)
assets
.
img
.
forEach
(
name
=>
{
var
id
=
this
.
getFilename
(
name
)
var
image
=
document
.
createElement
(
"
img
"
)
this
.
promises
.
push
(
pageEvents
.
load
(
image
))
image
.
id
=
name
image
.
src
=
"
/assets/img/
"
+
name
this
.
assetsDiv
.
appendChild
(
image
)
assets
.
image
[
id
]
=
image
})
assets
.
audioSfx
.
forEach
(
name
=>
{
this
.
promises
.
push
(
this
.
loadSound
(
name
,
snd
.
sfxGain
))
})
assets
.
audioMusic
.
forEach
(
name
=>
{
this
.
promises
.
push
(
this
.
loadSound
(
name
,
snd
.
musicGain
))
})
assets
.
audioSfxLR
.
forEach
(
name
=>
{
this
.
promises
.
push
(
this
.
loadSound
(
name
,
snd
.
sfxGain
).
then
(
sound
=>
{
this
.
promises
.
push
(
this
.
ajax
(
"
/api/config
"
).
then
(
conf
=>
{
gameConfig
=
JSON
.
parse
(
conf
)
snd
.
buffer
.
load
(
gameConfig
.
assets_baseurl
+
"
audio/
"
+
assets
.
audioOgg
).
then
(()
=>
{
this
.
oggNotSupported
=
false
},
()
=>
{
this
.
oggNotSupported
=
true
}).
then
(()
=>
{
assets
.
fonts
.
forEach
(
name
=>
{
var
font
=
document
.
createElement
(
"
h1
"
)
font
.
style
.
fontFamily
=
name
font
.
appendChild
(
document
.
createTextNode
(
"
I am a font
"
))
this
.
assetsDiv
.
appendChild
(
font
)
this
.
promises
.
push
(
new
Promise
((
resolve
,
reject
)
=>
{
FontDetect
.
onFontLoaded
(
name
,
resolve
,
reject
,
{
msTimeout
:
90000
})
}))
})
var
fontDetectDiv
=
document
.
getElementById
(
"
fontdetectHelper
"
)
fontDetectDiv
.
parentNode
.
removeChild
(
fontDetectDiv
)
assets
.
img
.
forEach
(
name
=>
{
var
id
=
this
.
getFilename
(
name
)
assets
.
sounds
[
id
+
"
_p1
"
]
=
assets
.
sounds
[
id
].
copy
(
snd
.
sfxGainL
)
assets
.
sounds
[
id
+
"
_p2
"
]
=
assets
.
sounds
[
id
].
copy
(
snd
.
sfxGainR
)
var
image
=
document
.
createElement
(
"
img
"
)
this
.
promises
.
push
(
pageEvents
.
load
(
image
))
image
.
id
=
name
image
.
src
=
gameConfig
.
assets_baseurl
+
"
img/
"
+
name
this
.
assetsDiv
.
appendChild
(
image
)
assets
.
image
[
id
]
=
image
})
assets
.
audioSfx
.
forEach
(
name
=>
{
this
.
promises
.
push
(
this
.
loadSound
(
name
,
snd
.
sfxGain
))
})
assets
.
audioMusic
.
forEach
(
name
=>
{
this
.
promises
.
push
(
this
.
loadSound
(
name
,
snd
.
musicGain
))
})
assets
.
audioSfxLR
.
forEach
(
name
=>
{
this
.
promises
.
push
(
this
.
loadSound
(
name
,
snd
.
sfxGain
).
then
(
sound
=>
{
var
id
=
this
.
getFilename
(
name
)
assets
.
sounds
[
id
+
"
_p1
"
]
=
assets
.
sounds
[
id
].
copy
(
snd
.
sfxGainL
)
assets
.
sounds
[
id
+
"
_p2
"
]
=
assets
.
sounds
[
id
].
copy
(
snd
.
sfxGainR
)
}))
})
assets
.
audioSfxLoud
.
forEach
(
name
=>
{
this
.
promises
.
push
(
this
.
loadSound
(
name
,
snd
.
sfxLoudGain
))
})
this
.
promises
.
push
(
this
.
ajax
(
"
/api/songs
"
).
then
(
songs
=>
{
assets
.
songs
=
JSON
.
parse
(
songs
)
}))
})
assets
.
audioSfxLoud
.
forEach
(
name
=>
{
this
.
promises
.
push
(
this
.
loadSound
(
name
,
snd
.
sfxLoudGain
))
})
this
.
promises
.
push
(
this
.
ajax
(
"
/api/songs
"
).
then
(
songs
=>
{
assets
.
songs
=
JSON
.
parse
(
songs
)
}))
this
.
promises
.
push
(
this
.
ajax
(
"
/api/config
"
).
then
(
conf
=>
{
gameConfig
=
JSON
.
parse
(
conf
)
}))
assets
.
views
.
forEach
(
name
=>
{
var
id
=
this
.
getFilename
(
name
)
this
.
promises
.
push
(
this
.
ajax
(
"
src/views/
"
+
name
).
then
(
page
=>
{
assets
.
pages
[
id
]
=
page
assets
.
views
.
forEach
(
name
=>
{
var
id
=
this
.
getFilename
(
name
)
this
.
promises
.
push
(
this
.
ajax
(
"
src/views/
"
+
name
).
then
(
page
=>
{
assets
.
pages
[
id
]
=
page
}))
})
this
.
promises
.
push
(
this
.
canvasTest
.
blurPerformance
().
then
(
result
=>
{
perf
.
blur
=
result
if
(
result
>
1000
/
50
){
// Less than 50 fps with blur enabled
disableBlur
=
true
}
}))
})
this
.
promises
.
push
(
this
.
canvasTest
.
blurPerformance
().
then
(
result
=>
{
perf
.
blur
=
result
if
(
result
>
1000
/
50
){
// Less than 50 fps with blur enabled
disableBlur
=
true
}
}))
this
.
promises
.
forEach
(
promise
=>
{
promise
.
then
(
this
.
assetLoaded
.
bind
(
this
))
})
Promise
.
all
(
this
.
promises
).
then
(()
=>
{
this
.
canvasTest
.
drawAllImages
().
then
(
result
=>
{
perf
.
allImg
=
result
perf
.
load
=
(
+
new
Date
)
-
this
.
startTime
this
.
canvasTest
.
clean
()
this
.
clean
()
this
.
callback
()
this
.
promises
.
forEach
(
promise
=>
{
promise
.
then
(
this
.
assetLoaded
.
bind
(
this
))
})
},
this
.
errorMsg
.
bind
(
this
))
})
Promise
.
all
(
this
.
promises
).
then
(()
=>
{
this
.
canvasTest
.
drawAllImages
().
then
(
result
=>
{
perf
.
allImg
=
result
perf
.
load
=
(
+
new
Date
)
-
this
.
startTime
this
.
canvasTest
.
clean
()
this
.
clean
()
this
.
callback
()
})
},
this
.
errorMsg
.
bind
(
this
))
})
}))
}
loadSound
(
name
,
gain
){
if
(
this
.
oggNotSupported
&&
name
.
endsWith
(
"
.ogg
"
)){
name
=
name
.
slice
(
0
,
-
4
)
+
"
.wav
"
}
var
id
=
this
.
getFilename
(
name
)
return
gain
.
load
(
"
/assets/
audio/
"
+
name
).
then
(
sound
=>
{
return
gain
.
load
(
gameConfig
.
assets_baseurl
+
"
audio/
"
+
name
).
then
(
sound
=>
{
assets
.
sounds
[
id
]
=
sound
})
}
...
...
templates/index.html
View file @
d1ae38e9
...
...
@@ -22,6 +22,7 @@
<link
rel=
"stylesheet"
href=
"/src/css/loadsong.css?{{version.commit_short}}"
>
<link
rel=
"stylesheet"
href=
"/src/css/game.css?{{version.commit_short}}"
>
<link
rel=
"stylesheet"
href=
"/src/css/debug.css?{{version.commit_short}}"
>
<link
rel=
"stylesheet"
href=
"{{config.assets_baseurl}}fonts/fonts.css?{{version.commit_short}}"
>
<script
src=
"/src/js/lib/fontdetect.min.js?{{version.commit_short}}"
></script>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment