From 0b6281cf1644fc188110b79a06300ce403c72313 Mon Sep 17 00:00:00 2001 From: lantzelot-swe <75668734+lantzelot-swe@users.noreply.github.com> Date: Fri, 27 Sep 2024 22:38:53 +0200 Subject: [PATCH] fix: PCUAE installation - downloads CBM edition of PCUAE - support to download SNES mode --- src/main/java/se/lantz/gui/MenuManager.java | 23 +++++++++++- .../manager/pcuae/BaseInstallManager.java | 21 ++++++++--- .../manager/pcuae/SNESModeInstallManager.java | 36 +++++++++++++++++++ 3 files changed, 74 insertions(+), 6 deletions(-) create mode 100644 src/main/java/se/lantz/manager/pcuae/SNESModeInstallManager.java diff --git a/src/main/java/se/lantz/gui/MenuManager.java b/src/main/java/se/lantz/gui/MenuManager.java index f1d8f7b..639a7e8 100644 --- a/src/main/java/se/lantz/gui/MenuManager.java +++ b/src/main/java/se/lantz/gui/MenuManager.java @@ -71,6 +71,7 @@ import se.lantz.manager.pcuae.MSXModeInstallManager; import se.lantz.manager.pcuae.PCUAEInstallManager; import se.lantz.manager.pcuae.PlaystationModeInstallManager; import se.lantz.manager.pcuae.RetroarchModeInstallManager; +import se.lantz.manager.pcuae.SNESModeInstallManager; import se.lantz.manager.pcuae.ScummVMModeInstallManager; import se.lantz.manager.pcuae.SegaModeInstallManager; import se.lantz.manager.pcuae.ViceModeInstallManager; @@ -163,6 +164,7 @@ public class MenuManager private InsetsMenuItem installMSXModeItem; private InsetsMenuItem installDosModeItem; private InsetsMenuItem installSegaModeItem; + private InsetsMenuItem installSnesModeItem; private InsetsMenuItem installPlaystationModeItem; private InsetsMenuItem installZesaruxModeItem; private InsetsMenuItem deleteInstallFilesItem; @@ -191,6 +193,7 @@ public class MenuManager private MSXModeInstallManager installMSXManager; private DosModeInstallManager installDosManager; private SegaModeInstallManager installSegaManager; + private SNESModeInstallManager installSnesManager; private PlaystationModeInstallManager installPlaystationManager; private ZesaruxModeInstallManager installZesaruxManager; private int currentFavoritesCount = 10; @@ -216,6 +219,7 @@ public class MenuManager this.installMSXManager = new MSXModeInstallManager(); this.installDosManager = new DosModeInstallManager(); this.installSegaManager = new SegaModeInstallManager(); + this.installSnesManager = new SNESModeInstallManager(); this.installPlaystationManager = new PlaystationModeInstallManager(); this.installZesaruxManager = new ZesaruxModeInstallManager(); uiModel.setSavedStatesManager(savedStatesManager); @@ -310,6 +314,7 @@ public class MenuManager pcuaeModeMenu.add(getInstallMSXModeItem()); pcuaeModeMenu.add(getInstallDosModeItem()); pcuaeModeMenu.add(getInstallSegaModeItem()); + pcuaeModeMenu.add(getInstallSnesModeItem()); pcuaeModeMenu.add(getInstallPlaystationModeItem()); pcuaeModeMenu.add(getInstallZesaruxModeItem()); pcuaeMenu.add(pcuaeModeMenu); @@ -534,7 +539,7 @@ public class MenuManager runGameItem.setAccelerator(keyStrokeToRunGame); runGameItem.setMnemonic('R'); - runGameItem.addActionListener(e -> MainWindow.getInstance().getMainPanel().runCurrentGame()); + runGameItem.addActionListener(e -> MainWindow.getInstance().getMainPanel().runCurrentGame(false)); return runGameItem; } @@ -1287,6 +1292,17 @@ public class MenuManager } return installSegaModeItem; } + + private InsetsMenuItem getInstallSnesModeItem() + { + if (installSnesModeItem == null) + { + installSnesModeItem = new InsetsMenuItem("Install SNES mode..."); + installSnesModeItem.setMnemonic('e'); + installSnesModeItem.addActionListener(e -> installSnesMode()); + } + return installSnesModeItem; + } private InsetsMenuItem getInstallPlaystationModeItem() { @@ -2045,6 +2061,11 @@ public class MenuManager { installSegaManager.installSegaMode(); } + + private void installSnesMode() + { + installSnesManager.installSnesMode(); + } private void installPlaystationMode() { diff --git a/src/main/java/se/lantz/manager/pcuae/BaseInstallManager.java b/src/main/java/se/lantz/manager/pcuae/BaseInstallManager.java index de956df..d15f5da 100644 --- a/src/main/java/se/lantz/manager/pcuae/BaseInstallManager.java +++ b/src/main/java/se/lantz/manager/pcuae/BaseInstallManager.java @@ -43,7 +43,7 @@ public abstract class BaseInstallManager implements AWTEventListener public static final String INSTALL_FOLDER = "./pcuae-install/"; protected static final String PCUAE_INSTALL_NAME = "pcuae"; - protected static final String PCUAE_MAIN_INSTALL_NAME = "main"; + protected static final String PCUAE_MAIN_INSTALL_NAME = "cbm"; protected static final String AMIGA_MODE_INSTALL_NAME = "amiga-mode"; protected static final String ATARI_MODE_INSTALL_NAME = "atari-mode"; protected static final String LINUX_MODE_INSTALL_NAME = "linux-mode"; @@ -54,6 +54,7 @@ public abstract class BaseInstallManager implements AWTEventListener protected static final String DOS_MODE_INSTALL_NAME = "dos-mode"; protected static final String SEGA_MODE_INSTALL_NAME = "sega-mode"; + protected static final String SNES_MODE_INSTALL_NAME = "snes-mode"; protected static final String PLAYSTATION_MODE_INSTALL_NAME = "playstation-mode"; protected static final String ZESARUX_MODE_INSTALL_NAME = "zesarux-mode"; @@ -167,8 +168,9 @@ public abstract class BaseInstallManager implements AWTEventListener name.contains(LINUX_MODE_INSTALL_NAME) || name.contains(RETROARCH_MODE_INSTALL_NAME) || name.contains(VICE_MODE_INSTALL_NAME) || name.contains(SCUMMVM_MODE_INSTALL_NAME) || name.contains(MSX_COLECO_MODE_INSTALL_NAME) || name.contains(DOS_MODE_INSTALL_NAME) || - name.contains(SEGA_MODE_INSTALL_NAME) || name.contains(PLAYSTATION_MODE_INSTALL_NAME) || - name.contains(ZESARUX_MODE_INSTALL_NAME)) && name.endsWith(".exe"); + name.contains(SEGA_MODE_INSTALL_NAME) || name.contains(SNES_MODE_INSTALL_NAME) || + name.contains(PLAYSTATION_MODE_INSTALL_NAME) || name.contains(ZESARUX_MODE_INSTALL_NAME)) && + name.endsWith(".exe"); } else { @@ -303,6 +305,15 @@ public abstract class BaseInstallManager implements AWTEventListener break; } + case SNES_MODE_INSTALL_NAME: + { + if (assetName.contains(SNES_MODE_INSTALL_NAME)) + { + downloadUrl = asset.getAsJsonObject().get("browser_download_url").getAsString(); + } + break; + } + case PLAYSTATION_MODE_INSTALL_NAME: { if (assetName.contains(PLAYSTATION_MODE_INSTALL_NAME)) @@ -327,8 +338,8 @@ public abstract class BaseInstallManager implements AWTEventListener assetName.contains(LINUX_MODE_INSTALL_NAME) || assetName.contains(RETROARCH_MODE_INSTALL_NAME) || assetName.contains(VICE_MODE_INSTALL_NAME) || assetName.contains(SCUMMVM_MODE_INSTALL_NAME) || assetName.contains(DOS_MODE_INSTALL_NAME) || assetName.contains(SEGA_MODE_INSTALL_NAME) || - assetName.contains(PLAYSTATION_MODE_INSTALL_NAME) || assetName.contains(ZESARUX_MODE_INSTALL_NAME)) && - assetName.contains(PCUAE_MAIN_INSTALL_NAME)) + assetName.contains(SNES_MODE_INSTALL_NAME) || assetName.contains(PLAYSTATION_MODE_INSTALL_NAME) || + assetName.contains(ZESARUX_MODE_INSTALL_NAME)) && assetName.contains(PCUAE_MAIN_INSTALL_NAME)) { downloadUrl = asset.getAsJsonObject().get("browser_download_url").getAsString(); } diff --git a/src/main/java/se/lantz/manager/pcuae/SNESModeInstallManager.java b/src/main/java/se/lantz/manager/pcuae/SNESModeInstallManager.java new file mode 100644 index 0000000..a1e4969 --- /dev/null +++ b/src/main/java/se/lantz/manager/pcuae/SNESModeInstallManager.java @@ -0,0 +1,36 @@ +package se.lantz.manager.pcuae; + +import javax.swing.JOptionPane; + +import se.lantz.gui.MainWindow; + +public class SNESModeInstallManager extends BaseInstallManager +{ + private static final String PRODUCT_NAME = "SNES mode"; + + public SNESModeInstallManager() + { + } + + public void installSnesMode() + { + readVersionFromInstallFolder(SNES_MODE_INSTALL_NAME); + if (isNewVersionAvailable(SNES_MODE_INSTALL_NAME)) + { + askAndStartDownload(PRODUCT_NAME, SNES_MODE_INSTALL_NAME); + } + else + { + askToInstallExistingVersion(PRODUCT_NAME); + } + } + + @Override + protected void executeAfterInstallation() + { + JOptionPane.showMessageDialog(MainWindow.getInstance(), + PRODUCT_NAME + " installed successfully.", + "Installation complete", + JOptionPane.INFORMATION_MESSAGE); + } +}