char *engineName, *engineDir, *engineChoice, *engineLine, *nickName, *params;\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[MAXENGINES] = {" "}, *engineMnemonic[MAXENGINES] = {""};\r
+char *engineList[MAXENGINES] = {""}, *engineMnemonic[MAXENGINES] = {""};\r
void (*okFunc)();\r
ChessProgramState *activeCps;\r
Option *activeList;\r
case SaveButton:\r
case Button: buttonList[buttons++] = nextOption; lastType = Button; break;\r
case TextBox:\r
+ case ListBox:\r
case FileName:\r
case PathName:\r
case Slider:\r
if(!stop)\r
nextType = Button; // kudge to flush remaining checks and combos undistorted\r
// Take a new line if a spin follows combos or checks, or when we encounter a textbox\r
- if((combos+checks || nextType == TextBox || nextType == FileName || nextType == PathName || nextType == Label) && layout&1) {\r
+ if((combos+checks || nextType == TextBox || nextType == ListBox || nextType == FileName || nextType == PathName || nextType == Label) && layout&1) {\r
layoutList[layout++] = -1;\r
}\r
// The last check or combo before a spin will be put on the same line as that spin (prefix)\r
}\r
// if a combo is followed by a textbox, it must stay at the end of the combo/checks list to appear\r
// immediately above the textbox, so treat it as check. (A check would automatically be and remain there.)\r
- if((nextType == TextBox || nextType == FileName || nextType == PathName) && lastType == ComboBox)\r
+ if((nextType == TextBox || nextType == ListBox || nextType == FileName || nextType == PathName) && lastType == ComboBox)\r
checkList[checks++] = comboList[--combos];\r
// Now append the checks behind the (remaining) combos to treat them as one group\r
for(i=0; i< checks; i++)\r
layoutList[layout++] = -1;\r
layoutList[layout++] = comboList[2*right];\r
}\r
- if(nextType == TextBox || nextType == FileName || nextType == PathName || nextType == Label) {\r
- // A textBox is double width, so must be left-adjusted, and the right column remains empty\r
+ if(nextType == ListBox) {\r
+ // A listBox will be left-adjusted, and cause rearrangement of the elements before it to the right column\r
breaks[layout/2] = lastType == Button ? 0 : 100;\r
layoutList[layout++] = -1;\r
layoutList[layout++] = nextOption - 1;\r
for(i=optionList[nextOption-1].min; i>0; i--) { // extra high text edit\r
+ breaks[layout/2] = -1;\r
layoutList[layout++] = -1;\r
layoutList[layout++] = -1;\r
}\r
+ } else \r
+ if(nextType == TextBox || nextType == FileName || nextType == PathName || nextType == Label) {\r
+ // A textBox is double width, so must be left-adjusted, and the right column remains empty\r
+ breaks[layout/2] = lastType == Button ? 0 : 100;\r
+ layoutList[layout++] = -1;\r
+ layoutList[layout++] = nextOption - 1;\r
+ if(optionList[nextOption-1].min) { // extra high text edit: goes right of existing listbox\r
+ layout -= 2; // remove\r
+ layoutList[layout-2*optionList[nextOption-1].min-2] = nextOption - 1;\r
+ }\r
} else if(nextType == Spin) {\r
// A spin will go in the next available position (right to left!). If it had to be prefixed with\r
// a check or combo, this next position must be to the right, and the prefix goes left to it.\r
}\r
SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) choices[optionList[j].value]);\r
break;\r
+ case ListBox:\r
+ choices = (char**) optionList[j].choice;\r
+ hwndCombo = GetDlgItem(hDlg, 2001+2*i);\r
+ SendMessage(hwndCombo, LB_RESETCONTENT, 0, 0);\r
+ for(k=0; k<optionList[j].max; k++) {\r
+ SendMessage(hwndCombo, LB_ADDSTRING, 0, (LPARAM) choices[k]);\r
+ }\r
+ break;\r
case Button:\r
case SaveButton:\r
default:\r
changed = new >= 0 && (optionList[j].value != new);\r
if(changed) optionList[j].value = new;\r
break;\r
+ case ListBox:\r
+ if(optionList[j].textValue)\r
+ *(int*) optionList[j].textValue = SendDlgItemMessage(hDlg, 2001+2*i, LB_GETCURSEL, 0, 0);\r
case Button:\r
default:\r
break; // are treated instantly, so they have been sent already\r
}\r
if(j < 0) break;\r
if(comboCallback && activeList[j].type == ComboBox && HIWORD(wParam) == CBN_SELCHANGE) {\r
- if(j > 5) break; // Yegh! Must solve problem with more than one ombobox in dialog\r
+ if(j > 5) break; // Yegh! Must solve problem with more than one combobox in dialog\r
(*comboCallback)(hDlg);\r
break;\r
} else\r
+ if(activeList[j].type == ListBox && HIWORD(wParam) == /*LBN_SELCHANGE*/ LBN_DBLCLK) {\r
+ ((ButtonCallback *) activeList[j].target)(hDlg);\r
+ break;\r
+ } else\r
if( activeList[j].type == SaveButton)\r
GetOptionValues(hDlg, activeCps, activeList);\r
else if( activeList[j].type != Button) break;\r
AddControl(x+95, y, 50, 11, 0x0081, ES_AUTOHSCROLL | ES_NUMBER | WS_BORDER | WS_VISIBLE | WS_CHILD | WS_TABSTOP, i+1);\r
break;\r
case TextBox:\r
+ extra = 13*activeList[layoutList[i/2]].min; // when extra high, left-align and put description text above it\r
+ AddControl(x+(extra?50:0), y+1, 95, 9, 0x0082, SS_ENDELLIPSIS | WS_VISIBLE | WS_CHILD, i);\r
+ AddControl(x+(extra?50:95), y+(extra?13:0), extra?105:200, 11+(extra?extra-13:0), 0x0081, ES_AUTOHSCROLL | WS_BORDER | WS_VISIBLE |\r
+ WS_CHILD | WS_TABSTOP | (extra ? ES_MULTILINE | ES_WANTRETURN | WS_VSCROLL :0), i+1);\r
+ break;\r
+ case ListBox:\r
AddControl(x, y+1, 95, 9, 0x0082, SS_ENDELLIPSIS | WS_VISIBLE | WS_CHILD, i);\r
extra = 13*activeList[layoutList[i/2]].min;\r
- AddControl(x+95, y, 200, 11+extra, 0x0081, ES_AUTOHSCROLL | WS_BORDER | WS_VISIBLE | WS_CHILD | WS_TABSTOP | \r
- (extra ? ES_MULTILINE | ES_WANTRETURN | WS_VSCROLL :0), i+1);\r
+ AddControl(x, y+13, 105, 11+extra-13, 0x0083, LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | WS_BORDER | LBS_NOTIFY |\r
+ WS_VISIBLE | WS_CHILD | WS_TABSTOP, i+1);\r
break;\r
case Label:\r
extra = activeList[layoutList[i/2]].value;\r
void\r
CreateDialogTemplate(int *layoutList, int nr, Option *optionList)\r
{\r
- int i, ii, j, x=1, y=0, buttonRows, breakPoint = -1, k=0;\r
+ int i, ii, j, x=1, y=0, maxY=0, buttonRows, breakPoint = -1, k=0;\r
\r
template.header.cdit = 0;\r
template.header.cx = 307;\r
0x0082, SS_ENDELLIPSIS | WS_VISIBLE | WS_CHILD, 2*(ii+MAX_OPTIONS));\r
}\r
j = layoutList[i];\r
- if(j >= 0)\r
+ if(j >= 0) {\r
AddOption(x+155-150*(i&1), y+13*(i>>1)+5, optionList[j].type, 2*i);\r
+ // listboxes have the special power to adjust the width of the column they are in\r
+ if(optionList[j].type == ListBox) x -= optionList[j].value, template.header.cx -= optionList[j].value;\r
+ }\r
if(k < groups && ii+1 == boxList[k+1]) {\r
k += 2; y += 4;\r
}\r
- if(ii+1 == breakPoint) { x += 318; y = -13*(breakPoint>>1); }\r
+ if(ii+1 >= breakPoint && breaks[ii+1>>1] >= 0) { x += 318; maxY = y+13*(ii+1>>1)+5; y = -13*(ii+1>>1); breakPoint = 1000; }\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 | 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
+ y += 18*buttonRows; if(y < maxY) y = maxY;\r
template.title[8] = optionList == first.option ? '1' : '2';\r
- template.header.cy = y += 18*buttonRows+2;\r
+ template.header.cy = y+2;\r
template.header.style &= ~WS_VSCROLL;\r
}\r
\r
return;\r
}\r
\r
+int EnterGroup P((HWND hDlg));\r
+\r
+static int engineNr, selected;\r
+\r
int InstallOK()\r
{\r
+ if(selected >= 0) { ASSIGN(engineLine, engineList[selected]); }\r
if(engineLine[0] == '#') { DisplayError(_("Select single engine from the group"), 0); return 0; }\r
if(isUCCI) isUCI = 2;\r
- if(engineChoice[0] == engineNr[0][0]) Load(&first, 0); else Load(&second, 1);\r
+ if(!engineNr) Load(&first, 0); else Load(&second, 1);\r
return 1;\r
}\r
\r
Option installOptions[] = {\r
- { 0, 0, 0, NULL, (void*) &engineLine, (char*) engineMnemonic, engineList, ComboBox, N_("Select engine from list:") },\r
+// { 0, 0, 0, NULL, (void*) &engineLine, (char*) engineMnemonic, engineList, ComboBox, N_("Select engine from list:") },\r
+ { 195, 14, 0, NULL, (void*) &EnterGroup, (char*) &selected, engineMnemonic, ListBox, 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, 0, NULL, (void*) &useNick, NULL, NULL, CheckBox, N_("Use nickname in PGN tag") },\r
{ 0, 0, 32+3, NULL, (void*) &engineName, NULL, NULL, FileName, N_("Engine (*.exe):") },\r
{ 0, 0, 0, NULL, (void*) ¶ms, NULL, NULL, TextBox, N_("command-line parameters:") },\r
+ { 0, 0, 0, NULL, (void*) &wbOptions, NULL, NULL, TextBox, N_("Special WinBoard options:") },\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 left empty)") },\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
+ { 0, 0, 0, NULL, (void*) &storeVariant, NULL, NULL, CheckBox, N_("Force current variant with this engine") },\r
{ 0, 0, 0, NULL, (void*) &isUCI, NULL, NULL, CheckBox, N_("UCI") },\r
{ 0, 0, 0, NULL, (void*) &v1, NULL, NULL, CheckBox, N_("WB protocol v1 (skip waiting for features)") },\r
{ 0, 0, 0, NULL, (void*) &isUCCI, NULL, NULL, CheckBox, N_("UCCI / USI (uses specified /uxiAdapter)") },\r
- { 0, 0, 0, NULL, (void*) &storeVariant, NULL, NULL, CheckBox, N_("Force current variant with this engine") },\r
- { 0, 0, 2, NULL, (void*) &engineChoice, (char*) engineNr, engineNr, ComboBox, N_("Load mentioned engine as") },\r
{ 0, 1, 0, NULL, (void*) &InstallOK, "", NULL, EndMark , "" }\r
};\r
\r
{\r
char buf[MSG_SIZ];\r
HANDLE hwndCombo = GetDlgItem(hDlg, 2001+2*1);\r
- int i = ComboBox_GetCurSel(hwndCombo);\r
+ int i = SendDlgItemMessage(hDlg, 2001+2*1, LB_GETCURSEL, 0, 0);\r
if(i == 0) buf[0] = NULLCHAR; // back to top level\r
else if(engineList[i][0] == '#') safeStrCpy(buf, engineList[i], MSG_SIZ); // group header, open group\r
- else return 0; // normal line, select engine\r
+ else {\r
+ ASSIGN(engineLine, engineList[i]);\r
+ if(isUCCI) isUCI = 2;\r
+ if(!engineNr) Load(&first, 0); else Load(&second, 1);\r
+ EndDialog( hDlg, 0 );\r
+ return 0; // normal line, select engine\r
+ }\r
installOptions[0].max = NamesToList(firstChessProgramNames, engineList, engineMnemonic, buf); // replace list by only the group contents\r
- SendMessage(hwndCombo, CB_RESETCONTENT, 0, 0);\r
- SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) buf);\r
+ SendMessage(hwndCombo, LB_RESETCONTENT, 0, 0);\r
+ SendMessage(hwndCombo, LB_ADDSTRING, 0, (LPARAM) buf);\r
for(i=1; i<installOptions[0].max; i++) {\r
- SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) engineMnemonic[i]);\r
+ SendMessage(hwndCombo, LB_ADDSTRING, 0, (LPARAM) engineMnemonic[i]);\r
}\r
- SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) 0, (LPARAM) buf);\r
+// SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) 0, (LPARAM) buf);\r
return 0;\r
}\r
\r
-void LoadEnginePopUp(HWND hwnd)\r
+void LoadEnginePopUp(HWND hwnd, int nr)\r
{\r
isUCI = isUCCI = storeVariant = v1 = useNick = FALSE; addToList = hasBook = TRUE; // defaults\r
+ engineNr = nr;\r
if(engineDir) free(engineDir); engineDir = strdup("");\r
if(params) free(params); params = strdup("");\r
if(nickName) free(nickName); nickName = strdup("");\r
- if(engineChoice) free(engineChoice); engineChoice = strdup(engineNr[0]);\r
if(engineLine) free(engineLine); engineLine = strdup("");\r
if(engineName) free(engineName); engineName = strdup("");\r
+ ASSIGN(wbOptions, "");\r
installOptions[0].max = NamesToList(firstChessProgramNames, engineList, engineMnemonic, ""); // only top level\r
- snprintf(title, MSG_SIZ, _("Load Engine"));\r
- comboCallback = &EnterGroup;\r
+ snprintf(title, MSG_SIZ, _("Load %s Engine"), nr ? _("second") : _("first"));\r
\r
GenericPopup(hwnd, installOptions);\r
}\r
\r
char *GetParticipants(HWND hDlg)\r
{\r
- int len = GetWindowTextLength(GetDlgItem(hDlg, 2001+2*9)) + 1;\r
+ int len = GetWindowTextLength(GetDlgItem(hDlg, 2001+2*0)) + 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
+ GetDlgItemText(hDlg, 2001+2*0, participants, len );\r
p = q = participants;\r
while(*p++ = *q++) if(p[-1] == '\r') p--;\r
return participants;\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
+ GetDlgItemText(hDlg, 2001+2*33, name, MSG_SIZ );\r
+ if(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
\r
void TimeControlOptionsPopup P((HWND hDlg));\r
void UciOptionsPopup P((HWND hDlg));\r
+int AddToTourney P((HWND hDlg));\r
\r
Option tourneyOptions[] = {\r
+ { 80, 15, 0, NULL, (void*) &AddToTourney, NULL, engineMnemonic, ListBox, N_("Select Engine:") },\r
+ { 0xD, 15, 0, NULL, (void*) &appData.participants, "", NULL, TextBox, N_("Tourney participants:") },\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, engineMnemonic, ComboBox, N_("Select Engine:") },\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
int AddToTourney(HWND hDlg)\r
{\r
char buf[MSG_SIZ];\r
- HANDLE hwndCombo = GetDlgItem(hDlg, 2001+2*7);\r
- int i = ComboBox_GetCurSel(hwndCombo);\r
+ HANDLE hwndCombo = GetDlgItem(hDlg, 2001+2*1);\r
+ int i = SendDlgItemMessage(hDlg, 2001+2*1, LB_GETCURSEL, 0, 0);\r
+ if(i<0) return 0;\r
if(i == 0) buf[0] = NULLCHAR; // back to top level\r
else if(engineList[i][0] == '#') safeStrCpy(buf, engineList[i], MSG_SIZ); // group header, open group\r
else { // normal line, select engine\r
snprintf(buf, MSG_SIZ, "%s\r\n", engineMnemonic[i]);\r
- SendMessage( GetDlgItem(hDlg, 2001+2*9), EM_SETSEL, 99999, 99999 );\r
- SendMessage( GetDlgItem(hDlg, 2001+2*9), EM_REPLACESEL, (WPARAM) FALSE, (LPARAM) buf );\r
+ SendMessage( GetDlgItem(hDlg, 2001+2*0), EM_SETSEL, 99999, 99999 );\r
+ SendMessage( GetDlgItem(hDlg, 2001+2*0), EM_REPLACESEL, (WPARAM) FALSE, (LPARAM) buf );\r
return 0;\r
}\r
- installOptions[0].max = NamesToList(firstChessProgramNames, engineList, engineMnemonic, buf); // replace list by only the group contents\r
- SendMessage(hwndCombo, CB_RESETCONTENT, 0, 0);\r
- SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) buf);\r
- for(i=1; i<installOptions[0].max; i++) {\r
- SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) engineMnemonic[i]);\r
+ tourneyOptions[0].max = NamesToList(firstChessProgramNames, engineList, engineMnemonic, buf); // replace list by only the group contents\r
+ SendMessage(hwndCombo, LB_RESETCONTENT, 0, 0);\r
+ SendMessage(hwndCombo, LB_ADDSTRING, 0, (LPARAM) buf);\r
+ for(i=1; i<tourneyOptions[0].max; i++) {\r
+ SendMessage(hwndCombo, LB_ADDSTRING, 0, (LPARAM) engineMnemonic[i]);\r
}\r
- SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) 0, (LPARAM) buf);\r
+// SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) 0, (LPARAM) buf);\r
return 0;\r
-\r
}\r
\r
void TourneyPopup(HWND hwnd)\r
{\r
int n = NamesToList(firstChessProgramNames, engineList, engineMnemonic, "");\r
- comboCallback = &AddToTourney;\r
autoinc = appData.loadGameIndex < 0 || appData.loadPositionIndex < 0;\r
twice = FALSE; swiss = appData.tourneyType < 0;\r
- tourneyOptions[3].max = n;\r
+ tourneyOptions[0].max = n;\r
snprintf(title, MSG_SIZ, _("Tournament and Match Options"));\r
ASSIGN(tfName, appData.tourneyFile[0] ? appData.tourneyFile : MakeName(appData.defName));\r
\r