X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=xoptions.c;h=eabebbe94f56fff7f51d4e3f399c778311062e5e;hb=1f070c3ba500547459ad3df71fbdbad1e5b4b4a0;hp=a6a305996ce2f4017e0b3d9c03069543e1e8f457;hpb=a31d0897123ab90c8d4a8304619834079c3ad5a9;p=xboard.git diff --git a/xoptions.c b/xoptions.c index a6a3059..eabebbe 100644 --- a/xoptions.c +++ b/xoptions.c @@ -303,11 +303,16 @@ extern Option installOptions[], matchOptions[]; char *engineNr[] = { N_("First Engine"), N_("Second Engine"), NULL }; char *engineList[100] = {" "}, *engineMnemonic[100] = {""}; -void AppendText(Option *opt, char *s) +int AppendText(Option *opt, char *s) { XawTextBlock t; + char *v; + int len; + GetWidgetText(opt, &v); + len = strlen(v); t.ptr = s; t.firstPos = 0; t.length = strlen(s); t.format = XawFmt8Bit; - XawTextReplace(opt->handle, 9999, 9999, &t); + XawTextReplace(opt->handle, len, len, &t); + return len; } void AddLine(Option *opt, char *s) @@ -324,14 +329,25 @@ void AddToTourney(int n) int MatchOK(int n) { - if(appData.participants && appData.participants[0]) free(appData.participants); - appData.participants = strdup(engineName); - if(!CreateTourney(tfName)) return !appData.participants[0]; + ASSIGN(appData.participants, engineName); + if(!CreateTourney(tfName) || matchMode) return matchMode || !appData.participants[0]; PopDown(0); // early popdown to prevent FreezeUI called through MatchEvent from causing XtGrab warning MatchEvent(2); // start tourney return 1; } +void ReplaceParticipant() +{ + GenericReadout(3); + Substitute(strdup(engineName), True); +} + +void UpgradeParticipant() +{ + GenericReadout(3); + Substitute(strdup(engineName), False); +} + Option matchOptions[] = { { 0, 0, 0, NULL, (void*) &tfName, ".trn", NULL, FileName, N_("Tournament file:") }, { 0, 0, 0, NULL, (void*) &appData.roundSync, "", NULL, CheckBox, N_("Sync after round (for concurrent playing of a single") }, @@ -348,7 +364,10 @@ Option matchOptions[] = { { 0, 0, 0, NULL, (void*) &appData.loadPositionFile, ".fen", NULL, FileName, N_("File with Start Positions:") }, { 0, -2, 1000000000, NULL, (void*) &appData.loadPositionIndex, "", NULL, Spin, N_("Position Number (-1 or -2 = Auto-Increment):") }, { 0, 0, 1000000000, NULL, (void*) &appData.rewindIndex, "", NULL, Spin, N_("Rewind Index after this many Games (0 = never):") }, -{ 0, 0, 0, NULL, (void*) &MatchOK, "", NULL, EndMark , "" } +{ 0, 0, 0, NULL, (void*) &appData.defNoBook, "", NULL, CheckBox, N_("Disable own engine books by default") }, +{ 0, 0, 0, NULL, (void*) &ReplaceParticipant, NULL, NULL, Button, N_("Replace Engine") }, +{ 0, 1, 0, NULL, (void*) &UpgradeParticipant, NULL, NULL, Button, N_("Upgrade Engine") }, +{ 0, 1, 0, NULL, (void*) &MatchOK, "", NULL, EndMark , "" } }; int GeneralOptionsOK(int n) @@ -360,6 +379,7 @@ int GeneralOptionsOK(int n) } Option generalOptions[] = { +{ 0, 0, 0, NULL, (void*) &appData.whitePOV, "", NULL, CheckBox, N_("Absolute Analysis Scores") }, { 0, 0, 0, NULL, (void*) &appData.sweepSelect, "", NULL, CheckBox, N_("Almost Always Queen (Detour Under-Promote)") }, { 0, 0, 0, NULL, (void*) &appData.animateDragging, "", NULL, CheckBox, N_("Animate Dragging") }, { 0, 0, 0, NULL, (void*) &appData.animate, "", NULL, CheckBox, N_("Animate Moving") }, @@ -384,6 +404,7 @@ Option generalOptions[] = { { 0, 0, 10, NULL, (void*) &appData.flashCount, "", NULL, Spin, N_("Flash Moves (0 = no flashing):") }, { 0, 1, 10, NULL, (void*) &appData.flashRate, "", NULL, Spin, N_("Flash Rate (high = fast):") }, { 0, 5, 100,NULL, (void*) &appData.animSpeed, "", NULL, Spin, N_("Animation Speed (high = slow):") }, +{ 0, 1, 5, NULL, (void*) &appData.zoom, "", NULL, Spin, N_("Zoom factor in Evaluation Graph:") }, { 0, 0, 0, NULL, (void*) &GeneralOptionsOK, "", NULL, EndMark , "" } }; @@ -439,16 +460,18 @@ Option variantDescriptors[] = { { VariantMakruk, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("makruk")}, { VariantGreat, 1, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("Great Shatranj (10x8)")}, { VariantAtomic, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("atomic")}, -{ VariantCapablanca, 1, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("Capablanca (10x8)")}, +{ VariantFalcon, 1, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("falcon (10x8)")}, { VariantTwoKings, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("two kings")}, -{ VariantGothic, 1, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("Gothic (10x8)")}, +{ VariantCapablanca, 1, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("Capablanca (10x8)")}, { Variant3Check, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("3-checks")}, -{ VariantJanus, 1, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("janus (10x8)")}, +{ VariantGothic, 1, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("Gothic (10x8)")}, { VariantSuicide, 0, 135, NULL, (void*) &Pick, "#FFFFBF", NULL, Button, N_("suicide")}, -{ VariantCapaRandom, 1, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("CRC (10x8)")}, +{ VariantJanus, 1, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("janus (10x8)")}, { VariantGiveaway, 0, 135, NULL, (void*) &Pick, "#FFFFBF", NULL, Button, N_("give-away")}, -{ VariantSpartan, 1, 135, NULL, (void*) &Pick, "#FF0000", NULL, Button, N_("Spartan")}, +{ VariantCapaRandom, 1, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("CRC (10x8)")}, { VariantLosers, 0, 135, NULL, (void*) &Pick, "#FFFFBF", NULL, Button, N_("losers")}, +{ VariantGrand, 1, 135, NULL, (void*) &Pick, "#5070FF", NULL, Button, N_("grand (10x10)")}, +{ VariantSpartan, 0, 135, NULL, (void*) &Pick, "#FF0000", NULL, Button, N_("Spartan")}, { 0, 0, 0, NULL, NULL, NULL, NULL, Label, N_("Board size ( -1 = default for selected variant):")}, { 0, -1, BOARD_RANKS-1, NULL, (void*) &appData.NrRanks, "", NULL, Spin, N_("Number of Board Ranks:") }, { 0, -1, BOARD_FILES, NULL, (void*) &appData.NrFiles, "", NULL, Spin, N_("Number of Board Files:") }, @@ -546,12 +569,31 @@ Option icsOptions[] = { { 0, 0, 0, NULL, (void*) &IcsOptionsOK, "", NULL, EndMark , "" } }; +char *modeNames[] = { N_("Exact position match"), N_("Shown position is subset"), N_("Same material with exactly same Pawn chain"), + N_("Same material"), N_("Material range (top board half optional)"), N_("Material difference (optional stuff balanced)"), NULL }; +char *modeValues[] = { "1", "2", "3", "4", "5", "6" }; +char *searchMode; + +int LoadOptionsOK() +{ + appData.searchMode = atoi(searchMode); + return 1; +} + Option loadOptions[] = { { 0, 0, 0, NULL, (void*) &appData.autoDisplayTags, "", NULL, CheckBox, N_("Auto-Display Tags") }, { 0, 0, 0, NULL, (void*) &appData.autoDisplayComment, "", NULL, CheckBox, N_("Auto-Display Comment") }, { 0, 0, 0, NULL, NULL, NULL, NULL, Label, N_("Auto-Play speed of loaded games\n(0 = instant, -1 = off):") }, { 0, -1, 10000000, NULL, (void*) &appData.timeDelay, "", NULL, Fractional, N_("Seconds per Move:") }, -{ 0, 0, 0, NULL, NULL, "", NULL, EndMark , "" } +{ 0, 0, 0, NULL, NULL, NULL, NULL, Label, N_("\nThresholds for position filtering in game list:") }, +{ 0, 0, 5000, NULL, (void*) &appData.eloThreshold1, "", NULL, Spin, N_("Elo of strongest player at least:") }, +{ 0, 0, 5000, NULL, (void*) &appData.eloThreshold2, "", NULL, Spin, N_("Elo of weakest player at least:") }, +{ 0, 0, 5000, NULL, (void*) &appData.dateThreshold, "", NULL, Spin, N_("No games before year:") }, +{ 0, 1, 50, NULL, (void*) &appData.stretch, "", NULL, Spin, N_("Minimum nr consecutive positions:") }, +{ 1, 0, 180, NULL, (void*) &searchMode, (char*) modeNames, modeValues, ComboBox, N_("Seach mode:") }, +{ 0, 0, 0, NULL, (void*) &appData.ignoreColors, "", NULL, CheckBox, N_("Also match reversed colors") }, +{ 0, 0, 0, NULL, (void*) &appData.findMirror, "", NULL, CheckBox, N_("Also match left-right flipped position") }, +{ 0, 0, 0, NULL, (void*) &LoadOptionsOK, "", NULL, EndMark , "" } }; Option saveOptions[] = { @@ -665,7 +707,6 @@ void RefreshColor(int source, int n) { int col, j, r, g, b, step = 10; char *s, buf[MSG_SIZ]; // color string - Arg args[5]; GetWidgetText(¤tOption[source], &s); if(sscanf(s, "#%x", &col) != 1) return; // malformed b = col & 0xFF; g = col & 0xFF00; r = col & 0xFF0000; @@ -748,6 +789,7 @@ Option boardOptions[] = { //{ 0, 0, 0, NULL, (void*) &appData.allWhite, "", NULL, CheckBox, N_("Use Outline Pieces for Black") }, { 0, 0, 0, NULL, (void*) &appData.monoMode, "", NULL, CheckBox, N_("Mono Mode") }, { 0,-1, 5, NULL, (void*) &appData.overrideLineGap, "", NULL, Spin, N_("Line Gap ( -1 = default for board size):") }, +{ 0, 0, 0, NULL, (void*) &appData.useBitmaps, "", NULL, CheckBox, N_("Use Board Textures") }, { 0, 0, 0, NULL, (void*) &appData.liteBackTextureFile, ".xpm", NULL, FileName, N_("Light-Squares Texture File:") }, { 0, 0, 0, NULL, (void*) &appData.darkBackTextureFile, ".xpm", NULL, FileName, N_("Dark-Squares Texture File:") }, { 0, 0, 0, NULL, (void*) &appData.bitmapDirectory, "", NULL, PathName, N_("Directory with Bitmap Pieces:") }, @@ -899,7 +941,7 @@ GenericPopUp(Option *option, char *title, int dlgNr) if(currentCps) { // Settings popup for engine: format through heuristic int n = currentCps->nrOptions; - if(!n) { DisplayNote(_("Engine has no options")); return 0; } + if(!n) { DisplayNote(_("Engine has no options")); currentCps = NULL; return 0; } if(n > 50) width = 4; else if(n>24) width = 2; else width = 1; height = n / width + 1; if(n && (currentOption[n-1].type == Button || currentOption[n-1].type == SaveButton)) currentOption[n].min = 1; // OK on same line @@ -1212,6 +1254,7 @@ void LoadOptionsProc(w, event, prms, nprms) String *prms; Cardinal *nprms; { + ASSIGN(searchMode, modeValues[appData.searchMode-1]); GenericPopUp(loadOptions, _("Load Game Options"), 0); } @@ -1292,6 +1335,7 @@ void MatchOptionsProc(w, event, prms, nprms) comboCallback = &AddToTourney; matchOptions[5].min = -(appData.pairingEngine[0] != NULLCHAR); // with pairing engine, allow Swiss ASSIGN(tfName, appData.tourneyFile[0] ? appData.tourneyFile : MakeName(appData.defName)); + ASSIGN(engineName, appData.participants); GenericPopUp(matchOptions, _("Match Options"), 0); } @@ -1388,7 +1432,7 @@ int NewComCallback(int n) void SaveChanges(int n) { - GetWidgetText(¤tOption[0], &commentText); + GenericReadout(0); ReplaceComment(commentIndex, commentText); } @@ -1401,8 +1445,11 @@ Option commentOptions[] = { void ClearTextWidget(Option *opt) { - XtCallActionProc(opt->handle, "select-all", NULL, NULL, 0); - XtCallActionProc(opt->handle, "kill-selection", NULL, NULL, 0); +// XtCallActionProc(opt->handle, "select-all", NULL, NULL, 0); +// XtCallActionProc(opt->handle, "kill-selection", NULL, NULL, 0); + Arg arg; + XtSetArg(arg, XtNstring, ""); // clear without disturbing selection! + XtSetValues(opt->handle, &arg, 1); } void ClearComment(int n) @@ -1412,7 +1459,6 @@ void ClearComment(int n) void NewCommentPopup(char *title, char *text, int index) { - Widget edit; Arg args[16]; if(shells[1]) { // if already exists, alter title and content @@ -1427,7 +1473,7 @@ void NewCommentPopup(char *title, char *text, int index) XtOverrideTranslations(commentOptions[0].handle, XtParseTranslationTable(commentTranslations)); } -static char *tagsText, *msgText; +static char *tagsText; int NewTagsCallback(int n) { @@ -1437,7 +1483,7 @@ int NewTagsCallback(int n) void changeTags(int n) { - GetWidgetText(¤tOption[1], &tagsText); + GenericReadout(1); if(bookUp) SaveToBook(tagsText); else ReplaceTags(tagsText, &gameInfo); } @@ -1451,7 +1497,6 @@ Option tagsOptions[] = { void NewTagsPopup(char *text, char *msg) { - Widget edit; Arg args[16]; char *title = bookUp ? _("Edit book") : _("Tags"); @@ -1503,12 +1548,11 @@ void TypeInProc(w, event, prms, nprms) String *prms; Cardinal *nprms; { - Arg args[2]; - String val; + char *val; if(prms[0][0] == '1') { GetWidgetText(&boxOptions[0], &val); - TypeInDoneEvent((char*)val); + TypeInDoneEvent(val); } PopDown(0); } @@ -1534,9 +1578,18 @@ void MoveTypeInProc(Widget widget, caddr_t unused, XEvent *event) XQueryKeymap(xDisplay,keys); metaL = XKeysymToKeycode(xDisplay, XK_Meta_L); metaR = XKeysymToKeycode(xDisplay, XK_Meta_R); - if ( n == 1 && *buf > 32 && !(keys[metaL>>3]&1<<(metaL&7)) && !(keys[metaR>>3]&1<<(metaR&7))) // printable, no alt - PopUpMoveDialog(*buf); - + if ( n == 1 && *buf >= 32 && !(keys[metaL>>3]&1<<(metaL&7)) && !(keys[metaR>>3]&1<<(metaR&7))) { // printable, no alt + if(appData.icsActive) { // text typed to board in ICS mode: divert to ICS input box + if(shells[4]) { // box already exists: append to current contents + char *p, newText[MSG_SIZ]; + GetWidgetText(&boxOptions[0], &p); + snprintf(newText, MSG_SIZ, "%s%c", p, *buf); + SetWidgetText(&boxOptions[0], newText, 4); + if(shellUp[4]) XSetInputFocus(xDisplay, XtWindow(boxOptions[0].handle), RevertToPointerRoot, CurrentTime); //why??? + } else icsText = buf; // box did not exist: make sure it pops up with char in it + InputBoxPopup(); + } else PopUpMoveDialog(*buf); + } } void @@ -1632,9 +1685,8 @@ Option shuffleOptions[] = { void SetRandom(int n) { - int r = n==2 ? -1 : rand() & (1<<30)-1; + int r = n==2 ? -1 : random() & (1<<30)-1; char buf[MSG_SIZ]; - Arg args[2]; snprintf(buf, MSG_SIZ, "%d", r); SetWidgetText(&shuffleOptions[1], buf, 0); SetWidgetState(&shuffleOptions[0], True); @@ -1670,6 +1722,7 @@ int TcOK(int n) if(tcType == 0 && tmpMoves <= 0) return 0; if(tcType == 2 && tmpInc <= 0) return 0; GetWidgetText(¤tOption[4], &tc); // get original text, in case it is min:sec + searchTime = 0; switch(tcType) { case 0: if(!ParseTimeControl(tc, -1, tmpMoves)) return 0;