X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwsettings.c;h=768a3867c9b6276184be32cf85801f8e6b076d0f;hb=81a421123596645386c49578a024de98cfc1a8f1;hp=a1909acb51b53158d2d65b089501905d0b92b65f;hpb=c221f1fcc16ca18090ea6a6d663efddc156e4c02;p=xboard.git diff --git a/winboard/wsettings.c b/winboard/wsettings.c index a1909ac..768a386 100644 --- a/winboard/wsettings.c +++ b/winboard/wsettings.c @@ -37,7 +37,7 @@ char *engineName, *engineDir, *engineChoice, *engineLine, *nickName, *params; Boolean isUCI, hasBook, storeVariant, v1, addToList, useNick, isUCCI; extern Option installOptions[], matchOptions[]; char *engineNr[] = { N_("First"), N_("Second"), NULL }; -char *engineList[1000] = {" "}, *engineMnemonic[1000] = {""}; +char *engineList[MAXENGINES] = {" "}, *engineMnemonic[MAXENGINES] = {""}; void (*okFunc)(); ChessProgramState *activeCps; Option *activeList; @@ -366,7 +366,7 @@ GetOptionValues(HWND hDlg, ChessProgramState *cps, Option *optionList) if(!cps) { char *p; p = (optionList[j].type != FileName ? strdup(text) : InterpretFileName(text, homeDir)); // all files relative to homeDir! - FREE(*(char**)optionList[j].target); *(char**)optionList[j].target = p; + FREE(*(char**)optionList[j].target); *(char**)optionList[j].target = p; free(text); text = p; while(*p++ = *text++) if(p[-1] == '\r') p--; // crush CR break; @@ -387,9 +387,9 @@ GetOptionValues(HWND hDlg, ChessProgramState *cps, Option *optionList) if(!success) break; new = -1; for(k=0; k 0) { if(*(char**)optionList[j].target) free(*(char**)optionList[j].target); *(char**)optionList[j].target = strdup(optionList[j].choice[new]); break; @@ -480,12 +480,14 @@ LRESULT CALLBACK SettingsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa } if(j < 0) break; if(comboCallback && activeList[j].type == ComboBox && HIWORD(wParam) == CBN_SELCHANGE) { + if(j > 5) break; // Yegh! Must solve problem with more than one ombobox in dialog (*comboCallback)(hDlg); break; } else if( activeList[j].type == SaveButton) GetOptionValues(hDlg, activeCps, activeList); else if( activeList[j].type != Button) break; + else if( !activeCps ) { (*(ButtonCallback*) activeList[j].target)(hDlg); break; } snprintf(buf, MSG_SIZ, "option %s\n", activeList[j].name); SendToProgram(buf, activeCps); } @@ -535,7 +537,7 @@ void AddOption(int x, int y, Control type, int i) break; case Label: extra = activeList[layoutList[i/2]].value; - AddControl(x+extra, y+1, 290-extra, 9, 0x0082, SS_ENDELLIPSIS | WS_VISIBLE | WS_CHILD, i); + AddControl(x+extra, y+1, 290-extra, 9, 0x0082, SS_ENDELLIPSIS | WS_VISIBLE | WS_CHILD | WS_TABSTOP, i); break; case FileName: case PathName: @@ -566,7 +568,7 @@ void AddOption(int x, int y, Control type, int i) void CreateDialogTemplate(int *layoutList, int nr, Option *optionList) { - int i, j, x=1, y=0, buttonRows, breakPoint = -1, k=0; + int i, ii, j, x=1, y=0, buttonRows, breakPoint = -1, k=0; template.header.cdit = 0; template.header.cx = 307; @@ -576,21 +578,22 @@ CreateDialogTemplate(int *layoutList, int nr, Option *optionList) template.header.cx = 625; } - for(i=0; i>1)-2, 301, 13*(boxList[k+1]-boxList[k]>>1)+8, 0x0082, WS_VISIBLE | WS_CHILD | SS_BLACKFRAME, 2400); AddControl(x+60, y+13*(i>>1)-6, 10*groupNameList[k]/3, 10, - 0x0082, SS_ENDELLIPSIS | WS_VISIBLE | WS_CHILD, 2*(i+MAX_OPTIONS)); + 0x0082, SS_ENDELLIPSIS | WS_VISIBLE | WS_CHILD, 2*(ii+MAX_OPTIONS)); } j = layoutList[i]; if(j >= 0) AddOption(x+155-150*(i&1), y+13*(i>>1)+5, optionList[j].type, 2*i); - if(k < groups && i+1 == boxList[k+1]) { + if(k < groups && ii+1 == boxList[k+1]) { k += 2; y += 4; } - if(i+1 == breakPoint) { x += 318; y = -13*(breakPoint>>1); } + if(ii+1 == breakPoint) { x += 318; y = -13*(breakPoint>>1); } } // add butons at the bottom of dialog window y += 13*(nr>>1)+5; @@ -626,6 +629,7 @@ EngineOptionsPopup(HWND hwnd, ChessProgramState *cps) int InstallOK() { + if(engineLine[0] == '#') { DisplayError(_("Select single engine from the group"), 0); return 0; } if(isUCCI) isUCI = 2; if(engineChoice[0] == engineNr[0][0]) Load(&first, 0); else Load(&second, 1); return 1; @@ -668,10 +672,27 @@ GenericPopup(HWND hwnd, Option *optionList) return; } -void LoadEnginePopUp(HWND hwnd) +int +EnterGroup(HWND hDlg) { - int n=0; + char buf[MSG_SIZ]; + HANDLE hwndCombo = GetDlgItem(hDlg, 2001+2*1); + int i = ComboBox_GetCurSel(hwndCombo); + if(i == 0) buf[0] = NULLCHAR; // back to top level + else if(engineList[i][0] == '#') safeStrCpy(buf, engineList[i], MSG_SIZ); // group header, open group + else return 0; // normal line, select engine + installOptions[0].max = NamesToList(firstChessProgramNames, engineList, engineMnemonic, buf); // replace list by only the group contents + SendMessage(hwndCombo, CB_RESETCONTENT, 0, 0); + SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) buf); + for(i=1; i