Angband
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
ui-entry-renderers.c File Reference

Define backend handling for some parts of the second character screen. More...

#include "ui-entry-init.h"
#include "ui-entry-renderers.h"
#include "ui-term.h"
#include "z-color.h"
#include "z-util.h"
#include "z-virt.h"
#include "list-ui-entry-renderers.h"

Data Structures

struct  backend_info
 
struct  renderer_info
 

Macros

#define MAX_PALETTE   (64)
 
#define MAX_UNITS_LABEL   (24)
 
#define F(x)   renderer_##x
 
#define FWIDTH(x)   valuewidth_##x
 
#define UI_ENTRY_RENDERER(x, co, c, lc, s, n, sg)   { F(x), FWIDTH(x), co, c, lc, s, n, UI_ENTRY_##sg},
 
#define UI_ENTRY_RENDERER(x, co, c, lc, s, n, sg)   #x,
 

Typedefs

typedef void(* renderer_func) (const wchar_t *label, int nlabel, const int *vals, const int *auxvals, int n, const struct ui_entry_details *details, const struct renderer_info *info)
 
typedef int(* valuewidth_func) (const struct renderer_info *info)
 

Enumerations

enum  { UI_ENTRY_NO_SIGN, UI_ENTRY_ALWAYS_SIGN, UI_ENTRY_NEGATIVE_SIGN, UI_ENTRY_SIGN_DEFAULT = INT_MIN }
 

Functions

static void format_int (int i, bool add_one, wchar_t zero, wchar_t overflow, bool nonneg, bool use_sign, int nbuf, wchar_t *buf)
 
static void show_combined_generic (const struct renderer_info *info, const struct ui_entry_details *details, int vcombined, int acombined)
 
static void renderer_COMPACT_RESIST_RENDERER_WITH_COMBINED_AUX (const wchar_t *label, int nlabel, const int *vals, const int *auxvals, int n, const struct ui_entry_details *details, const struct renderer_info *info)
 
static int valuewidth_COMPACT_RESIST_RENDERER_WITH_COMBINED_AUX (const struct renderer_info *info)
 
static void renderer_COMPACT_FLAG_RENDERER_WITH_COMBINED_AUX (const wchar_t *label, int nlabel, const int *vals, const int *auxvals, int n, const struct ui_entry_details *details, const struct renderer_info *info)
 
static int valuewidth_COMPACT_FLAG_RENDERER_WITH_COMBINED_AUX (const struct renderer_info *info)
 
static void renderer_NUMERIC_AS_SIGN_RENDERER_WITH_COMBINED_AUX (const wchar_t *label, int nlabel, const int *vals, const int *auxvals, int n, const struct ui_entry_details *details, const struct renderer_info *info)
 
static int valuewidth_NUMERIC_AS_SIGN_RENDERER_WITH_COMBINED_AUX (const struct renderer_info *info)
 
static void renderer_NUMERIC_RENDERER_WITH_COMBINED_AUX (const wchar_t *label, int nlabel, const int *vals, const int *auxvals, int n, const struct ui_entry_details *details, const struct renderer_info *info)
 
static int valuewidth_NUMERIC_RENDERER_WITH_COMBINED_AUX (const struct renderer_info *info)
 
static void renderer_NUMERIC_RENDERER_WITH_BOOL_AUX (const wchar_t *label, int nlabel, const int *vals, const int *auxvals, int n, const struct ui_entry_details *details, const struct renderer_info *info)
 
static int valuewidth_NUMERIC_RENDERER_WITH_BOOL_AUX (const struct renderer_info *info)
 
static char * convert_attrs_to_chars (const int *attr, int n)
 
static void convert_chars_to_attrs (const char *colors, int n, int *attr)
 
int ui_entry_renderer_get_min_index (void)
 Return the first valid index accepted by ui_entry_renderer_apply() and the other functions expecting a renderer index. More...
 
int ui_entry_renderer_get_index_limit (void)
 Return the upper bound for indices accepted by ui_entry_renderer_apply() and the other functions expecting a renderer index. More...
 
const char * ui_entry_renderer_get_name (int ind)
 Returns the name for the renderer as configured in ui_entry_renderers.txt. More...
 
int ui_entry_renderer_lookup (const char *name)
 Look up a renderer by name. More...
 
int ui_entry_renderer_query_value_width (int ind)
 Query a renderer for the number of characters used to draw a value. More...
 
int ui_entry_renderer_query_combined_width (int ind)
 Query a renderer for the number of characters used to draw the combined value. More...
 
int ui_entry_renderer_query_combiner (int ind)
 Returns the combiner index, suitable as the first argument to ui_entry_combiner_get_funcs(), for the given user interface renderer. More...
 
void ui_entry_renderer_apply (int ind, const wchar_t *label, int nlabel, const int *vals, const int *auxvals, int n, const struct ui_entry_details *details)
 Use a renderer to draw a set of values and, optionally, their label and combined value. More...
 
int ui_entry_renderer_customize (int ind, const char *colors, const char *label_colors, const char *symbols)
 
char * ui_entry_renderer_get_colors (int ind)
 
char * ui_entry_renderer_get_label_colors (int ind)
 
char * ui_entry_renderer_get_symbols (int ind)
 
static int convert_vanilla_res_level (int i)
 Result is 0 (no resistance)), 1 (resistance), 2 (vulnerable), 3 (immune), 4 (unknown), 5 (not present). More...
 
static int lookup_backend_by_name (const char *name)
 
static void augment_colors (const char *colors, int **attr, int *nattr)
 
static void augment_symbols (const char *symbols, wchar_t **s, int *n)
 
static enum parser_error parse_renderer_name (struct parser *p)
 
static enum parser_error parse_renderer_code (struct parser *p)
 
static enum parser_error parse_renderer_combine (struct parser *p)
 
static enum parser_error parse_renderer_colors (struct parser *p)
 
static enum parser_error parse_renderer_labelcolors (struct parser *p)
 
static enum parser_error parse_renderer_symbols (struct parser *p)
 
static enum parser_error parse_renderer_combined_renderer (struct parser *p)
 
static enum parser_error parse_renderer_ndigit (struct parser *p)
 
static enum parser_error parse_renderer_sign (struct parser *p)
 
static enum parser_error parse_renderer_units (struct parser *p)
 
static struct parserinit_parse_ui_entry_renderer (void)
 
static errr run_parse_ui_entry_renderer (struct parser *p)
 
static errr finish_parse_ui_entry_renderer (struct parser *p)
 
static void cleanup_parse_ui_entry_renderer (void)
 

Variables

static const struct backend_info backends []
 
static const char * backend_names []
 
static int renderer_count = 0
 
static int renderer_allocated = 0
 
static struct renderer_inforenderers = 0
 
struct file_parser ui_entry_renderer_parser
 

Detailed Description

Define backend handling for some parts of the second character screen.

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.

Macro Definition Documentation

◆ F

#define F (   x)    renderer_##x

◆ FWIDTH

#define FWIDTH (   x)    valuewidth_##x

◆ MAX_PALETTE

#define MAX_PALETTE   (64)

◆ MAX_UNITS_LABEL

#define MAX_UNITS_LABEL   (24)

Referenced by parse_renderer_units().

◆ UI_ENTRY_RENDERER [1/2]

#define UI_ENTRY_RENDERER (   x,
  co,
  c,
  lc,
  s,
  n,
  sg 
)    { F(x), FWIDTH(x), co, c, lc, s, n, UI_ENTRY_##sg},

◆ UI_ENTRY_RENDERER [2/2]

#define UI_ENTRY_RENDERER (   x,
  co,
  c,
  lc,
  s,
  n,
  sg 
)    #x,

Typedef Documentation

◆ renderer_func

typedef void(* renderer_func) (const wchar_t *label, int nlabel, const int *vals, const int *auxvals, int n, const struct ui_entry_details *details, const struct renderer_info *info)

◆ valuewidth_func

typedef int(* valuewidth_func) (const struct renderer_info *info)

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
UI_ENTRY_NO_SIGN 
UI_ENTRY_ALWAYS_SIGN 
UI_ENTRY_NEGATIVE_SIGN 
UI_ENTRY_SIGN_DEFAULT 

Function Documentation

◆ augment_colors()

static void augment_colors ( const char *  colors,
int **  attr,
int nattr 
)
static

◆ augment_symbols()

static void augment_symbols ( const char *  symbols,
wchar_t **  s,
int n 
)
static

◆ cleanup_parse_ui_entry_renderer()

static void cleanup_parse_ui_entry_renderer ( void  )
static

◆ convert_attrs_to_chars()

static char * convert_attrs_to_chars ( const int attr,
int  n 
)
static

◆ convert_chars_to_attrs()

static void convert_chars_to_attrs ( const char *  colors,
int  n,
int attr 
)
static

◆ convert_vanilla_res_level()

static int convert_vanilla_res_level ( int  i)
static

Result is 0 (no resistance)), 1 (resistance), 2 (vulnerable), 3 (immune), 4 (unknown), 5 (not present).

References UI_ENTRY_UNKNOWN_VALUE, and UI_ENTRY_VALUE_NOT_PRESENT.

Referenced by renderer_COMPACT_RESIST_RENDERER_WITH_COMBINED_AUX().

◆ finish_parse_ui_entry_renderer()

static errr finish_parse_ui_entry_renderer ( struct parser p)
static

◆ format_int()

static void format_int ( int  i,
bool  add_one,
wchar_t  zero,
wchar_t  overflow,
bool  nonneg,
bool  use_sign,
int  nbuf,
wchar_t *  buf 
)
static

◆ init_parse_ui_entry_renderer()

static struct parser* init_parse_ui_entry_renderer ( void  )
static

◆ lookup_backend_by_name()

static int lookup_backend_by_name ( const char *  name)
static

References backend_names, i, N_ELEMENTS, and streq.

Referenced by parse_renderer_code().

◆ parse_renderer_code()

static enum parser_error parse_renderer_code ( struct parser p)
static

◆ parse_renderer_colors()

static enum parser_error parse_renderer_colors ( struct parser p)
static

◆ parse_renderer_combine()

static enum parser_error parse_renderer_combine ( struct parser p)
static

◆ parse_renderer_combined_renderer()

static enum parser_error parse_renderer_combined_renderer ( struct parser p)
static

◆ parse_renderer_labelcolors()

static enum parser_error parse_renderer_labelcolors ( struct parser p)
static

◆ parse_renderer_name()

static enum parser_error parse_renderer_name ( struct parser p)
static

◆ parse_renderer_ndigit()

static enum parser_error parse_renderer_ndigit ( struct parser p)
static

◆ parse_renderer_sign()

static enum parser_error parse_renderer_sign ( struct parser p)
static

◆ parse_renderer_symbols()

static enum parser_error parse_renderer_symbols ( struct parser p)
static

◆ parse_renderer_units()

static enum parser_error parse_renderer_units ( struct parser p)
static

◆ renderer_COMPACT_FLAG_RENDERER_WITH_COMBINED_AUX()

static void renderer_COMPACT_FLAG_RENDERER_WITH_COMBINED_AUX ( const wchar_t *  label,
int  nlabel,
const int vals,
const int auxvals,
int  n,
const struct ui_entry_details details,
const struct renderer_info info 
)
static

◆ renderer_COMPACT_RESIST_RENDERER_WITH_COMBINED_AUX()

static void renderer_COMPACT_RESIST_RENDERER_WITH_COMBINED_AUX ( const wchar_t *  label,
int  nlabel,
const int vals,
const int auxvals,
int  n,
const struct ui_entry_details details,
const struct renderer_info info 
)
static

◆ renderer_NUMERIC_AS_SIGN_RENDERER_WITH_COMBINED_AUX()

static void renderer_NUMERIC_AS_SIGN_RENDERER_WITH_COMBINED_AUX ( const wchar_t *  label,
int  nlabel,
const int vals,
const int auxvals,
int  n,
const struct ui_entry_details details,
const struct renderer_info info 
)
static

◆ renderer_NUMERIC_RENDERER_WITH_BOOL_AUX()

static void renderer_NUMERIC_RENDERER_WITH_BOOL_AUX ( const wchar_t *  label,
int  nlabel,
const int vals,
const int auxvals,
int  n,
const struct ui_entry_details details,
const struct renderer_info info 
)
static

◆ renderer_NUMERIC_RENDERER_WITH_COMBINED_AUX()

static void renderer_NUMERIC_RENDERER_WITH_COMBINED_AUX ( const wchar_t *  label,
int  nlabel,
const int vals,
const int auxvals,
int  n,
const struct ui_entry_details details,
const struct renderer_info info 
)
static

◆ run_parse_ui_entry_renderer()

static errr run_parse_ui_entry_renderer ( struct parser p)
static

References parse_file().

◆ show_combined_generic()

static void show_combined_generic ( const struct renderer_info info,
const struct ui_entry_details details,
int  vcombined,
int  acombined 
)
static

◆ ui_entry_renderer_apply()

void ui_entry_renderer_apply ( int  ind,
const wchar_t *  label,
int  nlabel,
const int vals,
const int auxvals,
int  n,
const struct ui_entry_details details 
)

Use a renderer to draw a set of values and, optionally, their label and combined value.

ind is the index for the renderer; use ui_entry_renderer_lookup to get it. label and nlabel specify the label to draw. If nlabel is 0, no label will be drawn. vals, auxvals, and n set the values to draw. vals and auxvals each refer to n values. details controls certain aspects of the rendering including positions and the handling of the combined value. The comments for it in ui-entry-renderers.h describe it in more detail.

References renderer_info::backend, backend_info::func, and renderer_count.

Referenced by display_page(), display_player_sust_info(), display_resistance_panel(), and show_combined_generic().

◆ ui_entry_renderer_customize()

int ui_entry_renderer_customize ( int  ind,
const char *  colors,
const char *  label_colors,
const char *  symbols 
)

◆ ui_entry_renderer_get_colors()

char* ui_entry_renderer_get_colors ( int  ind)

◆ ui_entry_renderer_get_index_limit()

int ui_entry_renderer_get_index_limit ( void  )

Return the upper bound for indices accepted by ui_entry_renderer_apply() and the other functions expecting a renderer index.

Any index whose value is greater than or equal to ui_entry_get_min_index() and less than ui_entry_get_index_limit() is valid.

References renderer_count.

Referenced by dump_ui_entry_renderers().

◆ ui_entry_renderer_get_label_colors()

char* ui_entry_renderer_get_label_colors ( int  ind)

◆ ui_entry_renderer_get_min_index()

int ui_entry_renderer_get_min_index ( void  )

Return the first valid index accepted by ui_entry_renderer_apply() and the other functions expecting a renderer index.

Any index whose value is greater than or equal to ui_entry_get_min_index() and less than ui_entry_get_index_limit() is valid.

Referenced by dump_ui_entry_renderers().

◆ ui_entry_renderer_get_name()

const char* ui_entry_renderer_get_name ( int  ind)

Returns the name for the renderer as configured in ui_entry_renderers.txt.

The returned value will be NULL if ind is out of bounds.

References renderer_info::name, and renderer_count.

Referenced by dump_ui_entry_renderers().

◆ ui_entry_renderer_get_symbols()

char* ui_entry_renderer_get_symbols ( int  ind)

◆ ui_entry_renderer_lookup()

int ui_entry_renderer_lookup ( const char *  name)

Look up a renderer by name.

If the name is not one of those configured in ui_entry_renderers.txt, returns zero. Otherwise returns the index for the renderer.

References i, renderer_count, and streq.

Referenced by finish_parse_ui_entry_renderer(), parse_entry_renderer(), parse_prefs_entry_renderer(), and parse_renderer_name().

◆ ui_entry_renderer_query_combined_width()

int ui_entry_renderer_query_combined_width ( int  ind)

Query a renderer for the number of characters used to draw the combined value.

ind is the index for the renderer; use ui_entry_renderer_lookup to get it. Will return -1 if the renderer is not valid or has not been attached to another renderer to show the combined value.

References renderer_info::backend, renderer_info::combined_renderer_index, renderer_count, and backend_info::vw_func.

◆ ui_entry_renderer_query_combiner()

int ui_entry_renderer_query_combiner ( int  ind)

Returns the combiner index, suitable as the first argument to ui_entry_combiner_get_funcs(), for the given user interface renderer.

Returns zero if the renderer is not valid or has an invalid combiner.

References renderer_info::combiner_index, and renderer_count.

Referenced by compute_player_and_equipment_values().

◆ ui_entry_renderer_query_value_width()

int ui_entry_renderer_query_value_width ( int  ind)

Query a renderer for the number of characters used to draw a value.

ind is the index for the renderer; use ui_entry_renderer_lookup to get it. Will return -1 if the renderer is not valid or does not have an implemented backend.

References renderer_info::backend, renderer_count, and backend_info::vw_func.

◆ valuewidth_COMPACT_FLAG_RENDERER_WITH_COMBINED_AUX()

static int valuewidth_COMPACT_FLAG_RENDERER_WITH_COMBINED_AUX ( const struct renderer_info info)
static

◆ valuewidth_COMPACT_RESIST_RENDERER_WITH_COMBINED_AUX()

static int valuewidth_COMPACT_RESIST_RENDERER_WITH_COMBINED_AUX ( const struct renderer_info info)
static

◆ valuewidth_NUMERIC_AS_SIGN_RENDERER_WITH_COMBINED_AUX()

static int valuewidth_NUMERIC_AS_SIGN_RENDERER_WITH_COMBINED_AUX ( const struct renderer_info info)
static

◆ valuewidth_NUMERIC_RENDERER_WITH_BOOL_AUX()

static int valuewidth_NUMERIC_RENDERER_WITH_BOOL_AUX ( const struct renderer_info info)
static

◆ valuewidth_NUMERIC_RENDERER_WITH_COMBINED_AUX()

static int valuewidth_NUMERIC_RENDERER_WITH_COMBINED_AUX ( const struct renderer_info info)
static

Variable Documentation

◆ backend_names

const char* backend_names[]
static
Initial value:
= {
#define UI_ENTRY_RENDERER(x, co, c, lc, s, n, sg)
NULL
}

Referenced by lookup_backend_by_name().

◆ backends

const struct backend_info backends[]
static
Initial value:
=
{
#define F(x)
#define FWIDTH(x)
#define UI_ENTRY_RENDERER(x, co, c, lc, s, n, sg)
}

◆ renderer_allocated

int renderer_allocated = 0
static

◆ renderer_count

int renderer_count = 0
static

◆ renderers

struct renderer_info* renderers = 0
static

◆ ui_entry_renderer_parser

struct file_parser ui_entry_renderer_parser
Initial value:
= {
"ui_entry_renderer",
}
static errr run_parse_ui_entry_renderer(struct parser *p)
Definition: ui-entry-renderers.c:1462
static void cleanup_parse_ui_entry_renderer(void)
Definition: ui-entry-renderers.c:1517
static struct parser * init_parse_ui_entry_renderer(void)
Definition: ui-entry-renderers.c:1442
static errr finish_parse_ui_entry_renderer(struct parser *p)
Definition: ui-entry-renderers.c:1468