filter commit messages

This commit is contained in:
Anthony Calosa
2024-10-28 12:34:48 +08:00
parent 0bac8ea04d
commit 750d41a2d3
4 changed files with 81 additions and 50 deletions

View File

@@ -90,7 +90,7 @@ public enum FControl implements KeyEventDispatcher {
private CloseAction closeAction; private CloseAction closeAction;
private final List<HostedMatch> currentMatches = Lists.newArrayList(); private final List<HostedMatch> currentMatches = Lists.newArrayList();
private String snapsVersion = "", currentVersion = ""; private String snapsVersion = "", currentVersion = "";
private Date snapsTimestamp = null; private Date snapsTimestamp = null, buildTimeStamp = null;
private boolean isSnapshot, hasSnapsUpdate; private boolean isSnapshot, hasSnapsUpdate;
private Localizer localizer; private Localizer localizer;
@@ -165,7 +165,9 @@ public enum FControl implements KeyEventDispatcher {
Singletons.getView().getNavigationBar().closeSelectedTab(); Singletons.getView().getNavigationBar().closeSelectedTab();
break; break;
case EXIT_FORGE: case EXIT_FORGE:
if (exitForge()) { return; } if (exitForge()) {
return;
}
break; break;
} }
//prevent closing Forge if we reached this point //prevent closing Forge if we reached this point
@@ -174,12 +176,22 @@ public enum FControl implements KeyEventDispatcher {
}); });
} }
public Date getBuildTimeStamp() {
return buildTimeStamp;
}
public Date getSnapsTimestamp() {
return snapsTimestamp;
}
public CloseAction getCloseAction() { public CloseAction getCloseAction() {
return closeAction; return closeAction;
} }
public void setCloseAction(final CloseAction closeAction0) { public void setCloseAction(final CloseAction closeAction0) {
if (closeAction == closeAction0) { return; } if (closeAction == closeAction0) {
return;
}
closeAction = closeAction0; closeAction = closeAction0;
Singletons.getView().getNavigationBar().updateBtnCloseTooltip(); Singletons.getView().getNavigationBar().updateBtnCloseTooltip();
@@ -222,7 +234,9 @@ public enum FControl implements KeyEventDispatcher {
return true; return true;
} }
/** After view and model have been initialized, control can start.*/ /**
* After view and model have been initialized, control can start.
*/
public void initialize() { public void initialize() {
final ForgePreferences prefs = FModel.getPreferences(); final ForgePreferences prefs = FModel.getPreferences();
currentVersion = BuildInfo.getVersionString(); currentVersion = BuildInfo.getVersionString();
@@ -235,10 +249,12 @@ public enum FControl implements KeyEventDispatcher {
url = new URL("https://downloads.cardforge.org/dailysnapshots/build.txt"); url = new URL("https://downloads.cardforge.org/dailysnapshots/build.txt");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
snapsTimestamp = simpleDateFormat.parse(FileUtil.readFileToString(url)); snapsTimestamp = simpleDateFormat.parse(FileUtil.readFileToString(url));
buildTimeStamp = BuildInfo.getTimestamp();
hasSnapsUpdate = BuildInfo.verifyTimestamp(snapsTimestamp); hasSnapsUpdate = BuildInfo.verifyTimestamp(snapsTimestamp);
} }
} catch (Exception ignored) {} } catch (Exception ignored) {
}
// Preloads skin components (using progress bar). // Preloads skin components (using progress bar).
FSkin.loadFull(true); FSkin.loadFull(true);
@@ -266,7 +282,8 @@ public enum FControl implements KeyEventDispatcher {
// format release notes upon loading // format release notes upon loading
try { try {
TextUtil.getFormattedChangelog(new File(FileUtil.pathCombine(System.getProperty("user.dir"), ForgeConstants.CHANGES_FILE_NO_RELEASE)), ""); TextUtil.getFormattedChangelog(new File(FileUtil.pathCombine(System.getProperty("user.dir"), ForgeConstants.CHANGES_FILE_NO_RELEASE)), "");
} catch (Exception e){} } catch (Exception e) {
}
// Handles resizing in null layouts of layers in JLayeredPane as well as saving window layout // Handles resizing in null layouts of layers in JLayeredPane as well as saving window layout
final FFrame window = Singletons.getView().getFrame(); final FFrame window = Singletons.getView().getFrame();
window.addComponentListener(new ComponentAdapter() { window.addComponentListener(new ComponentAdapter() {
@@ -291,9 +308,11 @@ public enum FControl implements KeyEventDispatcher {
FView.SINGLETON_INSTANCE.setSplashProgessBarMessage(getLocalizer().getMessage("lblOpeningMainWindow")); FView.SINGLETON_INSTANCE.setSplashProgessBarMessage(getLocalizer().getMessage("lblOpeningMainWindow"));
SwingUtilities.invokeLater(() -> Singletons.getView().initialize()); SwingUtilities.invokeLater(() -> Singletons.getView().initialize());
} }
public boolean isSnapshot() { public boolean isSnapshot() {
return isSnapshot; return isSnapshot;
} }
public String getSnapshotNotification() { public String getSnapshotNotification() {
if (!isSnapshot || !hasSnapsUpdate || snapsVersion.isEmpty()) if (!isSnapshot || !hasSnapsUpdate || snapsVersion.isEmpty())
return ""; return "";
@@ -322,6 +341,7 @@ public enum FControl implements KeyEventDispatcher {
public boolean setCurrentScreen(final FScreen screen) { public boolean setCurrentScreen(final FScreen screen) {
return setCurrentScreen(screen, false); return setCurrentScreen(screen, false);
} }
public boolean setCurrentScreen(final FScreen screen, final boolean previousScreenClosed) { public boolean setCurrentScreen(final FScreen screen, final boolean previousScreenClosed) {
//TODO: Uncomment the line below if this function stops being used to refresh //TODO: Uncomment the line below if this function stops being used to refresh
//the current screen in some places (such as Continue and Restart in the match screen) //the current screen in some places (such as Continue and Restart in the match screen)
@@ -386,12 +406,16 @@ public enum FControl implements KeyEventDispatcher {
} }
public boolean ensureScreenActive(final FScreen screen) { public boolean ensureScreenActive(final FScreen screen) {
if (currentScreen == screen) { return true; } if (currentScreen == screen) {
return true;
}
return setCurrentScreen(screen); return setCurrentScreen(screen);
} }
/** Remove all children from a specified layer. */ /**
* Remove all children from a specified layer.
*/
private void clearChildren(final int layer0) { private void clearChildren(final int layer0) {
final Component[] children = FView.SINGLETON_INSTANCE.getLpnDocument().getComponentsInLayer(layer0); final Component[] children = FView.SINGLETON_INSTANCE.getLpnDocument().getComponentsInLayer(layer0);
@@ -400,16 +424,24 @@ public enum FControl implements KeyEventDispatcher {
} }
} }
/** Sizes children of JLayeredPane to fully fit their layers. */ /**
* Sizes children of JLayeredPane to fully fit their layers.
*/
private void sizeChildren() { private void sizeChildren() {
Component[] children = display.getComponentsInLayer(JLayeredPane.DEFAULT_LAYER); Component[] children = display.getComponentsInLayer(JLayeredPane.DEFAULT_LAYER);
if (children.length != 0) { children[0].setSize(display.getSize()); } if (children.length != 0) {
children[0].setSize(display.getSize());
}
children = display.getComponentsInLayer(FView.TARGETING_LAYER); children = display.getComponentsInLayer(FView.TARGETING_LAYER);
if (children.length != 0) { children[0].setSize(display.getSize()); } if (children.length != 0) {
children[0].setSize(display.getSize());
}
children = display.getComponentsInLayer(JLayeredPane.MODAL_LAYER); children = display.getComponentsInLayer(JLayeredPane.MODAL_LAYER);
if (children.length != 0) { children[0].setSize(display.getSize()); } if (children.length != 0) {
children[0].setSize(display.getSize());
}
} }
public Dimension getDisplaySize() { public Dimension getDisplaySize() {
@@ -428,18 +460,15 @@ public enum FControl implements KeyEventDispatcher {
forgeMenu.show(true); forgeMenu.show(true);
return true; return true;
} }
} } else if (e.getID() == KeyEvent.KEY_PRESSED && e.getModifiersEx() == InputEvent.ALT_DOWN_MASK) {
else if (e.getID() == KeyEvent.KEY_PRESSED && e.getModifiersEx() == InputEvent.ALT_DOWN_MASK) {
altKeyLastDown = true; altKeyLastDown = true;
} }
} } else {
else {
altKeyLastDown = false; altKeyLastDown = false;
if (e.getID() == KeyEvent.KEY_PRESSED) { if (e.getID() == KeyEvent.KEY_PRESSED) {
//give Forge menu the chance to handle the key event //give Forge menu the chance to handle the key event
return forgeMenu.handleKeyEvent(e); return forgeMenu.handleKeyEvent(e);
} } else if (e.getID() == KeyEvent.KEY_RELEASED) {
else if (e.getID() == KeyEvent.KEY_RELEASED) {
if (e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU) { if (e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU) {
forgeMenu.show(); forgeMenu.show();
} }

View File

@@ -2,6 +2,7 @@ package forge.screens.home.settings;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import forge.control.FControl;
import forge.download.AutoUpdater; import forge.download.AutoUpdater;
import forge.download.GuiDownloader; import forge.download.GuiDownloader;
import forge.gui.ImportDialog; import forge.gui.ImportDialog;
@@ -32,7 +33,7 @@ public enum CSubmenuDownloaders implements ICDoc {
SINGLETON_INSTANCE; SINGLETON_INSTANCE;
private final UiCommand cmdLicensing = VSubmenuDownloaders.SINGLETON_INSTANCE::showLicensing; private final UiCommand cmdLicensing = VSubmenuDownloaders.SINGLETON_INSTANCE::showLicensing;
private final UiCommand cmdCheckForUpdates = () -> new AutoUpdater(false).attemptToUpdate(CompletableFuture.supplyAsync(() -> RSSReader.getCommitLog(GITHUB_COMMITS_URL_ATOM, null, null))); private final UiCommand cmdCheckForUpdates = () -> new AutoUpdater(false).attemptToUpdate(CompletableFuture.supplyAsync(() -> RSSReader.getCommitLog(GITHUB_COMMITS_URL_ATOM, FControl.instance.getBuildTimeStamp(), FControl.instance.getSnapsTimestamp())));
private final UiCommand cmdPicDownload = () -> new GuiDownloader(new GuiDownloadPicturesLQ()).show(); private final UiCommand cmdPicDownload = () -> new GuiDownloader(new GuiDownloadPicturesLQ()).show();
private final UiCommand cmdPicDownloadHQ = () -> new GuiDownloader(new GuiDownloadPicturesHQ()).show(); private final UiCommand cmdPicDownloadHQ = () -> new GuiDownloader(new GuiDownloadPicturesHQ()).show();

View File

@@ -438,7 +438,7 @@ public abstract class FTitleBarBase extends SkinnedMenuBar {
protected void onClick() { protected void onClick() {
if (!displayText.isEmpty()) { if (!displayText.isEmpty()) {
try { try {
new AutoUpdater(false).attemptToUpdate(CompletableFuture.supplyAsync(() -> RSSReader.getCommitLog(GITHUB_COMMITS_URL_ATOM, null, null))); new AutoUpdater(false).attemptToUpdate(CompletableFuture.supplyAsync(() -> RSSReader.getCommitLog(GITHUB_COMMITS_URL_ATOM, FControl.instance.getBuildTimeStamp(), FControl.instance.getSnapsTimestamp())));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@@ -198,7 +198,8 @@ public class AutoUpdater {
String log = cf.get(); String log = cf.get();
String v = snapsBuildDate.isEmpty() ? version : version + TextUtil.enclosedParen(snapsBuildDate); String v = snapsBuildDate.isEmpty() ? version : version + TextUtil.enclosedParen(snapsBuildDate);
String b = buildDate.isEmpty() ? buildVersion : buildVersion + TextUtil.enclosedParen(buildDate); String b = buildDate.isEmpty() ? buildVersion : buildVersion + TextUtil.enclosedParen(buildDate);
String message = localizer.getMessage("lblNewVersionForgeAvailableUpdateConfirm", v, b) + log; String info = snapsBuildDate.isEmpty() ? "" : log;
String message = localizer.getMessage("lblNewVersionForgeAvailableUpdateConfirm", v, b) + info;
final List<String> options = ImmutableList.of(localizer.getMessage("lblUpdateNow"), localizer.getMessage("lblUpdateLater")); final List<String> options = ImmutableList.of(localizer.getMessage("lblUpdateNow"), localizer.getMessage("lblUpdateLater"));
if (SOptionPane.showOptionDialog(message, localizer.getMessage("lblNewVersionAvailable"), null, options, 0) == 0) { if (SOptionPane.showOptionDialog(message, localizer.getMessage("lblNewVersionAvailable"), null, options, 0) == 0) {
return downloadFromForge(); return downloadFromForge();