update snapshot notification message

This commit is contained in:
Anthony Calosa
2024-10-27 13:00:39 +08:00
parent 609777cf60
commit 89bc9c126f
10 changed files with 30 additions and 18 deletions

View File

@@ -89,6 +89,7 @@ public enum FControl implements KeyEventDispatcher {
private final List<HostedMatch> 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<String> options = ImmutableList.of(localizer.getMessage("lblCloseScreen"), localizer.getMessage("lblExitForge"), localizer.getMessage("lblCancel"));
final List<String> 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
}

View File

@@ -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;

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -3442,5 +3442,6 @@ lblRefund=返金
lblForgeUpdateMessage=アップデートはここにダウンロードされました: {0}。\nForge が終了し、アップデーターが実行されます。
lblRelease=リリース
lblSnapshot=スナップショット
lblNewSnapshotVersion=新しい FORGE-{0}!
cbSnapshotUpdate=起動時にスナップショットの更新を確認します。
nlSnapshotUpdate=有効にすると、起動時にスナップショットの更新が自動的にチェックされ、タイトル バーに通知が表示されます。

View File

@@ -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.

View File

@@ -3433,5 +3433,6 @@ lblRefund=退款
lblForgeUpdateMessage=更新已在此处下载:{0}。\nForge 现在将退出并运行更新程序。
lblRelease=发布
lblSnapshot=快照
lblNewSnapshotVersion=新 FORGE-{0}!
cbSnapshotUpdate=启动时检查快照更新。
nlSnapshotUpdate=启用后,启动时自动检查快照更新并在标题栏上显示通知。