diff --git a/src/main/java/se/lantz/gui/GameDetailsBackgroundPanel.java b/src/main/java/se/lantz/gui/GameDetailsBackgroundPanel.java index e474130..e3b609d 100644 --- a/src/main/java/se/lantz/gui/GameDetailsBackgroundPanel.java +++ b/src/main/java/se/lantz/gui/GameDetailsBackgroundPanel.java @@ -44,6 +44,7 @@ import se.lantz.manager.ScraperManager; import se.lantz.model.MainViewModel; import se.lantz.model.data.GameListData; import se.lantz.model.data.ScraperFields; +import se.lantz.util.FileManager; public class GameDetailsBackgroundPanel extends JPanel { @@ -188,6 +189,7 @@ public class GameDetailsBackgroundPanel extends JPanel systemSavesTabbedPane = new JTabbedPane(); systemSavesTabbedPane.addTab("System Settings", getSystemPanel()); systemSavesTabbedPane.addTab("Saved states", getSavesBackgroundPanel()); + updateSavedStatesTabTitle(); } return systemSavesTabbedPane; } @@ -500,4 +502,11 @@ public class GameDetailsBackgroundPanel extends JPanel return false; } } + + public void updateSavedStatesTabTitle() + { + String carouselVersion = FileManager.getConfiguredSavedStatesCarouselVersion(); + getSystemSavesTabbedPane().setTitleAt(1, "Saved States (Carousel " + carouselVersion + ")"); + getSavesBackgroundPanel().resetCurrentGameReference(); + } } diff --git a/src/main/java/se/lantz/gui/MainPanel.java b/src/main/java/se/lantz/gui/MainPanel.java index 67cc873..392bd8f 100644 --- a/src/main/java/se/lantz/gui/MainPanel.java +++ b/src/main/java/se/lantz/gui/MainPanel.java @@ -260,4 +260,9 @@ public class MainPanel extends JPanel { getListPanel().reloadCurrentGameView(); } + + public void updateSavedStatesTabTitle() + { + getGameDetailsBackgroundPanel().updateSavedStatesTabTitle(); + } } diff --git a/src/main/java/se/lantz/gui/MainWindow.java b/src/main/java/se/lantz/gui/MainWindow.java index d012118..3d7ee90 100644 --- a/src/main/java/se/lantz/gui/MainWindow.java +++ b/src/main/java/se/lantz/gui/MainWindow.java @@ -99,14 +99,16 @@ public final class MainWindow extends JFrame return menuBar; } - public void refreshFavoritesLists() + public void refreshAfterPreferencesSave() { getJMenuBar().removeAll(); for (JMenu menu : menuManager.getMenues()) { menuBar.add(menu); } + getMainPanel().reloadCurrentGameView(); + getMainPanel().updateSavedStatesTabTitle(); SwingUtilities.updateComponentTreeUI(this); repaintAfterModifications(); } diff --git a/src/main/java/se/lantz/gui/MenuManager.java b/src/main/java/se/lantz/gui/MenuManager.java index 130ac67..bb14d8c 100644 --- a/src/main/java/se/lantz/gui/MenuManager.java +++ b/src/main/java/se/lantz/gui/MenuManager.java @@ -1109,7 +1109,7 @@ public class MenuManager prefDialog.savePreferences(); //Update favorites menu setupEditMenu(); - MainWindow.getInstance().refreshFavoritesLists(); + MainWindow.getInstance().refreshAfterPreferencesSave(); //Refresh game views uiModel.reloadGameViews(); //Set all games as selected diff --git a/src/main/java/se/lantz/gui/SaveStateBackgroundPanel.java b/src/main/java/se/lantz/gui/SaveStateBackgroundPanel.java index 0e9f5af..e7b193b 100644 --- a/src/main/java/se/lantz/gui/SaveStateBackgroundPanel.java +++ b/src/main/java/se/lantz/gui/SaveStateBackgroundPanel.java @@ -80,4 +80,12 @@ public class SaveStateBackgroundPanel extends JPanel getSaveStatePanel3().commitEdits(); getSaveStatePanel4().commitEdits(); } + + void resetCurrentGameReference() + { + getSaveStatePanel1().resetCurrentGameReference(); + getSaveStatePanel2().resetCurrentGameReference(); + getSaveStatePanel3().resetCurrentGameReference(); + getSaveStatePanel4().resetCurrentGameReference(); + } } diff --git a/src/main/java/se/lantz/gui/SaveStatePanel.java b/src/main/java/se/lantz/gui/SaveStatePanel.java index daac6d1..5755fc1 100644 --- a/src/main/java/se/lantz/gui/SaveStatePanel.java +++ b/src/main/java/se/lantz/gui/SaveStatePanel.java @@ -311,7 +311,7 @@ public class SaveStatePanel extends JPanel BufferedImage image = null; if (!filename.isEmpty()) { - String fileName = model.getInfoModel().getGamesFile(); + String fileName = SavedStatesManager.getGameFolderName(model.getInfoModel().getGamesFile()); logger.debug(fileName.toString()); Path saveFolderPath = new File("./saves/" + fileName).toPath(); @@ -857,4 +857,9 @@ public class SaveStatePanel extends JPanel } return deleteButton; } + + void resetCurrentGameReference() + { + this.currentGameFile = ""; + } } diff --git a/src/main/java/se/lantz/gui/preferences/MiscPanel.java b/src/main/java/se/lantz/gui/preferences/MiscPanel.java index 612acd2..f2c0ed9 100644 --- a/src/main/java/se/lantz/gui/preferences/MiscPanel.java +++ b/src/main/java/se/lantz/gui/preferences/MiscPanel.java @@ -31,15 +31,18 @@ public class MiscPanel extends JPanel private JPanel favoritesPanel; private JLabel numberOfFavoritesLabel; private JSpinner favoritesSpinner; + private SaveStatePrefPanel saveStatePrefPanel; public MiscPanel(PreferencesModel model) { this.model = model; GridBagLayout gridBagLayout = new GridBagLayout(); + gridBagLayout.rowWeights = new double[]{0.0, 0.0, 1.0}; + gridBagLayout.columnWeights = new double[]{1.0}; setLayout(gridBagLayout); GridBagConstraints gbc_startupPanel = new GridBagConstraints(); - gbc_startupPanel.insets = new Insets(5, 5, 5, 5); + gbc_startupPanel.insets = new Insets(5, 5, 5, 3); gbc_startupPanel.weightx = 1.0; gbc_startupPanel.anchor = GridBagConstraints.NORTHWEST; gbc_startupPanel.fill = GridBagConstraints.BOTH; @@ -47,14 +50,21 @@ public class MiscPanel extends JPanel gbc_startupPanel.gridy = 0; add(getStartupPanel(), gbc_startupPanel); GridBagConstraints gbc_favoritesPanel = new GridBagConstraints(); - gbc_favoritesPanel.weighty = 1.0; gbc_favoritesPanel.anchor = GridBagConstraints.NORTHWEST; gbc_favoritesPanel.weightx = 1.0; - gbc_favoritesPanel.insets = new Insets(5, 5, 5, 5); + gbc_favoritesPanel.insets = new Insets(5, 5, 5, 3); gbc_favoritesPanel.fill = GridBagConstraints.HORIZONTAL; gbc_favoritesPanel.gridx = 0; gbc_favoritesPanel.gridy = 1; add(getFavoritesPanel(), gbc_favoritesPanel); + GridBagConstraints gbc_saveStatePrefPanel = new GridBagConstraints(); + gbc_saveStatePrefPanel.insets = new Insets(5, 5, 5, 3); + gbc_saveStatePrefPanel.weighty = 1.0; + gbc_saveStatePrefPanel.anchor = GridBagConstraints.NORTHWEST; + gbc_saveStatePrefPanel.fill = GridBagConstraints.HORIZONTAL; + gbc_saveStatePrefPanel.gridx = 0; + gbc_saveStatePrefPanel.gridy = 2; + add(getSaveStatePrefPanel(), gbc_saveStatePrefPanel); if (!Beans.isDesignTime()) { model.addPropertyChangeListener(e -> modelChanged()); @@ -195,4 +205,12 @@ public class MiscPanel extends JPanel } return favoritesSpinner; } + private SaveStatePrefPanel getSaveStatePrefPanel() { + if (saveStatePrefPanel == null) { + saveStatePrefPanel = new SaveStatePrefPanel(this.model); + saveStatePrefPanel + .setBorder(new TitledBorder(null, "Saved states preferences", TitledBorder.LEADING, TitledBorder.TOP, null, null)); + } + return saveStatePrefPanel; + } } diff --git a/src/main/java/se/lantz/gui/preferences/SaveStatePrefPanel.java b/src/main/java/se/lantz/gui/preferences/SaveStatePrefPanel.java new file mode 100644 index 0000000..9cfbfe2 --- /dev/null +++ b/src/main/java/se/lantz/gui/preferences/SaveStatePrefPanel.java @@ -0,0 +1,118 @@ +package se.lantz.gui.preferences; + +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.beans.Beans; + +import javax.swing.ButtonGroup; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; + +import se.lantz.model.PreferencesModel; + +public class SaveStatePrefPanel extends JPanel +{ + private JLabel infoLabel; + private JRadioButton v132RadioButton; + private JRadioButton v152RadioButton; + private final ButtonGroup buttonGroup = new ButtonGroup(); + private PreferencesModel model; + + public SaveStatePrefPanel(PreferencesModel model) + { + this.model = model; + GridBagLayout gridBagLayout = new GridBagLayout(); + setLayout(gridBagLayout); + GridBagConstraints gbc_infoLabel = new GridBagConstraints(); + gbc_infoLabel.insets = new Insets(10, 10, 10, 10); + gbc_infoLabel.weightx = 1.0; + gbc_infoLabel.fill = GridBagConstraints.HORIZONTAL; + gbc_infoLabel.anchor = GridBagConstraints.NORTHWEST; + gbc_infoLabel.gridx = 0; + gbc_infoLabel.gridy = 0; + add(getInfoLabel(), gbc_infoLabel); + GridBagConstraints gbc_v132RadioButton = new GridBagConstraints(); + gbc_v132RadioButton.anchor = GridBagConstraints.WEST; + gbc_v132RadioButton.weightx = 1.0; + gbc_v132RadioButton.insets = new Insets(0, 40, 0, 0); + gbc_v132RadioButton.gridx = 0; + gbc_v132RadioButton.gridy = 1; + add(getV132RadioButton(), gbc_v132RadioButton); + GridBagConstraints gbc_v152RadioButton = new GridBagConstraints(); + gbc_v152RadioButton.weighty = 1.0; + gbc_v152RadioButton.insets = new Insets(0, 40, 10, 0); + gbc_v152RadioButton.anchor = GridBagConstraints.NORTHWEST; + gbc_v152RadioButton.weightx = 1.0; + gbc_v152RadioButton.gridx = 0; + gbc_v152RadioButton.gridy = 2; + add(getV152RadioButton(), gbc_v152RadioButton); + if (!Beans.isDesignTime()) + { + model.addPropertyChangeListener(e -> modelChanged()); + //Trigger an initial read from the model + modelChanged(); + } + } + + private JLabel getInfoLabel() + { + if (infoLabel == null) + { + String info = "Different versions of the Carousel adds the saved states in different folders. " + + "You have to choose which verison of the Carousel you want the manager to read the saved states for. " + + "Only saved states for one carousel version at a time is shown for the games in the game list views."; + infoLabel = new JLabel(info); + } + return infoLabel; + } + + private JRadioButton getV132RadioButton() + { + if (v132RadioButton == null) + { + v132RadioButton = new JRadioButton("Carousel version 1.3.2 and earlier."); + v132RadioButton.addItemListener(new ItemListener() + { + public void itemStateChanged(ItemEvent e) + { + if (v132RadioButton.isSelected()) + { + model.setSavedStatesCarouselVersion(PreferencesModel.CAROUSEL_132); + } + } + }); + buttonGroup.add(v132RadioButton); + } + return v132RadioButton; + } + + private JRadioButton getV152RadioButton() + { + if (v152RadioButton == null) + { + v152RadioButton = new JRadioButton("Carousel version 1.5.2 and later."); + v152RadioButton.setSelected(true); + v152RadioButton.addItemListener(new ItemListener() + { + public void itemStateChanged(ItemEvent e) + { + if (v152RadioButton.isSelected()) + { + model.setSavedStatesCarouselVersion(PreferencesModel.CAROUSEL_152); + } + } + }); + buttonGroup.add(v152RadioButton); + } + return v152RadioButton; + } + + private void modelChanged() + { + getV132RadioButton().setSelected(model.getSavedStatesCarouselVersion().equals(PreferencesModel.CAROUSEL_132)); + } +} diff --git a/src/main/java/se/lantz/manager/SavedStatesManager.java b/src/main/java/se/lantz/manager/SavedStatesManager.java index f5efc0e..c5266be 100644 --- a/src/main/java/se/lantz/manager/SavedStatesManager.java +++ b/src/main/java/se/lantz/manager/SavedStatesManager.java @@ -26,6 +26,7 @@ import org.slf4j.LoggerFactory; import se.lantz.gui.exports.PublishWorker; import se.lantz.model.MainViewModel; +import se.lantz.model.PreferencesModel; import se.lantz.model.SavedStatesModel; import se.lantz.model.SavedStatesModel.SAVESTATE; import se.lantz.util.ExceptionHandler; @@ -102,15 +103,15 @@ public class SavedStatesManager //If the game has been renamed, make sure to rename the saves folder also String oldFileName = model.getInfoModel().getOldGamesFile(); String newFileName = model.getInfoModel().getGamesFile(); - File oldSaveFolder = new File(SAVES + oldFileName); + File oldSaveFolder = new File(SAVES + getGameFolderName(oldFileName)); if (!oldFileName.equals(newFileName) && oldSaveFolder.exists()) { //Rename old folder to new name - oldSaveFolder.renameTo(new File(SAVES + model.getInfoModel().getGamesFile())); + oldSaveFolder.renameTo(new File(SAVES + getGameFolderName(model.getInfoModel().getGamesFile()))); } String fileName = model.getInfoModel().getGamesFile(); - Path saveFolder = new File(SAVES + fileName).toPath(); + Path saveFolder = new File(SAVES + getGameFolderName(fileName)).toPath(); int numberofSaves = 0; //Check which ones are available Path mta0Path = saveFolder.resolve(MTA0); @@ -161,7 +162,7 @@ public class SavedStatesManager { savedStatesModel.resetProperties(); //Read from state directory, update model - String fileName = model.getInfoModel().getGamesFile(); + String fileName = getGameFolderName(model.getInfoModel().getGamesFile()); if (!fileName.isEmpty()) { //Check if folder is available @@ -330,7 +331,7 @@ public class SavedStatesManager private void deleteSavedState(SAVESTATE state) { - String fileName = model.getInfoModel().getGamesFile(); + String fileName = getGameFolderName(model.getInfoModel().getGamesFile()); Path saveFolder = new File(SAVES + fileName).toPath(); try { @@ -554,7 +555,8 @@ public class SavedStatesManager public int getNumberOfSavedStatesForGame(String gameFileName) { - return savedStatesMap.get(gameFileName) != null ? savedStatesMap.get(gameFileName) : 0; + String fileName = getGameFolderName(gameFileName); + return savedStatesMap.get(fileName) != null ? savedStatesMap.get(fileName) : 0; } public void checkEnablementOfPalNtscMenuItem(boolean check) @@ -568,7 +570,7 @@ public class SavedStatesManager if (!fileName.isEmpty() && fileName.contains(".vsf")) { //Check if folder is available - Path saveFolder = new File(SAVES + fileName).toPath(); + Path saveFolder = new File(SAVES + getGameFolderName(fileName)).toPath(); if (Files.exists(saveFolder)) { //Check which ones are available @@ -587,7 +589,7 @@ public class SavedStatesManager { String gamesFile = model.getInfoModel().getGamesFile(); Path gameFilePath = new File(FileManager.GAMES + gamesFile).toPath(); - Path firstSavedStatePath = new File(SAVES + gamesFile).toPath().resolve(VSZ0); + Path firstSavedStatePath = new File(SAVES + getGameFolderName(gamesFile)).toPath().resolve(VSZ0); Path tempFilePath = new File(FileManager.GAMES + "temp.gz").toPath(); try @@ -613,4 +615,24 @@ public class SavedStatesManager } return false; } + + public static String getGameFolderName(String fileName) + { + String returnValue = ""; + switch (FileManager.getConfiguredSavedStatesCarouselVersion()) + { + case PreferencesModel.CAROUSEL_132: + returnValue = fileName; + break; + case PreferencesModel.CAROUSEL_152: + if (fileName.indexOf(".") > -1) + { + returnValue = fileName.substring(0, fileName.indexOf(".")); + } + break; + default: + break; + } + return returnValue; + } } diff --git a/src/main/java/se/lantz/model/PreferencesModel.java b/src/main/java/se/lantz/model/PreferencesModel.java index dc30f7f..e8b5e04 100644 --- a/src/main/java/se/lantz/model/PreferencesModel.java +++ b/src/main/java/se/lantz/model/PreferencesModel.java @@ -7,6 +7,9 @@ import se.lantz.util.FileManager; public class PreferencesModel extends AbstractModel implements CommonInfoModel { + public static final String CAROUSEL_132 = "1.3.2"; + public static final String CAROUSEL_152 = "1.5.2"; + public static final String PCUAE_VERSION_CHECK = "checkForPCUAEVersion"; public static final String MANGER_VERSION_CHECK = "checkForManagerVersion"; public static final String GENRE = "infoSlotGenre"; @@ -20,12 +23,13 @@ public class PreferencesModel extends AbstractModel implements CommonInfoModel public static final String DESCRIPTION_IT = "infoSlotdescriptionIt"; public static final String FAVORITESCOUNT = "favoritesCount"; public static final String JOYSTICK = "joystick"; - - + public static final String SAVED_STATES_CAROUSEL = "savedStatesCarousel"; + private boolean checkPCUAEVersionAtStartup = true; private boolean checkManagerVersionAtStartup = true; - - private String description = "For more Info on PCUAE look in The Help Menu. Main keys are CTRL + F1 for The Help Menu, CTRL + F3 for Carousel Version Changer, CTRL + F5 for Mode Changer, CTRL + F7 for PCUAE Option Menu, CTRL + SHIFT + F7 for Carousel Gamelist Changer."; + + private String description = + "For more Info on PCUAE look in The Help Menu. Main keys are CTRL + F1 for The Help Menu, CTRL + F3 for Carousel Version Changer, CTRL + F5 for Mode Changer, CTRL + F7 for PCUAE Option Menu, CTRL + SHIFT + F7 for Carousel Gamelist Changer."; private String descriptionDe = ""; private String descriptionFr = ""; private String descriptionEs = ""; @@ -35,13 +39,15 @@ public class PreferencesModel extends AbstractModel implements CommonInfoModel private String author = ""; private String composer = "C64 SID Background Music"; private int favoritesCount = 10; - + private String joystickConfig = "J:2*:" + JoystickModel.DEFAULT_CONFIG; + private String savedStatesCarouselVersion = CAROUSEL_152; public PreferencesModel() { Properties configuredProperties = FileManager.getConfiguredProperties(); - setCheckManagerVersionAtStartup(Boolean.parseBoolean(configuredProperties.getProperty(MANGER_VERSION_CHECK, "true"))); + setCheckManagerVersionAtStartup(Boolean + .parseBoolean(configuredProperties.getProperty(MANGER_VERSION_CHECK, "true"))); setCheckPCUAEVersionAtStartup(Boolean.parseBoolean(configuredProperties.getProperty(PCUAE_VERSION_CHECK, "true"))); setGenre(configuredProperties.getProperty(GENRE, genre)); setAuthor(configuredProperties.getProperty(AUTHOR, author)); @@ -52,8 +58,10 @@ public class PreferencesModel extends AbstractModel implements CommonInfoModel setDescriptionEs(configuredProperties.getProperty(DESCRIPTION_ES, descriptionEs)); setDescriptionIt(configuredProperties.getProperty(DESCRIPTION_IT, descriptionIt)); setYear(Integer.parseInt(configuredProperties.getProperty(YEAR, Integer.toString(year)))); - setFavoritesCount(Integer.parseInt(configuredProperties.getProperty(FAVORITESCOUNT, Integer.toString(favoritesCount)))); + setFavoritesCount(Integer + .parseInt(configuredProperties.getProperty(FAVORITESCOUNT, Integer.toString(favoritesCount)))); setJoystickConfig(configuredProperties.getProperty(JOYSTICK, joystickConfig)); + setSavedStatesCarouselVersion(configuredProperties.getProperty(SAVED_STATES_CAROUSEL, CAROUSEL_152)); } public boolean isCheckPCUAEVersionAtStartup() @@ -104,15 +112,14 @@ public class PreferencesModel extends AbstractModel implements CommonInfoModel notifyChange(); } } - - + public String getDescriptionDe() { return descriptionDe; } public void setDescriptionDe(String descriptionDe) - { + { String old = getDescriptionDe(); //Replace all double spaces, tabs and newlines this.descriptionDe = descriptionDe.replaceAll("\\s\\s+", " "); @@ -272,12 +279,27 @@ public class PreferencesModel extends AbstractModel implements CommonInfoModel } } + public String getSavedStatesCarouselVersion() + { + return savedStatesCarouselVersion; + } + + public void setSavedStatesCarouselVersion(String savedStatesCarouselVersion) + { + String old = getSavedStatesCarouselVersion(); + this.savedStatesCarouselVersion = savedStatesCarouselVersion; + if (!Objects.equals(old, savedStatesCarouselVersion)) + { + notifyChange(); + } + } + public void savePreferences() { Properties configuredProperties = FileManager.getConfiguredProperties(); configuredProperties.put(MANGER_VERSION_CHECK, Boolean.toString(checkManagerVersionAtStartup)); configuredProperties.put(PCUAE_VERSION_CHECK, Boolean.toString(checkPCUAEVersionAtStartup)); - + configuredProperties.put(GENRE, genre); configuredProperties.put(AUTHOR, author); configuredProperties.put(COMPOSER, composer); @@ -289,6 +311,7 @@ public class PreferencesModel extends AbstractModel implements CommonInfoModel configuredProperties.put(YEAR, Integer.toString(year)); configuredProperties.put(FAVORITESCOUNT, Integer.toString(favoritesCount)); configuredProperties.put(JOYSTICK, joystickConfig); + configuredProperties.put(SAVED_STATES_CAROUSEL, savedStatesCarouselVersion); FileManager.storeProperties(); } } diff --git a/src/main/java/se/lantz/util/FileManager.java b/src/main/java/se/lantz/util/FileManager.java index 4e42266..60646f7 100644 --- a/src/main/java/se/lantz/util/FileManager.java +++ b/src/main/java/se/lantz/util/FileManager.java @@ -80,6 +80,7 @@ public class FileManager private static Properties fileProperties; private static int currentNoOfFavorites = -1; private static String currentJoystickConfig = ""; + private static String currentSavedStatesCarouselVersion = ""; private MainViewModel model; private InfoModel infoModel; @@ -625,7 +626,7 @@ public class FileManager } else { - gamePathString = SavedStatesManager.SAVES + infoModel.getGamesFile() + "/" + savedStatesModel.getState1File(); + gamePathString = SavedStatesManager.SAVES + SavedStatesManager.getGameFolderName(infoModel.getGamesFile()) + "/" + savedStatesModel.getState1File(); } } break; @@ -638,7 +639,7 @@ public class FileManager } else { - gamePathString = SavedStatesManager.SAVES + infoModel.getGamesFile() + "/" + savedStatesModel.getState2File(); + gamePathString = SavedStatesManager.SAVES + SavedStatesManager.getGameFolderName(infoModel.getGamesFile()) + "/" + savedStatesModel.getState2File(); } break; case Save2: @@ -650,7 +651,7 @@ public class FileManager } else { - gamePathString = SavedStatesManager.SAVES + infoModel.getGamesFile() + "/" + savedStatesModel.getState3File(); + gamePathString = SavedStatesManager.SAVES + SavedStatesManager.getGameFolderName(infoModel.getGamesFile()) + "/" + savedStatesModel.getState3File(); } break; case Save3: @@ -662,7 +663,7 @@ public class FileManager } else { - gamePathString = SavedStatesManager.SAVES + infoModel.getGamesFile() + "/" + savedStatesModel.getState4File(); + gamePathString = SavedStatesManager.SAVES + SavedStatesManager.getGameFolderName(infoModel.getGamesFile()) + "/" + savedStatesModel.getState4File(); } break; default: @@ -918,6 +919,7 @@ public class FileManager //Reset to load again in getConfiguredNumberOfFavorites() currentNoOfFavorites = -1; currentJoystickConfig = ""; + currentSavedStatesCarouselVersion = ""; try (OutputStream output = new FileOutputStream("./pcu.properties")) { // save properties to project root folder @@ -948,26 +950,38 @@ public class FileManager } return fileProperties; } - + public static int getConfiguredNumberOfFavorites() { //Only load once if not initialised. currentNoOfFavorites is reset when properties are stored. if (currentNoOfFavorites == -1) { - currentNoOfFavorites = Integer.parseInt(FileManager.getConfiguredProperties().getProperty(PreferencesModel.FAVORITESCOUNT, Integer.toString(10))); + currentNoOfFavorites = Integer.parseInt(FileManager.getConfiguredProperties() + .getProperty(PreferencesModel.FAVORITESCOUNT, Integer.toString(10))); } return currentNoOfFavorites; } - + public static String getConfiguredJoystickConfig() { if (currentJoystickConfig.isEmpty()) { - currentJoystickConfig = FileManager.getConfiguredProperties().getProperty(PreferencesModel.JOYSTICK, "J:2*:" + JoystickModel.DEFAULT_CONFIG); + currentJoystickConfig = FileManager.getConfiguredProperties().getProperty(PreferencesModel.JOYSTICK, + "J:2*:" + JoystickModel.DEFAULT_CONFIG); } return currentJoystickConfig; } + public static String getConfiguredSavedStatesCarouselVersion() + { + if (currentSavedStatesCarouselVersion.isEmpty()) + { + currentSavedStatesCarouselVersion = FileManager.getConfiguredProperties() + .getProperty(PreferencesModel.SAVED_STATES_CAROUSEL, PreferencesModel.CAROUSEL_152); + } + return currentSavedStatesCarouselVersion; + } + public static void backupDb(String targetFolderName) { File outputFolder = new File(BACKUP + "/" + targetFolderName + "/");