Changeset 254
- Timestamp:
- 07/03/07 17:29:00 (1 year ago)
- Files:
-
- trunk/src/cmd4.c (modified) (12 diffs)
- trunk/src/store.c (modified) (6 diffs)
- trunk/src/ui.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/cmd4.c
r252 r254 574 574 { 575 575 display_visual_list(g_name_len + 3, 7, browser_rows-1, 576 wid - (g_name_len + 3), attr_top, char_left);576 wid - (g_name_len + 3), attr_top, char_left); 577 577 place_visual_list_cursor(g_name_len + 3, 7, *o_funcs.xattr(oid), 578 578 *o_funcs.xchar(oid), attr_top, char_left); … … 1064 1064 } 1065 1065 1066 static int count_known_monsters(void) 1067 { 1068 int m_count = 0; 1069 int i; 1070 size_t j; 1071 1072 for (i = 0; i < z_info->r_max; i++) 1073 { 1074 monster_race *r_ptr = &r_info[i]; 1075 if (!cheat_know && !l_list[i].sights) continue; 1076 if (!r_ptr->name) continue; 1077 1078 if (r_ptr->flags1 & RF1_UNIQUE) m_count++; 1079 1080 for (j = 1; j < N_ELEMENTS(monster_group) - 1; j++) 1081 { 1082 const char *pat = monster_group[j].chars; 1083 if (strchr(pat, r_ptr->d_char)) m_count++; 1084 } 1085 } 1086 1087 return m_count; 1088 } 1089 1066 1090 /* 1067 1091 * Display known monsters. 1068 1092 */ 1069 static void do_cmd_knowledge_monsters(void )1093 static void do_cmd_knowledge_monsters(void *obj, const char *name) 1070 1094 { 1071 1095 group_funcs r_funcs = {N_ELEMENTS(monster_group), FALSE, race_name, … … 1207 1231 1208 1232 1233 /* If 'artifacts' is NULL, it counts the number of known artifacts, otherwise 1234 it collects the list of known artifacts into 'artifacts' as well. */ 1235 static int collect_known_artifacts(int *artifacts, size_t artifacts_len) 1236 { 1237 int a_count = 0; 1238 int i, j; 1239 1240 if (artifacts) 1241 assert(artifacts_len >= z_info->a_max); 1242 1243 for (j = 0; j < z_info->a_max; j++) 1244 { 1245 /* If the artifact has been created (or we're cheating) */ 1246 if ((cheat_xtra || a_info[j].cur_num) && a_info[j].name) 1247 { 1248 bool valid = TRUE; 1249 1250 for (i = 0; !cheat_xtra && i < z_info->o_max; i++) 1251 { 1252 int a = o_list[i].name1; 1253 1254 /* If we haven't actually identified the artifact yet */ 1255 if (a && a == j && !object_known_p(&o_list[i])) 1256 { 1257 valid = FALSE; 1258 } 1259 } 1260 1261 if (valid) 1262 { 1263 if (artifacts) 1264 artifacts[a_count++] = j; 1265 else 1266 a_count++; 1267 } 1268 } 1269 } 1270 1271 return a_count; 1272 } 1273 1209 1274 /* 1210 1275 * Display known artifacts 1211 1276 */ 1212 static void do_cmd_knowledge_artifacts(void )1277 static void do_cmd_knowledge_artifacts(void *obj, const char *name) 1213 1278 { 1214 1279 /* HACK -- should be TV_MAX */ … … 1216 1281 member_funcs art_f = {display_artifact, desc_art_fake, 0, 0, 0, 0, 0}; 1217 1282 1218 1219 1283 int *artifacts; 1220 1284 int a_count = 0; 1221 int i, j;1222 1285 1223 1286 C_MAKE(artifacts, z_info->a_max, int); 1224 1287 1225 1288 /* Collect valid artifacts */ 1226 for (i = 0; i < z_info->a_max; i++) 1227 { 1228 if ((cheat_xtra || a_info[i].cur_num) && a_info[i].name) 1229 artifacts[a_count++] = i; 1230 } 1231 for (i = 0; !cheat_xtra && i < z_info->o_max; i++) 1232 { 1233 int a = o_list[i].name1; 1234 if (a && !object_known_p(&o_list[i])) 1235 { 1236 for (j = 0; j < a_count && a != artifacts[j]; j++); 1237 a_count -= 1; 1238 for (; j < a_count; j++) 1239 artifacts[j] = artifacts[j+1]; 1240 } 1241 } 1289 a_count = collect_known_artifacts(artifacts, z_info->a_max); 1242 1290 1243 1291 display_knowledge("artifacts", artifacts, a_count, obj_f, art_f, 0); … … 1340 1388 * Display known ego_items 1341 1389 */ 1342 static void do_cmd_knowledge_ego_items(void )1390 static void do_cmd_knowledge_ego_items(void *obj, const char *name) 1343 1391 { 1344 1392 group_funcs obj_f = … … 1594 1642 * Display known objects 1595 1643 */ 1596 static void do_cmd_knowledge_objects(void )1644 static void do_cmd_knowledge_objects(void *obj, const char *name) 1597 1645 { 1598 1646 group_funcs kind_f = {TV_GOLD, FALSE, kind_name, o_cmp_tval, obj2gid, 0}; … … 1670 1718 * Interact with feature visuals. 1671 1719 */ 1672 static void do_cmd_knowledge_features(void )1720 static void do_cmd_knowledge_features(void *obj, const char *name) 1673 1721 { 1674 1722 group_funcs fkind_f = {N_ELEMENTS(feature_group_text), FALSE, … … 1696 1744 1697 1745 1698 void do_cmd_knowledge_home() 1746 void do_cmd_knowledge_home() 1699 1747 { 1700 1748 /* TODO */ … … 3023 3071 3024 3072 if (ESCAPE == c.key) break; 3025 if (c.key == ARROW_LEFT || c.key == ARROW_RIGHT) continue;3073 if (c.key == ARROW_LEFT || c.key == ARROW_RIGHT) continue; 3026 3074 evt = macro_actions[cursor].id; 3027 3075 … … 4008 4056 4009 4057 4010 void do_cmd_self_knowledge(void *obj, const char *name)4058 static void do_cmd_self_knowledge(void *obj, const char *name) 4011 4059 { 4012 4060 /* display self knowledge we already know about. */ … … 4019 4067 static menu_item knowledge_actions[] = 4020 4068 { 4021 {{0, "Display artifact knowledge", (action_f)do_cmd_knowledge_artifacts, 0}, '1'},4022 {{0, "Display monster knowledge", (action_f)do_cmd_knowledge_monsters, 0}, '2'},4023 {{0, "Display ego item knowledge", (action_f)do_cmd_knowledge_ego_items, 0}, '3'},4024 {{0, "Display object knowledge", (action_f)do_cmd_knowledge_objects, 0}, '4'},4025 {{0, "Display feature knowledge", (action_f)do_cmd_knowledge_features, 0}, '5'},4069 {{0, "Display object knowledge", do_cmd_knowledge_objects, 0}, '1'}, 4070 {{0, "Display artifact knowledge", do_cmd_knowledge_artifacts, 0}, '2'}, 4071 {{0, "Display ego item knowledge", do_cmd_knowledge_ego_items, 0}, '3'}, 4072 {{0, "Display monster knowledge", do_cmd_knowledge_monsters, 0}, '4'}, 4073 {{0, "Display feature knowledge", do_cmd_knowledge_features, 0}, '5'}, 4026 4074 {{0, "Display self-knowledge", do_cmd_self_knowledge, 0}, '6'}, 4027 4075 }; … … 4036 4084 { 4037 4085 int cursor = 0; 4086 int i; 4038 4087 event_type c = EVENT_EMPTY; 4039 4088 region knowledge_region = { 0, 0, -1, 11 }; 4089 4090 /* Grey out menu items that won't display anything */ 4091 if (collect_known_artifacts(NULL, 0) > 0) 4092 knowledge_actions[1].flags = 0; 4093 else 4094 knowledge_actions[1].flags = MN_GREYED; 4095 4096 knowledge_actions[2].flags = MN_GREYED; 4097 for (i = 0; i < z_info->e_max; i++) 4098 { 4099 if (e_info[i].everseen || cheat_xtra) 4100 { 4101 knowledge_actions[2].flags = 0; 4102 break; 4103 } 4104 } 4105 4106 if (count_known_monsters() > 0) 4107 knowledge_actions[3].flags = 0; 4108 else 4109 knowledge_actions[3].flags = MN_GREYED; 4040 4110 4041 4111 screen_save(); trunk/src/store.c
r239 r254 2047 2047 const char *prompt = "Sell which item? "; 2048 2048 2049 /* Clear all current messages */ 2050 msg_flag = FALSE; 2051 prt("", 0, 0); 2052 2049 2053 if (store_current == STORE_HOME) 2050 2054 prompt = "Drop which item? "; … … 2572 2576 2573 2577 2574 /*** Set up state ***/2578 /*** Set up state ***/ 2575 2579 2576 2580 /* XXX Take note of the store number from the terrain feature */ … … 2579 2583 2580 2584 2581 /*** Display ***/2585 /*** Display ***/ 2582 2586 2583 2587 /* Save current screen (ie. dungeon) */ … … 2602 2606 2603 2607 /* Calculate the positions of things and redraw */ 2608 store_flags = STORE_INIT_CHANGE; 2604 2609 store_display_recalc(); 2605 store_flags = STORE_INIT_CHANGE;2606 2610 store_redraw(); 2607 2611 … … 2612 2616 while (!leave) 2613 2617 { 2614 /* Keep track of stock and number of rows*/2618 /* As many rows in the menus as there are items in the store */ 2615 2619 menu.count = st_ptr->stock_num; 2616 items_region.page_rows = scr_places_y[LOC_ITEMS_END] - scr_places_y[LOC_ITEMS_START] + 1;2617 2620 2618 2621 /* These two can't intersect! */ … … 2624 2627 cursor = menu.count - 1; 2625 2628 2626 if (menu.count >= menu.active.page_rows) 2627 items_region.page_rows += 1; 2629 items_region.page_rows = scr_places_y[LOC_MORE] - scr_places_y[LOC_ITEMS_START]; 2628 2630 2629 2631 /* Init the menu structure */ 2630 2632 menu_init2(&menu, find_menu_skin(MN_SCROLL), cur_menu, &items_region); 2631 2633 2632 if (menu.count > = menu.active.page_rows)2634 if (menu.count > items_region.page_rows) 2633 2635 menu.prompt = " -more-"; 2634 2636 else trunk/src/ui.h
r166 r254 230 230 MN_DISABLED = 0x0100000, /* Neither action nor selection is permitted */ 231 231 MN_GRAYED = 0x0200000, /* Row is displayed with CURS_UNKNOWN colors */ 232 MN_GREYED = 0x0200000, /* Row is displayed with CURS_UNKNOWN colors */ 232 233 MN_SELECTED = 0x0400000, /* Row is currently selected */ 233 234 MN_SELECTABLE = 0x0800000, /* Row is permitted to be selected */
