removed unused variables (-Wunused-variable)
[xboard.git] / dialogs.c
index 9b5995c..c50651a 100644 (file)
--- a/dialogs.c
+++ b/dialogs.c
@@ -103,45 +103,47 @@ SetCurrentComboSelection (Option *opt)
 void
 GenericUpdate (Option *opts, int selected)
 {
-    int i, j;
+    int i;
     char buf[MSG_SIZ];
-    float x;
-       for(i=0; ; i++) {
-           if(selected >= 0) { if(i < selected) continue; else if(i > selected) break; }
-           switch(opts[i].type) {
-               case TextBox:
-               case FileName:
-               case PathName:
-                   SetWidgetText(&opts[i],  *(char**) opts[i].target, -1);
-                   break;
-               case Spin:
-                   sprintf(buf, "%d", *(int*) opts[i].target);
-                   SetWidgetText(&opts[i], buf, -1);
-                   break;
-               case Fractional:
-                   sprintf(buf, "%4.2f", *(float*) opts[i].target);
-                   SetWidgetText(&opts[i], buf, -1);
-                   break;
-               case CheckBox:
-                   SetWidgetState(&opts[i],  *(Boolean*) opts[i].target);
-                   break;
-               case ComboBox:
-                 if(opts[i].min & COMBO_CALLBACK) break;
-                 SetCurrentComboSelection(opts+i);
-                   // TODO: actually display this (but it is never used that way...)
-                   break;
-               case EndMark:
-                   return;
-           default:
-               printf("GenericUpdate: unexpected case in switch.\n");
-               case ListBox:
-               case Button:
-               case SaveButton:
-               case Label:
-               case Break:
-             break;
-           }
-       }
+
+    for(i=0; ; i++)
+      {
+       if(selected >= 0) { if(i < selected) continue; else if(i > selected) break; }
+       switch(opts[i].type)
+         {
+         case TextBox:
+         case FileName:
+         case PathName:
+           SetWidgetText(&opts[i],  *(char**) opts[i].target, -1);
+           break;
+         case Spin:
+           sprintf(buf, "%d", *(int*) opts[i].target);
+           SetWidgetText(&opts[i], buf, -1);
+           break;
+         case Fractional:
+           sprintf(buf, "%4.2f", *(float*) opts[i].target);
+           SetWidgetText(&opts[i], buf, -1);
+           break;
+         case CheckBox:
+           SetWidgetState(&opts[i],  *(Boolean*) opts[i].target);
+           break;
+         case ComboBox:
+           if(opts[i].min & COMBO_CALLBACK) break;
+           SetCurrentComboSelection(opts+i);
+           // TODO: actually display this (but it is never used that way...)
+           break;
+         case EndMark:
+           return;
+         default:
+           printf("GenericUpdate: unexpected case in switch.\n");
+         case ListBox:
+         case Button:
+         case SaveButton:
+         case Label:
+         case Break:
+           break;
+         }
+      }
 }
 
 //------------------------------------------- Read out dialog controls ------------------------------------
@@ -965,7 +967,6 @@ NewCommentPopup (char *title, char *text, int index)
 void
 EditCommentProc ()
 {
-    int j;
     if (PopDown(CommentDlg)) { // popdown succesful
 //     MarkMenuItem("Edit.EditComment", False);
 //     MarkMenuItem("View.Comments", False);
@@ -1454,13 +1455,13 @@ static int count;
 static void PromoPick P((int n));
 
 static Option promoOptions[] = {
-{   0,         0,    0, NULL, (void*) &PromoPick, NULL, NULL, Button, "" },
-{   0,  SAME_ROW,    0, NULL, (void*) &PromoPick, NULL, NULL, Button, "" },
-{   0,  SAME_ROW,    0, NULL, (void*) &PromoPick, NULL, NULL, Button, "" },
-{   0,  SAME_ROW,    0, NULL, (void*) &PromoPick, NULL, NULL, Button, "" },
-{   0,  SAME_ROW,    0, NULL, (void*) &PromoPick, NULL, NULL, Button, "" },
-{   0,  SAME_ROW,    0, NULL, (void*) &PromoPick, NULL, NULL, Button, "" },
-{   0,  SAME_ROW,    0, NULL, (void*) &PromoPick, NULL, NULL, Button, "" },
+{   0,         0,    0, NULL, (void*) &PromoPick, NULL, NULL, Button, NULL },
+{   0,  SAME_ROW,    0, NULL, (void*) &PromoPick, NULL, NULL, Button, NULL },
+{   0,  SAME_ROW,    0, NULL, (void*) &PromoPick, NULL, NULL, Button, NULL },
+{   0,  SAME_ROW,    0, NULL, (void*) &PromoPick, NULL, NULL, Button, NULL },
+{   0,  SAME_ROW,    0, NULL, (void*) &PromoPick, NULL, NULL, Button, NULL },
+{   0,  SAME_ROW,    0, NULL, (void*) &PromoPick, NULL, NULL, Button, NULL },
+{   0,  SAME_ROW,    0, NULL, (void*) &PromoPick, NULL, NULL, Button, NULL },
 {   0, SAME_ROW | NO_OK, 0, NULL, NULL, "", NULL, EndMark , "" }
 };
 
@@ -1489,8 +1490,9 @@ PromoPick (int n)
 static void
 SetPromo (char *name, int nr, char promoChar)
 {
-    safeStrCpy(promoOptions[nr].name, name, MSG_SIZ);
+    ASSIGN(promoOptions[nr].name, name);
     promoOptions[nr].value = promoChar;
+    promoOptions[nr].min = SAME_ROW;
 }
 
 void
@@ -1526,6 +1528,7 @@ PromotionPopUp ()
       SetPromo(_("Defer"), --count, '=');
       SetPromo(_("Promote"), --count, '+');
   }
+  promoOptions[count].min = 0;
   GenericPopUp(promoOptions + count, "Promotion", PromoDlg, BoardWindow, NONMODAL, 0);
 }
 
@@ -1762,6 +1765,8 @@ DisplayTitle (char *text)
 
     if (text == NULL) text = "";
 
+    if(partnerUp) { SetDialogTitle(DummyDlg, text); return; }
+
     if (*text != NULLCHAR) {
       safeStrCpy(icon, text, sizeof(icon)/sizeof(icon[0]) );
       safeStrCpy(title, text, sizeof(title)/sizeof(title[0]) );
@@ -1838,15 +1843,15 @@ static void
 PMSelect (int n)
 {   // user callback for board context menus
     if (pmFromX < 0 || pmFromY < 0) return;
-    if(n == 25) DropMenuEvent(dropMenuTranslation[values[n]], pmFromX, pmFromY);
-    else EditPositionMenuEvent(pieceMenuTranslation[n-23][values[n]], pmFromX, pmFromY);
+    if(n == W_DROP) DropMenuEvent(dropMenuTranslation[values[n]], pmFromX, pmFromY);
+    else EditPositionMenuEvent(pieceMenuTranslation[n - W_MENUW][values[n]], pmFromX, pmFromY);
 }
 
-int
+static void
 CCB (int n)
 {
     shiftKey = (ShiftKeys() & 3) != 0;
-    ClockClick(n == 12);
+    ClockClick(n == W_BLACK);
 }
 
 Option mainOptions[] = { // description of main window in terms of generic dialog creator
@@ -1909,6 +1914,7 @@ Exp (int n, int x, int y)
        if(but3) MovePV(x, y, lineGap + BOARD_HEIGHT * (squareSize + lineGap));
        return NULL;
     }
+    if(n != 10 && PopDown(PromoDlg)) fromX = fromY = -1; // user starts fiddling with board when promotion dialog is up
     shiftKey = ShiftKeys();
     controlKey = (shiftKey & 0xC) != 0;
     shiftKey = (shiftKey & 3) != 0;
@@ -1939,7 +1945,6 @@ Exp (int n, int x, int y)
 Option *
 BoardPopUp (int squareSize, int lineGap, void *clockFontThingy)
 {
-    extern Option *dialogOptions[];
     int i, size = BOARD_WIDTH*(squareSize + lineGap) + lineGap;
     mainOptions[W_WHITE].choice = (char**) clockFontThingy;
     mainOptions[W_BLACK].choice = (char**) clockFontThingy;
@@ -1978,12 +1983,13 @@ Option dualOptions[] = { // auxiliary board window
 void
 SlavePopUp ()
 {
+    int size = BOARD_WIDTH*(squareSize + lineGap) + lineGap;
     // copy params from main board
     dualOptions[0].choice = mainOptions[W_WHITE].choice;
     dualOptions[1].choice = mainOptions[W_BLACK].choice;
-    dualOptions[3].value = mainOptions[W_BOARD].value;
-    dualOptions[3].max = dualOptions[2].max = mainOptions[W_BOARD].max; // board size
-    dualOptions[0].max = dualOptions[1].max = mainOptions[W_WHITE].max; // clock width
+    dualOptions[3].value = BOARD_HEIGHT*(squareSize + lineGap) + lineGap;
+    dualOptions[3].max = dualOptions[2].max = size; // board width
+    dualOptions[0].max = dualOptions[1].max = size/2 - 3; // clock width
     GenericPopUp(dualOptions, "XBoard", DummyDlg, BoardWindow, NONMODAL, 1);
 }
 
@@ -2058,7 +2064,7 @@ DisplayMessage (char *message, char *extMessage)
 
 static ChessProgramState *savCps;
 static FILE **savFP;
-static char *fileName, *extFilter, *dirListing, *savMode, **namePtr;
+static char *fileName, *extFilter, *savMode, **namePtr;
 static int folderPtr, filePtr, oldVal, byExtension, extFlag;
 static char curDir[MSG_SIZ], title[MSG_SIZ], *folderList[1000], *fileList[1000];
 
@@ -2067,6 +2073,7 @@ static char *FileTypes[] = {
 "Chess Positions",
 "Tournaments",
 "Opening Books",
+"Sound files",
 "Settings (*.ini)",
 "Log files",
 "All files",
@@ -2084,6 +2091,7 @@ static char *Extensions[] = {
 ".fen .epd .pos",
 ".trn",
 ".bin",
+".wav",
 ".ini",
 ".log",
 "",
@@ -2188,7 +2196,6 @@ ListDir (int pathFlag)
        struct dirent *dp;
        struct stat statBuf;
        static int lastFlag;
-       char buf[MSG_SIZ];
 
        if(pathFlag < 0) pathFlag = lastFlag;
        lastFlag = pathFlag;
@@ -2198,7 +2205,7 @@ ListDir (int pathFlag)
        folderPtr = filePtr = 0; // clear listing
 
        while (dp = readdir(dir)) { // pass 1: list foders
-           char *s = dp->d_name, match;
+           char *s = dp->d_name;
            if(!stat(s, &statBuf) && S_ISDIR(statBuf.st_mode)) { // stat succeeds and tells us it is directory
                if(s[0] == '.' && strcmp(s, "..")) continue; // suppress hidden, except ".."
                ASSIGN(folderList[folderPtr], s); folderPtr++;
@@ -2276,7 +2283,7 @@ DirSelProc (int n, int sel)
     }
 }
 
-FILE *
+void
 Browse (DialogClass dlg, char *label, char *proposed, char *ext, Boolean pathFlag, char *mode, char **name, FILE **fp)
 {
     int j=0;
@@ -2290,8 +2297,7 @@ Browse (DialogClass dlg, char *label, char *proposed, char *ext, Boolean pathFla
     browseOptions[6].textValue = (char*) (pathFlag ? NULL : &FileSelProc); // disable file listbox during path browsing
     ListDir(pathFlag);
     currentCps = NULL;
-    if(GenericPopUp(browseOptions, label, BrowserDlg, dlg, MODAL, 0)) {
-    }
+    GenericPopUp(browseOptions, label, BrowserDlg, dlg, MODAL, 0);
     SetWidgetLabel(&browseOptions[9], FileTypes[j]);
 }