Skip to content

Commit

Permalink
update snapshot notification message
Browse files Browse the repository at this point in the history
  • Loading branch information
kevlahnota committed Oct 27, 2024
1 parent 609777c commit 89bc9c1
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 18 deletions.
33 changes: 18 additions & 15 deletions forge-gui-desktop/src/main/java/forge/control/FControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,20 @@ 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,
CLOSE_SCREEN,
EXIT_FORGE
}

public Localizer getLocalizer() {
if (localizer == null)
localizer = Localizer.getInstance();
return localizer;
}

private boolean hasCurrentMatches() {
cleanMatches();
return !currentMatches.isEmpty();
Expand Down Expand Up @@ -128,16 +135,15 @@ private void cleanMatches() {
* 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);
Expand Down Expand Up @@ -180,14 +186,13 @@ public void setCloseAction(final CloseAction closeAction0) {
}

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);
Expand Down Expand Up @@ -238,8 +243,7 @@ public void initialize() {

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);
Expand Down Expand Up @@ -277,7 +281,7 @@ public void componentMoved(final ComponentEvent e) {
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() {
Expand All @@ -286,7 +290,7 @@ public boolean isSnapshot() {
public String getSnapshotNotification() {
if (!isSnapshot || snapsVersion.isEmpty() || currentVersion.equalsIgnoreCase(snapsVersion))
return "";
return "NEW SNAPSHOT AVAILABLE!!!";
return getLocalizer().getMessage("lblNewSnapshotVersion", snapsVersion);
}

private void setGlobalKeyboardHandler() {
Expand Down Expand Up @@ -339,8 +343,7 @@ public boolean setCurrentScreen(final FScreen screen, final boolean previousScre
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
}
Expand Down
7 changes: 4 additions & 3 deletions forge-gui-desktop/src/main/java/forge/view/FTitleBarBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,9 @@ public void paintComponent(Graphics g) {
}
}
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"));
Expand All @@ -442,7 +443,7 @@ protected void onClick() {
}
@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;
Expand Down
1 change: 1 addition & 0 deletions forge-gui/res/languages/de-DE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 1 addition & 0 deletions forge-gui/res/languages/en-US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 1 addition & 0 deletions forge-gui/res/languages/es-ES.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 1 addition & 0 deletions forge-gui/res/languages/fr-FR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 1 addition & 0 deletions forge-gui/res/languages/it-IT.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 1 addition & 0 deletions forge-gui/res/languages/ja-JP.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3442,5 +3442,6 @@ lblRefund=返金
lblForgeUpdateMessage=アップデートはここにダウンロードされました: {0}。\nForge が終了し、アップデーターが実行されます。
lblRelease=リリース
lblSnapshot=スナップショット
lblNewSnapshotVersion=新しい FORGE-{0}!
cbSnapshotUpdate=起動時にスナップショットの更新を確認します。
nlSnapshotUpdate=有効にすると、起動時にスナップショットの更新が自動的にチェックされ、タイトル バーに通知が表示されます。
1 change: 1 addition & 0 deletions forge-gui/res/languages/pt-BR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 1 addition & 0 deletions forge-gui/res/languages/zh-CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3433,5 +3433,6 @@ lblRefund=退款
lblForgeUpdateMessage=更新已在此处下载:{0}。\nForge 现在将退出并运行更新程序。
lblRelease=发布
lblSnapshot=快照
lblNewSnapshotVersion=新 FORGE-{0}!
cbSnapshotUpdate=启动时检查快照更新。
nlSnapshotUpdate=启用后,启动时自动检查快照更新并在标题栏上显示通知。

0 comments on commit 89bc9c1

Please sign in to comment.