Skip to content

Commit

Permalink
Revert "started functionality for creating empty puzzles"
Browse files Browse the repository at this point in the history
This reverts commit afceb4d.
  • Loading branch information
mattsweet417 committed Jun 24, 2022
1 parent afceb4d commit f385d60
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 60 deletions.
35 changes: 0 additions & 35 deletions src/main/java/edu/rpi/legup/app/GameBoardFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,41 +96,6 @@ public void setConfig(Config config) {
this.config = config;
}

/**
* Loads an empty puzzle
*
* @param game name of the puzzle
* @param width width of the puzzle
* @param height height of the puzzle
*/
public void loadPuzzle(String game, int width, int height) throws RuntimeException {
setWindowTitle(puzzle.getName(), "New " + puzzle.getName() + " Puzzle");
String qualifiedClassName = config.getPuzzleClassForName(game);
LOGGER.debug("Loading " + qualifiedClassName);

try {
Class<?> c = Class.forName(qualifiedClassName);
Constructor<?> cons = c.getConstructor();
Puzzle puzzle = (Puzzle) cons.newInstance();

PuzzleImporter importer = puzzle.getImporter();
if (importer == null) {
LOGGER.error("Puzzle importer is null");
throw new RuntimeException("Puzzle importer null");
}

importer.initializePuzzle(width, height);
puzzle.initializeView();
puzzle.getBoardView().onTreeElementChanged(puzzle.getTree().getRootNode());
setPuzzle(puzzle);
}
catch(ClassNotFoundException | NoSuchMethodException | InvocationTargetException |
IllegalAccessException | InstantiationException e) {
LOGGER.error(e);
throw new RuntimeException("Puzzle creation error");
}
}

/**
* Loads a puzzle file
*
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/edu/rpi/legup/model/PuzzleImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,6 @@ public PuzzleImporter(Puzzle puzzle) {
this.puzzle = puzzle;
}

/**
* Initializes an empty puzzle
*
* @param width width of puzzle
* @param height height of puzzle
* @throws RuntimeException
*/
public void initializePuzzle(int width, int height) throws RuntimeException {

}

/**
* Initializes the puzzle attributes
*
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void initPuzzles() {
public void actionPerformed(ActionEvent e) {
if (e.getSource() == ok) {
String game = (String) gameBox.getSelectedItem();
this.homePanel.openEditorWithNewPuzzle(game, Integer.valueOf(width.getText()), Integer.valueOf(height.getText()));
this.homePanel.openEditorWithNewPuzzle(game);
setVisible(false);
}
else if (e.getSource() == cancel) {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/edu/rpi/legup/ui/HomePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,8 @@ private void openNewPuzzleDialog() {
cpd.setVisible(true);
}

public void openEditorWithNewPuzzle(String game, int width, int height) {
public void openEditorWithNewPuzzle(String game) {
// Set game type on the puzzle editor
this.legupUI.displayPanel(2);
this.legupUI.getPuzzleEditor().loadPuzzleFromHome(game, width, height);
}
}
2 changes: 0 additions & 2 deletions src/main/java/edu/rpi/legup/ui/LegupUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ public PuzzleEditorPanel getPuzzleEditor() {
return (PuzzleEditorPanel) panels[2];
}

public PuzzleEditorPanel getPuzzleEditor() { return (PuzzleEditorPanel) panels[2]; }

public static boolean profFlag(int flag) {
return !((PROF_FLAGS[CONFIG_INDEX] & flag) == 0);
}
Expand Down
12 changes: 3 additions & 9 deletions src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
import edu.rpi.legup.controller.BoardController;
import edu.rpi.legup.controller.EditorElementController;
import edu.rpi.legup.controller.ElementController;
import edu.rpi.legup.controller.RuleController;
import edu.rpi.legup.history.ICommand;
import edu.rpi.legup.history.IHistoryListener;
import edu.rpi.legup.model.Puzzle;
import edu.rpi.legup.save.InvalidFileFormatException;
import edu.rpi.legup.ui.boardview.BoardView;
import edu.rpi.legup.ui.proofeditorui.rulesview.RuleFrame;
import edu.rpi.legup.ui.puzzleeditorui.elementsview.ElementFrame;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -170,15 +172,7 @@ private void setupToolBar() {

this.add(toolBar, BorderLayout.NORTH);
}
public void loadPuzzleFromHome(String game, int width, int height) {
GameBoardFacade facade = GameBoardFacade.getInstance();
try {
facade.loadPuzzle(game, width, height);
}
catch (RuntimeException e){
LOGGER.error(e.getMessage());
}
}

public void promptPuzzle() {
GameBoardFacade facade = GameBoardFacade.getInstance();
if (facade.getBoard() != null) {
Expand Down

0 comments on commit f385d60

Please sign in to comment.