int j=layoutList[i];\r
if(j == -2) SetDlgItemText( hDlg, 2000+2*i, ". . ." );\r
if(j<0) continue;\r
- name = optionList[j].name;\r
+ name = cps ? optionList[j].name : _(optionList[j].name);\r
if(strstr(name, "Polyglot ") == name) name += 9;\r
SetDlgItemText( hDlg, 2000+2*i, name );\r
//if(appData.debugMode) fprintf(debugFP, "# %s = %d\n",optionList[j].name, optionList[j].value );\r
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
// CenterWindow(hDlg, GetWindow(hDlg, GW_OWNER));\r
SetOptionValues(hDlg, activeCps, activeList);\r
\r
-// SetFocus(GetDlgItem(hDlg, IDC_NFG_Edit));\r
+ SetFocus(GetDlgItem(hDlg, IDCANCEL));\r
\r
break;\r
\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
break;\r
case Label:\r
extra = activeList[layoutList[i/2]].value;\r
- AddControl(x+extra, y+1, 290-extra, 9, 0x0082, SS_ENDELLIPSIS | WS_VISIBLE | WS_CHILD, i);\r
+ AddControl(x+extra, y+1, 290-extra, 9, 0x0082, SS_ENDELLIPSIS | WS_VISIBLE | WS_CHILD | WS_TABSTOP, i);\r
break;\r
case FileName:\r
case PathName:\r
case Button:\r
case ResetButton:\r
case SaveButton:\r
- AddControl(x-2, y, 65, 13, 0x0080, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD, i);\r
+ AddControl(x-2, y, 65, 13, 0x0080, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | WS_TABSTOP, i);\r
case Message:\r
default:\r
break;\r
void\r
CreateDialogTemplate(int *layoutList, int nr, Option *optionList)\r
{\r
- int i, j, x=1, y=0, buttonRows, breakPoint = -1, k=0;\r
+ int i, ii, j, x=1, y=0, buttonRows, breakPoint = -1, k=0;\r
\r
template.header.cdit = 0;\r
template.header.cx = 307;\r
template.header.cx = 625;\r
}\r
\r
- for(i=0; i<nr; i++) {\r
- if(k < groups && i == boxList[k]) {\r
+ for(ii=0; ii<nr; ii++) {\r
+ i = ii^1; if(i == nr) i = ii; // if two on one line, swap order of treatment, to get good (left to right) tabbing order.\r
+ if(k < groups && ii == boxList[k]) {\r
y += 10;\r
AddControl(x+2, y+13*(i>>1)-2, 301, 13*(boxList[k+1]-boxList[k]>>1)+8,\r
0x0082, WS_VISIBLE | WS_CHILD | SS_BLACKFRAME, 2400);\r
AddControl(x+60, y+13*(i>>1)-6, 10*groupNameList[k]/3, 10,\r
- 0x0082, SS_ENDELLIPSIS | WS_VISIBLE | WS_CHILD, 2*(i+MAX_OPTIONS));\r
+ 0x0082, SS_ENDELLIPSIS | WS_VISIBLE | WS_CHILD, 2*(ii+MAX_OPTIONS));\r
}\r
j = layoutList[i];\r
if(j >= 0)\r
AddOption(x+155-150*(i&1), y+13*(i>>1)+5, optionList[j].type, 2*i);\r
- if(k < groups && i+1 == boxList[k+1]) {\r
+ if(k < groups && ii+1 == boxList[k+1]) {\r
k += 2; y += 4;\r
}\r
- if(i+1 == breakPoint) { x += 318; y = -13*(breakPoint>>1); }\r
+ if(ii+1 == breakPoint) { x += 318; y = -13*(breakPoint>>1); }\r
}\r
// add butons at the bottom of dialog window\r
y += 13*(nr>>1)+5;\r
\r
- AddControl(x+225, y+18*(buttonRows-1), 30, 15, 0x0080, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD, IDOK-2000);\r
- AddControl(x+260, y+18*(buttonRows-1), 40, 15, 0x0080, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD, IDCANCEL-2000);\r
for(i=0; i<buttons; i++) {\r
- AddControl(x+70*(i%4)+5, y+18*(i/4), 65, 15, 0x0080, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD, 2*(nr+i));\r
+ AddControl(x+70*(i%4)+5, y+18*(i/4), 65, 15, 0x0080, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | WS_TABSTOP, 2*(nr+i));\r
layoutList[nr+i] = buttonList[i];\r
}\r
+ AddControl(x+225, y+18*(buttonRows-1), 30, 15, 0x0080, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | WS_TABSTOP, IDOK-2000);\r
+ AddControl(x+260, y+18*(buttonRows-1), 40, 15, 0x0080, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | WS_TABSTOP, IDCANCEL-2000);\r
template.title[8] = optionList == first.option ? '1' : '2';\r
template.header.cy = y += 18*buttonRows+2;\r
template.header.style &= ~WS_VSCROLL;\r
}\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(!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(appData.tourneyFile)) MatchEvent(2); else return 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, 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
- { 0xD, 7, 0, NULL, (void*) &appData.participants, "", NULL, TextBox, "Tourney participants:" },\r
+ { 0xD, 7, 0, NULL, (void*) &appData.participants, "", NULL, TextBox, N_("Tourney participants:") },\r
{ 0, 0, 0, NULL, (void*) &swiss, "", NULL, CheckBox, N_("Use Swiss pairing engine (cycles = rounds)") },\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, 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
- 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