Merge branch 'browsersupport-translate' of LoveEevee/taiko-web into master

This commit is contained in:
Bui 2019-01-26 19:39:05 +01:00 committed by Gitea
commit faa6f1991e
10 changed files with 201 additions and 87 deletions

View File

@ -64,28 +64,27 @@ body{
left: 0; left: 0;
max-height: 100%; max-height: 100%;
overflow: hidden auto; overflow: hidden auto;
padding: 10px; padding: 0.5em;
background: #aef; background: #aef;
font-family: sans-serif; font-family: sans-serif;
font-size: 20px; font-size: 20px;
cursor: default; cursor: default;
z-index: 10; z-index: 10;
} }
#unsupportedBrowser::before{ #unsupportedWarn{
content: "!";
display: inline-block; display: inline-block;
width: 30px; width: 1.5em;
height: 30px; height: 1.5em;
margin-right: 10px; margin-right: 0.5em;
background: #39a; background: #39a;
color: #fff; color: #fff;
text-align: center; text-align: center;
line-height: 30px; line-height: 1.5em;
} }
#unsupportedBrowser.hidden{ #unsupportedBrowser.hidden{
width: 30px; width: 1.5em;
} }
#unsupportedBrowser.hidden *{ #unsupportedBrowser.hidden *:not(#unsupportedWarn){
display: none !important; display: none !important;
} }
#unsupportedBrowser a{ #unsupportedBrowser a{
@ -97,13 +96,13 @@ body{
text-decoration: underline; text-decoration: underline;
} }
#unsupportedBrowser ul{ #unsupportedBrowser ul{
margin: 5px; margin: 0.25em;
} }
#unsupportedDetails{ #unsupportedDetails{
display: none; display: none;
margin: 10px 50px 0 50px; margin: 0.5em 2.5em 0 2.5em;
border: 3px solid #39a; border: 0.15em solid #39a;
padding: 5px; padding: 0.25em;
cursor: auto; cursor: auto;
user-select: text; user-select: text;
} }
@ -111,10 +110,10 @@ body{
position: absolute; position: absolute;
right: 0; right: 0;
top: 0; top: 0;
width: 50px; width: 2.5em;
height: 50px; height: 2.5em;
text-align: center; text-align: center;
line-height: 45px; line-height: 2.25em;
color: #777; color: #777;
text-shadow: 1px 1px #fff; text-shadow: 0.05em 0.05em #fff;
} }

View File

@ -110,9 +110,13 @@
top: calc(50% + -1vw); top: calc(50% + -1vw);
bottom: auto; bottom: auto;
} }
@keyframes donbg-scroll{ @keyframes donbg-scroll1{
from{background-position-x: 0} from{background-position-x: 0}
to{background-position-x: calc(var(--h) / var(--sh1) * var(--sw) * -1)} to{background-position-x: calc(var(--h) / var(--sh1) * var(--sw1) * -1)}
}
@keyframes donbg-scroll2{
from{background-position-x: 0}
to{background-position-x: calc(var(--h) / var(--sh1) * var(--sw2) * -1)}
} }
@keyframes donbg-raise{ @keyframes donbg-raise{
from{background-position-y: 0} from{background-position-y: 0}
@ -134,7 +138,7 @@
30%{background-position-y: 0} 30%{background-position-y: 0}
} }
.donlayer1{ .donlayer1{
animation: 5s linear donbg-scroll infinite; animation: 5s linear donbg-scroll1 infinite;
background-size: auto 100%; background-size: auto 100%;
} }
.donlayer2{ .donlayer2{
@ -154,21 +158,27 @@
.donbg-4 .donlayer2, .donbg-4 .donlayer2,
.donbg-6 .donlayer2, .donbg-6 .donlayer2,
.donbg-raise .donlayer2{ .donbg-raise .donlayer2{
animation: 5s linear donbg-scroll infinite, 1s linear donbg-raise infinite alternate; animation: 5s linear donbg-scroll2 infinite, 1s linear donbg-raise infinite alternate;
} }
.donbg-3 .donlayer2, .donbg-3 .donlayer2,
.donbg-anim3 .donlayer2{ .donbg-anim3 .donlayer2{
animation: 3.4s linear donbg-scroll infinite, 1.8s linear donbg-anim3 infinite; animation: 3.4s linear donbg-scroll2 infinite, 1.8s linear donbg-anim3 infinite;
} }
.donbg-5 .donlayer2, .donbg-5 .donlayer2,
.donbg-anim5 .donlayer2{ .donbg-anim5 .donlayer2{
animation: 2.7s linear donbg-scroll infinite, 2.2s linear donbg-anim5 infinite; animation: 2.7s linear donbg-scroll2 infinite, 2.2s linear donbg-anim5 infinite;
}
.donbg-equalscroll .donlayer1{
animation: 5.3s linear donbg-scroll1 infinite;
}
.donbg-equalscroll .donlayer2{
animation: 5.3s linear donbg-scroll2 infinite;
} }
.donbg-fastscroll .donlayer1{ .donbg-fastscroll .donlayer1{
animation: 2s linear donbg-scroll infinite; animation: 2s linear donbg-scroll1 infinite;
} }
.donbg-fastscroll .donlayer2{ .donbg-fastscroll .donlayer2{
animation: 1s linear donbg-scroll infinite; animation: 1s linear donbg-scroll2 infinite;
} }
#tetsuohana{ #tetsuohana{

View File

@ -26,7 +26,6 @@ var assets = {
"about.js", "about.js",
"debug.js", "debug.js",
"session.js", "session.js",
"strings.js",
"importsongs.js" "importsongs.js"
], ],
"css": [ "css": [

View File

@ -49,38 +49,99 @@ function browserSupport(){
return el.style.length !== 0 return el.style.length !== 0
} }
} }
var failedTests = [] failedTests = []
for(var name in tests){ for(var name in tests){
var result = false var result = false
try{ try{
result = tests[name]() result = tests[name]()
}catch(e){} }catch(e){}
if(result === false){ if(result === false){
failedTests.push("<li>" + name + "</li>") failedTests.push(name)
} }
} }
if(failedTests.length !== 0){ if(failedTests.length !== 0){
var div = document.createElement("div") showUnsupported()
}
}
function showUnsupported(strings){
if(!strings){
var lang
try{
if("localStorage" in window && window.localStorage.lang && window.localStorage.lang in allStrings){
lang = window.localStorage.lang
}
if(!lang && "languages" in navigator){
var userLang = navigator.languages.slice()
userLang.unshift(navigator.language)
for(var i in userLang){
for(var j in allStrings){
if(allStrings[j].regex.test(userLang[i])){
lang = j
}
}
}
}
}catch(e){}
if(!lang){
lang = "en"
}
strings = allStrings[lang]
}
var div = document.getElementById("unsupportedBrowser")
if(div){
div.parentNode.removeChild(div)
}
div = document.createElement("div")
div.id = "unsupportedBrowser" div.id = "unsupportedBrowser"
div.innerHTML = var warn = document.createElement("div")
'<div id="unsupportedHide">x</div>\ warn.id = "unsupportedWarn"
<span>You are running an unsupported browser (\ warn.innerText = "!"
<a id="unsupportedLink">Details...</a>)</span>\ div.appendChild(warn)
<div id="unsupportedDetails">\ var hide = document.createElement("div")
The following tests have failed:\ hide.id = "unsupportedHide"
<ul>' hide.innerText = "x"
+ failedTests.join("") div.appendChild(hide)
+ '</ul>\
Please use a supported browser such as \ var span = document.createElement("span")
<a href="https://www.google.com/chrome/" id="unsupportedChrome">Google Chrome</a>\ var browserWarning = strings.browserSupport.browserWarning.split("%s")
</div>' for(var i = 0; i < browserWarning.length; i++){
if(i !== 0){
var link = document.createElement("a")
link.innerText = strings.browserSupport.details
span.appendChild(link)
}
span.appendChild(document.createTextNode(browserWarning[i]))
}
div.appendChild(span)
var details = document.createElement("div")
details.id = "unsupportedDetails"
details.appendChild(document.createTextNode(strings.browserSupport.failedTests))
var ul = document.createElement("ul")
for(var i = 0; i < failedTests.length; i++){
var li = document.createElement("li")
li.innerText = failedTests[i]
ul.appendChild(li)
}
details.appendChild(ul)
var supportedBrowser = strings.browserSupport.supportedBrowser.split("%s")
for(var i = 0; i < supportedBrowser.length; i++){
if(i !== 0){
var chrome = document.createElement("a")
chrome.href = "https://www.google.com/chrome/"
chrome.innerText = "Google Chrome"
details.appendChild(chrome)
}
details.appendChild(document.createTextNode(supportedBrowser[i]))
}
div.appendChild(details)
document.body.appendChild(div) document.body.appendChild(div)
var link = document.getElementById("unsupportedLink")
var details = document.getElementById("unsupportedDetails")
var hide = document.getElementById("unsupportedHide")
var chrome = document.getElementById("unsupportedChrome")
var divClick = function(event){ var divClick = function(event){
if(event.type === "touchstart"){ if(event.type === "touchstart"){
event.preventDefault() event.preventDefault()
@ -115,6 +176,11 @@ Please use a supported browser such as \
event.preventDefault() event.preventDefault()
chrome.click() chrome.click()
}) })
var touchText = function(){
div.style.fontSize = "4em"
removeEventListener("touchstart", touchText)
} }
addEventListener("touchstart", touchText)
} }
var failedTests
browserSupport() browserSupport()

View File

@ -22,6 +22,7 @@ class Circle{
this.gogoTime = config.gogoTime this.gogoTime = config.gogoTime
this.gogoChecked = false this.gogoChecked = false
this.beatMS = config.beatMS this.beatMS = config.beatMS
this.fixedPos = config.fixedPos
} }
getMS(){ getMS(){
return this.ms return this.ms

View File

@ -284,7 +284,8 @@ class Game{
type: sound, type: sound,
txt: "", txt: "",
speed: circle.speed, speed: circle.speed,
gogoTime: circle.gogoTime gogoTime: circle.gogoTime,
fixedPos: document.hasFocus()
}) })
circleAnim.played(score, dai) circleAnim.played(score, dai)
circleAnim.animate(ms) circleAnim.animate(ms)

View File

@ -396,6 +396,7 @@ class Scoresheet{
fontFamily: this.font, fontFamily: this.font,
x: 1257, x: 1257,
y: 20, y: 20,
width: 600,
align: "right", align: "right",
forceShadow: true forceShadow: true
}, [ }, [

View File

@ -88,6 +88,12 @@
linkTutorial: "Share this link with your friend to start playing together! Do not leave this screen while they join.", linkTutorial: "Share this link with your friend to start playing together! Do not leave this screen while they join.",
cancel: "Cancel" cancel: "Cancel"
} }
this.browserSupport = {
browserWarning: "サポートされていないブラウザを実行しています (%s)",
details: "詳しく",
failedTests: "このテストは失敗しました:",
supportedBrowser: "%sなどのサポートされているブラウザを使用してください"
}
} }
function StringsEn(){ function StringsEn(){
this.id = "en" this.id = "en"
@ -179,6 +185,12 @@ function StringsEn(){
linkTutorial: "Share this link with your friend to start playing together! Do not leave this screen while they join.", linkTutorial: "Share this link with your friend to start playing together! Do not leave this screen while they join.",
cancel: "Cancel" cancel: "Cancel"
} }
this.browserSupport = {
browserWarning: "You are running an unsupported browser (%s)",
details: "Details...",
failedTests: "The following tests have failed:",
supportedBrowser: "Please use a supported browser such as %s"
}
} }
function StringsCn(){ function StringsCn(){
this.id = "cn" this.id = "cn"
@ -270,6 +282,12 @@ function StringsCn(){
linkTutorial: "Share this link with your friend to start playing together! Do not leave this screen while they join.", linkTutorial: "Share this link with your friend to start playing together! Do not leave this screen while they join.",
cancel: "Cancel" cancel: "Cancel"
} }
this.browserSupport = {
browserWarning: "You are running an unsupported browser (%s)",
details: "Details...",
failedTests: "The following tests have failed:",
supportedBrowser: "Please use a supported browser such as %s"
}
} }
function StringsTw(){ function StringsTw(){
this.id = "tw" this.id = "tw"
@ -361,6 +379,12 @@ function StringsTw(){
linkTutorial: "Share this link with your friend to start playing together! Do not leave this screen while they join.", linkTutorial: "Share this link with your friend to start playing together! Do not leave this screen while they join.",
cancel: "Cancel" cancel: "Cancel"
} }
this.browserSupport = {
browserWarning: "You are running an unsupported browser (%s)",
details: "Details...",
failedTests: "The following tests have failed:",
supportedBrowser: "Please use a supported browser such as %s"
}
} }
function StringsKo(){ function StringsKo(){
this.id = "ko" this.id = "ko"
@ -452,6 +476,12 @@ function StringsKo(){
linkTutorial: "Share this link with your friend to start playing together! Do not leave this screen while they join.", linkTutorial: "Share this link with your friend to start playing together! Do not leave this screen while they join.",
cancel: "Cancel" cancel: "Cancel"
} }
this.browserSupport = {
browserWarning: "You are running an unsupported browser (%s)",
details: "Details...",
failedTests: "The following tests have failed:",
supportedBrowser: "Please use a supported browser such as %s"
}
} }
var allStrings = { var allStrings = {
"ja": new StringsJa(), "ja": new StringsJa(),

View File

@ -98,6 +98,9 @@ class Titlescreen{
this.langId.setAttribute("alt", strings.id.toUpperCase()) this.langId.setAttribute("alt", strings.id.toUpperCase())
loader.screen.style.fontFamily = strings.font loader.screen.style.fontFamily = strings.font
loader.screen.style.fontWeight = strings.font === "Microsoft YaHei, sans-serif" ? "bold" : "" loader.screen.style.fontWeight = strings.font === "Microsoft YaHei, sans-serif" ? "bold" : ""
if(failedTests.length !== 0){
showUnsupported(strings)
}
} }
addLangs(){ addLangs(){
for(var i in allStrings){ for(var i in allStrings){

View File

@ -1062,9 +1062,8 @@
} }
this.setLayers(donLayers, filename + songSkinName + (notStatic ? "_" : ""), notStatic) this.setLayers(donLayers, filename + songSkinName + (notStatic ? "_" : ""), notStatic)
} }
var w1 = assets.image[asset1].width this.donBg.style.setProperty("--sw1", assets.image[asset1].width)
var w2 = assets.image[asset2].width this.donBg.style.setProperty("--sw2", assets.image[asset2].width)
this.donBg.style.setProperty("--sw", w1 > w2 ? w1 : w2)
this.donBg.style.setProperty("--sh1", assets.image[asset1].height) this.donBg.style.setProperty("--sh1", assets.image[asset1].height)
this.donBg.style.setProperty("--sh2", assets.image[asset2].height) this.donBg.style.setProperty("--sh2", assets.image[asset2].height)
} }
@ -1163,6 +1162,11 @@
var animT = circle.getAnimT() var animT = circle.getAnimT()
if(ms < animT + 490){ if(ms < animT + 490){
if(circle.fixedPos){
circle.fixedPos = false
circle.animT = ms
animT = ms
}
var animPoint = (ms - animT) / 490 var animPoint = (ms - animT) / 490
var bezierPoint = this.calcBezierPoint(this.draw.easeOut(animPoint), this.animateBezier) var bezierPoint = this.calcBezierPoint(this.draw.easeOut(animPoint), this.animateBezier)
this.drawCircle(circle, {x: bezierPoint.x, y: bezierPoint.y}) this.drawCircle(circle, {x: bezierPoint.x, y: bezierPoint.y})