Crossfire Client, Trunk
|
#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.
Classes | |
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) |
static void | launch_mapedit (char *path) |
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 | |
bool | arm_mapedit |
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). | |
struct buffer_control_t | buffer_control |
#define | COUNT_BUFFER_SIZE 16 |
struct info_buffer_t | info_buffer [MESSAGE_BUFFER_COUNT] |
#define | MESSAGE_AGE_MAX 16 |
#define | MESSAGE_BUFFER_COUNT 10 |
#define | MESSAGE_BUFFER_SIZE 56 |
static void | message_callback (int orig_color, int type, int subtype, char *message) |
#define | MESSAGE_COUNT_MAX 16 |
struct msgctrl_data_t | msgctrl_defaults [MSG_TYPE_LAST-1] |
GtkWidget * | msgctrl_table |
message_control_t | msgctrl_widgets [MSG_TYPE_LAST-1] |
GtkWidget * | msgctrl_window |
Text-drawing functions for the message window
Definition in file info.c.
#define COUNT_BUFFER_SIZE 16 |
#define MESSAGE_AGE_MAX 16 |
#define MESSAGE_BUFFER_COUNT 10 |
#define MESSAGE_BUFFER_SIZE 56 |
#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.
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 802 of file info.c.
References add_to_textbuf(), FONT_ARCANE, FONT_FIXED, FONT_HAND, FONT_NORMAL, FONT_STRANGE, has_style, LOG(), LOG_ERROR, LOG_INFO, Info_Pane::msg_type_tags, NUM_COLORS, and usercolorname.
Referenced by 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 409 of file info.c.
References Info_Pane::color_tags, font_style_names, Info_Pane::font_tags, MAX_BUF, NUM_COLORS, NUM_FONTS, set_text_tag_from_style(), Info_Pane::textbuffer, and usercolorname.
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 355 of file info.c.
References Info_Pane::bold_tag, Info_Pane::color_tags, Info_Pane::default_tag, Info_Pane::font_tags, Info_Pane::italic_tag, max_subtype, MSG_TYPE_LAST, Info_Pane::msg_type_tags, NUM_COLORS, NUM_FONTS, Info_Pane::textbuffer, and Info_Pane::underline_tag.
Referenced by info_get_styles(), init_choose_char_window(), init_create_account_window(), init_create_character_window(), and init_login_window().
|
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 693 of file info.c.
References 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, MSG_TYPE_LAST, 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.
Definition at line 1774 of file info.c.
References message_control_t::buffer, msgctrl_data_t::buffer, buffer_control, buffer_control_t::count, buffer_parameter_t::default_state, MSG_TYPE_LAST, msgctrl_defaults, msgctrl_widgets, NUM_TEXT_VIEWS, message_control_t::pane, msgctrl_data_t::pane, buffer_parameter_t::state, boolean_widget_t::state, buffer_control_t::timer, and update_msgctrl_configuration().
Referenced by msgctrl_init(), and on_msgctrl_button_defaults_clicked().
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 915 of file info.c.
References add_marked_text_to_pane(), CONFIG_TIMESTAMP, info_pane, LOG(), LOG_ERROR, MSG_TYPE_LAST, msgctrl_widgets, NUM_TEXT_VIEWS, and want_config.
Referenced by bind_key(), client_negotiate(), command_foodbeep(), command_show(), command_take(), complete_command(), configure_keys(), do_set_mapscale(), draw_prompt(), DrawInfoCmd(), get_image_info(), handle_local_command(), handle_query(), info_buffer_flush(), init_common_cache_data(), keybinding_get_data(), launch_mapedit(), list_item_drop(), load_msgctrl_configuration(), message_callback(), new_menu_pickup(), parse_key(), print_inventory(), save_defaults(), save_keys(), save_msgctrl_configuration(), save_winpos(), script_init(), script_kill(), script_killall(), script_list(), script_process_cmd(), script_tell(), send_command(), 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 499 of file info.c.
References add_style_to_textbuffer(), add_tags_to_textbuffer(), has_init, has_style, info_pane, LOG(), LOG_INFO, MAX_BUF, max_subtype, Info_Pane::msg_type_tags, NUM_TEXT_VIEWS, and set_text_tag_from_style().
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 632 of file info.c.
References Info_Pane::adjustment, info_buffer_init(), info_pane, MAX_BUF, message_callback(), MSG_TYPE_LAST, NUM_TEXT_VIEWS, Info_Pane::scrolled_window, setTextManager(), Info_Pane::textbuffer, Info_Pane::textmark, Info_Pane::textview, and window_xml.
Referenced by 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 1593 of file info.c.
References message_control_t::buffer, buffer_control, config_dir, buffer_control_t::count, draw_ext_info(), LOG(), LOG_DEBUG, LOG_ERROR, MAX_BUF, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_ERROR, MSG_TYPE_LAST, msgctrl_widgets, NDI_RED, NUM_TEXT_VIEWS, message_control_t::pane, buffer_parameter_t::state, boolean_widget_t::state, buffer_control_t::timer, and update_msgctrl_configuration().
Referenced by msgctrl_init(), and on_msgctrl_button_load_clicked().
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 1329 of file info.c.
References info_pane, and NUM_TEXT_VIEWS.
Referenced by do_clearinfo().
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 1348 of file info.c.
References message_control_t::buffer, buffer_control, buffer_control_t::count, default_msgctrl_configuration(), dialog_xml, load_msgctrl_configuration(), MSG_TYPE_LAST, msgctrl_defaults, msgctrl_table, msgctrl_widgets, msgctrl_window, NUM_TEXT_VIEWS, on_msgctrl_button_apply_clicked(), on_msgctrl_button_close_clicked(), on_msgctrl_button_defaults_clicked(), on_msgctrl_button_load_clicked(), on_msgctrl_button_save_clicked(), message_control_t::pane, buffer_parameter_t::ptr, boolean_widget_t::ptr, and buffer_control_t::timer.
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 1910 of file info.c.
References msgctrl_window.
Referenced by init_menu_items().
void on_msgctrl_button_apply_clicked | ( | GtkButton * | button, |
gpointer | user_data | ||
) |
When the message control dialog apply button is pressed, the currently displayed settings are applied. The dialog is not dismissed, but remains open for further adjustments to be made.
button | |
user_data |
Definition at line 1880 of file info.c.
References read_msgctrl_configuration().
Referenced by msgctrl_init().
void on_msgctrl_button_close_clicked | ( | GtkButton * | button, |
gpointer | user_data | ||
) |
When the message control dialog close button is pressed, the currently displayed settings are applied and the dialog is dismissed.
button | |
user_data |
Definition at line 1894 of file info.c.
References msgctrl_window, and read_msgctrl_configuration().
Referenced by msgctrl_init().
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 1865 of file info.c.
References default_msgctrl_configuration().
Referenced by msgctrl_init().
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 1851 of file info.c.
References load_msgctrl_configuration().
Referenced by msgctrl_init().
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 |
Definition at line 1835 of file info.c.
References read_msgctrl_configuration(), and save_msgctrl_configuration().
Referenced by msgctrl_init().
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 1796 of file info.c.
References message_control_t::buffer, buffer_control, buffer_control_t::count, MSG_TYPE_LAST, msgctrl_widgets, NUM_TEXT_VIEWS, message_control_t::pane, buffer_parameter_t::ptr, buffer_parameter_t::state, boolean_widget_t::state, and buffer_control_t::timer.
Referenced by on_msgctrl_button_apply_clicked(), on_msgctrl_button_close_clicked(), on_msgctrl_button_save_clicked(), and save_msgctrl_configuration().
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 1525 of file info.c.
References buffer_control, config_dir, buffer_control_t::count, draw_ext_info(), LOG(), LOG_DEBUG, LOG_WARNING, make_path_to_file(), MAX_BUF, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_CONFIG, MSG_TYPE_CLIENT_ERROR, MSG_TYPE_LAST, msgctrl_widgets, NDI_BLUE, NDI_RED, NUM_TEXT_VIEWS, read_msgctrl_configuration(), buffer_parameter_t::state, and buffer_control_t::timer.
Referenced by on_msgctrl_button_save_clicked().
void set_text_tag_from_style | ( | GtkTextTag * | tag, |
GtkStyle * | style, | ||
const GtkStyle *const | base_style | ||
) |
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 317 of file info.c.
Referenced by add_style_to_textbuffer(), and info_get_styles().
void update_msgctrl_configuration | ( | void | ) |
Update the state of the message control dialog so the configuration matches the currently selected settings. Do not call this before msgctrl_widgets[] is initialized. It also really only makes sense to call it if changes have been made to msgctrl_widgets[].
Definition at line 1495 of file info.c.
References message_control_t::buffer, buffer_control, buffer_control_t::count, MSG_TYPE_LAST, msgctrl_widgets, NUM_TEXT_VIEWS, buffer_parameter_t::ptr, buffer_parameter_t::state, boolean_widget_t::state, and buffer_control_t::timer.
Referenced by default_msgctrl_configuration(), and load_msgctrl_configuration().
struct buffer_control_t buffer_control |
Referenced by default_msgctrl_configuration(), info_buffer_tick(), load_msgctrl_configuration(), msgctrl_init(), read_msgctrl_configuration(), save_msgctrl_configuration(), and update_msgctrl_configuration().
const char* const colorname[NUM_COLORS] |
|
static |
A mapping of font numbers to style based on the rcfile content.
Definition at line 47 of file info.c.
Referenced by add_style_to_textbuffer().
|
static |
Definition at line 90 of file info.c.
Referenced by add_marked_text_to_pane(), and 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 info_buffer_flush(), info_buffer_init(), info_buffer_tick(), and message_callback().
Info_Pane info_pane[NUM_TEXT_VIEWS] |
Definition at line 72 of file info.c.
Referenced by draw_ext_info(), info_get_styles(), info_init(), and menu_clear().
|
static |
Definition at line 90 of file info.c.
Referenced by add_tags_to_textbuffer(), add_to_textbuf(), and info_get_styles().
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.
Referenced by default_msgctrl_configuration(), and msgctrl_init().
GtkWidget* msgctrl_table |
The message control table where routing and buffer configuration is set up.
Definition at line 112 of file info.c.
Referenced by msgctrl_init().
message_control_t msgctrl_widgets[MSG_TYPE_LAST-1] |
All of the checkbox widgets for the entire message control dialog.
Definition at line 230 of file info.c.
Referenced by default_msgctrl_configuration(), draw_ext_info(), load_msgctrl_configuration(), message_callback(), msgctrl_init(), read_msgctrl_configuration(), save_msgctrl_configuration(), and update_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 msgctrl_init(), on_msgctrl_activate(), and on_msgctrl_button_close_clicked().
|
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(), add_style_to_textbuffer(), and add_to_textbuf().