Crossfire Client, Trunk  R19545
Data Structures | Macros | Functions | Variables
stats.c File Reference

Support for character statistics. More...

#include <assert.h>
#include <gtk/gtk.h>
#include "client.h"
#include "main.h"
#include "image.h"
#include "gtk2proto.h"
Include dependency graph for stats.c:

Go to the source code of this file.

Data Structures

struct  StatWindow
 

Macros

#define MAX_STAT_BARS   5
 
#define NUM_STYLES   6
 
#define PROTECTION_BOXES_X   6
 
#define PROTECTION_BOXES_Y   6
 
#define SKILL_BOXES_X   6
 
#define SKILL_BOXES_Y   17
 
#define STAT_BAR_EXP   4
 
#define STAT_BAR_FOOD   3
 
#define STAT_BAR_GRACE   2
 
#define STAT_BAR_HP   0
 
#define STAT_BAR_SP   1
 
#define STYLE_GRAD_LOW   4
 
#define STYLE_GRAD_NORMAL   3
 
#define STYLE_GRAD_SUPER   5
 
#define STYLE_LOW   1
 
#define STYLE_NORMAL   0
 
#define STYLE_SUPER   2
 

Functions

void clear_stat_mapping ()
 
void draw_message_window (int redraw)
 Updates the stats pane - hp, sp, etc labels. More...
 
void draw_stats (int redraw)
 Draws the stats window. More...
 
static void format_si_number (gint64 number, char *buffer, int limit)
 Format an integer using an appropriate SI prefix. More...
 
static int mapping_sort (NameMapping *a, NameMapping *b)
 The mapping tables may not be completely full, so handle null values. More...
 
void stats_get_styles (void)
 Gets the style information for the stat bars (only portion of the window right now that has custom style support. More...
 
void stats_init (GtkWidget *window_root)
 Associate the XML-defined widgets with pointers by name reference. More...
 
void update_stat (int stat_no, gint64 max_stat, gint64 current_stat, gint64 statbar_max, gint64 statbar_stat, int can_alert)
 Updates the stat bar and text display as it pertains to a specific stat. More...
 
static void update_stat_mapping (void)
 

Variables

GdkColor * bar_colors [MAX_STAT_BARS][NUM_STYLES]
 
static int lastmax [MAX_STAT_BARS]
 
static int lastval [MAX_STAT_BARS]
 
static gboolean need_mapping_update
 
static GtkWidget * stat_bar [MAX_STAT_BARS]
 
static const char *const stat_bar_names [MAX_STAT_BARS]
 
static GtkWidget * stat_current [MAX_STAT_BARS]
 
static GtkWidget * stat_max [MAX_STAT_BARS]
 
static const char *const stat_style_names [NUM_STYLES]
 
static StatWindow statwindow
 

Detailed Description

Support for character statistics.

Definition in file stats.c.

Macro Definition Documentation

#define MAX_STAT_BARS   5

Definition at line 36 of file stats.c.

Referenced by stats_get_styles(), and stats_init().

#define NUM_STYLES   6

Definition at line 52 of file stats.c.

Referenced by stats_get_styles().

#define PROTECTION_BOXES_X   6

Definition at line 76 of file stats.c.

Referenced by draw_stats(), and stats_init().

#define PROTECTION_BOXES_Y   6

Definition at line 77 of file stats.c.

Referenced by draw_stats(), and stats_init().

#define SKILL_BOXES_X   6

Definition at line 73 of file stats.c.

Referenced by stats_init().

#define SKILL_BOXES_Y   17

Definition at line 74 of file stats.c.

Referenced by stats_init().

#define STAT_BAR_EXP   4

Definition at line 35 of file stats.c.

Referenced by draw_message_window(), and update_stat().

#define STAT_BAR_FOOD   3

Definition at line 34 of file stats.c.

Referenced by draw_message_window().

#define STAT_BAR_GRACE   2

Definition at line 33 of file stats.c.

Referenced by draw_message_window().

#define STAT_BAR_HP   0

Definition at line 31 of file stats.c.

Referenced by draw_message_window().

#define STAT_BAR_SP   1

Definition at line 32 of file stats.c.

Referenced by draw_message_window().

#define STYLE_GRAD_LOW   4

Definition at line 50 of file stats.c.

Referenced by update_stat().

#define STYLE_GRAD_NORMAL   3

Definition at line 49 of file stats.c.

Referenced by update_stat().

#define STYLE_GRAD_SUPER   5

Definition at line 51 of file stats.c.

Referenced by update_stat().

#define STYLE_LOW   1

Definition at line 47 of file stats.c.

Referenced by update_stat().

#define STYLE_NORMAL   0

Definition at line 46 of file stats.c.

Referenced by update_stat().

#define STYLE_SUPER   2

Definition at line 48 of file stats.c.

Referenced by update_stat().

Function Documentation

void clear_stat_mapping ( void  )

Definition at line 782 of file stats.c.

References need_mapping_update.

Referenced by main().

Here is the caller graph for this function:

void draw_message_window ( int  redraw)

Updates the stats pane - hp, sp, etc labels.

Parameters
redraw

Definition at line 471 of file stats.c.

References CONFIG_FOODBEEP, cpl, Stat_struct::exp, exp_table, exp_table_max, Stat_struct::food, Stat_struct::grace, Stat_struct::hp, Stat_struct::level, Stat_struct::maxgrace, Stat_struct::maxhp, Stat_struct::maxsp, Stat_struct::sp, STAT_BAR_EXP, STAT_BAR_FOOD, STAT_BAR_GRACE, STAT_BAR_HP, STAT_BAR_SP, Player_Struct::stats, update_stat(), and use_config.

Referenced by configure_keys(), load_theme(), and StatsCmd().

Here is the call graph for this function:

Here is the caller graph for this function:

void draw_stats ( int  redraw)
static void format_si_number ( gint64  number,
char *  buffer,
int  limit 
)
static

Format an integer using an appropriate SI prefix.

Parameters
numberNumber to format
bufferPointer to a string to store the formatted number
limitSize of the buffer

Definition at line 258 of file stats.c.

Referenced by update_stat().

Here is the caller graph for this function:

static int mapping_sort ( NameMapping a,
NameMapping b 
)
static

The mapping tables may not be completely full, so handle null values.

Always treat null values as later in the sort order.

Definition at line 515 of file stats.c.

References NameMapping::name.

Referenced by update_stat_mapping().

Here is the caller graph for this function:

void stats_get_styles ( void  )

Gets the style information for the stat bars (only portion of the window right now that has custom style support.

Definition at line 114 of file stats.c.

References bar_colors, has_init, LOG(), LOG_INFO, MAX_BUF, MAX_STAT_BARS, NUM_STYLES, stat_bar, stat_bar_names, and stat_style_names.

Referenced by load_theme().

Here is the call graph for this function:

Here is the caller graph for this function:

void stats_init ( GtkWidget *  window_root)
void update_stat ( int  stat_no,
gint64  max_stat,
gint64  current_stat,
gint64  statbar_max,
gint64  statbar_stat,
int  can_alert 
)

Updates the stat bar and text display as it pertains to a specific stat.

Parameters
stat_noThe stat number to update.
max_statThe normal maximum value this stat can have. Note that within game terms, the actual value can go above this via supercharging stats.
current_statcurrent value of the stat.
statbar_max
statbar_statthis is the stat value to use for drawing the statbar. For most stats, this is same as current stat, but for the exp bar, we basically want it to be a graph relative to amount for next level.
can_alertWhether this stat can go on alert when it gets low. It doesn't make sense for this to happen on exp (not really an alert if you gain a level). Note: This is no longer used with the new style code - if a stat shouldn't ever change color when it is low, the style should dictate that.

Definition at line 307 of file stats.c.

References bar_colors, CONFIG_GRAD_COLOR, format_si_number(), lastmax, lastval, stat_bar, STAT_BAR_EXP, stat_current, stat_max, STYLE_GRAD_LOW, STYLE_GRAD_NORMAL, STYLE_GRAD_SUPER, STYLE_LOW, STYLE_NORMAL, STYLE_SUPER, and use_config.

Referenced by draw_message_window().

Here is the call graph for this function:

Here is the caller graph for this function:

static void update_stat_mapping ( void  )
static

Definition at line 533 of file stats.c.

References mapping_sort(), MAX_SKILL, NameMapping::name, need_mapping_update, NUM_RESISTS, resist_mapping, resists_name, skill_mapping, skill_names, and NameMapping::value.

Referenced by draw_stats().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

GdkColor* bar_colors[MAX_STAT_BARS][NUM_STYLES]

Definition at line 66 of file stats.c.

Referenced by stats_get_styles(), and update_stat().

int lastmax[MAX_STAT_BARS]
static

Definition at line 108 of file stats.c.

Referenced by stats_init(), and update_stat().

int lastval[MAX_STAT_BARS]
static

Definition at line 108 of file stats.c.

Referenced by stats_init(), and update_stat().

gboolean need_mapping_update
static

Definition at line 106 of file stats.c.

Referenced by clear_stat_mapping(), draw_stats(), and update_stat_mapping().

GtkWidget* stat_bar[MAX_STAT_BARS]
static

Definition at line 44 of file stats.c.

Referenced by stats_get_styles(), stats_init(), and update_stat().

const char* const stat_bar_names[MAX_STAT_BARS]
static
Initial value:
= {
"hp", "sp", "grace", "food", "exp"
}

Definition at line 38 of file stats.c.

Referenced by stats_get_styles(), and stats_init().

GtkWidget* stat_current[MAX_STAT_BARS]
static

Definition at line 42 of file stats.c.

Referenced by stats_init(), and update_stat().

GtkWidget* stat_max[MAX_STAT_BARS]
static

Definition at line 43 of file stats.c.

Referenced by stats_init(), and update_stat().

const char* const stat_style_names[NUM_STYLES]
static
Initial value:
= {
"bar_normal", "bar_low", "bar_super",
"gradual_bar_normal", "gradual_bar_low", "gradual_bar_super"
}

Definition at line 58 of file stats.c.

Referenced by stats_get_styles().

StatWindow statwindow
static

Definition at line 104 of file stats.c.