Make XBoard grant- and revoke-rights buttons work
authorH.G. Muller <h.g.muller@hccnet.nl>
Wed, 27 Jan 2010 12:19:05 +0000 (13:19 +0100)
committerArun Persaud <arun@nubati.net>
Sun, 7 Feb 2010 01:36:31 +0000 (17:36 -0800)
The buttons in the new promotion popup to specify castling rights are
now fully operational. A new ChessSquare enum code 'GrantRights' was
added to transmit the instruction. ('NoRights' was used for revoking
the rights.)

backend.c
common.h
xpromo.c

index 35cc84d..2c245d6 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -12183,6 +12183,18 @@ EditPositionMenuEvent(selection, x, y)
        SetBlackToPlayEvent();
        break;
 
+      case NoRights:
+       rightsBoard[y][x] = 0;
+        break;
+
+      case GrantRights:
+        { ChessSquare p = boards[0][y][x];
+         rightsBoard[y][x] = 1;
+         if(p == WhiteKing || p == WhiteUnicorn || p == BlackKing || p == BlackUnicorn)
+               rightsBoard[y][x] = 2;
+       }
+        break;
+
       case EmptySquare:
        if (gameMode == IcsExamining) {
             if (x < BOARD_LEFT || x >= BOARD_RGHT) break; // [HGM] holdings
index a5577e2..d15c45e 100644 (file)
--- a/common.h
+++ b/common.h
@@ -236,6 +236,7 @@ typedef enum {
     BlackSilver, BlackFalcon, BlackLance, BlackCobra, BlackUnicorn, BlackKing,
     EmptySquare, 
     NoRights, // [HGM] gamestate: for castling rights hidden in board[CASTLING]
+    GrantRights, // [HGM] promopopup: for EditPosition menu
     ClearBoard, WhitePlay, BlackPlay, PromotePiece, DemotePiece /*for use on EditPosition menus*/
   } ChessSquare;
 
index 49637b2..c2d7d9e 100644 (file)
--- a/xpromo.c
+++ b/xpromo.c
@@ -288,6 +288,12 @@ void PromoCallback(w, client_data, call_data)
     
     if (strcmp(name, _("clear board")) == 0) {
        EditPositionMenuEvent(ClearBoard, 0, 0);
+    } else
+    if (strcmp(name, _("grant rights")) == 0) {
+       EditPositionMenuEvent(GrantRights, fromX, fromY);
+    } else
+    if (strcmp(name, _("revoke rights")) == 0) {
+       EditPositionMenuEvent(NoRights, fromX, fromY);
     }
     PromoPopDown();
 }