promote popup fix
This commit is contained in:
@@ -7,7 +7,6 @@ import java.awt.event.MouseAdapter;
|
|||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
@@ -22,12 +21,11 @@ import chess.controller.CommandExecutor;
|
|||||||
import chess.controller.commands.CastlingCommand;
|
import chess.controller.commands.CastlingCommand;
|
||||||
import chess.controller.commands.GetAllowedMovesPieceCommand;
|
import chess.controller.commands.GetAllowedMovesPieceCommand;
|
||||||
import chess.controller.commands.GetPieceAtCommand;
|
import chess.controller.commands.GetPieceAtCommand;
|
||||||
import chess.controller.commands.GetPlayerMovesCommand;
|
|
||||||
import chess.controller.commands.MoveCommand;
|
import chess.controller.commands.MoveCommand;
|
||||||
import chess.controller.commands.PromoteCommand;
|
import chess.controller.commands.PromoteCommand;
|
||||||
import chess.controller.commands.PromoteCommand.PromoteType;
|
import chess.controller.commands.PromoteCommand.PromoteType;
|
||||||
import chess.controller.event.GameListener;
|
|
||||||
import chess.controller.commands.UndoCommand;
|
import chess.controller.commands.UndoCommand;
|
||||||
|
import chess.controller.event.GameListener;
|
||||||
import chess.model.Coordinate;
|
import chess.model.Coordinate;
|
||||||
import chess.model.Move;
|
import chess.model.Move;
|
||||||
import chess.model.Piece;
|
import chess.model.Piece;
|
||||||
@@ -231,6 +229,7 @@ public class Window extends JFrame implements GameListener {
|
|||||||
public void patSituation() {
|
public void patSituation() {
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
JOptionPane.showMessageDialog(this, "Pat. It's a draw!");
|
JOptionPane.showMessageDialog(this, "Pat. It's a draw!");
|
||||||
|
this.dispose();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,39 +247,41 @@ public class Window extends JFrame implements GameListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void promotePawn(Coordinate pieceCoords) {
|
public void promotePawn(Coordinate pieceCoords) {
|
||||||
// SwingUtilities.invokeLater(() -> {
|
if (!showPopups)
|
||||||
// String result = null;
|
return;
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
String result = null;
|
||||||
|
|
||||||
// Object[] possibilities = new Object[PromoteType.values().length];
|
Object[] possibilities = new Object[PromoteType.values().length];
|
||||||
// int i = 0;
|
int i = 0;
|
||||||
// for (PromoteType type : PromoteType.values()) {
|
for (PromoteType type : PromoteType.values()) {
|
||||||
// possibilities[i] = type.name();
|
possibilities[i] = type.name();
|
||||||
// i++;
|
i++;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// while (result == null || result.isEmpty()) {
|
while (result == null || result.isEmpty()) {
|
||||||
// result = (String) JOptionPane.showInputDialog(
|
result = (String) JOptionPane.showInputDialog(
|
||||||
// this,
|
this,
|
||||||
// "Choose the type of piece to upgrade the pawn",
|
"Choose the type of piece to upgrade the pawn",
|
||||||
// "Promote Dialog",
|
"Promote Dialog",
|
||||||
// JOptionPane.PLAIN_MESSAGE,
|
JOptionPane.PLAIN_MESSAGE,
|
||||||
// null,
|
null,
|
||||||
// possibilities,
|
possibilities,
|
||||||
// possibilities[0]);
|
possibilities[0]);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// PromoteType choosedType = null;
|
PromoteType choosedType = null;
|
||||||
|
|
||||||
// for (PromoteType type : PromoteType.values()) {
|
for (PromoteType type : PromoteType.values()) {
|
||||||
// if (type.name().equals(result)) {
|
if (type.name().equals(result)) {
|
||||||
// choosedType = type;
|
choosedType = type;
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if (choosedType != null)
|
if (choosedType != null)
|
||||||
// sendCommand(new PromoteCommand(choosedType));
|
sendCommand(new PromoteCommand(choosedType));
|
||||||
// });
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user