Skip to content
This repository has been archived by the owner on Nov 29, 2017. It is now read-only.

Commit

Permalink
Minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vapour101 committed Oct 1, 2017
1 parent 2d7003d commit 991a572
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
20 changes: 10 additions & 10 deletions src/main/java/ogs/SpectatorGameHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,6 @@ private void onGameData(Gamedata gamedata) {
fireGameEvent(GameEvent.MOVE);
}

private void onMovedata(Movedata move) {
if ( gameTree == null ) {
LogHelper.severe("gameTree is null");
return;
}

gameTree.stepForward(move.getMove(getTurnPlayer()));
fireGameEvent(GameEvent.MOVE);
}

private void fireGameEvent(EventType<? extends GameEvent> type) {
GameEvent event = new GameEvent(this, this, type);
fireEvent(event);
Expand All @@ -107,6 +97,16 @@ public <T extends SujiEvent> void unsubscribe(EventType<T> eventType, EventHandl
publisher.unsubscribe(eventType, eventHandler);
}

private void onMovedata(Movedata move) {
if ( gameTree == null ) {
LogHelper.severe("gameTree is null");
return;
}

gameTree.stepForward(move.getMove(getTurnPlayer()));
fireGameEvent(GameEvent.MOVE);
}

@Override
public void pass() {

Expand Down
17 changes: 12 additions & 5 deletions src/main/java/ui/controller/BoardController.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,18 @@ public class BoardController extends DockNodeController implements Initializable

private GameHandler game;
private String fxmlLocation;

private boolean interactive;
private Queue<Node> sideBarItems;


BoardController(GameHandler gameHandler, String resourcePath) {
this(gameHandler, resourcePath, true);
}

BoardController(GameHandler gameHandler, String resourcePath, boolean interactive) {
game = gameHandler;
fxmlLocation = resourcePath;
sideBarItems = new ArrayDeque<>();
this.interactive = interactive;
}

public final void addToSideBar(Node node) {
Expand All @@ -80,9 +84,12 @@ void setupPanes() {

private void constructCanvas() {
boardCanvas = new Canvas();
boardCanvas.setOnMouseMoved(this::canvasHover);
boardCanvas.setOnMouseClicked(this::canvasClicked);
boardCanvas.setOnMouseExited(this::canvasExit);

if ( interactive ) {
boardCanvas.setOnMouseMoved(this::canvasHover);
boardCanvas.setOnMouseClicked(this::canvasClicked);
boardCanvas.setOnMouseExited(this::canvasExit);
}

boardPane.getChildren().add(boardCanvas);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ui/controller/GameListController.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public TableRow<GameList.Game> call(TableView<GameList.Game> param) {

private void spectateGame(GameList.Game game) {
SpectatorGameHandler handler = new SpectatorGameHandler(game.getId());
BoardController controller = new BoardController(handler, "/fxml/localGame.fxml");
BoardController controller = new BoardController(handler, "/fxml/localGame.fxml", false);

PlayerPaneController playerInfo = new PlayerPaneController(game);
controller.addToSideBar(playerInfo.getRoot());
Expand Down

0 comments on commit 991a572

Please sign in to comment.