Changeset 862
- Timestamp:
- 04/29/08 21:12:02 (4 months ago)
- Files:
-
- trunk/src/cmd0.c (modified) (2 diffs)
- trunk/src/cmd4.c (modified) (7 diffs)
- trunk/src/death.c (modified) (1 diff)
- trunk/src/squelch.c (modified) (4 diffs)
- trunk/src/store.c (modified) (1 diff)
- trunk/src/ui-birth.c (modified) (1 diff)
- trunk/src/ui-menu.c (modified) (8 diffs)
- trunk/src/ui-menu.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/cmd0.c
r759 r862 474 474 menu.count = list->len; 475 475 menu.menu_data = list->list; 476 menu_init2(&menu, find_menu_skin(MN_SCROLL), &commands_menu, &area);476 menu_init2(&menu, MN_SKIN_SCROLL, &commands_menu, &area); 477 477 478 478 /* Set up the screen */ … … 539 539 menu.count = N_ELEMENTS(cmds_all) - 1; 540 540 menu.menu_data = &chosen_command; 541 menu_init2(&menu, find_menu_skin(MN_SCROLL), &commands_menu, &area);541 menu_init2(&menu, MN_SKIN_SCROLL, &commands_menu, &area); 542 542 543 543 /* Set up the screen */ trunk/src/cmd4.c
r823 r862 480 480 o_funcs.is_visual = FALSE; 481 481 482 menu_init(&group_menu, MN_S CROLL, MN_STRINGS, &group_region);483 menu_init2(&object_menu, find_menu_skin(MN_SCROLL), &object_iter, &object_region);482 menu_init(&group_menu, MN_SKIN_SCROLL, MN_STRINGS, &group_region); 483 menu_init2(&object_menu, MN_SKIN_SCROLL, &object_iter, &object_region); 484 484 485 485 … … 4223 4223 menu->cmd_keys = cmd_keys; 4224 4224 menu->count = N_ELEMENTS(option_actions); 4225 menu_init2(menu, find_menu_skin(MN_SCROLL), &options_iter, &SCREEN_REGION);4225 menu_init2(menu, MN_SKIN_SCROLL, &options_iter, &SCREEN_REGION); 4226 4226 4227 4227 /* Initialize the options toggle menu */ … … 4233 4233 menu->count = OPT_PAGE_PER; 4234 4234 menu->flags = MN_DBL_TAP; 4235 menu_init2(menu, find_menu_skin(MN_SCROLL), &options_toggle_iter, &SCREEN_REGION);4235 menu_init2(menu, MN_SKIN_SCROLL, &options_toggle_iter, &SCREEN_REGION); 4236 4236 4237 4237 /* macro menu */ … … 4244 4244 menu->menu_data = macro_actions; 4245 4245 menu->count = N_ELEMENTS(macro_actions); 4246 menu_init(menu, MN_S CROLL, MN_ACTIONS, &SCREEN_REGION);4246 menu_init(menu, MN_SKIN_SCROLL, MN_ACTIONS, &SCREEN_REGION); 4247 4247 4248 4248 /* visuals menu */ … … 4255 4255 menu->menu_data = visual_menu_items; 4256 4256 menu->count = N_ELEMENTS(visual_menu_items); 4257 menu_init(menu, MN_S CROLL, MN_ACTIONS, &SCREEN_REGION);4257 menu_init(menu, MN_SKIN_SCROLL, MN_ACTIONS, &SCREEN_REGION); 4258 4258 4259 4259 /* colors menu */ … … 4266 4266 menu->menu_data = color_events; 4267 4267 menu->count = N_ELEMENTS(color_events); 4268 menu_init(menu, MN_S CROLL, MN_ACTIONS, &SCREEN_REGION);4268 menu_init(menu, MN_SKIN_SCROLL, MN_ACTIONS, &SCREEN_REGION); 4269 4269 4270 4270 /* knowledge menu */ … … 4275 4275 menu->menu_data = knowledge_actions; 4276 4276 menu->count = N_ELEMENTS(knowledge_actions), 4277 menu_init(menu, MN_S CROLL, MN_ITEMS, &SCREEN_REGION);4277 menu_init(menu, MN_SKIN_SCROLL, MN_ITEMS, &SCREEN_REGION); 4278 4278 4279 4279 /* initialize other static variables */ trunk/src/death.c
r815 r862 472 472 menu->count = N_ELEMENTS(death_actions); 473 473 474 menu_init2(menu, find_menu_skin(MN_SCROLL), &death_iter, &area);474 menu_init2(menu, MN_SKIN_SCROLL, &death_iter, &area); 475 475 476 476 while (TRUE) trunk/src/squelch.c
r794 r862 630 630 menu.count = area.page_rows = SQUELCH_BAD + 1; 631 631 632 menu_init2(&menu, find_menu_skin(MN_SCROLL), &menu_f, &area);632 menu_init2(&menu, MN_SKIN_SCROLL, &menu_f, &area); 633 633 window_make(area.col - 2, area.row - 1, area.col + area.width + 2, area.row + area.page_rows); 634 634 … … 669 669 menu.cmd_keys = " \n\r"; 670 670 menu.count = TYPE_MAX; 671 menu_init2(&menu, find_menu_skin(MN_SCROLL), &menu_f, &area);671 menu_init2(&menu, MN_SKIN_SCROLL, &menu_f, &area); 672 672 673 673 /* Select an entry */ … … 797 797 menu.count = num; 798 798 menu.menu_data = choice; 799 menu_init2(&menu, find_menu_skin(MN_SCROLL), &menu_f, &area);799 menu_init2(&menu, MN_SKIN_SCROLL, &menu_f, &area); 800 800 801 801 /* Select an entry */ … … 934 934 menu.cmd_keys = cmd_keys; 935 935 menu.count = N_ELEMENTS(sval_dependent) + N_ELEMENTS(extra_item_options) + 1; 936 menu_init2(&menu, find_menu_skin(MN_SCROLL), &options_item_iter, &SCREEN_REGION);936 menu_init2(&menu, MN_SKIN_SCROLL, &options_item_iter, &SCREEN_REGION); 937 937 938 938 menu_layout(&menu, &SCREEN_REGION); trunk/src/store.c
r859 r862 2844 2844 2845 2845 /* Init the menu structure */ 2846 menu_init2(&menu, find_menu_skin(MN_SCROLL), cur_menu, &items_region);2846 menu_init2(&menu, MN_SKIN_SCROLL, cur_menu, &items_region); 2847 2847 2848 2848 if (menu.count > items_region.page_rows) trunk/src/ui-birth.c
r815 r862 350 350 /* Get ui-menu to initialise whatever it wants to to give us a scrollable 351 351 menu. */ 352 menu_init2(menu, find_menu_skin(MN_SCROLL), &birth_iter, reg);352 menu_init2(menu, MN_SKIN_SCROLL, &birth_iter, reg); 353 353 } 354 354 trunk/src/ui-menu.c
r552 r862 244 244 const menu_skin menu_skin_scroll = 245 245 { 246 MN_SCROLL,247 246 scrolling_get_cursor, 248 247 display_scrolling, … … 304 303 static const menu_skin menu_skin_column = 305 304 { 306 MN_COLUMNS,307 305 columns_get_cursor, 308 306 display_columns, … … 323 321 static const menu_skin menu_skin_key_select = 324 322 { 325 MN_KEY_ONLY,326 323 no_cursor, 327 324 display_nothing, 325 NULL, 328 326 }; 329 327 … … 822 820 823 821 /* 824 * The menu skin registry. In the unlikely event you need to register825 * more skins, make the array bigger.826 */827 static menu_skin const *menu_skin_reg[20] =828 {829 &menu_skin_scroll,830 &menu_skin_column,831 &menu_skin_key_select,832 0833 };834 835 /*836 822 * The menu row-iterator registry. 837 823 * Note that there's no need to register "anonymous" row iterators, that is, 838 824 * iterators always accessed by address, and not available in pref files. 839 825 */ 840 static menu_iter const *menu_iter_reg[ 20] =826 static menu_iter const *menu_iter_reg[] = 841 827 { 842 828 &menu_iter_actions, … … 858 844 } 859 845 860 const menu_skin *find_menu_skin(skin_id id)861 {862 size_t i;863 for (i = 0; i < N_ELEMENTS(menu_skin_reg) && menu_skin_reg[i]; i++)864 {865 if (menu_skin_reg[i]->id == id)866 return menu_skin_reg[i];867 }868 return NULL;869 }870 871 void add_menu_skin(const menu_skin *skin, skin_id id)872 {873 size_t i;874 875 assert(skin->id == id);876 for (i = 0; i < N_ELEMENTS(menu_skin_reg) && menu_skin_reg[i]; i++)877 assert(skin->id != menu_skin_reg[id]->id);878 879 if (i == N_ELEMENTS(menu_skin_reg))880 quit("too many registered skins!");881 882 menu_skin_reg[i] = skin;883 }884 846 885 847 void add_menu_iter(const menu_iter * iter, menu_iter_id id) … … 896 858 menu_iter_reg[i] = iter; 897 859 } 860 861 /* 862 * Return the skin behaviour struct for a given skin ID. 863 */ 864 static const menu_skin *find_menu_skin(skin_id id) 865 { 866 switch (id) 867 { 868 case MN_SKIN_SCROLL: 869 return &menu_skin_scroll; 870 871 case MN_SKIN_COLUMNS: 872 return &menu_skin_column; 873 874 case MN_SKIN_KEY_ONLY: 875 return &menu_skin_key_select; 876 } 877 878 return NULL; 879 } 880 898 881 899 882 /* … … 966 949 967 950 968 /* 951 /* 969 952 * Correctly initialise the menu block at 'menu' so that it's ready to use. 970 953 * Use the display skin given in 'skin' and the iterator in 'iter', and set 971 * up to use the region of the window given in 'loc' 954 * up to use the region of the window given in 'loc' 972 955 * 973 956 * Returns FALSE if something goes wrong, and TRUE otherwise (i.e. always). 974 957 */ 975 bool menu_init2(menu_type *menu, const menu_skin *skin, const menu_iter *iter, const region *loc) 976 { 958 bool menu_init2(menu_type *menu, skin_id skin_id, const menu_iter *iter, const region *loc) 959 { 960 const menu_skin *skin = find_menu_skin(skin_id); 961 assert(skin && "menu skin not found!"); 962 977 963 /* Default value for the parameter, effectively. */ 978 964 if (!loc) loc = &SCREEN_REGION; … … 1009 995 bool menu_init(menu_type *menu, skin_id skin_id, menu_iter_id iter_id, const region *loc) 1010 996 { 1011 const menu_skin *skin = find_menu_skin(skin_id);1012 997 const menu_iter *iter = find_menu_iter(iter_id); 1013 998 1014 if (!iter || !skin)1015 { 1016 msg_format("could not find menu VTAB (%d, %d)!", skin_id,iter_id);999 if (!iter) 1000 { 1001 msg_format("could not find menu VTAB (%d, %d)!", iter_id); 1017 1002 return FALSE; 1018 1003 } 1019 1004 1020 return menu_init2(menu, skin , iter, loc);1021 } 1022 1005 return menu_init2(menu, skin_id, iter, loc); 1006 } 1007 trunk/src/ui-menu.h
r861 r862 149 149 /* key-binding. */ 150 150 151 /* Identifier for the type of menu layout to use */ 151 152 /** Identifier for the type of menu layout to use */ 152 153 typedef enum 153 154 { 154 /* Skins */ 155 MN_SCROLL = 0x0000, /* Ordinary scrollable single-column list */ 156 MN_COLUMNS = 0x0002, /* multicolumn view */ 157 MN_NATIVE = 0x0003, /* Not implemented -- OS menu */ 158 MN_KEY_ONLY = 0x0004, /* No display */ 159 MN_USER = 0x0005 /* Anonymous, user defined. */ 155 MN_SKIN_SCROLL = 1, /**< Ordinary scrollable single-column list */ 156 MN_SKIN_COLUMNS = 2, /**< Multicolumn view */ 157 MN_SKIN_KEY_ONLY = 3, /**< No display */ 160 158 } skin_id; 161 159 160 162 161 /* Class functions for menu layout */ 163 struct menu_skin 164 { 165 /* Identifier from the above list */ 166 skin_id id; 162 struct menu_skin 163 { 167 164 /* Determines the cursor index given a (mouse) location */ 168 165 int (*get_cursor)(int row, int col, int n, int top, region *loc); … … 171 168 /* Specifies the relative menu item given the state of the menu */ 172 169 char (*get_tag)(menu_type *menu, int pos); 173 /* Superclass pointer. Not currently used */174 const menu_skin *super;175 170 }; 176 171 … … 282 277 283 278 284 /* Initialize a menu given a pointer to a skin and an iterator */ 285 bool menu_init2(menu_type *menu, const menu_skin *skin, 286 const menu_iter *iter, const region *loc); 279 /* Initialize a menu given skin ID and an iterator */ 280 bool menu_init2(menu_type *menu, skin_id skin, const menu_iter *iter, const region *loc); 287 281 288 282 /* Initialise a menu block given skin and iterator IDs */ … … 294 288 /* Menu VTAB registry */ 295 289 const menu_iter *find_menu_iter(menu_iter_id iter_id); 296 const menu_skin *find_menu_skin(skin_id skin_id);297 298 void add_menu_skin(const menu_skin *skin, skin_id id);299 290 void add_menu_iter(const menu_iter *skin, menu_iter_id id); 300 291
