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

Puzzle editor small code formatting #168

Merged
merged 2 commits into from
Jun 24, 2022
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
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; }
}