diff --git a/src/main/java/se/lantz/gui/MenuManager.java b/src/main/java/se/lantz/gui/MenuManager.java index 2f4d8d6..8213eec 100644 --- a/src/main/java/se/lantz/gui/MenuManager.java +++ b/src/main/java/se/lantz/gui/MenuManager.java @@ -53,6 +53,7 @@ import se.lantz.manager.SavedStatesManager; import se.lantz.manager.pcuae.AmigaModeInstallManager; import se.lantz.manager.pcuae.AtariModeInstallManager; import se.lantz.manager.pcuae.LinuxModeInstallManager; +import se.lantz.manager.pcuae.MSXModeInstallManager; import se.lantz.manager.pcuae.PCUAEInstallManager; import se.lantz.manager.pcuae.RetroarchModeInstallManager; import se.lantz.manager.pcuae.ScummVMModeInstallManager; @@ -139,6 +140,7 @@ public class MenuManager private JMenuItem installRetroarchModeItem; private JMenuItem installViceModeItem; private JMenuItem installScummVMModeItem; + private JMenuItem installMSXModeItem; private JMenuItem deleteInstallFilesItem; private JMenuItem helpItem; @@ -161,6 +163,7 @@ public class MenuManager private RetroarchModeInstallManager installRetroarchManager; private ViceModeInstallManager installViceManager; private ScummVMModeInstallManager installScummVMManager; + private MSXModeInstallManager installMSXManager; private MainWindow mainWindow; private int currentFavoritesCount = 10; @@ -183,6 +186,7 @@ public class MenuManager this.installRetroarchManager = new RetroarchModeInstallManager(); this.installViceManager = new ViceModeInstallManager(); this.installScummVMManager = new ScummVMModeInstallManager(); + this.installMSXManager = new MSXModeInstallManager(); uiModel.setSavedStatesManager(savedStatesManager); setupResourcesMap(); setupMenues(); @@ -253,14 +257,17 @@ public class MenuManager toolsMenu.addSeparator(); toolsMenu.add(getPalNtscFixMenuItem()); pcuaeMenu = new JMenu("PCUAE"); + pcuaeMenu.setMnemonic('P'); pcuaeMenu.add(getInstallPCUAEItem()); pcuaeModeMenu = new JMenu("Mode Packs"); + pcuaeModeMenu.setMnemonic('M'); pcuaeModeMenu.add(getInstallAmigaModeItem()); pcuaeModeMenu.add(getInstallAtariModeItem()); pcuaeModeMenu.add(getInstallLinuxModeItem()); pcuaeModeMenu.add(getInstallRetroarchModeItem()); pcuaeModeMenu.add(getInstallScummVMModeItem()); pcuaeModeMenu.add(getInstallViceModeItem()); + pcuaeModeMenu.add(getInstallMSXModeItem()); pcuaeMenu.add(pcuaeModeMenu); pcuaeMenu.addSeparator(); pcuaeMenu.add(getDeleteInstallFilesItem()); @@ -1045,7 +1052,7 @@ public class MenuManager if (installAmigaModeItem == null) { installAmigaModeItem = new JMenuItem("Install Amiga mode..."); - installAmigaModeItem.setMnemonic('a'); + installAmigaModeItem.setMnemonic('A'); installAmigaModeItem.addActionListener(e -> installAmigaMode()); } return installAmigaModeItem; @@ -1067,7 +1074,7 @@ public class MenuManager if (installLinuxModeItem == null) { installLinuxModeItem = new JMenuItem("Install Linux mode..."); - installLinuxModeItem.setMnemonic('l'); + installLinuxModeItem.setMnemonic('L'); installLinuxModeItem.addActionListener(e -> installLinuxMode()); } return installLinuxModeItem; @@ -1078,7 +1085,7 @@ public class MenuManager if (installRetroarchModeItem == null) { installRetroarchModeItem = new JMenuItem("Install Retroarch mode..."); - installRetroarchModeItem.setMnemonic('r'); + installRetroarchModeItem.setMnemonic('R'); installRetroarchModeItem.addActionListener(e -> installRetroarchMode()); } return installRetroarchModeItem; @@ -1089,11 +1096,24 @@ public class MenuManager if (installViceModeItem == null) { installViceModeItem = new JMenuItem("Install Vice mode..."); - installViceModeItem.setMnemonic('v'); + installViceModeItem.setMnemonic('V'); installViceModeItem.addActionListener(e -> installViceMode()); } return installViceModeItem; } + + private JMenuItem getInstallMSXModeItem() + { + if (installMSXModeItem == null) + { + installMSXModeItem = new JMenuItem("Install MSX/Colecovision mode..."); + installMSXModeItem.setMnemonic('M'); + installMSXModeItem.addActionListener(e -> installMSXMode()); + } + return installMSXModeItem; + } + + private JMenuItem getInstallScummVMModeItem() { @@ -1676,6 +1696,11 @@ public class MenuManager { installScummVMManager.installScummVMMode(); } + + private void installMSXMode() + { + installMSXManager.installMSXMode(); + } private void deleteInstallFiles() { diff --git a/src/main/java/se/lantz/manager/pcuae/BaseInstallManager.java b/src/main/java/se/lantz/manager/pcuae/BaseInstallManager.java index bdbc2a6..2747df0 100644 --- a/src/main/java/se/lantz/manager/pcuae/BaseInstallManager.java +++ b/src/main/java/se/lantz/manager/pcuae/BaseInstallManager.java @@ -49,6 +49,7 @@ public abstract class BaseInstallManager implements AWTEventListener protected static final String RETROARCH_MODE_INSTALL_NAME = "retroarch"; protected static final String VICE_MODE_INSTALL_NAME = "vice"; protected static final String SCUMMVM_MODE_INSTALL_NAME = "scummvm"; + protected static final String MSX_COLECO_MODE_INSTALL_NAME = "msx"; private boolean blockEvents = false; protected ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor(); @@ -158,8 +159,8 @@ public abstract class BaseInstallManager implements AWTEventListener //Check so that no other is part of the name return !(name.contains(AMIGA_MODE_INSTALL_NAME) || name.contains(ATARI_MODE_INSTALL_NAME) || 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.endsWith(".exe"); + name.contains(VICE_MODE_INSTALL_NAME) || name.contains(SCUMMVM_MODE_INSTALL_NAME) || + name.contains(MSX_COLECO_MODE_INSTALL_NAME)) && name.endsWith(".exe"); } else { @@ -262,6 +263,15 @@ public abstract class BaseInstallManager implements AWTEventListener } break; } + + case MSX_COLECO_MODE_INSTALL_NAME: + { + if (assetName.contains(MSX_COLECO_MODE_INSTALL_NAME)) + { + downloadUrl = asset.getAsJsonObject().get("browser_download_url").getAsString(); + } + break; + } case PCUAE_INSTALL_NAME: { if (!(assetName.contains(AMIGA_MODE_INSTALL_NAME) || assetName.contains(ATARI_MODE_INSTALL_NAME) || diff --git a/src/main/java/se/lantz/manager/pcuae/MSXModeInstallManager.java b/src/main/java/se/lantz/manager/pcuae/MSXModeInstallManager.java new file mode 100644 index 0000000..8f2a0bf --- /dev/null +++ b/src/main/java/se/lantz/manager/pcuae/MSXModeInstallManager.java @@ -0,0 +1,36 @@ +package se.lantz.manager.pcuae; + +import javax.swing.JOptionPane; + +import se.lantz.gui.MainWindow; + +public class MSXModeInstallManager extends BaseInstallManager +{ + private static final String PRODUCT_NAME = "MSX/Colecovison mode"; + + public MSXModeInstallManager() + { + } + + public void installMSXMode() + { + readVersionFromInstallFolder(MSX_COLECO_MODE_INSTALL_NAME); + if (isNewVersionAvailable(MSX_COLECO_MODE_INSTALL_NAME)) + { + askAndStartDownload(PRODUCT_NAME, MSX_COLECO_MODE_INSTALL_NAME); + } + else + { + askToInstallExistingVersion(PRODUCT_NAME); + } + } + + @Override + protected void executeAfterInstallation() + { + JOptionPane.showMessageDialog(MainWindow.getInstance(), + PRODUCT_NAME + " installed successfully.", + "Installation complete", + JOptionPane.INFORMATION_MESSAGE); + } +}