Crossfire Client, Trunk
R21611
|
#include "client.h"
#include <gtk/gtk.h>
#include "image.h"
#include "main.h"
#include "gtk2proto.h"
#include "msgtypes.h"
Go to the source code of this file.
Data Structures | |
struct | boolean_widget_t |
A container that holds the pointer and state of a checkbox control. Each Message Control dialog checkbox is tracked in one of these structs. More... | |
struct | buffer_control_t |
A container for all of the buffer control parameters like output count and time. The structure holds widget pointers, a state variables to track the parameter values, and the client built-in defaults. Only the final initializer for output_count and output_time is used as a default. More... | |
struct | buffer_parameter_t |
A container for a single buffer control parameter like output count or time. The structure holds a widget pointer, a state variable to track the widget value, and a default value. More... | |
struct | info_buffer_t |
A buffer record that supports suppression of duplicate messages. This buffer holds data for messages that are monitored for suppression of duplicates. The buffer holds all data passed to message_callback(), including type, subtype, suggested color, and the text. Age and count fields are provided to track the time a message is in the buffer, and how many times it occured during the time it is buffered. More... | |
struct | message_control_t |
A container for all of the checkboxes associated with a single message type. More... | |
struct | msgctrl_data_t |
Descriptive message type names with pane routing and buffer enable. A single struct defines a hard-coded, player-friendly, descriptive name to use for a single message type. All other fields in the structure define routing of messages to either or both client message panels, and whether or not messages of this type are passed through the duplicate suppression buffer system. This struct is intended to be used as the base type of an array that contains one struct per message type defined in newclient.h. The hard-coding of the descriptive name for the message type here is not ideal as it would be nicer to have it alongside the MSG_TYPE_* defines. More... | |
Macros | |
#define | NUM_TEXT_VIEWS 2 |
Functions | |
void | add_marked_text_to_pane (Info_Pane *pane, const char *message, int type, int subtype, int orig_color) |
void | add_style_to_textbuffer (Info_Pane *pane, GtkStyle *base_style) |
void | add_tags_to_textbuffer (Info_Pane *pane, GtkTextBuffer *textbuf) |
static void | add_to_textbuf (Info_Pane *pane, const char *message, int type, int subtype, int bold, int italic, int font, const char *color, int underline) |
void | default_msgctrl_configuration (void) |
void | draw_ext_info (int orig_color, int type, int subtype, const char *message) |
void | info_buffer_flush (const int id) |
void | info_buffer_init (void) |
void | info_buffer_tick (void) |
void | info_get_styles (void) |
void | info_init (GtkWidget *window_root) |
void | load_msgctrl_configuration (void) |
void | menu_clear (void) |
void | msgctrl_init (GtkWidget *window_root) |
void | on_msgctrl_activate (GtkMenuItem *menuitem, gpointer user_data) |
void | on_msgctrl_button_apply_clicked (GtkButton *button, gpointer user_data) |
void | on_msgctrl_button_close_clicked (GtkButton *button, gpointer user_data) |
void | on_msgctrl_button_defaults_clicked (GtkButton *button, gpointer user_data) |
void | on_msgctrl_button_load_clicked (GtkButton *button, gpointer user_data) |
void | on_msgctrl_button_save_clicked (GtkButton *button, gpointer user_data) |
void | read_msgctrl_configuration (void) |
void | save_msgctrl_configuration (void) |
void | set_text_tag_from_style (GtkTextTag *tag, GtkStyle *style, const GtkStyle *const base_style) |
void | update_msgctrl_configuration (void) |
Variables | |
const char *const | colorname [NUM_COLORS] |
static const char * | font_style_names [NUM_FONTS] |
static int | has_style =0 |
Info_Pane | info_pane [NUM_TEXT_VIEWS] |
static int | max_subtype =0 |
static const char *const | usercolorname [NUM_COLORS] |
GTK V2 Message Control System. | |
Supports a client-side implementation of what used to be provided by the server output-count and output-sync commands. These defines presently control the way the system works. The hardcoded values here are temporary and shall give way to client commands and/or a GUI method of configuring the system. Turn off the output count/sync by setting MESSAGE_COUNT_MAX to 1. It should be safe to experiment with most values as long as none of them are set less than 1, and as long as the two buffer sizes are set to reasonable values (buffer sizes include the terminating null character). | |
#define | MESSAGE_BUFFER_COUNT 10 |
#define | MESSAGE_BUFFER_SIZE 56 |
#define | COUNT_BUFFER_SIZE 16 |
#define | MESSAGE_COUNT_MAX 16 |
#define | MESSAGE_AGE_MAX 16 |
GtkWidget * | msgctrl_window |
GtkWidget * | msgctrl_table |
struct info_buffer_t | info_buffer [MESSAGE_BUFFER_COUNT] |
struct buffer_control_t | buffer_control |
message_control_t | msgctrl_widgets [MSG_TYPE_LAST-1] |
struct msgctrl_data_t | msgctrl_defaults [MSG_TYPE_LAST-1] |
static void | message_callback (int orig_color, int type, int subtype, char *message) |
Text-drawing functions for the message window
Definition in file info.c.
#define COUNT_BUFFER_SIZE 16 |
The maximum size of the tag that indicates the number of times a message occured while buffered. Example: "4 times "
Definition at line 130 of file info.c.
Referenced by draw_ext_info().
#define MESSAGE_AGE_MAX 16 |
#define MESSAGE_BUFFER_COUNT 10 |
The maximum number of messages to concurrently monitor for duplicate occurances.
Definition at line 116 of file info.c.
Referenced by draw_ext_info(), and message_callback().
#define MESSAGE_BUFFER_SIZE 56 |
The maximum allowable size of messages that are checked for duplicate reduction.
Definition at line 123 of file info.c.
Referenced by draw_ext_info().
#define MESSAGE_COUNT_MAX 16 |
#define NUM_TEXT_VIEWS 2 |
EndOf GTK V2 Font Style Definitions. The number of supported message panes (normal + critical). This define is meant to support anything that iterates over all the information panels. It does nothing to help remove or document hardcoded panel numbers throughout the code.
Definition at line 68 of file info.c.
Referenced by draw_ext_info(), info_get_styles(), message_callback(), and save_msgctrl_configuration().
void add_marked_text_to_pane | ( | Info_Pane * | pane, |
const char * | message, | ||
int | type, | ||
int | subtype, | ||
int | orig_color | ||
) |
This just does the work of taking text (which may have markup) and putting it into the target pane. This is a lower level than the draw_ext_info() below, as it does not do message routing. This is called from draw_ext_info() below, as well as account.c to update news/motd/rules.
pane | Pointer to the pane info to draw info. |
message | Message that is parsed and displayed. |
type | Type of the message - for default coloring information. |
subtype | Subtype of message - used for default coloring information. |
orig_color | Legacy color hint not based on type that is used when a theme does not define a style for the message. |
< Only if we get a [color] tag should we care, otherwise, the type/subtype should dictate color (unless no style set!)
Definition at line 819 of file info.c.
References add_to_textbuf(), CONFIG_TIMESTAMP, draw_ext_info(), FONT_ARCANE, FONT_FIXED, FONT_HAND, FONT_NORMAL, FONT_STRANGE, LOG(), LOG_ERROR, LOG_INFO, usercolorname, and want_config.
Referenced by add_to_textbuf(), draw_ext_info(), on_combobox_starting_map_changed(), and update_login_info().
void add_style_to_textbuffer | ( | Info_Pane * | pane, |
GtkStyle * | base_style | ||
) |
This is like add_tags_to_textbuffer above, but styles can be changed during the run of the client. So this has to be separate to note it it might be a reload.
pane | Message panel number to update. |
base_style | Base style if retrieved - may be null. |
Definition at line 426 of file info.c.
Referenced by info_get_styles(), init_choose_char_window(), init_create_account_window(), init_create_character_window(), and init_login_window().
void add_tags_to_textbuffer | ( | Info_Pane * | pane, |
GtkTextBuffer * | textbuf | ||
) |
Adds the various tags to the next buffer. If textbuf is non-null, then it also sets the text buffer for that pane to textbuf. This is called right now by info_get_styles() below and from within the account code.
pane | Message panel number to add buffer to. |
textbuf | Text buffer to apply tags to. It is allowed to be null if info_pane[pane].textbuffer has already been set. |
Definition at line 372 of file info.c.
Referenced by info_get_styles(), init_choose_char_window(), init_create_account_window(), init_create_character_window(), init_login_window(), and set_text_tag_from_style().
|
static |
Adds some data to the text buffer of the specified information panel using the appropriate tags to provide the desired formatting. Note that the style within the users theme determines how a particular type/subtype is drawn.
pane | The client message panel to write a message to. |
message | A pointer to some text to show in a client message window. |
type | The message type - see the MSG_TYPE values in newclient.h. |
subtype | Message subtype - see MSG_TYPE_*_* values in newclient.h. |
bold | If true, should be in bold text. |
italic | If true, should be in italic text |
font | Which font to use - resolved to an actual font style based on the user's theme file. |
color | String name of the color. |
underline | If true, draw underlined text. |
Definition at line 710 of file info.c.
References add_marked_text_to_pane(), Info_Pane::adjustment, Info_Pane::bold_tag, Info_Pane::color_tags, Info_Pane::default_tag, Info_Pane::font_tags, Info_Pane::italic_tag, LOG(), LOG_ERROR, max_subtype, MSG_TYPE_CLIENT, Info_Pane::msg_type_tags, NUM_COLORS, Info_Pane::textbuffer, Info_Pane::textmark, Info_Pane::textview, Info_Pane::underline_tag, and usercolorname.
Referenced by add_marked_text_to_pane().
void default_msgctrl_configuration | ( | void | ) |
Setup the state of the message control dialog so the configuration matches the default settings built in to the client.
Iterate through each message type. For each, copy the built-in client default to the Message Control dialog state variables. All supported defaults are copied, not just the ones supported by the layout.
void draw_ext_info | ( | int | orig_color, |
int | type, | ||
int | subtype, | ||
const char * | message | ||
) |
A message processor that accepts messages along with meta information color and type. The message type and subtype are analyzed to select font and other text attributes. All gtk-v2 client messages pass through this processor before being output. Before addition of the output buffering feature, this was the message callback function. It is a separate function so that it can be called both by the callback, and but buffer maintenance functions.
Client-sourced messages generally should be passed directly to this handler instead of to the callback. This will save some overhead as the callback implements a system that coalesces duplicate messages - a feature that is not really applicable to most messages that do not come from the server.
orig_color | Suggested text color that type/subtype can over-ride. |
type | Message type. See MSG_TYPE definitions in newclient.h. |
subtype | Message subtype. See MSG_TYPE_*_* values in newclient.h. |
message | The message text to display. |
< When 0, the type is valid and may be used to pick the panel routing, otherwise the message can only go to the main message pane.
Definition at line 932 of file info.c.
References add_marked_text_to_pane(), info_buffer_t::age, info_buffer_t::count, buffer_control_t::count, COUNT_BUFFER_SIZE, info_buffer, info_buffer_flush(), info_buffer_init(), LOG(), LOG_ERROR, info_buffer_t::message, MESSAGE_BUFFER_COUNT, MESSAGE_BUFFER_SIZE, msgctrl_widgets, NUM_TEXT_VIEWS, info_buffer_t::orig_color, info_buffer_t::subtype, info_buffer_t::type, and want_config.
Referenced by add_marked_text_to_pane(), bind_key(), client_negotiate(), command_foodbeep(), command_show(), command_take(), complete_command(), configure_keys(), draw_prompt(), DrawInfoCmd(), focusoutfunc(), get_image_info(), handle_local_command(), handle_query(), init_common_cache_data(), keybinding_get_data(), list_item_action(), message_callback(), new_menu_pickup(), parse_key(), parse_key_release(), print_inventory(), save_defaults(), save_keys(), save_msgctrl_configuration(), save_winpos(), script_init(), script_kill(), script_list(), script_process_cmd(), script_tell(), set_command_window(), SetupCmd(), show_keys(), toggle_keybind_scope(), unbind_key(), and unbind_usage().
void info_get_styles | ( | void | ) |
Loads up values from the style file. Note that the actual name of the style file is set elsewhere.
This function is designed so that it should be possible to call it multiple times - it will release old style data and load up new values. In this way, a user should be able to change styles on the fly and have things work.
Definition at line 516 of file info.c.
References add_style_to_textbuffer(), add_tags_to_textbuffer(), has_style, info_init(), LOG(), LOG_INFO, MAX_BUF, max_subtype, Info_Pane::msg_type_tags, NUM_TEXT_VIEWS, Info_Pane::scrolled_window, set_text_tag_from_style(), Info_Pane::textview, window_root, and window_xml.
Referenced by load_theme().
void info_init | ( | GtkWidget * | window_root | ) |
Initialize the information panels in the client. These panels are the client areas where text is drawn.
window_root | Pointer to the parent (root) application window. |
Definition at line 649 of file info.c.
Referenced by info_get_styles(), and init_ui().
void load_msgctrl_configuration | ( | void | ) |
Setup the state of the message control dialog so the configuration matches a previously saved configuration.
Definition at line 1579 of file info.c.
Referenced by save_msgctrl_configuration().
void menu_clear | ( | void | ) |
Clears all the message panels. It is not clear why someone would use it, but is called from the common area, and so is supported here.
Definition at line 1312 of file info.c.
References dialog_xml, and msgctrl_window.
Referenced by do_clearinfo(), and message_callback().
void msgctrl_init | ( | GtkWidget * | window_root | ) |
Initialize the message control panel by populating it with descriptions of each message type along with checkboxes that are used to configure the routing and duplicate suppression system. If previously saved settings are found on disk, they are loaded and applied, otherwise the built in client defaults are loaded and applied. This initialization must occur after the info_init() function runs.
window_root | The client main window |
Definition at line 1331 of file info.c.
Referenced by init_ui().
void on_msgctrl_activate | ( | GtkMenuItem * | menuitem, |
gpointer | user_data | ||
) |
Shows the message control dialog when the menu item is activated. The settings shown on the dialog when it is activated are the settings currently in use.
menuitem | |
user_data |
Definition at line 1896 of file info.c.
Referenced by init_menu_items().
void on_msgctrl_button_apply_clicked | ( | GtkButton * | button, |
gpointer | user_data | ||
) |
void on_msgctrl_button_close_clicked | ( | GtkButton * | button, |
gpointer | user_data | ||
) |
void on_msgctrl_button_defaults_clicked | ( | GtkButton * | button, |
gpointer | user_data | ||
) |
When the message control dialog defaults button is pressed, the default settings built into the client are restored and applied.
button | |
user_data |
Definition at line 1851 of file info.c.
References read_msgctrl_configuration().
void on_msgctrl_button_load_clicked | ( | GtkButton * | button, |
gpointer | user_data | ||
) |
When the message control dialog load button is pressed, the settings last saved are restored and applied. It may be used to "undo" both applied and unapplied setting changes.
button | |
user_data |
Definition at line 1837 of file info.c.
References read_msgctrl_configuration().
void on_msgctrl_button_save_clicked | ( | GtkButton * | button, |
gpointer | user_data | ||
) |
When the message control dialog save button is pressed, the currently shown settings are applied for immediate use and they are saved to disk so the settings persist across client sessions. Saved settings automatically load and apply when the client is started.
button | |
user_data |
void read_msgctrl_configuration | ( | void | ) |
Reads the state of the message control dialog and applies the settings to the msgctrl_widgets[] state variables that control the message routing and duplicate suppression system.
Definition at line 1782 of file info.c.
Referenced by on_msgctrl_button_defaults_clicked(), and on_msgctrl_button_load_clicked().
void save_msgctrl_configuration | ( | void | ) |
Applies the current state of the checkboxes to the msgctrl_widgets state variables and saves the settings to disk so the configuration persists across client sessions.
Definition at line 1511 of file info.c.
References buffer_control, config_dir, buffer_control_t::count, draw_ext_info(), load_msgctrl_configuration(), LOG(), LOG_DEBUG, MAX_BUF, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_CONFIG, MSG_TYPE_CLIENT_ERROR, msgctrl_widgets, NDI_BLUE, NDI_RED, NUM_TEXT_VIEWS, buffer_parameter_t::state, and buffer_control_t::timer.
void set_text_tag_from_style | ( | GtkTextTag * | tag, |
GtkStyle * | style, | ||
const GtkStyle *const | base_style | ||
) |
EndOf GTK V2 Message Control System. Sets attributes in the text tag from a style. Best I can gather, there is no way to take all of the attributes from a style and apply them directly to a text tag, hence this function to do the work. GtkTextTags also know what attributes are set and which are not set - thus, you can apply multiple tags to the same text, and get all of the effects. For styles, that isn't the case - a style contains all of the information. So this function also compares the loaded style from the base style, and only sets the attributes that are different.
tag | Text tag to set values on. |
style | Style name to get values from. |
base_style | Base style for the widget to compare against. |
Definition at line 334 of file info.c.
References add_tags_to_textbuffer(), Info_Pane::color_tags, Info_Pane::font_tags, max_subtype, MSG_TYPE_LAST, Info_Pane::msg_type_tags, NUM_COLORS, NUM_FONTS, and Info_Pane::textbuffer.
Referenced by info_get_styles().
void update_msgctrl_configuration | ( | void | ) |
struct buffer_control_t buffer_control |
Referenced by save_msgctrl_configuration().
const char* const colorname[NUM_COLORS] |
|
static |
|
static |
Definition at line 90 of file info.c.
Referenced by info_get_styles().
struct info_buffer_t info_buffer[MESSAGE_BUFFER_COUNT] |
Several buffers that support suppression of duplicates even even when the duplicates are alternate with other messages.
Referenced by draw_ext_info(), and message_callback().
Info_Pane info_pane[NUM_TEXT_VIEWS] |
|
static |
Definition at line 90 of file info.c.
Referenced by add_to_textbuf(), info_get_styles(), and set_text_tag_from_style().
struct msgctrl_data_t msgctrl_defaults[MSG_TYPE_LAST-1] |
A data structure to track how to handle each message type in with respect to panel routing and output count.
GtkWidget* msgctrl_table |
message_control_t msgctrl_widgets[MSG_TYPE_LAST-1] |
All of the checkbox widgets for the entire message control dialog.
Definition at line 249 of file info.c.
Referenced by draw_ext_info(), and save_msgctrl_configuration().
GtkWidget* msgctrl_window |
The message control dialog where routing and buffer configuration is set up.
Definition at line 108 of file info.c.
Referenced by menu_clear().
|
static |
Color names set by the user in the gtkrc file.
Definition at line 28 of file info.c.
Referenced by add_marked_text_to_pane(), and add_to_textbuf().