Changeset 170

Show
Ignore:
Timestamp:
06/09/07 08:44:22 (1 year ago)
Author:
takkaria
Message:

Fix the other problems in #128:

  • Enter doesn't work on options menu
  • Moving "up" in stores on Windows is the same as pressing space
Files:

Legend:

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

    r169 r170  
    374374static char scroll_get_tag(menu_type *menu, int pos) 
    375375{ 
    376         if(menu->selections) 
     376        if (menu->selections) 
    377377                return menu->selections[pos - menu->top]; 
     378 
    378379        return 0; 
    379380} 
     
    433434static char column_get_tag(menu_type *menu, int pos) 
    434435{ 
    435         if(menu->selections) 
     436        if (menu->selections) 
    436437                return menu->selections[pos]; 
     438 
    437439        return 0; 
    438440} 
     
    594596        region *loc = &menu->boundary; 
    595597        int oid = menu->cursor; 
     598 
    596599        if (menu->object_list && menu->cursor >= 0) 
    597600                oid = menu->object_list[oid]; 
     
    601604        if (menu->title) 
    602605                Term_putstr(loc->col, loc->row, loc->width, TERM_WHITE, menu->title); 
     606 
    603607        if (menu->prompt) 
    604608                Term_putstr(loc->col, loc->row + loc->page_rows - 1, loc->width, 
     
    673677                        out.index = m_curs; 
    674678 
    675                         if (*cursor == m_curs || !(menu->flags & MN_DBL_TAP)) { 
    676                                 if(*cursor != m_curs) { 
     679                        if (*cursor == m_curs || !(menu->flags & MN_DBL_TAP)) 
     680                        { 
     681                                if (*cursor != m_curs) 
     682                                { 
    677683                                        *cursor = m_curs; 
    678684                                        menu_refresh(menu); 
     
    681687                        } 
    682688                        else 
     689                        { 
    683690                                out.type = EVT_MOVE; 
     691                        } 
    684692 
    685693                        *cursor = m_curs; 
     
    713721                                else if (c >= 0) 
    714722                                { 
    715                                         if(menu->cursor != c) { 
     723                                        if (menu->cursor != c) 
     724                                        { 
    716725                                                menu->cursor = c; 
    717726                                                menu_refresh(menu); 
    718727                                        } 
     728 
    719729                                        out.type = EVT_SELECT; 
    720730                                        out.index = c; 
     731 
    721732                                        break; 
    722733                                } 
     
    727738                                return FALSE; 
    728739 
    729                         if (isspace(in->key) && (menu->flags & MN_PAGE)) 
     740                        if (in->key == ' ' && (menu->flags & MN_PAGE)) 
    730741                        { 
    731742                                /* Go to start of next page */ 
    732743                                *cursor += menu->active.page_rows - (*cursor % menu->active.page_rows); 
    733                                 if(*cursor >= menu->filter_count)  
     744 
     745                                if (*cursor >= menu->filter_count) 
    734746                                        *cursor = 0; 
     747 
    735748                                out.type = EVT_MOVE; 
    736749                                out.index = *cursor; 
     750 
    737751                                break; 
    738752                        } 
    739753 
    740                         /* cursor movement */ 
     754                        /* Cursor movement */ 
    741755                        dir = target_dir(in->key); 
    742756 
     757                        /* Handle Enter */ 
     758                        if (in->key == '\n' || in->key == '\r') 
     759                        { 
     760                                out.type = EVT_SELECT; 
     761                                out.index = *cursor; 
     762                        } 
    743763                        /* Reject diagonals */ 
    744                         if (ddx[dir] && ddy[dir]) 
     764                        else if (ddx[dir] && ddy[dir]) 
    745765                        { 
    746766                                return FALSE; 
    747767                        } 
     768                        /* Forward/back */ 
    748769                        else if (ddx[dir]) 
    749770                        { 
     
    10821103        const menu_skin *skin = find_menu_skin(skin_id); 
    10831104        const menu_iter *iter = find_menu_iter(iter_id); 
     1105 
    10841106        if (!iter || !skin) 
    10851107        { 
    1086                 msg_print(format 
    1087                                   ("could not find menu VTAB (%d, %d)!", skin_id, iter_id)); 
     1108                msg_format("could not find menu VTAB (%d, %d)!", skin_id, iter_id); 
    10881109                return FALSE; 
    10891110        } 
     1111 
    10901112        return menu_init2(menu, skin, iter, loc); 
    10911113} 
     
    10931115void menu_destroy(menu_type *menu) 
    10941116{ 
    1095         if (menu->object_list) FREE((void *)menu->object_list); 
     1117        if (menu->object_list) 
     1118                FREE(menu->object_list); 
    10961119} 
    10971120