Changeset 29

Show
Ignore:
Timestamp:
04/02/07 04:31:31 (2 years ago)
Author:
pmac
Message:

Knowledge browser menus now use the real thing.
Fixed regression in scrolling menus that crept in while I was writing labeling code.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/cmd4.c

    r28 r29  
    4343typedef struct { 
    4444 
    45                 /* Display object label (possibly with cursor) at given screen location. */ 
    46                 void (*display_label)(int col, int row, bool cursor, int oid); 
     45                void (*display_member)(int col, int row, bool cursor, int oid);  
    4746 
    4847                void (*lore)(int oid); /* Dump known lore to screen*/ 
     
    5655                /* Address of inscription.  Unknown 'flavors' return null  */ 
    5756                u16b *(*note)(int oid); 
     57 
     58                /* extra context for display of members */ 
     59                bool is_visual; 
     60 
    5861 
    5962} member_funcs; 
     
    141144const char *feature_group_text[] =  
    142145{ 
    143                "Floors", 
    144                "Traps", 
    145                "Doors", 
    146                "Stairs", 
    147                "Walls", 
    148                "Streamers", 
    149                "Obstructions", 
    150                "Stores", 
    151                "Other", 
    152                NULL 
     146        "Floors", 
     147        "Traps", 
     148        "Doors", 
     149        "Stairs", 
     150        "Walls", 
     151        "Streamers", 
     152        "Obstructions", 
     153        "Stores", 
     154        "Other", 
     155        NULL 
    153156}; 
    154157 
     
    158161static void display_visual_list(int col, int row, int height, int width, 
    159162                                byte attr_top, char char_left); 
    160  
    161 static void browser_mouse(key_event ke, int *column, int *grp_cur, int grp_cnt,  
    162                                 int *list_cur, int list_cnt, int col0, int row0, 
    163                                 int grp0, int list0, int *delay); 
    164  
    165 static void browser_cursor(char ch, int *column, int *grp_cur, int grp_cnt,  
    166                                 int *list_cur, int list_cnt); 
    167163 
    168164static bool visual_mode_command(key_event ke, bool *visual_list_ptr,  
     
    188184int feat_order(int feat) 
    189185{ 
    190                feature_type *f_ptr = &f_info[feat]; 
    191                switch(f_ptr->d_char) { 
    192                                case '.':                              return 0; 
    193                                case '^':                              return 1; 
    194                                case '\'': case '+':   return 2; 
    195                                case '<': case '>':            return 3; 
    196                                case '#':                              return 4; 
    197                                case '*': case '%' :   return 5; 
    198                                case ';': case ':' :   return 6; 
    199                                default: 
    200                                        if(isdigit(f_ptr->d_char)) return 7; 
    201                                        return 8; 
    202                
     186        feature_type *f_ptr = &f_info[feat]; 
     187        switch(f_ptr->d_char) { 
     188                case '.':                             return 0; 
     189                case '^':                             return 1; 
     190                case '\'': case '+':  return 2; 
     191                case '<': case '>':           return 3; 
     192                case '#':                             return 4; 
     193                case '*': case '%' :  return 5; 
     194                case ';': case ':' :  return 6; 
     195                default: 
     196                if(isdigit(f_ptr->d_char)) return 7; 
     197                return 8; 
     198       
    203199}; 
    204200 
     
    211207static void big_pad(int col, int row, byte a, byte c) 
    212208{ 
    213                Term_putch(col, row, a, c); 
    214                if(!use_bigtile) return; 
    215                if (a &0x80) Term_putch(col+1, row, 255, -1); 
    216                else Term_putch(col+1, row, 1, ' '); 
     209        Term_putch(col, row, a, c); 
     210        if(!use_bigtile) return; 
     211        if (a &0x80) Term_putch(col+1, row, 255, -1); 
     212        else Term_putch(col+1, row, 1, ' '); 
    217213} 
    218214 
    219215static int actual_width(int width) { 
    220                if (use_trptile) width = width * 3; 
    221                else if(use_dbltile) width *= 2; 
    222                if(use_bigtile) width *= 2; 
     216        if (use_trptile) width = width * 3; 
     217        else if(use_dbltile) width *= 2; 
     218        if(use_bigtile) width *= 2; 
    223219                return width; 
    224220} 
    225221static int actual_height(int height) { 
    226                if(use_bigtile) height *= 2; 
    227                if (use_trptile) height = height * 3 / 2; 
    228                else if(use_dbltile) height *= 2; 
    229                return height; 
     222        if(use_bigtile) height *= 2; 
     223        if (use_trptile) height = height * 3 / 2; 
     224        else if(use_dbltile) height *= 2; 
     225        return height; 
    230226} 
    231227 
    232228static int logical_width(int width) 
    233229{ 
    234                int div = 1; 
    235                if(use_trptile) div = 3; 
    236                else if(use_dbltile) div *= 2; 
    237                if(use_bigtile) div *= 2; 
    238                return width / div; 
     230        int div = 1; 
     231        if(use_trptile) div = 3; 
     232        else if(use_dbltile) div *= 2; 
     233        if(use_bigtile) div *= 2; 
     234        return width / div; 
    239235} 
    240236 
    241237static int logical_height(int height) 
    242238{ 
    243                int div = 1; 
    244                if(use_trptile) { 
    245                                height *= 2; 
    246                                div = 3; 
    247                
    248                else if(use_dbltile) div = 2; 
    249                if(use_bigtile) div *= 2; 
    250                return height / div; 
     239        int div = 1; 
     240        if(use_trptile) { 
     241                height *= 2; 
     242                div = 3; 
     243       
     244        else if(use_dbltile) div = 2; 
     245        if(use_bigtile) div *= 2; 
     246        return height / div; 
    251247} 
    252248 
     
    259255static int auto_note_modify(int note, char ch) 
    260256{ 
    261                char tmp[80]; 
    262  
    263                cptr s; 
    264  
    265                /* Paranoia */ 
    266                if (!ch) return(note); 
    267  
    268                /* Null length string to start */ 
    269                tmp[0] = '\0'; 
    270  
    271                /* Inscription */ 
    272                if (note) 
    273                
    274  
    275                                /* Get the inscription */ 
    276                                s = quark_str(note); 
    277  
    278                                /* Temporary copy */ 
    279                                my_strcpy(tmp,s,80); 
    280  
    281                                /* Process inscription */ 
    282                                while (s) 
    283                                
    284  
    285                                                /* Auto-pickup on "=g" */ 
    286                                                if (s[1] == ch) 
    287                                                
    288  
    289                                                                /* Truncate string */ 
    290                                                                tmp[strlen(tmp)-strlen(s)] = '\0'; 
    291  
    292                                                                /* Overwrite shorter string */ 
    293                                                                my_strcat(tmp,s+2,80); 
    294  
    295                                                                /* Create quark */ 
    296                                                                return(quark_add(tmp)); 
    297                                                
    298  
    299                                                /* Find another '=' */ 
    300                                                s = strchr(s + 1, '='); 
    301                                
    302                
    303  
    304                /* Append note */ 
    305                my_strcat(tmp,format("=%c",ch),80); 
    306  
    307                /* Create quark */ 
    308                return(quark_add(tmp)); 
     257        char tmp[80]; 
     258 
     259        cptr s; 
     260 
     261        /* Paranoia */ 
     262        if (!ch) return(note); 
     263 
     264        /* Null length string to start */ 
     265        tmp[0] = '\0'; 
     266 
     267        /* Inscription */ 
     268        if (note) 
     269       
     270 
     271                /* Get the inscription */ 
     272                s = quark_str(note); 
     273 
     274                /* Temporary copy */ 
     275                my_strcpy(tmp,s,80); 
     276 
     277                /* Process inscription */ 
     278                while (s) 
     279               
     280 
     281                        /* Auto-pickup on "=g" */ 
     282                        if (s[1] == ch) 
     283                       
     284 
     285                                /* Truncate string */ 
     286                                tmp[strlen(tmp)-strlen(s)] = '\0'; 
     287 
     288                                /* Overwrite shorter string */ 
     289                                my_strcat(tmp,s+2,80); 
     290 
     291                                /* Create quark */ 
     292                                return(quark_add(tmp)); 
     293                       
     294 
     295                        /* Find another '=' */ 
     296                        s = strchr(s + 1, '='); 
     297               
     298       
     299 
     300        /* Append note */ 
     301        my_strcat(tmp,format("=%c",ch),80); 
     302 
     303        /* Create quark */ 
     304        return(quark_add(tmp)); 
    309305} 
    310306 
     
    315311                                int start, int max, int cursor, const cptr group_text[]) 
    316312{ 
    317                 int i, pos; 
    318  
    319                 /* Display lines until done */ 
    320                 for (i = 0, pos = start; i < per_page && pos < max; i++, pos++) 
    321                 { 
    322                                 char buffer[21]; 
    323                                 byte attr = curs_attrs[CURS_KNOWN][cursor == pos]; 
    324  
    325                                 /* Erase the line */ 
    326                                 Term_erase(col, row + i, wid); 
    327  
    328                                 /* Display it (width should not exceed 20) */ 
    329                                 strncpy(buffer, group_text[pos], 20); 
    330                                 buffer[20] = 0; 
    331                                 c_put_str(attr, buffer, row + i, col); 
    332                 } 
    333                 /* Wipe the rest? */ 
    334 
    335  
    336 /* 
    337  * Display the members of a list. 
    338  * Aware of inscriptions, wizard information, and string-formatted visual data. 
    339  * label function must display actual visuals, to handle illumination, etc 
    340  */ 
    341 static void display_member_list(int col, int row, int wid, int per_page, 
    342                                 int start, int o_count, int cursor, int object_idx [], 
    343                                 member_funcs o_funcs) 
    344 
    345                 int i, pos; 
    346  
    347                 for(i = 0, pos = start; i < per_page && pos < o_count; i++, pos++) { 
    348                                 int oid = object_idx[pos]; 
    349                                 byte attr = curs_attrs[CURS_KNOWN][cursor == oid]; 
    350  
    351                                 /* Print basic label */ 
    352                                 o_funcs.display_label(col, row + i, pos == cursor, oid); 
    353  
    354                                 /* Show inscription, if applicable, aware and existing */ 
    355                                 if(o_funcs.note && o_funcs.note(oid) && *o_funcs.note(oid)) { 
    356                                                 c_put_str(TERM_YELLOW,quark_str(*o_funcs.note(oid)), row+i, 65); 
    357                                 } 
    358  
    359                                 if (p_ptr->wizard) 
    360                                                 c_put_str(attr, format("%d", oid), row, 60); 
    361  
    362                                 /* Do visual mode */ 
    363                                 if(per_page == 1 && o_funcs.xattr) { 
    364                                                 char c = *o_funcs.xchar(oid); 
    365                                                 byte a = *o_funcs.xattr(oid); 
    366                                                 c_put_str(attr, format((c & 0x80) ? "%02x/%02x" : "%02x/%d", a, c), row + i, 60); 
    367                                 } 
    368                 } 
    369  
    370                 /* Clear remaining lines */ 
    371                 for (; i < per_page; i++) 
    372                 { 
    373                                 Term_erase(col, row + i, 255); 
    374                 } 
    375 
    376  
     313        int i, pos; 
     314 
     315        /* Display lines until done */ 
     316        for (i = 0, pos = start; i < per_page && pos < max; i++, pos++) 
     317        { 
     318                char buffer[21]; 
     319                byte attr = curs_attrs[CURS_KNOWN][cursor == pos]; 
     320 
     321                /* Erase the line */ 
     322                Term_erase(col, row + i, wid); 
     323 
     324                /* Display it (width should not exceed 20) */ 
     325                strncpy(buffer, group_text[pos], 20); 
     326                buffer[20] = 0; 
     327                c_put_str(attr, buffer, row + i, col); 
     328        } 
     329        /* Wipe the rest? */ 
     330
     331 
     332static void display_group_member(menu_type *menu, int oid, 
     333                                                bool cursor, int row, int col, int wid) 
     334
     335        member_funcs *o_funcs = (member_funcs*) menu->menu_data; 
     336        byte attr = curs_attrs[CURS_KNOWN][cursor == oid]; 
     337 
     338        /* Show inscription, if applicable, aware and existing */ 
     339        if(o_funcs->note && o_funcs->note(oid) && *o_funcs->note(oid)) { 
     340                c_put_str(TERM_YELLOW,quark_str(*o_funcs->note(oid)), row, 65); 
     341        } 
     342        o_funcs->display_member(col, row, cursor, oid); 
     343 
     344        if (p_ptr->wizard) c_put_str(attr, format("%d", oid), row, 60); 
     345 
     346        /* Do visual mode */ 
     347        if(o_funcs->is_visual && o_funcs->xattr) { 
     348                char c = *o_funcs->xchar(oid); 
     349                byte a = *o_funcs->xattr(oid); 
     350                c_put_str(attr, format((c & 0x80) ? "%02x/%02x" : "%02x/%d", a, c), row, 60); 
     351        } 
     352
     353 
     354 
     355#define swap(a, b) (swapspace = (void*)(a)), ((a) = (b)), ((b) = swapspace) 
    377356 
    378357/* 
     
    396375        int grp_cnt = 0; /* total number groups */ 
    397376 
    398         int g_cur = 0, grp_old = -1, grp_top = 0; /* group list positions */ 
    399         int o_cur = 0, object_top = 0; /* object list positions */ 
    400         int g_o_count = 0; /* object count for group */ 
    401         int o_first = 0, g_o_max = 0; /* group limits in object list */ 
    402         int oid = -1, old_oid = -1;  /* object identifiers */ 
     377        int g_cur = 0, grp_old = -1; /* group list positions */ 
     378        int o_cur = 0;                                  /* object list positions */ 
     379        int g_o_count = 0;                               /* object count for group */ 
     380        int oid = -1;                           /* object identifiers */ 
    403381 
    404382        /* display state variables */ 
     
    409387 
    410388        int delay = 0; 
    411         int column = 0; 
     389 
     390        menu_type group_menu; 
     391        menu_type object_menu; 
     392        menu_iter object_iter; 
     393 
     394        /* Panel state */ 
     395        int *active_cursor = &g_cur, *inactive_cursor = &o_cur; 
     396        menu_type *active_menu = &group_menu, *inactive_menu = &object_menu; 
     397        int panel = 0; 
     398        void *swapspace; 
     399        bool do_swap = FALSE; 
    412400 
    413401        bool flag = FALSE; 
     
    440428        g_offset[grp_cnt] = o_count; 
    441429        g_list[grp_cnt] = -1; 
     430 
    442431 
    443432 
     
    452441        if(g_name_len >= 20) g_name_len = 20; 
    453442 
    454         while ((!flag) && (grp_cnt)) 
    455         { 
    456                 key_event ke; 
    457  
    458                 if (redraw) 
    459                 { 
    460                         clear_from(0); 
    461                         /* Hack: This could be cleaner */ 
    462                         prt( format("Knowledge - %s", title), 2, 0); 
     443        /* Disable the roguelike commands for the duration */ 
     444        int omode = rogue_like_commands; 
     445        rogue_like_commands = FALSE; 
     446 
     447        region title_area = {0, 0, 0, 4}; 
     448        region group_region = {0, 6, g_name_len, -1}; 
     449        region object_region = {g_name_len+3, 6, 0, -2}; 
     450 
     451        WIPE(&group_menu, menu_type); 
     452        group_menu.count = grp_cnt; 
     453        group_menu.cmd_keys = "\n\r6\x8C";  /* Don't treat this as motion */ 
     454        group_menu.menu_data = g_names; 
     455 
     456        WIPE(&object_menu, menu_type); 
     457        object_menu.menu_data = &o_funcs; 
     458        WIPE(&object_iter, object_iter); 
     459        object_iter.display_row = display_group_member; 
     460 
     461        o_funcs.is_visual = FALSE; 
     462 
     463        menu_init(&group_menu, MN_SCROLL, MN_STRING, &group_region); 
     464        menu_init2(&object_menu, find_menu_skin(MN_SCROLL), &object_iter, &object_region); 
     465 
     466 
     467        /* This is the event loop for a multi-region panel */ 
     468        /* Panels are -- text panels, two menus, and visual browser */ 
     469        /* with "pop-up menu" for lore */ 
     470        while((!flag) && (grp_cnt)) { 
     471                key_event ke, ke0; 
     472                if(redraw) { 
     473                        region_erase(&title_area); 
     474                        prt(format("Knowledge - %s", title), 2, 0); 
    463475                        prt( "Group", 4, 0); 
    464476                        prt("Name", 4, g_name_len + 3); 
     
    468480                        if(otherfields) 
    469481                                Term_addstr(-1, TERM_WHITE, otherfields); 
    470  
    471482                        for (i = 0; i < 78; i++) 
    472                         { 
    473483                                Term_putch(i, 5, TERM_WHITE, '='); 
    474                         } 
    475  
    476484                        for (i = 0; i < browser_rows; i++) 
    477                         { 
    478485                                Term_putch(g_name_len + 1, 6 + i, TERM_WHITE, '|'); 
    479                         } 
    480486 
    481487                        redraw = FALSE; 
    482488                } 
    483489 
    484                 /* Scroll group list */ 
    485                 if (g_cur < grp_top) grp_top = g_cur; 
    486                 if (g_cur >= grp_top + browser_rows) grp_top = g_cur - browser_rows + 1; 
    487                 if (grp_top + browser_rows >= grp_cnt) grp_top = grp_cnt - browser_rows; 
    488                 if(grp_top < 0) grp_top = 0; 
    489  
    490490                if(g_cur != grp_old) { 
    491                         o_first = o_cur = g_offset[g_cur]
    492                         object_top = o_first
     491                        grp_old = g_cur
     492                        o_cur = 0
    493493                        g_o_count = g_offset[g_cur+1] - g_offset[g_cur]; 
    494                         g_o_max = g_offset[g_cur+1]; 
    495                         grp_old = g_cur; 
    496                         old_oid = -1; 
    497                 } 
    498  
    499                 /* Display a scrollable list of groups */ 
    500                 display_group_list(0, 6, g_name_len, browser_rows, 
    501                                                                                         grp_top, grp_cnt, g_cur, g_names); 
    502  
    503                 /* Scroll object list */ 
    504                 if(o_cur >= g_o_max) o_cur = g_o_max-1; 
    505                 if(o_cur < o_first) o_cur = o_first; 
    506                 if (o_cur < object_top) object_top = o_cur; 
    507                 if (o_cur >= object_top + browser_rows) 
    508                         object_top = o_cur - browser_rows + 1; 
    509                 if (object_top + browser_rows >= g_o_max) 
    510                         object_top = g_o_max - browser_rows; 
    511                 if(object_top < o_first) object_top = o_first; 
    512  
    513                 oid = obj_list[o_cur]; 
    514  
     494                        menu_set_filter(&object_menu, obj_list + g_offset[g_cur], g_o_count); 
     495                        group_menu.cursor = g_cur; 
     496                        object_menu.cursor = 0; 
     497                } 
     498                /* HACK ... */ 
    515499                if(!visual_list) { 
    516                         /* Display a list of objects in the current group */ 
    517                         display_member_list(g_name_len + 3, 6, g_name_len, browser_rows,  
    518                                                                                 object_top, g_o_max, o_cur, obj_list, o_funcs); 
    519                 } 
    520                 else 
    521                 { 
    522                         /* Edit 1 group member */ 
    523                         object_top = o_cur; 
    524                         /* Display a single-row list */ 
    525                         display_member_list(g_name_len + 3, 6, g_name_len, 1,  
    526                                                                 o_cur, g_o_max, o_cur, obj_list, o_funcs); 
    527                         /* Display visual list below first object */ 
    528                         display_visual_list(g_name_len + 3, 7, browser_rows-1, 
    529                                                                                 wid - (g_name_len + 3), attr_top, char_left); 
    530                 } 
     500                        /* ... The object menu may be browsing the entire group... */ 
     501                        o_funcs.is_visual = FALSE; 
     502                        menu_set_filter(&object_menu, obj_list + g_offset[g_cur], g_o_count); 
     503                        object_menu.cursor = o_cur; 
     504                } 
     505                else { 
     506                        /* ... or just a single element in the group. */ 
     507                        o_funcs.is_visual = TRUE; 
     508                        menu_set_filter(&object_menu, obj_list + o_cur, 1); 
     509                        object_menu.cursor = 0; 
     510                } 
     511                oid = obj_list[g_offset[g_cur]+o_cur]; 
    531512                /* Prompt */ 
    532513                { 
     
    548529                                                                                pvs, pedit, pnote, pnote1), hgt-1, 0); 
    549530                } 
    550  
     531                if(do_swap) { 
     532                        do_swap = FALSE; 
     533                        swap(active_menu, inactive_menu); 
     534                        swap(active_cursor, inactive_cursor); 
     535                        panel = 1-panel; 
     536                } 
     537 
     538                menu_refresh(inactive_menu); 
     539                menu_refresh(active_menu); 
    551540                handle_stuff(); 
    552541 
     
    555544                        place_visual_list_cursor(g_name_len + 3, 7, *o_funcs.xattr(oid),  
    556545                                                                                *o_funcs.xchar(oid), attr_top, char_left); 
    557                 } 
    558                 else if (!column) 
    559                 { 
    560                         Term_gotoxy(0, 6 + (g_cur - grp_top)); 
    561                 } 
    562                 else 
    563                 { 
    564                         Term_gotoxy(g_name_len + 3, 6 + (o_cur - object_top)); 
    565546                } 
    566547 
     
    588569                } 
    589570 
     571                if(ke.type == EVT_MOUSE) { 
     572                        /* Change active panels */ 
     573                        if(region_inside(&inactive_menu->boundary, &ke)) { 
     574                                swap(active_menu, inactive_menu); 
     575                                swap(active_cursor, inactive_cursor); 
     576                                panel = 1-panel; 
     577                        } 
     578                } 
     579                ke0 = run_event_loop(&active_menu->target, 0, &ke); 
     580                if(ke0.type != EVT_AGAIN) ke = ke0; 
     581                switch(ke.type) { 
     582                        case EVT_KBRD: 
     583                                break; 
     584                        case ESCAPE: 
     585                                flag = TRUE; 
     586                                continue; 
     587                        case EVT_SELECT: 
     588                                if(panel == 1 && oid >= 0 && o_cur == active_menu->cursor) { 
     589                                        o_funcs.lore(oid); 
     590                                        redraw = TRUE; 
     591                                } 
     592                        case EVT_MOVE: 
     593                                *active_cursor = active_menu->cursor; 
     594                                continue; 
     595                        case EVT_BACK: 
     596                                if(panel == 1) 
     597                                        do_swap = TRUE; 
     598                        default: 
     599                                continue; 
     600                } 
    590601                switch (ke.key) 
    591602                { 
     
    595606                                flag = TRUE; 
    596607                                break; 
    597                         } 
    598  
    599                         case '\xff': 
    600                         { 
    601                                 /* Move the cursor */ 
    602                                 browser_mouse(ke, &column, &g_cur, grp_cnt, 
    603                                                                 &o_cur, g_o_max, g_name_len + 3, 6, 
    604                                                                 grp_top, object_top, &delay); 
    605                                 if (!ke.index) break; 
    606                                 if(oid != obj_list[o_cur]) 
    607                                                 break; 
    608608                        } 
    609609 
     
    614614                                if(oid >= 0) 
    615615                                        o_funcs.lore(oid); 
     616                                redraw = TRUE; 
    616617 
    617618                                redraw = TRUE; 
     
    681682                        default: 
    682683                        { 
    683                                 /* Move the cursor; disable roguelike keyset. */ 
    684                                 int omode = rogue_like_commands; 
    685                                 rogue_like_commands = FALSE; 
    686                                 if(target_dir(ke.key)) { 
    687                                         browser_cursor(ke.key, &column, &g_cur, grp_cnt, 
    688                                                                         &o_cur, g_o_max); 
     684                                int d = target_dir(ke.key); 
     685                                /* Handle key-driven motion between panels */ 
     686                                if((ddx[d] < 0) && panel == 1) { 
     687                                        /* Silly hack -- diagonal arithmetic */ 
     688                                        g_cur += -(ddy[d] < 0) + (ddy[d] > 0); 
     689                                        if(g_cur < 0) g_cur = 0; 
     690                                        if(g_cur >= grp_cnt) g_cur = grp_cnt -1; 
     691                                        do_swap = TRUE; 
     692                                } 
     693                                else if((ddx[d] > 0) == (panel == 0)) { 
     694                                        o_cur += -(ddy[d] < 0) + (ddy[d] > 0); 
     695                                        if(o_cur < 0) o_cur = 0; 
     696                                        if(o_cur >= g_o_count) o_cur = g_o_count-1; 
     697                                        do_swap = TRUE; 
    689698                                } 
    690699                                else if(o_funcs.note && o_funcs.note(oid)) { 
     
    692701                                        *o_funcs.note(oid) = note_idx; 
    693702                                } 
    694                                 rogue_like_commands = omode; 
    695703                                break; 
    696704                        } 
    697705                } 
    698706        } 
     707 
     708        rogue_like_commands = omode; 
    699709 
    700710        /* Prompt */ 
     
    10251035                                                        m_cmp_race, default_group, 0}; 
    10261036 
    1027         member_funcs m_funcs = {display_monster, mon_lore, m_xchar, m_xattr, 0}; 
     1037        member_funcs m_funcs = {display_monster, mon_lore, m_xchar, m_xattr, 0, 0}; 
     1038 
    10281039         
    10291040        int *monsters; 
     
    14391450static void do_cmd_knowledge_objects(void) 
    14401451{ 
    1441         group_funcs kind_f = 
    1442                 {TV_GOLD, FALSE, kind_name, o_cmp_tval, obj2gid, 0}; 
    1443         member_funcs obj_f = 
    1444                 {display_object, desc_obj_fake, o_xchar, o_xattr, o_note}; 
     1452        group_funcs kind_f = {TV_GOLD, FALSE, kind_name, o_cmp_tval, obj2gid, 0}; 
     1453        member_funcs obj_f = {display_object, desc_obj_fake, o_xchar, o_xattr,0 /* o_note*/}; 
    14451454 
    14461455        int *objects; 
     
    39563965        msg_print("Html screen dump saved."); 
    39573966        message_flush(); 
    3958 } 
    3959  
    3960  
    3961 /* 
    3962  * Move the cursor using the mouse in a browser window 
    3963  */ 
    3964 static void browser_mouse(key_event ke, int *column, int *grp_cur, 
    3965                                                         int grp_cnt, int *list_cur, int list_cnt, 
    3966                                                         int col0, int row0, int grp0, int list0, 
    3967                                                         int *delay) 
    3968 { 
    3969         int my = ke.mousey - row0; 
    3970         int mx = ke.mousex; 
    3971         int wid; 
    3972         int hgt; 
    3973  
    3974         int grp = *grp_cur; 
    3975         int list = *list_cur; 
    3976  
    3977         /* Get size */ 
    3978         Term_get_size(&wid, &hgt); 
    3979  
    3980         if (mx < col0) 
    3981         { 
    3982                 int old_grp = grp; 
    3983  
    3984                 *column = 0; 
    3985                 if ((my >= 0) && (my < grp_cnt - grp0) && (my < hgt - row0 - 2)) grp = my + grp0; 
    3986                 else if (my < 0) { grp--; *delay = 100; } 
    3987                 else if (my >= hgt - row0 - 2) { grp++; *delay = 50; } 
    3988  
    3989                 /* Verify */ 
    3990                 if (grp >= grp_cnt)     grp = grp_cnt - 1; 
    3991                 if (grp < 0) grp = 0; 
    3992                 if (grp != old_grp)     list = 0; 
    3993  
    3994         } 
    3995         else 
    3996         { 
    3997                 *column = 1; 
    3998                 if ((my >= 0) && (my < list_cnt - list0) && (my < hgt - row0 - 2)) list = my + list0; 
    3999                 else if (my < 0) { list--; *delay = 100; } 
    4000                 else if (my >= hgt - row0 - 2) { list++; *delay = 50; } 
    4001  
    4002                 /* Verify */ 
    4003                 if (list >= list_cnt) list = list_cnt - 1; 
    4004                 if (list < 0) list = 0; 
    4005         } 
    4006  
    4007         (*grp_cur) = grp; 
    4008         (*list_cur) = list; 
    4009 }  
    4010  
    4011 /*  
    4012  * Move the cursor in a browser window  
    4013  */ 
    4014 static void browser_cursor(char ch, int *column, int *grp_cur, int grp_cnt,  
    4015                                                    int *list_cur, int list_cnt) 
    4016 { 
    4017         int d; 
    4018         int col = *column; 
    4019         int grp = *grp_cur; 
    4020         int list = *list_cur; 
    4021  
    4022         /* Extract direction */ 
    4023         d = target_dir(ch); 
    4024  
    4025         if (!d) return; 
    4026  
    4027         /* Diagonals - hack */ 
    4028         if ((ddx[d] > 0) && ddy[d]) 
    4029         { 
    4030                 int browser_rows; 
    4031                 int wid, hgt; 
    4032  
    4033                 /* Get size */ 
    4034                 Term_get_size(&wid, &hgt); 
    4035  
    4036                 browser_rows = hgt - 8; 
    4037  
    4038                 /* Browse group list */ 
    4039                 if (!col) 
    4040                 { 
    4041                         int old_grp = grp; 
    4042  
    4043                         /* Move up or down */ 
    4044                         grp += ddy[d] * browser_rows; 
    4045  
    4046                         /* Verify */ 
    4047                         if (grp >= grp_cnt)     grp = grp_cnt - 1; 
    4048                         if (grp < 0) grp = 0; 
    4049                         if (grp != old_grp)     list = 0; 
    4050                 } 
    4051  
    4052                 /* Browse sub-list list */ 
    4053                 else 
    4054                 { 
    4055                         /* Move up or down */ 
    4056                         list += ddy[d] * browser_rows; 
    4057  
    4058                         /* Verify */ 
    4059                         if (list >= list_cnt) list = list_cnt - 1; 
    4060                         if (list < 0) list = 0; 
    4061                 } 
    4062  
    4063                 (*grp_cur) = grp; 
    4064                 (*list_cur) = list; 
    4065  
    4066                 return; 
    4067         } 
    4068  
    4069         if (ddx[d]) 
    4070         { 
    4071                 col += ddx[d]; 
    4072                 if (col < 0) col = 0; 
    4073                 if (col > 1) col = 1; 
    4074  
    4075                 (*column) = col; 
    4076  
    4077                 return; 
    4078         } 
    4079  
    4080         /* Browse group list */ 
    4081         if (!col) 
    4082         { 
    4083                 int old_grp = grp; 
    4084  
    4085                 /* Move up or down */ 
    4086                 grp += ddy[d]; 
    4087  
    4088                 /* Verify */ 
    4089                 if (grp < 0) grp = 0; 
    4090                 if (grp >= grp_cnt)     grp = grp_cnt - 1; 
    4091                 if (grp != old_grp)     list = 0; 
    4092         } 
    4093  
    4094         /* Browse sub-list list */ 
    4095         else 
    4096         { 
    4097                 /* Move up or down */ 
    4098                 list += ddy[d]; 
    4099  
    4100                 /* Verify */ 
    4101                 if (list >= list_cnt) list = list_cnt - 1; 
    4102                 if (list < 0) list = 0; 
    4103         } 
    4104  
    4105         (*grp_cur) = grp; 
    4106         (*list_cur) = list; 
    41073967} 
    41083968 
  • trunk/src/ui.c

    r28 r29  
    120120                        handled = target->self.handler(target->self.object, &ke); 
    121121 
    122                 if(target->is_modal) 
    123                         continue; 
    124  
    125                 while(list && !handled) { 
    126                         if(ke.type & list->listener->events.evt_flags) { 
    127                                 handled = list->listener->handler(list->listener->object, &ke); 
    128                         } 
    129                         list = list->next; 
     122                if(!target->is_modal) { 
     123                        while(list && !handled) { 
     124                                if(ke.type & list->listener->events.evt_flags) { 
     125                                        handled = list->listener->handler(list->listener->object, &ke); 
     126                                } 
     127                                list = list->next; 
     128