Search in sources :

Example 1 with GameTreeChangedEvent

use of com.playshogi.website.gwt.client.events.gametree.GameTreeChangedEvent in project playshogi by Tellmarch.

the class ViewKifuActivity method onMoveSelectedEvent.

@EventHandler
public void onMoveSelectedEvent(final MoveSelectedEvent event) {
    GWT.log("ViewKifuActivity handling MoveSelectedEvent");
    eventBus.fireEvent(new GameTreeChangedEvent(gameRecord.getGameTree(), event.getMoveNumber()));
}
Also used : GameTreeChangedEvent(com.playshogi.website.gwt.client.events.gametree.GameTreeChangedEvent) EventHandler(com.google.web.bindery.event.shared.binder.EventHandler)

Example 2 with GameTreeChangedEvent

use of com.playshogi.website.gwt.client.events.gametree.GameTreeChangedEvent in project playshogi by Tellmarch.

the class GameTreePanel method createContextMenu.

private PopupPanel createContextMenu() {
    final PopupPanel contextMenu;
    contextMenu = new PopupPanel(true);
    MenuBar menuBar = new MenuBar(true);
    deleteVariationMenu = new MenuItem("Delete Variation", () -> {
        GWT.log("Delete variation");
        Node node = (Node) tree.getSelectedItem().getUserObject();
        boolean confirm = Window.confirm("Delete variation starting with " + tree.getSelectedItem().getText() + "? This can not be undone.");
        if (confirm) {
            node.removeFromParent();
            eventBus.fireEvent(new GameTreeChangedEvent(gameNavigation.getGameTree()));
        }
        contextMenu.hide();
    });
    menuBar.addItem(deleteVariationMenu);
    if (!readOnly) {
        promoteVariationMenu = new MenuItem("Promote variation to main line", () -> {
            GWT.log("Promote variation");
            Node node = (Node) tree.getSelectedItem().getUserObject();
            node.promoteVariation();
            eventBus.fireEvent(new GameTreeChangedEvent(gameNavigation.getGameTree()));
            contextMenu.hide();
        });
        menuBar.addItem(promoteVariationMenu);
        rebaseMenu = new MenuItem("Start from here", () -> {
            GWT.log("Rebase");
            Node node = (Node) tree.getSelectedItem().getUserObject();
            if (!(node.getMove() instanceof EditMove)) {
                GWT.log("Not an edit move - aborting");
                return;
            }
            boolean confirm = Window.confirm("Only keep the variations starting from this position?" + " This can not be undone.");
            if (confirm) {
                node.setParent(null);
                node.setParentIndex(0);
                GameTree gameTree = new GameTree(node);
                eventBus.fireEvent(new GameTreeChangedEvent(gameTree));
            }
            contextMenu.hide();
        });
        menuBar.addItem(rebaseMenu);
    }
    contextMenu.add(menuBar);
    contextMenu.hide();
    return contextMenu;
}
Also used : GameTreeChangedEvent(com.playshogi.website.gwt.client.events.gametree.GameTreeChangedEvent) Node(com.playshogi.library.shogi.models.record.Node) GameTree(com.playshogi.library.shogi.models.record.GameTree) EditMove(com.playshogi.library.shogi.models.moves.EditMove)

Example 3 with GameTreeChangedEvent

use of com.playshogi.website.gwt.client.events.gametree.GameTreeChangedEvent in project playshogi by Tellmarch.

the class ByoYomiActivity method getProblemRequestCallback.

private AsyncCallback<ProblemDetails> getProblemRequestCallback() {
    return new AsyncCallback<ProblemDetails>() {

        @Override
        public void onSuccess(final ProblemDetails result) {
            if (result == null) {
                GWT.log("Got null usf from server for random problem request");
            } else {
                GWT.log("Got problem details for random problem request: " + result);
                String resultUsf = result.getUsf();
                GameRecord gameRecord = UsfFormat.INSTANCE.readSingle(resultUsf);
                GWT.log("Updating game navigator...");
                setTsumeId(result.getId());
                eventBus.fireEvent(new GameTreeChangedEvent(gameRecord.getGameTree()));
                initProblemTimer();
                initMoveTimer();
            }
        }

        @Override
        public void onFailure(final Throwable caught) {
            GWT.log("Remote called failed for problem request");
        }
    };
}
Also used : GameTreeChangedEvent(com.playshogi.website.gwt.client.events.gametree.GameTreeChangedEvent) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) ProblemDetails(com.playshogi.website.gwt.shared.models.ProblemDetails) GameRecord(com.playshogi.library.shogi.models.record.GameRecord)

Example 4 with GameTreeChangedEvent

use of com.playshogi.website.gwt.client.events.gametree.GameTreeChangedEvent in project playshogi by Tellmarch.

the class KifuEditorActivity method onImportGameRecord.

@EventHandler
public void onImportGameRecord(final ImportGameRecordEvent gameRecordChangedEvent) {
    GWT.log("problem editor Activity Handling ImportGameRecordEvent");
    GameRecord gameRecord = gameRecordChangedEvent.getGameRecord();
    eventBus.fireEvent(new GameTreeChangedEvent(gameRecord.getGameTree()));
    eventBus.fireEvent(new GameInformationChangedEvent(gameRecord.getGameInformation()));
}
Also used : GameTreeChangedEvent(com.playshogi.website.gwt.client.events.gametree.GameTreeChangedEvent) GameRecord(com.playshogi.library.shogi.models.record.GameRecord) EventHandler(com.google.web.bindery.event.shared.binder.EventHandler)

Example 5 with GameTreeChangedEvent

use of com.playshogi.website.gwt.client.events.gametree.GameTreeChangedEvent in project playshogi by Tellmarch.

the class TsumeActivity method getProblemRequestCallback.

private AsyncCallback<ProblemDetails> getProblemRequestCallback(final String tsumeId) {
    return new AsyncCallback<ProblemDetails>() {

        @Override
        public void onSuccess(final ProblemDetails result) {
            if (result == null) {
                GWT.log("Got null usf from server for problem request: " + tsumeId);
            } else {
                GWT.log("Got problem details problem request: " + tsumeId + " : " + result);
                String resultUsf = result.getUsf();
                GameRecord gameRecord = UsfFormat.INSTANCE.readSingle(resultUsf);
                GWT.log("Updating game navigator...");
                setTsumeId(result.getId());
                History.newItem("Tsume:" + new TsumePlace.Tokenizer().getToken(getPlace()), false);
                eventBus.fireEvent(new GameTreeChangedEvent(gameRecord.getGameTree()));
                initTimer();
            }
        }

        @Override
        public void onFailure(final Throwable caught) {
            GWT.log("Remote called failed for problem request: " + tsumeId);
        }
    };
}
Also used : TsumePlace(com.playshogi.website.gwt.client.place.TsumePlace) GameTreeChangedEvent(com.playshogi.website.gwt.client.events.gametree.GameTreeChangedEvent) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) ProblemDetails(com.playshogi.website.gwt.shared.models.ProblemDetails) GameRecord(com.playshogi.library.shogi.models.record.GameRecord)

Aggregations

GameTreeChangedEvent (com.playshogi.website.gwt.client.events.gametree.GameTreeChangedEvent)10 EventHandler (com.google.web.bindery.event.shared.binder.EventHandler)4 GameRecord (com.playshogi.library.shogi.models.record.GameRecord)3 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)2 EditMove (com.playshogi.library.shogi.models.moves.EditMove)2 GameInformationChangedEvent (com.playshogi.website.gwt.client.events.kifu.GameInformationChangedEvent)2 ProblemDetails (com.playshogi.website.gwt.shared.models.ProblemDetails)2 GameTree (com.playshogi.library.shogi.models.record.GameTree)1 Node (com.playshogi.library.shogi.models.record.Node)1 EditMovePlayedEvent (com.playshogi.website.gwt.client.events.gametree.EditMovePlayedEvent)1 TsumePlace (com.playshogi.website.gwt.client.place.TsumePlace)1