[Hotfix] Adding warning message for the maintenance (#5263)

* Adding warning message for the maintenance; needs localization

* Update src/ui/title-ui-handler.ts

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

* Update language codes

* Add French translation

Co-authored-by: Lugiad <2070109+Adri1@users.noreply.github.com>

* Fix variable typo in French translation

* Add `zh-CN`

Co-authored-by: Lugiad' <2070109+Adri1@users.noreply.github.com>

* Add `zh-TW`

Co-authored-by: Lugiad' <2070109+Adri1@users.noreply.github.com>

* Add `ja`

Co-authored-by: Lugiad' <2070109+Adri1@users.noreply.github.com>

* Add `es-ES`

Co-authored-by: Lugiad' <2070109+Adri1@users.noreply.github.com>

* Improve date localization

* Specify 12h/24h time format for each language

* Mark the temporary announcement code with comments

* Add `ko`

Co-authored-by: sodam <66295123+sodaMelon@users.noreply.github.com>

* Move announcement box 10 pixels to the left

* Update korean translation

Co-authored-by: sodam <66295123+sodaMelon@users.noreply.github.com>

* Added German translation

Co-authored-by: Lugiad' <2070109+Adri1@users.noreply.github.com>

* Removed some useless spaces in maintenance message

* Reduced announcement font size by 2 px

* Adding italian, fixing japanese

* Use English message as placeholder for pt-BR for now

---------

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
Co-authored-by: Lugiad <2070109+Adri1@users.noreply.github.com>
Co-authored-by: sodam <66295123+sodaMelon@users.noreply.github.com>
This commit is contained in:
Wlowscha 2025-02-07 05:17:36 +01:00 committed by GitHub
parent 8d20b7b5e0
commit c88c9337dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 61 additions and 3 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "pokemon-rogue-battle", "name": "pokemon-rogue-battle",
"version": "1.5.2", "version": "1.5.3",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "pokemon-rogue-battle", "name": "pokemon-rogue-battle",
"version": "1.5.2", "version": "1.5.3",
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"@material/material-color-utilities": "^0.2.7", "@material/material-color-utilities": "^0.2.7",

View File

@ -1,7 +1,7 @@
{ {
"name": "pokemon-rogue-battle", "name": "pokemon-rogue-battle",
"private": true, "private": true,
"version": "1.5.2", "version": "1.5.3",
"type": "module", "type": "module",
"scripts": { "scripts": {
"start": "vite", "start": "vite",

View File

@ -8,6 +8,7 @@ import { TimedEventDisplay } from "#app/timed-event-manager";
import { version } from "../../package.json"; import { version } from "../../package.json";
import { pokerogueApi } from "#app/plugins/api/pokerogue-api"; import { pokerogueApi } from "#app/plugins/api/pokerogue-api";
import { globalScene } from "#app/global-scene"; import { globalScene } from "#app/global-scene";
import { addWindow } from "./ui-theme";
export default class TitleUiHandler extends OptionSelectUiHandler { export default class TitleUiHandler extends OptionSelectUiHandler {
/** If the stats can not be retrieved, use this fallback value */ /** If the stats can not be retrieved, use this fallback value */
@ -19,6 +20,10 @@ export default class TitleUiHandler extends OptionSelectUiHandler {
private splashMessageText: Phaser.GameObjects.Text; private splashMessageText: Phaser.GameObjects.Text;
private eventDisplay: TimedEventDisplay; private eventDisplay: TimedEventDisplay;
private appVersionText: Phaser.GameObjects.Text; private appVersionText: Phaser.GameObjects.Text;
// -- start temporary maintenance announcement fields --
private announcementText: Phaser.GameObjects.Text;
private announcementBg: Phaser.GameObjects.NineSlice;
// -- end temporary maintenance announcement fields --
private titleStatsTimer: NodeJS.Timeout | null; private titleStatsTimer: NodeJS.Timeout | null;
@ -75,6 +80,59 @@ export default class TitleUiHandler extends OptionSelectUiHandler {
this.appVersionText.setOrigin(0.5, 0.5); this.appVersionText.setOrigin(0.5, 0.5);
this.appVersionText.setAngle(0); this.appVersionText.setAngle(0);
this.titleContainer.add(this.appVersionText); this.titleContainer.add(this.appVersionText);
// #region Temporary Maintenance Announcement
const currentLanguage = i18next.resolvedLanguage ?? "en";
const getTimeFormat = (): boolean => {
switch (currentLanguage) {
case "en":
case "es-ES":
case "ko":
case "zh-TW":
default:
return true; // 12h
case "de":
case "fr":
case "it":
case "ja":
case "pt-BR":
case "zh-CN":
return false; // 24h
}
};
const startDate = new Date(1738994400000);
const endDate = new Date(1739167200000);
const dateOptions: Intl.DateTimeFormatOptions = {
dateStyle: "short",
timeStyle: "short",
hour12: getTimeFormat(),
};
const startDateLocalized = new Intl.DateTimeFormat(currentLanguage, dateOptions).format(startDate);
const endDateLocalized = new Intl.DateTimeFormat(currentLanguage, dateOptions).format(endDate);
const localizedAnnouncementString: { [key: string]: string } = {
"en": ` - INFORMATION -\nServer maintenance is scheduled for the following period:\n${startDateLocalized} until ${endDateLocalized}\nEnd date and hour are an estimate.\nMaintenance may end at an earlier or later time.`,
"de": `- INFORMATION -\nServerwartung ist für den folgenden Zeitraum geplant:\n${startDateLocalized} bis ${endDateLocalized}\nEnddatum und Uhrzeit sind eine Schätzung.\nDie Wartung kann früher oder später beendet werden.`,
"es-ES": ` - INFORMACIÓN -\nUn mantenimiento del servidor está programado para el siguiente período:\nDesde el ${startDateLocalized} hasta el ${endDateLocalized}.\nLa fecha y hora de finalización son aproximadas.\nEl mantenimiento podría finalizar antes o extenderse más de lo previsto.`,
"fr": ` - INFORMATION -\nUne maintenance du serveur est prévue sur la période suivante :\nDu ${startDateLocalized} au ${endDateLocalized}\nLheure de fin est une estimation et peut savérer plus en avance ou tardive quannoncé.`,
"it": ` - ANNUNCIO -\nUna manutenzione del server avrà luogo nel periodo seguente:\nDal ${startDateLocalized} al ${endDateLocalized}\nData e ora di fine manutenzione sono una stima,\npotrebbe terminare in anticipo o più tardi.`,
"pt-BR": ` - INFORMATION -\nServer maintenance is scheduled for the following period:\n${startDateLocalized} until ${endDateLocalized}\nEnd date and hour are an estimate.\nMaintenance may end at an earlier or later time.`,
"zh-TW": ` - 通知 -\n伺服器預計在以下時間維護\n${startDateLocalized}${endDateLocalized}\n維護結束時間是預計時間\n維護可能稍早或稍晚結束。`,
"zh-CN": ` - 通知 -\n服务器预计在以下时间维护\n${startDateLocalized}${endDateLocalized}\n维护结束时间是预计时间\n维护可能稍早或稍晚结束。`,
"ko": ` - 공지사항 -\n아래 기간동안 점검 예정입니다. :\n${startDateLocalized} ~ ${endDateLocalized}\n종료시각은 예상시간입니다.\n점검은 예상했던 것보다 빠르게 혹은 늦게 끝날 수 있습니다.`,
"ja": ` - 情報 -\nサーバーメンテナンスの予定は以下の期間:\n${startDateLocalized} から ${endDateLocalized} まで\n終了日・時間は推定です。\nメンテナンスはこの時期より早く終了する場合も\n遅く終了する場合もあります。`,
};
const announcementString = localizedAnnouncementString[Object.keys(localizedAnnouncementString).find(lang => currentLanguage.includes(lang)) ?? "en"];
this.announcementText = addTextObject(logo.x - 148, logo.y + logo.displayHeight + 116, announcementString, TextStyle.MONEY, { fontSize: "76px", wordWrap: { width: 200 * 6 }});
this.announcementText.setOrigin(0, 1);
this.announcementText.setAngle(0);
const heightOffset = currentLanguage === "ja" ? -2 : 12;
this.announcementBg = addWindow(this.announcementText.x - 8, this.announcementText.y + 6, this.announcementText.width / 6 + 14, this.announcementText.height / 6 + heightOffset);
this.announcementBg.setName("announcement-bg");
this.announcementBg.setOrigin(0, 1);
this.titleContainer.add(this.announcementText);
this.titleContainer.add(this.announcementBg);
this.titleContainer.bringToTop(this.announcementText);
// #endregion
} }
updateTitleStats(): void { updateTitleStats(): void {