use of com.playshogi.website.gwt.client.events.gametree.PositionChangedEvent in project playshogi by Tellmarch.
the class PositionEditingPanel method createPresetsList.
private ListBox createPresetsList() {
final ListBox presets;
presets = new ListBox();
presets.addItem("Template", "");
presets.addItem("----------------", "");
presets.addItem("Empty board (One King)", "ONE_KING");
presets.addItem("Empty board (Two Kings)", "TWO_KINGS");
presets.addItem("----------------", "");
presets.addItem("Initial position: even game", Handicap.EVEN.name());
presets.addItem("Handicap: " + messages.handicapLance(), Handicap.LANCE.name());
presets.addItem("Handicap: " + messages.handicapBishop(), Handicap.BISHOP.name());
presets.addItem("Handicap: " + messages.handicapRook(), Handicap.ROOK.name());
presets.addItem("Handicap: " + messages.handicapRookLance(), Handicap.ROOK_LANCE.name());
presets.addItem("Handicap: " + messages.handicapTwoPieces(), Handicap.TWO_PIECES.name());
presets.addItem("Handicap: " + messages.handicapFourPieces(), Handicap.FOUR_PIECES.name());
presets.addItem("Handicap: " + messages.handicapSixPieces(), Handicap.SIX_PIECES.name());
presets.addItem("Handicap: " + messages.handicapEightPieces(), Handicap.EIGHT_PIECES.name());
presets.addItem("Handicap: " + messages.handicapNinePieces(), Handicap.NINE_PIECES.name());
presets.addItem("Handicap: " + messages.handicapTenPieces(), Handicap.TEN_PIECES.name());
presets.addItem("Handicap: " + messages.handicapThreePawns(), Handicap.THREE_PAWNS.name());
presets.addItem("Handicap: " + messages.handicapNakedKing(), Handicap.NAKED_KING.name());
presets.setVisibleItemCount(1);
presets.addChangeHandler(changeEvent -> {
String value = presets.getSelectedValue();
GWT.log(value);
if ("ONE_KING".equals(value)) {
eventBus.fireEvent(new PositionChangedEvent(ShogiInitialPositionFactory.createEmptyTsumePosition(false), true));
} else if ("TWO_KINGS".equals(value)) {
eventBus.fireEvent(new PositionChangedEvent(ShogiInitialPositionFactory.createEmptyTsumePosition(true), true));
} else if (!value.isEmpty()) {
eventBus.fireEvent(new PositionChangedEvent(ShogiInitialPositionFactory.createInitialPosition(Handicap.valueOf(value)), true));
}
});
return presets;
}
use of com.playshogi.website.gwt.client.events.gametree.PositionChangedEvent in project playshogi by Tellmarch.
the class ImportPositionPanel method importPositionFromText.
private void importPositionFromText() {
GWT.log("Importing position...");
ShogiPosition position = null;
if (sfenButton.getValue()) {
GWT.log("Will parse as SFEN position");
position = SfenConverter.fromSFEN(textArea.getText());
} else if (kifButton.getValue()) {
GWT.log("Will parse as KIF position");
position = KifFormat.INSTANCE.readPosition(textArea.getText());
} else if (ussButton.getValue()) {
GWT.log("Will parse as USS position");
position = UssConverter.fromUSS(textArea.getText());
}
if (position != null) {
GWT.log("Firing position changed event...");
eventBus.fireEvent(new PositionChangedEvent(position, true));
}
dialogBox.hide();
}
use of com.playshogi.website.gwt.client.events.gametree.PositionChangedEvent in project playshogi by Tellmarch.
the class OpeningsActivity method start.
@Override
public void start(final AcceptsOneWidget containerWidget, final EventBus eventBus) {
this.eventBus = eventBus;
GWT.log("Starting openings activity");
eventBinder.bindEventHandlers(this, eventBus);
final ShogiPosition position = SfenConverter.fromSFEN(sfen);
openingsView.activate(position, eventBus);
containerWidget.setWidget(openingsView.asWidget());
kifuService.getPositionDetails(SfenConverter.toSFEN(position), gameSetId, new AsyncCallback<PositionDetails>() {
@Override
public void onSuccess(final PositionDetails result) {
GWT.log("OPENINGS - GOT POSITION DETAILS " + result);
eventBus.fireEvent(new PositionStatisticsEvent(result, position, gameSetId));
}
@Override
public void onFailure(final Throwable caught) {
GWT.log("OPENINGS - ERROR GETTING POSITION STATS");
}
});
Scheduler.get().scheduleDeferred(() -> eventBus.fireEvent(new PositionChangedEvent(position, false)));
}
use of com.playshogi.website.gwt.client.events.gametree.PositionChangedEvent in project playshogi by Tellmarch.
the class KifuEditorView method onSwitchPlayerToPlay.
@EventHandler
public void onSwitchPlayerToPlay(final SwitchPlayerToPlayEvent event) {
GWT.log("Problem editor: handle SwitchPlayerToPlayEvent");
shogiBoard.getPosition().setPlayerToMove(shogiBoard.getPosition().getPlayerToMove().opposite());
eventBus.fireEvent(new PositionChangedEvent(shogiBoard.getPosition(), true));
}
use of com.playshogi.website.gwt.client.events.gametree.PositionChangedEvent in project playshogi by Tellmarch.
the class KifuEditorView method resetForNewProblem.
private void resetForNewProblem() {
Scheduler.get().scheduleDeferred(() -> {
loadGameRecord(new GameRecord());
kifuEditorLeftBarPanel.resetToProblemMode();
eventBus.fireEvent(new PositionChangedEvent(ShogiInitialPositionFactory.createEmptyTsumePosition(false), true));
});
}
Aggregations