From acceebbe37c9c4ad05f74dbfaf327d20171c874f Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Sun, 7 Feb 2016 22:48:34 +0100 Subject: [PATCH] Improve variant recognition for enabling buttons (XB) Buttons for variants were enabled when the name of the variant they selected was a sub-string of waht the engine could play, so that Grand Chess (variant grand) would be enabled by Fairy-Max' grande-acedrex. Now we test if the matched sub-string of the engine's variants feature is immediately followed by a comma (or at the end). --- gtk/xoptions.c | 4 +++- xaw/xoptions.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gtk/xoptions.c b/gtk/xoptions.c index 3df99a7..5880751 100644 --- a/gtk/xoptions.c +++ b/gtk/xoptions.c @@ -1457,10 +1457,12 @@ if(appData.debugMode) printf("n=%d, h=%d, w=%d\n",n,height,width); /* set button color on new variant dialog */ if(option[i].textValue) { static char *b = "Bold"; + char *v, *p = NULL, n = option[i].value; + if(n >= 0) v = VariantName(n), p = strstr(first.variants, v); gdk_color_parse( option[i].textValue, &color ); gtk_widget_modify_bg ( GTK_WIDGET(button), GTK_STATE_NORMAL, &color ); gtk_widget_set_sensitive(button, option[i].value >= 0 && (appData.noChessProgram - || strstr(first.variants, VariantName(option[i].value)))); + || p && (!*v || strlen(p) == strlen(v) || p[strlen(v)] == ','))); if(engineVariant[100] ? !strcmp(engineVariant+100, option[i].name) : gameInfo.variant ? option[i].value == gameInfo.variant : !strcmp(option[i].name, "Normal")) SetWidgetFont(gtk_bin_get_child(GTK_BIN(button)), &b); diff --git a/xaw/xoptions.c b/xaw/xoptions.c index 1809743..153ca43 100644 --- a/xaw/xoptions.c +++ b/xaw/xoptions.c @@ -1136,8 +1136,10 @@ GenericPopUp (Option *option, char *title, DialogClass dlgNr, DialogClass parent option[i].max /* w */, shrink ? textHeight : 0 /* h */, option[i].min & 0xE | chain /* chain */); XtSetArg(args[j], XtNlabel, _(option[i].name)); j++; if(option[i].textValue && *option[i].textValue == '#') { // special for buttons of New Variant dialog + char *p, *v, n = option[i].value; + if(n) v = VariantName(n), p = strstr(first.variants, v); XtSetArg(args[j], XtNsensitive, option[i].value >= 0 && (appData.noChessProgram - || strstr(first.variants, VariantName(option[i].value)))); j++; + || p && (!*v || strlen(p) == strlen(v) || p[strlen(v)] == ','))); j++; XtSetArg(args[j], XtNborderWidth, (gameInfo.variant == option[i].value)+1); j++; } option[i].handle = (void*) -- 1.7.0.4