Crossfire Client, Branch  R11627
Data Structures | Defines | Functions | Variables
stats.c File Reference

Support for character statistics. More...

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

Go to the source code of this file.

Data Structures

struct  NameMapping
struct  StatWindow

Defines

#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)
void draw_message_window (int redraw)
 Updates the stats pain - hp, sp, etc labels.
void draw_stats (int redraw)
 Draws the stats window.
static int mapping_sort (NameMapping *a, NameMapping *b)
 The mapping tables may not be completely full, so handle null values.
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.
void stats_init (GtkWidget *window_root)
void update_stat (int stat_no, sint64 max_stat, sint64 current_stat, sint64 statbar_max, sint64 statbar_stat, const char *name, int can_alert)
 Updates the stat bar and text display as it pertains to a specific stat.
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]
int need_mapping_update = 1
const char *const rcsid_gtk2_stats_c = "$Id: stats.c 9201 2008-06-01 17:32:45Z anmaster $"
NameMapping resist_mapping [NUM_RESISTS]
NameMapping skill_mapping [MAX_SKILL]
GtkWidget * stat_bar [MAX_STAT_BARS]
static const char *const stat_bar_names [MAX_STAT_BARS]
GtkWidget * stat_label [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.


Define Documentation

#define MAX_STAT_BARS   5

Definition at line 47 of file stats.c.

Referenced by stats_get_styles(), and stats_init().

#define NUM_STYLES   6

Definition at line 60 of file stats.c.

Referenced by stats_get_styles().

#define PROTECTION_BOXES_X   6

Definition at line 86 of file stats.c.

Referenced by draw_stats(), and stats_init().

#define PROTECTION_BOXES_Y   6

Definition at line 87 of file stats.c.

Referenced by draw_stats(), and stats_init().

#define SKILL_BOXES_X   6

Definition at line 83 of file stats.c.

Referenced by stats_init().

#define SKILL_BOXES_Y   17

Definition at line 84 of file stats.c.

Referenced by stats_init().

#define STAT_BAR_EXP   4

Definition at line 46 of file stats.c.

#define STAT_BAR_FOOD   3

Definition at line 45 of file stats.c.

#define STAT_BAR_GRACE   2

Definition at line 44 of file stats.c.

#define STAT_BAR_HP   0

Definition at line 42 of file stats.c.

#define STAT_BAR_SP   1

Definition at line 43 of file stats.c.

#define STYLE_GRAD_LOW   4

Definition at line 58 of file stats.c.

Referenced by update_stat().

#define STYLE_GRAD_NORMAL   3

Definition at line 57 of file stats.c.

Referenced by update_stat().

#define STYLE_GRAD_SUPER   5

Definition at line 59 of file stats.c.

Referenced by update_stat().

#define STYLE_LOW   1

Definition at line 55 of file stats.c.

Referenced by update_stat().

#define STYLE_NORMAL   0

Definition at line 54 of file stats.c.

Referenced by update_stat().

#define STYLE_SUPER   2

Definition at line 56 of file stats.c.

Referenced by update_stat().


Function Documentation

void clear_stat_mapping ( void  )

Definition at line 725 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 pain - hp, sp, etc labels.

Parameters:
redraw

Definition at line 437 of file stats.c.

References CONFIG_FOODBEEP, cpl, Stat_struct::exp, exp_table, exp_table_max, FALSE, Stat_struct::food, Stat_struct::grace, Stat_struct::hp, Stat_struct::level, Stat_struct::maxgrace, Stat_struct::maxhp, Stat_struct::maxsp, Stat_struct::sp, Player_Struct::stats, TRUE, update_stat(), and use_config.

Here is the call graph for this function:

void draw_stats ( int  redraw)
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 480 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 139 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(), and stats_init().

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,
sint64  max_stat,
sint64  current_stat,
sint64  statbar_max,
sint64  statbar_stat,
const char *  name,
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.
namePrintable name of the stat.
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 292 of file stats.c.

References bar_colors, CONFIG_GRAD_COLOR, lastmax, lastval, stat_bar, stat_label, 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 caller graph for this function:

static void update_stat_mapping ( void  ) [static]

Definition at line 491 of file stats.c.

References mapping_sort(), MAX_SKILL, NameMapping::name, need_mapping_update, NUM_RESISTS, resists_name, 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

Definition at line 75 of file stats.c.

Referenced by stats_get_styles(), and update_stat().

int lastmax[MAX_STAT_BARS] [static]

Definition at line 133 of file stats.c.

Referenced by stats_init(), and update_stat().

int lastval[MAX_STAT_BARS] [static]

Definition at line 133 of file stats.c.

Referenced by stats_init(), and update_stat().

Definition at line 131 of file stats.c.

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

const char* const rcsid_gtk2_stats_c = "$Id: stats.c 9201 2008-06-01 17:32:45Z anmaster $"

Definition at line 1 of file stats.c.

Definition at line 129 of file stats.c.

Definition at line 129 of file stats.c.

GtkWidget * stat_bar[MAX_STAT_BARS]

Definition at line 52 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 48 of file stats.c.

Referenced by stats_get_styles(), and stats_init().

Definition at line 52 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 66 of file stats.c.

Referenced by stats_get_styles().

Definition at line 114 of file stats.c.