X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=xoptions.c;h=2b29bbeaacad95046885ae843c2a850476061f24;hb=a7db862b2f44d23b358a1319cd8a374cf88c24fd;hp=0689355ca75af897b41d4b6136a4800557a5b40e;hpb=d39b0224115daf24fa2608e27d0ca16c8cd4aa70;p=xboard.git diff --git a/xoptions.c b/xoptions.c index 0689355..2b29bbe 100644 --- a/xoptions.c +++ b/xoptions.c @@ -624,6 +624,7 @@ int values[MAX_OPTIONS]; ChessProgramState *currentCps; static Option *currentOption; extern Widget shells[]; +static Boolean browserUp; void CheckCallback(Widget ww, XtPointer data, XEvent *event, Boolean *b) { @@ -659,6 +660,7 @@ void SpinCallback(w, client_data, call_data) XtSetArg(args[0], XtNstring, &q); XtGetValues(currentOption[data].handle, args, 1); for(r = ""; *q; q++) if(*q == '.') r = q; else if(*q == '/') r = ""; // last dot after last slash + browserUp = True; if(XsraSelFile(shells[0], currentOption[data].name, NULL, NULL, "", "", r, currentOption[data].type == PathName ? "p" : "f", NULL, &p)) { int len = strlen(p); @@ -666,6 +668,7 @@ void SpinCallback(w, client_data, call_data) XtSetArg(args[0], XtNstring, p); XtSetValues(currentOption[data].handle, args, 1); } + browserUp = False; SetFocus(currentOption[data].handle, shells[0], (XEvent*) NULL, False); return; } else @@ -732,8 +735,7 @@ char *trialSound; static int oldCores, oldPonder; int MakeColors P((void)); void CreateGCs P((int redo)); -void CreateXPMBoard P((char *s, int kind)); -void CreateXPMPieces P((void)); +void CreateAnyPieces P((void)); void GenericReadout(); Widget shells[10]; Widget marked[10]; @@ -785,6 +787,7 @@ void GenericPopDown(w, event, prms, nprms) Cardinal *nprms; { int n; + if(browserUp) return; // prevent closing dialog when it has an open file-browse daughter PopDown(prms[0][0] - '0'); } @@ -1145,12 +1148,11 @@ void AdjustColor(int i) void BoardOptionsOK(int n) { - extern int defaultLineGap; + extern int defaultLineGap, useImages, useImageSqs; if(appData.overrideLineGap >= 0) lineGap = appData.overrideLineGap; else lineGap = defaultLineGap; + useImages = useImageSqs = 0; MakeColors(); CreateGCs(True); - CreateXPMPieces(); - CreateXPMBoard(appData.liteBackTextureFile, 1); - CreateXPMBoard(appData.darkBackTextureFile, 0); + CreateAnyPieces(); InitDrawingSizes(-1, 0); DrawPosition(True, NULL); } @@ -1193,7 +1195,7 @@ Option boardOptions[] = { { 3, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "B" }, { 4, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "D" }, { 0, 0, 0, NULL, (void*) &appData.upsideDown, "", NULL, CheckBox, _("Flip Pieces Shogi Style (Colored buttons restore default)") }, -{ 0, 0, 0, NULL, (void*) &appData.allWhite, "", NULL, CheckBox, _("Use Outline Pieces for Black") }, +//{ 0, 0, 0, NULL, (void*) &appData.allWhite, "", NULL, CheckBox, _("Use Outline Pieces for Black") }, { 0, 0, 0, NULL, (void*) &appData.monoMode, "", NULL, CheckBox, _("Mono Mode") }, { 0,-1, 5, NULL, (void*) &appData.overrideLineGap, "", NULL, Spin, _("Line Gap ( -1 = default for board size):") }, { 0, 0, 0, NULL, (void*) &appData.liteBackTextureFile, "", NULL, FileName, _("Light-Squares Texture File:") }, @@ -1233,13 +1235,14 @@ void GenericReadout() sscanf(val, "%f", &x); if(x > currentOption[i].max) x = currentOption[i].max; if(x < currentOption[i].min) x = currentOption[i].min; - if(currentOption[i].value != x) { + if(currentOption[i].type == Fractional) + *(float*) currentOption[i].target = x; // engines never have float options! + else if(currentOption[i].value != x) { currentOption[i].value = x; - if(currentCps) { // engines never have float options, so no decimals! + if(currentCps) { snprintf(buf, MSG_SIZ, "option %s=%.0f\n", currentOption[i].name, x); SendToProgram(buf, currentCps); - } else if(currentOption[i].type == Spin) *(int*) currentOption[i].target = x; - else *(float*) currentOption[i].target = x; + } else *(int*) currentOption[i].target = x; } break; case CheckBox: @@ -1582,7 +1585,19 @@ GenericPopUp(Option *option, char *title, int dlgNr) if(!(option[i].min & 2)) { j=0; - if(option[i].min & 1) { XtSetArg(args[j], XtNfromHoriz, last); last = forelast; } else + if(option[i].min & 1) { + for(j=i-1; option[j+1].min&1 && option[j].type == Button; j--) { + XtSetArg(args[0], XtNtop, XtChainBottom); + XtSetArg(args[1], XtNbottom, XtChainBottom); + XtSetValues(option[j].handle, args, 2); + } + if(option[j].type == TextBox && option[j].name[0] == NULLCHAR) { + XtSetArg(args[0], XtNbottom, XtChainBottom); + XtSetValues(option[j].handle, args, 1); + } + j = 0; + XtSetArg(args[j], XtNfromHoriz, last); last = forelast; + } else XtSetArg(args[j], XtNfromHoriz, widest ? widest : dialog); j++; XtSetArg(args[j], XtNfromVert, anchor ? anchor : last); j++; XtSetArg(args[j], XtNbottom, XtChainBottom); j++; @@ -1859,13 +1874,13 @@ void changeTags(int n) { Arg args[16]; XtSetArg(args[0], XtNstring, &tagsText); - XtGetValues(currentOption[0].handle, args, 1); + XtGetValues(currentOption[1].handle, args, 1); ReplaceTags(tagsText, &gameInfo); } Option tagsOptions[] = { -{ 0xD, 200, 250, NULL, (void*) &tagsText, "", NULL, TextBox, "" }, { 0, 0, 0, NULL, NULL, NULL, NULL, Label, "" }, +{ 0xD, 200, 250, NULL, (void*) &tagsText, "", NULL, TextBox, "" }, { 0, 0, 0, NULL, (void*) &changeTags, NULL, NULL, Button, "save changes" }, { 0, 1, 0, NULL, (void*) &NewTagsCallback, "", NULL, EndMark , "" } }; @@ -1877,10 +1892,10 @@ void NewTagsPopup(char *text, char *msg) if(shells[2]) { // if already exists, alter title and content XtSetArg(args[0], XtNstring, text); - XtSetValues(tagsOptions[0].handle, args, 1); + XtSetValues(tagsOptions[1].handle, args, 1); } tagsText = text; - tagsOptions[1].textValue = msg; + tagsOptions[0].textValue = msg; MarkMenu("menuView.Show Tags", 2); GenericPopUp(tagsOptions, _("Tags"), 2); }