/** * Handle game finished. * * @param player the player */ private void handleGameFinished(IPlayer player) { TableViewerColumn column; column = this.playerColumn.get(player); column.getColumn().setImage(ProtoPlugin.getImage(ISharedImages.IMG_TICK_DECO)); // remove edition for (Text inputTxt : this.playerScoreInput.values()) { inputTxt.setEnabled(false); inputTxt.setBackground( OpenDartsFormsToolkit.getToolkit() .getColors() .getColor(OpenDartsFormsToolkit.COLOR_INACTIVE)); } for (TableViewerColumn col : this.playerColumn.values()) { col.setEditingSupport(null); } // End Game dialog if (!this.game.getParentSet().isFinished()) { String title = MessageFormat.format("{0} finished", this.game); String message = this.game.getWinningMessage(); Shell shell = this.getSite().getShell(); MessageDialog.open(MessageDialog.INFORMATION, shell, title, message, SWT.SHEET); } this.dirty = false; this.mForm.dirtyStateChanged(); }
/** * Handle player. * * @param player the player */ private void handlePlayer(IPlayer player, IGameEntry entry) { if (player != null) { TableViewerColumn column; // mark column column = this.playerColumn.get(player); TableViewerColumn c; for (IPlayer p : this.game.getPlayers()) { c = this.playerColumn.get(p); if (c.equals(column)) { c.getColumn().setImage(ProtoPlugin.getImage(ISharedImages.IMG_ARROW_DECO)); } else { c.getColumn().setImage(null); } } // enable/disable inputs & focus Text playerInputTxt = this.playerScoreInput.get(player); for (Text inputTxt : this.playerScoreInput.values()) { if (playerInputTxt.equals(inputTxt)) { inputTxt.setEnabled(true); inputTxt.setBackground( OpenDartsFormsToolkit.getToolkit() .getColors() .getColor(OpenDartsFormsToolkit.COLOR_ACTIVE)); inputTxt.setFocus(); } else { inputTxt.setEnabled(false); inputTxt.setText(""); inputTxt.setBackground( OpenDartsFormsToolkit.getToolkit() .getColors() .getColor(OpenDartsFormsToolkit.COLOR_INACTIVE)); } } // IA playing if (player.isComputer()) { ThreeDartsComputerDialog computerThrow = new DartsComputerX01Dialog( this.getSite().getShell(), player, this.game, (GameX01Entry) entry); computerThrow.open(); IDartsThrow dartThrow = computerThrow.getComputerThrow(); if (dartThrow instanceof WinningX01DartsThrow) { this.gameService.addWinningPlayerThrow(this.game, player, dartThrow); } else { this.gameService.addPlayerThrow(this.game, player, dartThrow); } } } }