Skip to content

Commit

Permalink
Merge pull request #168 from HenryCullom/puzzle-editor
Browse files Browse the repository at this point in the history
Puzzle editor small code formatting
  • Loading branch information
HazelCullom authored Jun 24, 2022
2 parents b9a9faf + 800252f commit fa44af9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/main/java/edu/rpi/legup/app/GameBoardFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import edu.rpi.legup.model.Puzzle;
import edu.rpi.legup.model.tree.Tree;
import edu.rpi.legup.ui.ProofEditorPanel;
import edu.rpi.legup.ui.PuzzleEditorPanel;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
Expand Down Expand Up @@ -45,6 +46,8 @@ public class GameBoardFacade implements IHistorySubject {

private ProofEditorPanel puzzleSolver;

private PuzzleEditorPanel puzzleEditor;

private String curFileName;

private History history;
Expand Down Expand Up @@ -77,13 +80,15 @@ public void initializeUI() {
EventQueue.invokeLater(() ->{
legupUI = new LegupUI();
puzzleSolver = legupUI.getProofEditor();
puzzleEditor = legupUI.getPuzzleEditor();
addHistoryListener(legupUI.getProofEditor());
});
}

public void setPuzzle(Puzzle puzzle) {
this.puzzle = puzzle;
this.puzzleSolver.setPuzzleView(puzzle);
this.puzzleEditor.setPuzzleView((puzzle));
this.history.clear();
}

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/edu/rpi/legup/ui/LegupUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ protected void displayPanel(int option) {
public ProofEditorPanel getProofEditor() {
return (ProofEditorPanel) panels[1];
}
public PuzzleEditorPanel getPuzzleEditor() {
return (PuzzleEditorPanel) panels[2];
}

public static boolean profFlag(int flag) {
return !((PROF_FLAGS[CONFIG_INDEX] & flag) == 0);
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
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;
Expand All @@ -30,6 +31,7 @@ public class PuzzleEditorPanel extends LegupPanel implements IHistoryListener {
private JToolBar toolBar;
private JFrame frame;
private JButton[] buttons;
JSplitPane splitPanel;
private JButton[] toolBarButtons;
private JPanel elementPanel;
private DynamicView dynamicBoardView;
Expand Down Expand Up @@ -235,4 +237,25 @@ public void setToolBarButtons(JButton[] toolBarButtons) {
private void repaintAll() {
boardView.repaint();
}

public void setPuzzleView(Puzzle puzzle) {
this.boardView = puzzle.getBoardView();

dynamicBoardView = new DynamicView(boardView);
this.splitPanel.setRightComponent(dynamicBoardView);
this.splitPanel.setVisible(true);

TitledBorder titleBoard = BorderFactory.createTitledBorder(boardView.getClass().getSimpleName());
titleBoard.setTitleJustification(TitledBorder.CENTER);
dynamicBoardView.setBorder(titleBoard);

puzzle.addBoardListener(puzzle.getBoardView());

elementFrame.getNonPlaceableElementPanel().setElements(puzzle.getNonPlaceableElements());
elementFrame.getPlaceableElementPanel().setElements(puzzle.getPlaceableElements());

toolBarButtons[ToolbarName.CHECK.ordinal()].setEnabled(true);
toolBarButtons[ToolbarName.SAVE.ordinal()].setEnabled(true);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public ElementFrame(EditorElementController controller) {
add(tabbedPane);
add(status, BorderLayout.SOUTH);

TitledBorder title = BorderFactory.createTitledBorder("Rules");
TitledBorder title = BorderFactory.createTitledBorder("Elements");
title.setTitleJustification(TitledBorder.CENTER);
setBorder(title);
}
Expand All @@ -67,4 +67,7 @@ public EditorElementController getController() {
public JTabbedPane getTabbedPane() {
return tabbedPane;
}

public NonPlaceableElementPanel getNonPlaceableElementPanel() { return nonPlaceableElementPanel; }
public PlaceableElementPanel getPlaceableElementPanel() { return placeableElementPanel; }
}

0 comments on commit fa44af9

Please sign in to comment.