Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Housecleaning #606

Merged
merged 3 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ class="joystickBase" />
<thead>
<tr>
<th>#</th>
<th>Player</th>
<th data-i18n="[html]modal.rankings.player">Player</th>
<th id="rankingValueHeader"></th>
</tr>
</thead>
Expand Down
6 changes: 5 additions & 1 deletion init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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';

Expand Down Expand Up @@ -118,6 +120,8 @@ async function injectScripts() {
if (typeof onResize !== 'undefined')
easyrpgPlayerLoadFuncs.push(onResize);

await initBlocker;

createEasyRpgPlayer(easyrpgPlayer)
.then(function(Module) {
// Module is ready
Expand Down
3 changes: 2 additions & 1 deletion lang/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@
}
},
"rankings": {
"title": "المراتب"
"title": "المراتب",
"player": "Player"
},
"screenshot": {
"title": "صور الشاشة",
Expand Down
3 changes: 2 additions & 1 deletion lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@
}
},
"rankings": {
"title": "Rankings"
"title": "Rankings",
"player": "Player"
},
"screenshot": {
"title": "Your Screenshot",
Expand Down
3 changes: 2 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@
}
},
"rankings": {
"title": "Rankings"
"title": "Rankings",
"player": "Player"
},
"screenshot": {
"title": "Your Screenshot",
Expand Down
3 changes: 2 additions & 1 deletion lang/eo.json
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,8 @@
}
},
"rankings": {
"title": "Rangolisto"
"title": "Rangolisto",
"player": "Player"
},
"screenshot": {
"title": "Via Ekrankopio",
Expand Down
3 changes: 2 additions & 1 deletion lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@
}
},
"rankings": {
"title": "Clasificaciones"
"title": "Clasificaciones",
"player": "Player"
},
"screenshot": {
"title": "Your Screenshot",
Expand Down
3 changes: 2 additions & 1 deletion lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@
}
},
"rankings": {
"title": "Classement"
"title": "Classement",
"player": "Player"
},
"screenshot": {
"title": "Votre capture d'écran",
Expand Down
3 changes: 2 additions & 1 deletion lang/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@
}
},
"rankings": {
"title": "Classifiche"
"title": "Classifiche",
"player": "Player"
},
"screenshot": {
"title": "Your Screenshot",
Expand Down
3 changes: 2 additions & 1 deletion lang/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@
}
},
"rankings": {
"title": "ランキング"
"title": "ランキング",
"player": "Player"
},
"screenshot": {
"title": "スクリーンショット",
Expand Down
3 changes: 2 additions & 1 deletion lang/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@
}
},
"rankings": {
"title": "랭킹"
"title": "랭킹",
"player": "Player"
},
"screenshot": {
"title": "나의 스크린샷",
Expand Down
3 changes: 2 additions & 1 deletion lang/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@
}
},
"rankings": {
"title": "Rankingi"
"title": "Rankingi",
"player": "Player"
},
"screenshot": {
"title": "Twój zrzut ekranu",
Expand Down
3 changes: 2 additions & 1 deletion lang/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@
}
},
"rankings": {
"title": "Placares"
"title": "Placares",
"player": "Player"
},
"screenshot": {
"title": "Suas Capturas de Tela",
Expand Down
3 changes: 2 additions & 1 deletion lang/ro.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@
}
},
"rankings": {
"title": "Ranguri"
"title": "Ranguri",
"player": "Player"
},
"screenshot": {
"title": "Your Screenshot",
Expand Down
3 changes: 2 additions & 1 deletion lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@
}
},
"rankings": {
"title": "Рейтинги"
"title": "Рейтинги",
"player": "Player"
},
"screenshot": {
"title": "Ваш снимок",
Expand Down
3 changes: 2 additions & 1 deletion lang/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@
}
},
"rankings": {
"title": "Sıralamalar"
"title": "Sıralamalar",
"player": "Player"
},
"screenshot": {
"title": "Ekran Görüntünüz",
Expand Down
3 changes: 2 additions & 1 deletion lang/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion lang/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@
}
},
"rankings": {
"title": "排行榜"
"title": "排行榜",
"player": "Player"
},
"screenshot": {
"title": "屏幕截图",
Expand Down
2 changes: 1 addition & 1 deletion play.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
29 changes: 22 additions & 7 deletions play.js
Original file line number Diff line number Diff line change
Expand Up @@ -1637,18 +1637,31 @@ 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))
document.documentElement.setAttribute('dir', 'rtl');
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);
Expand Down Expand Up @@ -2456,8 +2469,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() {
Expand Down