Crossfire Client, Trunk
|
#include "client.h"
#include <gtk/gtk.h>
#include "image.h"
#include "main.h"
#include "gtk2proto.h"
#include "../../pixmaps/all.xpm"
#include "../../pixmaps/coin.xpm"
#include "../../pixmaps/hand.xpm"
#include "../../pixmaps/hand2.xpm"
#include "../../pixmaps/lock.xpm"
#include "../../pixmaps/mag.xpm"
#include "../../pixmaps/nonmag.xpm"
#include "../../pixmaps/skull.xpm"
#include "../../pixmaps/unlock.xpm"
#include "../../pixmaps/unidentified.xpm"
Go to the source code of this file.
Data Structures | |
struct | Notebook_Info |
Macros | |
#define | INV_SHOW_COLOR 0x2 |
#define | INV_SHOW_ITEM 0x1 |
#define | INV_TABLE_AT(x, y, cols) inv_table_children[cols*y + x] |
#define | MAX_INV 2000 |
#define | NUM_INV_LISTS 11 |
Enumerations | |
enum | display_type { INV_TREE, INV_TABLE } |
enum | item_env { ITEM_INVENTORY = 0x1, ITEM_GROUND = 0x2, ITEM_IN_CONTAINER = 0x4 } |
enum | list_property { LIST_NONE, LIST_ICON, LIST_NAME, LIST_WEIGHT, LIST_OBJECT, LIST_BACKGROUND, LIST_TYPE, LIST_BASENAME, LIST_FOREGROUND, LIST_FONT, LIST_NUM_COLUMNS } |
enum | Styles { Style_Magical = 0, Style_Cursed, Style_Unpaid, Style_Locked, Style_Applied, Style_Last, Style_Attuned, Style_Repelled, Style_Denied, Style_Normal, Style_Last } |
Functions | |
static void | add_object_to_store (item *it, GtkTreeStore *store, GtkTreeIter *new, GtkTreeIter *parent, int color) |
static void | animate_inventory () |
static void | animate_look () |
void | close_container (item *op) |
void | command_show (const char *params) |
static void | draw_inv (int tab) |
static void | draw_inv_list (int tab) |
static void | draw_inv_table (int animate) |
static void | draw_inv_table_icon (GdkWindow *dst, const void *image) |
void | draw_lists () |
void | draw_look_list () |
static gboolean | drawingarea_inventory_table_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) |
static gboolean | drawingarea_inventory_table_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) |
static int | get_item_env (item *it) |
static GtkStyle * | get_row_style (item *it) |
void | inventory_get_styles () |
void | inventory_init (GtkWidget *window_root) |
void | inventory_tick () |
void | item_event_container_clearing (item *container) |
void | item_event_item_changed (item *it) |
void | item_event_item_deleting (item *it) |
static void | list_item_action (GdkEventButton *event, item *tmp) |
static void | list_item_drop (item *tmp) |
static void | list_row_collapse (GtkTreeView *treeview, GtkTreeIter *iter, GtkTreePath *path, gpointer user_data) |
static gboolean | list_selection_func (GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean path_currently_selected, gpointer userdata) |
static void | ma_apply (GtkWidget *widget, item *tmp) |
static void | ma_drop (GtkWidget *widget, item *tmp) |
static void | ma_examine (GtkWidget *widget, item *tmp) |
static void | ma_lock (GtkWidget *widget, item *tmp) |
static void | ma_mark (GtkWidget *widget, item *tmp) |
static void | on_switch_page (GtkNotebook *notebook, gpointer *page, guint page_num, gpointer user_data) |
void | open_container (item *op) |
static void | remove_object_from_store (item *it, GtkTreeStore *store) |
void | set_weight_limit (guint32 wlim) |
static void | setup_list_columns (GtkWidget *treeview) |
static int | show_all (item *it) |
static int | show_applied (item *it) |
static int | show_cursed (item *it) |
static void | show_item_menu (GdkEventButton *event, item *tmp) |
static int | show_locked (item *it) |
static int | show_magical (item *it) |
static int | show_nonmagical (item *it) |
static int | show_unapplied (item *it) |
static int | show_unidentified (item *it) |
static int | show_unlocked (item *it) |
static int | show_unpaid (item *it) |
Variables | |
static const GdkColor | applied_color = {0, 50000, 50000, 50000} |
static GtkWidget * | encumbrance_current |
static GtkWidget * | encumbrance_max |
static GtkWidget * | inv_notebook |
static Notebook_Info | inv_notebooks [NUM_INV_LISTS] |
static GtkStyle * | inv_styles [Style_Last] |
static GtkWidget * | inv_table |
static GtkWidget * | inv_table_children [MAX_INV] |
static int | num_inv_notebook_pages = 0 |
static GtkTreeStore * | store_look |
static const char * | Style_Names [Style_Last] |
static GtkTreeStore * | treestore |
GtkWidget * | treeview_look |
static double | weight_limit |
Draw inventory and 'look' windows
Definition in file inventory.c.
#define INV_SHOW_COLOR 0x2 |
Definition at line 81 of file inventory.c.
#define INV_SHOW_ITEM 0x1 |
Definition at line 80 of file inventory.c.
#define INV_TABLE_AT | ( | x, | |
y, | |||
cols | |||
) | inv_table_children[cols*y + x] |
Definition at line 59 of file inventory.c.
#define MAX_INV 2000 |
Definition at line 56 of file inventory.c.
#define NUM_INV_LISTS 11 |
Definition at line 79 of file inventory.c.
enum display_type |
Indicate how an inventory tab should be drawn
Enumerator | |
---|---|
INV_TREE | |
INV_TABLE |
Definition at line 87 of file inventory.c.
enum item_env |
Describe where an item is. These constants must be kept as-is for use in a few bitwise operations.
Enumerator | |
---|---|
ITEM_INVENTORY | |
ITEM_GROUND | |
ITEM_IN_CONTAINER |
Definition at line 180 of file inventory.c.
enum list_property |
Constants used to refer to columns in the inventory list view
Enumerator | |
---|---|
LIST_NONE | |
LIST_ICON | |
LIST_NAME | |
LIST_WEIGHT | |
LIST_OBJECT | |
LIST_BACKGROUND | |
LIST_TYPE | |
LIST_BASENAME | |
LIST_FOREGROUND | |
LIST_FONT | |
LIST_NUM_COLUMNS |
Definition at line 170 of file inventory.c.
enum Styles |
Enumerator | |
---|---|
Style_Magical | |
Style_Cursed | |
Style_Unpaid | |
Style_Locked | |
Style_Applied | |
Style_Last | |
Style_Attuned | |
Style_Repelled | |
Style_Denied | |
Style_Normal | |
Style_Last |
Definition at line 62 of file inventory.c.
|
static |
Adds a row to the treestore.
it | the object to add |
store | The TreeStore object. |
new | Returns the iter used/updated for the store |
parent | The parent iter (can be null). If non null, then this creates a real tree, for things like containers. |
color | If true, do foreground/background colors, otherwise, just black & white Normally it is set. However, when showing the cursed inv tab, it doesn't make a lot of sense to show them all in the special color, since they all meet that special criteria |
Definition at line 792 of file inventory.c.
References item_struct::d_name, item_struct::face, item_struct::flags, get_row_style(), PixmapInfo::icon_image, LIST_BACKGROUND, LIST_BASENAME, LIST_FONT, LIST_FOREGROUND, LIST_ICON, LIST_NAME, LIST_OBJECT, LIST_TYPE, LIST_WEIGHT, item_struct::nrof, pixmaps, item_struct::s_name, item_struct::type, and item_struct::weight.
Referenced by draw_inv_list(), and draw_look_list().
|
static |
Definition at line 1212 of file inventory.c.
References item_struct::anim_speed, item_struct::anim_state, item_struct::animation_id, animations, draw_inv_table(), item_struct::face, Animations::faces, PixmapInfo::icon_image, inv_notebook, inv_notebooks, INV_TABLE, item_struct::last_anim, LIST_ICON, LIST_OBJECT, Animations::num_animations, pixmaps, and treestore.
Referenced by inventory_tick().
|
static |
Definition at line 1264 of file inventory.c.
References item_struct::anim_speed, item_struct::anim_state, item_struct::animation_id, animations, item_struct::face, Animations::faces, PixmapInfo::icon_image, item_struct::last_anim, LIST_ICON, LIST_OBJECT, Animations::num_animations, pixmaps, and store_look.
Referenced by inventory_tick().
void close_container | ( | item * | op | ) |
Open and close_container are now no-ops - since these are now drawn inline as treestores, we don't need to update what we are drawing were. and since the activation of a container will cause the list to be redrawn, don't need to worry about making an explicit call here.
op |
Definition at line 647 of file inventory.c.
Referenced by item_actions().
void command_show | ( | const char * | params | ) |
params |
Definition at line 661 of file inventory.c.
References draw_ext_info(), inv_notebook, inv_notebooks, MAX_BUF, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_ERROR, NDI_RED, NUM_INV_LISTS, and num_inv_notebook_pages.
|
static |
Draws the inventory and updates the encumbrance statistics display in the client. Have to determine how to draw it.
tab |
Definition at line 1147 of file inventory.c.
References cpl, draw_inv_list(), draw_inv_table(), encumbrance_current, encumbrance_max, inv_notebooks, INV_TABLE, INV_TREE, Player_Struct::ob, item_struct::weight, and weight_limit.
Referenced by draw_lists().
|
static |
Draws the inventory window. tab is the notebook tab we are drawing. Has to be passed in because the callback sets this before the notebook is updated.
tab |
Definition at line 870 of file inventory.c.
References add_object_to_store(), Player_Struct::container, cpl, item_struct::inv, inv_notebooks, INV_SHOW_COLOR, INV_SHOW_ITEM, item_struct::next, Player_Struct::ob, item_struct::open, Notebook_Info::show_func, and treestore.
Referenced by draw_inv().
|
static |
Draws the table of image icons.
animate | If non-zero, then this is an animation run - flip the animation state of the objects, and only draw those that need to be drawn. |
Definition at line 981 of file inventory.c.
References item_struct::anim_speed, item_struct::anim_state, item_struct::animation_id, animations, item_struct::applied, applied_color, cpl, item_struct::d_name, draw_inv_table_icon(), drawingarea_inventory_table_button_press_event(), drawingarea_inventory_table_expose_event(), item_struct::face, Animations::faces, item_struct::flags, PixmapInfo::icon_image, image_size, item_struct::inv, inv_table, INV_TABLE_AT, item_struct::last_anim, LOG(), LOG_ERROR, MAX_INV, item_struct::next, Animations::num_animations, Player_Struct::ob, and pixmaps.
Referenced by animate_inventory(), and draw_inv().
|
static |
Definition at line 935 of file inventory.c.
Referenced by draw_inv_table(), and drawingarea_inventory_table_expose_event().
void draw_lists | ( | ) |
Redraws inventory and look windows when necessary
Definition at line 1165 of file inventory.c.
References Player_Struct::below, Player_Struct::container, cpl, draw_inv(), draw_look_list(), item_struct::env, inv_notebook, item_struct::inv_updated, and Player_Struct::ob.
Referenced by load_theme(), and redraw().
void draw_look_list | ( | ) |
Draws the objects beneath the player.
Definition at line 835 of file inventory.c.
References add_object_to_store(), Player_Struct::below, Player_Struct::container, cpl, item_struct::inv, item_struct::next, item_struct::open, store_look, and treeview_look.
Referenced by draw_lists().
|
static |
widget | |
event | |
user_data |
Definition at line 929 of file inventory.c.
References list_item_action().
Referenced by draw_inv_table().
|
static |
widget | |
event | |
user_data |
Definition at line 951 of file inventory.c.
References cpl, draw_inv_table_icon(), item_struct::face, PixmapInfo::icon_image, item_struct::inv_updated, Player_Struct::ob, and pixmaps.
Referenced by draw_inv_table().
|
static |
Returns information on the environment of the item, using the return values below. Note that there should never be a case where both ITEM_GROUND and ITEM_INVENTORY are returned, but I prefer a more active approach in returning actual values and not presuming that lack of value means it is in the other location.
it |
Definition at line 194 of file inventory.c.
References Player_Struct::below, cpl, item_struct::env, ITEM_GROUND, ITEM_IN_CONTAINER, ITEM_INVENTORY, and Player_Struct::ob.
Referenced by item_event_item_deleting(), and list_item_drop().
|
static |
it |
Definition at line 702 of file inventory.c.
References item_struct::applied, item_struct::cursed, item_struct::damned, inv_styles, item_struct::locked, item_struct::magical, Style_Applied, Style_Cursed, Style_Locked, Style_Magical, Style_Unpaid, and item_struct::unpaid.
Referenced by add_object_to_store().
void inventory_get_styles | ( | ) |
Gets the style information for the inventory windows. This is a separate function because if the user changes styles, it can be nice to re-load the configuration. The style for the inventory/look is a bit special. That is because with gtk, styles are widget wide - all rows in the widget would use the same style. We want to adjust the styles based on other attributes.
Definition at line 501 of file inventory.c.
References has_init, inv_styles, LOG(), LOG_INFO, Style_Last, and Style_Names.
Referenced by load_theme().
void inventory_init | ( | GtkWidget * | window_root | ) |
Set up the inventory viewer.
window_root | The client main window. |
Definition at line 528 of file inventory.c.
References encumbrance_current, encumbrance_max, inv_notebook, inv_notebooks, inv_table, inv_table_children, INV_TREE, LIST_NUM_COLUMNS, list_row_collapse(), LOG(), LOG_ERROR, MAX_INV, NUM_INV_LISTS, num_inv_notebook_pages, on_switch_page(), setup_list_columns(), store_look, treestore, Notebook_Info::treeview, treeview_look, and window_xml.
Referenced by init_ui().
void inventory_tick | ( | ) |
This is called periodically from main.c - basically a timeout, used to animate the inventory.
Definition at line 1304 of file inventory.c.
References animate_inventory(), and animate_look().
Referenced by client_tick().
void item_event_container_clearing | ( | item * | container | ) |
Definition at line 773 of file inventory.c.
Referenced by remove_item_inventory().
void item_event_item_changed | ( | item * | it | ) |
Definition at line 776 of file inventory.c.
Referenced by set_item_values().
void item_event_item_deleting | ( | item * | it | ) |
Definition at line 760 of file inventory.c.
References Player_Struct::below, cpl, get_item_env(), item_struct::inv_updated, ITEM_GROUND, ITEM_INVENTORY, Player_Struct::ob, remove_object_from_store(), store_look, and treestore.
Referenced by remove_item().
|
static |
event | |
tmp |
Definition at line 273 of file inventory.c.
References client_send_apply(), client_send_examine(), CONFIG_INV_MENU, list_item_drop(), send_mark_obj(), show_item_menu(), item_struct::tag, toggle_locked(), and use_config.
Referenced by drawingarea_inventory_table_button_press_event(), and list_selection_func().
|
static |
Definition at line 307 of file inventory.c.
References client_send_move(), Player_Struct::container, Player_Struct::count, cpl, draw_ext_info(), get_item_env(), ITEM_GROUND, ITEM_IN_CONTAINER, ITEM_INVENTORY, item_struct::locked, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_NOTICE, NDI_BLACK, Player_Struct::ob, spinbutton_count, and item_struct::tag.
Referenced by list_item_action(), and ma_drop().
|
static |
If the player collapses the row with the little icon, we have to unapply the object for things to work 'sanely' (eg, items not go into the container
treeview | |
iter | |
path | |
user_data |
Definition at line 397 of file inventory.c.
References client_send_apply(), LIST_OBJECT, and item_struct::tag.
Referenced by inventory_init().
|
static |
Used when a button is pressed on the inventory or look list. The parameters are those determined by the callback. Note that this function isn't 100% ideal - some of the events/handling is only relevant for objects in the inventory and not the look window (eg, locking items). OTOH, maybe it is just as well that the behaviour is always consistent.
selection | |
model | |
path | |
path_currently_selected | |
userdata |
Definition at line 357 of file inventory.c.
References list_item_action(), LIST_OBJECT, LOG(), and LOG_ERROR.
Referenced by setup_list_columns().
|
static |
Definition at line 213 of file inventory.c.
References client_send_apply(), and item_struct::tag.
Referenced by show_item_menu().
|
static |
Definition at line 225 of file inventory.c.
References list_item_drop().
Referenced by show_item_menu().
|
static |
Definition at line 209 of file inventory.c.
References client_send_examine(), and item_struct::tag.
Referenced by show_item_menu().
|
static |
Definition at line 221 of file inventory.c.
References toggle_locked().
Referenced by show_item_menu().
|
static |
Definition at line 217 of file inventory.c.
References send_mark_obj().
Referenced by show_item_menu().
|
static |
People are likely go to the different tabs much less often than their inventory changes. So rather than update all the tabs whenever the players inventory changes, only update the tab the player is viewing, and if they change tabs, draw the new tab and get rid of the old info. Ideally, I'd like to call draw_inv() from this function, but there is some oddity
notebook | |
page | |
page_num | |
user_data |
Definition at line 1198 of file inventory.c.
References cpl, inv_notebooks, INV_TREE, item_struct::inv_updated, Player_Struct::ob, and treestore.
Referenced by inventory_init().
void open_container | ( | item * | op | ) |
op |
Definition at line 654 of file inventory.c.
Referenced by item_actions().
|
static |
Definition at line 746 of file inventory.c.
References LIST_OBJECT.
Referenced by item_event_item_deleting().
void set_weight_limit | ( | guint32 | wlim | ) |
No reason to divide by 1000 everytime we do the display, so do it once and store it here.
wlim |
Definition at line 693 of file inventory.c.
References weight_limit.
Referenced by StatsCmd().
|
static |
treeview |
Definition at line 412 of file inventory.c.
References image_size, LIST_BACKGROUND, LIST_BASENAME, LIST_FONT, LIST_FOREGROUND, LIST_ICON, LIST_NAME, LIST_NONE, list_selection_func(), LIST_TYPE, and LIST_WEIGHT.
Referenced by inventory_init().
|
static |
Definition at line 111 of file inventory.c.
References INV_SHOW_COLOR, and INV_SHOW_ITEM.
|
static |
Definition at line 115 of file inventory.c.
References item_struct::applied, and INV_SHOW_ITEM.
|
static |
Definition at line 127 of file inventory.c.
References item_struct::cursed, item_struct::damned, and INV_SHOW_ITEM.
|
static |
Definition at line 229 of file inventory.c.
References Player_Struct::count, cpl, item_struct::env, item_struct::locked, ma_apply(), ma_drop(), ma_examine(), ma_lock(), ma_mark(), and Player_Struct::ob.
Referenced by list_item_action().
|
static |
Definition at line 139 of file inventory.c.
References INV_SHOW_COLOR, INV_SHOW_ITEM, and item_struct::locked.
|
static |
Definition at line 131 of file inventory.c.
References INV_SHOW_ITEM, and item_struct::magical.
|
static |
Definition at line 135 of file inventory.c.
References INV_SHOW_ITEM, and item_struct::magical.
|
static |
Definition at line 119 of file inventory.c.
References item_struct::applied, and INV_SHOW_ITEM.
|
static |
Definition at line 148 of file inventory.c.
References F_UNIDENTIFIED, item_struct::flagsval, and INV_SHOW_ITEM.
|
static |
Definition at line 143 of file inventory.c.
References INV_SHOW_COLOR, INV_SHOW_ITEM, item_struct::locked, and item_struct::open.
|
static |
Definition at line 123 of file inventory.c.
References INV_SHOW_ITEM, and item_struct::unpaid.
|
static |
Color to use to indicate that an item is applied.
Definition at line 41 of file inventory.c.
Referenced by draw_inv_table().
|
static |
Definition at line 44 of file inventory.c.
Referenced by draw_inv(), and inventory_init().
|
static |
Definition at line 45 of file inventory.c.
Referenced by draw_inv(), and inventory_init().
|
static |
Definition at line 46 of file inventory.c.
Referenced by animate_inventory(), command_show(), draw_lists(), and inventory_init().
|
static |
Definition at line 152 of file inventory.c.
Referenced by animate_inventory(), command_show(), draw_inv(), draw_inv_list(), inventory_init(), and on_switch_page().
|
static |
Definition at line 72 of file inventory.c.
Referenced by get_row_style(), and inventory_get_styles().
|
static |
Definition at line 47 of file inventory.c.
Referenced by draw_inv_table(), and inventory_init().
|
static |
Definition at line 57 of file inventory.c.
Referenced by inventory_init().
|
static |
Definition at line 91 of file inventory.c.
Referenced by command_show(), and inventory_init().
|
static |
Definition at line 43 of file inventory.c.
Referenced by animate_look(), draw_look_list(), inventory_init(), and item_event_item_deleting().
|
static |
Definition at line 67 of file inventory.c.
Referenced by inventory_get_styles().
|
static |
store of data for treeview
Definition at line 105 of file inventory.c.
Referenced by animate_inventory(), draw_inv_list(), inventory_init(), item_event_item_deleting(), and on_switch_page().
GtkWidget* treeview_look |
Definition at line 38 of file inventory.c.
Referenced by draw_look_list(), hide_all_login_windows(), inventory_init(), and on_entry_commands_activate().
|
static |
Definition at line 49 of file inventory.c.
Referenced by draw_inv(), and set_weight_limit().