From 780231902abb150d8161489bb98ee47ca4d0ec69 Mon Sep 17 00:00:00 2001 From: gyboth Date: Thu, 7 Apr 2005 16:44:33 +0000 Subject: [PATCH] Some fixes; added confirmations. --- bygfoot.glade | 4 +- bygfoot_misc.glade | 322 +++++++++++------- bygfoot_misc2.glade | 21 +- bygfoot_options.glade | 70 ++-- src/Makefile.am | 12 +- src/callback_func.c | 19 +- src/callbacks.c | 73 ++-- src/callbacks.h | 16 +- src/enums.h | 11 + src/finance.c | 8 +- src/game.c | 10 +- src/game_gui.c | 3 +- src/game_gui.h | 4 + src/interface.c | 2 +- src/load_save.c | 22 ++ src/load_save.h | 3 + src/main.c | 1 + src/misc2_callback_func.c | 36 +- src/misc2_callbacks.c | 48 +-- src/misc2_callbacks.h | 6 +- src/misc2_interface.c | 11 +- src/misc_callback_func.c | 2 + src/misc_callbacks.c | 11 +- src/misc_callbacks.h | 4 - src/misc_interface.c | 107 ++++-- src/option_gui.c | 22 +- src/options_interface.c | 39 ++- src/player.c | 51 +++ src/player.h | 4 + src/start_end.c | 22 +- src/start_end.h | 3 + src/treeview.c | 103 ++++++ src/treeview.h | 9 + src/user.c | 65 +++- src/user.h | 10 +- src/user_struct.h | 1 + src/variables.h | 3 + src/window.c | 24 +- src/window.h | 2 +- src/xml_country.c | 1 - src/xml_loadsave_misc.c | 17 +- support_files/bygfoot.conf | 5 +- support_files/bygfoot_user.conf | 1 - .../definitions/cup_brazil_prom_games.xml | 26 ++ 44 files changed, 875 insertions(+), 359 deletions(-) create mode 100644 support_files/definitions/cup_brazil_prom_games.xml diff --git a/bygfoot.glade b/bygfoot.glade index 637693bc..71e30d8c 100644 --- a/bygfoot.glade +++ b/bygfoot.glade @@ -772,7 +772,7 @@ 2 True - Save game (S or Ctrl - S) + Save game (Ctrl - S) True GTK_RELIEF_NORMAL @@ -1841,7 +1841,7 @@ True Show info True - + diff --git a/bygfoot_misc.glade b/bygfoot_misc.glade index f9afc0d5..c72abe64 100644 --- a/bygfoot_misc.glade +++ b/bygfoot_misc.glade @@ -1460,92 +1460,91 @@ 5 - + True + 5 + 2 False - 3 + 3 + 3 - + True - False - 3 - - - - True - Status: - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - label107 - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - + Status: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 - 0 - True - True + 0 + 1 + 0 + 1 + fill + - + + True + label107 + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 0 + 1 + fill + + + + + + + True + Current capacity: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + True False - 3 - - - - True - Current capacity: - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - + 0 @@ -1556,7 +1555,7 @@ GTK_JUSTIFY_LEFT False False - 0.5 + 0 0.5 0 0 @@ -1571,7 +1570,7 @@ True - seats + seats False False GTK_JUSTIFY_LEFT @@ -1590,57 +1589,142 @@ - 0 - False - False + 1 + 2 + 1 + 2 + fill + fill - + True - False - 3 - - - - True - Current safety: - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - GTK_PROGRESS_LEFT_TO_RIGHT - 0 - 0.1 - - - 0 - False - False - - + Current safety: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 - 0 - False - False + 0 + 1 + 2 + 3 + fill + + + + + + + True + GTK_PROGRESS_LEFT_TO_RIGHT + 0 + 0.1 + + + 1 + 2 + 2 + 3 + fill + + + + + + + True + Average attendance + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + label110 + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 3 + 4 + fill + + + + + + + True + Average attendance % + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 4 + 5 + fill + + + + + + + True + GTK_PROGRESS_LEFT_TO_RIGHT + 0 + 0.1 + + + 1 + 2 + 4 + 5 + fill + diff --git a/bygfoot_misc2.glade b/bygfoot_misc2.glade index e511dc3a..e28357ed 100644 --- a/bygfoot_misc2.glade +++ b/bygfoot_misc2.glade @@ -984,7 +984,7 @@ True False - 3 + 5 @@ -1024,25 +1024,6 @@ - - - True - True - Don't bother me with this next time. - True - GTK_RELIEF_NORMAL - False - False - True - - - - 0 - False - False - - - True diff --git a/bygfoot_options.glade b/bygfoot_options.glade index de71a737..1edeaf2c 100644 --- a/bygfoot_options.glade +++ b/bygfoot_options.glade @@ -42,10 +42,11 @@ 0 - + True + Whether to show a confirmation popup when you press quit and the game state is not saved True - Confirm new week round + Confirm quit when not saved True GTK_RELIEF_NORMAL False @@ -60,10 +61,11 @@ - + True + Whether to show a confirmation popup if a user team has an injured or banned player in the startup formation True - Confirm quit + Confirm when unfit True GTK_RELIEF_NORMAL False @@ -211,6 +213,7 @@ True + How often the game is saved automatically True 1 0 @@ -226,6 +229,47 @@ False + + + + True + Autosave files + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + How many files the autosave uses + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 1 0 100 1 10 10 + + + 0 + True + True + + 1 @@ -826,24 +870,6 @@ False 0 - - - True - True - Confirm when unfit - True - GTK_RELIEF_NORMAL - False - False - True - - - 0 - False - False - - - True diff --git a/src/Makefile.am b/src/Makefile.am index 853c8183..1b61b3dd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -10,7 +10,7 @@ bin_PROGRAMS = bygfoot bygfoot_SOURCES = \ callback_func.c callback_func.h callbacks.h cup.h finance.h fixture.h game_gui.h league.h live_game.h maths.h misc.h option.h player.h start_end.h team.h transfer.h treeview.h user.h window.h \ - callbacks.c callbacks.h callback_func.h game_gui.h load_save.h main.h option.h player.h team.h transfer.h treeview.h user.h window.h \ + callbacks.c callbacks.h callback_func.h free.h game_gui.h load_save.h main.h option.h player.h team.h transfer.h treeview.h user.h window.h \ cup.c cup.h free.h main.h maths.h misc.h team.h variables.h xml_league.h \ file.c file.h free.h main.h misc.h option.h support.h variables.h \ finance.c callbacks.h finance.h game_gui.h maths.h option.h player.h team.h user.h \ @@ -22,14 +22,14 @@ bygfoot_SOURCES = \ interface.c callbacks.h interface.h support.h \ league.c cup.h league.h table.h team.h variables.h \ live_game.c fixture.h free.h game.h game_gui.h live_game.h maths.h misc_callback_func.h option.h player.h support.h team.h treeview.h user.h variables.h window.h \ - load_save.c file.h gui.h load_save.h option.h support.h variables.h xml_loadsave_misc.h xml_loadsave_cup.h xml_loadsave_league.h xml_loadsave_transfers.h xml_loadsave_users.h xml.h \ + load_save.c file.h game_gui.h gui.h load_save.h option.h support.h variables.h xml_loadsave_misc.h xml_loadsave_cup.h xml_loadsave_league.h xml_loadsave_transfers.h xml_loadsave_users.h xml.h \ main.c cup_struct.h misc_callbacks.h file.h free.h league_struct.h live_game.h main.h transfer_struct.h variables.h window.h \ maths.c maths.h misc.h \ misc.c main.h maths.h misc.h \ - misc_callbacks.c callbacks.h callback_func.h game.h game_gui.h live_game.h load_save.h main.h misc_callback_func.h misc_callbacks.h option.h user.h variables.h window.h \ + misc_callbacks.c callbacks.h callback_func.h game.h game_gui.h live_game.h load_save.h main.h misc_callback_func.h misc_callbacks.h option.h user.h variables.h window.h xml_country.h \ misc_callback_func.c callbacks.h finance.h game.h game_gui.h gui.h load_save.h maths.h misc_callback_func.h option.h start_end.h support.h treeview.h user.h variables.h window.h xml_country.h xml_name.h \ misc_interface.c misc_interface.h misc_callbacks.h support.h \ - misc2_callbacks.c finance.h game_gui.h main.h misc2_callbacks.h misc2_callback_func.h misc2_interface.h player.h support.h transfer.h treeview.h user.h window.h \ + misc2_callbacks.c callback_func.h finance.h game_gui.h main.h misc2_callbacks.h misc2_callback_func.h misc2_interface.h player.h support.h transfer.h treeview.h user.h window.h \ misc2_callback_func.c file.h finance.h game_gui.h maths.h misc2_callback_func.h option.h player.h support.h team.h treeview.h transfer.h user.h window.h \ misc2_interface.c misc2_interface.h misc2_callbacks.h support.h \ option.c option.h variables.h \ @@ -37,14 +37,14 @@ bygfoot_SOURCES = \ options_callbacks.c file.h options_callbacks.h options_interface.h option_gui.h support.h user.h variables.h window.h \ options_interface.c options_interface.h options_callbacks.h support.h \ player.c cup.h free.h game_gui.h league.h maths.h misc.h option.h player.h team.h user.h \ - start_end.c cup.h file.h finance.h fixture.h game_gui.h gui.h league.h live_game.h main.h maths.h option.h start_end.h table.h team.h transfer.h user.h variables.h xml_name.h \ + start_end.c cup.h file.h finance.h fixture.h game_gui.h gui.h league.h load_save.h live_game.h main.h maths.h option.h start_end.h table.h team.h transfer.h user.h variables.h xml_name.h \ support.c support.h \ table.c cup.h league.h table.h variables.h \ team.c cup.h fixture.h game.h game_gui.h league.h maths.h misc.h option.h player.h team.h transfer.h user.h \ transfer.c finance.h free.h game_gui.h maths.h option.h player.h support.h team.h transfer.h treeview.h user.h \ treeview.c cup.h file.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_cell.h user.h \ treeview_cell.c misc.h option.h player.h team.h treeview.h treeview_cell.h user.h variables.h \ - user.c fixture.h free.h game_gui.h live_game.h maths.h misc.h option.h player.h team.h transfer.h user.h window.h \ + user.c fixture.h free.h game_gui.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 misc_interface.h misc2_interface.h option.h support.h user.h window.h \ xml.c cup.h file.h free.h gui.h league.h misc.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 file.h misc.h variables.h xml.h xml_loadsave_misc.h xml_loadsave_cup.h xml_loadsave_league.h \ diff --git a/src/callback_func.c b/src/callback_func.c index e21bc9b5..c23d8220 100644 --- a/src/callback_func.c +++ b/src/callback_func.c @@ -36,7 +36,7 @@ callback_show_next_live_game(void) option_int("int_opt_user_show_live_game", &usr(fixture_user_team_involved(&g_array_index(lig(i).fixtures, Fixture, j))). options)) - { + { live_game_calculate_fixture(&g_array_index(lig(i).fixtures, Fixture, j)); return; } @@ -62,6 +62,8 @@ callback_show_next_live_game(void) /* no more user games to show: end round. */ end_week_round(); + + setsav0; } /** Handle a click on the player list. @@ -114,6 +116,8 @@ callback_player_clicked(gint idx, GdkEventButton *event) selected_row[0] = idx; } } + + setsav0; } /** Show the last match of the current user. */ @@ -237,6 +241,7 @@ callback_transfer_list_clicked(gint idx) { transfer_remove_player(idx); on_button_transfers_clicked(NULL, NULL); + setsav0; return; } @@ -303,6 +308,8 @@ callback_offer_new_contract(gint idx) powf(-1, (pl->age > pl->peak_age)))) * (1 + scout_dev))); } + + setsav0; } /** Show the player list of a team in the browse-teams mode. */ @@ -381,13 +388,13 @@ callback_fire_player(gint idx) gchar buf[SMALL], buf2[SMALL]; Player *pl = player_of(current_user.tm, idx); - stat0 = STATUS_FIRE_PLAYER; - stat1 = idx; - stat2 = (gint)rint(pl->wage * const_float("float_player_fire_wage_factor") * pl->contract); + stat1 = STATUS_FIRE_PLAYER; + stat2 = idx; + stat3 = (gint)rint(pl->wage * const_float("float_player_fire_wage_factor") * pl->contract); - misc_print_grouped_int(stat2, buf2, FALSE); + misc_print_grouped_int(stat3, buf2, FALSE); sprintf(buf, _("You want to fire %s. Since his contract expires in %.1f years, he demands a compensation of %s. Do you accept?"), pl->name->str, pl->contract, buf2); - window_show_yesno(buf, FALSE); + window_show_yesno(buf); } diff --git a/src/callbacks.c b/src/callbacks.c index 2d645f40..e47f27c3 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -1,5 +1,6 @@ #include "callbacks.h" #include "callback_func.h" +#include "free.h" #include "game_gui.h" #include "load_save.h" #include "main.h" @@ -26,7 +27,12 @@ void on_menu_new_activate (GtkMenuItem *menuitem, gpointer user_data) { + window_destroy(&window.main, FALSE); + free_memory(); + main_init(-1, NULL); + window_show_startup(); + stat0 = STATUS_TEAM_SELECTION; } @@ -63,7 +69,13 @@ void on_menu_quit_activate (GtkMenuItem *menuitem, gpointer user_data) { - main_exit_program(EXIT_OK, NULL); + if(!getsav || !opt_int("int_opt_confirm_quit")) + main_exit_program(EXIT_OK, NULL); + else + { + stat1 = STATUS_QUERY_QUIT; + window_show_yesno("The current game state is unsaved and will be lost. Continue?"); + } } @@ -123,7 +135,14 @@ void on_button_new_week_clicked (GtkButton *button, gpointer user_data) { - callback_show_next_live_game(); + if(!opt_int("int_opt_confirm_unfit") || + !query_user_teams_have_unfit()) + callback_show_next_live_game(); + else + { + stat1 = STATUS_QUERY_UNFIT; + window_show_yesno(_("There are injured or banned players in one of the user teams. Continue?")); + } } @@ -272,14 +291,6 @@ on_menu_season_history_activate (GtkMenuItem *menuitem, } -void -on_menu_show_info_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - -} - - void on_menu_put_on_transfer_list_activate (GtkMenuItem *menuitem, gpointer user_data) @@ -290,6 +301,7 @@ on_menu_put_on_transfer_list_activate (GtkMenuItem *menuitem, game_gui_print_message(_("The player is already on the list.")); else { + setsav0; transfer_add_remove_user_player(player_of(current_user.tm, selected_row[0])); selected_row[0] = -1; } @@ -306,6 +318,7 @@ on_menu_remove_from_transfer_list_activate (GtkMenuItem *menuitem, game_gui_print_message(_("The player is not on the list.")); else { + setsav0; transfer_add_remove_user_player(player_of(current_user.tm, selected_row[0])); selected_row[0] = -1; } @@ -340,6 +353,7 @@ on_menu_shoots_penalties_activate (GtkMenuItem *menuitem, opt_user_set_int("int_opt_user_penalty_shooter", -1); game_gui_print_message(_("Penalty/free kick shooter deselected.")); treeview_show_user_player_list(); + setsav0; } else { @@ -349,6 +363,7 @@ on_menu_shoots_penalties_activate (GtkMenuItem *menuitem, player_of(current_user.tm, selected_row[0])->id); game_gui_print_message(buf); treeview_show_user_player_list(); + setsav0; } selected_row[0] = -1; @@ -445,14 +460,6 @@ on_menu_previous_user_activate (GtkMenuItem *menuitem, } -void -on_menu_show_user_list_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - -} - - void on_menu_custom_structure_activate (GtkMenuItem *menuitem, gpointer user_data) @@ -469,6 +476,7 @@ on_menu_team_button_press_event (GtkWidget *widget, gpointer user_data) { game_gui_read_radio_items(widget); + setsav0; return FALSE; } @@ -477,7 +485,7 @@ void on_menu_manage_users_activate (GtkMenuItem *menuitem, gpointer user_data) { - stat0 = STATUS_USER_MANAGEMENT; + stat0 = stat1 = STATUS_USER_MANAGEMENT; window_create(WINDOW_USER_MANAGEMENT); treeview_show_users(GTK_TREE_VIEW(lookup_widget(window.user_management, "treeview_user_management_users"))); treeview_show_team_list(GTK_TREE_VIEW(lookup_widget(window.user_management, "treeview_user_management_teams")), @@ -542,6 +550,8 @@ on_eventbox_style_button_press_event (GtkWidget *widget, if(stat0 == STATUS_MAIN) treeview_show_next_opponent(); + setsav0; + return FALSE; } @@ -573,6 +583,8 @@ on_eventbox_boost_button_press_event (GtkWidget *widget, if(stat0 == STATUS_MAIN) treeview_show_next_opponent(); + setsav0; + return FALSE; } @@ -601,6 +613,8 @@ on_menu_check_button_press_event (GtkWidget *widget, { game_gui_read_check_items(widget); + setsav0; + return FALSE; } @@ -616,14 +630,23 @@ on_menu_offer_new_contract_activate (GtkMenuItem *menuitem, callback_offer_new_contract(selected_row[0]); selected_row[0] = -1; + + setsav0; } void -on_player_menu_show_info_activate (GtkMenuItem *menuitem, - gpointer user_data) +on_menu_show_info_activate (GtkMenuItem *menuitem, + gpointer user_data) { + if(selected_row[0] == -1) + { + game_gui_print_message(_("You haven't selected a player.")); + return; + } + stat0 = STATUS_SHOW_PLAYER_INFO; + treeview_show_player_info(player_of(current_user.tm, selected_row[0])); } @@ -677,3 +700,11 @@ on_menu_browse_players_activate (GtkMenuItem *menuitem, callback_show_player_list(SHOW_CURRENT); stat0 = STATUS_SHOW_PLAYER_LIST; } + +void +on_player_menu_show_info_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + on_menu_show_info_activate(NULL, NULL); +} + diff --git a/src/callbacks.h b/src/callbacks.h index f628d51e..e15c956a 100644 --- a/src/callbacks.h +++ b/src/callbacks.h @@ -98,10 +98,6 @@ void on_menu_season_history_activate (GtkMenuItem *menuitem, gpointer user_data); -void -on_menu_show_info_activate (GtkMenuItem *menuitem, - gpointer user_data); - void on_menu_put_on_transfer_list_activate (GtkMenuItem *menuitem, gpointer user_data); @@ -141,10 +137,6 @@ void on_menu_previous_user_activate (GtkMenuItem *menuitem, gpointer user_data); -void -on_menu_show_user_list_activate (GtkMenuItem *menuitem, - gpointer user_data); - void on_menu_custom_structure_activate (GtkMenuItem *menuitem, gpointer user_data); @@ -207,8 +199,8 @@ on_menu_offer_new_contract_activate (GtkMenuItem *menuitem, gpointer user_data); void -on_player_menu_show_info_activate (GtkMenuItem *menuitem, - gpointer user_data); +on_menu_show_info_activate (GtkMenuItem *menuitem, + gpointer user_data); void on_player_menu_put_on_transfer_list_activate @@ -237,4 +229,8 @@ on_player_menu_shoots_penalties_activate void on_menu_browse_players_activate (GtkMenuItem *menuitem, gpointer user_data); + +void +on_player_menu_show_info_activate (GtkMenuItem *menuitem, + gpointer user_data); #endif diff --git a/src/enums.h b/src/enums.h index 1b9320b8..2b38207d 100644 --- a/src/enums.h +++ b/src/enums.h @@ -1,6 +1,14 @@ #ifndef ENUMS_H #define ENUMS_H +/** Some counters. */ +enum Counters +{ + COUNT_AUTOSAVE = 0, + COUNT_AUTOSAVE_FILE, + COUNT_END +}; + /** Scout and physio qualities. */ enum Quality { @@ -50,6 +58,7 @@ enum Status0Value STATUS_SHOW_LIVE_GAME, STATUS_LIVE_GAME_PAUSE, STATUS_SHOW_TEAM_LIST, + STATUS_SHOW_PLAYER_INFO, STATUS_BROWSE_TEAMS, STATUS_TEAM_SELECTION, STATUS_SHOW_LAST_MATCH, @@ -75,6 +84,8 @@ enum Status0Value STATUS_SAVE_GAME, STATUS_LOAD_GAME, STATUS_LOAD_GAME_TEAM_SELECTION, + STATUS_QUERY_UNFIT, + STATUS_QUERY_QUIT, STATUS_END }; diff --git a/src/finance.c b/src/finance.c index 34a8290b..a1f5e36e 100644 --- a/src/finance.c +++ b/src/finance.c @@ -42,19 +42,21 @@ finance_update_user_weekly(User *user) for(i=0;iplayers->len;i++) { user->money_out[1][MON_OUT_WAGE] -= player_of(tm, i)->wage; + user->money -= player_of(tm, i)->wage; if(player_of(tm, i)->health > 0) + { + user->money -= (gint)(finance_wage_unit(tm) * physio_factor[user->physio % 10]); user->money_out[1][MON_OUT_PHYSIO] -= (gint)(finance_wage_unit(tm) * physio_factor[user->physio % 10]); + } } user->money_out[1][MON_OUT_SCOUT] -= (gint)(finance_wage_unit(tm) * scout_factor[user->scout % 10]); + user->money -= (gint)(finance_wage_unit(tm) * scout_factor[user->scout % 10]); user->debt = (gint)rint((gfloat)user->debt * (1 + const_float("float_finance_interest"))); - for(i=0;imoney += user->money_out[1][i]; - if(user->money < -finance_team_drawing_credit_loan(user->tm, FALSE) && user->counters[COUNT_USER_POSITIVE] == -1) { diff --git a/src/game.c b/src/game.c index 1f45c437..86330277 100644 --- a/src/game.c +++ b/src/game.c @@ -283,8 +283,11 @@ game_initialize(Fixture *fix) if(user_idx[i] != -1) { if(i == 1 || !fix->home_advantage) + { usr(user_idx[i]).money_out[1][MON_OUT_JOURNEY] -= (gint)(finance_wage_unit(fix->teams[i]) * journey_factor); + usr(user_idx[i]).money -= (gint)(finance_wage_unit(fix->teams[i]) * journey_factor); + } if(!fix->home_advantage) { @@ -489,7 +492,8 @@ game_player_injury(Player *pl) math_gauss_disti(const_int("int_player_injury_duration_ligament") - const_int("int_player_injury_duration_dev_ligament"), const_int("int_player_injury_duration_ligament") + - const_int("int_player_injury_duration_dev_ligament"))}; + const_int("int_player_injury_duration_dev_ligament")), + 50}; for(i=1;i<13;i++) injury_probs[i] += injury_probs[i - 1]; @@ -503,6 +507,10 @@ game_player_injury(Player *pl) pl->recovery = duration[i - 1] + 1; pl->cskill = pl->fitness = 0; } + + if(pl->health == PLAYER_INJURY_CAREER_STOP && team_is_user(pl->team) != -1) + user_event_add(&usr(team_is_user(pl->team)), EVENT_TYPE_PLAYER_CAREER_STOP, pl->id, -1, + NULL, NULL); } /** Return a factor influencing who's fouled whom diff --git a/src/game_gui.c b/src/game_gui.c index 0f61c2e3..d061144b 100644 --- a/src/game_gui.c +++ b/src/game_gui.c @@ -341,7 +341,8 @@ game_gui_print_message(gchar *text) gboolean game_gui_clear_entry_message(gpointer data) { - gtk_entry_set_text(GTK_ENTRY(lookup_widget(window.main, "entry_message")), ""); + if(window.main != NULL) + gtk_entry_set_text(GTK_ENTRY(lookup_widget(window.main, "entry_message")), ""); return FALSE; } diff --git a/src/game_gui.h b/src/game_gui.h index ad3dba79..bb664b28 100644 --- a/src/game_gui.h +++ b/src/game_gui.h @@ -4,6 +4,10 @@ #include "bygfoot.h" #include "live_game_struct.h" +#define setsav1 gtk_widget_set_sensitive(lookup_widget(window.main, "button_save"), FALSE) +#define setsav0 gtk_widget_set_sensitive(lookup_widget(window.main, "button_save"), TRUE) +#define getsav GTK_WIDGET_SENSITIVE(lookup_widget(window.main, "button_save")) + void game_gui_live_game_show_unit(const LiveGameUnit *unit); diff --git a/src/interface.c b/src/interface.c index db6f8caa..16f35964 100644 --- a/src/interface.c +++ b/src/interface.c @@ -612,7 +612,7 @@ create_main_window (void) gtk_widget_show (button_save); gtk_box_pack_start (GTK_BOX (hbox1), button_save, FALSE, FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (button_save), 2); - gtk_tooltips_set_tip (tooltips, button_save, _("Save game (S or Ctrl - S)"), NULL); + gtk_tooltips_set_tip (tooltips, button_save, _("Save game (Ctrl - S)"), NULL); gtk_widget_add_accelerator (button_save, "clicked", accel_group, GDK_s, 0, GTK_ACCEL_VISIBLE); diff --git a/src/load_save.c b/src/load_save.c index 5b5ae1ea..79a8d2e0 100644 --- a/src/load_save.c +++ b/src/load_save.c @@ -1,5 +1,6 @@ #include "file.h" #include "gui.h" +#include "game_gui.h" #include "load_save.h" #include "option.h" #include "support.h" @@ -85,6 +86,7 @@ load_save_save_game(const gchar *filename) g_free(fullname); gui_show_progress(-1, ""); + setsav1; } /** Load the game from the specified file. */ @@ -147,6 +149,7 @@ load_save_load_game(const gchar* filename) g_string_printf(save_file, "%s", filename); gui_show_progress(-1, ""); + setsav1; } /** Store the name of the last savegame in the users home dir. */ @@ -186,3 +189,22 @@ load_save_last_save_get(void) return g_strdup(buf); } + +/** Write an autosave. */ +void +load_save_autosave(void) +{ + gchar buf[SMALL]; + const gchar *home = g_get_home_dir(); + FILE *fil = NULL; + + sprintf(buf, "%s/%s/saves/autosave%02d.zip", home, HOMEDIRNAME, + counters[COUNT_AUTOSAVE_FILE]); + + if(!file_my_fopen(buf, "w", &fil, FALSE)) + return; + + load_save_save_game(buf); + + counters[COUNT_AUTOSAVE_FILE] = (counters[COUNT_AUTOSAVE_FILE] + 1) % opt_int("int_opt_autosave_files"); +} diff --git a/src/load_save.h b/src/load_save.h index 79285d8a..9a621fce 100644 --- a/src/load_save.h +++ b/src/load_save.h @@ -15,4 +15,7 @@ load_save_last_save_set(const gchar *filename); gchar* load_save_last_save_get(void); +void +load_save_autosave(void); + #endif diff --git a/src/main.c b/src/main.c index 5ca852eb..9da9cab4 100644 --- a/src/main.c +++ b/src/main.c @@ -103,6 +103,7 @@ main (gint argc, gchar *argv[]) window_show_startup(); stat0 = STATUS_TEAM_SELECTION; + /*d*/ on_button_add_player_clicked(NULL, NULL); diff --git a/src/misc2_callback_func.c b/src/misc2_callback_func.c index 22713ac2..7ab13aca 100644 --- a/src/misc2_callback_func.c +++ b/src/misc2_callback_func.c @@ -16,47 +16,47 @@ void misc2_callback_transfer_user_player(void) { - Team *new_team = transoff(stat1, 0).tm; + Team *new_team = transoff(stat2, 0).tm; gchar buf[SMALL]; if(team_is_user(new_team) != -1) { if(new_team->players->len < const_int("int_team_max_players") && - BUDGET(user_get_index(user_from_team(new_team))) > transoff(stat1, 0).fee) + BUDGET(user_get_index(user_from_team(new_team))) > transoff(stat2, 0).fee) { - current_user.money += transoff(stat1, 0).fee; - current_user.money_in[1][MON_IN_TRANSFERS] += transoff(stat1, 0).fee; - user_from_team(new_team)->money -= transoff(stat1, 0).fee; + current_user.money += transoff(stat2, 0).fee; + current_user.money_in[1][MON_IN_TRANSFERS] += transoff(stat2, 0).fee; + user_from_team(new_team)->money -= transoff(stat2, 0).fee; user_from_team(new_team)->money_out[1][MON_OUT_TRANSFERS] -= - transoff(stat1, 0).fee; - player_copy(player_of_id(trans(stat1).tm, trans(stat1).id), + transoff(stat2, 0).fee; + player_copy(player_of_id(trans(stat2).tm, trans(stat2).id), new_team, new_team->players->len); player_of(new_team, new_team->players->len - 1)->contract = (gfloat)math_rndi(const_int("int_transfer_contract_lower"), const_int("int_transfer_contract_upper")); g_array_remove_index(current_user.tm->players, - player_id_index(current_user.tm, trans(stat1).id)); - transfer_remove_player(stat1); + player_id_index(current_user.tm, trans(stat2).id)); + transfer_remove_player(stat2); } else { sprintf(buf, _("%s couldn't afford to buy %s or his roster was full."), user_from_team(new_team)->name->str, - player_of_id(trans(stat1).tm, trans(stat1).id)->name->str); + player_of_id(trans(stat2).tm, trans(stat2).id)->name->str); game_gui_show_warning(buf); sprintf(buf, _("You didn't have enough money to buy %s or your roster was full."), - player_of_id(trans(stat1).tm, trans(stat1).id)->name->str); + player_of_id(trans(stat2).tm, trans(stat2).id)->name->str); user_event_add(user_from_team(new_team), EVENT_TYPE_WARNING, -1, -1, NULL, buf); - g_array_remove_index(trans(stat1).offers, 0); + g_array_remove_index(trans(stat2).offers, 0); } } else { - current_user.money += transoff(stat1, 0).fee; - current_user.money_in[1][MON_IN_TRANSFERS] += transoff(stat1, 0).fee; + current_user.money += transoff(stat2, 0).fee; + current_user.money_in[1][MON_IN_TRANSFERS] += transoff(stat2, 0).fee; player_remove_from_team(current_user.tm, - player_id_index(current_user.tm, trans(stat1).id)); - transfer_remove_player(stat1); + player_id_index(current_user.tm, trans(stat2).id)); + transfer_remove_player(stat2); } treeview_show_user_player_list(); @@ -80,6 +80,8 @@ misc2_callback_change_structure(gint structure) team_change_structure(current_user.tm, structure); treeview_show_user_player_list(); + setsav0; + return TRUE; } @@ -163,4 +165,6 @@ misc2_callback_add_user(void) treeview_show_users(GTK_TREE_VIEW(lookup_widget(window.user_management, "treeview_user_management_users"))); treeview_show_team_list(treeview_user_management_teams, FALSE, FALSE); + + setsav0; } diff --git a/src/misc2_callbacks.c b/src/misc2_callbacks.c index a34188c5..5c5d1cf4 100644 --- a/src/misc2_callbacks.c +++ b/src/misc2_callbacks.c @@ -1,3 +1,4 @@ +#include "callback_func.h" #include "finance.h" #include "game_gui.h" #include "main.h" @@ -39,6 +40,8 @@ on_button_offer_ok_clicked (GtkButton *button, game_gui_show_main(); window_destroy(&window.job_offer, TRUE); + + setsav0; } @@ -70,7 +73,7 @@ on_button_warning_clicked (GtkWidget *widget, { window_destroy(&window.warning, FALSE); - if(stat0 == STATUS_SHOW_EVENT) + if(stat1 == STATUS_SHOW_EVENT) user_event_show_next(); return FALSE; @@ -111,6 +114,8 @@ on_button_digits_ok_clicked (GtkButton *button, window_destroy(&window.digits, TRUE); game_gui_set_main_window_header(); + + setsav0; } @@ -131,44 +136,43 @@ on_window_yesno_delete_event (GtkWidget *widget, return FALSE; } - -void -on_checkbutton_yesno_toggled (GtkToggleButton *togglebutton, - gpointer user_data) -{ - -} - - void on_button_yesno_yes_clicked (GtkButton *button, gpointer user_data) -{ - switch(stat0) +{ + window_destroy(&window.yesno, TRUE); + setsav0; + + switch(stat1) { default: - g_warning("on_button_yesno_yes_clicked: unknown status %d\n", stat0); + g_warning("on_button_yesno_yes_clicked: unknown status %d\n", stat1); break; case STATUS_TRANSFER_OFFER: misc2_callback_transfer_user_player(); break; case STATUS_FIRE_PLAYER: - player_remove_from_team(current_user.tm, stat1); - current_user.money -= stat2; - current_user.money_out[1][MON_OUT_COMPENSATIONS] -= stat2; + player_remove_from_team(current_user.tm, stat2); + current_user.money -= stat3; + current_user.money_out[1][MON_OUT_COMPENSATIONS] -= stat3; treeview_show_user_player_list(); + game_gui_set_main_window_header(); break; case STATUS_USER_MANAGEMENT: - user_remove(stat1, TRUE); + user_remove(stat2, TRUE); treeview_show_users(GTK_TREE_VIEW(lookup_widget(window.user_management, "treeview_user_management_users"))); treeview_show_team_list(GTK_TREE_VIEW(lookup_widget(window.user_management, "treeview_user_management_teams")), FALSE, FALSE); break; + case STATUS_QUERY_UNFIT: + callback_show_next_live_game(); + break; + case STATUS_QUERY_QUIT: + main_exit_program(EXIT_OK, NULL); + break; } - - window_destroy(&window.yesno, TRUE); } @@ -238,13 +242,13 @@ on_treeview_user_management_users_button_press_event if(users->len == 1) { - game_gui_show_warning("You can't play Bygfoot with 0 users!"); + game_gui_show_warning("You can't play Bygfoot without users!"); return TRUE; } - stat1 = idx; + stat2 = idx; sprintf(buf, "Remove user %s from the game?", usr(idx).name->str); - window_show_yesno(buf, FALSE); + window_show_yesno(buf); return FALSE; } diff --git a/src/misc2_callbacks.h b/src/misc2_callbacks.h index 9cf14f9e..961dabc1 100644 --- a/src/misc2_callbacks.h +++ b/src/misc2_callbacks.h @@ -39,10 +39,6 @@ on_window_yesno_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data); -void -on_checkbutton_yesno_toggled (GtkToggleButton *togglebutton, - gpointer user_data); - void on_button_yesno_yes_clicked (GtkButton *button, gpointer user_data); @@ -56,7 +52,6 @@ void on_button_contract_offer_clicked (GtkButton *button, gpointer user_data); -#endif gboolean on_window_contract_delete_event (GtkWidget *widget, @@ -88,3 +83,4 @@ on_treeview_user_management_teams_row_activated GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data); +#endif diff --git a/src/misc2_interface.c b/src/misc2_interface.c index 17fc44ad..82b7d9e1 100644 --- a/src/misc2_interface.c +++ b/src/misc2_interface.c @@ -522,7 +522,6 @@ create_window_yesno (void) GtkWidget *vbox17; GtkWidget *image8; GtkWidget *label_yesno; - GtkWidget *checkbutton_yesno; GtkWidget *hbox18; GtkWidget *button_yesno_yes; GtkWidget *button_yesno_no; @@ -532,7 +531,7 @@ create_window_yesno (void) gtk_window_set_title (GTK_WINDOW (window_yesno), _("window1")); gtk_window_set_position (GTK_WINDOW (window_yesno), GTK_WIN_POS_CENTER); - vbox17 = gtk_vbox_new (FALSE, 3); + vbox17 = gtk_vbox_new (FALSE, 5); gtk_widget_show (vbox17); gtk_container_add (GTK_CONTAINER (window_yesno), vbox17); @@ -546,10 +545,6 @@ create_window_yesno (void) gtk_label_set_justify (GTK_LABEL (label_yesno), GTK_JUSTIFY_LEFT); gtk_label_set_line_wrap (GTK_LABEL (label_yesno), TRUE); - checkbutton_yesno = gtk_check_button_new_with_mnemonic (_("Don't bother me with this next time.")); - gtk_widget_show (checkbutton_yesno); - gtk_box_pack_start (GTK_BOX (vbox17), checkbutton_yesno, FALSE, FALSE, 0); - hbox18 = gtk_hbox_new (FALSE, 3); gtk_widget_show (hbox18); gtk_box_pack_start (GTK_BOX (vbox17), hbox18, FALSE, FALSE, 0); @@ -565,9 +560,6 @@ create_window_yesno (void) g_signal_connect ((gpointer) window_yesno, "delete_event", G_CALLBACK (on_window_yesno_delete_event), NULL); - g_signal_connect ((gpointer) checkbutton_yesno, "toggled", - G_CALLBACK (on_checkbutton_yesno_toggled), - NULL); g_signal_connect ((gpointer) button_yesno_yes, "clicked", G_CALLBACK (on_button_yesno_yes_clicked), NULL); @@ -580,7 +572,6 @@ create_window_yesno (void) GLADE_HOOKUP_OBJECT (window_yesno, vbox17, "vbox17"); GLADE_HOOKUP_OBJECT (window_yesno, image8, "image8"); GLADE_HOOKUP_OBJECT (window_yesno, label_yesno, "label_yesno"); - GLADE_HOOKUP_OBJECT (window_yesno, checkbutton_yesno, "checkbutton_yesno"); GLADE_HOOKUP_OBJECT (window_yesno, hbox18, "hbox18"); GLADE_HOOKUP_OBJECT (window_yesno, button_yesno_yes, "button_yesno_yes"); GLADE_HOOKUP_OBJECT (window_yesno, button_yesno_no, "button_yesno_no"); diff --git a/src/misc_callback_func.c b/src/misc_callback_func.c index 13aa7682..586ae72c 100644 --- a/src/misc_callback_func.c +++ b/src/misc_callback_func.c @@ -209,6 +209,8 @@ misc_callback_improve_stadium(void) window_destroy(&window.stadium, TRUE); game_gui_set_main_window_header(); + + setsav0; } /** Load a savegame directly from the startup window. */ diff --git a/src/misc_callbacks.c b/src/misc_callbacks.c index 5476c58c..e254bb6d 100644 --- a/src/misc_callbacks.c +++ b/src/misc_callbacks.c @@ -12,6 +12,7 @@ #include "user.h" #include "variables.h" #include "window.h" +#include "xml_country.h" void on_button_add_player_clicked (GtkButton *button, @@ -53,13 +54,6 @@ on_team_selection_tv_row_activated (GtkTreeView *treeview, on_button_add_player_clicked(NULL, NULL); } -void -on_button_select_country_file_clicked (GtkButton *button, - gpointer user_data) -{ - -} - void on_team_selection_load_clicked (GtkButton *button, gpointer user_data) @@ -153,6 +147,8 @@ on_button_font_sel_apply_clicked (GtkButton *button, stat0 = STATUS_MAIN; game_gui_show_main(); + + setsav0; } } @@ -311,4 +307,3 @@ on_button_startup_resume_clicked (GtkButton *button, g_free(last_save); } - diff --git a/src/misc_callbacks.h b/src/misc_callbacks.h index f932fb45..a301a0a9 100644 --- a/src/misc_callbacks.h +++ b/src/misc_callbacks.h @@ -15,10 +15,6 @@ on_team_selection_tv_row_activated (GtkTreeView *treeview, GtkTreeViewColumn *column, gpointer user_data); void -on_button_select_country_file_clicked (GtkButton *button, - gpointer user_data); - -void on_team_selection_ok_clicked (GtkButton *button, gpointer user_data); diff --git a/src/misc_interface.c b/src/misc_interface.c index ac1d33d1..e6d038bc 100644 --- a/src/misc_interface.c +++ b/src/misc_interface.c @@ -892,17 +892,19 @@ create_window_stadium (void) { GtkWidget *window_stadium; GtkWidget *vbox39; - GtkWidget *vbox48; - GtkWidget *hbox66; + GtkWidget *table1; GtkWidget *label106; GtkWidget *label_stadium_status; - GtkWidget *hbox62; GtkWidget *label101; + GtkWidget *hbox69; GtkWidget *label_capacity; GtkWidget *label102; - GtkWidget *hbox63; GtkWidget *label103; GtkWidget *progressbar_safety; + GtkWidget *label109; + GtkWidget *label_average_attendance; + GtkWidget *label111; + GtkWidget *progressbar_average_attendance; GtkWidget *hseparator14; GtkWidget *vbox43; GtkWidget *label90; @@ -948,55 +950,96 @@ create_window_stadium (void) gtk_widget_show (vbox39); gtk_container_add (GTK_CONTAINER (window_stadium), vbox39); - vbox48 = gtk_vbox_new (FALSE, 3); - gtk_widget_show (vbox48); - gtk_box_pack_start (GTK_BOX (vbox39), vbox48, FALSE, FALSE, 0); - - hbox66 = gtk_hbox_new (FALSE, 3); - gtk_widget_show (hbox66); - gtk_box_pack_start (GTK_BOX (vbox48), hbox66, TRUE, TRUE, 0); + table1 = gtk_table_new (5, 2, FALSE); + gtk_widget_show (table1); + gtk_box_pack_start (GTK_BOX (vbox39), table1, FALSE, FALSE, 0); + gtk_table_set_row_spacings (GTK_TABLE (table1), 3); + gtk_table_set_col_spacings (GTK_TABLE (table1), 3); label106 = gtk_label_new (_("Status: ")); gtk_widget_show (label106); - gtk_box_pack_start (GTK_BOX (hbox66), label106, FALSE, FALSE, 0); + gtk_table_attach (GTK_TABLE (table1), label106, 0, 1, 0, 1, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); gtk_label_set_justify (GTK_LABEL (label106), GTK_JUSTIFY_LEFT); + gtk_misc_set_alignment (GTK_MISC (label106), 0, 0.5); label_stadium_status = gtk_label_new (_("label107")); gtk_widget_show (label_stadium_status); - gtk_box_pack_start (GTK_BOX (hbox66), label_stadium_status, FALSE, FALSE, 0); + gtk_table_attach (GTK_TABLE (table1), label_stadium_status, 1, 2, 0, 1, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); gtk_label_set_justify (GTK_LABEL (label_stadium_status), GTK_JUSTIFY_LEFT); - - hbox62 = gtk_hbox_new (FALSE, 3); - gtk_widget_show (hbox62); - gtk_box_pack_start (GTK_BOX (vbox48), hbox62, FALSE, FALSE, 0); + gtk_misc_set_alignment (GTK_MISC (label_stadium_status), 0, 0.5); label101 = gtk_label_new (_("Current capacity:")); gtk_widget_show (label101); - gtk_box_pack_start (GTK_BOX (hbox62), label101, FALSE, FALSE, 0); + gtk_table_attach (GTK_TABLE (table1), label101, 0, 1, 1, 2, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); gtk_label_set_justify (GTK_LABEL (label101), GTK_JUSTIFY_LEFT); + gtk_misc_set_alignment (GTK_MISC (label101), 0, 0.5); + + hbox69 = gtk_hbox_new (FALSE, 0); + gtk_widget_show (hbox69); + gtk_table_attach (GTK_TABLE (table1), hbox69, 1, 2, 1, 2, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (GTK_FILL), 0, 0); label_capacity = gtk_label_new (_("label104")); gtk_widget_show (label_capacity); - gtk_box_pack_start (GTK_BOX (hbox62), label_capacity, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox69), label_capacity, FALSE, FALSE, 0); gtk_label_set_justify (GTK_LABEL (label_capacity), GTK_JUSTIFY_LEFT); + gtk_misc_set_alignment (GTK_MISC (label_capacity), 0, 0.5); - label102 = gtk_label_new (_("seats")); + label102 = gtk_label_new (_(" seats")); gtk_widget_show (label102); - gtk_box_pack_start (GTK_BOX (hbox62), label102, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox69), label102, FALSE, FALSE, 0); gtk_label_set_justify (GTK_LABEL (label102), GTK_JUSTIFY_LEFT); - hbox63 = gtk_hbox_new (FALSE, 3); - gtk_widget_show (hbox63); - gtk_box_pack_start (GTK_BOX (vbox48), hbox63, FALSE, FALSE, 0); - label103 = gtk_label_new (_("Current safety: ")); gtk_widget_show (label103); - gtk_box_pack_start (GTK_BOX (hbox63), label103, FALSE, FALSE, 0); + gtk_table_attach (GTK_TABLE (table1), label103, 0, 1, 2, 3, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); gtk_label_set_justify (GTK_LABEL (label103), GTK_JUSTIFY_LEFT); + gtk_misc_set_alignment (GTK_MISC (label103), 0, 0.5); progressbar_safety = gtk_progress_bar_new (); gtk_widget_show (progressbar_safety); - gtk_box_pack_start (GTK_BOX (hbox63), progressbar_safety, FALSE, FALSE, 0); + gtk_table_attach (GTK_TABLE (table1), progressbar_safety, 1, 2, 2, 3, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + + label109 = gtk_label_new (_("Average attendance ")); + gtk_widget_show (label109); + gtk_table_attach (GTK_TABLE (table1), label109, 0, 1, 3, 4, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + gtk_label_set_justify (GTK_LABEL (label109), GTK_JUSTIFY_LEFT); + gtk_misc_set_alignment (GTK_MISC (label109), 0, 0.5); + + label_average_attendance = gtk_label_new (_("label110")); + gtk_widget_show (label_average_attendance); + gtk_table_attach (GTK_TABLE (table1), label_average_attendance, 1, 2, 3, 4, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + gtk_label_set_justify (GTK_LABEL (label_average_attendance), GTK_JUSTIFY_LEFT); + gtk_misc_set_alignment (GTK_MISC (label_average_attendance), 0, 0.5); + + label111 = gtk_label_new (_("Average attendance % ")); + gtk_widget_show (label111); + gtk_table_attach (GTK_TABLE (table1), label111, 0, 1, 4, 5, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + gtk_label_set_justify (GTK_LABEL (label111), GTK_JUSTIFY_LEFT); + gtk_misc_set_alignment (GTK_MISC (label111), 0, 0.5); + + progressbar_average_attendance = gtk_progress_bar_new (); + gtk_widget_show (progressbar_average_attendance); + gtk_table_attach (GTK_TABLE (table1), progressbar_average_attendance, 1, 2, 4, 5, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); hseparator14 = gtk_hseparator_new (); gtk_widget_show (hseparator14); @@ -1154,17 +1197,19 @@ create_window_stadium (void) /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (window_stadium, window_stadium, "window_stadium"); GLADE_HOOKUP_OBJECT (window_stadium, vbox39, "vbox39"); - GLADE_HOOKUP_OBJECT (window_stadium, vbox48, "vbox48"); - GLADE_HOOKUP_OBJECT (window_stadium, hbox66, "hbox66"); + GLADE_HOOKUP_OBJECT (window_stadium, table1, "table1"); GLADE_HOOKUP_OBJECT (window_stadium, label106, "label106"); GLADE_HOOKUP_OBJECT (window_stadium, label_stadium_status, "label_stadium_status"); - GLADE_HOOKUP_OBJECT (window_stadium, hbox62, "hbox62"); GLADE_HOOKUP_OBJECT (window_stadium, label101, "label101"); + GLADE_HOOKUP_OBJECT (window_stadium, hbox69, "hbox69"); GLADE_HOOKUP_OBJECT (window_stadium, label_capacity, "label_capacity"); GLADE_HOOKUP_OBJECT (window_stadium, label102, "label102"); - GLADE_HOOKUP_OBJECT (window_stadium, hbox63, "hbox63"); GLADE_HOOKUP_OBJECT (window_stadium, label103, "label103"); GLADE_HOOKUP_OBJECT (window_stadium, progressbar_safety, "progressbar_safety"); + GLADE_HOOKUP_OBJECT (window_stadium, label109, "label109"); + GLADE_HOOKUP_OBJECT (window_stadium, label_average_attendance, "label_average_attendance"); + GLADE_HOOKUP_OBJECT (window_stadium, label111, "label111"); + GLADE_HOOKUP_OBJECT (window_stadium, progressbar_average_attendance, "progressbar_average_attendance"); GLADE_HOOKUP_OBJECT (window_stadium, hseparator14, "hseparator14"); GLADE_HOOKUP_OBJECT (window_stadium, vbox43, "vbox43"); GLADE_HOOKUP_OBJECT (window_stadium, label90, "label90"); diff --git a/src/option_gui.c b/src/option_gui.c index b4b1f92b..eaab19be 100644 --- a/src/option_gui.c +++ b/src/option_gui.c @@ -9,13 +9,12 @@ e.g. whether or not quit requires confirmation. */ enum BooleanOptions { - BOOL_OPT_CONF_NEW_WEEK = 0, - BOOL_OPT_CONF_QUIT, + BOOL_OPT_CONF_QUIT = 0, + BOOL_OPT_CONF_UNFIT, BOOL_OPT_SAVE_OVERWRITE, BOOL_OPT_MAXIMIZE, BOOL_OPT_PREFER_MESS, BOOL_OPT_AUTOSAVE, - BOOL_OPT_CONF_UNFIT, BOOL_OPT_SHOW_LIVE, BOOL_OPT_SHOW_TENDENCY, BOOL_OPT_PAUSE_INJURY, @@ -69,14 +68,14 @@ enum BooleanOptions void option_gui_write_bool_widgets(gint **bool_options, GtkToggleButton **bool_widgets) { - bool_widgets[BOOL_OPT_CONF_NEW_WEEK] = - GTK_TOGGLE_BUTTON(lookup_widget(window.options, "checkbutton_conf_new_week_round")); - bool_options[BOOL_OPT_CONF_NEW_WEEK] = opt_intp("int_opt_confirm_new_week_round"); - bool_widgets[BOOL_OPT_CONF_QUIT] = GTK_TOGGLE_BUTTON(lookup_widget(window.options, "checkbutton_conf_quit")); bool_options[BOOL_OPT_CONF_QUIT] = opt_intp("int_opt_confirm_quit"); + bool_widgets[BOOL_OPT_CONF_UNFIT] = + GTK_TOGGLE_BUTTON(lookup_widget(window.options, "checkbutton_conf_unfit")); + bool_options[BOOL_OPT_CONF_UNFIT] = opt_intp("int_opt_confirm_unfit"); + bool_widgets[BOOL_OPT_SAVE_OVERWRITE] = GTK_TOGGLE_BUTTON(lookup_widget(window.options, "checkbutton_save_overwrite")); bool_options[BOOL_OPT_SAVE_OVERWRITE] = opt_intp("int_opt_save_will_overwrite"); @@ -93,10 +92,6 @@ option_gui_write_bool_widgets(gint **bool_options, GtkToggleButton **bool_widget GTK_TOGGLE_BUTTON(lookup_widget(window.options, "checkbutton_autosave")); bool_options[BOOL_OPT_AUTOSAVE] = opt_intp("int_opt_autosave"); - bool_widgets[BOOL_OPT_CONF_UNFIT] = - GTK_TOGGLE_BUTTON(lookup_widget(window.options, "checkbutton_conf_unfit")); - bool_options[BOOL_OPT_CONF_UNFIT] = opt_user_intp("int_opt_user_confirm_unfit"); - bool_widgets[BOOL_OPT_SHOW_LIVE] = GTK_TOGGLE_BUTTON(lookup_widget(window.options, "checkbutton_show_live")); bool_options[BOOL_OPT_SHOW_LIVE] = opt_user_intp("int_opt_user_show_live_game"); @@ -282,6 +277,7 @@ option_gui_write_bool_widgets(gint **bool_options, GtkToggleButton **bool_widget enum SpinOptions { SPIN_OPT_AUTOSAVE = 0, + SPIN_OPT_AUTOSAVE_FILES, SPIN_OPT_PRECISION, SPIN_OPT_REFRESH, SPIN_OPT_LIVE_SPEED, @@ -296,6 +292,10 @@ option_gui_write_spin_widgets(gint **spin_options, GtkSpinButton **spin_widgets) GTK_SPIN_BUTTON(lookup_widget(window.options, "spinbutton_autosave")); spin_options[SPIN_OPT_AUTOSAVE] = opt_intp("int_opt_autosave_interval"); + spin_widgets[SPIN_OPT_AUTOSAVE_FILES] = + GTK_SPIN_BUTTON(lookup_widget(window.options, "spinbutton_autosave_files")); + spin_options[SPIN_OPT_AUTOSAVE_FILES] = opt_intp("int_opt_autosave_files"); + spin_widgets[SPIN_OPT_PRECISION] = GTK_SPIN_BUTTON(lookup_widget(window.options, "spinbutton_precision")); spin_options[SPIN_OPT_PRECISION] = opt_intp("int_opt_player_precision"); diff --git a/src/options_interface.c b/src/options_interface.c index 2210481e..602b42aa 100644 --- a/src/options_interface.c +++ b/src/options_interface.c @@ -34,8 +34,8 @@ create_window_options (void) GtkWidget *notebook1; GtkWidget *hbox2; GtkWidget *vbox3; - GtkWidget *checkbutton_conf_new_week_round; GtkWidget *checkbutton_conf_quit; + GtkWidget *checkbutton_conf_unfit; GtkWidget *checkbutton_save_overwrite; GtkWidget *checkbutton_maximize; GtkWidget *checkbutton_pref_mess; @@ -46,6 +46,9 @@ create_window_options (void) GtkWidget *label6; GtkObject *spinbutton_autosave_adj; GtkWidget *spinbutton_autosave; + GtkWidget *label36; + GtkObject *spinbutton_autosave_files_adj; + GtkWidget *spinbutton_autosave_files; GtkWidget *label7; GtkWidget *label8; GtkObject *spinbutton_precision_adj; @@ -84,7 +87,6 @@ create_window_options (void) GtkWidget *label2; GtkWidget *hbox6; GtkWidget *vbox6; - GtkWidget *checkbutton_conf_unfit; GtkWidget *checkbutton_show_job; GtkWidget *vseparator3; GtkWidget *vbox7; @@ -190,13 +192,15 @@ create_window_options (void) gtk_widget_show (vbox3); gtk_box_pack_start (GTK_BOX (hbox2), vbox3, TRUE, TRUE, 0); - checkbutton_conf_new_week_round = gtk_check_button_new_with_mnemonic (_("Confirm new week round")); - gtk_widget_show (checkbutton_conf_new_week_round); - gtk_box_pack_start (GTK_BOX (vbox3), checkbutton_conf_new_week_round, FALSE, FALSE, 0); - - checkbutton_conf_quit = gtk_check_button_new_with_mnemonic (_("Confirm quit")); + checkbutton_conf_quit = gtk_check_button_new_with_mnemonic (_("Confirm quit when not saved")); gtk_widget_show (checkbutton_conf_quit); gtk_box_pack_start (GTK_BOX (vbox3), checkbutton_conf_quit, FALSE, FALSE, 0); + gtk_tooltips_set_tip (tooltips, checkbutton_conf_quit, _("Whether to show a confirmation popup when you press quit and the game state is not saved"), NULL); + + checkbutton_conf_unfit = gtk_check_button_new_with_mnemonic (_("Confirm when unfit")); + gtk_widget_show (checkbutton_conf_unfit); + gtk_box_pack_start (GTK_BOX (vbox3), checkbutton_conf_unfit, FALSE, FALSE, 0); + gtk_tooltips_set_tip (tooltips, checkbutton_conf_unfit, _("Whether to show a confirmation popup if a user team has an injured or banned player in the startup formation"), NULL); checkbutton_save_overwrite = gtk_check_button_new_with_mnemonic (_("Save overwrites")); gtk_widget_show (checkbutton_save_overwrite); @@ -240,8 +244,20 @@ create_window_options (void) spinbutton_autosave = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_autosave_adj), 1, 0); gtk_widget_show (spinbutton_autosave); gtk_box_pack_start (GTK_BOX (hbox3), spinbutton_autosave, FALSE, FALSE, 0); + gtk_tooltips_set_tip (tooltips, spinbutton_autosave, _("How often the game is saved automatically"), NULL); gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton_autosave), TRUE); + label36 = gtk_label_new (_(" Autosave files ")); + gtk_widget_show (label36); + gtk_box_pack_start (GTK_BOX (hbox3), label36, FALSE, FALSE, 0); + gtk_label_set_justify (GTK_LABEL (label36), GTK_JUSTIFY_LEFT); + + spinbutton_autosave_files_adj = gtk_adjustment_new (1, 0, 100, 1, 10, 10); + spinbutton_autosave_files = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_autosave_files_adj), 1, 0); + gtk_widget_show (spinbutton_autosave_files); + gtk_box_pack_start (GTK_BOX (hbox3), spinbutton_autosave_files, TRUE, TRUE, 0); + gtk_tooltips_set_tip (tooltips, spinbutton_autosave_files, _("How many files the autosave uses"), NULL); + label7 = gtk_label_new (_("Player attribute precision ")); gtk_widget_show (label7); gtk_table_attach (GTK_TABLE (table1), label7, 0, 1, 1, 2, @@ -418,10 +434,6 @@ create_window_options (void) gtk_widget_show (vbox6); gtk_box_pack_start (GTK_BOX (hbox6), vbox6, TRUE, TRUE, 0); - checkbutton_conf_unfit = gtk_check_button_new_with_mnemonic (_("Confirm when unfit")); - gtk_widget_show (checkbutton_conf_unfit); - gtk_box_pack_start (GTK_BOX (vbox6), checkbutton_conf_unfit, FALSE, FALSE, 0); - checkbutton_show_job = gtk_check_button_new_with_mnemonic (_("Show job offers")); gtk_widget_show (checkbutton_show_job); gtk_box_pack_start (GTK_BOX (vbox6), checkbutton_show_job, FALSE, FALSE, 0); @@ -914,8 +926,8 @@ create_window_options (void) GLADE_HOOKUP_OBJECT (window_options, notebook1, "notebook1"); GLADE_HOOKUP_OBJECT (window_options, hbox2, "hbox2"); GLADE_HOOKUP_OBJECT (window_options, vbox3, "vbox3"); - GLADE_HOOKUP_OBJECT (window_options, checkbutton_conf_new_week_round, "checkbutton_conf_new_week_round"); GLADE_HOOKUP_OBJECT (window_options, checkbutton_conf_quit, "checkbutton_conf_quit"); + GLADE_HOOKUP_OBJECT (window_options, checkbutton_conf_unfit, "checkbutton_conf_unfit"); GLADE_HOOKUP_OBJECT (window_options, checkbutton_save_overwrite, "checkbutton_save_overwrite"); GLADE_HOOKUP_OBJECT (window_options, checkbutton_maximize, "checkbutton_maximize"); GLADE_HOOKUP_OBJECT (window_options, checkbutton_pref_mess, "checkbutton_pref_mess"); @@ -925,6 +937,8 @@ create_window_options (void) GLADE_HOOKUP_OBJECT (window_options, hbox3, "hbox3"); GLADE_HOOKUP_OBJECT (window_options, label6, "label6"); GLADE_HOOKUP_OBJECT (window_options, spinbutton_autosave, "spinbutton_autosave"); + GLADE_HOOKUP_OBJECT (window_options, label36, "label36"); + GLADE_HOOKUP_OBJECT (window_options, spinbutton_autosave_files, "spinbutton_autosave_files"); GLADE_HOOKUP_OBJECT (window_options, label7, "label7"); GLADE_HOOKUP_OBJECT (window_options, label8, "label8"); GLADE_HOOKUP_OBJECT (window_options, spinbutton_precision, "spinbutton_precision"); @@ -960,7 +974,6 @@ create_window_options (void) GLADE_HOOKUP_OBJECT (window_options, label2, "label2"); GLADE_HOOKUP_OBJECT (window_options, hbox6, "hbox6"); GLADE_HOOKUP_OBJECT (window_options, vbox6, "vbox6"); - GLADE_HOOKUP_OBJECT (window_options, checkbutton_conf_unfit, "checkbutton_conf_unfit"); GLADE_HOOKUP_OBJECT (window_options, checkbutton_show_job, "checkbutton_show_job"); GLADE_HOOKUP_OBJECT (window_options, vseparator3, "vseparator3"); GLADE_HOOKUP_OBJECT (window_options, vbox7, "vbox7"); diff --git a/src/player.c b/src/player.c index 8822a84b..07f15064 100644 --- a/src/player.c +++ b/src/player.c @@ -1021,3 +1021,54 @@ player_update_week_roundly(Team *tm, gint idx) pl->cskill = (pl->health > 0 || player_is_banned(pl) > 0) ? 0 : player_get_cskill(pl, pl->cpos); } + +/** Return injury descriptions. */ +gchar* +player_injury_to_char(gint injury_type) +{ + switch(injury_type) + { + default: + g_warning("player_injury_to_char: unknown type %d\n", injury_type); + return NULL; + break; + case PLAYER_INJURY_NONE: + return _("OK"); + break; + case PLAYER_INJURY_CONCUSSION: + return _("Concussion"); + break; + case PLAYER_INJURY_PULLED_MUSCLE: + return _("Pulled muscle"); + break; + case PLAYER_INJURY_HAMSTRING: + return _("Hamstring"); + break; + case PLAYER_INJURY_GROIN: + return _("Groin injury"); + break; + case PLAYER_INJURY_FRAC_ANKLE: + return _("Fractured ankle"); + break; + case PLAYER_INJURY_RIB: + return _("Broken rib"); + break; + case PLAYER_INJURY_LEG: + return _("Broken leg"); + break; + case PLAYER_INJURY_BROK_ANKLE: + return _("Broken ankle"); + break; + case PLAYER_INJURY_ARM: + return _("Broken arm"); + break; + case PLAYER_INJURY_SHOULDER: + return _("Broken shoulder"); + break; + case PLAYER_INJURY_LIGAMENT: + return _("Torn crucial ligament"); + break; + } + + return NULL; +} diff --git a/src/player.h b/src/player.h index e3f626eb..c59b909f 100644 --- a/src/player.h +++ b/src/player.h @@ -130,4 +130,8 @@ player_update_injury(Player *pl); void player_copy(Player *pl, Team *tm, gint insert_at); +gchar* +player_injury_to_char(gint injury_type); + + #endif diff --git a/src/start_end.c b/src/start_end.c index 840f69ec..f115aeff 100644 --- a/src/start_end.c +++ b/src/start_end.c @@ -6,6 +6,7 @@ #include "gui.h" #include "league.h" #include "live_game.h" +#include "load_save.h" #include "main.h" #include "maths.h" #include "option.h" @@ -24,7 +25,7 @@ typedef void(*WeekFunc)(void); /** Array of functions called when a week round is ended. */ WeekFunc end_week_round_funcs[] = -{end_week_round_results, end_week_round_sort_tables, +{end_week_round_autosave, end_week_round_results, end_week_round_sort_tables, end_week_round_update_fixtures, NULL}; /** Array of functions called when a week round @@ -249,14 +250,15 @@ start_week_round(void) start_func++; } - if(!user_games_this_week_round()) + if(!query_user_games_this_week_round()) end_week_round(); else { cur_user = 0; game_gui_show_main(); - if(week_round == 1) + /*d ??*/ +/* if(week_round == 1) */ user_event_show_next(); } } @@ -324,3 +326,17 @@ start_week_update_users(void) user_weekly_update_counters(&usr(i)); } } + +/** Save the game if autosave is on. */ +void +end_week_round_autosave(void) +{ + if(!opt_int("int_opt_autosave") || + !query_user_games_this_week_round()) + return; + + counters[COUNT_AUTOSAVE] = (counters[COUNT_AUTOSAVE] + 1) % opt_int("int_opt_autosave_interval"); + + if(counters[COUNT_AUTOSAVE] == 0) + load_save_autosave(); +} diff --git a/src/start_end.h b/src/start_end.h index 226d2d21..e6ea4c88 100644 --- a/src/start_end.h +++ b/src/start_end.h @@ -48,4 +48,7 @@ start_week_update_user_finances(void); void start_week_update_users(void); +void +end_week_round_autosave(void); + #endif diff --git a/src/treeview.c b/src/treeview.c index 22d66cb8..36fb75fb 100644 --- a/src/treeview.c +++ b/src/treeview.c @@ -2158,3 +2158,106 @@ treeview_show_preview(void) gtk_tree_view_set_model(treeview, model); g_object_unref(model); } + +GtkTreeModel* +treeview_create_player_info(const Player *pl) +{ + gint i; + gchar buf[SMALL]; + gint pos[2] = {pl->pos, pl->cpos}; + GtkListStore *liststore = gtk_list_store_new(2, + G_TYPE_STRING, + G_TYPE_STRING); + GtkTreeIter iter; + + gtk_list_store_append(liststore, &iter); + gtk_list_store_set(liststore, &iter, 0, _("Name"), 1, + pl->name->str, -1); + +/* for(i=0;i<2;i++) */ +/* { */ +/* if(pos[i] == PLAYER_POS_GOALIE) */ +/* sprintf(buf, "%s", */ +/* const_str("string_treeview_cell_color_player_pos_goalie_bg"), */ +/* const_str("string_treeview_cell_color_player_pos_goalie_fg"), */ +/* _("Goalkeeper")); */ +/* else if(pos[i] == PLAYER_POS_DEFENDER) */ +/* sprintf(buf, "%s", */ +/* const_str("string_treeview_cell_color_player_pos_defender_bg"), */ +/* const_str("string_treeview_cell_color_player_pos_defender_fg"), */ +/* _("Defender")); */ +/* else if(pos[i] == PLAYER_POS_MIDFIELDER) */ +/* sprintf(buf, "%s", */ +/* const_str("string_treeview_cell_color_player_pos_midfielder_bg"), */ +/* const_str("string_treeview_cell_color_player_pos_midfielder_fg"), */ +/* _("Midfielder")); */ +/* else if(pos[i] == PLAYER_POS_FORWARD) */ +/* sprintf(buf, "%s", */ +/* const_str("string_treeview_cell_color_player_pos_forward_bg"), */ +/* const_str("string_treeview_cell_color_player_pos_forward_fg"), */ +/* _("Forward")); */ + +/* gtk_list_store_append(liststore, &iter); */ + +/* if(i == 0) */ +/* gtk_list_store_set(liststore, &iter, 0, _("Position"), 1, */ +/* buf, -1); */ +/* else */ +/* gtk_list_store_set(liststore, &iter, 0, _("Current position"), 1, */ +/* buf, -1); */ +/* } */ + +/* gtk_list_store_append(liststore, &iter); */ +/* sprintf(buf, "%" */ +/* gtk_list_store_set(liststore, &iter, 0, _("Skill"), */ + +/* gtk_list_store_append(liststore, &iter); */ +/* if(pl->health != 0) */ +/* sprintf(buf, "%s (expected recovery in %d weeks)", */ +/* player_injury_to_char(pl->health), pl->recovery); */ +/* else */ +/* strcpy(buf, "OK"); */ +/* gtk_list_store_set(liststore, &iter, 0, _("Health"), 1, buf, -1); */ + + + + return GTK_TREE_MODEL(liststore); +} + +void +treeview_set_up_player_info(GtkTreeView *treeview) +{ + gint i; + GtkTreeViewColumn *col; + GtkCellRenderer *renderer; + + gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview), + GTK_SELECTION_NONE); + gtk_tree_view_set_rules_hint(treeview, TRUE); + gtk_tree_view_set_headers_visible(treeview, FALSE); + + for(i=0;i<2;i++) + { + col = gtk_tree_view_column_new(); + gtk_tree_view_append_column(treeview, col); + renderer = treeview_cell_renderer_text_new(); + gtk_tree_view_column_pack_start(col, renderer, FALSE); + gtk_tree_view_column_add_attribute(col, renderer, + "markup", i); + } +} + +/** Show extended information about the player in the right treeview. */ +void +treeview_show_player_info(const Player *pl) +{ + GtkTreeView *treeview = GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right")); + GtkTreeModel *model = NULL; + + treeview_clear(treeview); + + treeview_set_up_player_info(treeview); + model = treeview_create_player_info(pl); + gtk_tree_view_set_model(treeview, model); + g_object_unref(model); +} diff --git a/src/treeview.h b/src/treeview.h index a83421f8..a52b0a5d 100644 --- a/src/treeview.h +++ b/src/treeview.h @@ -198,4 +198,13 @@ treeview_create_preview(void); void treeview_show_preview(void); +void +treeview_show_player_info(const Player *pl); + +void +treeview_set_up_player_info(GtkTreeView *treeview); + +GtkTreeModel* +treeview_create_player_info(const Player *pl); + #endif diff --git a/src/user.c b/src/user.c index 97ef9fa8..a1254853 100644 --- a/src/user.c +++ b/src/user.c @@ -8,6 +8,7 @@ #include "player.h" #include "team.h" #include "transfer.h" +#include "treeview.h" #include "user.h" #include "window.h" @@ -153,7 +154,20 @@ user_set_player_list_attributes(const User *user, PlayerListAttribute *attribute /** Find out whether there are user games at the specified date. */ gboolean -user_games_in_week_round(gint week_number, gint week_round_number) +query_user_games_in_week_round(gint week_number, gint week_round_number) +{ + gint i; + + for(i=0;ilen;i++) + if(query_user_game_in_week_round(i, week_number, week_round_number)) + return TRUE; + + return FALSE; +} + +/** Find out whether the specified user has a match at the specified date. */ +gboolean +query_user_game_in_week_round(gint usr_idx, gint week_number, gint week_round_number) { gint i, j; @@ -161,7 +175,7 @@ user_games_in_week_round(gint week_number, gint week_round_number) { for(i=0;ilen;i++) for(j=0;jlen;j++) - if(fixture_user_team_involved(&g_array_index(lig(i).fixtures, Fixture, j)) != -1 && + if(fixture_user_team_involved(&g_array_index(lig(i).fixtures, Fixture, j)) == usr_idx && g_array_index(lig(i).fixtures, Fixture, j).week_number == week_number && g_array_index(lig(i).fixtures, Fixture, j).week_round_number == week_round_number) return TRUE; @@ -170,7 +184,7 @@ user_games_in_week_round(gint week_number, gint week_round_number) { for(i=0;ilen;i++) for(j=0;jlen;j++) - if(fixture_user_team_involved(&g_array_index(cp(i).fixtures, Fixture, j)) != -1 && + if(fixture_user_team_involved(&g_array_index(cp(i).fixtures, Fixture, j)) == usr_idx && g_array_index(cp(i).fixtures, Fixture, j).week_number == week_number && g_array_index(cp(i).fixtures, Fixture, j).week_round_number == week_round_number) return TRUE; @@ -179,6 +193,7 @@ user_games_in_week_round(gint week_number, gint week_round_number) return FALSE; } + /** Get the user managing the team. @param tm The team. @return A pointer to the user. */ @@ -310,12 +325,9 @@ user_event_show_next(void) gint temp_int = -1; if(current_user.events->len == 0) - { - stat0 = STATUS_MAIN; return; - } - stat0 = STATUS_SHOW_EVENT; + stat1 = STATUS_SHOW_EVENT; event = &g_array_index(current_user.events, Event, 0); @@ -377,15 +389,27 @@ user_event_show_next(void) sprintf(buf, _("%s would like to buy %s. They offer %s for him, which is %s than the player's value. Do you accept?"), transoff(temp_int, 0).tm->name->str, player_of_id(event->user->tm, trans(temp_int).id)->name->str, buf2, buf3); - stat0 = STATUS_TRANSFER_OFFER; - stat1 = temp_int; - window_show_yesno(buf, FALSE); + stat1 = STATUS_TRANSFER_OFFER; + stat2 = temp_int; + window_show_yesno(buf); break; case EVENT_TYPE_TRANSFER_OFFER_OUTBID: sprintf(buf, _("There was a higher bid for %s than yours."), event->value_string->str); game_gui_show_warning(buf); break; + case EVENT_TYPE_PLAYER_CAREER_STOP: + sprintf(buf, _("%s's injury was so severe that he can't play football on a professional level anymore. He leaves your team."), player_of_id(event->user->tm, event->value1)->name->str); + if(event->user->tm->players->len < 12) + { + strcat(buf, _(" Fortunately he's got a cousin who can help your team out.")); + player_replace_by_new(player_of_id(event->user->tm, event->value1), TRUE); + } + else + player_remove_from_team(event->user->tm, player_id_index(event->user->tm, event->value1)); + treeview_show_user_player_list(); + game_gui_show_warning(buf); + break; } user_event_remove(¤t_user, 0); @@ -417,3 +441,24 @@ user_get_index(User *user) return -1; } + +/** Check whether one of the user teams has an unfit player + in the startup formation. */ +gboolean +query_user_teams_have_unfit(void) +{ + gint i, j; + + for(i=0;ilen;i++) + { + if(query_user_game_in_week_round(i, week, week_round)) + { + for(j=0;j<11;j++) + if(g_array_index(usr(i).tm->players, Player, j).health != 0 || + player_is_banned(&g_array_index(usr(i).tm->players, Player, j))) + return TRUE; + } + } + + return FALSE; +} diff --git a/src/user.h b/src/user.h index adb0e9aa..d40a12f1 100644 --- a/src/user.h +++ b/src/user.h @@ -7,7 +7,7 @@ /** Convenience abbrevs. */ #define usr(i) g_array_index(users, User, i) -#define user_games_this_week_round() user_games_in_week_round(week, week_round) +#define query_user_games_this_week_round() query_user_games_in_week_round(week, week_round) #define current_user usr(cur_user) void @@ -29,7 +29,10 @@ void user_set_player_list_attributes(const User *user, PlayerListAttribute *attribute, gint list_number); gboolean -user_games_in_week_round(gint week_number, gint week_round_number); +query_user_game_in_week_round(gint usr_idx, gint week_number, gint week_round_number); + +gboolean +query_user_games_in_week_round(gint week_number, gint week_round_number); User* user_from_team(const Team *tm); @@ -63,4 +66,7 @@ gint user_event_get_index(User *user, gint type, gint value1, gint value2, gpointer value_pointer, gchar *value_string); +gboolean +query_user_teams_have_unfit(void); + #endif diff --git a/src/user_struct.h b/src/user_struct.h index 4cc5afc1..d6812dd3 100644 --- a/src/user_struct.h +++ b/src/user_struct.h @@ -89,6 +89,7 @@ enum EventType EVENT_TYPE_TRANSFER_OFFER_ROSTER, EVENT_TYPE_TRANSFER_OFFER_ACCEPTED, EVENT_TYPE_TRANSFER_OFFER_OUTBID, + EVENT_TYPE_PLAYER_CAREER_STOP, EVENT_TYPE_END }; diff --git a/src/variables.h b/src/variables.h index 4157988f..c4e872e0 100644 --- a/src/variables.h +++ b/src/variables.h @@ -30,6 +30,9 @@ OptionList constants; @see TransferPlayer */ GArray *transfer_list; +/** Some counters we use. */ +gint counters[COUNT_END]; + /** These help us keep track of what's happening. */ gint status[6]; diff --git a/src/window.c b/src/window.c index 828f71cb..b94141d0 100644 --- a/src/window.c +++ b/src/window.c @@ -130,9 +130,11 @@ window_show_stadium(void) GtkLabel *label_capacity, *label_costs_capacity, *label_costs_safety, *label_duration_capacity, *label_duration_safety, - *label_stadium_status; + *label_stadium_status, *label_average_attendance; GtkSpinButton *spinbutton_capacity, *spinbutton_safety; - GtkProgressBar *progressbar_safety; + GtkProgressBar *progressbar_safety, + *progressbar_average_attendance; + gfloat average_attendance_perc = 0; window_create(WINDOW_STADIUM); @@ -142,11 +144,13 @@ window_show_stadium(void) label_duration_capacity = GTK_LABEL(lookup_widget(window.stadium, "label_duration_capacity")); label_duration_safety = GTK_LABEL(lookup_widget(window.stadium, "label_duration_safety")); label_stadium_status = GTK_LABEL(lookup_widget(window.stadium, "label_stadium_status")); + label_average_attendance = GTK_LABEL(lookup_widget(window.stadium, "label_average_attendance")); spinbutton_capacity = GTK_SPIN_BUTTON(lookup_widget(window.stadium, "spinbutton_capacity")); spinbutton_safety = GTK_SPIN_BUTTON(lookup_widget(window.stadium, "spinbutton_safety")); progressbar_safety = GTK_PROGRESS_BAR(lookup_widget(window.stadium, "progressbar_safety")); + progressbar_average_attendance = GTK_PROGRESS_BAR(lookup_widget(window.stadium, "progressbar_average_attendance")); gui_label_set_text_from_int(label_capacity, tm->stadium.capacity, FALSE); gui_label_set_text_from_int(label_costs_capacity, @@ -159,17 +163,28 @@ window_show_stadium(void) 100)), FALSE); gui_label_set_text_from_int(label_duration_capacity, 1, FALSE); gui_label_set_text_from_int(label_duration_safety, 1, FALSE); + gui_label_set_text_from_int(label_average_attendance, tm->stadium.average_attendance, FALSE); + gtk_spin_button_set_value(spinbutton_capacity, (gdouble)const_int("int_stadium_improvement_base_seats")); gtk_spin_button_set_value(spinbutton_safety, const_float("float_stadium_improvement_base_safety") * 100); + if(tm->stadium.games > 0) + average_attendance_perc = + (gfloat)(tm->stadium.average_attendance * tm->stadium.games) / + (gfloat)tm->stadium.possible_attendance; + gtk_progress_bar_set_fraction(progressbar_safety, tm->stadium.safety); + gtk_progress_bar_set_fraction(progressbar_average_attendance, average_attendance_perc); sprintf(buf, "%d%%", (gint)rint(tm->stadium.safety * 100)); gtk_progress_bar_set_text(progressbar_safety, buf); + sprintf(buf, "%d%%", (gint)rint(average_attendance_perc * 100)); + gtk_progress_bar_set_text(progressbar_average_attendance, buf); + if(current_user.counters[COUNT_USER_STADIUM_CAPACITY] + current_user.counters[COUNT_USER_STADIUM_SAFETY] != 0) { @@ -198,14 +213,11 @@ window_show(gpointer window) @param text The text shown in the window. @param checkbutton Whether to show the checkbutton. */ void -window_show_yesno(gchar *text, gboolean checkbutton) +window_show_yesno(gchar *text) { window_create(WINDOW_YESNO); gtk_label_set_text(GTK_LABEL(lookup_widget(window.yesno, "label_yesno")), text); - - if(!checkbutton) - gtk_widget_hide(lookup_widget(window.yesno, "checkbutton_yesno")); } /** Create and show a window. Which one depends on the argument. diff --git a/src/window.h b/src/window.h index 1d7e78db..eed30f79 100644 --- a/src/window.h +++ b/src/window.h @@ -43,7 +43,7 @@ void window_show_stadium(void); void -window_show_yesno(gchar *text, gboolean checkbutton); +window_show_yesno(gchar *text); void window_show_options(void); diff --git a/src/xml_country.c b/src/xml_country.c index caa30593..0816e4bb 100644 --- a/src/xml_country.c +++ b/src/xml_country.c @@ -75,7 +75,6 @@ xml_country_read_start_element (GMarkupParseContext *context, } else if(strcmp(element_name, TAG_CUP) == 0) state = STATE_CUP; - else if(strcmp(element_name, TAG_COUNTRY) != 0) g_warning("xml_country_read_start_element: unknown tag: %s; I'm in state %d\n", element_name, state); diff --git a/src/xml_loadsave_misc.c b/src/xml_loadsave_misc.c index 44c61ee7..22ce22be 100644 --- a/src/xml_loadsave_misc.c +++ b/src/xml_loadsave_misc.c @@ -12,10 +12,11 @@ enum XmlLoadSaveCountryTags TAG_MISC_SEASON, TAG_MISC_WEEK, TAG_MISC_WEEK_ROUND, + TAG_MISC_COUNTER, TAG_END }; -gint state; +gint state, countidx; void xml_loadsave_misc_start_element (GMarkupParseContext *context, @@ -43,6 +44,9 @@ xml_loadsave_misc_start_element (GMarkupParseContext *context, valid_tag = TRUE; } + if(tag == TAG_MISC) + countidx = 0; + if(!valid_tag) g_warning("xml_loadsave_misc_start_element: unknown tag: %s; I'm in state %d\n", element_name, state); @@ -59,10 +63,15 @@ xml_loadsave_misc_end_element (GMarkupParseContext *context, if(tag == TAG_NAME || tag == TAG_SYMBOL || tag == TAG_SID || + tag == TAG_MISC_COUNTER || tag == TAG_MISC_SEASON || tag == TAG_MISC_WEEK || tag == TAG_MISC_WEEK_ROUND) + { state = TAG_MISC; + if(tag == TAG_MISC_COUNTER) + countidx++; + } else if(tag != TAG_MISC) g_warning("xml_loadsave_misc_end_element: unknown tag: %s; I'm in state %d\n", element_name, state); @@ -95,6 +104,8 @@ xml_loadsave_misc_text (GMarkupParseContext *context, week = int_value; else if(state == TAG_MISC_WEEK_ROUND) week_round = int_value; + else if(state == TAG_MISC_COUNTER) + counters[countidx] = int_value; } @@ -139,6 +150,7 @@ xml_loadsave_misc_read(const gchar *dirname, const gchar *basename) void xml_loadsave_misc_write(const gchar *prefix) { + gint i; gchar buf[SMALL]; FILE *fil = NULL; @@ -155,6 +167,9 @@ xml_loadsave_misc_write(const gchar *prefix) xml_write_int(fil, week, TAG_MISC_WEEK, I0); xml_write_int(fil, week_round, TAG_MISC_WEEK_ROUND, I0); + for(i=0;i\n", TAG_MISC); fclose(fil); } diff --git a/support_files/bygfoot.conf b/support_files/bygfoot.conf index e948aa63..db8f8a6c 100644 --- a/support_files/bygfoot.conf +++ b/support_files/bygfoot.conf @@ -4,13 +4,14 @@ # Most of these options are uncommented because their meaning # is rather clear if you take a look at the options window in the game. -int_opt_confirm_new_week_round 1 -int_opt_confirm_quit 1 +int_opt_confirm_quit 0 +int_opt_confirm_unfit 0 int_opt_save_will_overwrite 1 int_opt_maximize_main_window 1 int_opt_prefer_messages 0 int_opt_autosave 0 int_opt_autosave_interval 3 +int_opt_autosave_files 3 # precision of skill and talent in player lists int_opt_player_precision 0 diff --git a/support_files/bygfoot_user.conf b/support_files/bygfoot_user.conf index d3033d72..d264339e 100644 --- a/support_files/bygfoot_user.conf +++ b/support_files/bygfoot_user.conf @@ -11,7 +11,6 @@ int_opt_user_pause_injury 1 int_opt_user_pause_red 1 int_opt_user_pause_break 1 int_opt_user_auto_sub 1 -int_opt_user_confirm_unfit 1 int_opt_user_show_job_offers 1 int_opt_user_swap_adapts 1 int_opt_user_show_overall 0 diff --git a/support_files/definitions/cup_brazil_prom_games.xml b/support_files/definitions/cup_brazil_prom_games.xml new file mode 100644 index 00000000..8bf855d1 --- /dev/null +++ b/support_files/definitions/cup_brazil_prom_games.xml @@ -0,0 +1,26 @@ + + + Promotion Games + Prom. Gam. + flag_br.png + brazil_prom_games + national + + + + 1 + + + 0 + + + + + + 8 + 1 + 8 + + + +