Crossfire Client, Trunk  R20996
spells.c File Reference
#include "client.h"
#include <assert.h>
#include <gtk/gtk.h>
#include "image.h"
#include "metaserver.h"
#include "main.h"
#include "gtk2proto.h"
+ Include dependency graph for spells.c:

Go to the source code of this file.

Enumerations

enum  {
  LIST_IMAGE, LIST_NAME, LIST_LEVEL, LIST_TIME,
  LIST_COST, LIST_DAMAGE, LIST_SKILL, LIST_PATH,
  LIST_DESCRIPTION, LIST_BACKGROUND, LIST_MAX_SP, LIST_TAG,
  LIST_FOREGROUND, LIST_FONT
}
 
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

void on_spell_cast_clicked (GtkButton *button, gpointer user_data)
 
void on_spell_close_clicked (GtkButton *button, gpointer user_data)
 
void on_spell_invoke_clicked (GtkButton *button, gpointer user_data)
 
void on_spell_treeview_row_activated (GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data)
 
void on_spell_window_size_allocate (GtkWidget *widget, gpointer user_data)
 
void on_spells_activate (GtkMenuItem *menuitem, gpointer user_data)
 
void spell_get_styles (void)
 
static gboolean spell_selection_func (GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean path_currently_selected, gpointer userdata)
 
void update_spell_information (void)
 

Variables

static gpointer description_renderer = NULL
 
static int has_init = 0
 
static GtkWidget * spell_cast
 
static GtkWidget * spell_eventbox [Style_Last]
 
static GtkWidget * spell_invoke
 
static GtkWidget * spell_label [Style_Last]
 
static GtkWidget * spell_options
 
static GtkTreeSelection * spell_selection
 
static GtkListStore * spell_store
 
static GtkStyle * spell_styles [Style_Last]
 
static GtkWidget * spell_treeview
 
static GtkWidget * spell_window
 
static const char * Style_Names [Style_Last]
 

Detailed Description

Handles spell related functionality.

Definition in file spells.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
LIST_IMAGE 
LIST_NAME 
LIST_LEVEL 
LIST_TIME 
LIST_COST 
LIST_DAMAGE 
LIST_SKILL 
LIST_PATH 
LIST_DESCRIPTION 
LIST_BACKGROUND 
LIST_MAX_SP 
LIST_TAG 
LIST_FOREGROUND 
LIST_FONT 

Definition at line 39 of file spells.c.

◆ Styles

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 29 of file spells.c.

Function Documentation

◆ on_spell_cast_clicked()

void on_spell_cast_clicked ( GtkButton *  button,
gpointer  user_data 
)
Parameters
button
user_data

Definition at line 524 of file spells.c.

References LIST_TAG, LOG(), LOG_ERROR, MAX_BUF, options, send_command(), spell_options, and spell_selection.

Referenced by on_spells_activate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ on_spell_close_clicked()

void on_spell_close_clicked ( GtkButton *  button,
gpointer  user_data 
)
Parameters
button
user_data

Definition at line 580 of file spells.c.

References spell_window.

Referenced by on_spells_activate().

+ Here is the caller graph for this function:

◆ on_spell_invoke_clicked()

void on_spell_invoke_clicked ( GtkButton *  button,
gpointer  user_data 
)
Parameters
button
user_data

Definition at line 552 of file spells.c.

References LIST_TAG, LOG(), LOG_ERROR, MAX_BUF, options, send_command(), spell_options, and spell_selection.

Referenced by on_spells_activate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ on_spell_treeview_row_activated()

void on_spell_treeview_row_activated ( GtkTreeView *  treeview,
GtkTreePath *  path,
GtkTreeViewColumn *  column,
gpointer  user_data 
)
Parameters
treeview
path
column
user_data

Definition at line 492 of file spells.c.

References LIST_TAG, LOG(), LOG_ERROR, MAX_BUF, options, and send_command().

Referenced by on_spells_activate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ on_spell_window_size_allocate()

void on_spell_window_size_allocate ( GtkWidget *  widget,
gpointer  user_data 
)

Adjust the line wrap width used by the spells dialog Description column text renderer and force redraw of the rows to cause row height adjustment. To compute the new wrap width, the widths of all other columns are subtracted from the width of the spells window to determine the available width for the description column. The remaining space is then configured as the new wrap width. Once the new wrap is computed, mark all the rows changed so that the renderer adjusts the row height to expand or contract to fit the reformatted description.

Parameters
widget
user_data

Definition at line 124 of file spells.c.

References description_renderer, has_init, spell_store, spell_treeview, and width.

Referenced by on_spells_activate().

+ Here is the caller graph for this function:

◆ on_spells_activate()

◆ spell_get_styles()

void spell_get_styles ( void  )

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 66 of file spells.c.

References LOG(), LOG_INFO, spell_styles, Style_Last, and Style_Names.

Referenced by load_theme(), and on_spells_activate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ spell_selection_func()

static gboolean spell_selection_func ( GtkTreeSelection *  selection,
GtkTreeModel *  model,
GtkTreePath *  path,
gboolean  path_currently_selected,
gpointer  userdata 
)
static

Used if a user just single clicks on an entry - at which point, we enable the cast & invoke buttons.

Parameters
selection
model
path
path_currently_selected
userdata

Definition at line 100 of file spells.c.

References spell_cast, and spell_invoke.

Referenced by on_spells_activate().

+ Here is the caller graph for this function:

◆ update_spell_information()

Variable Documentation

◆ description_renderer

gpointer description_renderer = NULL
static

The cell renderer for the spell dialog descriptions.

Definition at line 49 of file spells.c.

Referenced by on_spell_window_size_allocate(), and on_spells_activate().

◆ has_init

int has_init = 0
static

Whether or not the spell dialog initialized since the client started up.

Definition at line 55 of file spells.c.

Referenced by on_spell_window_size_allocate(), on_spells_activate(), and update_spell_information().

◆ spell_cast

GtkWidget * spell_cast
static

Definition at line 35 of file spells.c.

Referenced by on_spells_activate(), and spell_selection_func().

◆ spell_eventbox

GtkWidget * spell_eventbox[Style_Last]
static

Definition at line 35 of file spells.c.

Referenced by on_spells_activate(), and update_spell_information().

◆ spell_invoke

GtkWidget * spell_invoke
static

Definition at line 35 of file spells.c.

Referenced by on_spells_activate(), and spell_selection_func().

◆ spell_label

GtkWidget * spell_label[Style_Last]
static

Definition at line 35 of file spells.c.

Referenced by on_spells_activate(), and update_spell_information().

◆ spell_options

GtkWidget * spell_options
static

Definition at line 35 of file spells.c.

Referenced by on_spell_cast_clicked(), on_spell_invoke_clicked(), and on_spells_activate().

◆ spell_selection

GtkTreeSelection* spell_selection
static

Definition at line 34 of file spells.c.

Referenced by on_spell_cast_clicked(), on_spell_invoke_clicked(), and on_spells_activate().

◆ spell_store

GtkListStore* spell_store
static

◆ spell_styles

GtkStyle* spell_styles[Style_Last]
static

The actual styles loaded, or NULL if no styles were found.

Definition at line 52 of file spells.c.

Referenced by spell_get_styles(), and update_spell_information().

◆ spell_treeview

GtkWidget * spell_treeview
static

Definition at line 35 of file spells.c.

Referenced by on_spell_window_size_allocate(), and on_spells_activate().

◆ spell_window

GtkWidget* spell_window
static

Definition at line 35 of file spells.c.

Referenced by on_spell_close_clicked(), and on_spells_activate().

◆ Style_Names

const char* Style_Names[Style_Last]
static
Initial value:
= {
"spell_attuned", "spell_repelled", "spell_denied", "spell_normal"
}

The names of theme file styles that are used in the spell dialog.

Definition at line 45 of file spells.c.

Referenced by spell_get_styles().