diff --git a/src/Makefile.am b/src/Makefile.am index ae866793..890cd5df 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 free.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 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 \ diff --git a/src/callbacks.c b/src/callbacks.c index 9dde9247..0cf43119 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -2,6 +2,7 @@ #include "callback_func.h" #include "free.h" #include "game_gui.h" +#include "gui.h" #include "load_save.h" #include "main.h" #include "option.h" @@ -110,6 +111,8 @@ on_button_back_to_main_clicked (GtkButton *button, stat0 = STATUS_MAIN; gtk_notebook_set_current_page(GTK_NOTEBOOK(lookup_widget(window.main, "notebook_player")), 0); game_gui_show_main(); + + gui_set_arrows(); } @@ -121,6 +124,8 @@ on_button_transfers_clicked (GtkButton *button, game_gui_print_message(_("Left click to make an offer. Right click to remove offer.")); treeview_show_transfer_list(GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right"))); gtk_notebook_set_current_page(GTK_NOTEBOOK(lookup_widget(window.main, "notebook_player")), 1); + + gui_set_arrows(); } @@ -130,6 +135,8 @@ on_button_preview_clicked (GtkButton *button, { stat0 = STATUS_SHOW_PREVIEW; treeview_show_preview(); + + gui_set_arrows(); } @@ -279,6 +286,8 @@ on_menu_fixtures_activate (GtkMenuItem *menuitem, { stat0 = STATUS_SHOW_FIXTURES; callback_show_fixtures(SHOW_TEAM); + + gui_set_arrows(); } void @@ -287,6 +296,8 @@ on_menu_tables_activate (GtkMenuItem *menuitem, { stat0 = STATUS_SHOW_TABLES; callback_show_tables(SHOW_CURRENT); + + gui_set_arrows(); } @@ -388,6 +399,8 @@ on_menu_my_league_results_activate (GtkMenuItem *menuitem, { stat0 = STATUS_SHOW_LEAGUE_RESULTS; treeview_show_league_results(GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right"))); + + gui_set_arrows(); } @@ -401,6 +414,8 @@ on_menu_browse_teams_activate (GtkMenuItem *menuitem, treeview_show_team_list(GTK_TREE_VIEW(treeview_right), TRUE, TRUE); stat0 = STATUS_SHOW_TEAM_LIST; + + gui_set_arrows(); } @@ -461,7 +476,7 @@ on_menu_next_user_activate (GtkMenuItem *menuitem, user_event_show_next(); - game_gui_show_main(); + on_button_back_to_main_clicked(NULL, NULL); } @@ -473,7 +488,7 @@ on_menu_previous_user_activate (GtkMenuItem *menuitem, user_event_show_next(); - game_gui_show_main(); + on_button_back_to_main_clicked(NULL, NULL); } @@ -537,6 +552,8 @@ on_menu_user_show_last_stats_activate (GtkMenuItem *menuitem, stat0 = STATUS_SHOW_LAST_MATCH_STATS; callback_show_last_match_stats(); + + gui_set_arrows(); } gboolean @@ -612,6 +629,8 @@ on_menu_show_finances_activate (GtkMenuItem *menuitem, game_gui_print_message("Left-click: get loan; Right-click: pay back; Middle click: stadium window."); treeview_show_finances(GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right")), ¤t_user); + + gui_set_arrows(); } @@ -662,6 +681,8 @@ on_menu_show_info_activate (GtkMenuItem *menuitem, stat0 = STATUS_SHOW_PLAYER_INFO; treeview_show_player_info(player_of(current_user.tm, selected_row[0])); + + gui_set_arrows(); } @@ -714,6 +735,8 @@ on_menu_browse_players_activate (GtkMenuItem *menuitem, { callback_show_player_list(SHOW_CURRENT); stat0 = STATUS_SHOW_PLAYER_LIST; + + gui_set_arrows(); } void diff --git a/src/gui.c b/src/gui.c index e1a96a79..058fafb2 100644 --- a/src/gui.c +++ b/src/gui.c @@ -82,3 +82,42 @@ gui_show_progress(gfloat value, gchar *text) while(gtk_events_pending()) gtk_main_iteration(); } + +/** Set either the right pair of arrows atop the right + treeview or the left pair or both to the specified + sensitivity state. */ +void +gui_set_arrow_pair(gint pair, gboolean state) +{ + gint i, j; + GtkWidget *buttons[2][2] = + {{lookup_widget(window.main ,"button_cl_back"), + lookup_widget(window.main ,"button_cl_forward")}, + {lookup_widget(window.main ,"button_browse_back"), + lookup_widget(window.main ,"button_browse_forward")}}; + + if(pair < 3) + for(i=0;i<2;i++) + gtk_widget_set_sensitive(buttons[pair][i], state); + else + for(i=0;i<2;i++) + for(j=0;j<2;j++) + gtk_widget_set_sensitive(buttons[i][j], state); +} + +/** Examine the status variable and set the + sensitivity of the arrows atop the right treeview + accordingly. */ +void +gui_set_arrows(void) +{ + gui_set_arrow_pair(3, FALSE); + + if(stat0 == STATUS_SHOW_FIXTURES) + gui_set_arrow_pair(3, TRUE); + else if(stat0 == STATUS_SHOW_PLAYER_INFO) + gui_set_arrow_pair(1, TRUE); + else if(stat0 == STATUS_SHOW_TABLES || + stat0 == STATUS_SHOW_PLAYER_LIST) + gui_set_arrow_pair(0, TRUE); +} diff --git a/src/gui.h b/src/gui.h index d05de197..21486b38 100644 --- a/src/gui.h +++ b/src/gui.h @@ -13,4 +13,10 @@ gui_label_set_text_from_float(GtkLabel *label, gfloat number, void gui_show_progress(gfloat value, gchar *text); +void +gui_set_arrow_pair(gint pair, gboolean state); + +void +gui_set_arrows(void); + #endif diff --git a/src/treeview.c b/src/treeview.c index bbb9c1dd..90af68e5 100644 --- a/src/treeview.c +++ b/src/treeview.c @@ -474,8 +474,14 @@ treeview_player_compare(GtkTreeModel *model, return_value = misc_int_compare(pl1->pos, pl2->pos); break; case PLAYER_LIST_ATTRIBUTE_GOALS: - return_value = misc_int_compare(player_games_goals_get(pl1, pl1->team->clid, PLAYER_VALUE_GOALS), - player_games_goals_get(pl2, pl2->team->clid, PLAYER_VALUE_GOALS)); + if(pl1->pos == 0 && pl2->pos == 0) + return_value = misc_int_compare(player_games_goals_get(pl2, pl2->team->clid, PLAYER_VALUE_GOALS), + player_games_goals_get(pl1, pl1->team->clid, PLAYER_VALUE_GOALS)); + else if(pl1->pos == 0 || pl2->pos == 0) + return_value = (pl1->pos == 0) ? 1 : -1; + else + return_value = misc_int_compare(player_games_goals_get(pl1, pl1->team->clid, PLAYER_VALUE_GOALS), + player_games_goals_get(pl2, pl2->team->clid, PLAYER_VALUE_GOALS)); break; case PLAYER_LIST_ATTRIBUTE_SHOTS: return_value = misc_int_compare(player_games_goals_get(pl1, pl1->team->clid, PLAYER_VALUE_SHOTS),