Skip to content

Commit

Permalink
Merge pull request #436 from ChickoonLord/master
Browse files Browse the repository at this point in the history
Go back to home screen when close puzzle file explore
  • Loading branch information
Corppet authored Feb 7, 2023
2 parents b32a355 + 1e0e713 commit bc49d60
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/main/java/edu/rpi/legup/ui/HomePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};
Expand All @@ -68,7 +67,6 @@ public void actionPerformed(ActionEvent e) {
}
String fileName = (String) items[0];
File puzzleFile = (File) items[1];
legupUI.displayPanel(2);
legupUI.getPuzzleEditor().loadPuzzle(fileName, puzzleFile);
}
};
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit bc49d60

Please sign in to comment.