Adapt WinBoard front-end to Mighty Lion
[xboard.git] / winboard / winboard.c
index e5df6db..1539f42 100644 (file)
@@ -109,7 +109,6 @@ VOID NewVariantPopup(HWND hwnd);
 int FinishMove P((ChessMove moveType, int fromX, int fromY, int toX, int toY,\r
                   /*char*/int promoChar));\r
 void DisplayMove P((int moveNumber));\r
-Boolean ParseFEN P((Board board, int *blackPlaysFirst, char *fen));\r
 void ChatPopUp P((char *s));\r
 typedef struct {\r
   ChessSquare piece;  \r
@@ -2273,7 +2272,7 @@ InitDrawingSizes(BoardSize boardSize, int flags)
        && (boardSize < SizePetite || boardSize > SizeBulky) // Archbishop and Chancellor available in entire middle range\r
       || (v == VariantShogi && boardSize != SizeModerate)   // Japanese-style Shogi\r
       ||  v == VariantKnightmate || v == VariantSChess || v == VariantXiangqi || v == VariantSpartan\r
-      ||  v == VariantShatranj || v == VariantMakruk || v == VariantGreat || v == VariantFairy ) {\r
+      ||  v == VariantShatranj || v == VariantMakruk || v == VariantGreat || v == VariantFairy || v == VariantLion ) {\r
       if(boardSize < SizeMediocre) boardSize = SizePetite; else\r
       if(boardSize > SizeModerate) boardSize = SizeBulky;  else\r
                                    boardSize = SizeMiddling;\r
@@ -2629,6 +2628,9 @@ InitDrawingSizes(BoardSize boardSize, int flags)
     pieceBitmap[0][WhiteUnicorn] = DoLoadBitmap(hInst, "u", squareSize, "s");\r
     pieceBitmap[1][WhiteUnicorn] = DoLoadBitmap(hInst, "u", squareSize, "o");\r
     pieceBitmap[2][WhiteUnicorn] = DoLoadBitmap(hInst, "u", squareSize, "w");\r
+    pieceBitmap[0][WhiteLion] = DoLoadBitmap(hInst, "ln", squareSize, "s");\r
+    pieceBitmap[1][WhiteLion] = DoLoadBitmap(hInst, "ln", squareSize, "o");\r
+    pieceBitmap[2][WhiteLion] = DoLoadBitmap(hInst, "ln", squareSize, "w");\r
 \r
     if(gameInfo.variant == VariantShogi) { /* promoted Gold represemtations */\r
       pieceBitmap[0][WhiteCannon] = DoLoadBitmap(hInst, "wp", squareSize, "s");\r
@@ -3251,6 +3253,8 @@ BOOL HasHighlightInfo()
 \r
     return result;\r
 \r
+\r
+\r
 }\r
 \r
 BOOL IsDrawArrowEnabled()\r
@@ -4274,8 +4278,10 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
       } else if (PtInRect((LPRECT) &blackRect, pt)) {\r
        ClockClick(!flipClock); break;\r
       }\r
+    if(dragging) { // [HGM] lion: don't destroy dragging info if we are already dragging\r
       dragInfo.start.x = dragInfo.start.y = -1;\r
       dragInfo.from = dragInfo.start;\r
+    }\r
     if(fromX == -1 && frozen) { // not sure where this is for\r
                fromX = fromY = -1; \r
       DrawPosition(forceFullRepaint || FALSE, NULL); /* [AS] */\r
@@ -4295,7 +4301,7 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
     if(PromoScroll(pt.x - boardRect.left, pt.y - boardRect.top)) break;\r
     MovePV(pt.x - boardRect.left, pt.y - boardRect.top, boardRect.bottom - boardRect.top);\r
     if ((appData.animateDragging || appData.highlightDragging)\r
-       && (wParam & MK_LBUTTON)\r
+       && (wParam & MK_LBUTTON || dragging == 2)\r
        && dragInfo.from.x >= 0) \r
     {\r
       BOOL full_repaint = FALSE;\r
@@ -5105,6 +5111,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
       break;\r
 \r
     case IDM_Rematch:\r
+\r
       RematchEvent();\r
       break;\r
 \r
@@ -6262,6 +6269,7 @@ StartupDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
        SwapEngines(singleList); // temporarily swap first and second, to load a second 'first', ...\r
        ParseArgs(StringGet, &p);\r
        SwapEngines(singleList); // ... and then make it 'second'\r
+\r
        appData.noChessProgram = FALSE;\r
        appData.icsActive = FALSE;\r
       } else if (IsDlgButtonChecked(hDlg, OPT_ChessServer)) {\r
@@ -6851,6 +6859,7 @@ SaveInHistory(char *cmd)
   histIn = (histIn + 1) % HISTORY_SIZE;\r
   if (history[histIn] != NULL) {\r
     free(history[histIn]);\r
+\r
     history[histIn] = NULL;\r
   }\r
   histP = histIn;\r
@@ -8717,6 +8726,13 @@ EditCommentPopUp(int index, char *title, char *str)
 }\r
 \r
 \r
+int\r
+Roar()\r
+{\r
+  MyPlaySound(&sounds[(int)SoundRoar]);\r
+  return 1;\r
+}\r
+\r
 VOID\r
 RingBell()\r
 {\r
@@ -8874,6 +8890,7 @@ DisplayBlackClock(long timeRemaining, int highlight)
   HDC hdc;\r
   char *flag = blackFlag && gameMode == TwoMachinesPlay ? "(!)" : "";\r
 \r
+\r
   if(appData.noGUI) return;\r
   hdc = GetDC(hwndMain);\r
   if (!IsIconic(hwndMain)) {\r
@@ -9892,16 +9909,23 @@ AnimateMove(board, fromX, fromY, toX, toY)
      int toY;\r
 {\r
   ChessSquare piece;\r
+  int x = toX, y = toY;\r
   POINT start, finish, mid;\r
   POINT frames[kFactor * 2 + 1];\r
   int nFrames, n;\r
 \r
+  if(killX >= 0 && IS_LION(board[fromY][fromX])) Roar();\r
+\r
   if (!appData.animate) return;\r
   if (doingSizing) return;\r
   if (fromY < 0 || fromX < 0) return;\r
   piece = board[fromY][fromX];\r
   if (piece >= EmptySquare) return;\r
 \r
+  if(killX >= 0) toX = killX, toY = killY; // [HGM] lion: first to kill square\r
+\r
+again:\r
+\r
   ScreenSquare(fromX, fromY, &start);\r
   ScreenSquare(toX, toY, &finish);\r
 \r
@@ -9940,6 +9964,9 @@ AnimateMove(board, fromX, fromY, toX, toY)
   }\r
   animInfo.pos = finish;\r
   DrawPosition(FALSE, NULL);\r
+\r
+  if(toX != x || toY != y) { fromX = toX; fromY = toY; toX = x; toY = y; goto again; } // second leg\r
+\r
   animInfo.piece = EmptySquare;\r
   Explode(board, fromX, fromY, toX, toY);\r
 }\r