From 049c65b2a5d9e635441d28d9c829d7829420567a Mon Sep 17 00:00:00 2001 From: Kevin Xu Date: Fri, 9 Feb 2024 17:19:33 -0500 Subject: [PATCH 1/7] one region color ripple effect --- .../rpi/legup/images/rippleeffect/regionRed.png | Bin 0 -> 953 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/main/resources/edu/rpi/legup/images/rippleeffect/regionRed.png diff --git a/src/main/resources/edu/rpi/legup/images/rippleeffect/regionRed.png b/src/main/resources/edu/rpi/legup/images/rippleeffect/regionRed.png new file mode 100644 index 0000000000000000000000000000000000000000..b9fc1756a8891590966162c0d5b910b6cde7634f GIT binary patch literal 953 zcmV;q14jIbP)a^Z&1AOkg&OcFn;sy3V)G{eEi(tn+trB!InhgF#SiSaw8Q z3+jVrhi73<;{NzG8@QKaV?b2dC_0xeC?IS^VNuSKh+xJU@CFzzshHRR2$4nSSF;hF zT9|G{FBu5Al#KL?7${QJn#sUyOH+@SMYsM^r+9a`jUq!Mx|JcFEiS)VN&)alJ@RE& zCu;_*^93l+!!zi7?7#>xh}mEv8Bmm#{!X)gBf$}~VbOjm-u#{ltOyu`taxBzC05G4 zbd2JI%@?RULaH#I5<_Jr<%|S1n5_V)+3k=qBM@(q3xeg*+-<*`;148rEUqFjrOlgRCs**F1OKhS1JjtTCH5rPaxjYrutBpg(_%ngU{qg*JLPb=3|iv`>wtcRD`q zL)UH=FeNLFhc=PvT#Z}S?x&aCj~px$tzu<^qGZIXsJXIsP=3rgIp&;CjpJ9VdafMr z)b@Q;x8?1%@|DS1pNj+?1;9fmu%eMvS7%dVs^zz&LB%htW_eDLtTp!?5tYJT!0c16 zvnFBnNgs+|&p`&P88VDxbheuH!(`u#%E4sTGp-R!w$UouYl@2d>HLjFeVVYM(S<|9 zCzsRpqP0gnnKY+eNrCnXgWKX41};pr5BV-jaHglktD5*P#Jc-zyZtUmCPv>D78Iaj z((}%kQKHG`;%^x^Ga)v-_?iP3Hp*|+Y@a?@KLWS|0`OwZhB~It4*%v$`6~eLfV?|? b`9%K*ap&e#^mId^00000NkvXXu0mjf0DP}z literal 0 HcmV?d00001 From a0b9e33ceb1b2bb61e8a083d321770deba79c983 Mon Sep 17 00:00:00 2001 From: Kevin Xu Date: Fri, 29 Mar 2024 21:35:46 -0400 Subject: [PATCH 2/7] wip --- .../edu/rpi/legup/ui/PuzzleEditorPanel.java | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index b3cd30ffb..fe3533a82 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -35,6 +35,7 @@ public class PuzzleEditorPanel extends LegupPanel implements IHistoryListener { private JMenuItem helpLegup, aboutLegup; private JMenuBar menuBar; private JToolBar toolBar; + private JFileChooser folderBrowser; private JFrame frame; private JButton[] buttons; JSplitPane splitPanel; @@ -380,25 +381,37 @@ public void loadPuzzleFromHome(String game, String[] statements) { public Object[] promptPuzzle() { GameBoardFacade facade = GameBoardFacade.getInstance(); if (facade.getBoard() != null) { - if (noQuit("Opening a new puzzle to edit?")) { + if (noQuit("Opening a new puzzle?")) { return new Object[0]; } } - if (fileDialog == null) { - fileDialog = new FileDialog(this.frame); - } + LegupPreferences preferences = LegupPreferences.getInstance(); String preferredDirectory = preferences.getUserPref(LegupPreferences.WORK_DIRECTORY); + if (preferences.getSavedPath() != "") { + preferredDirectory = preferences.getSavedPath(); + } - fileDialog.setMode(FileDialog.LOAD); - fileDialog.setTitle("Select Puzzle"); - fileDialog.setDirectory(preferredDirectory); - fileDialog.setVisible(true); + File preferredDirectoryFile = new File(preferredDirectory); + JFileChooser fileBrowser = new JFileChooser(preferredDirectoryFile); String fileName = null; File puzzleFile = null; - if (fileDialog.getDirectory() != null && fileDialog.getFile() != null) { - fileName = fileDialog.getDirectory() + File.separator + fileDialog.getFile(); - puzzleFile = new File(fileName); + + fileBrowser.showOpenDialog(this); + fileBrowser.setVisible(true); + fileBrowser.setCurrentDirectory(new File(preferredDirectory)); + fileBrowser.setDialogTitle("Select Proof File"); + fileBrowser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + fileBrowser.setAcceptAllFileFilterUsed(false); + + File puzzlePath = fileBrowser.getSelectedFile(); + System.out.println(puzzlePath.getAbsolutePath()); + + if (puzzlePath != null) { + fileName = puzzlePath.getAbsolutePath(); + String lastDirectoryPath = fileName.substring(0, fileName.lastIndexOf(File.separator)); + preferences.setSavedPath(lastDirectoryPath); + puzzleFile = puzzlePath; } else { // The attempt to prompt a puzzle ended gracefully (cancel) return null; From 7a16ca530dfcbc4267f2e4a9883c4b46f7f2fc9b Mon Sep 17 00:00:00 2001 From: Kevin Xu Date: Tue, 2 Apr 2024 17:09:21 -0400 Subject: [PATCH 3/7] remove irrelevant file --- .../rpi/legup/images/rippleeffect/regionRed.png | Bin 953 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/main/resources/edu/rpi/legup/images/rippleeffect/regionRed.png diff --git a/src/main/resources/edu/rpi/legup/images/rippleeffect/regionRed.png b/src/main/resources/edu/rpi/legup/images/rippleeffect/regionRed.png deleted file mode 100644 index b9fc1756a8891590966162c0d5b910b6cde7634f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 953 zcmV;q14jIbP)a^Z&1AOkg&OcFn;sy3V)G{eEi(tn+trB!InhgF#SiSaw8Q z3+jVrhi73<;{NzG8@QKaV?b2dC_0xeC?IS^VNuSKh+xJU@CFzzshHRR2$4nSSF;hF zT9|G{FBu5Al#KL?7${QJn#sUyOH+@SMYsM^r+9a`jUq!Mx|JcFEiS)VN&)alJ@RE& zCu;_*^93l+!!zi7?7#>xh}mEv8Bmm#{!X)gBf$}~VbOjm-u#{ltOyu`taxBzC05G4 zbd2JI%@?RULaH#I5<_Jr<%|S1n5_V)+3k=qBM@(q3xeg*+-<*`;148rEUqFjrOlgRCs**F1OKhS1JjtTCH5rPaxjYrutBpg(_%ngU{qg*JLPb=3|iv`>wtcRD`q zL)UH=FeNLFhc=PvT#Z}S?x&aCj~px$tzu<^qGZIXsJXIsP=3rgIp&;CjpJ9VdafMr z)b@Q;x8?1%@|DS1pNj+?1;9fmu%eMvS7%dVs^zz&LB%htW_eDLtTp!?5tYJT!0c16 zvnFBnNgs+|&p`&P88VDxbheuH!(`u#%E4sTGp-R!w$UouYl@2d>HLjFeVVYM(S<|9 zCzsRpqP0gnnKY+eNrCnXgWKX41};pr5BV-jaHglktD5*P#Jc-zyZtUmCPv>D78Iaj z((}%kQKHG`;%^x^Ga)v-_?iP3Hp*|+Y@a?@KLWS|0`OwZhB~It4*%v$`6~eLfV?|? b`9%K*ap&e#^mId^00000NkvXXu0mjf0DP}z From 10604c57726cb153d42e8d3a87f48351ee72e2c3 Mon Sep 17 00:00:00 2001 From: kevin Date: Fri, 12 Apr 2024 23:43:24 -0400 Subject: [PATCH 4/7] wip --- .../edu/rpi/legup/ui/ProofEditorPanel.java | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java index 956f83ba4..e8a63fe34 100644 --- a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java @@ -581,21 +581,35 @@ private void saveProofAs() { return; } - fileDialog.setMode(FileDialog.SAVE); - fileDialog.setTitle("Save As"); - String curFileName = GameBoardFacade.getInstance().getCurFileName(); - if (curFileName == null) { - fileDialog.setDirectory( - LegupPreferences.getInstance().getUserPref(LegupPreferences.WORK_DIRECTORY)); - } else { - File curFile = new File(curFileName); - fileDialog.setDirectory(curFile.getParent()); + LegupPreferences preferences = LegupPreferences.getInstance(); + String preferredDirectory = preferences.getUserPref(LegupPreferences.WORK_DIRECTORY); + if (preferences.getSavedPath() != "") { + preferredDirectory = preferences.getSavedPath(); } - fileDialog.setVisible(true); + File preferredDirectoryFile = new File(preferredDirectory); + JFileChooser fileBrowser = new JFileChooser(preferredDirectoryFile); String fileName = null; - if (fileDialog.getDirectory() != null && fileDialog.getFile() != null) { - fileName = fileDialog.getDirectory() + File.separator + fileDialog.getFile(); + File puzzleFile = null; + + fileBrowser.showOpenDialog(this); + fileBrowser.setVisible(true); + fileBrowser.setCurrentDirectory(new File(preferredDirectory)); + fileBrowser.setDialogTitle("Select Proof File"); + fileBrowser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + fileBrowser.setAcceptAllFileFilterUsed(false); + + File puzzlePath = fileBrowser.getSelectedFile(); + System.out.println(puzzlePath.getAbsolutePath()); + + if (puzzlePath != null) { + fileName = puzzlePath.getAbsolutePath(); + String lastDirectoryPath = fileName.substring(0, fileName.lastIndexOf(File.separator)); + preferences.setSavedPath(lastDirectoryPath); + puzzleFile = puzzlePath; + } else { + // The attempt to prompt a puzzle ended gracefully (cancel) + return null; } if (fileName != null) { From 1e1f70ef360caed33115a8d6518a24d92f3b0bf5 Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 16 Apr 2024 14:28:46 -0400 Subject: [PATCH 5/7] wip2 --- .../edu/rpi/legup/ui/ProofEditorPanel.java | 84 ++++++++++++++----- 1 file changed, 61 insertions(+), 23 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java index 956f83ba4..65e5e49be 100644 --- a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java @@ -581,34 +581,72 @@ private void saveProofAs() { return; } - fileDialog.setMode(FileDialog.SAVE); - fileDialog.setTitle("Save As"); - String curFileName = GameBoardFacade.getInstance().getCurFileName(); - if (curFileName == null) { - fileDialog.setDirectory( - LegupPreferences.getInstance().getUserPref(LegupPreferences.WORK_DIRECTORY)); - } else { - File curFile = new File(curFileName); - fileDialog.setDirectory(curFile.getParent()); - } - fileDialog.setVisible(true); + //=================================== - String fileName = null; - if (fileDialog.getDirectory() != null && fileDialog.getFile() != null) { - fileName = fileDialog.getDirectory() + File.separator + fileDialog.getFile(); + LegupPreferences preferences = LegupPreferences.getInstance(); + File preferredDirectory = + new File(preferences.getUserPref(LegupPreferences.WORK_DIRECTORY)); + if (preferences.getSavedPath() != "") { + preferredDirectory = new File(preferences.getSavedPath()); } + folderBrowser = new JFileChooser(preferredDirectory); - if (fileName != null) { - try { - PuzzleExporter exporter = puzzle.getExporter(); - if (exporter == null) { - throw new ExportFileException("Puzzle exporter null"); - } - exporter.exportPuzzle(fileName); - } catch (ExportFileException e) { - e.printStackTrace(); + folderBrowser.showSaveDialog(this); + folderBrowser.setVisible(true); + folderBrowser.setCurrentDirectory(new File(LegupPreferences.WORK_DIRECTORY)); + folderBrowser.setDialogTitle("Select Directory"); + folderBrowser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + folderBrowser.setAcceptAllFileFilterUsed(false); + + File folder = folderBrowser.getSelectedFile(); + + // Write csv file (Path,File-Name,Puzzle-Type,Score,Solved?) + File resultFile = new File(folder.getAbsolutePath() + File.separator + "result.csv"); + try (BufferedWriter writer = new BufferedWriter(new FileWriter(resultFile))) { + writer.append("Name,File Name,Puzzle Type,Score,Solved?\n"); + + // Go through student folders + for (final File folderEntry : + Objects.requireNonNull(folder.listFiles(File::isDirectory))) { + // Write path + String path = folderEntry.getName(); + traverseDir(folderEntry, writer, path); } + } catch (IOException ex) { + LOGGER.error(ex.getMessage()); } + + + //========================================== + +// fileDialog.setMode(FileDialog.SAVE); +// fileDialog.setTitle("Save As"); +// String curFileName = GameBoardFacade.getInstance().getCurFileName(); +// if (curFileName == null) { +// fileDialog.setDirectory( +// LegupPreferences.getInstance().getUserPref(LegupPreferences.WORK_DIRECTORY)); +// } else { +// File curFile = new File(curFileName); +// fileDialog.setDirectory(curFile.getParent()); +// } +// fileDialog.setVisible(true); +// +// String fileName = null; +// if (fileDialog.getDirectory() != null && fileDialog.getFile() != null) { +// fileName = fileDialog.getDirectory() + File.separator + fileDialog.getFile(); +// } +// +// if (fileName != null) { +// try { +// PuzzleExporter exporter = puzzle.getExporter(); +// if (exporter == null) { +// throw new ExportFileException("Puzzle exporter null"); +// } +// exporter.exportPuzzle(fileName); +// } catch (ExportFileException e) { +// e.printStackTrace(); +// } +// } } // Hyperlink for help button; links to wiki page for tutorials From 54e50c8a0041787c0a747af4cb37148e8ca34a64 Mon Sep 17 00:00:00 2001 From: Kevin Xu Date: Tue, 16 Apr 2024 15:21:22 -0400 Subject: [PATCH 6/7] save as for proof editor --- .../edu/rpi/legup/ui/ProofEditorPanel.java | 60 ++++--------------- 1 file changed, 11 insertions(+), 49 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java index 65e5e49be..8401e19f2 100644 --- a/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java @@ -580,9 +580,7 @@ private void saveProofAs() { if (puzzle == null) { return; } - - //=================================== - + LegupPreferences preferences = LegupPreferences.getInstance(); File preferredDirectory = new File(preferences.getUserPref(LegupPreferences.WORK_DIRECTORY)); @@ -598,55 +596,19 @@ private void saveProofAs() { folderBrowser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); folderBrowser.setAcceptAllFileFilterUsed(false); - File folder = folderBrowser.getSelectedFile(); + String path = folderBrowser.getSelectedFile().getAbsolutePath(); - // Write csv file (Path,File-Name,Puzzle-Type,Score,Solved?) - File resultFile = new File(folder.getAbsolutePath() + File.separator + "result.csv"); - try (BufferedWriter writer = new BufferedWriter(new FileWriter(resultFile))) { - writer.append("Name,File Name,Puzzle Type,Score,Solved?\n"); - - // Go through student folders - for (final File folderEntry : - Objects.requireNonNull(folder.listFiles(File::isDirectory))) { - // Write path - String path = folderEntry.getName(); - traverseDir(folderEntry, writer, path); + if (path != null) { + try { + PuzzleExporter exporter = puzzle.getExporter(); + if (exporter == null) { + throw new ExportFileException("Puzzle exporter null"); + } + exporter.exportPuzzle(path); + } catch (ExportFileException e) { + e.printStackTrace(); } - } catch (IOException ex) { - LOGGER.error(ex.getMessage()); } - - - //========================================== - -// fileDialog.setMode(FileDialog.SAVE); -// fileDialog.setTitle("Save As"); -// String curFileName = GameBoardFacade.getInstance().getCurFileName(); -// if (curFileName == null) { -// fileDialog.setDirectory( -// LegupPreferences.getInstance().getUserPref(LegupPreferences.WORK_DIRECTORY)); -// } else { -// File curFile = new File(curFileName); -// fileDialog.setDirectory(curFile.getParent()); -// } -// fileDialog.setVisible(true); -// -// String fileName = null; -// if (fileDialog.getDirectory() != null && fileDialog.getFile() != null) { -// fileName = fileDialog.getDirectory() + File.separator + fileDialog.getFile(); -// } -// -// if (fileName != null) { -// try { -// PuzzleExporter exporter = puzzle.getExporter(); -// if (exporter == null) { -// throw new ExportFileException("Puzzle exporter null"); -// } -// exporter.exportPuzzle(fileName); -// } catch (ExportFileException e) { -// e.printStackTrace(); -// } -// } } // Hyperlink for help button; links to wiki page for tutorials From c423e9ecd46d9291d89c650b73add57270deb334 Mon Sep 17 00:00:00 2001 From: Kevin Xu Date: Tue, 16 Apr 2024 15:30:24 -0400 Subject: [PATCH 7/7] proof editor fix --- .../edu/rpi/legup/ui/PuzzleEditorPanel.java | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java index fe3533a82..f50c8d6fc 100644 --- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java +++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java @@ -551,39 +551,35 @@ private String savePuzzle() { } } - if (fileDialog == null) { - fileDialog = new FileDialog(this.frame); + LegupPreferences preferences = LegupPreferences.getInstance(); + File preferredDirectory = + new File(preferences.getUserPref(LegupPreferences.WORK_DIRECTORY)); + if (preferences.getSavedPath() != "") { + preferredDirectory = new File(preferences.getSavedPath()); } + folderBrowser = new JFileChooser(preferredDirectory); - fileDialog.setMode(FileDialog.SAVE); - fileDialog.setTitle("Save Proof"); - String curFileName = GameBoardFacade.getInstance().getCurFileName(); - if (curFileName == null) { - fileDialog.setDirectory( - LegupPreferences.getInstance().getUserPref(LegupPreferences.WORK_DIRECTORY)); - } else { - File curFile = new File(curFileName); - fileDialog.setDirectory(curFile.getParent()); - } - fileDialog.setVisible(true); + folderBrowser.showSaveDialog(this); + folderBrowser.setVisible(true); + folderBrowser.setCurrentDirectory(new File(LegupPreferences.WORK_DIRECTORY)); + folderBrowser.setDialogTitle("Select Directory"); + folderBrowser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + folderBrowser.setAcceptAllFileFilterUsed(false); - String fileName = null; - if (fileDialog.getDirectory() != null && fileDialog.getFile() != null) { - fileName = fileDialog.getDirectory() + File.separator + fileDialog.getFile(); - } + String path = folderBrowser.getSelectedFile().getAbsolutePath(); - if (fileName != null) { + if (path != null) { try { PuzzleExporter exporter = puzzle.getExporter(); if (exporter == null) { throw new ExportFileException("Puzzle exporter null"); } - exporter.exportPuzzle(fileName); + exporter.exportPuzzle(path); } catch (ExportFileException e) { e.printStackTrace(); } } - return fileName; + return path; } public DynamicView getDynamicBoardView() {