feat: Add default joystick config to preferences
This commit is contained in:
parent
195ab79b49
commit
5f3e9b7e25
|
@ -154,10 +154,6 @@ public class JoystickPanel extends JPanel
|
|||
if (primaryJoyCheckBox == null)
|
||||
{
|
||||
String text = "Use port " + portnumber + " as Primary joystick";
|
||||
if (portnumber == 2)
|
||||
{
|
||||
text = text + " (Default setting)";
|
||||
}
|
||||
primaryJoyCheckBox = new JCheckBox(text);
|
||||
primaryJoyCheckBox.addItemListener((e) -> model.setPrimary(primaryJoyCheckBox.isSelected()));
|
||||
}
|
||||
|
@ -332,7 +328,7 @@ public class JoystickPanel extends JPanel
|
|||
return configPanel;
|
||||
}
|
||||
|
||||
private JCheckBox getMouseCheckBox()
|
||||
public JCheckBox getMouseCheckBox()
|
||||
{
|
||||
if (mouseCheckBox == null)
|
||||
{
|
||||
|
|
|
@ -50,7 +50,6 @@ public class InfoSlotPreferencesPanel extends JPanel
|
|||
public InfoSlotPreferencesPanel(PreferencesModel model)
|
||||
{
|
||||
this.model = model;
|
||||
this.setPreferredSize(new Dimension(335, 310));
|
||||
GridBagLayout gridBagLayout = new GridBagLayout();
|
||||
gridBagLayout.columnWeights = new double[] { 1.0, 0.0 };
|
||||
gridBagLayout.columnWidths = new int[] { 0, 0 };
|
||||
|
|
|
@ -7,37 +7,34 @@ import java.awt.Insets;
|
|||
import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.beans.Beans;
|
||||
import java.util.Calendar;
|
||||
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EtchedBorder;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
import se.lantz.model.PreferencesModel;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SpinnerModel;
|
||||
import javax.swing.SpinnerNumberModel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.border.EtchedBorder;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
public class PreferencesPanel extends JPanel
|
||||
import se.lantz.model.PreferencesModel;
|
||||
|
||||
public class MiscPanel extends JPanel
|
||||
{
|
||||
private JPanel startupPanel;
|
||||
private JPanel infoSlotPanel;
|
||||
private JCheckBox managerVersionCheckBox;
|
||||
private JCheckBox pcuaeVersionCheckBox;
|
||||
|
||||
private PreferencesModel model;
|
||||
private InfoSlotPreferencesPanel infoSlotPreferencesPanel;
|
||||
private JPanel favoritesPanel;
|
||||
private JLabel numberOfFavoritesLabel;
|
||||
private JSpinner favoritesSpinner;
|
||||
|
||||
public PreferencesPanel()
|
||||
public MiscPanel(PreferencesModel model)
|
||||
{
|
||||
model = new PreferencesModel();
|
||||
this.model = model;
|
||||
|
||||
GridBagLayout gridBagLayout = new GridBagLayout();
|
||||
setLayout(gridBagLayout);
|
||||
|
@ -50,28 +47,19 @@ public class PreferencesPanel 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.fill = GridBagConstraints.BOTH;
|
||||
gbc_favoritesPanel.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc_favoritesPanel.gridx = 0;
|
||||
gbc_favoritesPanel.gridy = 1;
|
||||
add(getFavoritesPanel(), gbc_favoritesPanel);
|
||||
GridBagConstraints gbc_infoSlotPanel = new GridBagConstraints();
|
||||
gbc_infoSlotPanel.weightx = 1.0;
|
||||
gbc_infoSlotPanel.weighty = 1.0;
|
||||
gbc_infoSlotPanel.anchor = GridBagConstraints.NORTHWEST;
|
||||
gbc_infoSlotPanel.insets = new Insets(5, 5, 0, 5);
|
||||
gbc_infoSlotPanel.fill = GridBagConstraints.BOTH;
|
||||
gbc_infoSlotPanel.gridx = 0;
|
||||
gbc_infoSlotPanel.gridy = 2;
|
||||
add(getInfoSlotPanel(), gbc_infoSlotPanel);
|
||||
if (!Beans.isDesignTime())
|
||||
{
|
||||
model.addPropertyChangeListener(e -> modelChanged());
|
||||
//Trigger an initial read from the model
|
||||
modelChanged();
|
||||
getInfoSlotPreferencesPanel().init();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,38 +98,13 @@ public class PreferencesPanel extends JPanel
|
|||
return startupPanel;
|
||||
}
|
||||
|
||||
private JPanel getInfoSlotPanel()
|
||||
{
|
||||
if (infoSlotPanel == null)
|
||||
{
|
||||
infoSlotPanel = new JPanel();
|
||||
infoSlotPanel
|
||||
.setBorder(new TitledBorder(null, "Infoslot preferences", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
GridBagLayout gbl_infoSlotPanel = new GridBagLayout();
|
||||
gbl_infoSlotPanel.columnWidths = new int[] { 0, 0 };
|
||||
gbl_infoSlotPanel.rowHeights = new int[] { 0, 0 };
|
||||
gbl_infoSlotPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
|
||||
gbl_infoSlotPanel.rowWeights = new double[] { 1.0, Double.MIN_VALUE };
|
||||
infoSlotPanel.setLayout(gbl_infoSlotPanel);
|
||||
GridBagConstraints gbc_infoSlotPreferencesPanel = new GridBagConstraints();
|
||||
gbc_infoSlotPreferencesPanel.fill = GridBagConstraints.BOTH;
|
||||
gbc_infoSlotPreferencesPanel.weighty = 1.0;
|
||||
gbc_infoSlotPreferencesPanel.weightx = 1.0;
|
||||
gbc_infoSlotPreferencesPanel.anchor = GridBagConstraints.NORTHWEST;
|
||||
gbc_infoSlotPreferencesPanel.insets = new Insets(0, 0, 0, 5);
|
||||
gbc_infoSlotPreferencesPanel.gridx = 0;
|
||||
gbc_infoSlotPreferencesPanel.gridy = 0;
|
||||
infoSlotPanel.add(getInfoSlotPreferencesPanel(), gbc_infoSlotPreferencesPanel);
|
||||
}
|
||||
return infoSlotPanel;
|
||||
}
|
||||
|
||||
private JCheckBox getManagerVersionCheckBox()
|
||||
{
|
||||
if (managerVersionCheckBox == null)
|
||||
{
|
||||
managerVersionCheckBox = new JCheckBox("Check for new version of PCUAE Manager at startup.");
|
||||
managerVersionCheckBox.addItemListener((e) -> model.setCheckManagerVersionAtStartup(managerVersionCheckBox.isSelected()));
|
||||
managerVersionCheckBox
|
||||
.addItemListener((e) -> model.setCheckManagerVersionAtStartup(managerVersionCheckBox.isSelected()));
|
||||
}
|
||||
return managerVersionCheckBox;
|
||||
}
|
||||
|
@ -151,16 +114,12 @@ public class PreferencesPanel extends JPanel
|
|||
if (pcuaeVersionCheckBox == null)
|
||||
{
|
||||
pcuaeVersionCheckBox = new JCheckBox("Check for new version of PCUAE main install at startup.");
|
||||
pcuaeVersionCheckBox.addItemListener((e) -> model.setCheckPCUAEVersionAtStartup(pcuaeVersionCheckBox.isSelected()));
|
||||
pcuaeVersionCheckBox
|
||||
.addItemListener((e) -> model.setCheckPCUAEVersionAtStartup(pcuaeVersionCheckBox.isSelected()));
|
||||
}
|
||||
return pcuaeVersionCheckBox;
|
||||
}
|
||||
|
||||
public void savePreferences()
|
||||
{
|
||||
model.savePreferences();
|
||||
}
|
||||
|
||||
private void modelChanged()
|
||||
{
|
||||
getManagerVersionCheckBox().setSelected(model.isCheckManagerVersionAtStartup());
|
||||
|
@ -170,46 +129,50 @@ public class PreferencesPanel extends JPanel
|
|||
getFavoritesSpinner().setValue(model.getFavoritesCount());
|
||||
}
|
||||
}
|
||||
private InfoSlotPreferencesPanel getInfoSlotPreferencesPanel() {
|
||||
if (infoSlotPreferencesPanel == null) {
|
||||
infoSlotPreferencesPanel = new InfoSlotPreferencesPanel(model);
|
||||
}
|
||||
return infoSlotPreferencesPanel;
|
||||
}
|
||||
private JPanel getFavoritesPanel() {
|
||||
if (favoritesPanel == null) {
|
||||
favoritesPanel = new JPanel();
|
||||
favoritesPanel.setBorder(new TitledBorder(null, "Favorites preferences", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
GridBagLayout gbl_favoritesPanel = new GridBagLayout();
|
||||
favoritesPanel.setLayout(gbl_favoritesPanel);
|
||||
GridBagConstraints gbc_numberOfFavoritesLabel = new GridBagConstraints();
|
||||
gbc_numberOfFavoritesLabel.insets = new Insets(5, 5, 5, 5);
|
||||
gbc_numberOfFavoritesLabel.gridx = 0;
|
||||
gbc_numberOfFavoritesLabel.gridy = 0;
|
||||
favoritesPanel.add(getNumberOfFavoritesLabel(), gbc_numberOfFavoritesLabel);
|
||||
GridBagConstraints gbc_favoritesSpinner = new GridBagConstraints();
|
||||
gbc_favoritesSpinner.anchor = GridBagConstraints.WEST;
|
||||
gbc_favoritesSpinner.weightx = 1.0;
|
||||
gbc_favoritesSpinner.insets = new Insets(5, 5, 5, 0);
|
||||
gbc_favoritesSpinner.gridx = 1;
|
||||
gbc_favoritesSpinner.gridy = 0;
|
||||
favoritesPanel.add(getFavoritesSpinner(), gbc_favoritesSpinner);
|
||||
|
||||
private JPanel getFavoritesPanel()
|
||||
{
|
||||
if (favoritesPanel == null)
|
||||
{
|
||||
favoritesPanel = new JPanel();
|
||||
favoritesPanel
|
||||
.setBorder(new TitledBorder(null, "Favorites preferences", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
GridBagLayout gbl_favoritesPanel = new GridBagLayout();
|
||||
favoritesPanel.setLayout(gbl_favoritesPanel);
|
||||
GridBagConstraints gbc_numberOfFavoritesLabel = new GridBagConstraints();
|
||||
gbc_numberOfFavoritesLabel.insets = new Insets(5, 5, 5, 5);
|
||||
gbc_numberOfFavoritesLabel.gridx = 0;
|
||||
gbc_numberOfFavoritesLabel.gridy = 0;
|
||||
favoritesPanel.add(getNumberOfFavoritesLabel(), gbc_numberOfFavoritesLabel);
|
||||
GridBagConstraints gbc_favoritesSpinner = new GridBagConstraints();
|
||||
gbc_favoritesSpinner.anchor = GridBagConstraints.WEST;
|
||||
gbc_favoritesSpinner.weightx = 1.0;
|
||||
gbc_favoritesSpinner.insets = new Insets(5, 5, 5, 0);
|
||||
gbc_favoritesSpinner.gridx = 1;
|
||||
gbc_favoritesSpinner.gridy = 0;
|
||||
favoritesPanel.add(getFavoritesSpinner(), gbc_favoritesSpinner);
|
||||
}
|
||||
return favoritesPanel;
|
||||
}
|
||||
private JLabel getNumberOfFavoritesLabel() {
|
||||
if (numberOfFavoritesLabel == null) {
|
||||
numberOfFavoritesLabel = new JLabel("Number of favorites lists");
|
||||
|
||||
private JLabel getNumberOfFavoritesLabel()
|
||||
{
|
||||
if (numberOfFavoritesLabel == null)
|
||||
{
|
||||
numberOfFavoritesLabel = new JLabel("Number of favorites lists");
|
||||
}
|
||||
return numberOfFavoritesLabel;
|
||||
}
|
||||
private JSpinner getFavoritesSpinner() {
|
||||
if (favoritesSpinner == null) {
|
||||
SpinnerModel spinnerModel = new SpinnerNumberModel(10, // initial value
|
||||
|
||||
private JSpinner getFavoritesSpinner()
|
||||
{
|
||||
if (favoritesSpinner == null)
|
||||
{
|
||||
SpinnerModel spinnerModel = new SpinnerNumberModel(10, // initial value
|
||||
1, // min
|
||||
10, // max
|
||||
1);
|
||||
favoritesSpinner = new JSpinner(spinnerModel);
|
||||
favoritesSpinner = new JSpinner(spinnerModel);
|
||||
JSpinner.NumberEditor numberEditor = new JSpinner.NumberEditor(favoritesSpinner, "####");
|
||||
favoritesSpinner.setEditor(numberEditor);
|
||||
// Select all when gaining focus
|
|
@ -7,30 +7,30 @@ import se.lantz.gui.BaseDialog;
|
|||
|
||||
public class PreferencesDialog extends BaseDialog
|
||||
{
|
||||
private PreferencesPanel panel;
|
||||
private PreferencesTabPanel panel;
|
||||
|
||||
public PreferencesDialog(Frame owner)
|
||||
{
|
||||
super(owner);
|
||||
setTitle("PCUAE Manager preferences");
|
||||
addContent(getPreferencesPanel());
|
||||
addContent(getPreferencesTabPanel());
|
||||
getOkButton().setText("Save");
|
||||
getOkButton().setPreferredSize(null);
|
||||
this.setPreferredSize(new Dimension(372, 570));
|
||||
this.setPreferredSize(new Dimension(366, 550));
|
||||
this.setResizable(false);
|
||||
}
|
||||
|
||||
private PreferencesPanel getPreferencesPanel()
|
||||
private PreferencesTabPanel getPreferencesTabPanel()
|
||||
{
|
||||
if (panel == null)
|
||||
{
|
||||
panel = new PreferencesPanel();
|
||||
panel = new PreferencesTabPanel();
|
||||
}
|
||||
return panel;
|
||||
}
|
||||
|
||||
public void savePreferences()
|
||||
{
|
||||
getPreferencesPanel().savePreferences();
|
||||
getPreferencesTabPanel().savePreferences();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,131 @@
|
|||
package se.lantz.gui.preferences;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTabbedPane;
|
||||
|
||||
import se.lantz.model.PreferencesModel;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.Insets;
|
||||
import se.lantz.gui.JoystickPanel;
|
||||
import se.lantz.model.JoystickModel;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
public class PreferencesTabPanel extends JPanel
|
||||
{
|
||||
private PreferencesModel model;
|
||||
private JTabbedPane tabbedPane;
|
||||
private MiscPanel miscPanel;
|
||||
private InfoSlotPreferencesPanel infoSlotPreferencesPanel;
|
||||
private JPanel infoSlotBackgroundPanel;
|
||||
private JPanel panel;
|
||||
private JPanel joystickBackgroundPanel;
|
||||
private JoystickPanel joystickPanel;
|
||||
|
||||
private JoystickModel joyModel;
|
||||
private JLabel infoLabel;
|
||||
|
||||
public PreferencesTabPanel()
|
||||
{
|
||||
this.model = new PreferencesModel();
|
||||
this.joyModel = new JoystickModel(false);
|
||||
setLayout(new BorderLayout(0, 0));
|
||||
add(getTabbedPane(), BorderLayout.CENTER);
|
||||
|
||||
getInfoSlotPreferencesPanel().init();
|
||||
}
|
||||
|
||||
private JTabbedPane getTabbedPane()
|
||||
{
|
||||
if (tabbedPane == null)
|
||||
{
|
||||
tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
||||
tabbedPane.addTab("Misc.", null, getMiscPanel(), null);
|
||||
tabbedPane.addTab("Infoslot", null, getInfoSlotBackgroundPanel(), null);
|
||||
tabbedPane.addTab("Joystick", null, getJoystickBackgroundPanel(), null);
|
||||
}
|
||||
return tabbedPane;
|
||||
}
|
||||
|
||||
private MiscPanel getMiscPanel()
|
||||
{
|
||||
if (miscPanel == null)
|
||||
{
|
||||
miscPanel = new MiscPanel(model);
|
||||
}
|
||||
return miscPanel;
|
||||
}
|
||||
|
||||
private InfoSlotPreferencesPanel getInfoSlotPreferencesPanel()
|
||||
{
|
||||
if (infoSlotPreferencesPanel == null)
|
||||
{
|
||||
infoSlotPreferencesPanel = new InfoSlotPreferencesPanel(model);
|
||||
}
|
||||
return infoSlotPreferencesPanel;
|
||||
}
|
||||
|
||||
public void savePreferences()
|
||||
{
|
||||
model.setJoystickConfig(joyModel.getConfigString());
|
||||
model.savePreferences();
|
||||
}
|
||||
|
||||
private JPanel getInfoSlotBackgroundPanel() {
|
||||
if (infoSlotBackgroundPanel == null) {
|
||||
infoSlotBackgroundPanel = new JPanel();
|
||||
GridBagLayout gbl_infoSlotBackgroundPanel = new GridBagLayout();
|
||||
infoSlotBackgroundPanel.setLayout(gbl_infoSlotBackgroundPanel);
|
||||
GridBagConstraints gbc_panel = new GridBagConstraints();
|
||||
gbc_panel.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc_panel.weighty = 1.0;
|
||||
gbc_panel.insets = new Insets(5, 5, 5, 10);
|
||||
gbc_panel.anchor = GridBagConstraints.NORTHWEST;
|
||||
gbc_panel.weightx = 1.0;
|
||||
gbc_panel.gridx = 0;
|
||||
gbc_panel.gridy = 0;
|
||||
infoSlotBackgroundPanel.add(getInfoSlotPreferencesPanel(), gbc_panel);
|
||||
}
|
||||
return infoSlotBackgroundPanel;
|
||||
}
|
||||
private JPanel getJoystickBackgroundPanel() {
|
||||
if (joystickBackgroundPanel == null) {
|
||||
joystickBackgroundPanel = new JPanel();
|
||||
GridBagLayout gbl_joystickBackgroundPanel = new GridBagLayout();
|
||||
joystickBackgroundPanel.setLayout(gbl_joystickBackgroundPanel);
|
||||
GridBagConstraints gbc_infoLabel = new GridBagConstraints();
|
||||
gbc_infoLabel.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc_infoLabel.weightx = 1.0;
|
||||
gbc_infoLabel.insets = new Insets(10, 10, 20, 9);
|
||||
gbc_infoLabel.gridx = 0;
|
||||
gbc_infoLabel.gridy = 0;
|
||||
joystickBackgroundPanel.add(getInfoLabel(), gbc_infoLabel);
|
||||
GridBagConstraints gbc_joystickPanel = new GridBagConstraints();
|
||||
gbc_joystickPanel.insets = new Insets(0, 5, 0, 5);
|
||||
gbc_joystickPanel.weighty = 1.0;
|
||||
gbc_joystickPanel.weightx = 1.0;
|
||||
gbc_joystickPanel.gridx = 0;
|
||||
gbc_joystickPanel.gridy = 1;
|
||||
joystickBackgroundPanel.add(getJoystickPanel(), gbc_joystickPanel);
|
||||
}
|
||||
return joystickBackgroundPanel;
|
||||
}
|
||||
private JoystickPanel getJoystickPanel() {
|
||||
if (joystickPanel == null) {
|
||||
joystickPanel = new JoystickPanel(2, joyModel);
|
||||
//Don't allow mouse as default
|
||||
joystickPanel.getMouseCheckBox().setVisible(false);
|
||||
//Set initial value
|
||||
joyModel.setConfigStringFromDb(model.getJoystickConfig());
|
||||
}
|
||||
return joystickPanel;
|
||||
}
|
||||
private JLabel getInfoLabel() {
|
||||
if (infoLabel == null) {
|
||||
infoLabel = new JLabel("<html>Specify the default joystick configuration to use when adding new games. Port 1 and Port 2 uses the same mapping.</html>");
|
||||
}
|
||||
return infoLabel;
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@ public class PreferencesModel extends AbstractModel implements CommonInfoModel
|
|||
public static final String DESCRIPTION_ES = "infoSlotdescriptionEs";
|
||||
public static final String DESCRIPTION_IT = "infoSlotdescriptionIt";
|
||||
public static final String FAVORITESCOUNT = "favoritesCount";
|
||||
public static final String JOYSTICK = "joystick";
|
||||
|
||||
|
||||
private boolean checkPCUAEVersionAtStartup = true;
|
||||
|
@ -35,6 +36,8 @@ public class PreferencesModel extends AbstractModel implements CommonInfoModel
|
|||
private String composer = "C64 SID Background Music";
|
||||
private int favoritesCount = 10;
|
||||
|
||||
private String joystickConfig = "J:2*:" + JoystickModel.DEFAULT_CONFIG;
|
||||
|
||||
public PreferencesModel()
|
||||
{
|
||||
Properties configuredProperties = FileManager.getConfiguredProperties();
|
||||
|
@ -50,6 +53,7 @@ public class PreferencesModel extends AbstractModel implements CommonInfoModel
|
|||
setDescriptionIt(configuredProperties.getProperty(DESCRIPTION_IT, descriptionIt));
|
||||
setYear(Integer.parseInt(configuredProperties.getProperty(YEAR, Integer.toString(year))));
|
||||
setFavoritesCount(Integer.parseInt(configuredProperties.getProperty(FAVORITESCOUNT, Integer.toString(favoritesCount))));
|
||||
setJoystickConfig(configuredProperties.getProperty(JOYSTICK, joystickConfig));
|
||||
}
|
||||
|
||||
public boolean isCheckPCUAEVersionAtStartup()
|
||||
|
@ -253,6 +257,21 @@ public class PreferencesModel extends AbstractModel implements CommonInfoModel
|
|||
}
|
||||
}
|
||||
|
||||
public String getJoystickConfig()
|
||||
{
|
||||
return joystickConfig;
|
||||
}
|
||||
|
||||
public void setJoystickConfig(String joystickConfig)
|
||||
{
|
||||
String old = getJoystickConfig();
|
||||
this.joystickConfig = joystickConfig;
|
||||
if (!Objects.equals(old, joystickConfig))
|
||||
{
|
||||
notifyChange();
|
||||
}
|
||||
}
|
||||
|
||||
public void savePreferences()
|
||||
{
|
||||
Properties configuredProperties = FileManager.getConfiguredProperties();
|
||||
|
@ -269,6 +288,7 @@ public class PreferencesModel extends AbstractModel implements CommonInfoModel
|
|||
configuredProperties.put(DESCRIPTION_IT, descriptionIt);
|
||||
configuredProperties.put(YEAR, Integer.toString(year));
|
||||
configuredProperties.put(FAVORITESCOUNT, Integer.toString(favoritesCount));
|
||||
configuredProperties.put(JOYSTICK, joystickConfig);
|
||||
FileManager.storeProperties();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package se.lantz.model.data;
|
||||
|
||||
import se.lantz.model.JoystickModel;
|
||||
import se.lantz.util.FileManager;
|
||||
|
||||
/**
|
||||
* The data structure representing a specific game.
|
||||
|
@ -33,8 +34,11 @@ public class GameDetails
|
|||
|
||||
public GameDetails()
|
||||
{
|
||||
setJoy1("J:1:" + JoystickModel.DEFAULT_CONFIG);
|
||||
setJoy2("J:2*:" + JoystickModel.DEFAULT_CONFIG);
|
||||
String configuredJoystick = FileManager.getConfiguredJoystickConfig();
|
||||
String joy1 = configuredJoystick.replace("J:2*:", "J:1:");
|
||||
joy1 = joy1.replace("J:2:", "J:1*:");
|
||||
setJoy1(joy1);
|
||||
setJoy2(configuredJoystick);
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
|
|
|
@ -48,6 +48,7 @@ import se.lantz.db.DbConnector;
|
|||
import se.lantz.gui.exports.PublishWorker;
|
||||
import se.lantz.manager.SavedStatesManager;
|
||||
import se.lantz.model.InfoModel;
|
||||
import se.lantz.model.JoystickModel;
|
||||
import se.lantz.model.MainViewModel;
|
||||
import se.lantz.model.PreferencesModel;
|
||||
import se.lantz.model.SavedStatesModel;
|
||||
|
@ -78,6 +79,7 @@ public class FileManager
|
|||
|
||||
private static Properties fileProperties;
|
||||
private static int currentNoOfFavorites = -1;
|
||||
private static String currentJoystickConfig = "";
|
||||
|
||||
private MainViewModel model;
|
||||
private InfoModel infoModel;
|
||||
|
@ -915,6 +917,7 @@ public class FileManager
|
|||
{
|
||||
//Reset to load again in getConfiguredNumberOfFavorites()
|
||||
currentNoOfFavorites = -1;
|
||||
currentJoystickConfig = "";
|
||||
try (OutputStream output = new FileOutputStream("./pcu.properties"))
|
||||
{
|
||||
// save properties to project root folder
|
||||
|
@ -956,6 +959,15 @@ public class FileManager
|
|||
return currentNoOfFavorites;
|
||||
}
|
||||
|
||||
public static String getConfiguredJoystickConfig()
|
||||
{
|
||||
if (currentJoystickConfig.isEmpty())
|
||||
{
|
||||
currentJoystickConfig = FileManager.getConfiguredProperties().getProperty(PreferencesModel.JOYSTICK, "J:2*:" + JoystickModel.DEFAULT_CONFIG);
|
||||
}
|
||||
return currentJoystickConfig;
|
||||
}
|
||||
|
||||
public static void backupDb(String targetFolderName)
|
||||
{
|
||||
File outputFolder = new File(BACKUP + "/" + targetFolderName + "/");
|
||||
|
|
Loading…
Reference in New Issue