| 2316 | | #ifdef Old_version |
|---|
| 2317 | | static void handle_mons_list(game_event_type type, game_event_data *data, void *user) |
|---|
| 2318 | | { |
|---|
| 2319 | | xtra_win_data *xd = &xdata[3]; |
|---|
| 2320 | | int i; |
|---|
| 2321 | | int line = 1, x = 0; |
|---|
| 2322 | | int cur_x; |
|---|
| 2323 | | unsigned total_count = 0, disp_count = 0; |
|---|
| 2324 | | |
|---|
| 2325 | | byte attr; |
|---|
| 2326 | | |
|---|
| 2327 | | char *m_name; |
|---|
| 2328 | | char buf[80]; |
|---|
| 2329 | | char str[80]; |
|---|
| 2330 | | |
|---|
| 2331 | | monster_type *m_ptr; |
|---|
| 2332 | | monster_race *r_ptr; |
|---|
| 2333 | | |
|---|
| 2334 | | u16b *race_count; |
|---|
| 2335 | | |
|---|
| 2336 | | |
|---|
| 2337 | | if (!xd) return; |
|---|
| 2338 | | |
|---|
| 2339 | | |
|---|
| 2340 | | xd->buf = gtk_text_buffer_new(NULL); |
|---|
| 2341 | | gtk_text_view_set_buffer(GTK_TEXT_VIEW (xd->text_view), xd->buf); |
|---|
| 2342 | | |
|---|
| 2343 | | init_color_tags(xd); |
|---|
| 2344 | | |
|---|
| 2345 | | /* Allocate the array */ |
|---|
| 2346 | | race_count = C_ZNEW(z_info->r_max, u16b); |
|---|
| 2347 | | |
|---|
| 2348 | | /* Scan the monster list */ |
|---|
| 2349 | | for (i = 1; i < mon_max; i++) |
|---|
| 2350 | | { |
|---|
| 2351 | | m_ptr = &mon_list[i]; |
|---|
| 2352 | | |
|---|
| 2353 | | /* Only visible monsters */ |
|---|
| 2354 | | if (!m_ptr->ml) continue; |
|---|
| 2355 | | |
|---|
| 2356 | | /* Bump the count for this race, and the total count */ |
|---|
| 2357 | | race_count[m_ptr->r_idx]++; |
|---|
| 2358 | | total_count++; |
|---|
| 2359 | | } |
|---|
| 2360 | | |
|---|
| 2361 | | /* Note no visible monsters */ |
|---|
| 2362 | | if (!total_count) |
|---|
| 2363 | | { |
|---|
| 2364 | | strnfmt(str, sizeof(str), "You see no monsters."); |
|---|
| 2365 | | text_view_print(xd, str, TERM_SLATE); |
|---|
| 2366 | | |
|---|
| 2367 | | /* Free up memory */ |
|---|
| 2368 | | FREE(race_count); |
|---|
| 2369 | | |
|---|
| 2370 | | /* Done */ |
|---|
| 2371 | | return; |
|---|
| 2372 | | } |
|---|
| 2373 | | |
|---|
| 2374 | | strnfmt(str, sizeof(str), "You can see %d monster%s:", total_count, PLURAL(total_count)); |
|---|
| 2375 | | text_view_print(xd, str, 1); |
|---|
| 2376 | | |
|---|
| 2377 | | /* Go over */ |
|---|
| 2378 | | for (i = 1; i < z_info->r_max; i++) |
|---|
| 2379 | | { |
|---|
| 2380 | | /* No monsters of this race are visible */ |
|---|
| 2381 | | if (!race_count[i]) continue; |
|---|
| 2382 | | |
|---|
| 2383 | | /* Reset position */ |
|---|
| 2384 | | cur_x = x; |
|---|
| 2385 | | |
|---|
| 2386 | | /* Note that these have been displayed */ |
|---|
| 2387 | | disp_count += race_count[i]; |
|---|
| 2388 | | |
|---|
| 2389 | | /* Get monster race and name */ |
|---|
| 2390 | | r_ptr = &r_info[i]; |
|---|
| 2391 | | m_name = r_name + r_ptr->name; |
|---|
| 2392 | | |
|---|
| 2393 | | /* Display uniques in a special colour */ |
|---|
| 2394 | | if (r_ptr->flags[0] & RF1_UNIQUE) |
|---|
| 2395 | | attr = TERM_VIOLET; |
|---|
| 2396 | | else |
|---|
| 2397 | | attr = TERM_WHITE; |
|---|
| 2398 | | |
|---|
| 2399 | | /* Build the monster name */ |
|---|
| 2400 | | if (race_count[i] == 1) |
|---|
| 2401 | | my_strcpy(buf, m_name, sizeof(buf)); |
|---|
| 2402 | | else |
|---|
| 2403 | | strnfmt(buf, sizeof(buf), "%s (x%d) ", m_name, race_count[i]); |
|---|
| 2404 | | |
|---|
| 2405 | | text_view_print(xd, buf, attr); |
|---|
| 2406 | | line++; |
|---|
| 2407 | | } |
|---|
| 2408 | | |
|---|
| 2409 | | /* Free the race counters */ |
|---|
| 2410 | | FREE(race_count); |
|---|
| 2411 | | } |
|---|
| 2412 | | #endif |
|---|