Angband
Functions
ui-obj-list.c File Reference

Object list UI. More...

#include "angband.h"
#include "init.h"
#include "obj-list.h"
#include "obj-util.h"
#include "ui-obj.h"
#include "ui-obj-list.h"
#include "ui-output.h"
#include "z-textblock.h"

Functions

static void object_list_format_section (const object_list_t *list, textblock *tb, int lines_to_display, int max_width, const char *prefix, size_t *max_width_result)
 Format a section of the object list: a header followed by object list entry rows.
static bool object_list_format_special (const object_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.
static void object_list_format_textblock (const object_list_t *list, textblock *tb, int max_lines, int max_width, size_t *max_height_result, size_t *max_width_result)
 Format the entire object list with the given parameters.
void object_list_show_subwindow (int height, int width)
 Display the object list statically.
void object_list_show_interactive (int height, int width)
 Display the object list interactively.

Detailed Description

Object 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

static void object_list_format_section ( const object_list_t list,
textblock tb,
int  lines_to_display,
int  max_width,
const char *  prefix,
size_t *  max_width_result 
)
static

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

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

  • object char;
  • number of objects;
  • object name (truncated, if needed to fit the line);
  • object 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 object list to format.
tbis the textblock to produce or NULL if only the dimensions need to be calculated.
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 objects.
max_width_resultis returned with the width needed to format the list without truncation.

References abs, COLOUR_RED, object_list_entry_s::count, object_list_entry_s::dx, object_list_entry_s::dy, object_list_s::entries, is_unknown(), object::kind, location, MAX, object_list_entry_s::object, object_kind_attr(), object_kind_char(), object_list_entry_line_attribute(), object_list_format_name(), PLURAL, strnfmt(), text_mbstowcs(), textblock_append(), textblock_append_c(), textblock_append_pict(), tile_height, tile_width, and object_list_s::total_entries.

Referenced by object_list_format_textblock().

static bool object_list_format_special ( const object_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 object_list_format_textblock().

Parameters
listis the object 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 FALSE.

Referenced by object_list_format_textblock().

static void object_list_format_textblock ( const object_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 object list with the given parameters.

This function can be used to calculate the preferred dimensions for the list by passing in a NULL textblock. This function calls object_list_format_special() first; if that function returns TRUE, it will bypass normal list formatting.

Parameters
listis the object 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 object_list_s::entries, MAX, object_list_format_section(), object_list_format_special(), and object_list_s::total_entries.

Referenced by object_list_show_interactive(), and object_list_show_subwindow().

void object_list_show_interactive ( int  height,
int  width 
)

Display the object 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, MIN, object_list_collect(), object_list_format_textblock(), object_list_free(), object_list_new(), object_list_sort(), object_list_standard_compare(), region::page_rows, region_erase_bordered(), region::row, textblock_free(), textblock_new(), textui_textblock_show(), and region::width.

Referenced by do_cmd_itemlist().

void object_list_show_subwindow ( int  height,
int  width 
)

Display the object list statically.

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

In order to be more efficient, 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 object_list_collect(), object_list_format_textblock(), object_list_reset(), object_list_shared_instance(), object_list_sort(), object_list_standard_compare(), SCREEN_REGION, textblock_free(), textblock_new(), and textui_textblock_place().

Referenced by update_itemlist_subwindow().