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
Option tourneyOptions[] = {\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, 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*) &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