2019-04-04 22:40:11 +02:00
|
|
|
class Settings{
|
2022-02-11 15:28:22 +01:00
|
|
|
constructor(...args){
|
|
|
|
this.init(...args)
|
|
|
|
}
|
|
|
|
init(){
|
2019-04-04 22:40:11 +02:00
|
|
|
var ios = /iPhone|iPad/.test(navigator.userAgent)
|
|
|
|
var phone = /Android|iPhone|iPad/.test(navigator.userAgent)
|
2019-11-28 07:04:40 +01:00
|
|
|
this.allLanguages = []
|
|
|
|
for(var i in allStrings){
|
|
|
|
this.allLanguages.push(i)
|
|
|
|
}
|
2019-04-04 22:40:11 +02:00
|
|
|
|
|
|
|
this.items = {
|
2019-04-06 12:19:10 +02:00
|
|
|
language: {
|
|
|
|
type: "language",
|
2019-11-28 07:04:40 +01:00
|
|
|
options: this.allLanguages,
|
2019-04-06 12:19:10 +02:00
|
|
|
default: this.getLang()
|
|
|
|
},
|
2019-04-04 22:40:11 +02:00
|
|
|
resolution: {
|
|
|
|
type: "select",
|
|
|
|
options: ["high", "medium", "low", "lowest"],
|
|
|
|
default: phone ? "medium" : "high"
|
|
|
|
},
|
|
|
|
touchAnimation: {
|
|
|
|
type: "toggle",
|
|
|
|
default: !ios,
|
|
|
|
touch: true
|
2019-04-05 21:53:51 +02:00
|
|
|
},
|
|
|
|
keyboardSettings: {
|
|
|
|
type: "keyboard",
|
|
|
|
default: {
|
|
|
|
ka_l: ["d"],
|
|
|
|
don_l: ["f"],
|
|
|
|
don_r: ["j"],
|
|
|
|
ka_r: ["k"]
|
|
|
|
},
|
|
|
|
touch: false
|
2019-04-16 20:06:41 +02:00
|
|
|
},
|
|
|
|
gamepadLayout: {
|
|
|
|
type: "gamepad",
|
|
|
|
options: ["a", "b", "c"],
|
|
|
|
default: "a",
|
|
|
|
gamepad: true
|
2019-11-28 07:04:40 +01:00
|
|
|
},
|
|
|
|
latency: {
|
|
|
|
type: "latency",
|
|
|
|
default: {
|
|
|
|
"audio": 0,
|
|
|
|
"video": 0,
|
|
|
|
"drumSounds": true
|
|
|
|
}
|
2020-02-29 16:56:59 +01:00
|
|
|
},
|
|
|
|
easierBigNotes: {
|
|
|
|
type: "toggle",
|
|
|
|
default: false
|
2020-03-31 15:44:54 +02:00
|
|
|
},
|
|
|
|
showLyrics: {
|
|
|
|
type: "toggle",
|
|
|
|
default: true
|
2019-04-04 22:40:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.storage = {}
|
|
|
|
try{
|
|
|
|
var storage = JSON.parse(localStorage.getItem("settings") || "{}")
|
|
|
|
for(var i in this.items){
|
|
|
|
var current = this.items[i]
|
2019-04-06 12:19:10 +02:00
|
|
|
if(current.type === "language"){
|
|
|
|
this.storage[i] = localStorage.getItem("lang")
|
|
|
|
if(current.options.indexOf(this.storage[i]) === -1){
|
|
|
|
this.storage[i] = null
|
|
|
|
}
|
|
|
|
}else if(i in storage){
|
2019-04-16 20:06:41 +02:00
|
|
|
if((current.type === "select" || current.type === "gamepad") && current.options.indexOf(storage[i]) === -1){
|
2019-04-04 22:40:11 +02:00
|
|
|
this.storage[i] = null
|
2019-04-05 21:53:51 +02:00
|
|
|
}else if(current.type === "keyboard"){
|
|
|
|
var obj = {}
|
|
|
|
for(var j in current.default){
|
2019-04-06 12:19:10 +02:00
|
|
|
if(storage[i] && storage[i][j] && storage[i][j][0]){
|
2019-04-05 21:53:51 +02:00
|
|
|
obj[j] = storage[i][j]
|
|
|
|
}else{
|
|
|
|
obj = null
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.storage[i] = obj
|
2019-11-28 07:04:40 +01:00
|
|
|
}else if(current.type === "latency"){
|
|
|
|
var obj = {}
|
|
|
|
for(var j in current.default){
|
|
|
|
if(storage[i] && j in storage[i]){
|
|
|
|
if(j === "drumSounds"){
|
|
|
|
obj[j] = !!storage[i][j]
|
|
|
|
continue
|
|
|
|
}else if(!isNaN(storage[i][j])){
|
|
|
|
obj[j] = Math.round(parseFloat(storage[i][j]) || 0)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
obj = null
|
|
|
|
break
|
|
|
|
}
|
|
|
|
this.storage[i] = obj
|
2019-04-04 22:40:11 +02:00
|
|
|
}else{
|
|
|
|
this.storage[i] = storage[i]
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
this.storage[i] = null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}catch(e){
|
|
|
|
for(var i in this.items){
|
|
|
|
this.storage[i] = null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
getItem(name){
|
|
|
|
var value = this.storage[name]
|
|
|
|
return value === null ? this.items[name].default : value
|
|
|
|
}
|
|
|
|
setItem(name, value){
|
|
|
|
this.storage[name] = value
|
|
|
|
try{
|
2019-04-06 12:19:10 +02:00
|
|
|
if(name === "language"){
|
|
|
|
if(value){
|
|
|
|
localStorage.setItem("lang", value)
|
|
|
|
}else{
|
|
|
|
localStorage.removeItem("lang")
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
var language = this.storage.language
|
|
|
|
delete this.storage.language
|
|
|
|
localStorage.setItem("settings", JSON.stringify(this.storage))
|
|
|
|
this.storage.language = language
|
|
|
|
}
|
2019-04-04 22:40:11 +02:00
|
|
|
}catch(e){}
|
|
|
|
}
|
2019-04-06 12:19:10 +02:00
|
|
|
getLang(){
|
|
|
|
if("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])){
|
|
|
|
return j
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-11-28 07:04:40 +01:00
|
|
|
return this.allLanguages[0]
|
2019-04-06 12:19:10 +02:00
|
|
|
}
|
|
|
|
setLang(lang, noEvent){
|
|
|
|
strings = lang
|
|
|
|
var boldFonts = strings.font === "Microsoft YaHei, sans-serif"
|
|
|
|
loader.screen.style.fontFamily = strings.font
|
|
|
|
loader.screen.style.fontWeight = boldFonts ? "bold" : ""
|
|
|
|
loader.screen.classList[boldFonts ? "add" : "remove"]("bold-fonts")
|
2022-02-11 15:28:22 +01:00
|
|
|
strings.plural = new Intl.PluralRules(lang.intl)
|
2019-04-06 12:19:10 +02:00
|
|
|
if(!noEvent){
|
|
|
|
pageEvents.send("language-change", lang.id)
|
|
|
|
}
|
|
|
|
}
|
2022-03-03 16:19:16 +01:00
|
|
|
addLang(lang, forceSet){
|
|
|
|
allStrings[lang.id] = lang
|
|
|
|
if(lang.categories){
|
|
|
|
assets.categories.forEach(category => {
|
|
|
|
if("title_lang" in category && lang.categories[category.title_lang.en]){
|
|
|
|
category.title_lang[lang.id] = lang.categories[category.title_lang.en]
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
languageList.push(lang.id)
|
|
|
|
this.allLanguages.push(lang.id)
|
|
|
|
this.items.language.default = this.getLang()
|
|
|
|
if(forceSet){
|
|
|
|
this.storage.language = lang.id
|
|
|
|
}else{
|
|
|
|
try{
|
|
|
|
this.storage.language = localStorage.getItem("lang")
|
|
|
|
}catch(e){}
|
|
|
|
if(this.items.language.options.indexOf(this.storage.language) === -1){
|
|
|
|
this.storage.language = null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(settings.getItem("language") === lang.id){
|
|
|
|
settings.setLang(lang)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
removeLang(lang){
|
|
|
|
delete allStrings[lang.id]
|
|
|
|
assets.categories.forEach(category => {
|
|
|
|
if("title_lang" in category){
|
|
|
|
delete category.title_lang[lang.id]
|
|
|
|
}
|
|
|
|
})
|
|
|
|
var index = languageList.indexOf(lang.id)
|
|
|
|
if(index !== -1){
|
|
|
|
languageList.splice(index, 1)
|
|
|
|
}
|
|
|
|
var index = this.allLanguages.indexOf(lang.id)
|
|
|
|
if(index !== -1){
|
|
|
|
this.allLanguages.splice(index, 1)
|
|
|
|
}
|
|
|
|
this.items.language.default = this.getLang()
|
|
|
|
try{
|
|
|
|
this.storage.language = localStorage.getItem("lang")
|
|
|
|
}catch(e){}
|
|
|
|
if(this.items.language.options.indexOf(this.storage.language) === -1){
|
|
|
|
this.storage.language = null
|
|
|
|
}
|
|
|
|
if(lang.id === strings.id){
|
|
|
|
settings.setLang(allStrings[this.getItem("language")])
|
|
|
|
}
|
|
|
|
}
|
2019-04-04 22:40:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class SettingsView{
|
2022-02-11 15:28:22 +01:00
|
|
|
constructor(...args){
|
|
|
|
this.init(...args)
|
|
|
|
}
|
2022-03-16 07:55:25 +01:00
|
|
|
init(touchEnabled, tutorial, songId, toSetting, settingsItems, noSoundStart){
|
2019-04-04 22:40:11 +02:00
|
|
|
this.touchEnabled = touchEnabled
|
2019-04-06 21:14:44 +02:00
|
|
|
this.tutorial = tutorial
|
2019-04-16 20:06:41 +02:00
|
|
|
this.songId = songId
|
2022-02-11 15:28:22 +01:00
|
|
|
this.customSettings = !!settingsItems
|
|
|
|
this.settingsItems = settingsItems || settings.items
|
2022-03-16 07:55:25 +01:00
|
|
|
this.locked = false
|
2019-04-16 20:06:41 +02:00
|
|
|
|
|
|
|
loader.changePage("settings", tutorial)
|
2022-03-16 07:55:25 +01:00
|
|
|
if(!noSoundStart){
|
|
|
|
assets.sounds["bgm_settings"].playLoop(0.1, false, 0, 1.392, 26.992)
|
|
|
|
}
|
2019-04-16 20:06:41 +02:00
|
|
|
this.defaultButton = document.getElementById("settings-default")
|
2019-11-28 07:04:40 +01:00
|
|
|
this.viewOuter = this.getElement("view-outer")
|
2019-04-04 22:40:11 +02:00
|
|
|
if(touchEnabled){
|
2019-11-28 07:04:40 +01:00
|
|
|
this.viewOuter.classList.add("touch-enabled")
|
2019-04-16 20:06:41 +02:00
|
|
|
}
|
2019-11-28 07:04:40 +01:00
|
|
|
this.touchEnd = []
|
2020-03-09 13:36:57 +01:00
|
|
|
this.windowSymbol = Symbol()
|
|
|
|
this.touchMove = {
|
|
|
|
active: false,
|
|
|
|
x: 0,
|
|
|
|
y: 0
|
|
|
|
}
|
|
|
|
pageEvents.add(window, ["mouseup", "touchstart", "touchmove", "touchend", "blur"], event => {
|
|
|
|
var move = this.touchMove
|
|
|
|
if(event.type === "touchstart"){
|
|
|
|
var cursor = event.changedTouches[0]
|
|
|
|
move.active = false
|
|
|
|
move.x = cursor.pageX
|
|
|
|
move.y = cursor.pageY
|
|
|
|
}else if(event.type === "touchmove"){
|
|
|
|
var cursor = event.changedTouches[0]
|
|
|
|
if (Math.abs(move.x - cursor.pageX) > 10 || Math.abs(move.y - cursor.pageY) > 10){
|
|
|
|
move.active = true
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
this.touchEnd.forEach(func => func(event))
|
|
|
|
move.active = false
|
|
|
|
}
|
|
|
|
}, this.windowSymbol)
|
2019-11-28 07:04:40 +01:00
|
|
|
|
2022-03-03 16:19:16 +01:00
|
|
|
if(this.customSettings){
|
|
|
|
pageEvents.add(window, "language-change", event => this.setLang(), this.windowSymbol)
|
|
|
|
}
|
|
|
|
|
2019-04-16 20:06:41 +02:00
|
|
|
var gamepadEnabled = false
|
|
|
|
if("getGamepads" in navigator){
|
|
|
|
var gamepads = navigator.getGamepads()
|
|
|
|
for(var i = 0; i < gamepads.length; i++){
|
|
|
|
if(gamepads[i]){
|
|
|
|
gamepadEnabled = true
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
2019-04-04 22:40:11 +02:00
|
|
|
}
|
2019-04-05 21:53:51 +02:00
|
|
|
this.mode = "settings"
|
2019-04-04 22:40:11 +02:00
|
|
|
|
2019-11-28 07:04:40 +01:00
|
|
|
this.pressedKeys = {}
|
2019-04-16 20:06:41 +02:00
|
|
|
this.keyboard = new Keyboard({
|
|
|
|
"confirm": ["enter", "space", "don_l", "don_r"],
|
|
|
|
"up": ["up"],
|
2019-11-28 07:04:40 +01:00
|
|
|
"right": ["right", "ka_r"],
|
|
|
|
"down": ["down"],
|
|
|
|
"left": ["left", "ka_l"],
|
2019-04-16 20:06:41 +02:00
|
|
|
"back": ["esc"],
|
|
|
|
"other": ["wildcard"]
|
|
|
|
}, this.keyPressed.bind(this))
|
|
|
|
this.gamepad = new Gamepad({
|
|
|
|
"confirm": ["b", "ls", "rs"],
|
|
|
|
"up": ["u", "lsu"],
|
2019-11-28 07:04:40 +01:00
|
|
|
"right": ["r", "rb", "rt", "lsr"],
|
|
|
|
"down": ["d", "lsd"],
|
|
|
|
"left": ["l", "lb", "lt", "lsl"],
|
2019-04-16 20:06:41 +02:00
|
|
|
"back": ["start", "a"]
|
|
|
|
}, this.keyPressed.bind(this))
|
|
|
|
|
|
|
|
this.viewTitle = this.getElement("view-title")
|
|
|
|
this.endButton = this.getElement("view-end-button")
|
2019-04-04 22:40:11 +02:00
|
|
|
this.resolution = settings.getItem("resolution")
|
|
|
|
|
2019-04-16 20:06:41 +02:00
|
|
|
var content = this.getElement("view-content")
|
2019-04-04 22:40:11 +02:00
|
|
|
this.items = []
|
2019-05-03 04:59:31 +02:00
|
|
|
this.selected = 0
|
2022-02-11 15:28:22 +01:00
|
|
|
for(let i in this.settingsItems){
|
|
|
|
var current = this.settingsItems[i]
|
2019-04-05 21:53:51 +02:00
|
|
|
if(
|
|
|
|
!touchEnabled && current.touch === true ||
|
2019-04-06 21:14:44 +02:00
|
|
|
touchEnabled && current.touch === false ||
|
2019-05-03 04:59:31 +02:00
|
|
|
!gamepadEnabled && current.gamepad === true
|
2019-04-05 21:53:51 +02:00
|
|
|
){
|
2019-04-04 22:40:11 +02:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
var settingBox = document.createElement("div")
|
|
|
|
settingBox.classList.add("setting-box")
|
2022-02-22 14:23:01 +01:00
|
|
|
if(current.indent){
|
|
|
|
settingBox.style.marginLeft = (2 * current.indent || 0).toString() + "em"
|
|
|
|
}
|
2019-04-04 22:40:11 +02:00
|
|
|
var nameDiv = document.createElement("div")
|
|
|
|
nameDiv.classList.add("setting-name", "stroke-sub")
|
2022-02-22 14:23:01 +01:00
|
|
|
if(current.name || current.name_lang){
|
|
|
|
var name = this.getLocalTitle(current.name, current.name_lang)
|
|
|
|
}else{
|
|
|
|
var name = strings.settings[i].name
|
|
|
|
}
|
2019-11-28 07:04:40 +01:00
|
|
|
this.setAltText(nameDiv, name)
|
2022-02-22 14:23:01 +01:00
|
|
|
if(current.description || current.description_lang){
|
2022-02-22 17:52:42 +01:00
|
|
|
settingBox.title = this.getLocalTitle(current.description, current.description_lang) || ""
|
2022-02-22 14:23:01 +01:00
|
|
|
}
|
2019-04-04 22:40:11 +02:00
|
|
|
settingBox.appendChild(nameDiv)
|
|
|
|
var valueDiv = document.createElement("div")
|
|
|
|
valueDiv.classList.add("setting-value")
|
2022-02-22 14:23:01 +01:00
|
|
|
let outputObject = {
|
|
|
|
id: i,
|
|
|
|
settingBox: settingBox,
|
|
|
|
nameDiv: nameDiv,
|
|
|
|
valueDiv: valueDiv,
|
|
|
|
name: current.name,
|
|
|
|
name_lang: current.name_lang,
|
|
|
|
description: current.description,
|
|
|
|
description_lang: current.description_lang
|
|
|
|
}
|
|
|
|
if(current.type === "number"){
|
|
|
|
["min", "max", "fixedPoint", "step", "sign", "format", "format_lang"].forEach(opt => {
|
|
|
|
if(opt in current){
|
|
|
|
outputObject[opt] = current[opt]
|
|
|
|
}
|
|
|
|
})
|
|
|
|
outputObject.valueText = document.createTextNode("")
|
|
|
|
valueDiv.appendChild(outputObject.valueText)
|
|
|
|
var buttons = document.createElement("div")
|
|
|
|
buttons.classList.add("latency-buttons")
|
2022-02-22 17:52:42 +01:00
|
|
|
buttons.title = ""
|
2022-02-22 14:23:01 +01:00
|
|
|
var buttonMinus = document.createElement("span")
|
|
|
|
buttonMinus.innerText = "-"
|
|
|
|
buttons.appendChild(buttonMinus)
|
|
|
|
this.addTouchRepeat(buttonMinus, event => {
|
|
|
|
this.numberAdjust(outputObject, -1)
|
|
|
|
})
|
|
|
|
var buttonPlus = document.createElement("span")
|
|
|
|
buttonPlus.innerText = "+"
|
|
|
|
buttons.appendChild(buttonPlus)
|
|
|
|
this.addTouchRepeat(buttonPlus, event => {
|
|
|
|
this.numberAdjust(outputObject, 1)
|
|
|
|
})
|
|
|
|
valueDiv.appendChild(buttons)
|
|
|
|
this.addTouch(settingBox, event => {
|
|
|
|
if(event.target.tagName !== "SPAN"){
|
|
|
|
this.setValue(i)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}else{
|
|
|
|
this.addTouchEnd(settingBox, event => this.setValue(i))
|
|
|
|
}
|
2019-04-04 22:40:11 +02:00
|
|
|
settingBox.appendChild(valueDiv)
|
|
|
|
content.appendChild(settingBox)
|
2019-11-28 07:04:40 +01:00
|
|
|
if(!toSetting && this.items.length === this.selected || toSetting === i){
|
|
|
|
this.selected = this.items.length
|
2019-04-04 22:40:11 +02:00
|
|
|
settingBox.classList.add("selected")
|
|
|
|
}
|
2022-02-22 14:23:01 +01:00
|
|
|
this.items.push(outputObject)
|
|
|
|
this.getValue(i, valueDiv)
|
2019-04-04 22:40:11 +02:00
|
|
|
}
|
2022-03-16 07:55:25 +01:00
|
|
|
var selectBack = this.items.length === 0
|
|
|
|
if(this.customSettings){
|
|
|
|
var form = document.createElement("form")
|
|
|
|
this.browse = document.createElement("input")
|
2022-03-16 17:04:51 +01:00
|
|
|
this.browse.id = "plugin-browse"
|
2022-03-16 07:55:25 +01:00
|
|
|
this.browse.type = "file"
|
|
|
|
this.browse.multiple = true
|
|
|
|
this.browse.accept = ".taikoweb.js"
|
|
|
|
pageEvents.add(this.browse, "change", this.browseChange.bind(this))
|
|
|
|
form.appendChild(this.browse)
|
|
|
|
this.browseButton = document.createElement("div")
|
2022-03-16 17:04:51 +01:00
|
|
|
this.browseButton.classList.add("taibtn", "stroke-sub", "plugin-browse-button")
|
|
|
|
this.browseText = document.createTextNode("")
|
|
|
|
this.browseButton.appendChild(this.browseText)
|
|
|
|
this.browseButton.appendChild(form)
|
2022-03-16 07:55:25 +01:00
|
|
|
this.defaultButton.parentNode.insertBefore(this.browseButton, this.defaultButton)
|
|
|
|
this.items.push({
|
|
|
|
id: "browse",
|
|
|
|
settingBox: this.browseButton
|
|
|
|
})
|
|
|
|
}
|
|
|
|
this.showDefault = !this.customSettings || plugins.allPlugins.filter(obj => obj.plugin.imported).length
|
|
|
|
if(this.showDefault){
|
|
|
|
this.items.push({
|
|
|
|
id: "default",
|
|
|
|
settingBox: this.defaultButton
|
|
|
|
})
|
|
|
|
this.addTouch(this.defaultButton, this.defaultSettings.bind(this))
|
|
|
|
}else{
|
|
|
|
this.defaultButton.parentNode.removeChild(this.defaultButton)
|
|
|
|
}
|
2019-04-04 22:40:11 +02:00
|
|
|
this.items.push({
|
|
|
|
id: "back",
|
|
|
|
settingBox: this.endButton
|
|
|
|
})
|
2019-04-16 20:06:41 +02:00
|
|
|
this.addTouch(this.endButton, this.onEnd.bind(this))
|
2022-03-16 07:55:25 +01:00
|
|
|
if(selectBack){
|
|
|
|
this.selected = this.items.length - 1
|
|
|
|
this.endButton.classList.add("selected")
|
|
|
|
}
|
2019-04-04 22:40:11 +02:00
|
|
|
|
2022-02-11 15:28:22 +01:00
|
|
|
if(!this.customSettings){
|
|
|
|
this.gamepadSettings = document.getElementById("settings-gamepad")
|
|
|
|
this.addTouch(this.gamepadSettings, event => {
|
|
|
|
if(event.target === event.currentTarget){
|
|
|
|
this.gamepadBack()
|
2019-11-28 07:04:40 +01:00
|
|
|
}
|
2022-02-11 15:28:22 +01:00
|
|
|
})
|
|
|
|
this.gamepadTitle = this.gamepadSettings.getElementsByClassName("view-title")[0]
|
|
|
|
this.gamepadEndButton = this.gamepadSettings.getElementsByClassName("view-end-button")[0]
|
|
|
|
this.addTouch(this.gamepadEndButton, event => this.gamepadBack(true))
|
|
|
|
this.gamepadBox = this.gamepadSettings.getElementsByClassName("setting-box")[0]
|
|
|
|
this.addTouch(this.gamepadBox, event => this.gamepadSet(1))
|
|
|
|
this.gamepadButtons = document.getElementById("gamepad-buttons")
|
|
|
|
this.gamepadValue = document.getElementById("gamepad-value")
|
|
|
|
|
|
|
|
this.latencySettings = document.getElementById("settings-latency")
|
|
|
|
this.addTouch(this.latencySettings, event => {
|
|
|
|
if(event.target === event.currentTarget){
|
|
|
|
this.latencyBack()
|
2019-11-28 07:04:40 +01:00
|
|
|
}
|
|
|
|
})
|
2022-02-11 15:28:22 +01:00
|
|
|
this.latencyTitle = this.latencySettings.getElementsByClassName("view-title")[0]
|
|
|
|
this.latencyItems = []
|
|
|
|
this.latencySelected = 0
|
|
|
|
var latencyContent = this.latencySettings.getElementsByClassName("view-content")[0]
|
|
|
|
var latencyWindow = ["calibration", "audio", "video", "drumSounds"]
|
|
|
|
for(let i in latencyWindow){
|
|
|
|
let current = latencyWindow[i]
|
|
|
|
var settingBox = document.createElement("div")
|
|
|
|
settingBox.classList.add("setting-box")
|
|
|
|
var nameDiv = document.createElement("div")
|
|
|
|
nameDiv.classList.add("setting-name", "stroke-sub")
|
|
|
|
var name = strings.settings.latency[current]
|
|
|
|
this.setAltText(nameDiv, name)
|
|
|
|
settingBox.appendChild(nameDiv)
|
|
|
|
let outputObject = {
|
|
|
|
id: current,
|
|
|
|
settingBox: settingBox,
|
|
|
|
nameDiv: nameDiv
|
|
|
|
}
|
|
|
|
if(current === "calibration"){
|
|
|
|
nameDiv.style.width = "100%"
|
|
|
|
}else{
|
|
|
|
var valueDiv = document.createElement("div")
|
|
|
|
valueDiv.classList.add("setting-value")
|
|
|
|
settingBox.appendChild(valueDiv)
|
|
|
|
var valueText = document.createTextNode("")
|
|
|
|
valueDiv.appendChild(valueText)
|
|
|
|
this.latencyGetValue(current, valueText)
|
|
|
|
if(current !== "drumSounds"){
|
|
|
|
var buttons = document.createElement("div")
|
|
|
|
buttons.classList.add("latency-buttons")
|
|
|
|
var buttonMinus = document.createElement("span")
|
|
|
|
buttonMinus.innerText = "-"
|
|
|
|
buttons.appendChild(buttonMinus)
|
|
|
|
this.addTouchRepeat(buttonMinus, event => {
|
|
|
|
this.latencySetAdjust(outputObject, -1)
|
|
|
|
})
|
|
|
|
var buttonPlus = document.createElement("span")
|
|
|
|
buttonPlus.innerText = "+"
|
|
|
|
buttons.appendChild(buttonPlus)
|
|
|
|
this.addTouchRepeat(buttonPlus, event => {
|
|
|
|
this.latencySetAdjust(outputObject, 1)
|
|
|
|
})
|
|
|
|
valueDiv.appendChild(buttons)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
latencyContent.appendChild(settingBox)
|
|
|
|
if(this.latencyItems.length === this.latencySelected){
|
|
|
|
settingBox.classList.add("selected")
|
|
|
|
}
|
|
|
|
this.addTouch(settingBox, event => {
|
|
|
|
if(event.target.tagName !== "SPAN"){
|
|
|
|
this.latencySetValue(current, event.type === "touchstart")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if(current !== "calibration"){
|
|
|
|
outputObject.valueDiv = valueDiv
|
|
|
|
outputObject.valueText = valueText
|
|
|
|
outputObject.buttonMinus = buttonMinus
|
|
|
|
outputObject.buttonPlus = buttonPlus
|
|
|
|
}
|
|
|
|
this.latencyItems.push(outputObject)
|
2019-11-28 07:04:40 +01:00
|
|
|
}
|
2022-02-11 15:28:22 +01:00
|
|
|
this.latencyDefaultButton = document.getElementById("latency-default")
|
|
|
|
this.latencyItems.push({
|
|
|
|
id: "default",
|
|
|
|
settingBox: this.latencyDefaultButton
|
|
|
|
})
|
|
|
|
this.addTouch(this.latencyDefaultButton, event => this.latencyDefault())
|
|
|
|
this.latencyEndButton = this.latencySettings.getElementsByClassName("view-end-button")[0]
|
|
|
|
this.latencyItems.push({
|
|
|
|
id: "back",
|
|
|
|
settingBox: this.latencyEndButton
|
|
|
|
})
|
|
|
|
this.addTouch(this.latencyEndButton, event => this.latencyBack(true))
|
2019-11-28 07:04:40 +01:00
|
|
|
}
|
|
|
|
|
2019-04-16 20:06:41 +02:00
|
|
|
this.setStrings()
|
|
|
|
|
2019-11-28 07:04:40 +01:00
|
|
|
this.drumSounds = settings.getItem("latency").drumSounds
|
|
|
|
this.playedSounds = {}
|
|
|
|
this.redrawRunning = true
|
|
|
|
this.redrawBind = this.redraw.bind(this)
|
|
|
|
this.redraw()
|
|
|
|
if(toSetting === "latency"){
|
|
|
|
this.mode = "latency"
|
|
|
|
this.latencySet()
|
|
|
|
}
|
2022-03-03 16:19:16 +01:00
|
|
|
if(this.customSettings){
|
|
|
|
pageEvents.send("plugins")
|
|
|
|
}else{
|
|
|
|
pageEvents.send("settings")
|
|
|
|
}
|
2019-04-04 22:40:11 +02:00
|
|
|
}
|
2019-04-16 20:06:41 +02:00
|
|
|
getElement(name){
|
|
|
|
return loader.screen.getElementsByClassName(name)[0]
|
|
|
|
}
|
2020-03-09 13:36:57 +01:00
|
|
|
addTouch(element, callback, end){
|
|
|
|
var touchEvent = end ? "touchend" : "touchstart"
|
|
|
|
pageEvents.add(element, ["mousedown", touchEvent], event => {
|
|
|
|
if(event.type === touchEvent){
|
2019-04-16 20:06:41 +02:00
|
|
|
event.preventDefault()
|
|
|
|
this.touched = true
|
|
|
|
}else if(event.which !== 1){
|
|
|
|
return
|
|
|
|
}else{
|
|
|
|
this.touched = false
|
|
|
|
}
|
2020-03-09 13:36:57 +01:00
|
|
|
if(event.type !== "touchend" || !this.touchMove.active){
|
|
|
|
callback(event)
|
|
|
|
}
|
2019-04-16 20:06:41 +02:00
|
|
|
})
|
|
|
|
}
|
2020-03-09 13:36:57 +01:00
|
|
|
addTouchEnd(element, callback){
|
|
|
|
this.addTouch(element, callback, true)
|
|
|
|
}
|
2019-11-28 07:04:40 +01:00
|
|
|
addTouchRepeat(element, callback){
|
|
|
|
this.addTouch(element, event => {
|
|
|
|
var active = true
|
|
|
|
var func = () => {
|
|
|
|
active = false
|
|
|
|
this.touchEnd.splice(this.touchEnd.indexOf(func), 1)
|
|
|
|
}
|
|
|
|
this.touchEnd.push(func)
|
|
|
|
var repeat = delay => {
|
|
|
|
if(active){
|
|
|
|
callback()
|
|
|
|
setTimeout(() => repeat(50), delay)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
repeat(400)
|
|
|
|
})
|
|
|
|
}
|
2019-04-16 20:06:41 +02:00
|
|
|
removeTouch(element){
|
|
|
|
pageEvents.remove(element, ["mousedown", "touchstart"])
|
2019-04-05 21:53:51 +02:00
|
|
|
}
|
2020-03-09 13:36:57 +01:00
|
|
|
removeTouchEnd(element){
|
|
|
|
pageEvents.remove(element, ["mousedown", "touchend"])
|
|
|
|
}
|
2019-04-05 21:53:51 +02:00
|
|
|
getValue(name, valueDiv){
|
2022-02-22 14:23:01 +01:00
|
|
|
if(!this.items){
|
|
|
|
return
|
|
|
|
}
|
2022-02-11 15:28:22 +01:00
|
|
|
var current = this.settingsItems[name]
|
|
|
|
if(current.getItem){
|
|
|
|
var value = current.getItem()
|
|
|
|
}else{
|
|
|
|
var value = settings.getItem(name)
|
|
|
|
}
|
2019-04-06 12:19:10 +02:00
|
|
|
if(current.type === "language"){
|
|
|
|
value = allStrings[value].name + " (" + value + ")"
|
2019-04-16 20:06:41 +02:00
|
|
|
}else if(current.type === "select" || current.type === "gamepad"){
|
2019-04-04 22:40:11 +02:00
|
|
|
value = strings.settings[name][value]
|
|
|
|
}else if(current.type === "toggle"){
|
|
|
|
value = value ? strings.settings.on : strings.settings.off
|
2019-04-05 21:53:51 +02:00
|
|
|
}else if(current.type === "keyboard"){
|
|
|
|
valueDiv.innerHTML = ""
|
|
|
|
for(var i in value){
|
2019-04-16 20:06:41 +02:00
|
|
|
var keyDiv = document.createElement("div")
|
|
|
|
keyDiv.style.color = i === "ka_l" || i === "ka_r" ? "#009aa5" : "#ef2c10"
|
|
|
|
var key = value[i][0]
|
|
|
|
for(var j in this.keyboard.substitute){
|
|
|
|
if(this.keyboard.substitute[j] === key){
|
|
|
|
key = j
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
keyDiv.innerText = key.toUpperCase()
|
|
|
|
valueDiv.appendChild(keyDiv)
|
2019-04-05 21:53:51 +02:00
|
|
|
}
|
|
|
|
return
|
2019-11-28 07:04:40 +01:00
|
|
|
}else if(current.type === "latency"){
|
|
|
|
var audioVideo = [Math.round(value.audio), Math.round(value.video)]
|
|
|
|
var latencyValue = strings.settings[name].value.split("%s")
|
|
|
|
var latencyIndex = 0
|
|
|
|
value = ""
|
|
|
|
latencyValue.forEach((string, i) => {
|
|
|
|
if(i !== 0){
|
|
|
|
value += this.addMs(audioVideo[latencyIndex++])
|
|
|
|
}
|
|
|
|
value += string
|
|
|
|
})
|
2022-02-22 14:23:01 +01:00
|
|
|
}else if(current.type === "number"){
|
|
|
|
var mul = Math.pow(10, current.fixedPoint || 0)
|
|
|
|
this.items[name].value = value * mul
|
|
|
|
value = Intl.NumberFormat(strings.intl, current.sign ? {
|
|
|
|
signDisplay: "always"
|
|
|
|
} : undefined).format(value)
|
|
|
|
if(current.format || current.format_lang){
|
|
|
|
value = this.getLocalTitle(current.format, current.format_lang).replace("%s", value)
|
|
|
|
}
|
|
|
|
this.items[name].valueText.data = value
|
|
|
|
return
|
2019-04-04 22:40:11 +02:00
|
|
|
}
|
2019-04-05 21:53:51 +02:00
|
|
|
valueDiv.innerText = value
|
2019-04-04 22:40:11 +02:00
|
|
|
}
|
|
|
|
setValue(name){
|
2022-03-16 07:55:25 +01:00
|
|
|
if(this.locked){
|
|
|
|
return
|
|
|
|
}
|
2022-02-11 15:28:22 +01:00
|
|
|
var promise
|
|
|
|
var current = this.settingsItems[name]
|
|
|
|
if(current.getItem){
|
|
|
|
var value = current.getItem()
|
|
|
|
}else{
|
|
|
|
var value = settings.getItem(name)
|
|
|
|
}
|
2019-04-05 21:53:51 +02:00
|
|
|
var selectedIndex = this.items.findIndex(item => item.id === name)
|
|
|
|
var selected = this.items[selectedIndex]
|
|
|
|
if(this.mode !== "settings"){
|
2022-02-22 14:23:01 +01:00
|
|
|
if(this.mode === "number"){
|
|
|
|
return this.numberBack(this.items[this.selected])
|
|
|
|
}
|
2019-04-05 21:53:51 +02:00
|
|
|
if(this.selected === selectedIndex){
|
|
|
|
this.keyboardBack(selected)
|
2019-11-28 07:04:40 +01:00
|
|
|
this.playSound("se_don")
|
2019-04-05 21:53:51 +02:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if(this.selected !== selectedIndex){
|
|
|
|
this.items[this.selected].settingBox.classList.remove("selected")
|
|
|
|
this.selected = selectedIndex
|
|
|
|
selected.settingBox.classList.add("selected")
|
|
|
|
}
|
2019-04-06 12:19:10 +02:00
|
|
|
if(current.type === "language" || current.type === "select"){
|
2019-04-04 22:40:11 +02:00
|
|
|
value = current.options[this.mod(current.options.length, current.options.indexOf(value) + 1)]
|
|
|
|
}else if(current.type === "toggle"){
|
|
|
|
value = !value
|
2019-04-05 21:53:51 +02:00
|
|
|
}else if(current.type === "keyboard"){
|
|
|
|
this.mode = "keyboard"
|
|
|
|
selected.settingBox.style.animation = "none"
|
|
|
|
selected.valueDiv.classList.add("selected")
|
|
|
|
this.keyboardKeys = {}
|
|
|
|
this.keyboardSet()
|
2019-11-28 07:04:40 +01:00
|
|
|
this.playSound("se_don")
|
2019-04-05 21:53:51 +02:00
|
|
|
return
|
2019-04-16 20:06:41 +02:00
|
|
|
}else if(current.type === "gamepad"){
|
|
|
|
this.mode = "gamepad"
|
|
|
|
this.gamepadSelected = current.options.indexOf(value)
|
|
|
|
this.gamepadSet()
|
2019-11-28 07:04:40 +01:00
|
|
|
this.playSound("se_don")
|
|
|
|
return
|
|
|
|
}else if(current.type === "latency"){
|
|
|
|
this.mode = "latency"
|
|
|
|
this.latencySet()
|
|
|
|
this.playSound("se_don")
|
2019-04-16 20:06:41 +02:00
|
|
|
return
|
2022-02-22 14:23:01 +01:00
|
|
|
}else if(current.type === "number"){
|
|
|
|
this.mode = "number"
|
|
|
|
selected.settingBox.style.animation = "none"
|
|
|
|
selected.valueDiv.classList.add("selected")
|
|
|
|
this.playSound("se_don")
|
|
|
|
return
|
2019-04-04 22:40:11 +02:00
|
|
|
}
|
2022-02-11 15:28:22 +01:00
|
|
|
if(current.setItem){
|
|
|
|
promise = current.setItem(value)
|
|
|
|
}else{
|
|
|
|
settings.setItem(name, value)
|
2019-04-06 12:19:10 +02:00
|
|
|
}
|
2022-02-11 15:28:22 +01:00
|
|
|
(promise || Promise.resolve()).then(() => {
|
|
|
|
this.getValue(name, this.items[this.selected].valueDiv)
|
|
|
|
this.playSound("se_ka")
|
|
|
|
if(current.type === "language"){
|
|
|
|
this.setLang(allStrings[value])
|
|
|
|
}
|
|
|
|
})
|
2019-04-04 22:40:11 +02:00
|
|
|
}
|
2019-11-28 07:04:40 +01:00
|
|
|
keyPressed(pressed, name, event, repeat){
|
2022-03-16 07:55:25 +01:00
|
|
|
if(this.locked){
|
|
|
|
return
|
|
|
|
}
|
2019-11-28 07:04:40 +01:00
|
|
|
if(pressed){
|
|
|
|
if(!this.pressedKeys[name]){
|
|
|
|
this.pressedKeys[name] = this.getMS() + 300
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
this.pressedKeys[name] = 0
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if(repeat && name !== "up" && name !== "right" && name !== "down" && name !== "left"){
|
2019-04-04 22:40:11 +02:00
|
|
|
return
|
|
|
|
}
|
2019-04-16 20:06:41 +02:00
|
|
|
this.touched = false
|
2019-04-04 22:40:11 +02:00
|
|
|
var selected = this.items[this.selected]
|
2019-04-05 21:53:51 +02:00
|
|
|
if(this.mode === "settings"){
|
|
|
|
if(name === "confirm"){
|
|
|
|
if(selected.id === "back"){
|
|
|
|
this.onEnd()
|
2019-04-05 23:10:15 +02:00
|
|
|
}else if(selected.id === "default"){
|
|
|
|
this.defaultSettings()
|
2022-03-16 07:55:25 +01:00
|
|
|
}else if(selected.id === "browse"){
|
|
|
|
if(event){
|
|
|
|
this.playSound("se_don")
|
|
|
|
this.browse.click()
|
|
|
|
}
|
2019-04-05 21:53:51 +02:00
|
|
|
}else{
|
|
|
|
this.setValue(selected.id)
|
|
|
|
}
|
2019-11-28 07:04:40 +01:00
|
|
|
}else if(name === "up" || name === "right" || name === "down" || name === "left"){
|
2019-04-05 21:53:51 +02:00
|
|
|
selected.settingBox.classList.remove("selected")
|
2019-04-05 23:10:15 +02:00
|
|
|
do{
|
2019-11-28 07:04:40 +01:00
|
|
|
this.selected = this.mod(this.items.length, this.selected + ((name === "right" || name === "down") ? 1 : -1))
|
2022-03-16 07:55:25 +01:00
|
|
|
}while((this.items[this.selected].id === "default" || this.items[this.selected].id === "browse") && name !== "left")
|
2019-04-06 21:14:44 +02:00
|
|
|
selected = this.items[this.selected]
|
|
|
|
selected.settingBox.classList.add("selected")
|
2020-03-12 05:59:28 +01:00
|
|
|
this.scrollTo(selected.settingBox)
|
2019-11-28 07:04:40 +01:00
|
|
|
this.playSound("se_ka")
|
2019-04-05 21:53:51 +02:00
|
|
|
}else if(name === "back"){
|
2019-04-04 22:40:11 +02:00
|
|
|
this.onEnd()
|
2019-04-05 21:53:51 +02:00
|
|
|
}
|
2019-04-16 20:06:41 +02:00
|
|
|
}else if(this.mode === "gamepad"){
|
|
|
|
if(name === "confirm"){
|
|
|
|
this.gamepadBack(true)
|
2019-11-28 07:04:40 +01:00
|
|
|
}else if(name === "up" || name === "right" || name === "down" || name === "left"){
|
|
|
|
this.gamepadSet((name === "right" || name === "down") ? 1 : -1)
|
2019-04-16 20:06:41 +02:00
|
|
|
}else if(name === "back"){
|
|
|
|
this.gamepadBack()
|
|
|
|
}
|
2019-04-05 21:53:51 +02:00
|
|
|
}else if(this.mode === "keyboard"){
|
|
|
|
if(name === "back"){
|
|
|
|
this.keyboardBack(selected)
|
2019-11-28 07:04:40 +01:00
|
|
|
this.playSound("se_cancel")
|
|
|
|
}else if(event){
|
2019-04-16 20:06:41 +02:00
|
|
|
event.preventDefault()
|
|
|
|
var currentKey = event.key.toLowerCase()
|
|
|
|
for(var i in this.keyboardKeys){
|
|
|
|
if(this.keyboardKeys[i][0] === currentKey || !currentKey){
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var current = this.keyboardCurrent
|
2019-11-28 07:04:40 +01:00
|
|
|
this.playSound(current === "ka_l" || current === "ka_r" ? "se_ka" : "se_don")
|
2019-04-16 20:06:41 +02:00
|
|
|
this.keyboardKeys[current] = [currentKey]
|
|
|
|
this.keyboardSet()
|
2019-04-05 21:53:51 +02:00
|
|
|
}
|
2019-11-28 07:04:40 +01:00
|
|
|
}else if(this.mode === "latency"){
|
|
|
|
var latencySelected = this.latencyItems[this.latencySelected]
|
|
|
|
if(name === "confirm"){
|
|
|
|
if(latencySelected.id === "back"){
|
|
|
|
this.latencyBack(true)
|
|
|
|
}else if(latencySelected.id === "default"){
|
|
|
|
this.latencyDefault()
|
|
|
|
}else{
|
|
|
|
this.latencySetValue(latencySelected.id)
|
|
|
|
}
|
|
|
|
}else if(name === "up" || name === "right" || name === "down" || name === "left"){
|
|
|
|
latencySelected.settingBox.classList.remove("selected")
|
|
|
|
do{
|
|
|
|
this.latencySelected = this.mod(this.latencyItems.length, this.latencySelected + ((name === "right" || name === "down") ? 1 : -1))
|
|
|
|
}while(this.latencyItems[this.latencySelected].id === "default" && name !== "left")
|
|
|
|
latencySelected = this.latencyItems[this.latencySelected]
|
|
|
|
latencySelected.settingBox.classList.add("selected")
|
|
|
|
latencySelected.settingBox.scrollIntoView()
|
|
|
|
this.playSound("se_ka")
|
|
|
|
}else if(name === "back"){
|
|
|
|
this.latencyBack()
|
|
|
|
}
|
|
|
|
}else if(this.mode === "latencySet"){
|
|
|
|
var latencySelected = this.latencyItems[this.latencySelected]
|
|
|
|
if(name === "confirm" || name === "back"){
|
|
|
|
this.latencySetBack(latencySelected)
|
|
|
|
this.playSound(name === "confirm" ? "se_don" : "se_cancel")
|
|
|
|
}else if(name === "up" || name === "right" || name === "down" || name === "left"){
|
|
|
|
this.latencySetAdjust(latencySelected, (name === "up" || name === "right") ? 1 : -1)
|
2022-02-22 14:23:01 +01:00
|
|
|
if(event){
|
|
|
|
event.preventDefault()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else if(this.mode === "number"){
|
|
|
|
if(name === "confirm" || name === "back"){
|
|
|
|
this.numberBack(selected)
|
|
|
|
this.playSound(name === "confirm" ? "se_don" : "se_cancel")
|
|
|
|
}else if(name === "up" || name === "right" || name === "down" || name === "left"){
|
|
|
|
this.numberAdjust(selected, (name === "up" || name === "right") ? 1 : -1)
|
|
|
|
if(event){
|
|
|
|
event.preventDefault()
|
|
|
|
}
|
2019-11-28 07:04:40 +01:00
|
|
|
}
|
2019-04-05 21:53:51 +02:00
|
|
|
}
|
|
|
|
}
|
2020-03-12 05:59:28 +01:00
|
|
|
scrollTo(element){
|
|
|
|
var parentNode = element.parentNode
|
|
|
|
var selected = element.getBoundingClientRect()
|
|
|
|
var parent = parentNode.getBoundingClientRect()
|
|
|
|
var scrollY = parentNode.scrollTop
|
|
|
|
var selectedPosTop = selected.top - selected.height / 2
|
|
|
|
if(Math.floor(selectedPosTop) < Math.floor(parent.top)){
|
|
|
|
parentNode.scrollTop += selectedPosTop - parent.top
|
|
|
|
}else{
|
|
|
|
var selectedPosBottom = selected.top + selected.height * 1.5 - parent.top
|
|
|
|
if(Math.floor(selectedPosBottom) > Math.floor(parent.height)){
|
|
|
|
parentNode.scrollTop += selectedPosBottom - parent.height
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-05 21:53:51 +02:00
|
|
|
keyboardSet(){
|
|
|
|
var selected = this.items[this.selected]
|
2022-02-11 15:28:22 +01:00
|
|
|
var current = this.settingsItems[selected.id]
|
2019-04-05 21:53:51 +02:00
|
|
|
selected.valueDiv.innerHTML = ""
|
|
|
|
for(var i in current.default){
|
2019-04-16 20:06:41 +02:00
|
|
|
var keyDiv = document.createElement("div")
|
|
|
|
keyDiv.style.color = i === "ka_l" || i === "ka_r" ? "#009aa5" : "#ef2c10"
|
2019-04-05 21:53:51 +02:00
|
|
|
if(this.keyboardKeys[i]){
|
2019-04-16 20:06:41 +02:00
|
|
|
var key = this.keyboardKeys[i][0]
|
|
|
|
for(var j in this.keyboard.substitute){
|
|
|
|
if(this.keyboard.substitute[j] === key){
|
|
|
|
key = j
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
keyDiv.innerText = key.toUpperCase()
|
|
|
|
selected.valueDiv.appendChild(keyDiv)
|
2019-04-04 22:40:11 +02:00
|
|
|
}else{
|
2019-04-16 20:06:41 +02:00
|
|
|
keyDiv.innerText = "[" + strings.settings[selected.id][i] + "]"
|
|
|
|
selected.valueDiv.appendChild(keyDiv)
|
2019-04-05 21:53:51 +02:00
|
|
|
this.keyboardCurrent = i
|
|
|
|
return
|
2019-04-04 22:40:11 +02:00
|
|
|
}
|
|
|
|
}
|
2019-04-05 21:53:51 +02:00
|
|
|
settings.setItem(selected.id, this.keyboardKeys)
|
|
|
|
this.keyboardBack(selected)
|
2019-04-16 20:06:41 +02:00
|
|
|
this.keyboard.update()
|
2019-04-05 21:53:51 +02:00
|
|
|
pageEvents.setKbd()
|
|
|
|
}
|
|
|
|
keyboardBack(selected){
|
|
|
|
this.mode = "settings"
|
|
|
|
selected.settingBox.style.animation = ""
|
|
|
|
selected.valueDiv.classList.remove("selected")
|
|
|
|
this.getValue(selected.id, selected.valueDiv)
|
2019-04-04 22:40:11 +02:00
|
|
|
}
|
2019-04-16 20:06:41 +02:00
|
|
|
gamepadSet(diff){
|
|
|
|
if(this.mode !== "gamepad"){
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var selected = this.items[this.selected]
|
2022-02-11 15:28:22 +01:00
|
|
|
var current = this.settingsItems[selected.id]
|
2019-04-16 20:06:41 +02:00
|
|
|
if(diff){
|
|
|
|
this.gamepadSelected = this.mod(current.options.length, this.gamepadSelected + diff)
|
2019-11-28 07:04:40 +01:00
|
|
|
this.playSound("se_ka")
|
2019-04-16 20:06:41 +02:00
|
|
|
}
|
|
|
|
var opt = current.options[this.gamepadSelected]
|
2019-04-16 21:48:21 +02:00
|
|
|
var value = strings.settings[selected.id][opt]
|
2019-11-28 07:04:40 +01:00
|
|
|
this.setAltText(this.gamepadValue, value)
|
|
|
|
this.gamepadButtons.style.backgroundPosition = "0 " + (-11.87 - 4.93 * this.gamepadSelected) + "em"
|
|
|
|
this.gamepadSettings.style.display = "flex"
|
2019-04-16 20:06:41 +02:00
|
|
|
}
|
2019-04-16 22:29:26 +02:00
|
|
|
gamepadBack(confirm){
|
2019-04-16 20:06:41 +02:00
|
|
|
if(this.mode !== "gamepad"){
|
|
|
|
return
|
|
|
|
}
|
2019-04-16 22:29:26 +02:00
|
|
|
var selected = this.items[this.selected]
|
2022-02-11 15:28:22 +01:00
|
|
|
var current = this.settingsItems[selected.id]
|
2019-04-16 22:29:26 +02:00
|
|
|
settings.setItem(selected.id, current.options[this.gamepadSelected])
|
|
|
|
this.getValue(selected.id, selected.valueDiv)
|
2019-11-28 07:04:40 +01:00
|
|
|
this.playSound(confirm ? "se_don" : "se_cancel")
|
2019-04-16 20:06:41 +02:00
|
|
|
this.gamepadSettings.style.display = ""
|
|
|
|
this.mode = "settings"
|
|
|
|
}
|
2019-11-28 07:04:40 +01:00
|
|
|
latencySet(){
|
|
|
|
if(this.mode !== "latency"){
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var selected = this.items[this.selected]
|
2022-02-11 15:28:22 +01:00
|
|
|
var current = this.settingsItems[selected.id]
|
2019-11-28 07:04:40 +01:00
|
|
|
this.latencySettings.style.display = "flex"
|
|
|
|
}
|
|
|
|
latencyGetValue(name, valueText){
|
|
|
|
var currentLatency = settings.getItem("latency")
|
|
|
|
if(name === "drumSounds"){
|
|
|
|
valueText.data = currentLatency[name] ? strings.settings.on : strings.settings.off
|
|
|
|
}else{
|
|
|
|
valueText.data = this.addMs(currentLatency[name] || 0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
latencySetValue(name, touched){
|
|
|
|
var selectedIndex = this.latencyItems.findIndex(item => item.id === name)
|
|
|
|
var selected = this.latencyItems[selectedIndex]
|
|
|
|
if(this.mode === "latencySet"){
|
|
|
|
this.latencySetBack(this.latencyItems[this.latencySelected])
|
|
|
|
if(this.latencySelected === selectedIndex){
|
|
|
|
this.playSound("se_don")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}else if(this.mode !== "latency"){
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if(name === "calibration"){
|
|
|
|
this.playSound("se_don")
|
|
|
|
this.clean()
|
|
|
|
new LoadSong({
|
|
|
|
"title": strings.calibration.title,
|
|
|
|
"folder": "calibration",
|
|
|
|
"type": "tja",
|
|
|
|
"songSkin": {}
|
|
|
|
}, false, false, touched)
|
|
|
|
}else if(name === "drumSounds"){
|
|
|
|
this.drumSounds = !settings.getItem("latency")[name]
|
|
|
|
this.latencySave(name, this.drumSounds)
|
|
|
|
this.latencyGetValue(name, selected.valueText)
|
|
|
|
this.playSound("se_don")
|
|
|
|
}else{
|
|
|
|
var value = Math.round(settings.getItem("latency")[name] || 0)
|
|
|
|
if(this.latencySelected !== selectedIndex){
|
|
|
|
this.latencyItems[this.latencySelected].settingBox.classList.remove("selected")
|
|
|
|
this.latencySelected = selectedIndex
|
|
|
|
selected.settingBox.classList.add("selected")
|
|
|
|
}
|
|
|
|
this.mode = "latencySet"
|
|
|
|
selected.settingBox.style.animation = "none"
|
|
|
|
selected.valueDiv.classList.add("selected")
|
|
|
|
selected.value = value
|
|
|
|
this.playSound("se_don")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
latencySetAdjust(selected, add){
|
|
|
|
selected.value += add
|
|
|
|
if(selected.value > 500){
|
|
|
|
selected.value = 500
|
|
|
|
}else if(selected.value < -200){
|
|
|
|
selected.value = -200
|
|
|
|
}else{
|
|
|
|
this.playSound("se_ka")
|
|
|
|
}
|
|
|
|
selected.valueText.data = this.addMs(selected.value)
|
|
|
|
}
|
|
|
|
latencySetBack(selected){
|
|
|
|
this.mode = "latency"
|
|
|
|
selected.settingBox.style.animation = ""
|
|
|
|
selected.valueDiv.classList.remove("selected")
|
|
|
|
this.latencySave(selected.id, selected.value)
|
|
|
|
this.latencyGetValue(selected.id, selected.valueText)
|
|
|
|
}
|
|
|
|
latencySave(id, value){
|
|
|
|
var input = settings.getItem("latency")
|
|
|
|
var output = {}
|
|
|
|
for(var i in input){
|
|
|
|
if(i === id){
|
|
|
|
output[i] = value
|
|
|
|
}else{
|
|
|
|
output[i] = input[i]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
settings.setItem("latency", output)
|
|
|
|
}
|
|
|
|
latencyDefault(){
|
|
|
|
if(this.mode === "latencySet"){
|
|
|
|
this.latencySetBack(this.latencyItems[this.latencySelected])
|
|
|
|
}else if(this.mode !== "latency"){
|
|
|
|
return
|
|
|
|
}
|
|
|
|
settings.setItem("latency", null)
|
|
|
|
this.latencyItems.forEach(item => {
|
|
|
|
if(item.id === "audio" || item.id === "video" || item.id === "drumSounds"){
|
|
|
|
this.latencyGetValue(item.id, item.valueText)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
this.drumSounds = settings.getItem("latency").drumSounds
|
|
|
|
this.playSound("se_don")
|
|
|
|
}
|
|
|
|
latencyBack(confirm){
|
|
|
|
if(this.mode === "latencySet"){
|
|
|
|
this.latencySetBack(this.latencyItems[this.latencySelected])
|
|
|
|
if(!confirm){
|
|
|
|
this.playSound("se_don")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(this.mode !== "latency"){
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var selected = this.items[this.selected]
|
2022-02-11 15:28:22 +01:00
|
|
|
var current = this.settingsItems[selected.id]
|
2019-11-28 07:04:40 +01:00
|
|
|
this.getValue(selected.id, selected.valueDiv)
|
|
|
|
this.playSound(confirm ? "se_don" : "se_cancel")
|
|
|
|
this.latencySettings.style.display = ""
|
|
|
|
this.mode = "settings"
|
|
|
|
}
|
2022-02-22 14:23:01 +01:00
|
|
|
numberAdjust(selected, add){
|
|
|
|
var selectedItem = this.items[this.selected]
|
|
|
|
var mul = Math.pow(10, selected.fixedPoint || 0)
|
|
|
|
selectedItem.value += add * ("step" in selected ? selected.step : 1)
|
|
|
|
if("max" in selected && selectedItem.value > selected.max * mul){
|
|
|
|
selectedItem.value = selected.max * mul
|
|
|
|
}else if("min" in selected && selectedItem.value < selected.min * mul){
|
|
|
|
selectedItem.value = selected.min * mul
|
|
|
|
}else{
|
|
|
|
this.playSound("se_ka")
|
|
|
|
}
|
|
|
|
var valueText = Intl.NumberFormat(strings.intl, selected.sign ? {
|
|
|
|
signDisplay: "always"
|
|
|
|
} : undefined).format(selectedItem.value / mul)
|
|
|
|
if(selected.format || selected.format_lang){
|
|
|
|
valueText = this.getLocalTitle(selected.format, selected.format_lang).replace("%s", valueText)
|
|
|
|
}
|
|
|
|
selectedItem.valueText.data = valueText
|
|
|
|
}
|
|
|
|
numberBack(selected){
|
|
|
|
this.mode = "settings"
|
|
|
|
selected.settingBox.style.animation = ""
|
|
|
|
selected.valueDiv.classList.remove("selected")
|
|
|
|
var current = this.settingsItems[selected.id]
|
|
|
|
var promise
|
|
|
|
var mul = Math.pow(10, selected.fixedPoint || 0)
|
|
|
|
var value = selected.value / mul
|
|
|
|
if(current.setItem){
|
|
|
|
promise = current.setItem(value)
|
|
|
|
}else{
|
|
|
|
settings.setItem(selected.id, value)
|
|
|
|
}
|
|
|
|
(promise || Promise.resolve()).then(() => {
|
|
|
|
this.getValue(selected.id, selected.valueText)
|
|
|
|
})
|
|
|
|
}
|
2019-11-28 07:04:40 +01:00
|
|
|
addMs(input){
|
|
|
|
var split = strings.calibration.ms.split("%s")
|
|
|
|
var index = 0
|
|
|
|
var output = ""
|
|
|
|
var inputStrings = [(input > 0 ? "+" : "") + input.toString()]
|
|
|
|
split.forEach((string, i) => {
|
|
|
|
if(i !== 0){
|
|
|
|
output += inputStrings[index++]
|
|
|
|
}
|
|
|
|
output += string
|
|
|
|
})
|
|
|
|
return output
|
|
|
|
}
|
2019-04-16 20:06:41 +02:00
|
|
|
defaultSettings(){
|
2022-02-11 15:28:22 +01:00
|
|
|
if(this.customSettings){
|
|
|
|
plugins.unloadImported()
|
2022-03-16 07:55:25 +01:00
|
|
|
this.clean(true)
|
|
|
|
this.playSound("se_don")
|
|
|
|
return setTimeout(() => this.restart(), 500)
|
2022-02-11 15:28:22 +01:00
|
|
|
}
|
2019-04-06 12:19:10 +02:00
|
|
|
if(this.mode === "keyboard"){
|
|
|
|
this.keyboardBack(this.items[this.selected])
|
2019-04-05 23:10:15 +02:00
|
|
|
}
|
2022-02-11 15:28:22 +01:00
|
|
|
for(var i in this.settingsItems){
|
2019-04-05 23:10:15 +02:00
|
|
|
settings.setItem(i, null)
|
|
|
|
}
|
2019-04-06 12:19:10 +02:00
|
|
|
this.setLang(allStrings[settings.getItem("language")])
|
2019-04-16 20:06:41 +02:00
|
|
|
this.keyboard.update()
|
|
|
|
pageEvents.setKbd()
|
2019-11-28 07:04:40 +01:00
|
|
|
this.latencyItems.forEach(item => {
|
|
|
|
if(item.id === "audio" || item.id === "video" || item.id === "drumSounds"){
|
|
|
|
this.latencyGetValue(item.id, item.valueText)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
this.drumSounds = settings.getItem("latency").drumSounds
|
|
|
|
this.playSound("se_don")
|
2019-04-05 23:10:15 +02:00
|
|
|
}
|
2022-03-16 07:55:25 +01:00
|
|
|
browseChange(event){
|
|
|
|
this.locked = true
|
|
|
|
var files = []
|
|
|
|
for(var i = 0; i < event.target.files.length; i++){
|
|
|
|
files.push(new LocalFile(event.target.files[i]))
|
|
|
|
}
|
|
|
|
var customSongs = new CustomSongs(this.touchEnabled, true)
|
|
|
|
customSongs.importLocal(files).then(() => {
|
|
|
|
this.clean(true)
|
|
|
|
return this.restart()
|
|
|
|
}).catch(e => {
|
|
|
|
if(e){
|
|
|
|
var message = e.message
|
|
|
|
if(e.name === "nosongs"){
|
|
|
|
message = strings.plugins.noPlugins
|
|
|
|
}
|
|
|
|
if(message){
|
|
|
|
alert(message)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.locked = false
|
|
|
|
this.browse.form.reset()
|
|
|
|
return Promise.resolve()
|
|
|
|
})
|
|
|
|
}
|
2019-04-16 20:06:41 +02:00
|
|
|
onEnd(){
|
2022-02-22 14:23:01 +01:00
|
|
|
if(this.mode === "number"){
|
|
|
|
this.numberBack(this.items[this.selected])
|
|
|
|
}
|
2019-04-04 22:40:11 +02:00
|
|
|
this.clean()
|
2019-11-28 07:04:40 +01:00
|
|
|
this.playSound("se_don")
|
2019-04-04 22:40:11 +02:00
|
|
|
setTimeout(() => {
|
2019-04-16 20:06:41 +02:00
|
|
|
if(this.tutorial && !this.touched){
|
|
|
|
new Tutorial(false, this.songId)
|
|
|
|
}else{
|
2019-04-16 22:29:26 +02:00
|
|
|
try{
|
|
|
|
localStorage.setItem("tutorial", "true")
|
|
|
|
}catch(e){}
|
2022-02-11 15:28:22 +01:00
|
|
|
new SongSelect(this.tutorial ? false : this.customSettings ? "plugins" : "settings", false, this.touched, this.songId)
|
2019-04-16 20:06:41 +02:00
|
|
|
}
|
2019-04-04 22:40:11 +02:00
|
|
|
}, 500)
|
|
|
|
}
|
2022-03-16 07:55:25 +01:00
|
|
|
restart(){
|
|
|
|
if(this.mode === "number"){
|
|
|
|
this.numberBack(this.items[this.selected])
|
|
|
|
}
|
|
|
|
return new SettingsView(this.touchEnabled, this.tutorial, this.songId, undefined, this.customSettings ? plugins.getSettings() : undefined, true)
|
|
|
|
}
|
2022-02-22 14:23:01 +01:00
|
|
|
getLocalTitle(title, titleLang){
|
|
|
|
if(titleLang){
|
|
|
|
for(var id in titleLang){
|
|
|
|
if(id === strings.id && titleLang[id]){
|
|
|
|
return titleLang[id]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return title
|
|
|
|
}
|
2019-04-06 12:19:10 +02:00
|
|
|
setLang(lang){
|
2022-03-03 16:19:16 +01:00
|
|
|
if(lang){
|
|
|
|
settings.setLang(lang)
|
|
|
|
}
|
2019-04-06 12:19:10 +02:00
|
|
|
if(failedTests.length !== 0){
|
|
|
|
showUnsupported(strings)
|
|
|
|
}
|
|
|
|
for(var i in this.items){
|
|
|
|
var item = this.items[i]
|
|
|
|
if(item.valueDiv){
|
2022-02-22 14:23:01 +01:00
|
|
|
if(item.name || item.name_lang){
|
|
|
|
var name = this.getLocalTitle(item.name, item.name_lang)
|
|
|
|
}else{
|
|
|
|
var name = strings.settings[item.id].name
|
|
|
|
}
|
2019-11-28 07:04:40 +01:00
|
|
|
this.setAltText(item.nameDiv, name)
|
2022-02-22 14:23:01 +01:00
|
|
|
if(item.description || item.description_lang){
|
2022-02-22 17:52:42 +01:00
|
|
|
item.settingBox.title = this.getLocalTitle(item.description, item.description_lang) || ""
|
2022-02-22 14:23:01 +01:00
|
|
|
}
|
2019-04-06 12:19:10 +02:00
|
|
|
this.getValue(item.id, item.valueDiv)
|
|
|
|
}
|
|
|
|
}
|
2019-11-28 07:04:40 +01:00
|
|
|
for(var i in this.latencyItems){
|
|
|
|
var current = this.latencyItems[i]
|
|
|
|
if(current.nameDiv){
|
|
|
|
this.setAltText(current.nameDiv, strings.settings.latency[current.id])
|
|
|
|
}
|
|
|
|
if(current.valueText){
|
|
|
|
this.latencyGetValue(current.id, current.valueText)
|
|
|
|
}
|
|
|
|
}
|
2019-04-06 12:19:10 +02:00
|
|
|
this.setStrings()
|
|
|
|
}
|
|
|
|
setStrings(){
|
2022-02-11 15:28:22 +01:00
|
|
|
this.setAltText(this.viewTitle, this.customSettings ? strings.plugins.title : strings.gameSettings)
|
2019-11-28 07:04:40 +01:00
|
|
|
this.setAltText(this.endButton, strings.settings.ok)
|
2022-03-16 07:55:25 +01:00
|
|
|
if(this.customSettings){
|
2022-03-16 17:04:51 +01:00
|
|
|
this.browseText.data = strings.plugins.browse
|
|
|
|
this.browseButton.setAttribute("alt", strings.plugins.browse)
|
2022-03-16 07:55:25 +01:00
|
|
|
}else{
|
2022-02-11 15:28:22 +01:00
|
|
|
this.setAltText(this.gamepadTitle, strings.settings.gamepadLayout.name)
|
|
|
|
this.setAltText(this.gamepadEndButton, strings.settings.ok)
|
|
|
|
this.setAltText(this.latencyTitle, strings.settings.latency.name)
|
|
|
|
this.setAltText(this.latencyDefaultButton, strings.settings.default)
|
|
|
|
this.setAltText(this.latencyEndButton, strings.settings.ok)
|
|
|
|
}
|
2022-03-16 07:55:25 +01:00
|
|
|
if(this.showDefault){
|
|
|
|
this.setAltText(this.defaultButton, this.customSettings ? strings.plugins.unloadAll : strings.settings.default)
|
|
|
|
}
|
2019-11-28 07:04:40 +01:00
|
|
|
}
|
|
|
|
setAltText(element, text){
|
|
|
|
element.innerText = text
|
|
|
|
element.setAttribute("alt", text)
|
2019-04-06 12:19:10 +02:00
|
|
|
}
|
2019-04-04 22:40:11 +02:00
|
|
|
mod(length, index){
|
|
|
|
return ((index % length) + length) % length
|
|
|
|
}
|
2019-11-28 07:04:40 +01:00
|
|
|
playSound(id, time){
|
|
|
|
if(!this.drumSounds && (id === "se_don" || id === "se_ka" || id === "se_cancel")){
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var ms = Date.now() + (time || 0) * 1000
|
|
|
|
if(!(id in this.playedSounds) || ms > this.playedSounds[id] + 30){
|
|
|
|
assets.sounds[id].play(time)
|
|
|
|
this.playedSounds[id] = ms
|
|
|
|
}
|
|
|
|
}
|
|
|
|
redraw(){
|
|
|
|
if(!this.redrawRunning){
|
|
|
|
return
|
|
|
|
}
|
|
|
|
requestAnimationFrame(this.redrawBind)
|
|
|
|
var ms = this.getMS()
|
|
|
|
|
|
|
|
for(var key in this.pressedKeys){
|
|
|
|
if(this.pressedKeys[key]){
|
|
|
|
if(ms >= this.pressedKeys[key] + 50){
|
|
|
|
this.keyPressed(true, key, null, true)
|
|
|
|
this.pressedKeys[key] = ms
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
getMS(){
|
|
|
|
return Date.now()
|
|
|
|
}
|
2022-03-16 07:55:25 +01:00
|
|
|
clean(noSoundStop){
|
2019-11-28 07:04:40 +01:00
|
|
|
this.redrawRunning = false
|
2019-04-16 20:06:41 +02:00
|
|
|
this.keyboard.clean()
|
2019-04-04 22:40:11 +02:00
|
|
|
this.gamepad.clean()
|
2022-03-16 07:55:25 +01:00
|
|
|
if(!noSoundStop){
|
|
|
|
assets.sounds["bgm_settings"].stop()
|
|
|
|
}
|
2020-03-09 13:36:57 +01:00
|
|
|
pageEvents.remove(window, ["mouseup", "touchstart", "touchmove", "touchend", "blur"], this.windowSymbol)
|
2022-03-03 16:19:16 +01:00
|
|
|
if(this.customSettings){
|
|
|
|
pageEvents.remove(window, "language-change", this.windowSymbol)
|
|
|
|
}
|
2019-04-04 22:40:11 +02:00
|
|
|
for(var i in this.items){
|
2020-03-09 13:36:57 +01:00
|
|
|
this.removeTouchEnd(this.items[i].settingBox)
|
2019-04-04 22:40:11 +02:00
|
|
|
}
|
2019-11-28 07:04:40 +01:00
|
|
|
for(var i in this.latencyItems){
|
|
|
|
this.removeTouch(this.latencyItems[i].settingBox)
|
|
|
|
if(this.latencyItems[i].buttonMinus){
|
|
|
|
this.removeTouch(this.latencyItems[i].buttonMinus)
|
|
|
|
this.removeTouch(this.latencyItems[i].buttonPlus)
|
|
|
|
}
|
|
|
|
}
|
2019-04-06 21:14:44 +02:00
|
|
|
if(this.defaultButton){
|
|
|
|
delete this.defaultButton
|
|
|
|
}
|
2022-03-16 07:55:25 +01:00
|
|
|
if(this.customSettings){
|
|
|
|
pageEvents.remove(this.browse, "change")
|
|
|
|
delete this.browse
|
|
|
|
delete this.browseButton
|
2022-03-16 17:04:51 +01:00
|
|
|
delete this.browseText
|
2022-03-16 07:55:25 +01:00
|
|
|
}else{
|
2022-02-11 15:28:22 +01:00
|
|
|
this.removeTouch(this.gamepadSettings)
|
|
|
|
this.removeTouch(this.gamepadEndButton)
|
|
|
|
this.removeTouch(this.gamepadBox)
|
|
|
|
this.removeTouch(this.latencySettings)
|
|
|
|
this.removeTouch(this.latencyDefaultButton)
|
|
|
|
this.removeTouch(this.latencyEndButton)
|
|
|
|
}
|
2020-03-09 13:36:57 +01:00
|
|
|
delete this.windowSymbol
|
|
|
|
delete this.touchMove
|
2019-11-28 07:04:40 +01:00
|
|
|
delete this.viewOuter
|
|
|
|
delete this.touchEnd
|
2019-04-06 12:19:10 +02:00
|
|
|
delete this.tutorialTitle
|
2019-04-04 22:40:11 +02:00
|
|
|
delete this.endButton
|
|
|
|
delete this.items
|
2019-04-16 20:06:41 +02:00
|
|
|
delete this.gamepadSettings
|
|
|
|
delete this.gamepadTitle
|
|
|
|
delete this.gamepadEndButton
|
2019-04-16 21:48:21 +02:00
|
|
|
delete this.gamepadBox
|
2019-04-16 20:06:41 +02:00
|
|
|
delete this.gamepadButtons
|
|
|
|
delete this.gamepadValue
|
2019-11-28 07:04:40 +01:00
|
|
|
delete this.latencyItems
|
|
|
|
delete this.latencySettings
|
|
|
|
delete this.latencyTitle
|
|
|
|
delete this.latencyDefaultButton
|
|
|
|
delete this.latencyEndButton
|
2019-04-04 22:40:11 +02:00
|
|
|
if(this.resolution !== settings.getItem("resolution")){
|
|
|
|
for(var i in assets.image){
|
2022-03-16 07:55:25 +01:00
|
|
|
if(i === "touch_drum" || i.startsWith("bg_song_") || i.startsWith("bg_stage_") || i.startsWith("bg_don_") || i.startsWith("results_")){
|
|
|
|
var img = assets.image[i]
|
|
|
|
URL.revokeObjectURL(img.src)
|
|
|
|
if(img.parentNode){
|
|
|
|
img.parentNode.removeChild(img)
|
|
|
|
}
|
2019-04-04 22:40:11 +02:00
|
|
|
delete assets.image[i]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|