From b5fc217cb5aa6cc45e70d827f1771191ffa2ad5c Mon Sep 17 00:00:00 2001 From: Viet Dinh <54ckb0y789@gmail.com> Date: Thu, 5 Dec 2024 15:48:32 -0500 Subject: [PATCH 1/3] Add i18n key for ranking player header Closes #602 --- index.php | 2 +- lang/ar.json | 3 ++- lang/de.json | 3 ++- lang/en.json | 3 ++- lang/eo.json | 3 ++- lang/es.json | 3 ++- lang/fr.json | 3 ++- lang/it.json | 3 ++- lang/ja.json | 3 ++- lang/ko.json | 3 ++- lang/pl.json | 3 ++- lang/pt.json | 3 ++- lang/ro.json | 3 ++- lang/ru.json | 3 ++- lang/tr.json | 3 ++- lang/vi.json | 3 ++- lang/zh.json | 3 ++- 17 files changed, 33 insertions(+), 17 deletions(-) diff --git a/index.php b/index.php index 41afe96f..3a6a2049 100644 --- a/index.php +++ b/index.php @@ -1249,7 +1249,7 @@ class="joystickBase" /> # - Player + Player diff --git a/lang/ar.json b/lang/ar.json index b1438d2a..1976d0b6 100644 --- a/lang/ar.json +++ b/lang/ar.json @@ -432,7 +432,8 @@ } }, "rankings": { - "title": "المراتب" + "title": "المراتب", + "player": "Player" }, "screenshot": { "title": "صور الشاشة", diff --git a/lang/de.json b/lang/de.json index 24e988ff..f831f44d 100644 --- a/lang/de.json +++ b/lang/de.json @@ -432,7 +432,8 @@ } }, "rankings": { - "title": "Rankings" + "title": "Rankings", + "player": "Player" }, "screenshot": { "title": "Your Screenshot", diff --git a/lang/en.json b/lang/en.json index bc2c0676..198af21a 100644 --- a/lang/en.json +++ b/lang/en.json @@ -432,7 +432,8 @@ } }, "rankings": { - "title": "Rankings" + "title": "Rankings", + "player": "Player" }, "screenshot": { "title": "Your Screenshot", diff --git a/lang/eo.json b/lang/eo.json index 668ad877..6911f5af 100644 --- a/lang/eo.json +++ b/lang/eo.json @@ -431,7 +431,8 @@ } }, "rankings": { - "title": "Rangolisto" + "title": "Rangolisto", + "player": "Player" }, "screenshot": { "title": "Via Ekrankopio", diff --git a/lang/es.json b/lang/es.json index 90bdf217..b60f1bfc 100644 --- a/lang/es.json +++ b/lang/es.json @@ -432,7 +432,8 @@ } }, "rankings": { - "title": "Clasificaciones" + "title": "Clasificaciones", + "player": "Player" }, "screenshot": { "title": "Your Screenshot", diff --git a/lang/fr.json b/lang/fr.json index 59123c77..514c64ee 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -432,7 +432,8 @@ } }, "rankings": { - "title": "Classement" + "title": "Classement", + "player": "Player" }, "screenshot": { "title": "Votre capture d'écran", diff --git a/lang/it.json b/lang/it.json index 9bfcfcf6..098b13b5 100644 --- a/lang/it.json +++ b/lang/it.json @@ -432,7 +432,8 @@ } }, "rankings": { - "title": "Classifiche" + "title": "Classifiche", + "player": "Player" }, "screenshot": { "title": "Your Screenshot", diff --git a/lang/ja.json b/lang/ja.json index 484d03b5..6cb0a2b8 100644 --- a/lang/ja.json +++ b/lang/ja.json @@ -432,7 +432,8 @@ } }, "rankings": { - "title": "ランキング" + "title": "ランキング", + "player": "Player" }, "screenshot": { "title": "スクリーンショット", diff --git a/lang/ko.json b/lang/ko.json index 3398c104..6b0e1a22 100644 --- a/lang/ko.json +++ b/lang/ko.json @@ -432,7 +432,8 @@ } }, "rankings": { - "title": "랭킹" + "title": "랭킹", + "player": "Player" }, "screenshot": { "title": "나의 스크린샷", diff --git a/lang/pl.json b/lang/pl.json index 3a41bc19..a272f9e4 100644 --- a/lang/pl.json +++ b/lang/pl.json @@ -432,7 +432,8 @@ } }, "rankings": { - "title": "Rankingi" + "title": "Rankingi", + "player": "Player" }, "screenshot": { "title": "Twój zrzut ekranu", diff --git a/lang/pt.json b/lang/pt.json index 40b5b253..360afc70 100644 --- a/lang/pt.json +++ b/lang/pt.json @@ -432,7 +432,8 @@ } }, "rankings": { - "title": "Placares" + "title": "Placares", + "player": "Player" }, "screenshot": { "title": "Suas Capturas de Tela", diff --git a/lang/ro.json b/lang/ro.json index 94cb4e6b..d6c70c2b 100644 --- a/lang/ro.json +++ b/lang/ro.json @@ -432,7 +432,8 @@ } }, "rankings": { - "title": "Ranguri" + "title": "Ranguri", + "player": "Player" }, "screenshot": { "title": "Your Screenshot", diff --git a/lang/ru.json b/lang/ru.json index 2a75d5bd..c6c23e7b 100644 --- a/lang/ru.json +++ b/lang/ru.json @@ -432,7 +432,8 @@ } }, "rankings": { - "title": "Рейтинги" + "title": "Рейтинги", + "player": "Player" }, "screenshot": { "title": "Ваш снимок", diff --git a/lang/tr.json b/lang/tr.json index d2bd6115..1111d4a8 100644 --- a/lang/tr.json +++ b/lang/tr.json @@ -432,7 +432,8 @@ } }, "rankings": { - "title": "Sıralamalar" + "title": "Sıralamalar", + "player": "Player" }, "screenshot": { "title": "Ekran Görüntünüz", diff --git a/lang/vi.json b/lang/vi.json index 5f5ce818..9c02c2da 100644 --- a/lang/vi.json +++ b/lang/vi.json @@ -432,7 +432,8 @@ } }, "rankings": { - "title": "Bảng Xếp Hạng" + "title": "Bảng Xếp Hạng", + "player": "Player" }, "screenshot": { "title": "Ảnh chụp màn hình của bạn", diff --git a/lang/zh.json b/lang/zh.json index da476591..7463d232 100644 --- a/lang/zh.json +++ b/lang/zh.json @@ -432,7 +432,8 @@ } }, "rankings": { - "title": "排行榜" + "title": "排行榜", + "player": "Player" }, "screenshot": { "title": "屏幕截图", From 136f176633aa743371d899165bf8223441d728d3 Mon Sep 17 00:00:00 2001 From: Viet Dinh <54ckb0y789@gmail.com> Date: Thu, 5 Dec 2024 16:14:44 -0500 Subject: [PATCH 2/3] Fix styling for screenshot spoiler links Closes #586 --- play.css | 2 +- play.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/play.css b/play.css index e627f486..f09a99b7 100644 --- a/play.css +++ b/play.css @@ -251,7 +251,7 @@ body { -webkit-text-fill-color: transparent; } -.spoiler:not(.show) a { +.spoiler:not(.show):not(.screenshotItem:hover) a { opacity: 0; pointer-events: none; } diff --git a/play.js b/play.js index b7ac05b1..ad077c26 100644 --- a/play.js +++ b/play.js @@ -2456,8 +2456,10 @@ function openWikiModal(url, asImg) { wikiFrame.addEventListener('load', () => removeLoader(wikiModal), { once: true }); } } - if (wikiModal.classList.contains('hidden')) - openModal('wikiModal'); + if (wikiModal.classList.contains('hidden')) { + const activeModal = document.querySelector('#modalContainer .modal:not(.hidden)'); + openModal('wikiModal', undefined, activeModal?.id); + } } function checkShowVersionUpdate() { From d5d126d5159be16590640ea4a752c595181111db Mon Sep 17 00:00:00 2001 From: Viet Dinh <54ckb0y789@gmail.com> Date: Thu, 5 Dec 2024 19:10:43 -0500 Subject: [PATCH 3/3] Fix preinit language setting Closes #414, #510 --- init.js | 6 +++++- play.js | 23 ++++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/init.js b/init.js index cd8aca53..64830652 100644 --- a/init.js +++ b/init.js @@ -68,6 +68,8 @@ const apiUrl = `${serverUrl}/api`; const adminApiUrl = `${serverUrl}/admin`; const ynomojiUrlPrefix = 'images/ynomoji/'; +let initBlocker = Promise.resolve(); + async function injectScripts() { const supportsSimd = await wasmFeatureDetect.simd(); @@ -89,7 +91,7 @@ async function injectScripts() { const script = scripts[index]; const loadFunc = index < scripts.length - 1 ? () => injectScript(index + 1) - : () => { // Assumes last script is index.js + : async () => { // Assumes last script is index.js if (typeof ENV !== 'undefined') ENV.SDL_EMSCRIPTEN_KEYBOARD_ELEMENT = '#canvas'; @@ -118,6 +120,8 @@ async function injectScripts() { if (typeof onResize !== 'undefined') easyrpgPlayerLoadFuncs.push(onResize); + await initBlocker; + createEasyRpgPlayer(easyrpgPlayer) .then(function(Module) { // Module is ready diff --git a/play.js b/play.js index ad077c26..dc605d45 100644 --- a/play.js +++ b/play.js @@ -1637,6 +1637,17 @@ document.onmousemove = function (ev) { } }; +async function withTimeout(duration, prom) { + let handle; + const timeout = new Promise(resolve => handle = setTimeout(() => resolve('__timeout__'), duration)); + const res = await Promise.race([timeout, prom]); + if (res === '__timeout__') { + console.warn(`timed out after ${duration} ms`, prom); + } + clearTimeout(handle); + return res; +} + const rtlLangs = ['ar']; function setLang(lang, isInit) { if (rtlLangs.includes(lang)) @@ -1644,11 +1655,13 @@ function setLang(lang, isInit) { else document.documentElement.removeAttribute('dir'); globalConfig.lang = lang; - fetchNewest(`../data/${gameId}/Language/${lang}/meta.ini`).then(response => { // Prevent a crash when the --language argument is used and the game doesn't have a Language folder - if (response.ok && response.status < 400 && isInit && gameIds.indexOf(gameId) > -1) { - easyrpgPlayer.language = (gameDefaultLangs.hasOwnProperty(gameId) ? gameDefaultLangs[gameId] !== lang : lang !== 'en') ? lang : 'default'; - } - }); + initBlocker = initBlocker.then(() => withTimeout(500, // TODO Is this enough? + fetchNewest(`../data/${gameId}/Language/${lang}/meta.ini`).then(response => { // Prevent a crash when the --language argument is used and the game doesn't have a Language folder + if (response.ok && response.status < 400 && isInit && gameIds.indexOf(gameId) > -1) { + easyrpgPlayer.language = (gameDefaultLangs.hasOwnProperty(gameId) ? gameDefaultLangs[gameId] !== lang : lang !== 'en') ? lang : 'default'; + } + }) + )); initLocalization(isInit); if (!isInit) updateConfig(globalConfig, true);