X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwsettings.c;h=6fc5c40682a7f677319e72d6271504a1e407ec18;hb=f29ff21f23c2a22fc55e14ba48c53d704c22289d;hp=a1909acb51b53158d2d65b089501905d0b92b65f;hpb=c221f1fcc16ca18090ea6a6d663efddc156e4c02;p=xboard.git diff --git a/winboard/wsettings.c b/winboard/wsettings.c index a1909ac..6fc5c40 100644 --- a/winboard/wsettings.c +++ b/winboard/wsettings.c @@ -486,6 +486,7 @@ LRESULT CALLBACK SettingsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa 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 +536,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 +567,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 +577,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; @@ -692,9 +694,37 @@ char *tfName; int MatchOK() { if(autoinc) appData.loadGameIndex = appData.loadPositionIndex = -(twice + 1); + if(!appData.loadGameFile[0]) appData.loadGameIndex = -2*twice; // kludge to pass value of "twice" for use in GUI book if(swiss) { appData.defaultMatchGames = 1; appData.tourneyType = -1; } - if(CreateTourney(tfName)) MatchEvent(2); else return !appData.participants[0]; - return 1; + if(CreateTourney(tfName) && !matchMode) { // CreateTourney reloads original settings if file already existed + MatchEvent(2); + return 1; // close dialog + } + return matchMode || !appData.participants[0]; // if we failed to create and are not in playing, forbid popdown if there are participants +} + +char *GetParticipants(HWND hDlg) +{ + int len = GetWindowTextLength(GetDlgItem(hDlg, 2001+2*9)) + 1; + char *participants,*p, *q; + if(len < 4) return NULL; // box is empty (enough) + participants = (char*) malloc(len); + GetDlgItemText(hDlg, 2001+2*9, participants, len ); + p = q = participants; + while(*p++ = *q++) if(p[-1] == '\r') p--; + return participants; +} + +void ReplaceParticipant(HWND hDlg) +{ + char *participants = GetParticipants(hDlg); + Substitute(participants, TRUE); +} + +void UpgradeParticipant(HWND hDlg) +{ + char *participants = GetParticipants(hDlg); + Substitute(participants, FALSE); } Option tourneyOptions[] = { @@ -718,6 +748,8 @@ Option tourneyOptions[] = { { 0, 0, 1000000000, NULL, (void*) &appData.rewindIndex, "", NULL, Spin, N_("Rewind after (0 = never):") }, { 0, 0, 0, NULL, (void*) &twice, "", NULL, CheckBox, N_("Use each line/position twice") }, { 0, 0, 1000000000, NULL, (void*) &appData.matchPause, "", NULL, Spin, N_("Pause between Games (ms):") }, + { 0, 0, 0, NULL, (void*) &ReplaceParticipant, "", NULL, Button, N_("Replace Engine") }, + { 0, 0, 0, NULL, (void*) &UpgradeParticipant, "", NULL, Button, N_("Upgrade Engine") }, { 0, 0, 0, NULL, (void*) &MatchOK, "", NULL, EndMark , "" } }; @@ -740,7 +772,7 @@ void TourneyPopup(HWND hwnd) NamesToList(firstChessProgramNames, engineList, engineMnemonic); comboCallback = &AddToTourney; autoinc = appData.loadGameIndex < 0 || appData.loadPositionIndex < 0; - twice = TRUE; swiss = appData.tourneyType < 0; + twice = FALSE; swiss = appData.tourneyType < 0; while(engineList[n]) n++; tourneyOptions[3].max = n-1; snprintf(title, MSG_SIZ, _("Tournament and Match Options")); ASSIGN(tfName, appData.tourneyFile[0] ? appData.tourneyFile : MakeName(appData.defName));