Use a callback for reporting progress of simulating games

This removes the gtk2 dependency from end_week_round_results() so it can
be potentially used with other frontends.
This commit is contained in:
Tom Stellard 2020-12-27 21:09:02 -08:00 committed by Tom Stellard
parent fdd8922aba
commit e7ff2f9d4d
37 changed files with 246 additions and 176 deletions

View File

@ -1,10 +1,24 @@
#include "bygfoot.h"
#include "gui.h"
#include "misc.h"
#include "start_end.h"
#include "user.h"
#include "xml_country.h"
void
bygfoot_init(Bygfoot *bygfoot, enum BygfootFrontend frontend)
{
memset(bygfoot, 0, sizeof(*bygfoot));
bygfoot->frontend = frontend;
switch(frontend) {
case BYGFOOT_FRONTEND_GTK2:
bygfoot->show_progress = gui_show_progress;
bygfoot->get_progress_bar_fraction;
break;
}
}
User *bygfoot_add_user(Bygfoot *bygfoot, const gchar *username, Team *tm)
{
User new_user = user_new();
@ -27,3 +41,17 @@ void bygfoot_start_game(Bygfoot *bygfoot)
for (i = 0; i < users->len; i++)
user_set_up_team_new_game(&usr(i));
}
void bygfoot_show_progress(const Bygfoot *bygfoot, gfloat value, const gchar *text, gint pictype)
{
if (bygfoot->show_progress)
bygfoot->show_progress(value, text, pictype);
}
gdouble bygfoot_get_progress_bar_fraction(const Bygfoot *bygfoot)
{
if (bygfoot->get_progress_bar_fraction)
return bygfoot->get_progress_bar_fraction();
return 0;
}

View File

@ -205,6 +205,9 @@ typedef struct
gint paned_pos;
} Windows;
void bygfoot_init(Bygfoot *bygfoot, enum BygfootFrontend frontend);
User *bygfoot_add_user(Bygfoot *bygfoot, const gchar *username, Team *tm);
void bygfoot_start_game(Bygfoot *bygfoot);
void bygfoot_show_progress(const Bygfoot *bygfoot, gfloat value, const gchar *text, gint pictype);
gdouble bygfoot_get_progress_bar_fraction(const Bygfoot *bygfoot);
#endif

View File

@ -1,12 +1,23 @@
#ifndef BYGFOOT_STRUCT_H
#define BYGFOOT_STRUCT_H
enum BygfootFrontend {
BYGFOOT_FRONTEND_GTK2
};
/** This struct holds all of the global state for a bygfoot game. The goal
* is for ths struct to eventually replace all the global variables.
*/
typedef struct
{
gint unused;
/** Which kind of frontend is being use. See #enum BygfootFrontend. */
enum BygfootFrontend frontend;
/** @name Frontend functions */
/* @{ */
void (*show_progress)(gfloat, const gchar *, gint);
gdouble (*get_progress_bar_fraction)(void);
/* @} */
} Bygfoot;
#endif

View File

@ -48,7 +48,7 @@
/** Show the users' live games. */
void
callback_show_next_live_game(void)
callback_show_next_live_game(Bygfoot *bygfoot)
{
#ifdef DEBUG
printf("callback_show_next_live_game\n");
@ -92,7 +92,7 @@ callback_show_next_live_game(void)
options))
{
live_game_calculate_fixture(&g_array_index(lig(i).fixtures, Fixture, j),
&usr(fixture_user_team_involved(&g_array_index(lig(i).fixtures, Fixture, j))).live_game);
&usr(fixture_user_team_involved(&g_array_index(lig(i).fixtures, Fixture, j))).live_game, bygfoot);
return;
}
}
@ -126,7 +126,7 @@ callback_show_next_live_game(void)
options))
{
live_game_calculate_fixture(&g_array_index(acp(i)->fixtures, Fixture, j),
&usr(fixture_user_team_involved(&g_array_index(acp(i)->fixtures, Fixture, j))).live_game);
&usr(fixture_user_team_involved(&g_array_index(acp(i)->fixtures, Fixture, j))).live_game, bygfoot);
return;
}
}
@ -151,7 +151,7 @@ callback_show_next_live_game(void)
g_array_free (user_teams_played, TRUE);
treeview_show_user_player_list();
/* no more user games to show: end round. */
end_week_round();
end_week_round(bygfoot);
game_gui_show_main();
user_event_show_next();
@ -244,7 +244,7 @@ callback_player_clicked(gint idx, GdkEventButton *event)
/** Show the last match of the current user.
@param start Whether we start the replay from the beginning or continue it. */
void
callback_show_last_match(gboolean start, LiveGame *lg)
callback_show_last_match(gboolean start, LiveGame *lg, Bygfoot *bygfoot)
{
#ifdef DEBUG
printf("callback_show_last_match\n");
@ -259,7 +259,7 @@ callback_show_last_match(gboolean start, LiveGame *lg)
stat2 = cur_user;
statp = lg;
window_create(WINDOW_LIVE);
window_create_with_userdata(WINDOW_LIVE, bygfoot);
gui_set_sensitive_lg_meters(FALSE);

View File

@ -30,7 +30,7 @@
#include "live_game_struct.h"
void
callback_show_next_live_game(void);
callback_show_next_live_game(Bygfoot *bygfoot);
void
callback_player_clicked(gint idx, GdkEventButton *event);
@ -39,7 +39,7 @@ void
callback_player_activate(gint idx);
void
callback_show_last_match(gboolean start, LiveGame *lg);
callback_show_last_match(gboolean start, LiveGame *lg, Bygfoot *bygfoot);
void
callback_show_fixtures(gint type);

View File

@ -231,6 +231,7 @@ G_MODULE_EXPORT void
on_button_new_week_clicked (GtkButton *button,
gpointer user_data)
{
Bygfoot *bygfoot = (Bygfoot*)user_data;
#ifdef DEBUG
printf("on_button_new_week_clicked\n");
#endif
@ -250,8 +251,8 @@ on_button_new_week_clicked (GtkButton *button,
}
else
{
load_save_autosave();
callback_show_next_live_game();
load_save_autosave(bygfoot);
callback_show_next_live_game(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(bygfoot, "last_save", FALSE))
{
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);
}
@ -608,6 +611,7 @@ G_MODULE_EXPORT void
on_menu_save_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
Bygfoot *bygfoot;
#ifdef DEBUG
printf("on_menu_save_activate\n");
#endif
@ -616,7 +620,7 @@ on_menu_save_activate (GtkMenuItem *menuitem,
save_file == NULL)
on_menu_save_as_activate(NULL, NULL);
else
load_save_save_game(save_file);
load_save_save_game(bygfoot, save_file);
}
@ -624,12 +628,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
@ -1440,6 +1445,7 @@ G_MODULE_EXPORT void
on_menu_user_show_last_match_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
Bygfoot *bygfoot = (Bygfoot*)user_data;
#ifdef DEBUG
printf("on_menu_user_show_last_match_activate\n");
#endif
@ -1452,7 +1458,7 @@ on_menu_user_show_last_match_activate (GtkMenuItem *menuitem,
stat1 = STATUS_SHOW_LAST_MATCH;
stat3 = 0;
callback_show_last_match(TRUE, &current_user.live_game);
callback_show_last_match(TRUE, &current_user.live_game, bygfoot);
}
@ -1600,6 +1606,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 +1620,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 +1631,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 +1639,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);
}

View File

@ -26,7 +26,6 @@
#ifndef CALLBACKS_H
#define CALLBACKS_H
#include "bygfoot.h"
#include "interface.h"
#include "support.h"

View File

@ -252,7 +252,7 @@ debug_reset_counter(gpointer data)
}
void
debug_calibrate_betting_odds(gint skilldiffmax, gint matches_per_skilldiff)
debug_calibrate_betting_odds(gint skilldiffmax, gint matches_per_skilldiff, Bygfoot *bygfoot)
{
#ifdef DEBUG
printf("debug_calibrate_betting_odds\n");
@ -282,7 +282,7 @@ debug_calibrate_betting_odds(gint skilldiffmax, gint matches_per_skilldiff)
g_array_index(fix->teams[1]->players, Player, i).fitness = 0.9;
}
live_game_calculate_fixture(fix, &live_game);
live_game_calculate_fixture(fix, &live_game, bygfoot);
if(fix->result[0][0] < fix->result[1][0])
res[2]++;
else

View File

@ -27,6 +27,7 @@
#define DEBUG_H
#include <gtk/gtk.h>
#include "bygfoot_struct.h"
//#include "bygfoot.h"
enum DebugOutput
@ -43,7 +44,7 @@ gboolean
debug_reset_counter(gpointer data);
void
debug_calibrate_betting_odds(gint skilldiffmax, gint matches_per_skilldiff);
debug_calibrate_betting_odds(gint skilldiffmax, gint matches_per_skilldiff, Bygfoot *bygfoot);
void
debug_writer_out(const gchar *file_name,

View File

@ -18,11 +18,11 @@
#include "file.h"
GtkWidget*
create_main_window (void)
create_main_window (Bygfoot *bygfoot)
{
GtkWidget *main_window;
GtkBuilder *builder;
builder = load_ui(file_find_support_file("bygfoot.glade", TRUE));
builder = load_ui_with_userdata(file_find_support_file("bygfoot.glade", TRUE), bygfoot);
main_window = GTK_WIDGET (gtk_builder_get_object (builder, "main_window"));
/* Store pointers to all widgets, for use by lookup_widget(). */

View File

@ -1,4 +1,5 @@
#include "bygfoot.h"
GtkWidget* create_main_window (void);
GtkWidget* create_main_window (Bygfoot *bygfoot);
GtkWidget* create_menu_player (void);
GtkWidget* create_menu_youth (void);

View File

@ -65,7 +65,7 @@ gboolean show;
@param live_game The live game used for calculation.
*/
void
live_game_calculate_fixture(Fixture *fix, LiveGame *live_game)
live_game_calculate_fixture(Fixture *fix, LiveGame *live_game, Bygfoot *bygfoot)
{
#ifdef DEBUG
printf("live_game_calculate_fixture\n");
@ -74,7 +74,7 @@ live_game_calculate_fixture(Fixture *fix, LiveGame *live_game)
if(stat0 != STATUS_LIVE_GAME_PAUSE &&
stat0 != STATUS_LIVE_GAME_CHANGE)
live_game_initialize(fix, live_game);
live_game_initialize(fix, live_game, bygfoot);
else
stat0 = STATUS_SHOW_LIVE_GAME;
@ -103,12 +103,12 @@ live_game_calculate_fixture(Fixture *fix, LiveGame *live_game)
stat0 = STATUS_NONE;
}
else if(stat0 == STATUS_LIVE_GAME_CHANGE)
live_game_resume();
live_game_resume(bygfoot);
}
/** Initialize a few things at the beginning of a live game. */
void
live_game_initialize(Fixture *fix, LiveGame *live_game)
live_game_initialize(Fixture *fix, LiveGame *live_game, Bygfoot *bygfoot)
{
#ifdef DEBUG
printf("live_game_initialize\n");
@ -129,7 +129,7 @@ live_game_initialize(Fixture *fix, LiveGame *live_game)
on_button_back_to_main_clicked(NULL, NULL);
if(window.live == NULL)
window.live = window_create(WINDOW_LIVE);
window.live = window_create_with_userdata(WINDOW_LIVE, bygfoot);
else
gtk_window_set_title(
GTK_WINDOW(window.live),
@ -1753,7 +1753,7 @@ live_game_injury_get_player(void)
/** Resume a live game. Show team changes. */
void
live_game_resume(void)
live_game_resume(Bygfoot *bygfoot)
{
#ifdef DEBUG
printf("live_game_resume\n");
@ -1786,7 +1786,7 @@ live_game_resume(void)
tms[i]->boost + 1);
}
live_game_calculate_fixture(usr(stat2).live_game.fix, &usr(stat2).live_game);
live_game_calculate_fixture(usr(stat2).live_game.fix, &usr(stat2).live_game, bygfoot);
}

View File

@ -30,10 +30,10 @@
#include "live_game_struct.h"
void
live_game_calculate_fixture(Fixture *fix, LiveGame *live_game);
live_game_calculate_fixture(Fixture *fix, LiveGame *live_game, Bygfoot *bygfoot);
void
live_game_initialize(Fixture *fix, LiveGame *live_game);
live_game_initialize(Fixture *fix, LiveGame *live_game, Bygfoot *bygfoot);
gboolean
query_live_game_event_is_break(gint minute, gint time);
@ -120,7 +120,7 @@ void
live_game_injury_get_player(void);
void
live_game_resume(void);
live_game_resume(Bygfoot *bygfoot);
void
live_game_event_substitution(gint team_number, gint sub_in, gint sub_out);

View File

@ -53,7 +53,7 @@
/** Save the game to the specified file. */
void
load_save_save_game(const gchar *filename)
load_save_save_game(Bygfoot *bygfoot, const gchar *filename)
{
#ifdef DEBUG
printf("load_save_save_game\n");
@ -77,7 +77,7 @@ load_save_save_game(const gchar *filename)
if(debug > 60)
g_print("load_save_save options\n");
gui_show_progress(0, _("Saving options..."),
bygfoot_show_progress(bygfoot, 0, _("Saving options..."),
PIC_TYPE_SAVE);
sprintf(buf, "%s___options", prefix);
@ -88,8 +88,8 @@ load_save_save_game(const gchar *filename)
if(debug > 60)
g_print("load_save_save leagues/cups \n");
gui_show_progress(
((PROGRESS_MAX * gui_get_progress_bar_fraction()) + 1) / PROGRESS_MAX,
bygfoot_show_progress(bygfoot,
((PROGRESS_MAX * bygfoot_get_progress_bar_fraction(bygfoot)) + 1) / PROGRESS_MAX,
_("Saving leagues and cups..."),
PIC_TYPE_SAVE);
@ -98,8 +98,8 @@ load_save_save_game(const gchar *filename)
if(debug > 60)
g_print("load_save_save users \n");
gui_show_progress(
((PROGRESS_MAX * gui_get_progress_bar_fraction()) + 1) / PROGRESS_MAX,
bygfoot_show_progress(bygfoot,
((PROGRESS_MAX * bygfoot_get_progress_bar_fraction(bygfoot)) + 1) / PROGRESS_MAX,
_("Saving users..."),
PIC_TYPE_SAVE);
@ -108,8 +108,8 @@ load_save_save_game(const gchar *filename)
if(debug > 60)
g_print("load_save_save transfers \n");
gui_show_progress(
((PROGRESS_MAX * gui_get_progress_bar_fraction()) + 1) / PROGRESS_MAX,
bygfoot_show_progress(bygfoot,
((PROGRESS_MAX * bygfoot_get_progress_bar_fraction(bygfoot)) + 1) / PROGRESS_MAX,
_("Saving transfer list..."),
PIC_TYPE_SAVE);
@ -118,8 +118,8 @@ load_save_save_game(const gchar *filename)
if(debug > 60)
g_print("load_save_save stats \n");
gui_show_progress(
((PROGRESS_MAX * gui_get_progress_bar_fraction()) + 1) / PROGRESS_MAX,
bygfoot_show_progress(bygfoot,
((PROGRESS_MAX * bygfoot_get_progress_bar_fraction(bygfoot)) + 1) / PROGRESS_MAX,
_("Saving season stats..."),
PIC_TYPE_SAVE);
@ -128,8 +128,8 @@ load_save_save_game(const gchar *filename)
if(debug > 60)
g_print("load_save_save jobs \n");
gui_show_progress(
((PROGRESS_MAX * gui_get_progress_bar_fraction()) + 1) / PROGRESS_MAX,
bygfoot_show_progress(bygfoot,
((PROGRESS_MAX * bygfoot_get_progress_bar_fraction(bygfoot)) + 1) / PROGRESS_MAX,
/* The 'job exchange' is a list of teams looking for a manager. */
_("Saving job exchange..."),
PIC_TYPE_SAVE);
@ -139,8 +139,8 @@ load_save_save_game(const gchar *filename)
if(debug > 60)
g_print("load_save_save newspaper \n");
gui_show_progress(
((PROGRESS_MAX * gui_get_progress_bar_fraction()) + 1) / PROGRESS_MAX,
bygfoot_show_progress(bygfoot,
((PROGRESS_MAX * bygfoot_get_progress_bar_fraction(bygfoot)) + 1) / PROGRESS_MAX,
_("Saving newspaper..."),
PIC_TYPE_SAVE);
@ -149,15 +149,15 @@ load_save_save_game(const gchar *filename)
if(debug > 60)
g_print("load_save_save misc \n");
gui_show_progress(
((PROGRESS_MAX * gui_get_progress_bar_fraction()) + 1) / PROGRESS_MAX,
bygfoot_show_progress(bygfoot,
((PROGRESS_MAX * bygfoot_get_progress_bar_fraction(bygfoot)) + 1) / PROGRESS_MAX,
_("Saving miscellaneous..."),
PIC_TYPE_SAVE);
xml_loadsave_misc_write(prefix);
gui_show_progress(
((PROGRESS_MAX * gui_get_progress_bar_fraction()) + 1) / PROGRESS_MAX,
bygfoot_show_progress(bygfoot,
((PROGRESS_MAX * bygfoot_get_progress_bar_fraction(bygfoot)) + 1) / PROGRESS_MAX,
_("Compressing savegame..."),
PIC_TYPE_SAVE);
@ -167,7 +167,7 @@ load_save_save_game(const gchar *filename)
if(debug > 60)
g_print("load_save_save done \n");
gui_show_progress(1, _("Done."),
bygfoot_show_progress(bygfoot, 1, _("Done."),
PIC_TYPE_SAVE);
file_store_text_in_saves("last_save", fullname->str);
@ -175,15 +175,17 @@ load_save_save_game(const gchar *filename)
g_free(prefix);
g_string_free(fullname, TRUE);
gui_show_progress(-1, "",
bygfoot_show_progress(bygfoot, -1, "",
PIC_TYPE_SAVE);
setsav1;
if (bygfoot->frontend == BYGFOOT_FRONTEND_GTK2) {
setsav1;
}
}
/** 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(Bygfoot *bygfoot, const gchar* filename, gboolean create_main_window)
{
#ifdef DEBUG
printf("load_save_load_game\n");
@ -211,7 +213,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(bygfoot, basename, create_main_window);
g_free(basename);
return TRUE;
}
@ -225,7 +227,7 @@ load_save_load_game(const gchar* filename, gboolean create_main_window)
if(window.main != NULL)
gtk_widget_hide(window.main);
gui_show_progress(0, _("Uncompressing savegame..."),
bygfoot_show_progress(bygfoot, 0, _("Uncompressing savegame..."),
PIC_TYPE_LOAD);
file_decompress(fullname);
@ -233,8 +235,8 @@ load_save_load_game(const gchar* filename, gboolean create_main_window)
if(debug > 60)
g_print("load_save_load options\n");
gui_show_progress(
((PROGRESS_MAX * gui_get_progress_bar_fraction()) + 1) / PROGRESS_MAX,
bygfoot_show_progress(bygfoot,
((PROGRESS_MAX * bygfoot_get_progress_bar_fraction(bygfoot)) + 1) / PROGRESS_MAX,
_("Loading options..."),
PIC_TYPE_LOAD);
@ -247,18 +249,18 @@ load_save_load_game(const gchar* filename, gboolean create_main_window)
if(debug > 60)
g_print("load_save_load leagues \n");
gui_show_progress(
((PROGRESS_MAX * gui_get_progress_bar_fraction()) + 1) / PROGRESS_MAX,
bygfoot_show_progress(bygfoot,
((PROGRESS_MAX * bygfoot_get_progress_bar_fraction(bygfoot)) + 1) / PROGRESS_MAX,
_("Loading leagues and cups..."),
PIC_TYPE_LOAD);
xml_loadsave_leagues_cups_read(dirname, prefix);
xml_loadsave_leagues_cups_read(bygfoot, dirname, prefix);
if(debug > 60)
g_print("load_save_load users \n");
gui_show_progress(
((PROGRESS_MAX * gui_get_progress_bar_fraction()) + 1) / PROGRESS_MAX,
bygfoot_show_progress(bygfoot,
((PROGRESS_MAX * bygfoot_get_progress_bar_fraction(bygfoot)) + 1) / PROGRESS_MAX,
_("Loading users..."),
PIC_TYPE_LOAD);
@ -267,8 +269,8 @@ load_save_load_game(const gchar* filename, gboolean create_main_window)
if(debug > 60)
g_print("load_save_load transfers \n");
gui_show_progress(
((PROGRESS_MAX * gui_get_progress_bar_fraction()) + 1) / PROGRESS_MAX,
bygfoot_show_progress(bygfoot,
((PROGRESS_MAX * bygfoot_get_progress_bar_fraction(bygfoot)) + 1) / PROGRESS_MAX,
_("Loading transfer list..."),
PIC_TYPE_LOAD);
@ -277,8 +279,8 @@ load_save_load_game(const gchar* filename, gboolean create_main_window)
if(debug > 60)
g_print("load_save_load stats \n");
gui_show_progress(
((PROGRESS_MAX * gui_get_progress_bar_fraction()) + 1) / PROGRESS_MAX,
bygfoot_show_progress(bygfoot,
((PROGRESS_MAX * bygfoot_get_progress_bar_fraction(bygfoot)) + 1) / PROGRESS_MAX,
_("Loading season stats..."),
PIC_TYPE_LOAD);
@ -287,8 +289,8 @@ load_save_load_game(const gchar* filename, gboolean create_main_window)
if(debug > 60)
g_print("load_save_load jobs \n");
gui_show_progress(
((PROGRESS_MAX * gui_get_progress_bar_fraction()) + 1) / PROGRESS_MAX,
bygfoot_show_progress(bygfoot,
((PROGRESS_MAX * bygfoot_get_progress_bar_fraction(bygfoot)) + 1) / PROGRESS_MAX,
/* The 'job exchange' is a list of teams looking for a manager. */
_("Loading job exchange..."),
PIC_TYPE_LOAD);
@ -298,8 +300,8 @@ load_save_load_game(const gchar* filename, gboolean create_main_window)
if(debug > 60)
g_print("load_save_load newspaper \n");
gui_show_progress(
((PROGRESS_MAX * gui_get_progress_bar_fraction()) + 1) / PROGRESS_MAX,
bygfoot_show_progress(bygfoot,
((PROGRESS_MAX * bygfoot_get_progress_bar_fraction(bygfoot)) + 1) / PROGRESS_MAX,
_("Loading newspaper..."),
PIC_TYPE_LOAD);
@ -308,8 +310,8 @@ load_save_load_game(const gchar* filename, gboolean create_main_window)
if(debug > 60)
g_print("load_save_load misc \n");
gui_show_progress(
((PROGRESS_MAX * gui_get_progress_bar_fraction()) + 1) / PROGRESS_MAX,
bygfoot_show_progress(bygfoot,
((PROGRESS_MAX * bygfoot_get_progress_bar_fraction(bygfoot)) + 1) / PROGRESS_MAX,
_("Loading miscellaneous..."),
PIC_TYPE_LOAD);
@ -318,7 +320,7 @@ load_save_load_game(const gchar* filename, gboolean create_main_window)
if(debug > 60)
g_print("load_save_load done \n");
gui_show_progress(1, _("Done."),
bygfoot_show_progress(bygfoot, 1, _("Done."),
PIC_TYPE_LOAD);
chdir(dirname);
@ -342,7 +344,7 @@ load_save_load_game(const gchar* filename, gboolean create_main_window)
file_store_text_in_saves("last_save", fullname);
gui_show_progress(-1, "",
bygfoot_show_progress(bygfoot, -1, "",
PIC_TYPE_LOAD);
if(create_main_window)
@ -369,7 +371,7 @@ load_save_load_game(const gchar* filename, gboolean create_main_window)
/** Write an autosave. */
void
load_save_autosave(void)
load_save_autosave(Bygfoot *bygfoot)
{
#ifdef DEBUG
printf("load_save_autosave\n");
@ -405,7 +407,7 @@ load_save_autosave(void)
fclose(fil);
sprintf(prefix, "autosave_%02d_", counters[COUNT_AUTOSAVE_FILE]);
load_save_save_game(buf);
load_save_save_game(bygfoot, buf);
chdir(directory);
GPtrArray *files = file_dir_get_contents(directory, prefix, ".zip");
// Remove the zipfile from the list
@ -449,7 +451,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(Bygfoot *bygfoot, const gchar *filename)
{
#ifdef DEBUG
printf("load_game_from_command_line\n");
@ -459,7 +461,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(bygfoot, filename, TRUE);
fullname = (g_str_has_suffix(filename, const_str("string_fs_save_suffix"))) ?
g_strdup(filename) :
@ -467,7 +469,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(bygfoot, fullname, TRUE))
{
g_free(fullname);
return TRUE;
@ -480,7 +482,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(bygfoot, support_file_name, TRUE))
{
g_free(fullname);
g_free(support_file_name);

View File

@ -29,16 +29,16 @@
#include "bygfoot.h"
void
load_save_save_game(const gchar* filename);
load_save_save_game(Bygfoot *bygfoot, const gchar* filename);
gboolean
load_save_load_game(const gchar* filename, gboolean create_main_window);
load_save_load_game(Bygfoot *bygfoot, const gchar* filename, gboolean create_main_window);
void
load_save_autosave(void);
load_save_autosave(Bygfoot *bygfoot);
gboolean
load_game_from_command_line(const gchar *filename);
load_game_from_command_line(Bygfoot *bygfoot, const gchar *filename);
void
load_save_write_autosave_name(gchar *filename);

View File

@ -424,18 +424,19 @@ main (gint argc, gchar *argv[])
int fd2 = open ("stderr.log", O_CREAT|O_WRONLY|O_TRUNC, 0666);
dup2 (fd2, 2);
#endif
bygfoot_init(&bygfoot, BYGFOOT_FRONTEND_GTK2);
gtk_init (&argc, &argv);
main_init(&argc, &argv);
if((load_last_save && !load_game_from_command_line("last_save")) ||
if((load_last_save && !load_game_from_command_line(&bygfoot, "last_save")) ||
(!load_last_save && (argc == 1 ||
(argc > 1 && !load_game_from_command_line(argv[1])))))
(argc > 1 && !load_game_from_command_line(&bygfoot, argv[1])))))
{
if(country.sid == NULL)
{
stat0 = STATUS_SPLASH;
window_show_splash();
window_show_splash(&bygfoot);
if(os_is_unix)
file_check_home_dir();

View File

@ -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");
@ -298,7 +298,8 @@ misc2_callback_mmatches_button_press(GtkWidget *widget, gint row_num, gint col_n
stat3 = 0;
callback_show_last_match(
TRUE,
&g_array_index(current_user.mmatches, MemMatch, row_num).lg);
&g_array_index(current_user.mmatches, MemMatch, row_num).lg,
bygfoot);
}
else if(col_num == TREEVIEW_MMATCH_COL_REMOVE)
{
@ -316,7 +317,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)

View File

@ -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);

View File

@ -234,6 +234,7 @@ G_MODULE_EXPORT void
on_button_yesno_yes_clicked (GtkButton *button,
gpointer user_data)
{
Bygfoot *bygfoot = (Bygfoot*)user_data;
#ifdef DEBUG
printf("on_button_yesno_yes_clicked\n");
#endif
@ -268,15 +269,15 @@ on_button_yesno_yes_clicked (GtkButton *button,
FALSE, FALSE);
break;
case STATUS_QUERY_UNFIT:
load_save_autosave();
callback_show_next_live_game();
load_save_autosave(bygfoot);
callback_show_next_live_game(bygfoot);
break;
case STATUS_QUERY_QUIT:
main_exit_program(EXIT_OK, NULL);
break;
case STATUS_QUERY_USER_NO_TURN:
load_save_autosave();
callback_show_next_live_game();
load_save_autosave(bygfoot);
callback_show_next_live_game(bygfoot);
break;
case STATUS_QUERY_KICK_YOUTH:
free_player(&g_array_index(current_user.youth_academy.players, Player, selected_row));
@ -671,6 +672,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 +697,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 +745,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 +789,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);
}

View File

@ -11,6 +11,7 @@
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include "bygfoot_struct.h"
#include "misc2_callbacks.h"
#include "misc2_interface.h"
#include "file.h"
@ -107,11 +108,11 @@ create_window_digits (void)
}
GtkWidget*
create_window_yesno (void)
create_window_yesno (Bygfoot *bygfoot)
{
GtkWidget *window_yesno;
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_yesno = GTK_WIDGET (gtk_builder_get_object (builder, "window_yesno"));
/* Store pointers to all widgets, for use by lookup_widget(). */

View File

@ -6,7 +6,7 @@ GtkWidget* create_window_job_offer (void);
GtkWidget* create_window_progress (void);
GtkWidget* create_window_warning (void);
GtkWidget* create_window_digits (void);
GtkWidget* create_window_yesno (void);
GtkWidget* create_window_yesno (Bygfoot *bygfoot);
GtkWidget* create_window_contract (void);
GtkWidget* create_window_user_management (void);
GtkWidget* create_window_debug (void);

View File

@ -222,12 +222,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);
}
@ -235,11 +236,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(bygfoot, "last_save");
}

View File

@ -38,11 +38,11 @@ create_window_bets (void)
}
GtkWidget*
create_window_splash (void)
create_window_splash (Bygfoot *bygfoot)
{
GtkWidget *window_splash;
GtkBuilder *builder;
builder = load_ui(file_find_support_file("bygfoot_misc3.glade", TRUE));
builder = load_ui_with_userdata(file_find_support_file("bygfoot_misc3.glade", TRUE), bygfoot);
window_splash = GTK_WIDGET (gtk_builder_get_object (builder, "window_splash"));
gtk_widget_show (window_splash);

View File

@ -2,7 +2,9 @@
* DO NOT EDIT THIS FILE - it is generated by Glade.
*/
#include "bygfoot.h"
GtkWidget* create_window_bets (void);
GtkWidget* create_window_splash (void);
GtkWidget* create_window_splash (Bygfoot *bygfoot);
GtkWidget* create_window_alr (void);
GtkWidget* create_window_news (void);

View File

@ -106,7 +106,7 @@ misc_callback_start_game(Bygfoot *bygfoot)
{
bygfoot_start_game(bygfoot);
window_create(WINDOW_MAIN);
window_create_with_userdata(WINDOW_MAIN, bygfoot);
game_gui_show_main();
@ -122,7 +122,7 @@ misc_callback_start_game(Bygfoot *bygfoot)
start_new_game();
free_users(TRUE);
debug_calibrate_betting_odds(opt_int("int_opt_calodds_skilldiffmax"),
opt_int("int_opt_calodds_matches"));
opt_int("int_opt_calodds_matches"), bygfoot);
main_exit_program(EXIT_OK, NULL);
}
}
@ -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(Bygfoot *bygfoot, const gchar *filename)
{
#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(bygfoot, filename, TRUE))
window_destroy(&window.splash);
else
gtk_widget_show(window.splash);

View File

@ -50,7 +50,7 @@ void
misc_callback_update_stadium_window(gboolean capacity);
void
misc_callback_startup_load(const gchar *filename);
misc_callback_startup_load(Bygfoot *bygfoot, const gchar *filename);
void
misc_callback_new_sponsor(void);

View File

@ -155,13 +155,14 @@ on_live_window_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
Bygfoot *bygfoot = (Bygfoot*)user_data;
#ifdef DEBUG
printf("on_live_window_delete_event\n");
#endif
if(GTK_WIDGET_IS_SENSITIVE(lookup_widget(widget, "button_live_close")))
{
on_button_live_close_clicked(NULL, NULL);
on_button_live_close_clicked(NULL, bygfoot);
return FALSE;
}
@ -173,6 +174,7 @@ G_MODULE_EXPORT void
on_button_live_close_clicked (GtkButton *button,
gpointer user_data)
{
Bygfoot *bygfoot = (Bygfoot*)user_data;
#ifdef DEBUG
printf("on_button_live_close_clicked\n");
#endif
@ -181,7 +183,7 @@ on_button_live_close_clicked (GtkButton *button,
stat4 != STATUS_SHOW_LAST_MATCH_PAUSE)
stat4 = STATUS_SHOW_LAST_MATCH_ABORT;
else if(stat1 != STATUS_SHOW_LAST_MATCH)
callback_show_next_live_game();
callback_show_next_live_game(bygfoot);
else
{
window_destroy(&window.live);
@ -206,6 +208,7 @@ G_MODULE_EXPORT void
on_button_resume_clicked (GtkButton *button,
gpointer user_data)
{
Bygfoot *bygfoot = (Bygfoot*)user_data;
#ifdef DEBUG
printf("on_button_resume_clicked\n");
#endif
@ -215,7 +218,7 @@ on_button_resume_clicked (GtkButton *button,
if(stat1 == STATUS_SHOW_LAST_MATCH)
{
callback_show_last_match(FALSE, &current_user.live_game);
callback_show_last_match(FALSE, &current_user.live_game, bygfoot);
return;
}
else if(game_check_live_game_resume_state())
@ -229,7 +232,7 @@ on_button_resume_clicked (GtkButton *button,
gtk_widget_grab_focus(button_pause);
}
game_gui_set_main_window_sensitivity(FALSE);
live_game_resume();
live_game_resume(bygfoot);
}
else
game_gui_show_warning(_("There were too many substitutions. Only 3 per game are allowed. Player list reset."));
@ -580,11 +583,12 @@ G_MODULE_EXPORT void
on_button_team_selection_back_clicked (GtkButton *button,
gpointer user_data)
{
Bygfoot *bygfoot = (Bygfoot*)user_data;
#ifdef DEBUG
printf("on_button_team_selection_back_clicked\n");
#endif
window_destroy(&window.startup);
stat0 = STATUS_SPLASH;
window_show_splash();
window_show_splash(bygfoot);
}

View File

@ -85,11 +85,11 @@ create_window_font_sel (void)
}
GtkWidget*
create_window_live (void)
create_window_live (Bygfoot *bygfoot)
{
GtkWidget *window_live;
GtkBuilder *builder;
builder = load_ui(file_find_support_file("bygfoot_misc.glade", TRUE));
builder = load_ui_with_userdata(file_find_support_file("bygfoot_misc.glade", TRUE), bygfoot);
window_live = GTK_WIDGET (gtk_builder_get_object (builder, "window_live"));
/* Store pointers to all widgets, for use by lookup_widget(). */

View File

@ -6,7 +6,7 @@
GtkWidget* create_window_startup (Bygfoot *bygfoot);
GtkWidget* create_window_font_sel (void);
GtkWidget* create_window_live (void);
GtkWidget* create_window_live (Bygfoot *bygfoot);
GtkWidget* create_window_stadium (void);
GtkWidget* create_window_file_chooser (void);
GtkWidget* create_window_sponsors (void);

View File

@ -55,10 +55,11 @@
/** Prototype of a function called at the start or
end of a week round. */
typedef void(*WeekFunc)(void);
typedef void(*WeekFuncBygfoot)(Bygfoot *);
/** Array of functions called when a week round
is ended. */
WeekFunc end_week_round_funcs[] =
WeekFuncBygfoot end_week_round_funcs[] =
{end_week_round_results, end_week_round_sort_tables,
end_week_round_generate_news, end_week_round_update_fixtures, NULL};
@ -284,7 +285,7 @@ start_new_season_reset_ids(void)
/** End a week round. */
void
end_week_round(void)
end_week_round(Bygfoot *bygfoot)
{
#ifdef DEBUG
printf("end_week_round\n");
@ -292,14 +293,14 @@ end_week_round(void)
gint i = 0;
gboolean new_week = TRUE;
WeekFunc *end_func = end_week_round_funcs;
WeekFuncBygfoot *end_func = end_week_round_funcs;
if(debug > 100)
g_print("End w %d r %d \n", week, week_round);
while(*end_func != NULL)
{
(*end_func)();
(*end_func)(bygfoot);
end_func++;
}
@ -339,12 +340,12 @@ end_week_round(void)
start_week();
}
start_week_round();
start_week_round(bygfoot);
}
/** Calculate the match results of a week round. */
void
end_week_round_results(void)
end_week_round_results(Bygfoot *bygfoot)
{
#ifdef DEBUG
printf("end_week_round_results\n");
@ -376,11 +377,11 @@ end_week_round_results(void)
{
g_array_append_val(live_games, live_game);
live_game_calculate_fixture(&g_array_index(lig(i).fixtures, Fixture, j),
&g_array_index(live_games, LiveGame, live_games->len - 1));
&g_array_index(live_games, LiveGame, live_games->len - 1), bygfoot);
}
else
live_game_calculate_fixture(&g_array_index(lig(i).fixtures, Fixture, j),
&usr(usr_idx).live_game);
&usr(usr_idx).live_game, bygfoot);
done++;
fixture_result_to_buf(&g_array_index(lig(i).fixtures, Fixture, j),
@ -389,7 +390,7 @@ end_week_round_results(void)
g_array_index(lig(i).fixtures, Fixture, j).teams[0]->name,
buf,
g_array_index(lig(i).fixtures, Fixture, j).teams[1]->name);
gui_show_progress((gfloat)done / num_matches, buf2,
bygfoot_show_progress(bygfoot, (gfloat)done / num_matches, buf2,
PIC_TYPE_MATCHPIC);
if(debug > 120)
@ -412,11 +413,11 @@ end_week_round_results(void)
{
g_array_append_val(live_games, live_game);
live_game_calculate_fixture(&g_array_index(acp(i)->fixtures, Fixture, j),
&g_array_index(live_games, LiveGame, live_games->len - 1));
&g_array_index(live_games, LiveGame, live_games->len - 1), bygfoot);
}
else
live_game_calculate_fixture(&g_array_index(acp(i)->fixtures, Fixture, j),
&usr(usr_idx).live_game);
&usr(usr_idx).live_game, bygfoot);
done++;
fixture_result_to_buf(&g_array_index(acp(i)->fixtures, Fixture, j),
@ -425,7 +426,7 @@ end_week_round_results(void)
g_array_index(acp(i)->fixtures, Fixture, j).teams[0]->name,
buf,
g_array_index(acp(i)->fixtures, Fixture, j).teams[1]->name);
gui_show_progress((gfloat)done / num_matches, buf2,
bygfoot_show_progress(bygfoot, (gfloat)done / num_matches, buf2,
PIC_TYPE_MATCHPIC);
if(debug > 120)
g_print("%s \n", buf2);
@ -433,12 +434,12 @@ end_week_round_results(void)
}
}
gui_show_progress(-1, "", PIC_TYPE_MATCHPIC);
bygfoot_show_progress(bygfoot, -1, "", PIC_TYPE_MATCHPIC);
}
/** Sort league and cup tables. */
void
end_week_round_sort_tables(void)
end_week_round_sort_tables(Bygfoot *bygfoot)
{
#ifdef DEBUG
printf("end_week_round_sort_tables\n");
@ -480,7 +481,7 @@ end_week_round_sort_tables(void)
/** Update cup fixtures. */
void
end_week_round_update_fixtures(void)
end_week_round_update_fixtures(Bygfoot *bygfoot)
{
#ifdef DEBUG
printf("end_week_round_update_fixtures\n");
@ -522,7 +523,7 @@ end_week_round_update_fixtures(void)
/** Write newspaper articles after week round. */
void
end_week_round_generate_news(void)
end_week_round_generate_news(Bygfoot *bygfoot)
{
gint i;
@ -549,7 +550,7 @@ end_week_round_generate_news(void)
/** Start a new week round. */
void
start_week_round(void)
start_week_round(Bygfoot *bygfoot)
{
#ifdef DEBUG
printf("start_week_round\n");
@ -575,7 +576,7 @@ start_week_round(void)
(week_round > 1 &&
!query_user_games_in_week_round(week, week_round - 1))))
{
end_week_round();
end_week_round(bygfoot);
}
else
{

View File

@ -41,19 +41,19 @@ void
start_generate_league_teams(void);
void
end_week_round(void);
end_week_round(Bygfoot *bygfoot);
void
end_week_round_results(void);
end_week_round_results(Bygfoot *bygfoot);
void
end_week_round_sort_tables(void);
end_week_round_sort_tables(Bygfoot *bygfoot);
void
end_week_round_update_fixtures(void);
end_week_round_update_fixtures(Bygfoot *bygfoot);
void
start_week_round(void);
start_week_round(Bygfoot *bygfoot);
void
start_week(void);
@ -95,6 +95,6 @@ void
start_week_update_leagues(void);
void
end_week_round_generate_news(void);
end_week_round_generate_news(Bygfoot *bygfoot);
#endif

View File

@ -58,13 +58,13 @@
/** Show the splash screen window. */
void
window_show_splash(void)
window_show_splash(Bygfoot *bygfoot)
{
#ifdef DEBUG
printf("window_show_splash\n");
#endif
window_create(WINDOW_SPLASH);
window_create_with_userdata(WINDOW_SPLASH, bygfoot);
treeview_show_contributors(
GTK_TREE_VIEW(lookup_widget(window.splash, "treeview_splash_contributors")));
@ -347,7 +347,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");
@ -420,11 +420,11 @@ 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(bygfoot, filename, FALSE);
else if(stat5 == STATUS_LOAD_GAME_SPLASH)
misc_callback_startup_load(filename);
misc_callback_startup_load(bygfoot, filename);
else if(stat5 == STATUS_SAVE_GAME)
load_save_save_game(filename);
load_save_save_game(bygfoot, filename);
else if(stat5 == STATUS_SELECT_MM_FILE_LOAD)
{
mm_file_exists = g_file_test(filename, G_FILE_TEST_EXISTS);
@ -435,7 +435,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."));
@ -450,7 +450,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);
@ -471,14 +471,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")),
@ -815,7 +815,7 @@ window_create_with_userdata(gint window_type, Bygfoot *bygfoot)
case WINDOW_MAIN:
if(window.main == NULL)
{
window.main = create_main_window();
window.main = create_main_window(bygfoot);
wind = window.main;
window_main_load_geometry();
window.paned_pos =
@ -840,7 +840,7 @@ window_create_with_userdata(gint window_type, Bygfoot *bygfoot)
if(window.live != NULL)
debug_print_message("window_create: called on already existing window\n");
else
window.live = create_window_live();
window.live = create_window_live(bygfoot);
if(((LiveGame*)statp)->fix != NULL)
strcpy(buf, league_cup_get_name_string(((LiveGame*)statp)->fix->clid));
wind = window.live;
@ -891,7 +891,7 @@ window_create_with_userdata(gint window_type, Bygfoot *bygfoot)
if(window.yesno != NULL)
debug_print_message("window_create: called on already existing window\n");
else
window.yesno = create_window_yesno();
window.yesno = create_window_yesno(bygfoot);
wind = window.yesno;
strcpy(buf, "???");
break;
@ -985,7 +985,7 @@ window_create_with_userdata(gint window_type, Bygfoot *bygfoot)
if(window.splash != NULL)
debug_print_message("window_create: called on already existing window\n");
else
window.splash = create_window_splash();
window.splash = create_window_splash(bygfoot);
wind = window.splash;
break;
case WINDOW_TRAINING_CAMP:

View File

@ -81,7 +81,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);
@ -105,7 +105,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);
@ -120,7 +120,7 @@ void
window_show_progress(gint pictype);
void
window_show_splash(void);
window_show_splash(Bygfoot *bygfoot);
void
window_load_hint_number(void);

View File

@ -73,7 +73,7 @@ xml_load_users(const gchar *dirname, const gchar *basename)
}
void
xml_load_league(const gchar *dirname, const gchar *basename)
xml_load_league(Bygfoot *bygfoot, const gchar *dirname, const gchar *basename)
{
#ifdef DEBUG
printf("xml_load_league\n");
@ -92,7 +92,7 @@ xml_load_league(const gchar *dirname, const gchar *basename)
sprintf(buf, _("Loading league: %s"),
lig(ligs->len - 1).name);
gui_show_progress(gui_get_progress_bar_fraction(), buf,
bygfoot_show_progress(bygfoot, bygfoot_get_progress_bar_fraction(bygfoot), buf,
PIC_TYPE_LOAD);
if(debug > 80)
@ -108,7 +108,7 @@ xml_load_league(const gchar *dirname, const gchar *basename)
}
void
xml_load_cup(Cup *cup, const gchar *dirname, const gchar *basename)
xml_load_cup(Bygfoot *bygfoot, Cup *cup, const gchar *dirname, const gchar *basename)
{
#ifdef DEBUG
printf("xml_load_cup\n");
@ -122,7 +122,7 @@ xml_load_cup(Cup *cup, const gchar *dirname, const gchar *basename)
sprintf(buf, _("Loading cup: %s"),
cup->name);
gui_show_progress(gui_get_progress_bar_fraction(), buf,
bygfoot_show_progress(bygfoot, bygfoot_get_progress_bar_fraction(bygfoot), buf,
PIC_TYPE_LOAD);
if(debug > 80)

View File

@ -104,10 +104,10 @@ void
xml_load_users(const gchar *dirname, const gchar *basename);
void
xml_load_league(const gchar *dirname, const gchar *basename);
xml_load_league(Bygfoot *bygfoot, const gchar *dirname, const gchar *basename);
void
xml_load_cup(Cup *cup, const gchar *dirname, const gchar *basename);
xml_load_cup(Bygfoot *bygfoot, Cup *cup, const gchar *dirname, const gchar *basename);
void
xml_load_transfers(const gchar *dirname, const gchar *basename);

View File

@ -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
@ -113,18 +114,18 @@ xml_loadsave_leagues_cups_text (GMarkupParseContext *context,
buf[text_len] = '\0';
if(state == TAG_LEAGUE_FILE)
xml_load_league(dir, buf);
xml_load_league(bygfoot, dir, buf);
else if(state == TAG_CUP_FILE)
{
new_cup = cup_new(FALSE);
g_array_append_val(cps, new_cup);
xml_load_cup(&g_array_index(cps, Cup, cps->len - 1), dir, buf);
xml_load_cup(bygfoot, &g_array_index(cps, Cup, cps->len - 1), dir, buf);
}
}
/** 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(Bygfoot *bygfoot, const gchar *dirname, const gchar *prefix)
{
#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))
{

View File

@ -54,7 +54,7 @@ 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(Bygfoot *bygfoot, const gchar *dirname, const gchar *prefix);
void