Angband
Functions
ui-mon-list.c File Reference

Monster list UI. More...

#include "mon-desc.h"
#include "mon-list.h"
#include "mon-lore.h"
#include "mon-util.h"
#include "player-timed.h"
#include "ui-output.h"
#include "ui-prefs.h"
#include "ui-term.h"

Functions

static void monster_list_format_section (const monster_list_t *list, textblock *tb, monster_list_section_t section, int lines_to_display, int max_width, const char *prefix, bool show_others, size_t *max_width_result)
 Format a section of the monster list: a header followed by monster list entry rows. More...
 
static bool monster_list_format_special (const monster_list_t *list, textblock *tb, int max_lines, int max_width, size_t *max_height_result, size_t *max_width_result)
 Allow the standard list formatted to be bypassed for special cases. More...
 
static void monster_list_format_textblock (const monster_list_t *list, textblock *tb, int max_lines, int max_width, size_t *max_height_result, size_t *max_width_result)
 Format the entire monster list with the given parameters. More...
 
void monster_list_get_glyphs (monster_list_t *list)
 Get correct monster glyphs. More...
 
void monster_list_show_subwindow (int height, int width)
 Display the monster list statically. More...
 
void monster_list_show_interactive (int height, int width)
 Display the monster list interactively. More...
 
void monster_list_force_subwindow_update (void)
 Force an update to the monster list subwindow. More...
 

Detailed Description

Monster list UI.

Copyright (c) 1997-2007 Ben Harrison, James E. Wilson, Robert A. Koeneke Copyright (c) 2013 Ben Semmler

This work is free software; you can redistribute it and/or modify it under the terms of either:

a) the GNU General Public License as published by the Free Software Foundation, version 2, or

b) the "Angband licence": This software may be copied and distributed for educational, research, and not for profit purposes provided that this copyright and statement are included in all such copies. Other copyrights may also apply.

Function Documentation

◆ monster_list_force_subwindow_update()

void monster_list_force_subwindow_update ( void  )

Force an update to the monster list subwindow.

There are conditions that monster_list_reset() can't catch, so we set the turn an invalid value to force the list to update.

References monster_list_s::creation_turn, and monster_list_shared_instance().

Referenced by new_level_display_update().

◆ monster_list_format_section()

static void monster_list_format_section ( const monster_list_t list,
textblock tb,
monster_list_section_t  section,
int  lines_to_display,
int  max_width,
const char *  prefix,
bool  show_others,
size_t *  max_width_result 
)
static

Format a section of the monster list: a header followed by monster list entry rows.

This function will process each entry for the given section. It will display:

  • monster char;
  • number of monsters;
  • monster name (truncated, if needed to fit the line);
  • whether or not the monster is asleep (and how many if in a group);
  • monster distance from the player (aligned to the right side of the list). By passing in a NULL textblock, the maximum line width of the section can be found.
Parameters
listis the monster list to format.
tbis the textblock to produce or NULL if only the dimensions need to be calculated.
sectionis the section of the monster list to format.
lines_to_displayare the number of entries to display (not including the header).
max_widthis the maximum line width.
prefixis the beginning of the header; the remainder is appended with the number of monsters.
show_othersis used to append "other monsters" to the header, after the number of monsters.
max_width_resultis returned with the width needed to format the list without truncation.

References abs, monster_list_entry_s::asleep, monster_list_entry_s::attr, monster_list_entry_s::count, monster_list_s::distinct_entries, monster_list_entry_s::dx, monster_list_entry_s::dy, monster_list_s::entries, get_mon_name(), index, location, MAX, MIN, monster_list_entry_line_color(), monster_x_char, my_strcat(), NULL, PLURAL, monster_list_entry_s::race, monster_race::ridx, strnfmt(), textblock_append(), textblock_append_c(), textblock_append_pict(), tile_height, tile_width, monster_list_s::total_entries, monster_list_s::total_monsters, utf8_clipto(), and utf8_strlen().

Referenced by monster_list_format_textblock().

◆ monster_list_format_special()

static bool monster_list_format_special ( const monster_list_t list,
textblock tb,
int  max_lines,
int  max_width,
size_t *  max_height_result,
size_t *  max_width_result 
)
static

Allow the standard list formatted to be bypassed for special cases.

Returning true will bypass any other formatteding in monster_list_format_textblock().

Parameters
listis the monster list to format.
tbis the textblock to produce or NULL if only the dimensions need to be calculated.
max_linesis the maximum number of lines that can be displayed.
max_widthis the maximum line width that can be displayed.
max_height_resultis returned with the number of lines needed to format the list without truncation.
max_width_resultis returned with the width needed to format the list without truncation.
Returns
true if further formatting should be bypassed.

References COLOUR_ORANGE, NULL, textblock_append_c(), and player::timed.

Referenced by monster_list_format_textblock().

◆ monster_list_format_textblock()

static void monster_list_format_textblock ( const monster_list_t list,
textblock tb,
int  max_lines,
int  max_width,
size_t *  max_height_result,
size_t *  max_width_result 
)
static

Format the entire monster list with the given parameters.

This function can be used to calculate the preferred dimensions for the list by passing in a NULL textblock. The LOS section of the list will always be shown, while the other section will be added conditionally. Also, this function calls monster_list_format_special() first; if that function returns true, it will bypass normal list formatting.

Parameters
listis the monster list to format.
tbis the textblock to produce or NULL if only the dimensions need to be calculated.
max_linesis the maximum number of lines that can be displayed.
max_widthis the maximum line width that can be displayed.
max_height_resultis returned with the number of lines needed to format the list without truncation.
max_width_resultis returned with the width needed to format the list without truncation.

References abs, monster_list_s::entries, MAX, monster_list_format_section(), monster_list_format_special(), MONSTER_LIST_SECTION_ESP, MONSTER_LIST_SECTION_LOS, NULL, textblock_append(), monster_list_s::total_entries, and monster_list_s::total_monsters.

Referenced by monster_list_show_interactive(), and monster_list_show_subwindow().

◆ monster_list_get_glyphs()

void monster_list_get_glyphs ( monster_list_t list)

◆ monster_list_show_interactive()

void monster_list_show_interactive ( int  height,
int  width 
)

Display the monster list interactively.

This will dynamically size the list for the best appearance. This should only be used in the main term.

Parameters
heightis the height limit for the list.
widthis the width limit for the list.

References region::col, max_height, max_width, MIN, monster_list_collect(), monster_list_format_textblock(), monster_list_free(), monster_list_get_glyphs(), monster_list_new(), monster_list_sort(), monster_list_standard_compare(), NULL, region::page_rows, region_erase_bordered(), region::row, textblock_free(), textblock_new(), textui_textblock_show(), and region::width.

Referenced by do_cmd_monlist().

◆ monster_list_show_subwindow()

void monster_list_show_subwindow ( int  height,
int  width 
)

Display the monster list statically.

This will force the list to be displayed to the provided dimensions. Contents will be adjusted accordingly.

In order to support more efficient monster flicker animations, this function uses a shared list object so that it's not constantly allocating and freeing the list.

Parameters
heightis the height of the list.
widthis the width of the list.

References cave, cave_monster(), cave_monster_max(), monster_list_s::creation_turn, i, mflag_has, monster_list_collect(), monster_list_format_textblock(), monster_list_get_glyphs(), monster_list_reset(), monster_list_shared_instance(), monster_list_sort(), monster_list_standard_compare(), NULL, SCREEN_REGION, textblock_free(), textblock_new(), and textui_textblock_place().

Referenced by update_monlist_subwindow().