mirror of
https://github.com/tstellar/bygfoot.git
synced 2025-03-12 08:40:08 +01:00
Load team stuff
This commit is contained in:
parent
27a374f226
commit
f00c9357b7
@ -28,6 +28,7 @@ bygfoot_init(Bygfoot *bygfoot, enum BygfootFrontend frontend,
|
||||
case BYGFOOT_BACKEND_FILESYSTEM:
|
||||
bygfoot->get_country_list = file_get_country_files;
|
||||
bygfoot->load_bygfoot = bygfoot_filesystem_load_bygfoot;
|
||||
bygfoot->load_country = bygfoot_filesystem_load_country;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -90,8 +91,7 @@ bygfoot_set_id(Bygfoot *bygfoot, const gchar *id)
|
||||
|
||||
Country *bygfoot_load_country(Bygfoot *bygfoot, const gchar *country_name)
|
||||
{
|
||||
xml_country_read(country_name, NULL);
|
||||
return &country;
|
||||
return bygfoot->load_country(bygfoot, country_name);
|
||||
}
|
||||
|
||||
User *bygfoot_add_user(Bygfoot *bygfoot, const gchar *username, Team *tm)
|
||||
|
@ -149,7 +149,7 @@ enum ReservePromRules
|
||||
/**
|
||||
* A struct representing a country.
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct country
|
||||
{
|
||||
gchar *name, /**< Name of the country. */
|
||||
*symbol, /**< Symbol of the country, eg a flag pixmap. */
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
struct country;
|
||||
|
||||
enum BygfootFrontend {
|
||||
|
||||
BYGFOOT_FRONTEND_NONE,
|
||||
@ -41,8 +43,9 @@ typedef struct bygfoot
|
||||
* <Continent>/<...>/<country>
|
||||
*/
|
||||
GPtrArray *(*get_country_list)(const struct bygfoot *);
|
||||
void (*load_bygfoot)(const struct bygfoot *, const gchar *);
|
||||
void (*load_bygfoot)(struct bygfoot *, const gchar *);
|
||||
gboolean (*is_bygfoot_id_unique)(struct bygfoot *, const gchar *);
|
||||
struct country *(*load_country)(struct bygfoot *, const gchar *);
|
||||
/* @} */
|
||||
} Bygfoot;
|
||||
|
||||
|
@ -149,11 +149,12 @@ G_MODULE_EXPORT void
|
||||
on_button_load_clicked (GtkButton *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
Bygfoot *bygfoot = (Bygfoot*)user_data;
|
||||
#ifdef DEBUG
|
||||
printf("on_button_load_clicked\n");
|
||||
#endif
|
||||
|
||||
on_menu_open_activate(NULL, NULL);
|
||||
on_menu_open_activate(NULL, bygfoot);
|
||||
}
|
||||
|
||||
|
||||
@ -561,11 +562,12 @@ G_MODULE_EXPORT void
|
||||
on_menu_load_last_save_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
Bygfoot *bygfoot = (Bygfoot*)user_data;
|
||||
#ifdef DEBUG
|
||||
printf("on_menu_load_last_save_activate\n");
|
||||
#endif
|
||||
|
||||
if(load_save_load_game("last_save", FALSE))
|
||||
if(load_save_load_game("last_save", FALSE, bygfoot))
|
||||
{
|
||||
cur_user = 0;
|
||||
on_button_back_to_main_clicked(NULL, NULL);
|
||||
@ -595,12 +597,13 @@ G_MODULE_EXPORT void
|
||||
on_menu_open_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
Bygfoot *bygfoot = (Bygfoot*)user_data;
|
||||
#ifdef DEBUG
|
||||
printf("on_menu_open_activate\n");
|
||||
#endif
|
||||
|
||||
stat5 = STATUS_LOAD_GAME;
|
||||
window_show_file_sel();
|
||||
window_show_file_sel(bygfoot);
|
||||
}
|
||||
|
||||
|
||||
@ -624,12 +627,13 @@ G_MODULE_EXPORT void
|
||||
on_menu_save_as_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
Bygfoot *bygfoot = (Bygfoot*)user_data;
|
||||
#ifdef DEBUG
|
||||
printf("on_menu_save_as_activate\n");
|
||||
#endif
|
||||
|
||||
stat5 = STATUS_SAVE_GAME;
|
||||
window_show_file_sel();
|
||||
window_show_file_sel(bygfoot);
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT void
|
||||
@ -1600,6 +1604,7 @@ G_MODULE_EXPORT void
|
||||
on_mm_add_last_match_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
Bygfoot *bygfoot = (Bygfoot*)user_data;
|
||||
#ifdef DEBUG
|
||||
printf("on_mm_add_last_match_activate\n");
|
||||
#endif
|
||||
@ -1613,7 +1618,7 @@ on_mm_add_last_match_activate (GtkMenuItem *menuitem,
|
||||
if(current_user.mmatches_file == NULL)
|
||||
{
|
||||
stat5 = STATUS_SELECT_MM_FILE_ADD;
|
||||
window_show_file_sel();
|
||||
window_show_file_sel(bygfoot);
|
||||
}
|
||||
else
|
||||
user_mm_add_last_match(FALSE, TRUE);
|
||||
@ -1624,6 +1629,7 @@ G_MODULE_EXPORT void
|
||||
on_mm_manage_matches_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
Bygfoot *bygfoot = (Bygfoot*)user_data;
|
||||
#ifdef DEBUG
|
||||
printf("on_mm_manage_matches_activate\n");
|
||||
#endif
|
||||
@ -1631,10 +1637,10 @@ on_mm_manage_matches_activate (GtkMenuItem *menuitem,
|
||||
if(current_user.mmatches_file == NULL)
|
||||
{
|
||||
stat5 = STATUS_SELECT_MM_FILE_LOAD;
|
||||
window_show_file_sel();
|
||||
window_show_file_sel(bygfoot);
|
||||
}
|
||||
else
|
||||
window_show_mmatches();
|
||||
window_show_mmatches(bygfoot);
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,7 +44,7 @@
|
||||
@see #Cup
|
||||
*/
|
||||
Cup
|
||||
cup_new(gboolean new_id)
|
||||
cup_new(gboolean new_id, Bygfoot *bygfoot)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("cup_new\n");
|
||||
@ -78,7 +78,8 @@ cup_new(gboolean new_id)
|
||||
|
||||
new.next_fixture_update_week = -1;
|
||||
new.next_fixture_update_week_round = -1;
|
||||
|
||||
|
||||
new.bygfoot = bygfoot;
|
||||
return new;
|
||||
}
|
||||
|
||||
@ -568,7 +569,7 @@ cup_load_choose_team_generate(Cup *cup, CupRound *cup_round, const CupChooseTeam
|
||||
{
|
||||
if(!query_cup_choose_team_is_league((gchar*)g_ptr_array_index(sids, j)))
|
||||
{
|
||||
xml_league_read((gchar*)g_ptr_array_index(sids, j), leagues);
|
||||
xml_league_read((gchar*)g_ptr_array_index(sids, j), leagues, cup->bygfoot);
|
||||
|
||||
for(k=0; k < g_array_index(leagues, League, leagues->len - 1).teams->len; k++)
|
||||
{
|
||||
|
@ -35,7 +35,7 @@
|
||||
#define cup_get_last_tables(clid) g_array_index(cup_from_clid(clid)->rounds, CupRound, cup_has_tables(clid)).tables
|
||||
|
||||
Cup
|
||||
cup_new(gboolean new_id);
|
||||
cup_new(gboolean new_id, Bygfoot *bygfoot);
|
||||
|
||||
CupChooseTeam
|
||||
cup_choose_team_new(void);
|
||||
|
@ -203,6 +203,8 @@ typedef struct
|
||||
the fixtures of which should be avoided when scheduling
|
||||
the cup fixtures. */
|
||||
GPtrArray *skip_weeks_with;
|
||||
|
||||
Bygfoot *bygfoot;
|
||||
} Cup;
|
||||
|
||||
#endif
|
||||
|
12
src/job.c
12
src/job.c
@ -69,14 +69,14 @@ job_update(Bygfoot *bygfoot)
|
||||
const_float("float_job_international_perc")) : 0;
|
||||
|
||||
for(i=0;i<new_offers - int_offers;i++)
|
||||
job_add_new_national();
|
||||
job_add_new_national(bygfoot);
|
||||
|
||||
job_add_new_international(bygfoot, int_offers);
|
||||
}
|
||||
|
||||
/** Add some new international job offers to the job exchange. */
|
||||
void
|
||||
job_add_new_international(const Bygfoot *bygfoot, gint num_of_new)
|
||||
job_add_new_international(Bygfoot *bygfoot, gint num_of_new)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("job_add_new_international\n");
|
||||
@ -111,7 +111,7 @@ job_add_new_international(const Bygfoot *bygfoot, gint num_of_new)
|
||||
{
|
||||
idx = k;
|
||||
xml_country_read((gchar*)g_ptr_array_index(country_files, rndom),
|
||||
&countries[k]);
|
||||
&countries[k], bygfoot);
|
||||
counters[COUNT_LEAGUE_ID] -= countries[k].leagues->len;
|
||||
k++;
|
||||
}
|
||||
@ -147,6 +147,7 @@ job_add_new_international(const Bygfoot *bygfoot, gint num_of_new)
|
||||
(gint)rint((team_get_average_talent(tm) /
|
||||
league->average_talent) * 100);
|
||||
|
||||
new_job.bygfoot = bygfoot;
|
||||
g_array_append_val(jobs, new_job);
|
||||
}
|
||||
|
||||
@ -179,7 +180,7 @@ job_country_is_in_list(const gchar *country_file,
|
||||
|
||||
/** Add a new national job offer to the job exchange. */
|
||||
void
|
||||
job_add_new_national(void)
|
||||
job_add_new_national(Bygfoot *bygfoot)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("job_add_new_national\n");
|
||||
@ -204,6 +205,7 @@ job_add_new_national(void)
|
||||
(gint)rint((team_get_average_talent(tm) /
|
||||
league->average_talent) * 100);
|
||||
new_job.team_id = tm->id;
|
||||
new_job.bygfoot = bygfoot;
|
||||
|
||||
g_array_append_val(jobs, new_job);
|
||||
}
|
||||
@ -405,7 +407,7 @@ job_change_country(Job *job)
|
||||
|
||||
free_country(&country, TRUE);
|
||||
|
||||
xml_country_read(job->country_file, &country);
|
||||
xml_country_read(job->country_file, &country, job->bygfoot);
|
||||
|
||||
stat5 = STATUS_GENERATE_TEAMS;
|
||||
for(i=0;i<ligs->len;i++)
|
||||
|
@ -36,14 +36,14 @@ void
|
||||
job_update(Bygfoot *bygfoot);
|
||||
|
||||
void
|
||||
job_add_new_international(const Bygfoot *bygfoot, gint num_of_new);
|
||||
job_add_new_international(Bygfoot *bygfoot, gint num_of_new);
|
||||
|
||||
gint
|
||||
job_country_is_in_list(const gchar *country_file,
|
||||
const Country *countries, gint len);
|
||||
|
||||
void
|
||||
job_add_new_national(void);
|
||||
job_add_new_national(Bygfoot *bygfoot);
|
||||
|
||||
gint
|
||||
job_team_is_on_list(gint team_id);
|
||||
|
@ -59,6 +59,8 @@ typedef struct
|
||||
gint talent_percent;
|
||||
/** The id of the team the job describes. */
|
||||
gint team_id;
|
||||
|
||||
Bygfoot *bygfoot;
|
||||
} Job;
|
||||
|
||||
#endif
|
||||
|
@ -43,7 +43,7 @@
|
||||
@see League
|
||||
*/
|
||||
League
|
||||
league_new(gboolean new_id)
|
||||
league_new(gboolean new_id, Bygfoot *bygfoot)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("league_new\n");
|
||||
@ -82,7 +82,8 @@ league_new(gboolean new_id)
|
||||
new.yellow_red = 1000;
|
||||
|
||||
new.stats = stat_league_new("", "");
|
||||
|
||||
|
||||
new.bygfoot = bygfoot;
|
||||
return new;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ typedef struct
|
||||
} MoveSummary;
|
||||
|
||||
League
|
||||
league_new(gboolean new_id);
|
||||
league_new(gboolean new_id, Bygfoot *bygfoot);
|
||||
|
||||
PromRelElement
|
||||
prom_rel_element_new(void);
|
||||
|
@ -193,6 +193,8 @@ typedef struct
|
||||
the fixtures of which should be avoided when scheduling
|
||||
the league fixtures. */
|
||||
GPtrArray *skip_weeks_with;
|
||||
|
||||
Bygfoot *bygfoot;
|
||||
} League;
|
||||
|
||||
#endif
|
||||
|
@ -183,7 +183,8 @@ load_save_save_game(const gchar *filename)
|
||||
/** Load the game from the specified file.
|
||||
@param create_main_window Whether to create and show the main window. */
|
||||
gboolean
|
||||
load_save_load_game(const gchar* filename, gboolean create_main_window)
|
||||
load_save_load_game(const gchar* filename, gboolean create_main_window,
|
||||
Bygfoot *bygfoot)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("load_save_load_game\n");
|
||||
@ -211,7 +212,7 @@ load_save_load_game(const gchar* filename, gboolean create_main_window)
|
||||
|
||||
if(basename != NULL)
|
||||
{
|
||||
load_save_load_game(basename, create_main_window);
|
||||
load_save_load_game(basename, create_main_window, bygfoot);
|
||||
g_free(basename);
|
||||
return TRUE;
|
||||
}
|
||||
@ -252,7 +253,7 @@ load_save_load_game(const gchar* filename, gboolean create_main_window)
|
||||
_("Loading leagues and cups..."),
|
||||
PIC_TYPE_LOAD);
|
||||
|
||||
xml_loadsave_leagues_cups_read(dirname, prefix);
|
||||
xml_loadsave_leagues_cups_read(dirname, prefix, bygfoot);
|
||||
|
||||
if(debug > 60)
|
||||
g_print("load_save_load users \n");
|
||||
@ -449,7 +450,7 @@ load_save_write_autosave_name(gchar *filename)
|
||||
|
||||
/** Try to load a savegame given on the command line. */
|
||||
gboolean
|
||||
load_game_from_command_line(const gchar *filename)
|
||||
load_game_from_command_line(const gchar *filename, Bygfoot *bygfoot)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("load_game_from_command_line\n");
|
||||
@ -459,7 +460,7 @@ load_game_from_command_line(const gchar *filename)
|
||||
*support_file_name = NULL;
|
||||
|
||||
if(strcmp(filename, "last_save") == 0)
|
||||
return load_save_load_game(filename, TRUE);
|
||||
return load_save_load_game(filename, TRUE, bygfoot);
|
||||
|
||||
fullname = (g_str_has_suffix(filename, const_str("string_fs_save_suffix"))) ?
|
||||
g_strdup(filename) :
|
||||
@ -467,7 +468,7 @@ load_game_from_command_line(const gchar *filename)
|
||||
|
||||
if(g_file_test(fullname, G_FILE_TEST_EXISTS))
|
||||
{
|
||||
if(load_save_load_game(fullname, TRUE))
|
||||
if(load_save_load_game(fullname, TRUE, bygfoot))
|
||||
{
|
||||
g_free(fullname);
|
||||
return TRUE;
|
||||
@ -480,7 +481,7 @@ load_game_from_command_line(const gchar *filename)
|
||||
|
||||
if(g_file_test(support_file_name, G_FILE_TEST_EXISTS))
|
||||
{
|
||||
if(load_save_load_game(support_file_name, TRUE))
|
||||
if(load_save_load_game(support_file_name, TRUE, bygfoot))
|
||||
{
|
||||
g_free(fullname);
|
||||
g_free(support_file_name);
|
||||
|
@ -32,13 +32,14 @@ void
|
||||
load_save_save_game(const gchar* filename);
|
||||
|
||||
gboolean
|
||||
load_save_load_game(const gchar* filename, gboolean create_main_window);
|
||||
load_save_load_game(const gchar* filename, gboolean create_main_window,
|
||||
Bygfoot *bygfoot);
|
||||
|
||||
void
|
||||
load_save_autosave(void);
|
||||
|
||||
gboolean
|
||||
load_game_from_command_line(const gchar *filename);
|
||||
load_game_from_command_line(const gchar *filename, Bygfoot *bygfoot);
|
||||
|
||||
void
|
||||
load_save_write_autosave_name(gchar *filename);
|
||||
|
@ -374,7 +374,7 @@ static void validate_country_file(gpointer country_file, gpointer user_data)
|
||||
{
|
||||
Country country;
|
||||
memset(&country, 0, sizeof(country));
|
||||
xml_country_read(country_file, &country);
|
||||
xml_country_read(country_file, &country, NULL);
|
||||
}
|
||||
|
||||
static void validate_country_files(const Bygfoot *bygfoot)
|
||||
@ -494,9 +494,9 @@ main (gint argc, gchar *argv[])
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
if((load_last_save && !load_game_from_command_line("last_save")) ||
|
||||
if((load_last_save && !load_game_from_command_line("last_save", &bygfoot)) ||
|
||||
(!load_last_save && (argc == 1 ||
|
||||
(argc > 1 && !load_game_from_command_line(argv[1])))))
|
||||
(argc > 1 && !load_game_from_command_line(argv[1], &bygfoot)))))
|
||||
{
|
||||
if(country.sid == NULL)
|
||||
{
|
||||
|
@ -283,7 +283,7 @@ misc2_callback_add_user(void)
|
||||
@param row_num The row that's been clicked on.
|
||||
@param col_num The column number. */
|
||||
void
|
||||
misc2_callback_mmatches_button_press(GtkWidget *widget, gint row_num, gint col_num)
|
||||
misc2_callback_mmatches_button_press(GtkWidget *widget, gint row_num, gint col_num, Bygfoot *bygfoot)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("misc2_callback_mmatches_button_press\n");
|
||||
@ -316,7 +316,7 @@ misc2_callback_mmatches_button_press(GtkWidget *widget, gint row_num, gint col_n
|
||||
{
|
||||
stat5 = STATUS_SELECT_MM_FILE_EXPORT;
|
||||
stat4 = row_num;
|
||||
window_show_file_sel();
|
||||
window_show_file_sel(bygfoot);
|
||||
}
|
||||
}
|
||||
else if(row_num == current_user.mmatches->len && col_num == 1)
|
||||
|
@ -44,7 +44,7 @@ void
|
||||
misc2_callback_add_user(void);
|
||||
|
||||
void
|
||||
misc2_callback_mmatches_button_press(GtkWidget *widget, gint row_num, gint col_num);
|
||||
misc2_callback_mmatches_button_press(GtkWidget *widget, gint row_num, gint col_num, Bygfoot *bygfoot);
|
||||
|
||||
gboolean
|
||||
misc2_callback_evaluate_job_application(Job *job, User *user);
|
||||
|
@ -671,6 +671,7 @@ on_treeview_mmatches_button_press_event (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
gpointer user_data)
|
||||
{
|
||||
Bygfoot *bygfoot = (Bygfoot*)user_data;
|
||||
#ifdef DEBUG
|
||||
printf("on_treeview_mmatches_button_press_event\n");
|
||||
#endif
|
||||
@ -695,7 +696,7 @@ on_treeview_mmatches_button_press_event (GtkWidget *widget,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
misc2_callback_mmatches_button_press(widget, mmidx, col_num);
|
||||
misc2_callback_mmatches_button_press(widget, mmidx, col_num, bygfoot);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -743,12 +744,13 @@ G_MODULE_EXPORT void
|
||||
on_button_mm_file_clicked (GtkButton *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
Bygfoot *bygfoot = (Bygfoot*)user_data;
|
||||
#ifdef DEBUG
|
||||
printf("on_button_mm_file_clicked\n");
|
||||
#endif
|
||||
|
||||
stat5 = STATUS_SELECT_MM_FILE_LOAD;
|
||||
window_show_file_sel();
|
||||
window_show_file_sel(bygfoot);
|
||||
}
|
||||
|
||||
|
||||
@ -786,12 +788,13 @@ G_MODULE_EXPORT void
|
||||
on_button_mm_import_clicked (GtkButton *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
Bygfoot *bygfoot = (Bygfoot*)user_data;
|
||||
#ifdef DEBUG
|
||||
printf("on_button_mm_import_clicked\n");
|
||||
#endif
|
||||
|
||||
stat5 = STATUS_SELECT_MM_FILE_IMPORT;
|
||||
window_show_file_sel();
|
||||
window_show_file_sel(bygfoot);
|
||||
}
|
||||
|
||||
|
||||
|
@ -225,11 +225,11 @@ create_window_transfer_dialog (void)
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
create_window_mmatches (void)
|
||||
create_window_mmatches (Bygfoot *bygfoot)
|
||||
{
|
||||
GtkWidget *window_mmatches;
|
||||
GtkBuilder *builder;
|
||||
builder = load_ui(file_find_support_file("bygfoot_misc2.glade", TRUE));
|
||||
builder = load_ui_with_userdata(file_find_support_file("bygfoot_misc2.glade", TRUE), bygfoot);
|
||||
window_mmatches = GTK_WIDGET (gtk_builder_get_object (builder, "window_mmatches"));
|
||||
|
||||
/* Store pointers to all widgets, for use by lookup_widget(). */
|
||||
|
@ -12,4 +12,4 @@ GtkWidget* create_window_user_management (void);
|
||||
GtkWidget* create_window_debug (void);
|
||||
GtkWidget* create_window_help (void);
|
||||
GtkWidget* create_window_transfer_dialog (void);
|
||||
GtkWidget* create_window_mmatches (void);
|
||||
GtkWidget* create_window_mmatches (Bygfoot *bygfoot);
|
||||
|
@ -228,12 +228,13 @@ G_MODULE_EXPORT void
|
||||
on_button_splash_load_game_clicked (GtkButton *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
Bygfoot *bygfoot = (Bygfoot*)user_data;
|
||||
#ifdef DEBUG
|
||||
printf("on_button_splash_load_game_clicked\n");
|
||||
#endif
|
||||
|
||||
stat5 = STATUS_LOAD_GAME_SPLASH;
|
||||
window_show_file_sel();
|
||||
window_show_file_sel(bygfoot);
|
||||
}
|
||||
|
||||
|
||||
@ -241,11 +242,12 @@ G_MODULE_EXPORT void
|
||||
on_button_splash_resume_game_clicked (GtkButton *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
Bygfoot *bygfoot = (Bygfoot*)user_data;
|
||||
#ifdef DEBUG
|
||||
printf("on_button_splash_resume_game_clicked\n");
|
||||
#endif
|
||||
|
||||
misc_callback_startup_load("last_save");
|
||||
misc_callback_startup_load("last_save", bygfoot);
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,7 +59,7 @@ misc_callback_show_team_list(GtkWidget *widget, Bygfoot *bygfoot, const gchar *c
|
||||
GtkWidget *treeview_startup =
|
||||
lookup_widget(widget, "treeview_startup");
|
||||
|
||||
xml_country_read(country_file, NULL);
|
||||
bygfoot_load_country(bygfoot, country_file);
|
||||
|
||||
treeview_show_team_list(GTK_TREE_VIEW(treeview_startup), FALSE, FALSE);
|
||||
|
||||
@ -325,7 +325,7 @@ misc_callback_improve_stadium(void)
|
||||
|
||||
/** Load a savegame directly from the startup window. */
|
||||
void
|
||||
misc_callback_startup_load(const gchar *filename)
|
||||
misc_callback_startup_load(const gchar *filename, Bygfoot *bygfoot)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("misc_callback_startup_load\n");
|
||||
@ -333,7 +333,7 @@ misc_callback_startup_load(const gchar *filename)
|
||||
|
||||
gtk_widget_hide(window.splash);
|
||||
|
||||
if(load_save_load_game(filename, TRUE))
|
||||
if(load_save_load_game(filename, TRUE, bygfoot))
|
||||
window_destroy(&window.splash);
|
||||
else
|
||||
gtk_widget_show(window.splash);
|
||||
|
@ -50,7 +50,7 @@ void
|
||||
misc_callback_update_stadium_window(gboolean capacity);
|
||||
|
||||
void
|
||||
misc_callback_startup_load(const gchar *filename);
|
||||
misc_callback_startup_load(const gchar *filename, Bygfoot *bygfoot);
|
||||
|
||||
void
|
||||
misc_callback_new_sponsor(void);
|
||||
|
16
src/window.c
16
src/window.c
@ -353,7 +353,7 @@ window_show_startup(Bygfoot *bygfoot)
|
||||
|
||||
/** Show the file selection window. */
|
||||
void
|
||||
window_show_file_sel(void)
|
||||
window_show_file_sel(Bygfoot *bygfoot)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("window_show_file_sel\n");
|
||||
@ -426,9 +426,9 @@ window_show_file_sel(void)
|
||||
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(window.file_chooser));
|
||||
|
||||
if(stat5 == STATUS_LOAD_GAME)
|
||||
load_save_load_game(filename, FALSE);
|
||||
load_save_load_game(filename, FALSE, bygfoot);
|
||||
else if(stat5 == STATUS_LOAD_GAME_SPLASH)
|
||||
misc_callback_startup_load(filename);
|
||||
misc_callback_startup_load(filename, bygfoot);
|
||||
else if(stat5 == STATUS_SAVE_GAME)
|
||||
load_save_save_game(filename);
|
||||
else if(stat5 == STATUS_SELECT_MM_FILE_LOAD)
|
||||
@ -441,7 +441,7 @@ window_show_file_sel(void)
|
||||
user_mm_load_file(filename, NULL);
|
||||
else
|
||||
user_mm_set_filename(filename, NULL);
|
||||
window_show_mmatches();
|
||||
window_show_mmatches(bygfoot);
|
||||
}
|
||||
else
|
||||
game_gui_show_warning(_("Not a valid Bygfoot Memorable Matches filename."));
|
||||
@ -456,7 +456,7 @@ window_show_file_sel(void)
|
||||
else if(stat5 == STATUS_SELECT_MM_FILE_IMPORT)
|
||||
{
|
||||
user_mm_import_file(filename);
|
||||
window_show_mmatches();
|
||||
window_show_mmatches(bygfoot);
|
||||
}
|
||||
else if(stat5 == STATUS_SELECT_MM_FILE_EXPORT)
|
||||
user_mm_export_file(filename);
|
||||
@ -477,14 +477,14 @@ window_show_file_sel(void)
|
||||
|
||||
/** Show window with memorable matches list. */
|
||||
void
|
||||
window_show_mmatches(void)
|
||||
window_show_mmatches(Bygfoot *bygfoot)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("window_show_mmatches\n");
|
||||
#endif
|
||||
|
||||
if(window.mmatches == NULL)
|
||||
window_create(WINDOW_MMATCHES);
|
||||
window_create_with_userdata(WINDOW_MMATCHES, bygfoot);
|
||||
treeview2_show_mmatches();
|
||||
|
||||
gtk_entry_set_text(GTK_ENTRY(lookup_widget(window.mmatches, "entry_mm_file")),
|
||||
@ -975,7 +975,7 @@ window_create_with_userdata(gint window_type, Bygfoot *bygfoot)
|
||||
if(window.mmatches != NULL)
|
||||
debug_print_message("window_create: called on already existing window\n");
|
||||
else
|
||||
window.mmatches = create_window_mmatches();
|
||||
window.mmatches = create_window_mmatches(bygfoot);
|
||||
wind = window.mmatches;
|
||||
strcpy(buf, _("Memorable matches"));
|
||||
break;
|
||||
|
@ -82,7 +82,7 @@ window_show_digits(const gchar *text_main, const gchar* text1,
|
||||
gint value1, const gchar* text2, gint value2, gboolean show_alr);
|
||||
|
||||
void
|
||||
window_show_file_sel(void);
|
||||
window_show_file_sel(Bygfoot *bygfoot);
|
||||
|
||||
void
|
||||
window_show_stadium(void);
|
||||
@ -106,7 +106,7 @@ void
|
||||
window_show_transfer_dialog(const gchar *text);
|
||||
|
||||
void
|
||||
window_show_mmatches(void);
|
||||
window_show_mmatches(Bygfoot *bygfoot);
|
||||
|
||||
void
|
||||
window_main_save_geometry(void);
|
||||
|
@ -73,14 +73,14 @@ xml_load_users(const gchar *dirname, const gchar *basename)
|
||||
}
|
||||
|
||||
void
|
||||
xml_load_league(const gchar *dirname, const gchar *basename)
|
||||
xml_load_league(const gchar *dirname, const gchar *basename, Bygfoot *bygfoot)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("xml_load_league\n");
|
||||
#endif
|
||||
|
||||
gchar buf[SMALL], team_file[SMALL];
|
||||
League new = league_new(FALSE);
|
||||
League new = league_new(FALSE, bygfoot);
|
||||
gchar *prefix = g_strndup(basename, strlen(basename) - 4);
|
||||
|
||||
g_array_append_val(ligs, new);
|
||||
|
@ -104,7 +104,7 @@ void
|
||||
xml_load_users(const gchar *dirname, const gchar *basename);
|
||||
|
||||
void
|
||||
xml_load_league(const gchar *dirname, const gchar *basename);
|
||||
xml_load_league(const gchar *dirname, const gchar *basename, Bygfoot *bygfoot);
|
||||
|
||||
void
|
||||
xml_load_cup(Cup *cup, const gchar *dirname, const gchar *basename);
|
||||
|
@ -169,6 +169,8 @@ xml_country_read_text (GMarkupParseContext *context,
|
||||
gpointer user_data,
|
||||
GError **error)
|
||||
{
|
||||
|
||||
Bygfoot *bygfoot = (Bygfoot*)user_data;
|
||||
#ifdef DEBUG
|
||||
printf("xml_country_read_text\n");
|
||||
#endif
|
||||
@ -200,9 +202,9 @@ xml_country_read_text (GMarkupParseContext *context,
|
||||
sett_set_int("int_opt_disable_training_camp", 1);//***ML***
|
||||
}
|
||||
else if(state == STATE_LEAGUE)
|
||||
xml_league_read(buf, cntry->leagues);
|
||||
xml_league_read(buf, cntry->leagues, bygfoot);
|
||||
else if(state == STATE_CUP)
|
||||
xml_cup_read(buf, cntry->cups);
|
||||
xml_cup_read(buf, cntry->cups, bygfoot);
|
||||
else if(state == STATE_RESERVE_PROMOTION_RULES) {
|
||||
if (!strcmp(buf, "none"))
|
||||
cntry->reserve_promotion_rules = RESERVE_PROM_RULES_NONE;
|
||||
@ -225,7 +227,7 @@ xml_country_read_text (GMarkupParseContext *context,
|
||||
@param cntry The country variable to write.
|
||||
*/
|
||||
void
|
||||
xml_country_read(const gchar *country_name, Country *cntry_arg)
|
||||
xml_country_read(const gchar *country_name, Country *cntry_arg, Bygfoot *bygfoot)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("xml_country_read\n");
|
||||
@ -243,7 +245,7 @@ xml_country_read(const gchar *country_name, Country *cntry_arg)
|
||||
gint i;
|
||||
|
||||
context =
|
||||
g_markup_parse_context_new(&parser, 0, NULL, NULL);
|
||||
g_markup_parse_context_new(&parser, 0, bygfoot, NULL);
|
||||
|
||||
if(file_name == NULL)
|
||||
{
|
||||
|
@ -49,6 +49,6 @@ xml_country_read_text (GMarkupParseContext *context,
|
||||
|
||||
|
||||
void
|
||||
xml_country_read(const gchar *country_name, Country *cntry_arg);
|
||||
xml_country_read(const gchar *country_name, Country *cntry_arg, Bygfoot *bygfoot);
|
||||
|
||||
#endif
|
||||
|
@ -158,7 +158,7 @@ xml_cup_read_start_element (GMarkupParseContext *context,
|
||||
|
||||
if(strcmp(element_name, TAG_CUP) == 0)
|
||||
{
|
||||
new_cup = cup_new(FALSE);
|
||||
new_cup = cup_new(FALSE, (Bygfoot*)user_data);
|
||||
state = STATE_CUP;
|
||||
}
|
||||
else if(strcmp(element_name, TAG_DEF_NAME) == 0)
|
||||
@ -477,7 +477,7 @@ xml_cup_read_text (GMarkupParseContext *context,
|
||||
* @param cups The array we append the new cup to.
|
||||
*/
|
||||
void
|
||||
xml_cup_read(const gchar *cup_name, GArray *cups)
|
||||
xml_cup_read(const gchar *cup_name, GArray *cups, Bygfoot *bygfoot)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("xml_cup_read\n");
|
||||
@ -495,7 +495,7 @@ xml_cup_read(const gchar *cup_name, GArray *cups)
|
||||
gint i;
|
||||
|
||||
context =
|
||||
g_markup_parse_context_new(&parser, 0, NULL, NULL);
|
||||
g_markup_parse_context_new(&parser, 0, bygfoot, NULL);
|
||||
|
||||
if(file_name == NULL)
|
||||
{
|
||||
|
@ -51,6 +51,6 @@ xml_cup_read_end_element (GMarkupParseContext *context,
|
||||
|
||||
|
||||
void
|
||||
xml_cup_read(const gchar *file, GArray *cups);
|
||||
xml_cup_read(const gchar *file, GArray *cups, Bygfoot *bygfoot);
|
||||
|
||||
#endif
|
||||
|
@ -160,10 +160,11 @@ xml_league_read_start_element (GMarkupParseContext *context,
|
||||
JoinedLeague new_joined_league;
|
||||
NewTable new_table;
|
||||
WeekBreak new_week_break;
|
||||
Bygfoot *bygfoot = (Bygfoot*)user_data;
|
||||
|
||||
if(strcmp(element_name, TAG_LEAGUE) == 0)
|
||||
{
|
||||
new_league = league_new(TRUE);
|
||||
new_league = league_new(TRUE, bygfoot);
|
||||
state = STATE_LEAGUE;
|
||||
}
|
||||
else if(strcmp(element_name, TAG_DEF_NAME) == 0)
|
||||
@ -522,7 +523,7 @@ xml_league_read_text (GMarkupParseContext *context,
|
||||
* @param leagues The array we write the league into.
|
||||
*/
|
||||
void
|
||||
xml_league_read(const gchar *league_name, GArray *leagues)
|
||||
xml_league_read(const gchar *league_name, GArray *leagues, Bygfoot *bygfoot)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("xml_league_read\n");
|
||||
@ -539,7 +540,7 @@ xml_league_read(const gchar *league_name, GArray *leagues)
|
||||
gchar buf[SMALL];
|
||||
|
||||
context =
|
||||
g_markup_parse_context_new(&parser, 0, NULL, NULL);
|
||||
g_markup_parse_context_new(&parser, 0, bygfoot, NULL);
|
||||
|
||||
if(file_name == NULL)
|
||||
{
|
||||
|
@ -50,6 +50,6 @@ xml_league_read_text (GMarkupParseContext *context,
|
||||
GError **error);
|
||||
|
||||
void
|
||||
xml_league_read(const gchar *league_name, GArray *leagues);
|
||||
xml_league_read(const gchar *league_name, GArray *leagues, Bygfoot *bygfoot);
|
||||
|
||||
#endif
|
||||
|
@ -102,6 +102,7 @@ xml_loadsave_leagues_cups_text (GMarkupParseContext *context,
|
||||
gpointer user_data,
|
||||
GError **error)
|
||||
{
|
||||
Bygfoot *bygfoot = (Bygfoot*)user_data;
|
||||
#ifdef DEBUG
|
||||
printf("xml_loadsave_leagues_cups_text\n");
|
||||
#endif
|
||||
@ -112,11 +113,11 @@ xml_loadsave_leagues_cups_text (GMarkupParseContext *context,
|
||||
strncpy(buf, text, text_len);
|
||||
buf[text_len] = '\0';
|
||||
|
||||
if(state == TAG_LEAGUE_FILE)
|
||||
xml_load_league(dir, buf);
|
||||
else if(state == TAG_CUP_FILE)
|
||||
if(state == TAG_LEAGUE_FILE) {
|
||||
xml_load_league(dir, buf, bygfoot);
|
||||
}else if(state == TAG_CUP_FILE)
|
||||
{
|
||||
new_cup = cup_new(FALSE);
|
||||
new_cup = cup_new(FALSE, bygfoot);
|
||||
g_array_append_val(cps, new_cup);
|
||||
xml_load_cup(&g_array_index(cps, Cup, cps->len - 1), dir, buf);
|
||||
}
|
||||
@ -124,7 +125,7 @@ xml_loadsave_leagues_cups_text (GMarkupParseContext *context,
|
||||
|
||||
/** Load the leagues and cups given in the leagues_cups.xml file. */
|
||||
void
|
||||
xml_loadsave_leagues_cups_read(const gchar *dirname, const gchar *prefix)
|
||||
xml_loadsave_leagues_cups_read(const gchar *dirname, const gchar *prefix, Bygfoot *bygfoot)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("xml_loadsave_leagues_cups_read\n");
|
||||
@ -142,7 +143,7 @@ xml_loadsave_leagues_cups_read(const gchar *dirname, const gchar *prefix)
|
||||
sprintf(file, "%s%s%s___leagues_cups.xml", dirname, G_DIR_SEPARATOR_S, prefix);
|
||||
|
||||
context =
|
||||
g_markup_parse_context_new(&parser, 0, NULL, NULL);
|
||||
g_markup_parse_context_new(&parser, 0, bygfoot, NULL);
|
||||
|
||||
if(!g_file_get_contents(file, &file_contents, &length, &error))
|
||||
{
|
||||
|
@ -54,7 +54,8 @@ xml_loadsave_leagues_cups_text (GMarkupParseContext *context,
|
||||
GError **error);
|
||||
|
||||
void
|
||||
xml_loadsave_leagues_cups_read(const gchar *dirname, const gchar *prefix);
|
||||
xml_loadsave_leagues_cups_read(const gchar *dirname, const gchar *prefix,
|
||||
Bygfoot *bygfoot);
|
||||
|
||||
|
||||
void
|
||||
|
Loading…
x
Reference in New Issue
Block a user