Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go back to home screen when close puzzle file explore #436

Merged
merged 3 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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