Player browse sorting.

This commit is contained in:
gyboth 2005-04-10 12:32:44 +00:00
parent 1d8591b1ff
commit 5b460629a4
5 changed files with 79 additions and 5 deletions

View File

@ -10,7 +10,7 @@ bin_PROGRAMS = bygfoot
bygfoot_SOURCES = \ 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 \ 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 \ 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 \ 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 \ finance.c callbacks.h finance.h game_gui.h maths.h option.h player.h team.h user.h \

View File

@ -2,6 +2,7 @@
#include "callback_func.h" #include "callback_func.h"
#include "free.h" #include "free.h"
#include "game_gui.h" #include "game_gui.h"
#include "gui.h"
#include "load_save.h" #include "load_save.h"
#include "main.h" #include "main.h"
#include "option.h" #include "option.h"
@ -110,6 +111,8 @@ on_button_back_to_main_clicked (GtkButton *button,
stat0 = STATUS_MAIN; stat0 = STATUS_MAIN;
gtk_notebook_set_current_page(GTK_NOTEBOOK(lookup_widget(window.main, "notebook_player")), 0); gtk_notebook_set_current_page(GTK_NOTEBOOK(lookup_widget(window.main, "notebook_player")), 0);
game_gui_show_main(); 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.")); 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"))); 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); 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; stat0 = STATUS_SHOW_PREVIEW;
treeview_show_preview(); treeview_show_preview();
gui_set_arrows();
} }
@ -279,6 +286,8 @@ on_menu_fixtures_activate (GtkMenuItem *menuitem,
{ {
stat0 = STATUS_SHOW_FIXTURES; stat0 = STATUS_SHOW_FIXTURES;
callback_show_fixtures(SHOW_TEAM); callback_show_fixtures(SHOW_TEAM);
gui_set_arrows();
} }
void void
@ -287,6 +296,8 @@ on_menu_tables_activate (GtkMenuItem *menuitem,
{ {
stat0 = STATUS_SHOW_TABLES; stat0 = STATUS_SHOW_TABLES;
callback_show_tables(SHOW_CURRENT); 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; stat0 = STATUS_SHOW_LEAGUE_RESULTS;
treeview_show_league_results(GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right"))); 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); treeview_show_team_list(GTK_TREE_VIEW(treeview_right), TRUE, TRUE);
stat0 = STATUS_SHOW_TEAM_LIST; stat0 = STATUS_SHOW_TEAM_LIST;
gui_set_arrows();
} }
@ -461,7 +476,7 @@ on_menu_next_user_activate (GtkMenuItem *menuitem,
user_event_show_next(); 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(); 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; stat0 = STATUS_SHOW_LAST_MATCH_STATS;
callback_show_last_match_stats(); callback_show_last_match_stats();
gui_set_arrows();
} }
gboolean 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."); 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")), treeview_show_finances(GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right")),
&current_user); &current_user);
gui_set_arrows();
} }
@ -662,6 +681,8 @@ on_menu_show_info_activate (GtkMenuItem *menuitem,
stat0 = STATUS_SHOW_PLAYER_INFO; stat0 = STATUS_SHOW_PLAYER_INFO;
treeview_show_player_info(player_of(current_user.tm, selected_row[0])); 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); callback_show_player_list(SHOW_CURRENT);
stat0 = STATUS_SHOW_PLAYER_LIST; stat0 = STATUS_SHOW_PLAYER_LIST;
gui_set_arrows();
} }
void void

View File

@ -82,3 +82,42 @@ gui_show_progress(gfloat value, gchar *text)
while(gtk_events_pending()) while(gtk_events_pending())
gtk_main_iteration(); 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);
}

View File

@ -13,4 +13,10 @@ gui_label_set_text_from_float(GtkLabel *label, gfloat number,
void void
gui_show_progress(gfloat value, gchar *text); gui_show_progress(gfloat value, gchar *text);
void
gui_set_arrow_pair(gint pair, gboolean state);
void
gui_set_arrows(void);
#endif #endif

View File

@ -474,6 +474,12 @@ treeview_player_compare(GtkTreeModel *model,
return_value = misc_int_compare(pl1->pos, pl2->pos); return_value = misc_int_compare(pl1->pos, pl2->pos);
break; break;
case PLAYER_LIST_ATTRIBUTE_GOALS: case PLAYER_LIST_ATTRIBUTE_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), 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)); player_games_goals_get(pl2, pl2->team->clid, PLAYER_VALUE_GOALS));
break; break;