Angband
|
Putting text on the screen, screen saving and loading, panel handling. More...
#include "angband.h"
#include "cave.h"
#include "ui-input.h"
#include "ui-output.h"
#include "z-textblock.h"
Functions | |
region | region_calculate (region loc) |
Regions | |
void | region_erase_bordered (const region *loc) |
Erase the contents of a region + 1 char each way. | |
void | region_erase (const region *loc) |
Erase the contents of a region. | |
bool | region_inside (const region *loc, const ui_event *key) |
Check whether a (mouse) event is inside a region. | |
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 | |
void | textui_textblock_place (textblock *tb, region orig_area, const char *header) |
Plonk a textblock on the screen in a certain bounding box. | |
void | textui_textblock_show (textblock *tb, region orig_area, const char *header) |
Show a textblock interactively. | |
void | text_out_to_screen (byte a, const char *str) |
text_out hook for screen display | |
void | c_put_str (byte attr, const char *str, int row, int col) |
Simple text display | |
void | put_str (const char *str, int row, int col) |
As above, but in white. | |
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. | |
void | prt (const char *str, int row, int col) |
As above, but in white. | |
void | screen_save (void) |
Save the screen, and increase the "icky" depth. | |
void | screen_load (void) |
Load the screen, and decrease the "icky" depth. | |
bool | textui_map_is_visible (void) |
void | window_make (int origin_x, int origin_y, int end_x, int end_y) |
Miscellaneous things | |
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. | |
static void | verify_panel_int (bool centered) |
bool | change_panel (int dir) |
Change the current panel to the panel lying in the given direction. | |
void | verify_panel (void) |
Verify the current panel (relative to the player location). | |
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 |
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.
Display a string on the screen using an attribute, and clear to the end of the line.
References Term_addstr(), and Term_erase().
Referenced by display_artifact(), display_ego_item(), display_feature(), display_monster(), display_object(), display_options_item(), do_cmd_message_one(), gf_display(), mon_summary(), option_toggle_display(), prt(), spell_menu_display(), textui_textblock_place(), textui_textblock_show(), ui_keymap_create(), wiz_create_item_display(), and wiz_create_item_subdisplay().
Display a string on the screen using an attribute.
At the given location, using the given attribute, if allowed, add the given string. Do not clear the line.
References Term_putstr().
Referenced by birthmenu_display(), death_info(), display_group_member(), display_object(), display_player_stat_info(), display_player_sust_info(), display_scores_aux(), ego_display(), gf_display(), ignore_sval_menu_display(), print_history_header(), prt_ac(), prt_dtrap(), prt_exp(), prt_field(), prt_gold(), prt_hp(), prt_level(), prt_recall(), prt_sp(), prt_speed(), prt_stat(), prt_state(), prt_study(), prt_tmd(), put_str(), quality_display(), quality_subdisplay(), show_obj_list(), and store_display_entry().
References TRUE, and verify_panel_int().
Referenced by do_cmd_center_map().
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, FALSE, term::hgt, modify_panel(), term::offset_x, term::offset_y, PW_MAP, SCREEN_HGT, SCREEN_WID, TRUE, term::wid, and window_flag.
Referenced by do_cmd_locate(), and target_set_interactive().
|
static |
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().
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, FALSE, chunk::height, term::offset_x, term::offset_y, PR_MAP, player_upkeep::redraw, redraw_stuff(), SCREEN_HGT, SCREEN_WID, tile_height, tile_width, TRUE, player::upkeep, and chunk::width.
Referenced by adjust_panel_help(), change_panel(), target_set_interactive(), and verify_panel_int().
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(), death_info(), display_glyphs(), display_knowledge(), display_scores_aux(), do_cmd_delay(), do_cmd_hp_warn(), do_cmd_inven(), 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_ben(), ego_menu(), get_char(), get_character_name(), get_com_ex(), get_confirm_command(), get_debug_command(), get_history_command(), get_pref_path(), gf_display(), history_display(), keymap_browse_hook(), o_xtra_act(), pause_line(), point_based_start(), prt_welcome(), repeated_command_display(), roller_command(), save_game(), see_floor_items(), show_command_list(), show_file(), show_obj_list(), spell_menu_browse(), spell_menu_select(), splashscreen_note(), store_display_frame(), store_get_check(), store_menu_handle(), 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().
As above, but in white.
References c_put_str(), and COLOUR_WHITE.
Referenced by display_monster(), display_player_stat_info(), display_scores_aux(), display_winner(), do_cmd_query_symbol(), do_cmd_view_map(), pause_line(), point_based_points(), print_tomb(), prt_ac(), prt_depth(), prt_exp(), prt_gold(), prt_hp(), prt_level(), prt_sp(), prt_stat(), prt_unignore(), put_str_centred(), show_obj_list(), and store_display_frame().
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().
Erase the contents of a region.
References region::col, i, region::page_rows, region_calculate(), region::row, Term_erase(), and region::width.
Referenced by display_knowledge(), display_panel(), and window_make().
Erase the contents of a region + 1 char each way.
References region::col, i, MAX, region::page_rows, region_calculate(), region::row, Term_erase(), and region::width.
Referenced by context_menu_cave(), context_menu_command(), context_menu_object(), context_menu_player(), context_menu_player_2(), context_menu_store(), context_menu_store_item(), monster_list_show_interactive(), object_list_show_interactive(), show_command_list(), spell_menu_browse(), spell_menu_select(), and textui_cmd_ignore_menu().
Check whether a (mouse) event is inside a region.
References region::col, FALSE, ui_event::mouse, region::page_rows, region::row, TRUE, region::width, mouseclick::x, and mouseclick::y.
Referenced by display_knowledge(), and menu_handle_mouse().
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_load_screen(), do_cmd_messages(), do_cmd_monlist(), do_cmd_options(), do_cmd_options_item(), do_cmd_options_win(), do_cmd_pref_file_hack(), do_cmd_save_screen_text(), 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(), 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_enter_store(), textui_get_item(), textui_store_knowledge(), textui_textblock_show(), wiz_create_item(), wiz_create_item_action(), and wiz_gf_demo().
Save the screen, and increase the "icky" depth.
References EVENT_MESSAGE_FLUSH, event_signal(), screen_save_depth, and Term_save().
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_load_screen(), do_cmd_messages(), do_cmd_monlist(), do_cmd_options(), do_cmd_options_item(), do_cmd_options_win(), do_cmd_pref_file_hack(), do_cmd_save_screen_text(), 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(), 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_enter_store(), textui_get_item(), textui_store_knowledge(), textui_textblock_show(), wiz_create_item(), wiz_create_item_action(), and wiz_gf_demo().
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(), display_player_xtra_info(), ego_menu(), print_menu_instructions(), race_help(), show_splashscreen(), spell_menu_browser(), store_display_help(), and target_display_help().
References term::offset_x, term::offset_y, SCREEN_HGT, SCREEN_WID, and term_screen.
Referenced by textui_input_init().
References screen_save_depth.
Referenced by textui_input_init().
References term::offset_x, term::offset_y, SCREEN_HGT, SCREEN_WID, Term, and TRUE.
Referenced by textui_input_init().
Plonk a textblock on the screen in a certain bounding box.
References c_prt(), region::col, COLOUR_L_BLUE, display_area(), mem_free(), region::page_rows, region_calculate(), region::row, textblock_attrs(), textblock_calculate_lines(), textblock_text(), and region::width.
Referenced by context_menu_object(), display_object_recall(), do_cmd_query_symbol(), edit_text(), lore_show_subwindow(), monster_list_show_subwindow(), and object_list_show_subwindow().
Show a textblock interactively.
References ARROW_DOWN, ARROW_UP, c_prt(), keypress::code, region::col, COLOUR_L_BLUE, COLOUR_WHITE, display_area(), ESCAPE, inkey(), mem_free(), region::page_rows, region_calculate(), region::row, screen_load(), screen_save(), textblock_attrs(), textblock_calculate_lines(), textblock_text(), and region::width.
Referenced by context_menu_object(), death_examine(), desc_art_fake(), desc_ego_fake(), desc_obj_fake(), display_object_recall_interactive(), lore_show_interactive(), mon_lore(), monster_list_show_interactive(), object_list_show_interactive(), store_examine(), and textui_obj_examine().
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(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().
References angband_term, ANGBAND_TERM_MAX, term::hgt, modify_panel(), term::offset_x, term::offset_y, PW_MAP, player::px, player::py, player_upkeep::running, SCREEN_HGT, SCREEN_WID, player::upkeep, term::wid, and window_flag.
Referenced by center_panel(), and verify_panel().
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().
s16b screen_save_depth |
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_game(), and ui_leave_game().