From 89bc9c126f563400842f1948bf69807b74cc509f Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Sun, 27 Oct 2024 13:00:39 +0800 Subject: [PATCH] update snapshot notification message --- .../src/main/java/forge/control/FControl.java | 33 ++++++++++--------- .../main/java/forge/view/FTitleBarBase.java | 7 ++-- forge-gui/res/languages/de-DE.properties | 1 + forge-gui/res/languages/en-US.properties | 1 + forge-gui/res/languages/es-ES.properties | 1 + forge-gui/res/languages/fr-FR.properties | 1 + forge-gui/res/languages/it-IT.properties | 1 + forge-gui/res/languages/ja-JP.properties | 1 + forge-gui/res/languages/pt-BR.properties | 1 + forge-gui/res/languages/zh-CN.properties | 1 + 10 files changed, 30 insertions(+), 18 deletions(-) diff --git a/forge-gui-desktop/src/main/java/forge/control/FControl.java b/forge-gui-desktop/src/main/java/forge/control/FControl.java index 3a3d5156a4c..fbd7d496816 100644 --- a/forge-gui-desktop/src/main/java/forge/control/FControl.java +++ b/forge-gui-desktop/src/main/java/forge/control/FControl.java @@ -89,6 +89,7 @@ public enum FControl implements KeyEventDispatcher { private final List currentMatches = Lists.newArrayList(); private String snapsVersion = "", currentVersion = ""; private boolean isSnapshot; + private Localizer localizer; public enum CloseAction { NONE, @@ -96,6 +97,12 @@ public enum FControl implements KeyEventDispatcher { EXIT_FORGE } + public Localizer getLocalizer() { + if (localizer == null) + localizer = Localizer.getInstance(); + return localizer; + } + private boolean hasCurrentMatches() { cleanMatches(); return !currentMatches.isEmpty(); @@ -128,16 +135,15 @@ public enum FControl implements KeyEventDispatcher { * instantiated separately by each screen's top level view class. */ FControl() { - final Localizer localizer = Localizer.getInstance(); Singletons.getView().getFrame().addWindowListener(new WindowAdapter() { @Override public void windowClosing(final WindowEvent e) { switch (closeAction) { case NONE: //prompt user for close action if not previously specified - final List options = ImmutableList.of(localizer.getMessage("lblCloseScreen"), localizer.getMessage("lblExitForge"), localizer.getMessage("lblCancel")); + final List options = ImmutableList.of(getLocalizer().getMessage("lblCloseScreen"), getLocalizer().getMessage("lblExitForge"), getLocalizer().getMessage("lblCancel")); final int reply = FOptionPane.showOptionDialog( - localizer.getMessage("txCloseAction1") + "\n\n" + localizer.getMessage("txCloseAction2"), - localizer.getMessage("titCloseAction"), + getLocalizer().getMessage("txCloseAction1") + "\n\n" + getLocalizer().getMessage("txCloseAction2"), + getLocalizer().getMessage("titCloseAction"), FOptionPane.INFORMATION_ICON, options, 2); @@ -180,14 +186,13 @@ public enum FControl implements KeyEventDispatcher { } public boolean canExitForge(final boolean forRestart) { - final Localizer localizer = Localizer.getInstance(); - final String action = (forRestart ? localizer.getMessage("lblRestart") : localizer.getMessage("lblExit")); - String userPrompt =(forRestart ? localizer.getMessage("lblAreYouSureYouWishRestartForge") : localizer.getMessage("lblAreYouSureYouWishExitForge")); + final String action = (forRestart ? getLocalizer().getMessage("lblRestart") : getLocalizer().getMessage("lblExit")); + String userPrompt =(forRestart ? getLocalizer().getMessage("lblAreYouSureYouWishRestartForge") : getLocalizer().getMessage("lblAreYouSureYouWishExitForge")); final boolean hasCurrentMatches = hasCurrentMatches(); if (hasCurrentMatches) { - userPrompt = localizer.getMessage("lblOneOrMoreGamesActive") + ". " + userPrompt; + userPrompt = getLocalizer().getMessage("lblOneOrMoreGamesActive") + ". " + userPrompt; } - if (!FOptionPane.showConfirmDialog(userPrompt, action + " Forge", action, localizer.getMessage("lblCancel"), !hasCurrentMatches)) { //default Yes if no game active + if (!FOptionPane.showConfirmDialog(userPrompt, action + " Forge", action, getLocalizer().getMessage("lblCancel"), !hasCurrentMatches)) { //default Yes if no game active return false; } return CDeckEditorUI.SINGLETON_INSTANCE.canSwitchAway(true); @@ -238,8 +243,7 @@ public enum FControl implements KeyEventDispatcher { closeAction = CloseAction.valueOf(prefs.getPref(FPref.UI_CLOSE_ACTION)); - final Localizer localizer = Localizer.getInstance(); - FView.SINGLETON_INSTANCE.setSplashProgessBarMessage(localizer.getMessage("lblLoadingQuest")); + FView.SINGLETON_INSTANCE.setSplashProgessBarMessage(getLocalizer().getMessage("lblLoadingQuest")); // Preload quest data if present final File dirQuests = new File(ForgeConstants.QUEST_SAVE_DIR); final String questname = FModel.getQuestPreferences().getPref(QPref.CURRENT_QUEST); @@ -277,7 +281,7 @@ public enum FControl implements KeyEventDispatcher { FView.SINGLETON_INSTANCE.getLpnDocument().addComponentListener(SResizingUtil.getWindowResizeListener()); setGlobalKeyboardHandler(); - FView.SINGLETON_INSTANCE.setSplashProgessBarMessage(localizer.getMessage("lblOpeningMainWindow")); + FView.SINGLETON_INSTANCE.setSplashProgessBarMessage(getLocalizer().getMessage("lblOpeningMainWindow")); SwingUtilities.invokeLater(() -> Singletons.getView().initialize()); } public boolean isSnapshot() { @@ -286,7 +290,7 @@ public enum FControl implements KeyEventDispatcher { public String getSnapshotNotification() { if (!isSnapshot || snapsVersion.isEmpty() || currentVersion.equalsIgnoreCase(snapsVersion)) return ""; - return "NEW SNAPSHOT AVAILABLE!!!"; + return getLocalizer().getMessage("lblNewSnapshotVersion", snapsVersion); } private void setGlobalKeyboardHandler() { @@ -339,8 +343,7 @@ public enum FControl implements KeyEventDispatcher { try { SLayoutIO.loadLayout(null); } catch (final InvalidLayoutFileException ex) { - final Localizer localizer = Localizer.getInstance(); - SOptionPane.showMessageDialog(String.format(localizer.getMessage("lblerrLoadingLayoutFile"), screen.getTabCaption()), "Warning!"); + SOptionPane.showMessageDialog(String.format(getLocalizer().getMessage("lblerrLoadingLayoutFile"), screen.getTabCaption()), "Warning!"); if (screen.deleteLayoutFile()) { SLayoutIO.loadLayout(null); //try again } diff --git a/forge-gui-desktop/src/main/java/forge/view/FTitleBarBase.java b/forge-gui-desktop/src/main/java/forge/view/FTitleBarBase.java index de5446c9037..efae38f2f95 100644 --- a/forge-gui-desktop/src/main/java/forge/view/FTitleBarBase.java +++ b/forge-gui-desktop/src/main/java/forge/view/FTitleBarBase.java @@ -424,8 +424,9 @@ public abstract class FTitleBarBase extends SkinnedMenuBar { } } public class UpdaterButton extends TitleBarButton { - final int MARQUEE_SPEED_DIV = 15; - final int REPAINT_WITHIN_MS = 25; + final int MARQUEE_SPEED_DIV = 50; + final int REPAINT_WITHIN_MS = 50; + final int wMod = 60; final String displayText = FControl.instance.getSnapshotNotification(); public UpdaterButton() { setToolTipText(Localizer.getInstance().getMessage("btnCheckForUpdates")); @@ -442,7 +443,7 @@ public abstract class FTitleBarBase extends SkinnedMenuBar { } @Override public void paintComponent(Graphics g) { - g.translate((int)((System.currentTimeMillis() / MARQUEE_SPEED_DIV) % (getWidth() * 2)) - getWidth(), 0); + g.translate(-((int)((System.currentTimeMillis() / MARQUEE_SPEED_DIV) % ((getWidth() + wMod) * 2)) - (getWidth() + wMod)), 0); super.paintComponent(g); int thickness = 2; Graphics2D g2d = (Graphics2D) g; diff --git a/forge-gui/res/languages/de-DE.properties b/forge-gui/res/languages/de-DE.properties index 42452727b63..d0e59c3ad83 100644 --- a/forge-gui/res/languages/de-DE.properties +++ b/forge-gui/res/languages/de-DE.properties @@ -3440,5 +3440,6 @@ lblRefund=Erstattung lblForgeUpdateMessage=Das Update wurde hier heruntergeladen: {0}.\nForge wird nun beendet und führt den Updater aus. lblRelease=Freigeben lblSnapshot=Schnappschuss +lblNewSnapshotVersion=NEU FORGE-{0}! cbSnapshotUpdate=Überprüfen Sie Snapshot-Updates beim Start. nlSnapshotUpdate=Wenn diese Option aktiviert ist, werden Snapshot-Updates beim Start automatisch überprüft und die Benachrichtigung in der Titelleiste angezeigt. \ No newline at end of file diff --git a/forge-gui/res/languages/en-US.properties b/forge-gui/res/languages/en-US.properties index 71ac0e73045..2976acc4c85 100644 --- a/forge-gui/res/languages/en-US.properties +++ b/forge-gui/res/languages/en-US.properties @@ -3173,5 +3173,6 @@ lblRefund=Refund lblForgeUpdateMessage=Update has been downloaded here: {0}.\nForge will now exit and run the updater. lblRelease=Release lblSnapshot=Snapshot +lblNewSnapshotVersion=NEW FORGE-{0}! cbSnapshotUpdate=Check snapshot updates on startup. nlSnapshotUpdate=When enabled, automatically check snapshot updates on startup and displays the notification on the title bar. \ No newline at end of file diff --git a/forge-gui/res/languages/es-ES.properties b/forge-gui/res/languages/es-ES.properties index 27aa763977f..709599f586e 100644 --- a/forge-gui/res/languages/es-ES.properties +++ b/forge-gui/res/languages/es-ES.properties @@ -3454,5 +3454,6 @@ lblRefund=Reembolso lblForgeUpdateMessage=La actualización se descargó aquí: {0}.\nForge ahora saldrá y ejecutará el actualizador. lblRelease=Liberar lblSnapshot=Instantánea +lblNewSnapshotVersion=NUEVO FORGE-{0}! cbSnapshotUpdate=Verifique las actualizaciones de instantáneas al inicio. nlSnapshotUpdate=Cuando está habilitado, verifica automáticamente las actualizaciones de instantáneas al inicio y muestra la notificación en la barra de título. \ No newline at end of file diff --git a/forge-gui/res/languages/fr-FR.properties b/forge-gui/res/languages/fr-FR.properties index 4449dfa0486..665c8a3433b 100644 --- a/forge-gui/res/languages/fr-FR.properties +++ b/forge-gui/res/languages/fr-FR.properties @@ -3448,5 +3448,6 @@ lblRefund=Remboursement lblForgeUpdateMessage=La mise à jour a été téléchargée ici: {0}.\nForge va maintenant quitter et exécuter le programme de mise à jour. lblRelease=Libérer lblSnapshot=Instantané +lblNewSnapshotVersion=NOUVEAU FORGE–{0}! cbSnapshotUpdate=Vérifiez les mises à jour des instantanés au démarrage. nlSnapshotUpdate=Lorsqu'il est activé, vérifie automatiquement les mises à jour des instantanés au démarrage et affiche la notification sur la barre de titre. \ No newline at end of file diff --git a/forge-gui/res/languages/it-IT.properties b/forge-gui/res/languages/it-IT.properties index 5c413d912e4..23d0b728b7f 100644 --- a/forge-gui/res/languages/it-IT.properties +++ b/forge-gui/res/languages/it-IT.properties @@ -3446,5 +3446,6 @@ lblRefund=Rimborso lblForgeUpdateMessage=L'aggiornamento è stato scaricato qui: {0}.\nForge ora uscirà ed eseguirà l'aggiornamento. lblRelease=Pubblicazione lblSnapshot=Istantanea +lblNewSnapshotVersion=NUOVO FORGE-{0}! cbSnapshotUpdate=Controlla gli aggiornamenti delle istantanee all'avvio. nlSnapshotUpdate=Se abilitato, controlla automaticamente gli aggiornamenti delle istantanee all'avvio e visualizza la notifica sulla barra del titolo. \ No newline at end of file diff --git a/forge-gui/res/languages/ja-JP.properties b/forge-gui/res/languages/ja-JP.properties index bda6324926b..6920b588e0e 100644 --- a/forge-gui/res/languages/ja-JP.properties +++ b/forge-gui/res/languages/ja-JP.properties @@ -3442,5 +3442,6 @@ lblRefund=返金 lblForgeUpdateMessage=アップデートはここにダウンロードされました: {0}。\nForge が終了し、アップデーターが実行されます。 lblRelease=リリース lblSnapshot=スナップショット +lblNewSnapshotVersion=新しい FORGE-{0}! cbSnapshotUpdate=起動時にスナップショットの更新を確認します。 nlSnapshotUpdate=有効にすると、起動時にスナップショットの更新が自動的にチェックされ、タイトル バーに通知が表示されます。 \ No newline at end of file diff --git a/forge-gui/res/languages/pt-BR.properties b/forge-gui/res/languages/pt-BR.properties index ca4f5423007..ee91a34fb19 100644 --- a/forge-gui/res/languages/pt-BR.properties +++ b/forge-gui/res/languages/pt-BR.properties @@ -3532,5 +3532,6 @@ lblRefund=Reembolso lblForgeUpdateMessage=A atualização foi baixada aqui: {0}.\nO Forge agora sairá e executará o atualizador. lblRelease=Liberar lblSnapshot=Instantâneo +lblNewSnapshotVersion=NOVO FORGE-{0}! cbSnapshotUpdate=Verifique as atualizações de instantâneos na inicialização. nlSnapshotUpdate=Quando ativado, verifica automaticamente as atualizações do snapshot na inicialização e exibe a notificação na barra de título. \ No newline at end of file diff --git a/forge-gui/res/languages/zh-CN.properties b/forge-gui/res/languages/zh-CN.properties index 44159ee3ab0..1affbd7a025 100644 --- a/forge-gui/res/languages/zh-CN.properties +++ b/forge-gui/res/languages/zh-CN.properties @@ -3433,5 +3433,6 @@ lblRefund=退款 lblForgeUpdateMessage=更新已在此处下载:{0}。\nForge 现在将退出并运行更新程序。 lblRelease=发布 lblSnapshot=快照 +lblNewSnapshotVersion=新 FORGE-{0}! cbSnapshotUpdate=启动时检查快照更新。 nlSnapshotUpdate=启用后,启动时自动检查快照更新并在标题栏上显示通知。 \ No newline at end of file