From 782d09b9cd83894b99b8a9004e55e10eb8adb321 Mon Sep 17 00:00:00 2001 From: David <67387813+ChickoonLord@users.noreply.github.com> Date: Tue, 7 Feb 2023 16:52:46 -0500 Subject: [PATCH 1/2] Failing to open file sends you back to home screen --- src/main/java/edu/rpi/legup/ui/HomePanel.java | 1 - src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/ui/HomePanel.java b/src/main/java/edu/rpi/legup/ui/HomePanel.java index 23fd2b11b..396ecd64a 100644 --- a/src/main/java/edu/rpi/legup/ui/HomePanel.java +++ b/src/main/java/edu/rpi/legup/ui/HomePanel.java @@ -68,7 +68,6 @@ public void actionPerformed(ActionEvent e) { } String fileName = (String) items[0]; File puzzleFile = (File) items[1]; - legupUI.displayPanel(2); legupUI.getPuzzleEditor().loadPuzzle(fileName, puzzleFile); } }; diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index f8dcfa4fe..7d3447bd7 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -330,11 +330,13 @@ public void loadPuzzle() { public void loadPuzzle(String fileName, File puzzleFile) { if (puzzleFile != null && puzzleFile.exists()) { try { + legupUI.displayPanel(2); GameBoardFacade.getInstance().loadPuzzleEditor(fileName); String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName(); frame.setTitle(puzzleName + " - " + puzzleFile.getName()); } catch (InvalidFileFormatException e) { + legupUI.displayPanel(0); LOGGER.error(e.getMessage()); JOptionPane.showMessageDialog(null, "File does not exist, cannot be read, or cannot be edited", "Error", JOptionPane.ERROR_MESSAGE); loadPuzzle(); From dd33db62e3076e70b94c962da50a7c174c69db27 Mon Sep 17 00:00:00 2001 From: David <67387813+ChickoonLord@users.noreply.github.com> Date: Tue, 7 Feb 2023 17:06:03 -0500 Subject: [PATCH 2/2] Failing to open puzzle proof file sends you back to home --- src/main/java/edu/rpi/legup/ui/HomePanel.java | 1 - src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/ui/HomePanel.java b/src/main/java/edu/rpi/legup/ui/HomePanel.java index 396ecd64a..8cc78afda 100644 --- a/src/main/java/edu/rpi/legup/ui/HomePanel.java +++ b/src/main/java/edu/rpi/legup/ui/HomePanel.java @@ -53,7 +53,6 @@ public void actionPerformed(ActionEvent e) { } String fileName = (String) items[0]; File puzzleFile = (File) items[1]; - legupUI.displayPanel(1); legupUI.getProofEditor().loadPuzzle(fileName, puzzleFile); } }; diff --git a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java index a62563e7b..541e44658 100644 --- a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java @@ -395,11 +395,13 @@ public void loadPuzzle() { public void loadPuzzle(String fileName, File puzzleFile) { if (puzzleFile != null && puzzleFile.exists()) { try { + legupUI.displayPanel(1); GameBoardFacade.getInstance().loadPuzzle(fileName); String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName(); frame.setTitle(puzzleName + " - " + puzzleFile.getName()); } catch (InvalidFileFormatException e) { + legupUI.displayPanel(0); LOGGER.error(e.getMessage()); if (e.getMessage().contains("Proof Tree construction error: could not find rule by ID")) { // TO DO: make error message not hardcoded JOptionPane.showMessageDialog(null, "This file runs on an outdated version of Legup\nand is not compatible with the current version.", "Error", JOptionPane.ERROR_MESSAGE);