Implement searching games in Game List for a position
[xboard.git] / xoptions.c
index 7e7eed8..31750ba 100644 (file)
@@ -554,12 +554,27 @@ Option icsOptions[] = {
 { 0, 0, 0, NULL, (void*) &IcsOptionsOK, "", NULL, EndMark , "" }
 };
 
+char *modeNames[] = { N_("Exact match"), N_("Shown position is subset"), N_("Same material and Pawn chain"), N_("Same material"), NULL };
+char *modeValues[] = { "1", "2", "3", "4" };
+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:") },
+{ 1, 0, 180, NULL, (void*) &searchMode, (char*) modeNames, modeValues, ComboBox, N_("Seach mode:") },
+{ 0,  0, 0, NULL, (void*) &LoadOptionsOK, "", NULL, EndMark , "" }
 };
 
 Option saveOptions[] = {
@@ -673,7 +688,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(&currentOption[source], &s);
     if(sscanf(s, "#%x", &col) != 1) return;   // malformed
     b = col & 0xFF; g = col & 0xFF00; r = col & 0xFF0000;
@@ -1220,6 +1234,7 @@ void LoadOptionsProc(w, event, prms, nprms)
      String *prms;
      Cardinal *nprms;
 {
+   ASSIGN(searchMode, modeValues[appData.searchMode-1]);
    GenericPopUp(loadOptions, _("Load Game Options"), 0);
 }
 
@@ -1396,7 +1411,7 @@ int NewComCallback(int n)
 
 void SaveChanges(int n)
 {
-    GetWidgetText(&currentOption[0], &commentText);
+    GenericReadout(0);
     ReplaceComment(commentIndex, commentText);
 }
 
@@ -1423,7 +1438,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
@@ -1438,7 +1452,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)
 {
@@ -1448,7 +1462,7 @@ int NewTagsCallback(int n)
 
 void changeTags(int n)
 {
-    GetWidgetText(&currentOption[1], &tagsText);
+    GenericReadout(1);
     if(bookUp) SaveToBook(tagsText); else
     ReplaceTags(tagsText, &gameInfo);
 }
@@ -1462,7 +1476,6 @@ Option tagsOptions[] = {
 
 void NewTagsPopup(char *text, char *msg)
 {
-    Widget edit;
     Arg args[16];
     char *title = bookUp ? _("Edit book") : _("Tags");
 
@@ -1514,12 +1527,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);
 }
@@ -1645,7 +1657,6 @@ void SetRandom(int n)
 {
     int r = n==2 ? -1 : rand() & (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);