put up nameable subset of discoveries list as a menu */
| 1128 | |
| 1129 | /* put up nameable subset of discoveries list as a menu */ |
| 1130 | void |
| 1131 | rename_disco(void) |
| 1132 | { |
| 1133 | int i, dis; |
| 1134 | int ct = 0, mn = 0, sl; |
| 1135 | char *s, oclass, prev_class; |
| 1136 | winid tmpwin; |
| 1137 | anything any; |
| 1138 | menu_item *selected = 0; |
| 1139 | int clr = NO_COLOR; |
| 1140 | char buf[BUFSZ]; |
| 1141 | |
| 1142 | any = cg.zeroany; |
| 1143 | tmpwin = create_nhwindow(NHW_MENU); |
| 1144 | start_menu(tmpwin, MENU_BEHAVE_STANDARD); |
| 1145 | |
| 1146 | /* |
| 1147 | * Skip the "unique objects" section (each will appear within its |
| 1148 | * regular class if it is nameable) and the artifacts section. |
| 1149 | * We assume that classes omitted from packorder aren't nameable |
| 1150 | * so we skip venom too. |
| 1151 | */ |
| 1152 | |
| 1153 | /* for each class, show discoveries in that class */ |
| 1154 | for (s = flags.inv_order; *s; s++) { |
| 1155 | oclass = *s; |
| 1156 | prev_class = oclass + 1; /* forced different from oclass */ |
| 1157 | for (i = svb.bases[(int) oclass]; |
| 1158 | i < NUM_OBJECTS && objects[i].oc_class == oclass; i++) { |
| 1159 | dis = svd.disco[i]; |
| 1160 | if (!dis || !interesting_to_discover(dis)) |
| 1161 | continue; |
| 1162 | ct++; |
| 1163 | if (!objtyp_is_callable(dis)) |
| 1164 | continue; |
| 1165 | mn++; |
| 1166 | |
| 1167 | if (oclass != prev_class) { |
| 1168 | any.a_int = 0; |
| 1169 | add_menu_heading(tmpwin, |
| 1170 | let_to_name(oclass, FALSE, FALSE)); |
| 1171 | prev_class = oclass; |
| 1172 | } |
| 1173 | any.a_int = dis; |
| 1174 | *buf = '\0'; |
| 1175 | disco_append_typename(buf, dis); |
| 1176 | add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, |
| 1177 | ATR_NONE, clr, buf, MENU_ITEMFLAGS_NONE); |
| 1178 | } |
| 1179 | } |
| 1180 | if (ct == 0) { |
| 1181 | You("haven't discovered anything yet..."); |
| 1182 | } else if (mn == 0) { |
| 1183 | pline("None of your discoveries can be assigned names..."); |
| 1184 | } else { |
| 1185 | end_menu(tmpwin, "Pick an object type to name"); |
| 1186 | dis = STRANGE_OBJECT; |
| 1187 | sl = select_menu(tmpwin, PICK_ONE, &selected); |
no test coverage detected