Implement -monoMouse option (XB)
[xboard.git] / dialogs.c
index e02bc17..29003f5 100644 (file)
--- a/dialogs.c
+++ b/dialogs.c
@@ -286,11 +286,11 @@ static Option matchOptions[] = {
 { 0,  0,          0, NULL, (void*) &appData.cycleSync, "", NULL, CheckBox, N_("Sync after cycle") },
 { 0,  LR,       175, NULL, NULL, NULL, NULL, Label, N_("Tourney participants:") },
 { 0, SAME_ROW|RR, 175, NULL, NULL, NULL, NULL, Label, N_("Select Engine:") },
-{ 150, T_VSCRL | T_FILL | T_WRAP,
+{ 200, T_VSCRL | T_FILL | T_WRAP,
                 175, NULL, (void*) &engineName, NULL, NULL, TextBox, "" },
-{ 150, SAME_ROW|RR,
+{ 200, SAME_ROW|RR,
                 175, NULL, (void*) engineMnemonic, (char*) &AddToTourney, NULL, ListBox, "" },
-{ 0, 0, 0, NULL, NULL, NULL, NULL, Break, "" }, // to decouple alignment above and below boxes
+{ 0, SAME_ROW, 0, NULL, NULL, NULL, NULL, Break, "" }, // to decouple alignment above and below boxes
 //{ 0,  COMBO_CALLBACK | NO_GETTEXT,
 //               0, NULL, (void*) &AddToTourney, (char*) (engineMnemonic+1), (engineMnemonic+1), ComboBox, N_("Select Engine:") },
 { 0,  0,         10, NULL, (void*) &appData.tourneyType, "", NULL, Spin, N_("Tourney type (0 = round-robin, 1 = gauntlet):") },
@@ -494,6 +494,18 @@ static Option variantDescriptors[] = {
 { VariantChu,    SAME_ROW, 135, NULL, (void*) &Pick, "#BFFFBF", NULL, Button, N_("chu shogi (12x12)")},
 //{ -1,                   0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_(" ")}, // dummy, to have good alignment
 // optional buttons for engine-defined variants
+{ 0, NO_OK, 0, NULL, NULL, "", NULL, EndMark , "" },
+{ 0, SAME_ROW, 0, NULL, NULL, NULL, NULL, Skip, ""},
+{ VariantUnknown,       0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
+{ VariantUnknown, SAME_ROW,135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
+{ VariantUnknown,       0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
+{ VariantUnknown, SAME_ROW,135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
+{ VariantUnknown,       0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
+{ VariantUnknown, SAME_ROW,135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
+{ VariantUnknown,       0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
+{ VariantUnknown, SAME_ROW,135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
+{ VariantUnknown,       0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
+{ VariantUnknown, SAME_ROW,135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
 { VariantUnknown,       0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
 { VariantUnknown, SAME_ROW,135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
 { VariantUnknown,       0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Skip, NULL },
@@ -550,11 +562,13 @@ NewVariantProc ()
 {
    static int start;
    int i, last;
-   char buf[MSG_SIZ];
    ranksTmp = filesTmp = sizeTmp = -1; // prefer defaults over actual settings
    if(appData.noChessProgram) sprintf(warning, _("Only bughouse is not available in viewer mode.")); else
    sprintf(warning, _("All variants not supported by the first engine\n(currently %s) are disabled."), first.tidy);
-   if(!start) while(variantDescriptors[start].type != Skip) start++; // locate first spare
+   if(!start) {
+       while(variantDescriptors[start].type != EndMark) start++; // locate spares
+       start += 2; // conditional EndMark and Break
+   }
    last = -1;
    for(i=0; variantDescriptors[start+i].type != EndMark; i++) { // create buttons for engine-defined variants
      char *v = EngineDefinedVariant(&first, i);
@@ -569,9 +583,11 @@ NewVariantProc ()
        variantDescriptors[start+last+1].type = Button;
        variantDescriptors[start+last+1].value = Skip;
    }
-   safeStrCpy(buf, engineVariant, MSG_SIZ); *engineVariant = NULLCHAR; // yeghh...
+   variantDescriptors[start-2].type = (last < 0 ? EndMark : Skip);
+   variantDescriptors[start-1].type = (last < 6 ? Skip : Break);
+   safeStrCpy(engineVariant+100, engineVariant, 100); *engineVariant = NULLCHAR; // yeghh...
    GenericPopUp(variantDescriptors, _("New Variant"), TransientDlg, BoardWindow, MODAL, 0);
-   safeStrCpy(engineVariant, buf, MSG_SIZ); // must temporarily clear to avoid enabling all variant buttons
+   safeStrCpy(engineVariant, engineVariant+100, MSG_SIZ); // must temporarily clear to avoid enabling all variant buttons
 }
 
 //------------------------------------------- Common Engine Options -------------------------------------
@@ -1445,7 +1461,7 @@ SecondSettingsProc ()
 //----------------------------------------------- Load Engine --------------------------------------
 
 char *engineDir, *engineLine, *nickName, *params;
-Boolean isUCI, hasBook, storeVariant, v1, addToList, useNick, secondEng;
+Boolean isUCI, isUSI, hasBook, storeVariant, v1, addToList, useNick, secondEng;
 
 static void EngSel P((int n, int sel));
 static int InstallOK P((int n));
@@ -1461,6 +1477,7 @@ static Option installOptions[] = {
 {   0,  0,    0, NULL, (void*) &engineName, NULL, NULL, FileName, N_("Engine Command:") },
 {   0,  LR,   0, NULL, NULL, NULL, NULL, Label, N_("(Directory will be derived from engine path when empty)") },
 {   0,  0,    0, NULL, (void*) &isUCI, NULL, NULL, CheckBox, N_("UCI") },
+{   0,  0,    0, NULL, (void*) &isUSI, NULL, NULL, CheckBox, N_("USI/UCCI (uses specified -uxiAdapter)") },
 {   0,  0,    0, NULL, (void*) &v1, NULL, NULL, CheckBox, N_("WB protocol v1 (do not wait for engine features)") },
 {   0,  0,    0, NULL, (void*) &hasBook, NULL, NULL, CheckBox, N_("Must not use GUI book") },
 {   0,  0,    0, NULL, (void*) &addToList, NULL, NULL, CheckBox, N_("Add this engine to the list") },
@@ -1475,6 +1492,10 @@ InstallOK (int n)
        ASSIGN(engineLine, engineList[n]);
     }
     PopDown(TransientDlg); // early popdown, to allow FreezeUI to instate grab
+    if(isUSI) {
+       isUCI = 2; // kludge to pass isUSI to Load()
+       if(!*appData.ucciAdapter) { ASSIGN(appData.ucciAdapter, "usi2wb -%variant \"%fcp\"\"%fd\""); } // make sure -uxiAdapter is defined
+    }
     if(!secondEng) Load(&first, 0); else Load(&second, 1);
     return FALSE; // no double PopDown!
 }
@@ -1500,7 +1521,7 @@ EngSel (int n, int sel)
 static void
 LoadEngineProc (int engineNr, char *title)
 {
-   isUCI = storeVariant = v1 = useNick = False; addToList = hasBook = True; // defaults
+   isUCI = isUSI = storeVariant = v1 = useNick = False; addToList = hasBook = True; // defaults
    secondEng = engineNr;
    if(engineLine)   free(engineLine);   engineLine = strdup("");
    if(engineDir)    free(engineDir);    engineDir = strdup(".");
@@ -2133,6 +2154,7 @@ GLT_OK (int n)
 {
     GLT_ParseList();
     appData.gameListTags = strdup(lpUserGLT);
+    GameListUpdate();
     return 1;
 }
 
@@ -2397,7 +2419,8 @@ DisplayLogos (Option *w1, Option *w2)
 {
        void *whiteLogo = first.programLogo, *blackLogo = second.programLogo;
        if(appData.autoLogo) {
-
+         if(appData.noChessProgram) whiteLogo = blackLogo = NULL;
+         if(appData.icsActive) whiteLogo = blackLogo = second.programLogo;
          switch(gameMode) { // pick logos based on game mode
            case IcsObserving:
                whiteLogo = second.programLogo; // ICS logo
@@ -2521,6 +2544,12 @@ Exp (int n, int x, int y)
     static int but1, but3, oldW, oldH;
     int menuNr = -3, sizing, f, r;
     TimeMark now;
+    extern Boolean right;
+
+    if(right) {  // kludgy way to let button 1 double as button 3 when back-end requests this
+       if(but1 && n == 0) but1 = 0, but3 = 1;
+       else if(n == -1) n = -3, right = FALSE;
+    }
 
     if(n == 0) { // motion
        if(SeekGraphClick(Press, x, y, 1)) return NULL;
@@ -2572,13 +2601,14 @@ Option *
 BoardPopUp (int squareSize, int lineGap, void *clockFontThingy)
 {
     int i, size = BOARD_WIDTH*(squareSize + lineGap) + lineGap, logo = appData.logoSize;
+    int f = 2*appData.fixedSize; // width fudge, needed for unknown reasons to not clip board
     mainOptions[W_WHITE].choice = (char**) clockFontThingy;
     mainOptions[W_BLACK].choice = (char**) clockFontThingy;
     mainOptions[W_BOARD].value = BOARD_HEIGHT*(squareSize + lineGap) + lineGap;
     mainOptions[W_BOARD].max = mainOptions[W_SMALL].max = size; // board size
     mainOptions[W_SMALL].max = size - 2; // board title (subtract border!)
     mainOptions[W_BLACK].max = mainOptions[W_WHITE].max = size/2-3; // clock width
-    mainOptions[W_MESSG].max = appData.showButtonBar ? size-135 : size-2; // message
+    mainOptions[W_MESSG].max = appData.showButtonBar ? size-135+f : size-2+f; // message
     mainOptions[W_MENU].max = size-40; // menu bar
     mainOptions[W_TITLE].type = appData.titleInWindow ? Label : Skip ;
     if(logo && logo <= size/4) { // Activate logos
@@ -2700,6 +2730,7 @@ DisplayMessage (char *message, char *extMessage)
 
 #define MAXFILES 1000
 
+static DialogClass savDlg;
 static ChessProgramState *savCps;
 static FILE **savFP;
 static char *fileName, *extFilter, *savMode, **namePtr;
@@ -2782,7 +2813,7 @@ BrowseOK (int n)
                    snprintf(title, MSG_SIZ, "%s", fileName);
                else
                    snprintf(title, MSG_SIZ, "%s/%s", curDir, fileName);
-               SetWidgetText((Option*) savFP, title, TransientDlg);
+               SetWidgetText((Option*) savFP, title, savDlg);
                currentCps = savCps; // could return to Engine Settings dialog!
                return TRUE;
        }
@@ -2939,7 +2970,7 @@ void
 Browse (DialogClass dlg, char *label, char *proposed, char *ext, Boolean pathFlag, char *mode, char **name, FILE **fp)
 {
     int j=0;
-    savFP = fp; savMode = mode, namePtr = name, savCps = currentCps, oldVal = values[9]; // save params, for use in callback
+    savFP = fp; savMode = mode, namePtr = name, savCps = currentCps, oldVal = values[9], savDlg = dlg; // save params, for use in callback
     ASSIGN(extFilter, ext);
     ASSIGN(fileName, proposed ? proposed : "");
     for(j=0; Extensions[j]; j++) // look up actual value in list of possible values, to get selection nr