From f9582611f33cda9be002c8adefede4ff5fe44007 Mon Sep 17 00:00:00 2001 From: lantzelot-swe Date: Tue, 5 Jan 2021 22:51:39 +0100 Subject: [PATCH] fix: changing info for a game whith the same screenshot for 1 and 2 works better --- src/main/java/se/lantz/gui/SystemPanel.java | 4 +-- src/main/java/se/lantz/model/InfoModel.java | 39 +++++++++++---------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/main/java/se/lantz/gui/SystemPanel.java b/src/main/java/se/lantz/gui/SystemPanel.java index 028e808..3c51ef6 100644 --- a/src/main/java/se/lantz/gui/SystemPanel.java +++ b/src/main/java/se/lantz/gui/SystemPanel.java @@ -440,7 +440,7 @@ public class SystemPanel extends JPanel gbc_configLabel.gridheight = 2; gbc_configLabel.weighty = 1.0; gbc_configLabel.anchor = GridBagConstraints.NORTHWEST; - gbc_configLabel.insets = new Insets(59, 5, 5, 5); + gbc_configLabel.insets = new Insets(62, 5, 5, 5); gbc_configLabel.gridx = 0; gbc_configLabel.gridy = 0; configPanel.add(getConfigLabel(), gbc_configLabel); @@ -448,7 +448,7 @@ public class SystemPanel extends JPanel gbc_configTextField.weighty = 1.0; gbc_configTextField.fill = GridBagConstraints.HORIZONTAL; gbc_configTextField.weightx = 1.0; - gbc_configTextField.insets = new Insets(42, 0, 5, 0); + gbc_configTextField.insets = new Insets(45, 0, 5, 0); gbc_configTextField.anchor = GridBagConstraints.NORTHWEST; gbc_configTextField.gridx = 1; gbc_configTextField.gridy = 1; diff --git a/src/main/java/se/lantz/model/InfoModel.java b/src/main/java/se/lantz/model/InfoModel.java index 055ff4b..9599145 100644 --- a/src/main/java/se/lantz/model/InfoModel.java +++ b/src/main/java/se/lantz/model/InfoModel.java @@ -266,26 +266,29 @@ public class InfoModel extends AbstractModel public void updateFileNames() { - disableChangeNotification(true); - String fileName = FileManager.generateFileNameFromTitle(this.title); - if (!getCoverFile().isEmpty() || getCoverImage() != null) + if (isNewGame() || isTitleChanged()) { - setCoverFile(fileName + "-cover.png"); + disableChangeNotification(true); + String fileName = FileManager.generateFileNameFromTitle(this.title); + if (!getCoverFile().isEmpty() || getCoverImage() != null) + { + setCoverFile(fileName + "-cover.png"); + } + if (!getScreens1File().isEmpty() || getScreen1Image() != null) + { + setScreens1File(fileName + "-00.png"); + } + if (!getScreens2File().isEmpty() || getScreen2Image() != null) + { + setScreens2File(fileName + "-01.png"); + } + if (!getGamesFile().isEmpty()) + { + String fileEnding = getGamesFile().substring(getGamesFile().indexOf(".")); + setGamesFile(fileName + fileEnding); + } + disableChangeNotification(false); } - if (!getScreens1File().isEmpty() || getScreen1Image() != null) - { - setScreens1File(fileName + "-00.png"); - } - if (!getScreens2File().isEmpty() || getScreen2Image() != null) - { - setScreens2File(fileName + "-01.png"); - } - if (!getGamesFile().isEmpty()) - { - String fileEnding = getGamesFile().substring(getGamesFile().indexOf(".")); - setGamesFile(fileName + fileEnding); - } - disableChangeNotification(false); } public boolean isNewGame()