Port grouping to XBoard Load Engine
[xboard.git] / dialogs.c
index f257a83..dea46c9 100644 (file)
--- a/dialogs.c
+++ b/dialogs.c
@@ -235,7 +235,7 @@ GenericReadout (Option *opts, int selected)
 //------------------------------------------- Match Options ------------------------------------------------------
 
 char *engineName, *engineChoice, *tfName;
-char *engineList[MAXENGINES] = {" "}, *engineMnemonic[MAXENGINES] = {""};
+char *engineList[MAXENGINES] = {" "}, *engineMnemonic[MAXENGINES];
 
 static void AddToTourney P((int n));
 static void CloneTourney P((void));
@@ -270,10 +270,10 @@ static Option matchOptions[] = {
 { 0,  1, 1000000000, NULL, (void*) &appData.tourneyCycles, "", NULL, Spin, N_("Number of tourney cycles (or Swiss rounds):") },
 { 0,  1, 1000000000, NULL, (void*) &appData.defaultMatchGames, "", NULL, Spin, N_("Default Number of Games in Match (or Pairing):") },
 { 0,  0, 1000000000, NULL, (void*) &appData.matchPause, "", NULL, Spin, N_("Pause between Match Games (msec):") },
-{ 0,  0,          0, NULL, (void*) &appData.saveGameFile, ".pgn", NULL, FileName, N_("Save Tourney Games on:") },
-{ 0,  0,          0, NULL, (void*) &appData.loadGameFile, ".pgn", NULL, FileName, N_("Game File with Opening Lines:") },
+{ 0,  0,          0, NULL, (void*) &appData.saveGameFile, ".pgn .game", NULL, FileName, N_("Save Tourney Games on:") },
+{ 0,  0,          0, NULL, (void*) &appData.loadGameFile, ".pgn .game", NULL, FileName, N_("Game File with Opening Lines:") },
 { 0, -2, 1000000000, NULL, (void*) &appData.loadGameIndex, "", NULL, Spin, N_("Game Number (-1 or -2 = Auto-Increment):") },
-{ 0,  0,          0, NULL, (void*) &appData.loadPositionFile, ".fen", NULL, FileName, N_("File with Start Positions:") },
+{ 0,  0,          0, NULL, (void*) &appData.loadPositionFile, ".fen .epd .pos", NULL, FileName, N_("File with Start Positions:") },
 { 0, -2, 1000000000, NULL, (void*) &appData.loadPositionIndex, "", NULL, Spin, N_("Position Number (-1 or -2 = Auto-Increment):") },
 { 0,  0, 1000000000, NULL, (void*) &appData.rewindIndex, "", NULL, Spin, N_("Rewind Index after this many Games (0 = never):") },
 { 0,  0,          0, NULL, (void*) &appData.defNoBook, "", NULL, CheckBox, N_("Disable own engine books by default") },
@@ -1218,9 +1218,19 @@ InstallOK (int n)
 static void
 EngSel (int n, int sel)
 {
-    if(sel < 1) return;
-    ASSIGN(engineLine, engineList[sel]);
-    InstallOK(0);
+    int nr;
+    char buf[MSG_SIZ];
+    if(sel < 1) buf[0] = NULLCHAR; // back to top level
+    else if(engineList[sel][0] == '#') safeStrCpy(buf, engineList[sel], MSG_SIZ); // group header, open group
+    else { // normal line, select engine
+       ASSIGN(engineLine, engineList[sel]);
+       InstallOK(0);
+       return;
+    }
+    nr = NamesToList(firstChessProgramNames, engineList, engineMnemonic, buf); // replace list by only the group contents
+    ASSIGN(engineMnemonic[0], buf);
+    LoadListBox(&installOptions[1], _("# no engines are installed"));
+    HighlightWithScroll(&installOptions[1], 0, nr);
 }
 
 static void
@@ -1232,7 +1242,8 @@ LoadEngineProc (int engineNr, char *title)
    if(engineDir)    free(engineDir);    engineDir = strdup("");
    if(nickName)     free(nickName);     nickName = strdup("");
    if(params)       free(params);       params = strdup("");
-   NamesToList(firstChessProgramNames, engineList, engineMnemonic, "all");
+   ASSIGN(engineMnemonic[0], "");
+   NamesToList(firstChessProgramNames, engineList, engineMnemonic, "");
    GenericPopUp(installOptions, title, TransientDlg, BoardWindow, MODAL, 0);
 }