Add secondry adapter command for UCCI or USI
[xboard.git] / winboard / wsettings.c
index e3ddead..0c92fbc 100644 (file)
@@ -34,7 +34,7 @@ int breaks[MAX_OPTIONS];
 int checks, combos, buttons, layout, groups;\r
 char title[MSG_SIZ];\r
 char *engineName, *engineDir, *engineChoice, *engineLine, *nickName, *params;\r
-Boolean isUCI, hasBook, storeVariant, v1, addToList;\r
+Boolean isUCI, hasBook, storeVariant, v1, addToList, useNick, isUCCI;\r
 extern Option installOptions[], matchOptions[];\r
 char *engineNr[] = { N_("First"), N_("Second"), NULL };\r
 char *engineList[1000] = {" "}, *engineMnemonic[1000] = {""};\r
@@ -352,8 +352,9 @@ GetOptionValues(HWND hDlg, ChessProgramState *cps, Option *optionList)
                if(!success) break;\r
                if(!cps) {\r
                    char *p;\r
-                   if(*(char**)optionList[j].target) free(*(char**)optionList[j].target);\r
-                   *(char**)optionList[j].target = p = text;\r
+                   p = (optionList[j].type != FileName ? strdup(text) : InterpretFileName(text, homeDir)); // all files relative to homeDir!\r
+                   FREE(*(char**)optionList[j].target); *(char**)optionList[j].target = p;
+                   free(text); text = p;\r
                    while(*p++ = *text++) if(p[-1] == '\r') p--; // crush CR\r
                    break;\r
                }\r
@@ -396,10 +397,12 @@ GetOptionValues(HWND hDlg, ChessProgramState *cps, Option *optionList)
     if(!cps && okFunc) ((ButtonCallback*) okFunc)(0);\r
 }\r
 \r
+char *defaultExt[] = { NULL, "pgn", "fen", "exe", "trn", "bin", "log", "ini" };\r
+\r
 LRESULT CALLBACK SettingsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
 {\r
     char buf[MSG_SIZ];\r
-    int i, j;\r
+    int i, j, ext;\r
 \r
     switch( message )\r
     {\r
@@ -445,7 +448,8 @@ LRESULT CALLBACK SettingsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa
                          ofn.hwndOwner = hDlg;\r
                          ofn.hInstance = hInst;\r
                          ofn.lpstrFilter = filter;\r
-                         ofn.nFilterIndex      = 1L + (activeCps ? 0 : activeList[layoutList[(i-2000)/2+1]].max);\r
+                         ofn.nFilterIndex      = 1L + (ext = activeCps ? 0 : activeList[layoutList[(i-2000)/2+1]].max);\r
+                         ofn.lpstrDefExt       = defaultExt[ext];\r
                          ofn.lpstrFile = buf;\r
                          ofn.nMaxFile = sizeof(buf);\r
                          ofn.lpstrTitle = _("Choose File");\r
@@ -607,7 +611,8 @@ EngineOptionsPopup(HWND hwnd, ChessProgramState *cps)
 }\r
 \r
 void InstallOK()\r
-{\r
+{
+    if(isUCCI) isUCI = 2;\r
     if(engineChoice[0] == engineNr[0][0])  Load(&first, 0); else Load(&second, 1);\r
 }\r
 \r
@@ -615,11 +620,13 @@ Option installOptions[] = {
   {   0,  0,    0, NULL, (void*) &engineLine, (char*) engineMnemonic, engineList, ComboBox, N_("Select engine from list:") },\r
   {   0,  0,    0, NULL, NULL, NULL, NULL, Label, N_("or specify one below:") },\r
   {   0,  0,    0, NULL, (void*) &nickName, NULL, NULL, TextBox, N_("Nickname (optional):") },\r
-  {   0,  0,    3, NULL, (void*) &engineName, NULL, NULL, FileName, N_("Engine Executable:") },\r
-  {   0,  0,    0, NULL, (void*) &params, NULL, NULL, TextBox, N_("Engine command-line Parameters:") },\r
-  {   0,  0,    0, NULL, (void*) &engineDir, NULL, NULL, PathName, N_("Engine Directory:") },\r
+  {   0,  0,    0, NULL, (void*) &useNick, NULL, NULL, CheckBox, N_("Use nickname in PGN tag") },\r
+  {   0,  0,    3, NULL, (void*) &engineName, NULL, NULL, FileName, N_("Engine (*.exe):") },\r
+  {   0,  0,    0, NULL, (void*) &params, NULL, NULL, TextBox, N_("command-line parameters:") },\r
+  {   0,  0,    0, NULL, (void*) &engineDir, NULL, NULL, PathName, N_("directory:") },\r
   {  95,  0,    0, NULL, NULL, NULL, NULL, Label, N_("(Directory will be derived from engine path when empty)") },\r
   {   0,  0,    0, NULL, (void*) &isUCI, NULL, NULL, CheckBox, N_("UCI") },\r
+  {   0,  0,    0, NULL, (void*) &isUCCI, NULL, NULL, CheckBox, N_("UCCI / USI (uses specified /uxiAdapter)") },\r
   {   0,  0,    0, NULL, (void*) &v1, NULL, NULL, CheckBox, N_("WB protocol v1 (skip waiting for features)") },\r
   {   0,  0,    0, NULL, (void*) &addToList, NULL, NULL, CheckBox, N_("Add this engine to the list") },\r
   {   0,  0,    0, NULL, (void*) &hasBook, NULL, NULL, CheckBox, N_("Must not use GUI book") },\r
@@ -650,7 +657,7 @@ void LoadEnginePopUp(HWND hwnd)
 {\r
     int n=0;\r
 \r
-    isUCI = addToList = storeVariant = v1 = FALSE; hasBook = TRUE; // defaults\r
+    isUCI = isUCCI = storeVariant = v1 = useNick = FALSE; addToList = hasBook = TRUE; // defaults\r
     if(engineDir)    free(engineDir);    engineDir = strdup("");\r
     if(params)       free(params);       params = strdup("");\r
     if(nickName)     free(nickName);     nickName = strdup("");\r
@@ -679,11 +686,12 @@ Option tourneyOptions[] = {
   { 0,  0,          4, NULL, (void*) &appData.tourneyFile, "", NULL, FileName, N_("Tournament file:") },\r
   { 0,  1,          0, NULL, (void*) &engineChoice, (char*) (engineMnemonic+1), (engineMnemonic+1), ComboBox, N_("Select Engine:") },\r
   { 0xD, 7,         0, NULL, (void*) &engineName, "", NULL, TextBox, "Tourney participants:" },\r
-  { 0, -1,         10, NULL, (void*) &appData.tourneyType, "", NULL, Spin, N_("Tourney type (0=RR, 1=gauntlet):") },\r
+  { 0,  0,         10, NULL, (void*) &appData.tourneyType, "", NULL, Spin, N_("Tourney type (0=RR, 1=gauntlet):") },\r
   { 0,  0,          0, NULL, (void*) &appData.cycleSync, "", NULL, CheckBox, N_("Sync after cycle") },\r
   { 0,  1, 1000000000, NULL, (void*) &appData.tourneyCycles, "", NULL, Spin, N_("Number of tourney cycles:") },\r
   { 0,  0,          0, NULL, (void*) &appData.roundSync, "", NULL, CheckBox, N_("Sync after round") },\r
   { 0,  1, 1000000000, NULL, (void*) &appData.defaultMatchGames, "", NULL, Spin, N_("Games per Match / Pairing:") },\r
+  { 0,  0,          1, NULL, (void*) &appData.saveGameFile, "", NULL, FileName, N_("File for saving tourney games:") },\r
   { 0,  0,          1, NULL, (void*) &appData.loadGameFile, "", NULL, FileName, N_("Game File with Opening Lines:") },\r
   { 0, -2, 1000000000, NULL, (void*) &appData.loadGameIndex, "", NULL, Spin, N_("Game Number:") },\r
   { 0,  0,          2, NULL, (void*) &appData.loadPositionFile, "", NULL, FileName, N_("File with Start Positions:") },\r
@@ -702,7 +710,7 @@ void AddToTourney(HWND hDlg)
 //    strncat(buf, "\r\n", MSG_SIZ);\r
     int i = ComboBox_GetCurSel(GetDlgItem(hDlg, 2001+2*3));\r
     snprintf(buf, MSG_SIZ, "%s\r\n", engineMnemonic[i+1]);\r
-    SendMessage( GetDlgItem(hDlg, 2001+2*5), EM_SETSEL, 0, 0 );\r
+    SendMessage( GetDlgItem(hDlg, 2001+2*5), EM_SETSEL, 99999, 99999 );\r
     SendMessage( GetDlgItem(hDlg, 2001+2*5), EM_REPLACESEL, (WPARAM) FALSE, (LPARAM) buf );\r
 }\r
 \r