fix: add menu option to install MSX/Colecovision mode

This commit is contained in:
lantzelot-swe 2024-02-10 22:08:41 +01:00
parent 13a7ddbd89
commit 5d3f57b1ea
3 changed files with 77 additions and 6 deletions

View File

@ -53,6 +53,7 @@ import se.lantz.manager.SavedStatesManager;
import se.lantz.manager.pcuae.AmigaModeInstallManager; import se.lantz.manager.pcuae.AmigaModeInstallManager;
import se.lantz.manager.pcuae.AtariModeInstallManager; import se.lantz.manager.pcuae.AtariModeInstallManager;
import se.lantz.manager.pcuae.LinuxModeInstallManager; import se.lantz.manager.pcuae.LinuxModeInstallManager;
import se.lantz.manager.pcuae.MSXModeInstallManager;
import se.lantz.manager.pcuae.PCUAEInstallManager; import se.lantz.manager.pcuae.PCUAEInstallManager;
import se.lantz.manager.pcuae.RetroarchModeInstallManager; import se.lantz.manager.pcuae.RetroarchModeInstallManager;
import se.lantz.manager.pcuae.ScummVMModeInstallManager; import se.lantz.manager.pcuae.ScummVMModeInstallManager;
@ -139,6 +140,7 @@ public class MenuManager
private JMenuItem installRetroarchModeItem; private JMenuItem installRetroarchModeItem;
private JMenuItem installViceModeItem; private JMenuItem installViceModeItem;
private JMenuItem installScummVMModeItem; private JMenuItem installScummVMModeItem;
private JMenuItem installMSXModeItem;
private JMenuItem deleteInstallFilesItem; private JMenuItem deleteInstallFilesItem;
private JMenuItem helpItem; private JMenuItem helpItem;
@ -161,6 +163,7 @@ public class MenuManager
private RetroarchModeInstallManager installRetroarchManager; private RetroarchModeInstallManager installRetroarchManager;
private ViceModeInstallManager installViceManager; private ViceModeInstallManager installViceManager;
private ScummVMModeInstallManager installScummVMManager; private ScummVMModeInstallManager installScummVMManager;
private MSXModeInstallManager installMSXManager;
private MainWindow mainWindow; private MainWindow mainWindow;
private int currentFavoritesCount = 10; private int currentFavoritesCount = 10;
@ -183,6 +186,7 @@ public class MenuManager
this.installRetroarchManager = new RetroarchModeInstallManager(); this.installRetroarchManager = new RetroarchModeInstallManager();
this.installViceManager = new ViceModeInstallManager(); this.installViceManager = new ViceModeInstallManager();
this.installScummVMManager = new ScummVMModeInstallManager(); this.installScummVMManager = new ScummVMModeInstallManager();
this.installMSXManager = new MSXModeInstallManager();
uiModel.setSavedStatesManager(savedStatesManager); uiModel.setSavedStatesManager(savedStatesManager);
setupResourcesMap(); setupResourcesMap();
setupMenues(); setupMenues();
@ -253,14 +257,17 @@ public class MenuManager
toolsMenu.addSeparator(); toolsMenu.addSeparator();
toolsMenu.add(getPalNtscFixMenuItem()); toolsMenu.add(getPalNtscFixMenuItem());
pcuaeMenu = new JMenu("PCUAE"); pcuaeMenu = new JMenu("PCUAE");
pcuaeMenu.setMnemonic('P');
pcuaeMenu.add(getInstallPCUAEItem()); pcuaeMenu.add(getInstallPCUAEItem());
pcuaeModeMenu = new JMenu("Mode Packs"); pcuaeModeMenu = new JMenu("Mode Packs");
pcuaeModeMenu.setMnemonic('M');
pcuaeModeMenu.add(getInstallAmigaModeItem()); pcuaeModeMenu.add(getInstallAmigaModeItem());
pcuaeModeMenu.add(getInstallAtariModeItem()); pcuaeModeMenu.add(getInstallAtariModeItem());
pcuaeModeMenu.add(getInstallLinuxModeItem()); pcuaeModeMenu.add(getInstallLinuxModeItem());
pcuaeModeMenu.add(getInstallRetroarchModeItem()); pcuaeModeMenu.add(getInstallRetroarchModeItem());
pcuaeModeMenu.add(getInstallScummVMModeItem()); pcuaeModeMenu.add(getInstallScummVMModeItem());
pcuaeModeMenu.add(getInstallViceModeItem()); pcuaeModeMenu.add(getInstallViceModeItem());
pcuaeModeMenu.add(getInstallMSXModeItem());
pcuaeMenu.add(pcuaeModeMenu); pcuaeMenu.add(pcuaeModeMenu);
pcuaeMenu.addSeparator(); pcuaeMenu.addSeparator();
pcuaeMenu.add(getDeleteInstallFilesItem()); pcuaeMenu.add(getDeleteInstallFilesItem());
@ -1045,7 +1052,7 @@ public class MenuManager
if (installAmigaModeItem == null) if (installAmigaModeItem == null)
{ {
installAmigaModeItem = new JMenuItem("Install Amiga mode..."); installAmigaModeItem = new JMenuItem("Install Amiga mode...");
installAmigaModeItem.setMnemonic('a'); installAmigaModeItem.setMnemonic('A');
installAmigaModeItem.addActionListener(e -> installAmigaMode()); installAmigaModeItem.addActionListener(e -> installAmigaMode());
} }
return installAmigaModeItem; return installAmigaModeItem;
@ -1067,7 +1074,7 @@ public class MenuManager
if (installLinuxModeItem == null) if (installLinuxModeItem == null)
{ {
installLinuxModeItem = new JMenuItem("Install Linux mode..."); installLinuxModeItem = new JMenuItem("Install Linux mode...");
installLinuxModeItem.setMnemonic('l'); installLinuxModeItem.setMnemonic('L');
installLinuxModeItem.addActionListener(e -> installLinuxMode()); installLinuxModeItem.addActionListener(e -> installLinuxMode());
} }
return installLinuxModeItem; return installLinuxModeItem;
@ -1078,7 +1085,7 @@ public class MenuManager
if (installRetroarchModeItem == null) if (installRetroarchModeItem == null)
{ {
installRetroarchModeItem = new JMenuItem("Install Retroarch mode..."); installRetroarchModeItem = new JMenuItem("Install Retroarch mode...");
installRetroarchModeItem.setMnemonic('r'); installRetroarchModeItem.setMnemonic('R');
installRetroarchModeItem.addActionListener(e -> installRetroarchMode()); installRetroarchModeItem.addActionListener(e -> installRetroarchMode());
} }
return installRetroarchModeItem; return installRetroarchModeItem;
@ -1089,11 +1096,24 @@ public class MenuManager
if (installViceModeItem == null) if (installViceModeItem == null)
{ {
installViceModeItem = new JMenuItem("Install Vice mode..."); installViceModeItem = new JMenuItem("Install Vice mode...");
installViceModeItem.setMnemonic('v'); installViceModeItem.setMnemonic('V');
installViceModeItem.addActionListener(e -> installViceMode()); installViceModeItem.addActionListener(e -> installViceMode());
} }
return installViceModeItem; 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() private JMenuItem getInstallScummVMModeItem()
{ {
@ -1676,6 +1696,11 @@ public class MenuManager
{ {
installScummVMManager.installScummVMMode(); installScummVMManager.installScummVMMode();
} }
private void installMSXMode()
{
installMSXManager.installMSXMode();
}
private void deleteInstallFiles() private void deleteInstallFiles()
{ {

View File

@ -49,6 +49,7 @@ public abstract class BaseInstallManager implements AWTEventListener
protected static final String RETROARCH_MODE_INSTALL_NAME = "retroarch"; protected static final String RETROARCH_MODE_INSTALL_NAME = "retroarch";
protected static final String VICE_MODE_INSTALL_NAME = "vice"; protected static final String VICE_MODE_INSTALL_NAME = "vice";
protected static final String SCUMMVM_MODE_INSTALL_NAME = "scummvm"; protected static final String SCUMMVM_MODE_INSTALL_NAME = "scummvm";
protected static final String MSX_COLECO_MODE_INSTALL_NAME = "msx";
private boolean blockEvents = false; private boolean blockEvents = false;
protected ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor(); 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 //Check so that no other is part of the name
return !(name.contains(AMIGA_MODE_INSTALL_NAME) || name.contains(ATARI_MODE_INSTALL_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(LINUX_MODE_INSTALL_NAME) || name.contains(RETROARCH_MODE_INSTALL_NAME) ||
name.contains(VICE_MODE_INSTALL_NAME) || name.contains(SCUMMVM_MODE_INSTALL_NAME)) && name.contains(VICE_MODE_INSTALL_NAME) || name.contains(SCUMMVM_MODE_INSTALL_NAME) ||
name.endsWith(".exe"); name.contains(MSX_COLECO_MODE_INSTALL_NAME)) && name.endsWith(".exe");
} }
else else
{ {
@ -262,6 +263,15 @@ public abstract class BaseInstallManager implements AWTEventListener
} }
break; 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: case PCUAE_INSTALL_NAME:
{ {
if (!(assetName.contains(AMIGA_MODE_INSTALL_NAME) || assetName.contains(ATARI_MODE_INSTALL_NAME) || if (!(assetName.contains(AMIGA_MODE_INSTALL_NAME) || assetName.contains(ATARI_MODE_INSTALL_NAME) ||

View File

@ -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);
}
}