Let XBoard propose name of tourney file
[xboard.git] / winboard / wsettings.c
index 023eb2d..84c02cb 100644 (file)
@@ -362,7 +362,7 @@ GetOptionValues(HWND hDlg, ChessProgramState *cps, Option *optionList)
                if(cps) len = MSG_SIZ - strlen(optionList[j].name) - 9, text = newText;\r
                else    len = GetWindowTextLength(GetDlgItem(hDlg, 2001+2*i)) + 1, text = (char*) malloc(len);\r
                success = GetDlgItemText( hDlg, 2001+2*i, text, len );\r
-               if(!success) break;\r
+               if(!success) text[0] = NULLCHAR; // empty string can be valid input\r
                if(!cps) {\r
                    char *p;\r
                    p = (optionList[j].type != FileName ? strdup(text) : InterpretFileName(text, homeDir)); // all files relative to homeDir!\r
@@ -687,17 +687,18 @@ void LoadEnginePopUp(HWND hwnd)
 }\r
 \r
 Boolean autoinc, twice, swiss;\r
+char *tfName;\r
 \r
 int MatchOK()\r
 {\r
     if(autoinc) appData.loadGameIndex = appData.loadPositionIndex = -(twice + 1);\r
     if(swiss) { appData.defaultMatchGames = 1; appData.tourneyType = -1; }\r
-    if(CreateTourney(appData.tourneyFile)) MatchEvent(2); else return 0;\r
+    if(CreateTourney(tfName)) MatchEvent(2); else return !appData.participants[0];\r
     return 1;\r
 }\r
 \r
 Option tourneyOptions[] = {\r
-  { 0,  0,          4, NULL, (void*) &appData.tourneyFile, "", NULL, FileName, N_("Tournament file:") },\r
+  { 0,  0,          4, NULL, (void*) &tfName, "", NULL, FileName, N_("Tournament file:") },\r
   { 30, 0,          0, NULL, NULL, NULL, NULL, Label, N_("If you specify an existing file, the rest of this dialog will be ignored.") },\r
   { 30, 0,          0, NULL, NULL, NULL, NULL, Label, N_("Otherwise, the file will be created, with the settings you specify below:") },\r
   { 0,  1,          0, NULL, (void*) &engineChoice, (char*) (engineMnemonic+1), (engineMnemonic+1), ComboBox, N_("Select Engine:") },\r
@@ -742,7 +743,7 @@ void TourneyPopup(HWND hwnd)
     twice = TRUE; swiss = appData.tourneyType < 0;\r
     while(engineList[n]) n++; tourneyOptions[3].max = n-1;\r
     snprintf(title, MSG_SIZ, _("Tournament and Match Options"));\r
-    if(appData.pairingEngine[0]) tourneyOptions[5].min = -19;\r
+    ASSIGN(tfName, appData.tourneyFile[0] ? appData.tourneyFile : MakeName(appData.defName));\r
 \r
     GenericPopup(hwnd, tourneyOptions);\r
 }\r