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

[Hotfix] Adding warning message for the maintenance #5263

Merged
merged 20 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from 15 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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pokemon-rogue-battle",
"private": true,
"version": "1.5.2",
"version": "1.5.3",
"type": "module",
"scripts": {
"start": "vite",
Expand Down
57 changes: 57 additions & 0 deletions src/ui/title-ui-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { TimedEventDisplay } from "#app/timed-event-manager";
import { version } from "../../package.json";
import { pokerogueApi } from "#app/plugins/api/pokerogue-api";
import { globalScene } from "#app/global-scene";
import { addWindow } from "./ui-theme";

export default class TitleUiHandler extends OptionSelectUiHandler {
/** If the stats can not be retrieved, use this fallback value */
Expand All @@ -19,6 +20,10 @@ export default class TitleUiHandler extends OptionSelectUiHandler {
private splashMessageText: Phaser.GameObjects.Text;
private eventDisplay: TimedEventDisplay;
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;

Expand Down Expand Up @@ -75,6 +80,58 @@ export default class TitleUiHandler extends OptionSelectUiHandler {
this.appVersionText.setOrigin(0.5, 0.5);
this.appVersionText.setAngle(0);
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": // <-- in review
case "zh-CN":
return false; // 24h
}
};
const startDate = new Date(1738994400000);
const endDate = new Date(1739167200000);
const dateOptions: Intl.DateTimeFormatOptions = {
dateStyle: "short",
timeStyle: "short",
sodaMelon marked this conversation as resolved.
Show resolved Hide resolved
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 - German translation goes here:\n${startDateLocalized} until ${endDateLocalized}`,
Wlowscha marked this conversation as resolved.
Show resolved Hide resolved
"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}\nL’heure de fin est une estimation et peut s’avérer plus en avance ou tardive qu’annoncé.`,
"it": ` - INFORMATION - Italian translation goes here:\n${startDateLocalized} until ${endDateLocalized}`,
"pt-BR": ` - INFORMATION - Portugese translation goes here:\n${startDateLocalized} until ${endDateLocalized}`,
"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メンテナンスはこの時期より早く終了する場合も遅く終了する場合もあります。`,
};
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: "78px", wordWrap: { width: 200 * 6 }});
this.announcementText.setOrigin(0, 1);
this.announcementText.setAngle(0);
this.announcementBg = addWindow(this.announcementText.x - 8, this.announcementText.y + 6, this.announcementText.width / 6 + 14, this.announcementText.height / 6 + 12);
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 {
Expand Down