Let EditPosition double-click on piece promote it
authorH.G.Muller <hgm@hgm-xboard.(none)>
Wed, 9 Apr 2014 07:53:56 +0000 (09:53 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Wed, 9 Apr 2014 07:53:56 +0000 (09:53 +0200)
For pieces with Shogi-like promotion (i.e. if the promoted piece has
pieceToChar defined as '+'), let a second click on it in Edit Position
mode promote or demote it (as the case requires) when the piece menu is off,
rather than remove it (as was the old behavior.

backend.c

index b05e795..9d659e2 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -6940,6 +6940,13 @@ UserMoveEvent(int fromX, int fromY, int toX, int toY, int promoChar)
            DrawPosition(FALSE, boards[currentMove]);
            return;
        } else if (toX >= 0 && toY >= 0) {
+           if(!appData.pieceMenu && toX == fromX && toY == fromY && boards[0][rf][ff] != EmptySquare) {
+               ChessSquare q, p = boards[0][rf][ff];
+               if(p >= BlackPawn) p = BLACK_TO_WHITE p;
+               if(CHUPROMOTED p < BlackPawn) p = q = CHUPROMOTED boards[0][rf][ff];
+               else p = CHUDEMOTED (q = boards[0][rf][ff]);
+               if(PieceToChar(q) == '+') gatingPiece = p;
+           }
            boards[0][toY][toX] = boards[0][fromY][fromX];
            if(fromX == BOARD_LEFT-2) { // handle 'moves' out of holdings
                if(boards[0][fromY][0] != EmptySquare) {