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 final List<HostedMatch> currentMatches = Lists.newArrayList();
private String snapsVersion = "", currentVersion = "";
private Date snapsTimestamp = null;
private Date snapsTimestamp = null, buildTimeStamp = null;
private boolean isSnapshot, hasSnapsUpdate;
private Localizer localizer;
@@ -165,7 +165,9 @@ public enum FControl implements KeyEventDispatcher {
Singletons.getView().getNavigationBar().closeSelectedTab();
break;
case EXIT_FORGE:
if (exitForge()) { return; }
if (exitForge()) {
return;
}
break;
}
//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() {
return closeAction;
}
public void setCloseAction(final CloseAction closeAction0) {
if (closeAction == closeAction0) { return; }
if (closeAction == closeAction0) {
return;
}
closeAction = closeAction0;
Singletons.getView().getNavigationBar().updateBtnCloseTooltip();
@@ -222,7 +234,9 @@ public enum FControl implements KeyEventDispatcher {
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() {
final ForgePreferences prefs = FModel.getPreferences();
currentVersion = BuildInfo.getVersionString();
@@ -235,10 +249,12 @@ public enum FControl implements KeyEventDispatcher {
url = new URL("https://downloads.cardforge.org/dailysnapshots/build.txt");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
snapsTimestamp = simpleDateFormat.parse(FileUtil.readFileToString(url));
buildTimeStamp = BuildInfo.getTimestamp();
hasSnapsUpdate = BuildInfo.verifyTimestamp(snapsTimestamp);
}
} catch (Exception ignored) {}
} catch (Exception ignored) {
}
// Preloads skin components (using progress bar).
FSkin.loadFull(true);
@@ -266,7 +282,8 @@ public enum FControl implements KeyEventDispatcher {
// format release notes upon loading
try {
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
final FFrame window = Singletons.getView().getFrame();
window.addComponentListener(new ComponentAdapter() {
@@ -291,9 +308,11 @@ public enum FControl implements KeyEventDispatcher {
FView.SINGLETON_INSTANCE.setSplashProgessBarMessage(getLocalizer().getMessage("lblOpeningMainWindow"));
SwingUtilities.invokeLater(() -> Singletons.getView().initialize());
}
public boolean isSnapshot() {
return isSnapshot;
}
public String getSnapshotNotification() {
if (!isSnapshot || !hasSnapsUpdate || snapsVersion.isEmpty())
return "";
@@ -322,6 +341,7 @@ public enum FControl implements KeyEventDispatcher {
public boolean setCurrentScreen(final FScreen screen) {
return setCurrentScreen(screen, false);
}
public boolean setCurrentScreen(final FScreen screen, final boolean previousScreenClosed) {
//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)
@@ -386,12 +406,16 @@ public enum FControl implements KeyEventDispatcher {
}
public boolean ensureScreenActive(final FScreen screen) {
if (currentScreen == screen) { return true; }
if (currentScreen == screen) {
return true;
}
return setCurrentScreen(screen);
}
/** Remove all children from a specified layer. */
/**
* Remove all children from a specified layer.
*/
private void clearChildren(final int 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() {
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);
if (children.length != 0) { children[0].setSize(display.getSize()); }
if (children.length != 0) {
children[0].setSize(display.getSize());
}
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() {
@@ -428,18 +460,15 @@ public enum FControl implements KeyEventDispatcher {
forgeMenu.show(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;
}
}
else {
} else {
altKeyLastDown = false;
if (e.getID() == KeyEvent.KEY_PRESSED) {
//give Forge menu the chance to handle the key event
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) {
forgeMenu.show();
}

View File

@@ -2,6 +2,7 @@ package forge.screens.home.settings;
import javax.swing.SwingUtilities;
import forge.control.FControl;
import forge.download.AutoUpdater;
import forge.download.GuiDownloader;
import forge.gui.ImportDialog;
@@ -32,7 +33,7 @@ public enum CSubmenuDownloaders implements ICDoc {
SINGLETON_INSTANCE;
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 cmdPicDownloadHQ = () -> new GuiDownloader(new GuiDownloadPicturesHQ()).show();

View File

@@ -438,7 +438,7 @@ public abstract class FTitleBarBase extends SkinnedMenuBar {
protected void onClick() {
if (!displayText.isEmpty()) {
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) {
e.printStackTrace();
}

View File

@@ -198,7 +198,8 @@ public class AutoUpdater {
String log = cf.get();
String v = snapsBuildDate.isEmpty() ? version : version + TextUtil.enclosedParen(snapsBuildDate);
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"));
if (SOptionPane.showOptionDialog(message, localizer.getMessage("lblNewVersionAvailable"), null, options, 0) == 0) {
return downloadFromForge();