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

Go to the source code of this file.

Macros

#define CLASS_OPT_ENG   NUM_OPT_FIELDS - 1
 
#define CLASS_OPT_START   NUM_OPT_FIELDS/2
 
#define NUM_OPT_FIELDS   6
 
#define RACE_OPT_END   CLASS_OPT_START - 1
 
#define RACE_OPT_START   0
 
#define STARTING_MAP_PANE   0
 
#define WINDOW_CHOOSE_MAP   2
 
#define WINDOW_CREATE_CHARACTER   1
 
#define WINDOW_NONE   0
 

Functions

static int character_data_ok ()
 
static void create_character_set_sensitive (int sensitive)
 
void create_character_window_hide ()
 
void create_character_window_show ()
 
void init_create_character_window ()
 
void new_char_window_update_info ()
 
void on_button_cc_cancel (GtkButton *button, gpointer user_data)
 
void on_button_cc_done (GtkButton *button, gpointer user_data)
 
void on_button_choose_starting_map (GtkButton *button, gpointer user_data)
 
void on_button_csm_cancel (GtkButton *button, gpointer user_data)
 
void on_combobox_rcs_changed (GtkComboBox *box, gpointer user_data)
 
void on_combobox_starting_map_changed (GtkComboBox *box, gpointer user_data)
 
void on_spinbutton_cc (GtkSpinButton *spinbutton, gpointer user_data)
 
static void send_create_player_to_server ()
 
static void show_window (int window)
 
void starting_map_update_info ()
 
static void update_all_stats ()
 

Variables

static GtkWidget * button_cc_cancel
 
static GtkWidget * button_choose_starting_map
 
static GtkWidget * button_csm_cancel
 
static GtkWidget * button_csm_done
 
static GtkWidget * choose_starting_map_window
 
static GtkWidget * combobox_cs
 
static GtkWidget * combobox_rs
 
static GtkWidget * combobox_starting_map
 
Info_Pane create_char_pane [1]
 
static GtkWidget * create_character_window
 
static GtkWidget * entry_new_character_name
 
static int has_init =0
 
static GtkWidget * label_cc_desc
 
static GtkWidget * label_cc_status_update
 
static GtkWidget * label_cc_unspent
 
static GtkWidget * label_cs [NUM_NEW_CHAR_STATS]
 
static GtkWidget * label_rs [NUM_NEW_CHAR_STATS]
 
static GtkWidget * label_tot [NUM_NEW_CHAR_STATS]
 
static int negative_stat =0
 
static GtkWidget * opt_combobox [NUM_OPT_FIELDS]
 
static GtkWidget * opt_label [NUM_OPT_FIELDS]
 
static GtkWidget * spinbutton_cc [NUM_NEW_CHAR_STATS]
 
static GtkTextMark * text_mark_cs
 
static GtkTextMark * text_mark_rs
 
GtkTextBuffer * textbuf_starting_map
 
static GtkWidget * textview_cs_desc
 
static GtkWidget * textview_rs_desc
 

Detailed Description

Handle new character creation

Definition in file create_char.c.

Macro Definition Documentation

◆ CLASS_OPT_ENG

#define CLASS_OPT_ENG   NUM_OPT_FIELDS - 1

Definition at line 47 of file create_char.c.

◆ CLASS_OPT_START

#define CLASS_OPT_START   NUM_OPT_FIELDS/2

Definition at line 45 of file create_char.c.

Referenced by on_combobox_rcs_changed(), and send_create_player_to_server().

◆ NUM_OPT_FIELDS

#define NUM_OPT_FIELDS   6

Definition at line 43 of file create_char.c.

Referenced by init_create_character_window(), and on_combobox_rcs_changed().

◆ RACE_OPT_END

#define RACE_OPT_END   CLASS_OPT_START - 1

Definition at line 46 of file create_char.c.

◆ RACE_OPT_START

#define RACE_OPT_START   0

Definition at line 44 of file create_char.c.

Referenced by on_combobox_rcs_changed(), and send_create_player_to_server().

◆ STARTING_MAP_PANE

#define STARTING_MAP_PANE   0

Definition at line 68 of file create_char.c.

Referenced by init_create_character_window(), and on_combobox_starting_map_changed().

◆ WINDOW_CHOOSE_MAP

#define WINDOW_CHOOSE_MAP   2

Definition at line 73 of file create_char.c.

Referenced by character_data_ok(), on_button_choose_starting_map(), and show_window().

◆ WINDOW_CREATE_CHARACTER

#define WINDOW_CREATE_CHARACTER   1

◆ WINDOW_NONE

#define WINDOW_NONE   0

Definition at line 71 of file create_char.c.

Referenced by create_character_window_hide(), on_button_cc_cancel(), and show_window().

Function Documentation

◆ character_data_ok()

static int character_data_ok ( )
static

This checks the various spin buttons, combox boxes, etc to make sure everything that should be set has been set, and in the case of attributes, that they are within range. This will show/hide the relevant window and throw up dialog windows if necessary

Returns
TRUE if everything checks out, FALSE if not.

Definition at line 396 of file create_char.c.

References choose_starting_map_window, combobox_starting_map, create_character_window, entry_new_character_name, label_cc_status_update, negative_stat, NUM_NEW_CHAR_STATS, show_window(), spinbutton_cc, starting_map_number, stat_points, WINDOW_CHOOSE_MAP, and WINDOW_CREATE_CHARACTER.

Referenced by on_button_cc_done().

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

◆ create_character_set_sensitive()

static void create_character_set_sensitive ( int  sensitive)
static

This function makes the widgets in the window sensitive (or not). This is used because having the player fiddle with the attributes before we get the information from the server doesn't make sense.

Parameters
sensitivepassed to gtk_widget_set_sensitive, to either make the widget sensitive or not

Definition at line 119 of file create_char.c.

References button_choose_starting_map, combobox_cs, combobox_rs, entry_new_character_name, NUM_NEW_CHAR_STATS, spinbutton_cc, and starting_map_number.

Referenced by create_character_window_show(), and new_char_window_update_info().

+ Here is the caller graph for this function:

◆ create_character_window_hide()

void create_character_window_hide ( )

Basically opposite as above - hide the create character windows - this is called from hide_all_login_windows(), which is called when the client gets an addme success command.

Definition at line 195 of file create_char.c.

References show_window(), and WINDOW_NONE.

Referenced by hide_all_login_windows().

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

◆ create_character_window_show()

void create_character_window_show ( )

This function is here so that other files, in particular account.c:on_button_create_character_clicked() can pop up this window. This function also requests necessary data from server if we don't already have it.

Definition at line 152 of file create_char.c.

References classes, create_character_set_sensitive(), create_character_window, cs_print_string(), csocket, ClientSocket::fd, label_cc_status_update, races, and stat_points.

Referenced by on_button_create_character_clicked().

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

◆ init_create_character_window()

◆ new_char_window_update_info()

void new_char_window_update_info ( )

We have gotten some new information from the server, so we need to update the information - race/class choices or stat points/min stat/max stat information.

Definition at line 633 of file create_char.c.

References classes, combobox_cs, combobox_rs, create_character_set_sensitive(), label_cc_status_update, label_cc_unspent, num_classes, NUM_NEW_CHAR_STATS, num_races, on_combobox_rcs_changed(), races, spinbutton_cc, stat_maximum, stat_min, stat_points, used_classes, and used_races.

Referenced by get_class_info(), get_new_char_info(), and get_race_info().

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

◆ on_button_cc_cancel()

void on_button_cc_cancel ( GtkButton *  button,
gpointer  user_data 
)

User has hit the 'return to character selection' button - basically meaning that we have to hide the current window and show the choose_char_window.

Parameters
buttonignored
user_dataignored

Definition at line 365 of file create_char.c.

References choose_char_window_show(), show_window(), and WINDOW_NONE.

Referenced by init_create_character_window().

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

◆ on_button_cc_done()

void on_button_cc_done ( GtkButton *  button,
gpointer  user_data 
)

User has hit the done button. Need to verify input, and if it looks good, send it to the server. Note: This callback is used for the 'Done' button in both the character character window and starting map window.

Parameters
buttonignored
user_dataignored

Definition at line 496 of file create_char.c.

References character_data_ok(), label_cc_status_update, send_create_player_to_server(), show_main_client(), show_window(), and WINDOW_CREATE_CHARACTER.

Referenced by init_create_character_window().

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

◆ on_button_choose_starting_map()

void on_button_choose_starting_map ( GtkButton *  button,
gpointer  user_data 
)

User has hit the choose starting map button. Not much to do, other than make that window visible

Parameters
buttonignored
user_dataignored

Definition at line 380 of file create_char.c.

References show_window(), and WINDOW_CHOOSE_MAP.

Referenced by init_create_character_window().

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

◆ on_button_csm_cancel()

void on_button_csm_cancel ( GtkButton *  button,
gpointer  user_data 
)

User has hit the 'return to character creation' button - basically meaning that we have to hide the current window and show the create_character_window.

Parameters
buttonignored
user_dataignored

Definition at line 721 of file create_char.c.

References show_window(), and WINDOW_CREATE_CHARACTER.

Referenced by init_create_character_window().

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

◆ on_combobox_rcs_changed()

void on_combobox_rcs_changed ( GtkComboBox *  box,
gpointer  user_data 
)

User has changed one of the fields in the race/class combobox. Since the logic for the two is somewhat the same, we use one function to handle the event - as such, we really need to pay attention to what box is set to.

Parameters
boxThe combobox that generated the event.
user_dataignored

Definition at line 534 of file create_char.c.

References RC_Choice::choice_desc, CLASS_OPT_START, classes, combobox_cs, combobox_rs, label_cs, label_rs, LOG(), LOG_ERROR, NUM_NEW_CHAR_STATS, NUM_OPT_FIELDS, Race_Class_Info::num_rc_choice, RC_Choice::num_values, opt_combobox, opt_label, RACE_OPT_START, races, Race_Class_Info::rc_choice, Stat_Mapping::rc_offset, Race_Class_Info::stat_adj, stat_mapping, text_mark_cs, text_mark_rs, textview_cs_desc, textview_rs_desc, update_all_stats(), and RC_Choice::value_desc.

Referenced by new_char_window_update_info().

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

◆ on_combobox_starting_map_changed()

void on_combobox_starting_map_changed ( GtkComboBox *  box,
gpointer  user_data 
)

Definition at line 728 of file create_char.c.

References add_marked_text_to_pane(), starting_map_info, STARTING_MAP_PANE, and textbuf_starting_map.

Referenced by starting_map_update_info().

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

◆ on_spinbutton_cc()

void on_spinbutton_cc ( GtkSpinButton *  spinbutton,
gpointer  user_data 
)

User has changed one of the spinbutton values. We need to total back up the values.

Definition at line 515 of file create_char.c.

References update_all_stats().

Referenced by init_create_character_window().

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

◆ send_create_player_to_server()

◆ show_window()

static void show_window ( int  window)
static

This is a little helper window which shows the window specified and hides the other window(s). This is just a bit cleaner than having a bunch if gtk_widget_show()/ gtk_wdiget_hide() calls. Also, if more than 2 windows are ever used, this will also make it easier to make sure the correct window is displayed.

Parameters
windowWINDOW_... define as listed at top of this file which defines the winow. Special is WINDOW_NONE, which will just result in this hiding all windows.

Definition at line 88 of file create_char.c.

References choose_starting_map_window, create_character_window, WINDOW_CHOOSE_MAP, WINDOW_CREATE_CHARACTER, and WINDOW_NONE.

Referenced by character_data_ok(), create_character_window_hide(), on_button_cc_cancel(), on_button_cc_done(), on_button_choose_starting_map(), and on_button_csm_cancel().

+ Here is the caller graph for this function:

◆ starting_map_update_info()

void starting_map_update_info ( )

We have gotten starting map information from the server - now update the combo boxes.

Definition at line 753 of file create_char.c.

References button_choose_starting_map, combobox_starting_map, on_combobox_starting_map_changed(), starting_map_info, and starting_map_number.

Referenced by get_starting_map_info().

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

◆ update_all_stats()

static void update_all_stats ( )
static

Whenever something in the window changes, this is called to update everything - in the case of most any value, we need to recalculate everything - trying to do a delta from the old to new is probably more effort than it is worth and is more prone to errors.

Definition at line 206 of file create_char.c.

References label_cc_status_update, label_cc_unspent, label_cs, label_rs, label_tot, MAX_BUF, negative_stat, NUM_NEW_CHAR_STATS, spinbutton_cc, and stat_points.

Referenced by on_combobox_rcs_changed(), and on_spinbutton_cc().

+ Here is the caller graph for this function:

Variable Documentation

◆ button_cc_cancel

GtkWidget * button_cc_cancel
static

Definition at line 51 of file create_char.c.

Referenced by init_create_character_window().

◆ button_choose_starting_map

GtkWidget * button_choose_starting_map
static

◆ button_csm_cancel

GtkWidget * button_csm_cancel
static

Definition at line 61 of file create_char.c.

Referenced by init_create_character_window().

◆ button_csm_done

GtkWidget * button_csm_done
static

Definition at line 61 of file create_char.c.

Referenced by init_create_character_window().

◆ choose_starting_map_window

GtkWidget* choose_starting_map_window
static

Definition at line 61 of file create_char.c.

Referenced by character_data_ok(), init_create_character_window(), and show_window().

◆ combobox_cs

◆ combobox_rs

◆ combobox_starting_map

GtkWidget * combobox_starting_map
static

◆ create_char_pane

Info_Pane create_char_pane[1]

Definition at line 69 of file create_char.c.

◆ create_character_window

GtkWidget * create_character_window
static

◆ entry_new_character_name

GtkWidget * entry_new_character_name
static

◆ has_init

int has_init =0
static

Definition at line 66 of file create_char.c.

Referenced by init_create_character_window().

◆ label_cc_desc

GtkWidget * label_cc_desc
static

Definition at line 51 of file create_char.c.

Referenced by init_create_character_window().

◆ label_cc_status_update

◆ label_cc_unspent

GtkWidget * label_cc_unspent
static

◆ label_cs

GtkWidget * label_cs[NUM_NEW_CHAR_STATS]
static

◆ label_rs

GtkWidget * label_rs[NUM_NEW_CHAR_STATS]
static

◆ label_tot

GtkWidget * label_tot[NUM_NEW_CHAR_STATS]
static

Definition at line 51 of file create_char.c.

Referenced by init_create_character_window(), and update_all_stats().

◆ negative_stat

int negative_stat =0
static

Definition at line 66 of file create_char.c.

Referenced by character_data_ok(), and update_all_stats().

◆ opt_combobox

GtkWidget * opt_combobox[NUM_OPT_FIELDS]
static

◆ opt_label

GtkWidget * opt_label[NUM_OPT_FIELDS]
static

Definition at line 51 of file create_char.c.

Referenced by init_create_character_window(), and on_combobox_rcs_changed().

◆ spinbutton_cc

◆ text_mark_cs

GtkTextMark* text_mark_cs
static

Definition at line 58 of file create_char.c.

Referenced by init_create_character_window(), and on_combobox_rcs_changed().

◆ text_mark_rs

GtkTextMark * text_mark_rs
static

Definition at line 58 of file create_char.c.

Referenced by init_create_character_window(), and on_combobox_rcs_changed().

◆ textbuf_starting_map

GtkTextBuffer* textbuf_starting_map

Definition at line 64 of file create_char.c.

Referenced by init_create_character_window(), and on_combobox_starting_map_changed().

◆ textview_cs_desc

GtkWidget * textview_cs_desc
static

Definition at line 51 of file create_char.c.

Referenced by init_create_character_window(), and on_combobox_rcs_changed().

◆ textview_rs_desc

GtkWidget * textview_rs_desc
static

Definition at line 51 of file create_char.c.

Referenced by init_create_character_window(), and on_combobox_rcs_changed().