Angband
Functions | Variables
ui-output.c File Reference

Putting text on the screen, screen saving and loading, panel handling. More...

#include "angband.h"
#include "cave.h"
#include "player-calcs.h"
#include "ui-input.h"
#include "ui-output.h"
#include "z-textblock.h"

Functions

region region_calculate (region loc)
 

Regions

More...
 
void region_erase_bordered (const region *loc)
 Erase the contents of a region + 1 char each way. More...
 
void region_erase (const region *loc)
 Erase the contents of a region. More...
 
bool region_inside (const region *loc, const ui_event *key)
 Check whether a (mouse) event is inside a region. More...
 
static void display_area (const wchar_t *text, const byte *attrs, size_t *line_starts, size_t *line_lengths, size_t n_lines, region area, size_t line_from)
 

Text display

More...
 
void textui_textblock_place (textblock *tb, region orig_area, const char *header)
 Plonk a textblock on the screen in a certain bounding box. More...
 
void textui_textblock_show (textblock *tb, region orig_area, const char *header)
 Show a textblock interactively. More...
 
void text_out_to_screen (byte a, const char *str)
 

text_out hook for screen display

More...
 
void c_put_str (byte attr, const char *str, int row, int col)
 

Simple text display

More...
 
void put_str (const char *str, int row, int col)
 As above, but in white. More...
 
void c_prt (byte attr, const char *str, int row, int col)
 Display a string on the screen using an attribute, and clear to the end of the line. More...
 
void prt (const char *str, int row, int col)
 As above, but in white. More...
 
void screen_save (void)
 Save the screen, and increase the "icky" depth. More...
 
void screen_load (void)
 Load the screen, and decrease the "icky" depth. More...
 
bool textui_map_is_visible (void)
 
void window_make (int origin_x, int origin_y, int end_x, int end_y)
 

Miscellaneous things

More...
 
bool panel_should_modify (term *t, int wy, int wx)
 
bool modify_panel (term *t, int wy, int wx)
 Modify the current panel to the given coordinates, adjusting only to ensure the coordinates are legal, and return true if anything done. More...
 
static void verify_panel_int (bool centered)
 
bool change_panel (int dir)
 Change the current panel to the panel lying in the given direction. More...
 
void verify_panel (void)
 Verify the current panel (relative to the player location). More...
 
void center_panel (void)
 
void textui_get_panel (int *min_y, int *min_x, int *max_y, int *max_x)
 
bool textui_panel_contains (unsigned int y, unsigned int x)
 

Variables

s16b screen_save_depth
 

Screen loading/saving

More...
 

Detailed Description

Putting text on the screen, screen saving and loading, panel handling.

Copyright (c) 2007 Pete Mack and others.

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

void c_prt ( byte  attr,
const char *  str,
int  row,
int  col 
)
void c_put_str ( byte  attr,
const char *  str,
int  row,
int  col 
)
void center_panel ( void  )

References verify_panel_int().

Referenced by do_cmd_center_map().

bool change_panel ( int  dir)

Change the current panel to the panel lying in the given direction.

Return true if the panel was changed.

References angband_term, ANGBAND_TERM_MAX, ddx, ddy, term::hgt, modify_panel(), term::offset_x, term::offset_y, PW_MAPS, SCREEN_HGT, SCREEN_WID, term::wid, and window_flag.

Referenced by do_cmd_locate(), and target_set_interactive().

static void display_area ( const wchar_t *  text,
const byte attrs,
size_t *  line_starts,
size_t *  line_lengths,
size_t  n_lines,
region  area,
size_t  line_from 
)
static


Text display

These functions are designed to display large blocks of text on the screen all at once. They are the ui-term specific layer on top of the z-textblock.c functions. Utility function

References region::col, i, MIN, region::page_rows, region::row, Term_erase(), Term_putch(), and region::width.

Referenced by textui_textblock_place(), and textui_textblock_show().

bool modify_panel ( term t,
int  wy,
int  wx 
)

Modify the current panel to the given coordinates, adjusting only to ensure the coordinates are legal, and return true if anything done.

The town should never be scrolled around.

Note that monsters are no longer affected in any way by panel changes.

As a total hack, whenever the current panel changes, we assume that the "overhead view" window should be updated.

References cave, chunk::height, term::offset_x, term::offset_y, panel_should_modify(), PR_MAP, player_upkeep::redraw, redraw_stuff(), SCREEN_HGT, SCREEN_WID, tile_height, tile_width, player::upkeep, and chunk::width.

Referenced by adjust_panel_help(), change_panel(), target_set_interactive(), and verify_panel_int().

bool panel_should_modify ( term t,
int  wy,
int  wx 
)
void prt ( const char *  str,
int  row,
int  col 
)

As above, but in white.

References c_prt(), and COLOUR_WHITE.

Referenced by close_game(), colors_modify(), context_menu_cave(), context_menu_command(), context_menu_object(), context_menu_player(), context_menu_player_2(), context_menu_player_display_floor(), context_menu_store(), context_menu_store_item(), curse_menu(), death_info(), display_glyphs(), display_knowledge(), display_scores_aux(), do_cmd_delay(), do_cmd_hp_warn(), do_cmd_keylog(), do_cmd_lazymove_delay(), do_cmd_messages(), do_cmd_options_win(), do_cmd_pref_file_hack(), do_cmd_query_symbol(), do_cmd_unknown(), do_cmd_view_map(), do_cmd_wiz_effect(), do_cmd_wiz_hack_nick(), ego_menu(), get_char(), get_character_name(), get_com_ex(), get_confirm_command(), get_debug_command(), get_file_text(), get_history_command(), get_pref_path(), history_display(), item_menu(), item_menu_browser(), keymap_browse_hook(), o_xtra_act(), pause_line(), point_based_start(), proj_display(), prt_welcome(), repeated_command_display(), roller_command(), rune_xtra_act(), save_game(), see_floor_items(), show_command_list(), show_file(), show_obj(), show_obj_list(), spell_menu_browse(), spell_menu_select(), splashscreen_note(), store_display_frame(), store_get_check(), store_menu_handle(), store_process_command_key(), store_purchase(), store_redraw(), store_sell(), sval_menu(), target_recall_loop_object(), target_set_interactive(), target_set_interactive_aux(), textui_birth_quickstart(), textui_cmd_ignore_menu(), textui_cmd_suicide(), textui_get_check(), textui_get_command(), textui_get_count(), textui_get_item(), textui_get_rep_dir(), textui_get_string(), ui_keymap_create(), ui_keymap_query(), ui_keymap_remove(), ui_leave_init(), update_statusline(), visuals_reset(), wiz_display_item(), and wiz_statistics().

void put_str ( const char *  str,
int  row,
int  col 
)
region region_calculate ( region  loc)


Regions

Given a region with relative values, make them absolute.

These functions are used for manipulating regions on the screen, used mostly (but not exclusively) by the menu functions.

References region::col, h, loc(), region::page_rows, region::row, Term_get_size(), w, and region::width.

Referenced by menu_calc_size(), region_erase(), region_erase_bordered(), textui_textblock_place(), and textui_textblock_show().

void region_erase ( const region loc)
void region_erase_bordered ( const region loc)
bool region_inside ( const region loc,
const ui_event key 
)

Check whether a (mouse) event is inside a region.

References region::col, ui_event::mouse, region::page_rows, region::row, region::width, mouseclick::x, and mouseclick::y.

Referenced by display_knowledge(), and menu_handle_mouse().

void screen_load ( void  )

Load the screen, and decrease the "icky" depth.

References EVENT_MESSAGE_FLUSH, event_signal(), screen_save_depth, Term_load(), Term_redraw(), tile_height, and tile_width.

Referenced by cmd_menu(), context_menu_cave(), context_menu_command(), context_menu_object(), context_menu_player(), context_menu_player_2(), context_menu_player_display_floor(), context_menu_store(), context_menu_store_item(), death_file(), death_info(), death_messages(), death_scores(), display_knowledge(), do_cmd_change_name(), do_cmd_colors(), do_cmd_delay(), do_cmd_equip(), do_cmd_help(), do_cmd_hp_warn(), do_cmd_inven(), do_cmd_itemlist(), do_cmd_keylog(), do_cmd_keymaps(), do_cmd_lazymove_delay(), do_cmd_messages(), do_cmd_monlist(), do_cmd_options(), do_cmd_options_item(), do_cmd_options_win(), do_cmd_pref_file_hack(), do_cmd_quiver(), do_cmd_spoilers(), do_cmd_view_map(), do_cmd_visuals(), do_cmd_wiz_effect(), do_cmd_wiz_help(), do_cmd_wiz_play(), ego_menu(), get_debug_command(), get_pref_path(), history_display(), menu_refresh(), menu_select(), o_xtra_act(), option_toggle_handle(), option_toggle_menu(), quality_action(), quality_menu(), rune_xtra_act(), see_floor_items(), show_command_list(), show_scores(), spell_menu_browse(), spell_menu_select(), store_purchase(), store_sell(), sval_menu(), target_set_interactive_aux(), textui_action_menu_choose(), textui_browse_knowledge(), textui_cmd_ignore_menu(), textui_get_item(), textui_store_knowledge(), textui_textblock_show(), use_store(), wiz_create_item(), wiz_create_item_action(), and wiz_proj_demo().

void screen_save ( void  )

Save the screen, and increase the "icky" depth.

References EVENT_MESSAGE_FLUSH, event_signal(), PR_MAP, player_upkeep::redraw, redraw_stuff(), screen_save_depth, Term_save(), and player::upkeep.

Referenced by cmd_menu(), context_menu_cave(), context_menu_command(), context_menu_object(), context_menu_player(), context_menu_player_2(), context_menu_player_display_floor(), context_menu_store(), context_menu_store_item(), death_file(), death_info(), death_messages(), death_scores(), display_knowledge(), do_cmd_change_name(), do_cmd_colors(), do_cmd_delay(), do_cmd_equip(), do_cmd_help(), do_cmd_hp_warn(), do_cmd_inven(), do_cmd_itemlist(), do_cmd_keylog(), do_cmd_keymaps(), do_cmd_lazymove_delay(), do_cmd_messages(), do_cmd_monlist(), do_cmd_options(), do_cmd_options_item(), do_cmd_options_win(), do_cmd_pref_file_hack(), do_cmd_quiver(), do_cmd_spoilers(), do_cmd_view_map(), do_cmd_visuals(), do_cmd_wiz_effect(), do_cmd_wiz_help(), do_cmd_wiz_play(), ego_menu(), get_debug_command(), get_pref_path(), history_display(), menu_refresh(), menu_select(), o_xtra_act(), option_toggle_handle(), option_toggle_menu(), quality_action(), quality_menu(), rune_xtra_act(), see_floor_items(), show_command_list(), show_scores(), spell_menu_browse(), spell_menu_select(), store_purchase(), store_sell(), sval_menu(), target_set_interactive_aux(), textui_action_menu_choose(), textui_browse_knowledge(), textui_cmd_ignore_menu(), textui_get_item(), textui_store_knowledge(), textui_textblock_show(), use_store(), wiz_create_item(), wiz_create_item_action(), and wiz_proj_demo().

void text_out_to_screen ( byte  a,
const char *  str 
)


text_out hook for screen display

Print some (colored) text to the screen at the current cursor position, automatically "wrapping" existing text (at spaces) when necessary to avoid placing any text into the last column, and clearing every line before placing any text in that line. Also, allow "newline" to force a "wrap" to the next line. Advance the cursor as needed so sequential calls to this function will work correctly.

Once this function has been called, the cursor should not be moved until all the related "text_out()" calls to the window are complete.

This function will correctly handle any width up to the maximum legal value of 256, though it works best for a standard 80 character width.

References buf, h, i, Term_addch(), Term_erase(), Term_get_size(), Term_gotoxy(), Term_locate(), Term_what(), text_mbstowcs(), text_out_indent, text_out_pad, text_out_wrap, and void().

Referenced by class_help(), curse_menu_browser(), display_player_xtra_info(), ego_menu(), item_menu_browser(), print_menu_instructions(), race_help(), show_splashscreen(), spell_menu_browser(), store_display_help(), and target_display_help().

void textui_get_panel ( int min_y,
int min_x,
int max_y,
int max_x 
)
bool textui_map_is_visible ( void  )

References screen_save_depth.

Referenced by textui_input_init().

bool textui_panel_contains ( unsigned int  y,
unsigned int  x 
)
void textui_textblock_place ( textblock tb,
region  orig_area,
const char *  header 
)
void textui_textblock_show ( textblock tb,
region  orig_area,
const char *  header 
)
void verify_panel ( void  )

Verify the current panel (relative to the player location).

By default, when the player gets "too close" to the edge of the current panel, the map scrolls one panel in that direction so that the player is no longer so close to the edge.

The "OPT(player, center_player)" option allows the current panel to always be centered around the player, which is very expensive, and also has some interesting gameplay ramifications.

References OPT, and verify_panel_int().

Referenced by check_panel(), do_cmd_locate(), do_cmd_redraw(), new_level_display_update(), and target_set_interactive().

static void verify_panel_int ( bool  centered)
static
void window_make ( int  origin_x,
int  origin_y,
int  end_x,
int  end_y 
)


Miscellaneous things

A Hengband-like 'window' function, that draws a surround box in ASCII art.

References region::col, COLOUR_WHITE, region::page_rows, region_erase(), region::row, Term_putch(), and region::width.

Referenced by cmd_menu(), display_map(), quality_action(), and textui_action_menu_choose().

Variable Documentation

s16b screen_save_depth


Screen loading/saving

Screen loading and saving can be done to an arbitrary depth but it's important that every call to screen_save() is balanced by a call to screen_load() later on. 'screen_save_depth' is used by the game to keep track of whether it should try to update the map and sidebar or not, so if you miss out a screen_load you will not get proper game updates.

Term_save() / Term_load() do all the heavy lifting here. Depth of the screen_save() stack

Referenced by close_game(), inkey_ex(), screen_load(), screen_save(), textui_init(), textui_map_is_visible(), ui_enter_world(), and ui_leave_world().