diff --git a/src/Makefile.am b/src/Makefile.am index cb0a0fba..740207c1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -46,7 +46,7 @@ bygfoot_SOURCES = \ treeview.c cup.h finance.h fixture.h free.h game.h league.h live_game.h maths.h misc.h player.h option.h support.h team.h transfer.h treeview.h treeview_helper.h user.h \ treeview_helper.c cup.h file.h fixture.h free.h league.h misc.h option.h player.h support.h team.h treeview.h treeview_helper.h user.h variables.h \ user.c cup.h fixture.h free.h game_gui.h league.h live_game.h maths.h misc.h option.h player.h team.h transfer.h treeview.h user.h window.h \ - window.c file.h finance.h free.h game_gui.h gui.h interface.h main.h misc_interface.h misc2_interface.h option.h support.h user.h window.h \ + window.c file.h finance.h free.h game_gui.h gui.h interface.h main.h misc_interface.h misc2_interface.h option.h support.h treeview.h treeview_helper.h user.h window.h \ xml.c cup.h file.h free.h gui.h league.h misc.h option.h support.h table.h transfer_struct.h user.h variables.h xml.h xml_loadsave_cup.h xml_loadsave_league.h xml_loadsave_teams.h xml_loadsave_fixtures.h xml_loadsave_table.h xml_loadsave_transfers.h xml_loadsave_users.h \ xml_loadsave_misc.c cup.h file.h misc.h variables.h xml.h xml_loadsave_misc.h xml_loadsave_cup.h xml_loadsave_league.h \ xml_loadsave_cup.c cup.h file.h misc.h table.h team.h xml.h xml_loadsave_cup.h xml_loadsave_fixtures.h xml_loadsave_table.h xml_loadsave_teams.h \ diff --git a/src/callback_func.c b/src/callback_func.c index 1b085fdf..d4af92a2 100644 --- a/src/callback_func.c +++ b/src/callback_func.c @@ -116,26 +116,59 @@ callback_player_clicked(gint idx, GdkEventButton *event) setsav0; } -/** Show the last match of the current user. */ +/** 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(void) +callback_show_last_match(gboolean start) { gint i; - stat2 = cur_user; + stat4 = -1; - window_create(WINDOW_LIVE); + if(start) + { + stat2 = cur_user; - current_user.live_game.fix = - &g_array_index(league_cup_get_fixtures(current_user.live_game.fix_clid), - Fixture, current_user.live_game.fix_idx); + window_create(WINDOW_LIVE); - treeview_show_game_stats(GTK_TREE_VIEW(lookup_widget(window.live, "treeview_stats")), - ¤t_user.live_game); - live_game_set_match(¤t_user.live_game); + current_user.live_game.fix = + &g_array_index(league_cup_get_fixtures(current_user.live_game.fix_clid), + Fixture, current_user.live_game.fix_idx); - for(i=0;ilen;i++) + treeview_show_game_stats(GTK_TREE_VIEW(lookup_widget(window.live, "treeview_stats")), + ¤t_user.live_game); + live_game_set_match(¤t_user.live_game); + } + else + { + gtk_widget_set_sensitive(lookup_widget(window.live, "button_pause"), TRUE); + gtk_widget_set_sensitive(lookup_widget(window.live, "button_resume"), FALSE); + } + + for(i=stat3;ilen;i++) + { game_gui_live_game_show_unit(&g_array_index(current_user.live_game.units, LiveGameUnit, i)); + + if(stat4 == STATUS_SHOW_LAST_MATCH_PAUSE || + stat4 == STATUS_SHOW_LAST_MATCH_ABORT) + { + stat3 = i + 1; + break; + } + } + + if(stat4 == STATUS_SHOW_LAST_MATCH_PAUSE) + { + gtk_widget_set_sensitive(lookup_widget(window.live, "button_pause"), FALSE); + gtk_widget_set_sensitive(lookup_widget(window.live, "button_resume"), TRUE); + } + else if(stat4 == STATUS_SHOW_LAST_MATCH_ABORT) + { + window_destroy(&window.live, TRUE); + stat1 = stat2 = stat3 = stat4 = -1; + } + else + stat3 = -1; } /** Show the last match stats of the current user. */ diff --git a/src/callback_func.h b/src/callback_func.h index 0b2ee8b0..1b94fb57 100644 --- a/src/callback_func.h +++ b/src/callback_func.h @@ -10,7 +10,7 @@ void callback_player_clicked(gint idx, GdkEventButton *event); void -callback_show_last_match(void); +callback_show_last_match(gboolean start); void callback_show_fixtures(gint type); diff --git a/src/callbacks.c b/src/callbacks.c index 7a23f745..3d1d18cf 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -595,8 +595,9 @@ on_menu_user_show_last_match_activate (GtkMenuItem *menuitem, return; } - stat0 = STATUS_SHOW_LAST_MATCH; - callback_show_last_match(); + stat1 = STATUS_SHOW_LAST_MATCH; + stat3 = 0; + callback_show_last_match(TRUE); } diff --git a/src/enums.h b/src/enums.h index 92e9b7e9..b96f713d 100644 --- a/src/enums.h +++ b/src/enums.h @@ -66,6 +66,8 @@ enum Status0Value STATUS_BROWSE_TEAMS, STATUS_TEAM_SELECTION, STATUS_SHOW_LAST_MATCH, + STATUS_SHOW_LAST_MATCH_PAUSE, + STATUS_SHOW_LAST_MATCH_ABORT, STATUS_SHOW_LAST_MATCH_STATS, STATUS_SHOW_FIXTURES, STATUS_SHOW_FIXTURES_WEEK, diff --git a/src/game_gui.c b/src/game_gui.c index e9530c69..46745a85 100644 --- a/src/game_gui.c +++ b/src/game_gui.c @@ -62,8 +62,8 @@ game_gui_live_game_show_unit(const LiveGameUnit *unit) if(unit->event.type == LIVE_GAME_EVENT_START_MATCH) { - gtk_widget_set_sensitive(button_live_close, FALSE); - gtk_widget_set_sensitive(button_pause, (stat0 != STATUS_SHOW_LAST_MATCH)); + gtk_widget_set_sensitive(button_live_close, (stat1 == STATUS_SHOW_LAST_MATCH)); + gtk_widget_set_sensitive(button_pause, TRUE); gtk_widget_set_sensitive(button_resume, FALSE); } else if(unit->event.type == LIVE_GAME_EVENT_END_MATCH) @@ -76,7 +76,7 @@ game_gui_live_game_show_unit(const LiveGameUnit *unit) } else if(unit->event.type == LIVE_GAME_EVENT_PENALTIES) { - gtk_widget_set_sensitive(button_pause, FALSE); + gtk_widget_set_sensitive(button_pause, (stat1 == STATUS_SHOW_LAST_MATCH)); gtk_widget_set_sensitive(button_resume, FALSE); } } diff --git a/src/misc_callback_func.c b/src/misc_callback_func.c index 3cbb91f3..c59be0e2 100644 --- a/src/misc_callback_func.c +++ b/src/misc_callback_func.c @@ -125,6 +125,12 @@ misc_callback_remove_user(GdkEventButton *event) void misc_callback_pause_live_game(void) { + if(stat1 == STATUS_SHOW_LAST_MATCH) + { + stat4 = STATUS_SHOW_LAST_MATCH_PAUSE; + return; + } + if(g_array_index(usr(stat2).live_game.units, LiveGameUnit, usr(stat2).live_game.units->len - 1).event.type == LIVE_GAME_EVENT_END_MATCH) diff --git a/src/misc_callbacks.c b/src/misc_callbacks.c index 1e0ca7e2..32455812 100644 --- a/src/misc_callbacks.c +++ b/src/misc_callbacks.c @@ -168,11 +168,16 @@ void on_button_live_close_clicked (GtkButton *button, gpointer user_data) { - stat2 = -1; - if(stat0 != STATUS_SHOW_LAST_MATCH) + if(stat1 == STATUS_SHOW_LAST_MATCH && stat3 != -1 && + stat4 != STATUS_SHOW_LAST_MATCH_PAUSE) + stat4 = STATUS_SHOW_LAST_MATCH_ABORT; + else if(stat1 != STATUS_SHOW_LAST_MATCH) callback_show_next_live_game(); else + { window_destroy(&window.live, TRUE); + stat1 = stat2 = stat3 = stat4 = -1; + } } @@ -196,7 +201,12 @@ void on_button_resume_clicked (GtkButton *button, gpointer user_data) { - if(game_check_live_game_resume_state()) + if(stat1 == STATUS_SHOW_LAST_MATCH) + { + callback_show_last_match(FALSE); + return; + } + else if(game_check_live_game_resume_state()) { gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); if(g_array_index(usr(stat2).live_game.units, LiveGameUnit,