for(k=0; k<optionList[j].max; k++) {\r
if(!strcmp(choices[k], newText)) new = k;\r
}\r
- if(!cps && new) {\r
+ if(!cps && new > 0) {\r
if(*(char**)optionList[j].target) free(*(char**)optionList[j].target);\r
*(char**)optionList[j].target = strdup(optionList[j].choice[new]);\r
break;\r
if( activeList[j].type == SaveButton)\r
GetOptionValues(hDlg, activeCps, activeList);\r
else if( activeList[j].type != Button) break;\r
+ else if( !activeCps ) { (*(ButtonCallback*) activeList[j].target)(hDlg); break; }\r
snprintf(buf, MSG_SIZ, "option %s\n", activeList[j].name);\r
SendToProgram(buf, activeCps);\r
}\r
int MatchOK()\r
{\r
if(autoinc) appData.loadGameIndex = appData.loadPositionIndex = -(twice + 1);\r
+ if(!appData.loadGameFile[0]) appData.loadGameIndex = -2*twice; // kludge to pass value of "twice" for use in GUI book\r
if(swiss) { appData.defaultMatchGames = 1; appData.tourneyType = -1; }\r
- if(CreateTourney(tfName)) MatchEvent(2); else return !appData.participants[0];\r
- return 1;\r
+ if(CreateTourney(tfName) && !matchMode) { // CreateTourney reloads original settings if file already existed\r
+ MatchEvent(2);\r
+ return 1; // close dialog\r
+ }\r
+ return matchMode || !appData.participants[0]; // if we failed to create and are not in playing, forbid popdown if there are participants\r
+}\r
+\r
+char *GetParticipants(HWND hDlg)\r
+{\r
+ int len = GetWindowTextLength(GetDlgItem(hDlg, 2001+2*9)) + 1;\r
+ char *participants,*p, *q;\r
+ if(len < 4) return NULL; // box is empty (enough)\r
+ participants = (char*) malloc(len);\r
+ GetDlgItemText(hDlg, 2001+2*9, participants, len );\r
+ p = q = participants;\r
+ while(*p++ = *q++) if(p[-1] == '\r') p--;\r
+ return participants;\r
+}\r
+\r
+void ReplaceParticipant(HWND hDlg)\r
+{\r
+ char *participants = GetParticipants(hDlg);\r
+ Substitute(participants, TRUE);\r
+}\r
+ \r
+void UpgradeParticipant(HWND hDlg)\r
+{\r
+ char *participants = GetParticipants(hDlg);\r
+ Substitute(participants, FALSE);\r
}\r
\r
+void Inspect(HWND hDlg)\r
+{\r
+ FILE *f;\r
+ char name[MSG_SIZ];\r
+ GetDlgItemText(hDlg, 2001+2*1, name, MSG_SIZ );\r
+ if(name && name[0] && (f = fopen(name, "r")) ) {\r
+ char *saveSaveFile;\r
+ saveSaveFile = appData.saveGameFile; appData.saveGameFile = NULL; // this is a persistent option, protect from change\r
+ ParseArgsFromFile(f);\r
+ autoinc = ((appData.loadPositionFile[0] ? appData.loadGameIndex : appData.loadPositionIndex) < 0);\r
+ twice = ((appData.loadPositionFile[0] ? appData.loadGameIndex : appData.loadPositionIndex) == -2);\r
+ swiss = appData.tourneyType < 0;\r
+ SetOptionValues(hDlg, NULL, activeList);\r
+ FREE(appData.saveGameFile); appData.saveGameFile = saveSaveFile;\r
+ } else DisplayError(_("First you must specify an existing tourney file to clone"), 0);\r
+}\r
+\r
+void TimeControlOptionsPopup P((HWND hDlg));\r
+void UciOptionsPopup P((HWND hDlg));\r
+\r
Option tourneyOptions[] = {\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
{ 0, 0, 0, NULL, (void*) &autoinc, "", NULL, CheckBox, N_("Step through lines/positions in file") },\r
{ 0, 0, 1000000000, NULL, (void*) &appData.rewindIndex, "", NULL, Spin, N_("Rewind after (0 = never):") },\r
{ 0, 0, 0, NULL, (void*) &twice, "", NULL, CheckBox, N_("Use each line/position twice") },\r
+ { 0, 0, 0, NULL, (void*) &appData.defNoBook, "", NULL, CheckBox, N_("Make all use GUI book by default") },\r
{ 0, 0, 1000000000, NULL, (void*) &appData.matchPause, "", NULL, Spin, N_("Pause between Games (ms):") },\r
+ { 0, 0, 0, NULL, (void*) &ReplaceParticipant, "", NULL, Button, N_("Replace Engine") },\r
+ { 0, 0, 0, NULL, (void*) &UpgradeParticipant, "", NULL, Button, N_("Upgrade Engine") },\r
+ { 0, 0, 0, NULL, (void*) &TimeControlOptionsPopup, "", NULL, Button, N_("Time Control...") },\r
+ { 0, 0, 0, NULL, (void*) &UciOptionsPopup, "", NULL, Button, N_("Common Engine...") },\r
+ { 0, 0, 0, NULL, (void*) &Inspect, "", NULL, Button, N_("Clone Tourney") },\r
{ 0, 0, 0, NULL, (void*) &MatchOK, "", NULL, EndMark , "" }\r
};\r
\r
NamesToList(firstChessProgramNames, engineList, engineMnemonic);\r
comboCallback = &AddToTourney;\r
autoinc = appData.loadGameIndex < 0 || appData.loadPositionIndex < 0;\r
- twice = TRUE; swiss = appData.tourneyType < 0;\r
+ twice = FALSE; swiss = appData.tourneyType < 0;\r
while(engineList[n]) n++; tourneyOptions[3].max = n-1;\r
snprintf(title, MSG_SIZ, _("Tournament and Match Options"));\r
ASSIGN(tfName, appData.tourneyFile[0] ? appData.tourneyFile : MakeName(appData.defName));\r