X-Git-Url: https://git.cworth.org/git?p=wordgame;a=blobdiff_plain;f=rack-fancy.c;fp=rack-fancy.c;h=65e0b0c6268120ce4ac3ae1e0c40c8e4997c6d0c;hp=7f0542d0dc3fc0ba3523154a35fd4d1938b579f8;hb=68466572ce337908614fb489601cd1590e142677;hpb=a26e439b57a16e31a8fb67a079cbad659c21fd39 diff --git a/rack-fancy.c b/rack-fancy.c index 7f0542d..65e0b0c 100644 --- a/rack-fancy.c +++ b/rack-fancy.c @@ -27,7 +27,8 @@ #include "word-game.h" #include "demo-item.h" -#define RACK_DICT_ENTRY_FOUND (1<<1) +#define RACK_DICT_ENTRY_OBSCURE (1<<1) +#define RACK_DICT_ENTRY_FOUND (1<<2) #define MAX_TILES 7 typedef struct _tile @@ -47,6 +48,7 @@ typedef struct _rack int guess_length; bag_t bag; dict_t dict; + dict_t obscure; dict_t solution; int solution_total; GooCanvasItem *solution_item; @@ -119,6 +121,13 @@ dict_paint_action (void *closure, char *word, dict_entry_t *entry) break; } + /* Don't bother displaying unfound obscure words. */ + if (*entry & RACK_DICT_ENTRY_OBSCURE) { + if (! found) + return; + cairo_set_source_rgb (cr, 0, 1, 0); /* green */ + } + cairo_move_to (cr, cursor->x, cursor->y); if (show_blanks) { int i, length = strlen (word); @@ -323,6 +332,9 @@ rack_init (rack_t *rack, dict_init (&rack->dict); dict_add_words_from_file (&rack->dict, "words.txt"); + dict_init (&rack->obscure); + dict_add_words_from_file (&rack->obscure, "obscure.txt"); + dict_init (&rack->solution); rack->solution_total = 0; @@ -331,6 +343,17 @@ rack_init (rack_t *rack, rack->num_tiles = 0; } +static void +_flag_obscure_word (void *closure, char *word, dict_entry_t *entry) +{ + dict_t *obscure = closure; + dict_entry_t *obscure_entry; + + obscure_entry = dict_lookup (obscure, word); + if (DICT_ENTRY_IS_WORD (obscure_entry)) + *entry |= RACK_DICT_ENTRY_OBSCURE; +} + static void rack_new_game (rack_t *rack) { @@ -362,7 +385,6 @@ rack_new_game (rack_t *rack) for (i = 0; i + length <= bottom + 1; i++) { memcpy (word, &rack->bag.tiles[i], length); word[length] = '\0'; - printf ("Candidate word %s\n", word); dict_fini (&rack->solution); dict_init (&rack->solution); subanagram_expand (word, &rack->dict, &rack->solution); @@ -376,6 +398,8 @@ rack_new_game (rack_t *rack) } DONE: + dict_for_each (&rack->solution, + _flag_obscure_word, &rack->obscure); rack->solution_total = dict_count (&rack->solution); goo_canvas_item_simple_changed (GOO_CANVAS_ITEM_SIMPLE (rack->solution_item), FALSE);