Crossfire Client, Trunk
Classes | Macros | Functions | Variables
stats.c File Reference
#include "client.h"
#include <assert.h>
#include <gtk/gtk.h>
#include "main.h"
#include "image.h"
#include "gtk2proto.h"
Include dependency graph for stats.c:

Go to the source code of this file.

Classes

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)
 
void draw_stats (int redraw)
 
static char * format_si_number (gint64 number)
 
static int mapping_sort (NameMapping *a, NameMapping *b)
 
void stats_get_styles (void)
 
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)
 
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 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

◆ MAX_STAT_BARS

#define MAX_STAT_BARS   5

Definition at line 33 of file stats.c.

◆ NUM_STYLES

#define NUM_STYLES   6

Definition at line 47 of file stats.c.

◆ PROTECTION_BOXES_X

#define PROTECTION_BOXES_X   6

Definition at line 71 of file stats.c.

◆ PROTECTION_BOXES_Y

#define PROTECTION_BOXES_Y   6

Definition at line 72 of file stats.c.

◆ SKILL_BOXES_X

#define SKILL_BOXES_X   6

Definition at line 68 of file stats.c.

◆ SKILL_BOXES_Y

#define SKILL_BOXES_Y   17

Definition at line 69 of file stats.c.

◆ STAT_BAR_EXP

#define STAT_BAR_EXP   4

Definition at line 32 of file stats.c.

◆ STAT_BAR_FOOD

#define STAT_BAR_FOOD   3

Definition at line 31 of file stats.c.

◆ STAT_BAR_GRACE

#define STAT_BAR_GRACE   2

Definition at line 30 of file stats.c.

◆ STAT_BAR_HP

#define STAT_BAR_HP   0

Definition at line 28 of file stats.c.

◆ STAT_BAR_SP

#define STAT_BAR_SP   1

Definition at line 29 of file stats.c.

◆ STYLE_GRAD_LOW

#define STYLE_GRAD_LOW   4

Definition at line 45 of file stats.c.

◆ STYLE_GRAD_NORMAL

#define STYLE_GRAD_NORMAL   3

Definition at line 44 of file stats.c.

◆ STYLE_GRAD_SUPER

#define STYLE_GRAD_SUPER   5

Definition at line 46 of file stats.c.

◆ STYLE_LOW

#define STYLE_LOW   1

Definition at line 42 of file stats.c.

◆ STYLE_NORMAL

#define STYLE_NORMAL   0

Definition at line 41 of file stats.c.

◆ STYLE_SUPER

#define STYLE_SUPER   2

Definition at line 43 of file stats.c.

Function Documentation

◆ clear_stat_mapping()

void clear_stat_mapping ( )

Definition at line 771 of file stats.c.

References need_mapping_update.

Referenced by show_main_client().

Here is the caller graph for this function:

◆ draw_message_window()

void draw_message_window ( int  redraw)

Updates the stats pane - hp, sp, etc labels

Parameters
redraw

Definition at line 459 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:

◆ draw_stats()

void draw_stats ( int  redraw)

◆ format_si_number()

static char* format_si_number ( gint64  number)
static

Format an integer using an appropriate SI prefix.

Parameters
numberNumber to format
Returns
A newly-allocated string with the formatted number

Definition at line 243 of file stats.c.

Referenced by update_stat().

Here is the caller graph for this function:

◆ mapping_sort()

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 503 of file stats.c.

References NameMapping::name.

Referenced by update_stat_mapping().

Here is the caller graph for this function:

◆ stats_get_styles()

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 109 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:

◆ stats_init()

void stats_init ( GtkWidget *  window_root)

◆ update_stat()

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 291 of file stats.c.

References bar_colors, CONFIG_GRAD_COLOR, format_si_number(), lastmax, lastval, stat_bar, STAT_BAR_EXP, 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:

◆ update_stat_mapping()

static void update_stat_mapping ( void  )
static

Definition at line 521 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

◆ bar_colors

GdkColor* bar_colors[MAX_STAT_BARS][NUM_STYLES]

Definition at line 61 of file stats.c.

Referenced by stats_get_styles(), and update_stat().

◆ lastmax

int lastmax[MAX_STAT_BARS]
static

Definition at line 103 of file stats.c.

Referenced by stats_init(), and update_stat().

◆ lastval

int lastval[MAX_STAT_BARS]
static

Definition at line 103 of file stats.c.

Referenced by stats_init(), and update_stat().

◆ need_mapping_update

gboolean need_mapping_update
static

Definition at line 101 of file stats.c.

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

◆ stat_bar

GtkWidget* stat_bar[MAX_STAT_BARS]
static

Definition at line 39 of file stats.c.

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

◆ stat_bar_names

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

Definition at line 35 of file stats.c.

Referenced by stats_get_styles(), and stats_init().

◆ stat_style_names

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 53 of file stats.c.

Referenced by stats_get_styles().

◆ statwindow

StatWindow statwindow
static

Definition at line 99 of file stats.c.

Referenced by draw_stats(), and stats_init().