fix: New image for saved states that are missing a screenshot

This commit is contained in:
lantzelot-swe 2021-11-20 23:35:21 +01:00
parent 178f8a0b7e
commit 7f67e09f75
2 changed files with 30 additions and 2 deletions

View File

@ -56,6 +56,7 @@ public class SaveStatePanel extends JPanel
private BufferedImage currentScreenImage = null;
private String currentGameFile = "";
private ImageIcon missingSceenshotIcon = null;
private ImageIcon noSceenshotIcon = null;
private JLabel timeLabel;
private JLabel snapshotLabel;
private JFormattedTextField timeField;
@ -287,7 +288,14 @@ public class SaveStatePanel extends JPanel
}
if (modelScreenFile.isEmpty())
{
getScreenshotLabel().setIcon(getMissingScreenshotImageIcon());
if (getSnapshotTextField().getText().isEmpty())
{
getScreenshotLabel().setIcon(getMissingScreenshotImageIcon());
}
else
{
getScreenshotLabel().setIcon(getNoScreenshotImageIcon());
}
}
else if (!model.getInfoModel().getGamesFile().equals(currentGameFile))
{
@ -317,7 +325,7 @@ public class SaveStatePanel extends JPanel
catch (IOException e)
{
logger.error("can't read file: " + filename, e);
screenLabel.setIcon(getMissingScreenshotImageIcon());
screenLabel.setIcon(getNoScreenshotImageIcon());
}
}
else
@ -326,6 +334,26 @@ public class SaveStatePanel extends JPanel
}
return image;
}
private ImageIcon getNoScreenshotImageIcon()
{
if (noSceenshotIcon == null)
{
BufferedImage image = null;
try
{
image = ImageIO.read(FileManager.class.getResource("/se/lantz/NoScreenSaveSlot.png"));
Image newImage = image.getScaledInstance(130, 82, Image.SCALE_SMOOTH);
noSceenshotIcon = new ImageIcon(newImage);
}
catch (IOException e)
{
logger.error("can't read missing icon", e);
}
}
return noSceenshotIcon;
}
private ImageIcon getMissingScreenshotImageIcon()
{

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB