feat: Configure Carousel version for saved states

The saved states folders differ in name for different carousels, an option to configure which version to show saved states for has been added to the preferences dialog.
This commit is contained in:
lantzelot-swe 2022-01-14 22:14:53 +01:00
parent 5f3e9b7e25
commit af69512a6f
11 changed files with 257 additions and 33 deletions

View File

@ -44,6 +44,7 @@ import se.lantz.manager.ScraperManager;
import se.lantz.model.MainViewModel; import se.lantz.model.MainViewModel;
import se.lantz.model.data.GameListData; import se.lantz.model.data.GameListData;
import se.lantz.model.data.ScraperFields; import se.lantz.model.data.ScraperFields;
import se.lantz.util.FileManager;
public class GameDetailsBackgroundPanel extends JPanel public class GameDetailsBackgroundPanel extends JPanel
{ {
@ -188,6 +189,7 @@ public class GameDetailsBackgroundPanel extends JPanel
systemSavesTabbedPane = new JTabbedPane(); systemSavesTabbedPane = new JTabbedPane();
systemSavesTabbedPane.addTab("System Settings", getSystemPanel()); systemSavesTabbedPane.addTab("System Settings", getSystemPanel());
systemSavesTabbedPane.addTab("Saved states", getSavesBackgroundPanel()); systemSavesTabbedPane.addTab("Saved states", getSavesBackgroundPanel());
updateSavedStatesTabTitle();
} }
return systemSavesTabbedPane; return systemSavesTabbedPane;
} }
@ -500,4 +502,11 @@ public class GameDetailsBackgroundPanel extends JPanel
return false; return false;
} }
} }
public void updateSavedStatesTabTitle()
{
String carouselVersion = FileManager.getConfiguredSavedStatesCarouselVersion();
getSystemSavesTabbedPane().setTitleAt(1, "Saved States (Carousel " + carouselVersion + ")");
getSavesBackgroundPanel().resetCurrentGameReference();
}
} }

View File

@ -260,4 +260,9 @@ public class MainPanel extends JPanel
{ {
getListPanel().reloadCurrentGameView(); getListPanel().reloadCurrentGameView();
} }
public void updateSavedStatesTabTitle()
{
getGameDetailsBackgroundPanel().updateSavedStatesTabTitle();
}
} }

View File

@ -99,14 +99,16 @@ public final class MainWindow extends JFrame
return menuBar; return menuBar;
} }
public void refreshFavoritesLists() public void refreshAfterPreferencesSave()
{ {
getJMenuBar().removeAll(); getJMenuBar().removeAll();
for (JMenu menu : menuManager.getMenues()) for (JMenu menu : menuManager.getMenues())
{ {
menuBar.add(menu); menuBar.add(menu);
} }
getMainPanel().reloadCurrentGameView(); getMainPanel().reloadCurrentGameView();
getMainPanel().updateSavedStatesTabTitle();
SwingUtilities.updateComponentTreeUI(this); SwingUtilities.updateComponentTreeUI(this);
repaintAfterModifications(); repaintAfterModifications();
} }

View File

@ -1109,7 +1109,7 @@ public class MenuManager
prefDialog.savePreferences(); prefDialog.savePreferences();
//Update favorites menu //Update favorites menu
setupEditMenu(); setupEditMenu();
MainWindow.getInstance().refreshFavoritesLists(); MainWindow.getInstance().refreshAfterPreferencesSave();
//Refresh game views //Refresh game views
uiModel.reloadGameViews(); uiModel.reloadGameViews();
//Set all games as selected //Set all games as selected

View File

@ -80,4 +80,12 @@ public class SaveStateBackgroundPanel extends JPanel
getSaveStatePanel3().commitEdits(); getSaveStatePanel3().commitEdits();
getSaveStatePanel4().commitEdits(); getSaveStatePanel4().commitEdits();
} }
void resetCurrentGameReference()
{
getSaveStatePanel1().resetCurrentGameReference();
getSaveStatePanel2().resetCurrentGameReference();
getSaveStatePanel3().resetCurrentGameReference();
getSaveStatePanel4().resetCurrentGameReference();
}
} }

View File

@ -311,7 +311,7 @@ public class SaveStatePanel extends JPanel
BufferedImage image = null; BufferedImage image = null;
if (!filename.isEmpty()) if (!filename.isEmpty())
{ {
String fileName = model.getInfoModel().getGamesFile(); String fileName = SavedStatesManager.getGameFolderName(model.getInfoModel().getGamesFile());
logger.debug(fileName.toString()); logger.debug(fileName.toString());
Path saveFolderPath = new File("./saves/" + fileName).toPath(); Path saveFolderPath = new File("./saves/" + fileName).toPath();
@ -857,4 +857,9 @@ public class SaveStatePanel extends JPanel
} }
return deleteButton; return deleteButton;
} }
void resetCurrentGameReference()
{
this.currentGameFile = "";
}
} }

View File

@ -31,15 +31,18 @@ public class MiscPanel extends JPanel
private JPanel favoritesPanel; private JPanel favoritesPanel;
private JLabel numberOfFavoritesLabel; private JLabel numberOfFavoritesLabel;
private JSpinner favoritesSpinner; private JSpinner favoritesSpinner;
private SaveStatePrefPanel saveStatePrefPanel;
public MiscPanel(PreferencesModel model) public MiscPanel(PreferencesModel model)
{ {
this.model = model; this.model = model;
GridBagLayout gridBagLayout = new GridBagLayout(); GridBagLayout gridBagLayout = new GridBagLayout();
gridBagLayout.rowWeights = new double[]{0.0, 0.0, 1.0};
gridBagLayout.columnWeights = new double[]{1.0};
setLayout(gridBagLayout); setLayout(gridBagLayout);
GridBagConstraints gbc_startupPanel = new GridBagConstraints(); 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.weightx = 1.0;
gbc_startupPanel.anchor = GridBagConstraints.NORTHWEST; gbc_startupPanel.anchor = GridBagConstraints.NORTHWEST;
gbc_startupPanel.fill = GridBagConstraints.BOTH; gbc_startupPanel.fill = GridBagConstraints.BOTH;
@ -47,14 +50,21 @@ public class MiscPanel extends JPanel
gbc_startupPanel.gridy = 0; gbc_startupPanel.gridy = 0;
add(getStartupPanel(), gbc_startupPanel); add(getStartupPanel(), gbc_startupPanel);
GridBagConstraints gbc_favoritesPanel = new GridBagConstraints(); GridBagConstraints gbc_favoritesPanel = new GridBagConstraints();
gbc_favoritesPanel.weighty = 1.0;
gbc_favoritesPanel.anchor = GridBagConstraints.NORTHWEST; gbc_favoritesPanel.anchor = GridBagConstraints.NORTHWEST;
gbc_favoritesPanel.weightx = 1.0; 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.fill = GridBagConstraints.HORIZONTAL;
gbc_favoritesPanel.gridx = 0; gbc_favoritesPanel.gridx = 0;
gbc_favoritesPanel.gridy = 1; gbc_favoritesPanel.gridy = 1;
add(getFavoritesPanel(), gbc_favoritesPanel); 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()) if (!Beans.isDesignTime())
{ {
model.addPropertyChangeListener(e -> modelChanged()); model.addPropertyChangeListener(e -> modelChanged());
@ -195,4 +205,12 @@ public class MiscPanel extends JPanel
} }
return favoritesSpinner; 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;
}
} }

View File

@ -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 = "<html>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.</html>";
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));
}
}

View File

@ -26,6 +26,7 @@ import org.slf4j.LoggerFactory;
import se.lantz.gui.exports.PublishWorker; import se.lantz.gui.exports.PublishWorker;
import se.lantz.model.MainViewModel; import se.lantz.model.MainViewModel;
import se.lantz.model.PreferencesModel;
import se.lantz.model.SavedStatesModel; import se.lantz.model.SavedStatesModel;
import se.lantz.model.SavedStatesModel.SAVESTATE; import se.lantz.model.SavedStatesModel.SAVESTATE;
import se.lantz.util.ExceptionHandler; 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 //If the game has been renamed, make sure to rename the saves folder also
String oldFileName = model.getInfoModel().getOldGamesFile(); String oldFileName = model.getInfoModel().getOldGamesFile();
String newFileName = model.getInfoModel().getGamesFile(); String newFileName = model.getInfoModel().getGamesFile();
File oldSaveFolder = new File(SAVES + oldFileName); File oldSaveFolder = new File(SAVES + getGameFolderName(oldFileName));
if (!oldFileName.equals(newFileName) && oldSaveFolder.exists()) if (!oldFileName.equals(newFileName) && oldSaveFolder.exists())
{ {
//Rename old folder to new name //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(); String fileName = model.getInfoModel().getGamesFile();
Path saveFolder = new File(SAVES + fileName).toPath(); Path saveFolder = new File(SAVES + getGameFolderName(fileName)).toPath();
int numberofSaves = 0; int numberofSaves = 0;
//Check which ones are available //Check which ones are available
Path mta0Path = saveFolder.resolve(MTA0); Path mta0Path = saveFolder.resolve(MTA0);
@ -161,7 +162,7 @@ public class SavedStatesManager
{ {
savedStatesModel.resetProperties(); savedStatesModel.resetProperties();
//Read from state directory, update model //Read from state directory, update model
String fileName = model.getInfoModel().getGamesFile(); String fileName = getGameFolderName(model.getInfoModel().getGamesFile());
if (!fileName.isEmpty()) if (!fileName.isEmpty())
{ {
//Check if folder is available //Check if folder is available
@ -330,7 +331,7 @@ public class SavedStatesManager
private void deleteSavedState(SAVESTATE state) private void deleteSavedState(SAVESTATE state)
{ {
String fileName = model.getInfoModel().getGamesFile(); String fileName = getGameFolderName(model.getInfoModel().getGamesFile());
Path saveFolder = new File(SAVES + fileName).toPath(); Path saveFolder = new File(SAVES + fileName).toPath();
try try
{ {
@ -554,7 +555,8 @@ public class SavedStatesManager
public int getNumberOfSavedStatesForGame(String gameFileName) 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) public void checkEnablementOfPalNtscMenuItem(boolean check)
@ -568,7 +570,7 @@ public class SavedStatesManager
if (!fileName.isEmpty() && fileName.contains(".vsf")) if (!fileName.isEmpty() && fileName.contains(".vsf"))
{ {
//Check if folder is available //Check if folder is available
Path saveFolder = new File(SAVES + fileName).toPath(); Path saveFolder = new File(SAVES + getGameFolderName(fileName)).toPath();
if (Files.exists(saveFolder)) if (Files.exists(saveFolder))
{ {
//Check which ones are available //Check which ones are available
@ -587,7 +589,7 @@ public class SavedStatesManager
{ {
String gamesFile = model.getInfoModel().getGamesFile(); String gamesFile = model.getInfoModel().getGamesFile();
Path gameFilePath = new File(FileManager.GAMES + gamesFile).toPath(); 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(); Path tempFilePath = new File(FileManager.GAMES + "temp.gz").toPath();
try try
@ -613,4 +615,24 @@ public class SavedStatesManager
} }
return false; 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;
}
} }

View File

@ -7,6 +7,9 @@ import se.lantz.util.FileManager;
public class PreferencesModel extends AbstractModel implements CommonInfoModel 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 PCUAE_VERSION_CHECK = "checkForPCUAEVersion";
public static final String MANGER_VERSION_CHECK = "checkForManagerVersion"; public static final String MANGER_VERSION_CHECK = "checkForManagerVersion";
public static final String GENRE = "infoSlotGenre"; 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 DESCRIPTION_IT = "infoSlotdescriptionIt";
public static final String FAVORITESCOUNT = "favoritesCount"; public static final String FAVORITESCOUNT = "favoritesCount";
public static final String JOYSTICK = "joystick"; public static final String JOYSTICK = "joystick";
public static final String SAVED_STATES_CAROUSEL = "savedStatesCarousel";
private boolean checkPCUAEVersionAtStartup = true; private boolean checkPCUAEVersionAtStartup = true;
private boolean checkManagerVersionAtStartup = 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 descriptionDe = "";
private String descriptionFr = ""; private String descriptionFr = "";
private String descriptionEs = ""; private String descriptionEs = "";
@ -35,13 +39,15 @@ public class PreferencesModel extends AbstractModel implements CommonInfoModel
private String author = ""; private String author = "";
private String composer = "C64 SID Background Music"; private String composer = "C64 SID Background Music";
private int favoritesCount = 10; private int favoritesCount = 10;
private String joystickConfig = "J:2*:" + JoystickModel.DEFAULT_CONFIG; private String joystickConfig = "J:2*:" + JoystickModel.DEFAULT_CONFIG;
private String savedStatesCarouselVersion = CAROUSEL_152;
public PreferencesModel() public PreferencesModel()
{ {
Properties configuredProperties = FileManager.getConfiguredProperties(); 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"))); setCheckPCUAEVersionAtStartup(Boolean.parseBoolean(configuredProperties.getProperty(PCUAE_VERSION_CHECK, "true")));
setGenre(configuredProperties.getProperty(GENRE, genre)); setGenre(configuredProperties.getProperty(GENRE, genre));
setAuthor(configuredProperties.getProperty(AUTHOR, author)); setAuthor(configuredProperties.getProperty(AUTHOR, author));
@ -52,8 +58,10 @@ public class PreferencesModel extends AbstractModel implements CommonInfoModel
setDescriptionEs(configuredProperties.getProperty(DESCRIPTION_ES, descriptionEs)); setDescriptionEs(configuredProperties.getProperty(DESCRIPTION_ES, descriptionEs));
setDescriptionIt(configuredProperties.getProperty(DESCRIPTION_IT, descriptionIt)); setDescriptionIt(configuredProperties.getProperty(DESCRIPTION_IT, descriptionIt));
setYear(Integer.parseInt(configuredProperties.getProperty(YEAR, Integer.toString(year)))); 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)); setJoystickConfig(configuredProperties.getProperty(JOYSTICK, joystickConfig));
setSavedStatesCarouselVersion(configuredProperties.getProperty(SAVED_STATES_CAROUSEL, CAROUSEL_152));
} }
public boolean isCheckPCUAEVersionAtStartup() public boolean isCheckPCUAEVersionAtStartup()
@ -104,15 +112,14 @@ public class PreferencesModel extends AbstractModel implements CommonInfoModel
notifyChange(); notifyChange();
} }
} }
public String getDescriptionDe() public String getDescriptionDe()
{ {
return descriptionDe; return descriptionDe;
} }
public void setDescriptionDe(String descriptionDe) public void setDescriptionDe(String descriptionDe)
{ {
String old = getDescriptionDe(); String old = getDescriptionDe();
//Replace all double spaces, tabs and newlines //Replace all double spaces, tabs and newlines
this.descriptionDe = descriptionDe.replaceAll("\\s\\s+", " "); 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() public void savePreferences()
{ {
Properties configuredProperties = FileManager.getConfiguredProperties(); Properties configuredProperties = FileManager.getConfiguredProperties();
configuredProperties.put(MANGER_VERSION_CHECK, Boolean.toString(checkManagerVersionAtStartup)); configuredProperties.put(MANGER_VERSION_CHECK, Boolean.toString(checkManagerVersionAtStartup));
configuredProperties.put(PCUAE_VERSION_CHECK, Boolean.toString(checkPCUAEVersionAtStartup)); configuredProperties.put(PCUAE_VERSION_CHECK, Boolean.toString(checkPCUAEVersionAtStartup));
configuredProperties.put(GENRE, genre); configuredProperties.put(GENRE, genre);
configuredProperties.put(AUTHOR, author); configuredProperties.put(AUTHOR, author);
configuredProperties.put(COMPOSER, composer); configuredProperties.put(COMPOSER, composer);
@ -289,6 +311,7 @@ public class PreferencesModel extends AbstractModel implements CommonInfoModel
configuredProperties.put(YEAR, Integer.toString(year)); configuredProperties.put(YEAR, Integer.toString(year));
configuredProperties.put(FAVORITESCOUNT, Integer.toString(favoritesCount)); configuredProperties.put(FAVORITESCOUNT, Integer.toString(favoritesCount));
configuredProperties.put(JOYSTICK, joystickConfig); configuredProperties.put(JOYSTICK, joystickConfig);
configuredProperties.put(SAVED_STATES_CAROUSEL, savedStatesCarouselVersion);
FileManager.storeProperties(); FileManager.storeProperties();
} }
} }

View File

@ -80,6 +80,7 @@ public class FileManager
private static Properties fileProperties; private static Properties fileProperties;
private static int currentNoOfFavorites = -1; private static int currentNoOfFavorites = -1;
private static String currentJoystickConfig = ""; private static String currentJoystickConfig = "";
private static String currentSavedStatesCarouselVersion = "";
private MainViewModel model; private MainViewModel model;
private InfoModel infoModel; private InfoModel infoModel;
@ -625,7 +626,7 @@ public class FileManager
} }
else else
{ {
gamePathString = SavedStatesManager.SAVES + infoModel.getGamesFile() + "/" + savedStatesModel.getState1File(); gamePathString = SavedStatesManager.SAVES + SavedStatesManager.getGameFolderName(infoModel.getGamesFile()) + "/" + savedStatesModel.getState1File();
} }
} }
break; break;
@ -638,7 +639,7 @@ public class FileManager
} }
else else
{ {
gamePathString = SavedStatesManager.SAVES + infoModel.getGamesFile() + "/" + savedStatesModel.getState2File(); gamePathString = SavedStatesManager.SAVES + SavedStatesManager.getGameFolderName(infoModel.getGamesFile()) + "/" + savedStatesModel.getState2File();
} }
break; break;
case Save2: case Save2:
@ -650,7 +651,7 @@ public class FileManager
} }
else else
{ {
gamePathString = SavedStatesManager.SAVES + infoModel.getGamesFile() + "/" + savedStatesModel.getState3File(); gamePathString = SavedStatesManager.SAVES + SavedStatesManager.getGameFolderName(infoModel.getGamesFile()) + "/" + savedStatesModel.getState3File();
} }
break; break;
case Save3: case Save3:
@ -662,7 +663,7 @@ public class FileManager
} }
else else
{ {
gamePathString = SavedStatesManager.SAVES + infoModel.getGamesFile() + "/" + savedStatesModel.getState4File(); gamePathString = SavedStatesManager.SAVES + SavedStatesManager.getGameFolderName(infoModel.getGamesFile()) + "/" + savedStatesModel.getState4File();
} }
break; break;
default: default:
@ -918,6 +919,7 @@ public class FileManager
//Reset to load again in getConfiguredNumberOfFavorites() //Reset to load again in getConfiguredNumberOfFavorites()
currentNoOfFavorites = -1; currentNoOfFavorites = -1;
currentJoystickConfig = ""; currentJoystickConfig = "";
currentSavedStatesCarouselVersion = "";
try (OutputStream output = new FileOutputStream("./pcu.properties")) try (OutputStream output = new FileOutputStream("./pcu.properties"))
{ {
// save properties to project root folder // save properties to project root folder
@ -948,26 +950,38 @@ public class FileManager
} }
return fileProperties; return fileProperties;
} }
public static int getConfiguredNumberOfFavorites() public static int getConfiguredNumberOfFavorites()
{ {
//Only load once if not initialised. currentNoOfFavorites is reset when properties are stored. //Only load once if not initialised. currentNoOfFavorites is reset when properties are stored.
if (currentNoOfFavorites == -1) 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; return currentNoOfFavorites;
} }
public static String getConfiguredJoystickConfig() public static String getConfiguredJoystickConfig()
{ {
if (currentJoystickConfig.isEmpty()) 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; 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) public static void backupDb(String targetFolderName)
{ {
File outputFolder = new File(BACKUP + "/" + targetFolderName + "/"); File outputFolder = new File(BACKUP + "/" + targetFolderName + "/");