Atrinik Client  4.0
Functions | Variables
inventory.c File Reference
#include <global.h>
#include <toolkit/string.h>

Go to the source code of this file.

Functions

static int inventory_matches_filter (object *op)
 
void inventory_filter_set (uint64_t filter)
 
void inventory_filter_toggle (uint64_t filter)
 
void inventory_filter_set_names (const char *filter)
 
static int inventory_render_object (widgetdata *widget, object *ob, uint32_t i, uint32_t *r, int mx, int my)
 
static void event_drag_cb (void)
 
static void widget_draw (widgetdata *widget)
 
static int widget_event (widgetdata *widget, SDL_Event *event)
 
static int widget_menu_handle (widgetdata *widget, SDL_Event *event)
 
void widget_inventory_init (widgetdata *widget)
 
uint32_t widget_inventory_num_items (widgetdata *widget)
 
objectwidget_inventory_get_selected (widgetdata *widget)
 
void widget_inventory_handle_arrow_key (widgetdata *widget, SDLKey key)
 
void object_show_inventory (SDL_Surface *surface, object *tmp, int x, int y)
 
void menu_inventory_drop (widgetdata *widget, widgetdata *menuitem, SDL_Event *event)
 
void menu_inventory_dropall (widgetdata *widget, widgetdata *menuitem, SDL_Event *event)
 
void menu_inventory_get (widgetdata *widget, widgetdata *menuitem, SDL_Event *event)
 
void menu_inventory_getall (widgetdata *widget, widgetdata *menuitem, SDL_Event *event)
 
void menu_inventory_examine (widgetdata *widget, widgetdata *menuitem, SDL_Event *event)
 
void menu_inventory_loadtoconsole (widgetdata *widget, widgetdata *menuitem, SDL_Event *event)
 
void menu_inventory_patch (widgetdata *widget, widgetdata *menuitem, SDL_Event *event)
 
void menu_inventory_mark (widgetdata *widget, widgetdata *menuitem, SDL_Event *event)
 
void menu_inventory_lock (widgetdata *widget, widgetdata *menuitem, SDL_Event *event)
 
void menu_inventory_drag (widgetdata *widget, widgetdata *menuitem, SDL_Event *event)
 
void widget_inventory_handle_apply (widgetdata *widget)
 
void menu_inv_filter (widgetdata *widget, widgetdata *menuitem, SDL_Event *event)
 
void menu_inv_filter_submenu (widgetdata *widget, widgetdata *menuitem, SDL_Event *event)
 
void menu_inventory_submenu_more (widgetdata *widget, widgetdata *menuitem, SDL_Event *event)
 

Variables

uint64_t inventory_filter = INVENTORY_FILTER_ALL
 
const char * inventory_filter_names [INVENTORY_FILTER_MAX]
 

Detailed Description

Implements inventory type widgets.

Author
Alex Tokar

Definition in file inventory.c.

Function Documentation

static void event_drag_cb ( void  )
static

Called when dragged object is not handled, and a handler was specified.

Definition at line 381 of file inventory.c.

void inventory_filter_set ( uint64_t  filter)

Set an inventory filter to the passed value.

Parameters
filterThe value to set.

Definition at line 116 of file inventory.c.

void inventory_filter_set_names ( const char *  filter)

Set one or more filters.

Parameters
filterFilter(s) to toggle.

Definition at line 153 of file inventory.c.

void inventory_filter_toggle ( uint64_t  filter)

Toggle one inventory filter.

Parameters
filterFilter to toggle.

Definition at line 132 of file inventory.c.

static int inventory_matches_filter ( object op)
static

Check if an object matches one of the active inventory filters.

Parameters
opObject to check.
Returns
1 if there is a match, 0 otherwise.

Definition at line 55 of file inventory.c.

static int inventory_render_object ( widgetdata widget,
object ob,
uint32_t  i,
uint32_t *  r,
int  mx,
int  my 
)
static

Render a single object in the inventory widget.

If 'mx' and 'my' are not -1, no rendering is done and instead the return value indicates whether the mx/my coordinates are over the object.

Parameters
widgetThe widget.
obObject to render.
iInteger index of the object in the linked list.
[out]rRendering index of the object.
mxMouse X. Can be -1.
myMouse Y. Can be -1.
Returns
1 if the object was rendered, 0 otherwise.

Definition at line 196 of file inventory.c.

void menu_inv_filter ( widgetdata widget,
widgetdata menuitem,
SDL_Event *  event 
)

Handle clicking a specific inventory filter.

Parameters
widgetThe widget.
menuitemThe menu item.
eventEvent.

Definition at line 1296 of file inventory.c.

void menu_inv_filter_submenu ( widgetdata widget,
widgetdata menuitem,
SDL_Event *  event 
)

Construct the inventory filters submenu.

Parameters
widgetThe widget.
menuitemThe menu item.
eventEvent.

Definition at line 1332 of file inventory.c.

void menu_inventory_drag ( widgetdata widget,
widgetdata menuitem,
SDL_Event *  event 
)

The 'Drag' menu action for inventory windows.

Parameters
widgetThe widget.
menuitemThe menu item.
eventEvent.

Definition at line 1252 of file inventory.c.

void menu_inventory_drop ( widgetdata widget,
widgetdata menuitem,
SDL_Event *  event 
)

The 'Drop' menu action for inventory windows.

Parameters
widgetThe widget.
menuitemThe menu item.
eventEvent.

Definition at line 938 of file inventory.c.

void menu_inventory_dropall ( widgetdata widget,
widgetdata menuitem,
SDL_Event *  event 
)

The 'Drop all' menu action for inventory windows.

Parameters
widgetThe widget.
menuitemThe menu item.
eventEvent.

Definition at line 1004 of file inventory.c.

void menu_inventory_examine ( widgetdata widget,
widgetdata menuitem,
SDL_Event *  event 
)

The 'Examine' menu action for inventory windows.

Parameters
widgetThe widget.
menuitemThe menu item.
eventEvent.

Definition at line 1119 of file inventory.c.

void menu_inventory_get ( widgetdata widget,
widgetdata menuitem,
SDL_Event *  event 
)

The 'Get' menu action for inventory windows.

Parameters
widgetThe widget.
menuitemThe menu item.
eventEvent.

Definition at line 1019 of file inventory.c.

void menu_inventory_getall ( widgetdata widget,
widgetdata menuitem,
SDL_Event *  event 
)

The 'Get all' menu action for inventory windows.

Parameters
widgetThe widget.
menuitemThe menu item.
eventEvent.

Definition at line 1104 of file inventory.c.

void menu_inventory_loadtoconsole ( widgetdata widget,
widgetdata menuitem,
SDL_Event *  event 
)

The 'Load to console' menu action for inventory windows.

Parameters
widgetThe widget.
menuitemThe menu item.
eventEvent.

Definition at line 1143 of file inventory.c.

void menu_inventory_lock ( widgetdata widget,
widgetdata menuitem,
SDL_Event *  event 
)

The 'Lock' menu action for inventory windows.

Parameters
widgetThe widget.
menuitemThe menu item.
eventEvent.

Definition at line 1223 of file inventory.c.

void menu_inventory_mark ( widgetdata widget,
widgetdata menuitem,
SDL_Event *  event 
)

The 'Mark' menu action for inventory windows.

Parameters
widgetThe widget.
menuitemThe menu item.
eventEvent.

Definition at line 1194 of file inventory.c.

void menu_inventory_patch ( widgetdata widget,
widgetdata menuitem,
SDL_Event *  event 
)

The 'Patch' menu action for inventory windows.

Parameters
widgetThe widget.
menuitemThe menu item.
eventEvent.

Definition at line 1169 of file inventory.c.

void menu_inventory_submenu_more ( widgetdata widget,
widgetdata menuitem,
SDL_Event *  event 
)

Construct the "More" inventory submenu.

Parameters
widgetThe widget.
menuitemThe menu item.
eventEvent.

Definition at line 1362 of file inventory.c.

void object_show_inventory ( SDL_Surface *  surface,
object tmp,
int  x,
int  y 
)

Draw an inventory item on the screen surface.

Uses object_show_centered() to draw the item's face and center it. Draws any additional flags (like magical, cursed, damned) as icons and draws nrof (if higher than 1) of items near the bottom.

Parameters
tmpPointer to the inventory item
xX position of the item
yY position of the item

Definition at line 870 of file inventory.c.

static void widget_draw ( widgetdata widget)
static

Definition at line 401 of file inventory.c.

static int widget_event ( widgetdata widget,
SDL_Event *  event 
)
static

Definition at line 498 of file inventory.c.

object* widget_inventory_get_selected ( widgetdata widget)

Get the selected object from the inventory widget.

Parameters
widgetThe inventory object.
Returns
The selected object, if any.

Definition at line 750 of file inventory.c.

void widget_inventory_handle_apply ( widgetdata widget)

Handle the 'apply' operation for objects inside inventory widget.

Parameters
widgetThe widget.

Definition at line 1273 of file inventory.c.

void widget_inventory_handle_arrow_key ( widgetdata widget,
SDLKey  key 
)

Handle the arrow keys in the inventory widget.

Parameters
widgetThe inventory widget.
keyThe key.

Definition at line 795 of file inventory.c.

void widget_inventory_init ( widgetdata widget)

Initialize one inventory widget.

Definition at line 695 of file inventory.c.

uint32_t widget_inventory_num_items ( widgetdata widget)

Calculate number of items in the inventory widget.

Parameters
widgetThe widget.
Returns
Number of items in the inventory widget.

Definition at line 713 of file inventory.c.

static int widget_menu_handle ( widgetdata widget,
SDL_Event *  event 
)
static

Definition at line 645 of file inventory.c.

Variable Documentation

uint64_t inventory_filter = INVENTORY_FILTER_ALL

Active inventory filter, one of Inventory filters.

Definition at line 38 of file inventory.c.

const char* inventory_filter_names[INVENTORY_FILTER_MAX]
Initial value:
= {
"applied", "container", "magical", "cursed", "unidentified", "unapplied",
"locked"
}

String representations of the possible inventory filters.

Definition at line 43 of file inventory.c.