/** * Display monster recall modally and wait for a keypress. * * This is intended to be called when the main window is active (hence the * message flushing). * * \param race is the monster race we are describing. * \param lore is the known information about the monster race. */ void lore_show_interactive(const monster_race *race, const monster_lore *lore) { textblock *tb; assert(race && lore); event_signal(EVENT_MESSAGE_FLUSH); tb = textblock_new(); lore_description(tb, race, lore, FALSE); textui_textblock_show(tb, SCREEN_REGION, NULL); textblock_free(tb); }
/** * Display monster recall statically. * * This is intended to be called in a subwindow, since it clears the entire * window before drawing, and has no interactivity. * * \param race is the monster race we are describing. * \param lore is the known information about the monster race. */ void lore_show_subwindow(const monster_race *race, const monster_lore *lore) { int y; textblock *tb; assert(race && lore); /* Erase the window, since textui_textblock_place() only clears what it * needs */ for (y = 0; y < Term->hgt; y++) Term_erase(0, y, 255); tb = textblock_new(); lore_description(tb, race, lore, FALSE); textui_textblock_place(tb, SCREEN_REGION, NULL); textblock_free(tb); }
/** * Create a spoiler file for monsters (-SHAWN-) */ static void spoil_mon_info(const char *fname) { char buf[1024]; int i, n; u16b *who; int count = 0; textblock *tb = NULL; /* Open the file */ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname); fh = file_open(buf, MODE_WRITE, FTYPE_TEXT); if (!fh) { msg("Cannot create spoiler file."); return; } /* Dump the header */ tb = textblock_new(); textblock_append(tb, "Monster Spoilers for %s\n", buildid); textblock_append(tb, "------------------------------------------\n\n"); textblock_to_file(tb, fh, 0, 75); textblock_free(tb); tb = NULL; /* Allocate the "who" array */ who = mem_zalloc(z_info->r_max * sizeof(u16b)); /* Scan the monsters */ for (i = 1; i < z_info->r_max; i++) { struct monster_race *race = &r_info[i]; /* Use that monster */ if (race->name) who[count++] = (u16b)i; } sort(who, count, sizeof(*who), cmp_monsters); /* List all monsters in order. */ for (n = 0; n < count; n++) { int r_idx = who[n]; const struct monster_race *race = &r_info[r_idx]; const struct monster_lore *lore = &l_list[r_idx]; tb = textblock_new(); /* Line 1: prefix, name, color, and symbol */ if (rf_has(race->flags, RF_QUESTOR)) textblock_append(tb, "[Q] "); else if (rf_has(race->flags, RF_UNIQUE)) textblock_append(tb, "[U] "); else textblock_append(tb, "The "); /* As of 3.5, race->name and race->text are stored as UTF-8 strings; * there is no conversion from the source edit files. */ textblock_append_utf8(tb, race->name); textblock_append(tb, " ("); /* ---)--- */ textblock_append(tb, attr_to_text(race->d_attr)); textblock_append(tb, " '%c')\n", race->d_char); /* Line 2: number, level, rarity, speed, HP, AC, exp */ textblock_append(tb, "=== "); textblock_append(tb, "Num:%d ", r_idx); textblock_append(tb, "Lev:%d ", race->level); textblock_append(tb, "Rar:%d ", race->rarity); if (race->speed >= 110) textblock_append(tb, "Spd:+%d ", (race->speed - 110)); else textblock_append(tb, "Spd:-%d ", (110 - race->speed)); textblock_append(tb, "Hp:%d ", race->avg_hp); textblock_append(tb, "Ac:%d ", race->ac); textblock_append(tb, "Exp:%ld\n", (long)(race->mexp)); /* Normal description (with automatic line breaks) */ lore_description(tb, race, lore, true); textblock_append(tb, "\n"); textblock_to_file(tb, fh, 0, 75); textblock_free(tb); tb = NULL; } /* Free the "who" array */ mem_free(who); /* Check for errors */ if (!file_close(fh)) { msg("Cannot close spoiler file."); return; } msg("Successfully created a spoiler file."); }