X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=dialogs.c;h=7db75dbd93fe695ad36d455e4453cf251b74bddc;hb=6e40d1751ec11a717529545c7253fc6a8236bc24;hp=cf49bfa565b6645155e4ece7810663c61d181533;hpb=4e99bea34045f95fa146c9179ad378435e15d9fa;p=xboard.git diff --git a/dialogs.c b/dialogs.c index cf49bfa..7db75db 100644 --- a/dialogs.c +++ b/dialogs.c @@ -1,7 +1,7 @@ /* * dialogs.c -- platform-independent code for dialogs of XBoard * - * Copyright 2000, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc. + * Copyright 2000, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Free Software Foundation, Inc. * ------------------------------------------------------------------------ * * GNU XBoard is free software: you can redistribute it and/or modify @@ -93,11 +93,13 @@ int SetCurrentComboSelection (Option *opt) { int j; + if(currentCps) ; else if(!opt->textValue) opt->value = *(int*)opt->target; /* numeric */else { for(j=0; opt->choice[j]; j++) // look up actual value in list of possible values, to get selection nr if(*(char**)opt->target && !strcmp(*(char**)opt->target, ((char**)opt->textValue)[j])) break; opt->value = j + (opt->choice[j] == NULL); } + SetComboChoice(opt, opt->value); return opt->value; } @@ -331,6 +333,7 @@ UpgradeParticipant () static void PseudoOK () { + if(matchMode) return; GenericReadout(matchOptions, -2); // read all, but suppress calling of MatchOK ASSIGN(appData.participants, engineName); ASSIGN(appData.tourneyFile, tfName); @@ -1459,6 +1462,22 @@ SecondSettingsProc () SettingsPopUp(&second); } +void +RefreshSettingsDialog (ChessProgramState *cps, int val) +{ + if(val == 1) { // option values changed + if(shellUp[TransientDlg] && cps == currentCps) { + GenericUpdate(cps->option, -1); // normally update values when dialog is up + } + return; // and be done + } + if(val == 2) { // option list changed + if(!shellUp[TransientDlg] || cps != currentCps) return; // our dialog is not up, so nothing to do + } + PopDown(TransientDlg); // make sure any other dialog closes first + SettingsPopUp(cps); // and popup new one +} + //----------------------------------------------- Load Engine -------------------------------------- char *engineDir, *engineLine, *nickName, *params; @@ -1592,7 +1611,7 @@ ShuffleMenuProc () //------------------------------------------------------ Time Control ----------------------------------- static int TcOK P((int n)); -int tmpMoves, tmpTc, tmpInc, tmpOdds1, tmpOdds2, tcType; +int tmpMoves, tmpTc, tmpInc, tmpOdds1, tmpOdds2, tcType, by60; static void SetTcType P((int n)); @@ -1608,6 +1627,7 @@ static Option tcOptions[] = { { 0, 0, 0, NULL, (void*) &SetTcType, NULL, NULL, Button, N_("classical") }, { 0,SAME_ROW,0,NULL, (void*) &SetTcType, NULL, NULL, Button, N_("incremental") }, { 0,SAME_ROW,0,NULL, (void*) &SetTcType, NULL, NULL, Button, N_("fixed max") }, +{ 0, 0, 0, NULL, (void*) &by60, "", NULL, CheckBox, N_("Divide entered times by 60") }, { 0, 0, 200, NULL, (void*) &tmpMoves, NULL, NULL, Spin, N_("Moves per session:") }, { 0, 0,10000, NULL, (void*) &tmpTc, NULL, NULL, Spin, N_("Initial time (min):") }, { 0, 0, 10000, NULL, (void*) &tmpInc, NULL, NULL, Spin, N_("Increment or max (sec/move):") }, @@ -1620,10 +1640,11 @@ static Option tcOptions[] = { static int TcOK (int n) { - char *tc; + char *tc, buf[MSG_SIZ]; if(tcType == 0 && tmpMoves <= 0) return 0; if(tcType == 2 && tmpInc <= 0) return 0; - GetWidgetText(&tcOptions[4], &tc); // get original text, in case it is min:sec + GetWidgetText(&tcOptions[5], &tc); // get original text, in case it is min:sec + if(by60) snprintf(buf, MSG_SIZ, "%d:%02d", tmpTc/60, tmpTc%60), tc=buf; searchTime = 0; switch(tcType) { case 0: @@ -1635,10 +1656,10 @@ TcOK (int n) case 1: if(!ParseTimeControl(tc, tmpInc, 0)) return 0; ASSIGN(appData.timeControl, tc); - appData.timeIncrement = tmpInc; + appData.timeIncrement = (by60 ? tmpInc/60. : tmpInc); break; case 2: - searchTime = tmpInc; + searchTime = (by60 ? tmpInc/60 : tmpInc); } appData.firstTimeOdds = first.timeOdds = tmpOdds1; appData.secondTimeOdds = second.timeOdds = tmpOdds2; @@ -1651,29 +1672,34 @@ SetTcType (int n) { switch(tcType = n) { case 0: - SetWidgetText(&tcOptions[3], Value(tmpMoves), TransientDlg); - SetWidgetText(&tcOptions[4], Value(tmpTc), TransientDlg); - SetWidgetText(&tcOptions[5], _("Unused"), TransientDlg); + SetWidgetText(&tcOptions[4], Value(tmpMoves), TransientDlg); + SetWidgetText(&tcOptions[5], Value(tmpTc), TransientDlg); + SetWidgetText(&tcOptions[6], _("Unused"), TransientDlg); break; case 1: - SetWidgetText(&tcOptions[3], _("Unused"), TransientDlg); - SetWidgetText(&tcOptions[4], Value(tmpTc), TransientDlg); - SetWidgetText(&tcOptions[5], Value(tmpInc), TransientDlg); + SetWidgetText(&tcOptions[4], _("Unused"), TransientDlg); + SetWidgetText(&tcOptions[5], Value(tmpTc), TransientDlg); + SetWidgetText(&tcOptions[6], Value(tmpInc), TransientDlg); break; case 2: - SetWidgetText(&tcOptions[3], _("Unused"), TransientDlg); SetWidgetText(&tcOptions[4], _("Unused"), TransientDlg); - SetWidgetText(&tcOptions[5], Value(tmpInc), TransientDlg); + SetWidgetText(&tcOptions[5], _("Unused"), TransientDlg); + SetWidgetText(&tcOptions[6], Value(tmpInc), TransientDlg); } } void TimeControlProc () { + if(gameMode != BeginningOfGame) { + DisplayError(_("Changing time control during a game is not implemented"), 0); + return; + } tmpMoves = appData.movesPerSession; tmpInc = appData.timeIncrement; if(tmpInc < 0) tmpInc = 0; tmpOdds1 = tmpOdds2 = 1; tcType = 0; tmpTc = atoi(appData.timeControl); + by60 = 0; GenericPopUp(tcOptions, _("Time Control"), TransientDlg, BoardWindow, MODAL, 0); SetTcType(searchTime ? 2 : appData.timeIncrement < 0 ? 0 : 1); } @@ -1945,6 +1971,7 @@ OutputChatMessage (int partner, char *mess) char *p = texts[partner]; int len = strlen(mess) + 1; + if(!DialogExists(ChatDlg)) return; if(p) len += strlen(p); texts[partner] = (char*) malloc(len); snprintf(texts[partner], len, "%s%s", p ? p : "", mess); @@ -2262,8 +2289,8 @@ ErrorPopUp (char *title, char *label, int modal) { errorUp = True; errorOptions[1].name = label; - if(dialogError = shellUp[TransientDlg]) - GenericPopUp(errorOptions+1, title, FatalDlg, TransientDlg, MODAL, 0); // pop up as daughter of the transient dialog + if(dialogError = shellUp[MasterDlg]) + GenericPopUp(errorOptions+1, title, FatalDlg, MasterDlg, MODAL, 0); // pop up as daughter of the transient dialog else GenericPopUp(errorOptions+modal, title, modal ? FatalDlg: ErrorDlg, BoardWindow, modal, 0); // kludge: option start address indicates modality } @@ -2555,7 +2582,7 @@ MenuCallback (int n) static Option * Exp (int n, int x, int y) { - static int but1, but3, oldW, oldH; + static int but1, but3, oldW, oldH, oldX, oldY; int menuNr = -3, sizing, f, r; TimeMark now; extern Boolean right; @@ -2566,6 +2593,7 @@ Exp (int n, int x, int y) } if(n == 0) { // motion + oldX = x; oldY = y; if(SeekGraphClick(Press, x, y, 1)) return NULL; if((but1 || dragging == 2) && !PromoScroll(x, y)) DragPieceMove(x, y); if(but3) MovePV(x, y, lineGap + BOARD_HEIGHT * (squareSize + lineGap)); @@ -2588,8 +2616,8 @@ Exp (int n, int x, int y) case 3: menuNr = RightClick(Press, x, y, &pmFromX, &pmFromY), but3 = 1; break; case -2: shiftKey = !shiftKey; case -3: menuNr = RightClick(Release, x, y, &pmFromX, &pmFromY), but3 = 0; break; - case 4: BackwardEvent(); break; - case 5: ForwardEvent(); break; + case 4: Wheel(-1, oldX, oldY); break; + case 5: Wheel(1, oldX, oldY); break; case 10: sizing = (oldW != x || oldH != y); oldW = x; oldH = y;