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
21259abd
Commit
21259abd
authored
Mar 06, 2020
by
LoveEevee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Scoresheet: Save results to localstorage
parent
41afc2a9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
165 additions
and
1 deletion
+165
-1
public/src/js/assets.js
public/src/js/assets.js
+2
-1
public/src/js/loader.js
public/src/js/loader.js
+1
-0
public/src/js/main.js
public/src/js/main.js
+1
-0
public/src/js/scoresheet.js
public/src/js/scoresheet.js
+24
-0
public/src/js/scorestorage.js
public/src/js/scorestorage.js
+135
-0
public/src/js/songselect.js
public/src/js/songselect.js
+2
-0
No files found.
public/src/js/assets.js
View file @
21259abd
...
...
@@ -30,7 +30,8 @@ var assets = {
"
session.js
"
,
"
importsongs.js
"
,
"
logo.js
"
,
"
settings.js
"
"
settings.js
"
,
"
scorestorage.js
"
],
"
css
"
:
[
"
main.css
"
,
...
...
public/src/js/loader.js
View file @
21259abd
...
...
@@ -204,6 +204,7 @@ class Loader{
}
settings
=
new
Settings
()
scoreStorage
=
new
ScoreStorage
()
pageEvents
.
setKbd
()
Promise
.
all
(
this
.
promises
).
then
(()
=>
{
...
...
public/src/js/main.js
View file @
21259abd
...
...
@@ -83,6 +83,7 @@ var perf = {
var
strings
var
vectors
var
settings
var
scoreStorage
pageEvents
.
add
(
root
,
[
"
touchstart
"
,
"
touchmove
"
,
"
touchend
"
],
event
=>
{
if
(
event
.
cancelable
&&
cancelTouch
&&
event
.
target
.
tagName
!==
"
SELECT
"
){
...
...
public/src/js/scoresheet.js
View file @
21259abd
class
Scoresheet
{
constructor
(
controller
,
results
,
multiplayer
,
touchEnabled
){
this
.
controller
=
controller
this
.
resultsObj
=
results
this
.
results
=
{}
for
(
var
i
in
results
){
this
.
results
[
i
]
=
results
[
i
].
toString
()
...
...
@@ -54,6 +55,7 @@ class Scoresheet{
"
ura
"
:
4
}
this
.
scoreSaved
=
false
this
.
redrawRunning
=
true
this
.
redrawBind
=
this
.
redraw
.
bind
(
this
)
this
.
redraw
()
...
...
@@ -248,6 +250,9 @@ class Scoresheet{
if
(
this
.
state
.
screen
===
"
fadeIn
"
&&
elapsed
<
1000
){
bgOffset
=
Math
.
min
(
1
,
this
.
draw
.
easeIn
(
1
-
elapsed
/
1000
))
*
(
winH
/
2
)
}
if
((
this
.
state
.
screen
!==
"
fadeIn
"
||
elapsed
>=
1000
)
&&
!
this
.
scoreSaved
){
this
.
saveScore
()
}
if
(
bgOffset
){
ctx
.
save
()
...
...
@@ -854,6 +859,25 @@ class Scoresheet{
return
Date
.
now
()
}
saveScore
(){
if
(
!
this
.
controller
.
autoPlayEnabled
&&
this
.
resultsObj
.
points
>
0
){
var
title
=
this
.
controller
.
selectedSong
.
originalTitle
var
difficulty
=
this
.
resultsObj
.
difficulty
var
oldScore
=
scoreStorage
.
get
(
title
,
difficulty
)
if
(
!
oldScore
||
oldScore
.
points
<=
this
.
resultsObj
.
points
){
this
.
resultsObj
.
crown
=
""
if
(
this
.
controller
.
game
.
rules
.
clearReached
(
this
.
resultsObj
.
gauge
)){
this
.
resultsObj
.
crown
=
this
.
resultsObj
.
bad
===
0
?
"
gold
"
:
"
silver
"
}
delete
this
.
resultsObj
.
title
delete
this
.
resultsObj
.
difficulty
delete
this
.
resultsObj
.
gauge
scoreStorage
.
add
(
title
,
difficulty
,
this
.
resultsObj
)
}
}
this
.
scoreSaved
=
true
}
clean
(){
this
.
keyboard
.
clean
()
this
.
gamepad
.
clean
()
...
...
public/src/js/scorestorage.js
0 → 100644
View file @
21259abd
class
ScoreStorage
{
constructor
(){
this
.
scores
=
{}
this
.
difficulty
=
[
"
oni
"
,
"
ura
"
,
"
hard
"
,
"
normal
"
,
"
easy
"
]
this
.
scoreKeys
=
[
"
points
"
,
"
good
"
,
"
ok
"
,
"
bad
"
,
"
maxCombo
"
,
"
drumroll
"
]
this
.
crownValue
=
[
""
,
"
silver
"
,
"
gold
"
]
this
.
load
()
}
load
(){
this
.
scores
=
{}
this
.
scoreStrings
=
{}
try
{
var
localScores
=
localStorage
.
getItem
(
"
scoreStorage
"
)
if
(
localScores
){
this
.
scoreStrings
=
JSON
.
parse
(
localScores
)
}
}
catch
(
e
){}
for
(
var
song
in
this
.
scoreStrings
){
var
scoreString
=
this
.
scoreStrings
[
song
]
var
songAdded
=
false
if
(
typeof
scoreString
===
"
string
"
&&
scoreString
){
var
diffArray
=
scoreString
.
split
(
"
;
"
)
for
(
var
i
in
this
.
difficulty
){
if
(
diffArray
[
i
]){
var
crown
=
parseInt
(
diffArray
[
i
].
slice
(
0
,
1
))
||
0
var
score
=
{
crown
:
this
.
crownValue
[
crown
]
||
""
}
var
scoreArray
=
diffArray
[
i
].
slice
(
1
).
split
(
"
,
"
)
for
(
var
j
in
this
.
scoreKeys
){
var
name
=
this
.
scoreKeys
[
j
]
var
value
=
parseInt
(
scoreArray
[
j
],
36
)
||
0
if
(
value
<
0
){
value
=
0
}
score
[
name
]
=
value
}
if
(
!
songAdded
){
this
.
scores
[
song
]
=
[]
songAdded
=
true
}
this
.
scores
[
song
][
this
.
difficulty
[
i
]]
=
score
}
}
}
}
}
save
(){
for
(
var
song
in
this
.
scores
){
this
.
writeString
(
song
)
}
this
.
write
()
}
write
(){
try
{
localStorage
.
setItem
(
"
scoreStorage
"
,
JSON
.
stringify
(
this
.
scoreStrings
))
}
catch
(
e
){}
}
writeString
(
song
){
var
score
=
this
.
scores
[
song
]
var
diffArray
=
[]
var
notEmpty
=
false
for
(
var
i
=
this
.
difficulty
.
length
;
i
--
;){
var
diff
=
this
.
difficulty
[
i
]
if
(
score
[
diff
]){
var
scoreArray
=
[]
var
crown
=
this
.
crownValue
.
indexOf
(
score
[
diff
].
crown
).
toString
()
for
(
var
j
in
this
.
scoreKeys
){
var
name
=
this
.
scoreKeys
[
j
]
var
value
=
score
[
diff
][
name
]
value
=
Math
.
floor
(
value
).
toString
(
36
)
scoreArray
.
push
(
value
)
}
diffArray
.
unshift
(
crown
+
scoreArray
.
join
(
"
,
"
))
notEmpty
=
true
}
else
if
(
notEmpty
){
diffArray
.
unshift
(
""
)
}
}
this
.
scoreStrings
[
song
]
=
diffArray
.
join
(
"
;
"
)
}
get
(
song
,
difficulty
){
if
(
!
song
){
return
this
.
scores
}
else
if
(
song
in
this
.
scores
){
if
(
difficulty
){
return
this
.
scores
[
song
][
difficulty
]
}
else
{
return
this
.
scores
[
song
]
}
}
}
add
(
song
,
difficulty
,
scoreObject
){
if
(
!
(
song
in
this
.
scores
)){
this
.
scores
[
song
]
=
{}
}
this
.
scores
[
song
][
difficulty
]
=
scoreObject
this
.
writeString
(
song
)
this
.
write
()
}
template
(){
var
template
=
{
crown
:
""
}
for
(
var
i
in
this
.
scoreKeys
){
var
name
=
this
.
scoreKeys
[
i
]
template
[
name
]
=
0
}
return
template
}
remove
(
song
,
difficulty
){
if
(
song
in
this
.
scores
){
if
(
difficulty
){
if
(
difficulty
in
this
.
scores
[
song
]){
delete
this
.
scores
[
song
][
difficulty
]
var
noDiff
=
true
for
(
var
i
in
this
.
difficulty
){
if
(
this
.
scores
[
song
][
this
.
difficulty
[
i
]]){
noDiff
=
false
break
}
}
if
(
noDiff
){
delete
this
.
scores
[
song
]
delete
this
.
scoreStrings
[
song
]
}
else
{
this
.
writeString
(
song
)
}
}
}
else
{
delete
this
.
scores
[
song
]
delete
this
.
scoreStrings
[
song
]
}
this
.
write
()
}
}
}
public/src/js/songselect.js
View file @
21259abd
...
...
@@ -113,6 +113,7 @@ class SongSelect{
this
.
songs
.
push
({
id
:
song
.
id
,
title
:
title
,
originalTitle
:
song
.
title
,
subtitle
:
subtitle
,
skin
:
song
.
category
in
this
.
songSkin
?
this
.
songSkin
[
song
.
category
]
:
this
.
songSkin
.
default
,
stars
:
song
.
stars
,
...
...
@@ -738,6 +739,7 @@ class SongSelect{
new
LoadSong
({
"
title
"
:
selectedSong
.
title
,
"
originalTitle
"
:
selectedSong
.
originalTitle
,
"
folder
"
:
selectedSong
.
id
,
"
difficulty
"
:
this
.
difficultyId
[
difficulty
],
"
category
"
:
selectedSong
.
category
,
...
...
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