From 59baa9f06f2fd61a1c5b25e2debb68a15521847e Mon Sep 17 00:00:00 2001 From: LoveEevee Date: Mon, 21 Jan 2019 18:47:22 +0300 Subject: [PATCH] Titlescreen: Add language selection menu --- public/src/css/loader.css | 1 - public/src/css/titlescreen.css | 22 +- public/src/js/assets.js | 3 +- public/src/js/canvasdraw.js | 66 ++++-- public/src/js/main.js | 3 +- public/src/js/parseosu.js | 4 +- public/src/js/scoresheet.js | 2 +- public/src/js/songselect.js | 16 +- public/src/js/strings.js | 348 +++++++++++++++++++++++++----- public/src/js/titlescreen.js | 61 +++++- public/src/js/view.js | 25 ++- public/src/views/titlescreen.html | 3 + 12 files changed, 463 insertions(+), 91 deletions(-) diff --git a/public/src/css/loader.css b/public/src/css/loader.css index 306ced8..de0e97d 100644 --- a/public/src/css/loader.css +++ b/public/src/css/loader.css @@ -17,7 +17,6 @@ body{ background-color: #000; background-position: top center; background-size: 30vh; - font-family: TnT, Meiryo, sans-serif; } #screen.pattern-bg{ background-color: #fe7839; diff --git a/public/src/css/titlescreen.css b/public/src/css/titlescreen.css index 0cced4c..a438950 100644 --- a/public/src/css/titlescreen.css +++ b/public/src/css/titlescreen.css @@ -41,5 +41,25 @@ .click-to-continue::before{ -webkit-text-stroke: 0.25em #f00; filter: blur(0.3vmin); - left: auto; +} +#lang{ + font-size: 3vmin; + position: absolute; + bottom: 0; + left: 0; + background-repeat: no-repeat; + background-size: auto 70%; + background-position: center; + width: 4em; + height: 4em; +} +#lang:focus-within{ + outline: #4d90fe auto 5px; +} +#lang-dropdown{ + font-size: 1.7em; + font-family: Microsoft YaHei, sans-serif; + opacity: 0; + width: 100%; + height: 100%; } diff --git a/public/src/js/assets.js b/public/src/js/assets.js index 89097f8..3292909 100644 --- a/public/src/js/assets.js +++ b/public/src/js/assets.js @@ -82,7 +82,8 @@ var assets = { "mimizu.png", "results_flowers.png", "results_mikoshi.png", - "results_tetsuohana.png" + "results_tetsuohana.png", + "globe.svg" ], "audioSfx": [ "don.wav", diff --git a/public/src/js/canvasdraw.js b/public/src/js/canvasdraw.js index 48e3bbb..572cf90 100644 --- a/public/src/js/canvasdraw.js +++ b/public/src/js/canvasdraw.js @@ -285,6 +285,7 @@ inputText = inputText.slice(0, matches.index) ura = matches[0] } + var bold = this.bold(config.fontFamily) var string = inputText.split("") var drawn = [] @@ -296,30 +297,54 @@ drawn.push({text: symbol, x: 0, y: 0, h: 18}) }else if(symbol === "ー"){ // Long-vowel mark - drawn.push({realText: symbol, svg: this.longVowelMark, x: -4, y: 5, h: 33, scale: [mul, mul]}) + if(bold){ + drawn.push({text: symbol, x: -1, y: -1, h: 33, rotate: true}) + }else{ + drawn.push({realText: symbol, svg: this.longVowelMark, x: -4, y: 5, h: 33, scale: [mul, mul]}) + } }else if(symbol === "∀"){ drawn.push({text: symbol, x: 0, y: 0, h: 39, rotate: true}) }else if(symbol === "↓"){ drawn.push({text: symbol, x: 0, y: 12, h: 45}) }else if(symbol === "."){ - drawn.push({realText: symbol, text: ".", x: 13, y: -7, h: 15, scale: [1.2, 0.7]}) + if(bold){ + drawn.push({realText: symbol, text: ".", x: 13, y: -15, h: 15}) + }else{ + drawn.push({realText: symbol, text: ".", x: 13, y: -7, h: 15, scale: [1.2, 0.7]}) + } }else if(symbol === "…"){ - drawn.push({text: symbol, x: 0, y: 5, h: 25, rotate: true}) + drawn.push({text: symbol, x: bold ? 9 : 0, y: 5, h: 25, rotate: true}) }else if(r.comma.test(symbol)){ // Comma, full stop - drawn.push({text: symbol, x: 13, y: -7, h: 15, scale: [1.2, 0.7]}) + if(bold){ + drawn.push({text: symbol, x: 13, y: -15, h: 15}) + }else{ + drawn.push({text: symbol, x: 13, y: -7, h: 15, scale: [1.2, 0.7]}) + } }else if(r.ideographicComma.test(symbol)){ // Ideographic comma, full stop drawn.push({text: symbol, x: 16, y: -16, h: 18}) }else if(r.apostrophe.test(symbol)){ // Apostrophe - drawn.push({realText: symbol, text: ",", x: 20, y: -39, h: 0, scale: [1.2, 0.7]}) + if(bold){ + drawn.push({text: symbol, x: 20, y: -25, h: 0}) + }else{ + drawn.push({realText: symbol, text: ",", x: 20, y: -39, h: 0, scale: [1.2, 0.7]}) + } }else if(r.degree.test(symbol)){ // Degree - drawn.push({text: symbol, x: 16, y: 3, h: 18}) + if(bold){ + drawn.push({text: symbol, x: 16, y: 9, h: 25}) + }else{ + drawn.push({text: symbol, x: 16, y: 3, h: 18}) + } }else if(r.brackets.test(symbol)){ // Rotated brackets - drawn.push({text: symbol, x: 0, y: -5, h: 25, rotate: true}) + if(bold){ + drawn.push({text: symbol, x: 0, y: 0, h: 35, rotate: true}) + }else{ + drawn.push({text: symbol, x: 0, y: -5, h: 25, rotate: true}) + } }else if(r.tilde.test(symbol)){ // Rotated hyphen, tilde drawn.push({realText: symbol, text: symbol === "~" ? "~" : symbol, x: 0, y: 2, h: 35, rotate: true}) @@ -448,7 +473,7 @@ actions.push("selectable") } for(let action of actions){ - ctx.font = config.fontSize + "px " + config.fontFamily + ctx.font = bold + config.fontSize + "px " + config.fontFamily ctx.textBaseline = "top" if(action === "stroke"){ ctx.strokeStyle = config.outline @@ -571,6 +596,7 @@ inputText = inputText.slice(0, matches.index) ura = matches[0] } + var bold = this.bold(config.fontFamily) var string = inputText.split("") var drawn = [] @@ -587,12 +613,20 @@ }else if(symbol === "'"){ drawn.push({text: ",", x: 0, y: -15, w: 7, scale: [1, 0.7]}) }else if(symbol === "∀"){ - drawn.push({text: symbol, x: -3, y: 0, w: 55}) + if(bold){ + drawn.push({text: symbol, x: 0, y: 0, w: 40}) + }else{ + drawn.push({text: symbol, x: -3, y: 0, w: 55}) + } }else if(symbol === "."){ drawn.push({text: symbol, x: -9, y: 0, w: 37}) }else if(r.comma.test(symbol)){ // Comma, full stop - drawn.push({text: symbol, x: -3, y: 13, w: 13, scale: [1.2, 0.7]}) + if(bold){ + drawn.push({text: symbol, x: -3, y: 0, w: 13}) + }else{ + drawn.push({text: symbol, x: -3, y: 13, w: 13, scale: [1.2, 0.7]}) + } }else if(r.en.test(symbol)){ // n-width drawn.push({text: symbol, x: 0, y: 0, w: 28}) @@ -614,7 +648,11 @@ drawn.push({text: number, x: 0, y: 0, w: 32}) }else if(r.degree.test(symbol)){ // Degree - drawn.push({text: symbol, x: 5, y: 0, w: 0}) + if(bold){ + drawn.push({text: symbol, x: 0, y: 0, w: 20}) + }else{ + drawn.push({text: symbol, x: 5, y: 0, w: 0}) + } }else if(r.uppercase.test(symbol)){ // Latin script uppercase drawn.push({text: symbol, x: 0, y: 0, w: 32}) @@ -668,7 +706,7 @@ drawn.reverse() } - ctx.font = config.fontSize + "px " + config.fontFamily + ctx.font = bold + config.fontSize + "px " + config.fontFamily ctx.textBaseline = config.baseline || "top" ctx.textAlign = "center" @@ -1252,6 +1290,10 @@ } } + bold(font){ + return font === "Microsoft YaHei, sans-serif" ? "bold " : "" + } + getMS(){ return Date.now() } diff --git a/public/src/js/main.js b/public/src/js/main.js index 7176140..aa21888 100644 --- a/public/src/js/main.js +++ b/public/src/js/main.js @@ -80,9 +80,10 @@ var perf = { allImg: 0, load: 0 } +var strings pageEvents.add(root, ["touchstart", "touchmove", "touchend"], event => { - if(event.cancelable && cancelTouch){ + if(event.cancelable && cancelTouch && event.target.tagName !== "SELECT"){ event.preventDefault() } }) diff --git a/public/src/js/parseosu.js b/public/src/js/parseosu.js index 0039bd8..336bc70 100644 --- a/public/src/js/parseosu.js +++ b/public/src/js/parseosu.js @@ -319,10 +319,10 @@ class ParseOsu{ if(hitSound & this.osu.FINISH){ if(hitSound & this.osu.WHISTLE || hitSound & this.osu.CLAP){ type = "daiKa" - txt = "カッ(大)" + txt = strings.note.daiKa }else if(hitSound & this.osu.NORMAL || hitSound === this.osu.FINISH){ type = "daiDon" - txt = "ドン(大)" + txt = strings.note.daiDon }else{ emptyValue = true } diff --git a/public/src/js/scoresheet.js b/public/src/js/scoresheet.js index d0ed61e..445c4a3 100644 --- a/public/src/js/scoresheet.js +++ b/public/src/js/scoresheet.js @@ -16,7 +16,7 @@ class Scoresheet{ this.fadeScreen.id = "fade-screen" this.game.appendChild(this.fadeScreen) - this.font = "TnT, Meiryo, sans-serif" + this.font = strings.font this.state = { screen: "fadeIn", screenMS: this.getMS(), diff --git a/public/src/js/songselect.js b/public/src/js/songselect.js index c011a63..88eaba4 100644 --- a/public/src/js/songselect.js +++ b/public/src/js/songselect.js @@ -90,14 +90,15 @@ class SongSelect{ outline: "#656565" } } - this.font = "TnT, Meiryo, sans-serif" + this.font = strings.font this.songs = [] for(let song of assets.songs){ + var en = strings.id === "en" this.songs.push({ id: song.id, - title: song.title, - subtitle: song.subtitle, + title: en ? song.title_en : song.title, + subtitle: en ? song.subtitle_en : song.subtitle, skin: song.category in this.songSkin ? this.songSkin[song.category] : this.songSkin.default, stars: song.stars, category: song.category, @@ -886,6 +887,7 @@ class SongSelect{ fontFamily: this.font, x: 53, y: 30, + width: 280, letterSpacing: 2, forceShadow: true }, [ @@ -1089,8 +1091,7 @@ class SongSelect{ highlight = 0 } - if(this.currentSongId !== currentSong.id || this.currentSongTitle !== currentSong.title){ - this.currentSongId = currentSong.id + if(this.currentSongTitle !== currentSong.title){ this.currentSongTitle = currentSong.title this.currentSongCache.clear() } @@ -1279,15 +1280,16 @@ class SongSelect{ h: (songSel ? 88 : 135) + 10, id: this.difficulty[currentUra ? 4 : i] + (songSel ? "1" : "0") }, ctx => { + var ja = strings.id === "ja" this.draw.verticalText({ ctx: ctx, text: this.difficulty[i], x: offset, y: 0, width: songSel ? 44 : 56, - height: songSel ? (i === 1 ? 66 : 88) : (i === 0 ? 130 : (i === 1 ? 110 : 135)), + height: songSel ? (i === 1 && ja ? 66 : 88) : (ja ? 130 : (i === 1 && ja ? 110 : 135)), fill: currentUra ? "#fff" : "#000", - fontSize: songSel ? 25 : (i === 2 ? 45 : 40), + fontSize: songSel ? 25 : (i === 2 && ja ? 45 : 40), fontFamily: this.font, outline: currentUra ? "#003C52" : false, outlineSize: currentUra ? this.songAsset.letterBorder : 0 diff --git a/public/src/js/strings.js b/public/src/js/strings.js index b1ed85b..7428fc0 100644 --- a/public/src/js/strings.js +++ b/public/src/js/strings.js @@ -1,55 +1,297 @@ -class StringsJa{ - constructor(){ - this.titleProceed = "Click or Press Enter!" - this.categories = { - "J-POP": "J-POP", - "アニメ": "アニメ", - "ボーカロイド™曲": "ボーカロイド™曲", - "バラエティ": "バラエティ", - "クラシック": "クラシック", - "ゲームミュージック": "ゲームミュージック", - "ナムコオリジナル": "ナムコオリジナル" - } - this.selectSong = "曲をえらぶ" - this.selectDifficulty = "むずかしさをえらぶ" - this.back = "もどる" - this.random = "ランダム" - this.randomSong = "ランダムに曲をえらぶ" - this.tutorial = "あそびかた説明" - this.aboutSimulator = "このシミュレータについて" - this.browse = "参照する…" - this.defaultSongList = "デフォルト曲リスト" - this.songOptions = "演奏オプション" - this.none = "なし" - this.auto = "オート" - this.netplay = "ネットプレイ" - this.easy = "かんたん" - this.normal = "ふつう" - this.hard = "むずかしい" - this.oni = "おに" - this.sessionStart = "オンラインセッションを開始する!" - this.sessionEnd = "オンラインセッションを終了する" - this.loading = "Loading..." - this.cancel = "Cancel" - this.note = { - don: "ドン", - ka: "カッ", - daiDon: "ドン(大)", - daiKa: "カッ(大)", - drumroll: "連打ーっ!!", - daiDrumroll: "連打(大)ーっ!!", - balloon: "ふうせん" - } - this.clear = "クリア" - this.pauseOptions = [ - "演奏をつづける", - "はじめからやりなおす", - "「曲をえらぶ」にもどる" - ] - this.results = "成績発表" - this.points = "点" - this.maxCombo = "最大コンボ数" - this.drumroll = "連打数" +function StringsJa(){ + this.id = "ja" + this.name = "日本語" + this.regex = /^ja$/ + this.font = "TnT, Meiryo, sans-serif" + + this.titleProceed = "クリックするかEnterを押す!" + this.categories = { + "J-POP": "J-POP", + "アニメ": "アニメ", + "ボーカロイド™曲": "ボーカロイド™曲", + "バラエティ": "バラエティ", + "クラシック": "クラシック", + "ゲームミュージック": "ゲームミュージック", + "ナムコオリジナル": "ナムコオリジナル" } + this.selectSong = "曲をえらぶ" + this.selectDifficulty = "むずかしさをえらぶ" + this.back = "もどる" + this.random = "ランダム" + this.randomSong = "ランダムに曲をえらぶ" + this.tutorial = "あそびかた説明" + this.aboutSimulator = "このシミュレータについて" + this.browse = "参照する…" + this.defaultSongList = "デフォルト曲リスト" + this.songOptions = "演奏オプション" + this.none = "なし" + this.auto = "オート" + this.netplay = "ネットプレイ" + this.easy = "かんたん" + this.normal = "ふつう" + this.hard = "むずかしい" + this.oni = "おに" + this.sessionStart = "オンラインセッションを開始する!" + this.sessionEnd = "オンラインセッションを終了する" + this.loading = "ロード中..." + this.cancel = "キャンセル" + this.note = { + don: "ドン", + ka: "カッ", + daiDon: "ドン(大)", + daiKa: "カッ(大)", + drumroll: "連打ーっ!!", + daiDrumroll: "連打(大)ーっ!!", + balloon: "ふうせん" + } + this.combo = "コンボ" + this.clear = "クリア" + this.pauseOptions = [ + "演奏をつづける", + "はじめからやりなおす", + "「曲をえらぶ」にもどる" + ] + this.results = "成績発表" + this.points = "点" + this.maxCombo = "最大コンボ数" + this.drumroll = "連打数" +} +function StringsEn(){ + this.id = "en" + this.name = "English" + this.regex = /^en$|^en-/ + this.font = "TnT, Meiryo, sans-serif" + + this.titleProceed = "Click or Press Enter!" + this.categories = { + "J-POP": "Pop", + "アニメ": "Anime", + "ボーカロイド™曲": "VOCALOID™ Music", + "バラエティ": "Variety", + "クラシック": "Classical", + "ゲームミュージック": "Game Music", + "ナムコオリジナル": "NAMCO Original" + } + this.selectSong = "Select Song" + this.selectDifficulty = "Select Difficulty" + this.back = "Back" + this.random = "Random" + this.randomSong = "Random Song" + this.tutorial = "How to Play" + this.aboutSimulator = "About Simulator" + this.browse = "Browse…" + this.defaultSongList = "Default Song List" + this.songOptions = "Song Options" + this.none = "None" + this.auto = "Auto" + this.netplay = "Netplay" + this.easy = "Easy" + this.normal = "Normal" + this.hard = "Hard" + this.oni = "Extreme" + this.sessionStart = "Begin an Online Session!" + this.sessionEnd = "End Online Session" + this.loading = "Loading..." + this.cancel = "Cancel" + this.note = { + don: "Don", + ka: "Ka", + daiDon: "DON", + daiKa: "KA", + drumroll: "Drum rollー!!", + daiDrumroll: "DRUM ROLLー!!", + balloon: "Balloon" + } + this.combo = "Combo" + this.clear = "Clear" + this.pauseOptions = [ + "Continue", + "Retry", + "Back to Select Song" + ] + this.results = "Results" + this.points = "pts" + this.maxCombo = "MAX Combo" + this.drumroll = "Drumroll" +} +function StringsCn(){ + this.id = "cn" + this.name = "中文简体" + this.regex = /^zh$|^zh-CN$/ + this.font = "Microsoft YaHei, sans-serif" + + this.titleProceed = "点击或按回车!" + this.categories = { + "J-POP": "流行音乐", + "アニメ": "卡通动画音乐", + "ボーカロイド™曲": "VOCALOID™ Music", + "バラエティ": "综合音乐", + "クラシック": "古典音乐", + "ゲームミュージック": "游戏音乐", + "ナムコオリジナル": "NAMCO原创音乐" + } + this.selectSong = "选择乐曲" + this.selectDifficulty = "选择难度" + this.back = "返回" + this.random = "随机" + this.randomSong = "随机选曲" + this.tutorial = "操作说明" + this.aboutSimulator = "游戏信息" + this.browse = "浏览…" + this.defaultSongList = "默认歌曲列表" + this.songOptions = "选项" + this.none = "无" + this.auto = "自动" + this.netplay = "网络对战" + this.easy = "简单" + this.normal = "普通" + this.hard = "困难" + this.oni = "魔王" + this.sessionStart = "开始在线会议!" + this.sessionEnd = "结束在线会话" + this.loading = "读取中..." + this.cancel = "取消" + this.note = { + don: "咚", + ka: "咔", + daiDon: "咚(大)", + daiKa: "咔(大)", + drumroll: "连打ー!!", + daiDrumroll: "连打(大)ー!!", + balloon: "气球" + } + this.combo = "连段" + this.clear = "通关" + this.pauseOptions = [ + "继续演奏", + "从头开始", + "返回「选择乐曲」" + ] + this.results = "发表成绩" + this.points = "点" + this.maxCombo = "最多连段数" + this.drumroll = "连打数" +} +function StringsTw(){ + this.id = "tw" + this.name = "中文繁體" + this.regex = /^zh-HK$|^zh-TW$/ + this.font = "Microsoft YaHei, sans-serif" + + this.titleProceed = "點擊或按回車!" + this.categories = { + "J-POP": "流行音樂", + "アニメ": "卡通動畫音樂", + "ボーカロイド™曲": "VOCALOID™ Music", + "バラエティ": "綜合音樂", + "クラシック": "古典音樂", + "ゲームミュージック": "遊戲音樂", + "ナムコオリジナル": "NAMCO原創音樂" + } + this.selectSong = "選擇樂曲" + this.selectDifficulty = "選擇難度" + this.back = "返回" + this.random = "隨機" + this.randomSong = "隨機選曲" + this.tutorial = "操作说明" + this.aboutSimulator = "游戏信息" + this.browse = "浏览…" + this.defaultSongList = "默认歌曲列表" + this.songOptions = "選項" + this.none = "無" + this.auto = "自動" + this.netplay = "网络对战" + this.easy = "簡單" + this.normal = "普通" + this.hard = "困難" + this.oni = "魔王" + this.sessionStart = "開始在線會議!" + this.sessionEnd = "結束在線會話" + this.loading = "讀取中..." + this.cancel = "取消" + this.note = { + don: "咚", + ka: "咔", + daiDon: "咚(大)", + daiKa: "咔(大)", + drumroll: "連打ー!!", + daiDrumroll: "連打(大)ー!!", + balloon: "氣球" + } + this.combo = "連段" + this.clear = "通關" + this.pauseOptions = [ + "繼續演奏", + "從頭開始", + "返回「選擇樂曲」" + ] + this.results = "發表成績" + this.points = "點" + this.maxCombo = "最多連段數" + this.drumroll = "連打數" +} +function StringsKo(){ + this.id = "ko" + this.name = "한국어" + this.regex = /^ko$/ + this.font = "Microsoft YaHei, sans-serif" + + this.titleProceed = "클릭하거나 Enter를 누릅니다!" + this.categories = { + "J-POP": "POP", + "アニメ": "애니메이션", + "ボーカロイド™曲": "VOCALOID™ Music", + "バラエティ": "버라이어티", + "クラシック": "클래식", + "ゲームミュージック": "게임", + "ナムコオリジナル": "남코 오리지널" + } + this.selectSong = "곡 선택" + this.selectDifficulty = "난이도 선택" + this.back = "돌아간다" + this.random = "랜덤" + this.randomSong = "랜덤" + this.tutorial = "지도 시간" + this.aboutSimulator = "게임 정보" + this.browse = "찾아보기…" + this.defaultSongList = "기본 노래 목록" + this.songOptions = "옵션" + this.none = "없음" + this.auto = "오토" + this.netplay = "넷 플레이" + this.easy = "쉬움" + this.normal = "보통" + this.hard = "어려움" + this.oni = "귀신" + this.sessionStart = "온라인 세션 시작!" + this.sessionEnd = "온라인 세션 끝내기" + this.loading = "로딩 중..." + this.cancel = "취소" + this.note = { + don: "쿵", + ka: "딱", + daiDon: "쿵(대)", + daiKa: "딱(대)", + drumroll: "연타ー!!", + daiDrumroll: "연타(대)ー!!", + balloon: "풍선" + } + this.combo = "콤보" + this.clear = "클리어" + this.pauseOptions = [ + "연주 계속하기", + "처음부터 다시", + "「곡 선택」으로" + ] + this.results = "성적 발표" + this.points = "점" + this.maxCombo = "최대 콤보 수" + this.drumroll = "연타 횟수" +} +var allStrings = { + "ja": new StringsJa(), + "en": new StringsEn(), + "cn": new StringsCn(), + "tw": new StringsTw(), + "ko": new StringsKo() } -var strings = new StringsJa() diff --git a/public/src/js/titlescreen.js b/public/src/js/titlescreen.js index 777e09d..58b6acb 100644 --- a/public/src/js/titlescreen.js +++ b/public/src/js/titlescreen.js @@ -1,13 +1,19 @@ class Titlescreen{ constructor(){ loader.changePage("titlescreen", false) + this.titleScreen = document.getElementById("title-screen") - var proceed = document.getElementById("title-proceed") - proceed.appendChild(document.createTextNode(strings.titleProceed)) - proceed.setAttribute("alt", strings.titleProceed) + this.proceed = document.getElementById("title-proceed") + this.langDropdown = document.getElementById("lang-dropdown") + + this.lang = this.getLang() + this.setLang(allStrings[this.lang]) + this.addLangs() pageEvents.keyAdd(this, "all", "down", this.keyDown.bind(this)) pageEvents.add(this.titleScreen, ["mousedown", "touchstart"], this.onPressed.bind(this)) + pageEvents.add(this.langDropdown, "change", this.langChange.bind(this)) + assets.sounds["title"].play() this.gamepad = new Gamepad({ "13": ["a", "b", "x", "y", "start", "ls", "rs"] @@ -24,7 +30,11 @@ class Titlescreen{ }) } } + keyDown(event, code){ + if(event && event.target === this.langDropdown){ + return + } if(!code){ code = event.keyCode } @@ -61,11 +71,56 @@ class Titlescreen{ }, 500) } } + + getLang(){ + if(localStorage.lang && localStorage.lang in allStrings){ + return localStorage.lang + } + 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 + } + } + } + } + return "ja" + } + setLang(lang){ + strings = lang + this.proceed.innerText = strings.titleProceed + this.proceed.setAttribute("alt", strings.titleProceed) + loader.screen.style.fontFamily = strings.font + loader.screen.style.fontWeight = strings.font === "Microsoft YaHei, sans-serif" ? "bold" : "" + } + addLangs(){ + for(var i in allStrings){ + var option = document.createElement("option") + option.value = i + if(i === this.lang){ + option.selected = true + } + option.appendChild(document.createTextNode(allStrings[i].name)) + this.langDropdown.appendChild(option) + } + } + langChange(){ + this.lang = this.langDropdown.value + localStorage.lang = this.lang + this.setLang(allStrings[this.lang]) + } + clean(){ this.gamepad.clean() assets.sounds["title"].stop() pageEvents.keyRemove(this, "all") pageEvents.remove(this.titleScreen, ["mousedown", "touchstart"]) + pageEvents.remove(this.langDropdown, "change") delete this.titleScreen + delete this.proceed + delete this.langDropdown } } diff --git a/public/src/js/view.js b/public/src/js/view.js index 203db89..ce17057 100644 --- a/public/src/js/view.js +++ b/public/src/js/view.js @@ -69,7 +69,7 @@ this.drumroll = [] this.beatInterval = this.controller.parsedSongData.beatInfo.beatInterval - this.font = "TnT, Meiryo, sans-serif" + this.font = strings.font this.draw = new CanvasDraw() this.assets = new ViewAssets(this) @@ -260,9 +260,14 @@ }) ctx.fill() + if(selectedSong.category in strings.categories){ + var categoryName = strings.categories[selectedSong.category] + }else{ + var categoryName = selectedSong.category + } this.draw.layeredText({ ctx: ctx, - text: selectedSong.category, + text: categoryName, fontSize: 15, fontFamily: this.font, align: "center", @@ -629,7 +634,7 @@ // Score ctx.save() - ctx.font = "30px " + this.font + ctx.font = "30px TnT, Meiryo, sans-serif" ctx.fillStyle = "#fff" ctx.strokeStyle = "#fff" ctx.lineWidth = 0.3 @@ -763,11 +768,13 @@ }else{ ctx.fillStyle = "#fff" } - ctx.font = fontSize + "px " + this.font + ctx.font = this.draw.bold(this.font) + fontSize + "px " + this.font ctx.lineWidth = 7 * mul ctx.textAlign = "center" - ctx.strokeText("コンボ", comboX, comboTextY) - ctx.fillText("コンボ", comboX, comboTextY) + ctx.miterLimit = 1 + ctx.strokeText(strings.combo, comboX, comboTextY) + ctx.miterLimit = 10 + ctx.fillText(strings.combo, comboX, comboTextY) } // Slot @@ -931,7 +938,7 @@ x: _w / 2, y: 18, width: _w, - height: _h, + height: _h - 54, fontSize: 40, fontFamily: this.font, letterSpacing: -1 @@ -1292,7 +1299,7 @@ var text = circle.getText() var textX = circlePos.x var textY = circlePos.y + 83 * mul - ctx.font = lyricsSize + "px Kozuka" + ctx.font = lyricsSize + "px Kozuka, Microsoft YaHei, sans-serif" ctx.textBaseline = "middle" ctx.textAlign = "center" @@ -1373,7 +1380,7 @@ ctx: ctx, text: i.toString(), fontSize: fontSize, - fontFamily: this.font, + fontFamily: "TnT, Meiryo, sans-serif", x: textX, y: textY }, [ diff --git a/public/src/views/titlescreen.html b/public/src/views/titlescreen.html index 91f0fee..11a5fd4 100644 --- a/public/src/views/titlescreen.html +++ b/public/src/views/titlescreen.html @@ -2,3 +2,6 @@
太鼓の達人ウェブ
+
+ +