mirror of
https://github.com/tstellar/bygfoot.git
synced 2025-03-14 01:30:10 +01:00
League results done.
This commit is contained in:
parent
9e5d150934
commit
67dab84632
@ -98,7 +98,7 @@ callback_player_clicked(gint idx, GdkEventButton *event)
|
|||||||
|
|
||||||
selected_row[0] = -1;
|
selected_row[0] = -1;
|
||||||
|
|
||||||
treeview_show_user_player_list(¤t_user);
|
treeview_show_user_player_list();
|
||||||
}
|
}
|
||||||
else if(event->button == 3)
|
else if(event->button == 3)
|
||||||
{
|
{
|
||||||
|
@ -427,7 +427,8 @@ void
|
|||||||
on_menu_my_league_results_activate (GtkMenuItem *menuitem,
|
on_menu_my_league_results_activate (GtkMenuItem *menuitem,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
stat0 = STATUS_SHOW_LEAGUE_RESULTS;
|
||||||
|
treeview_show_league_results(GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,6 +65,7 @@ enum Status0Value
|
|||||||
STATUS_JOB_OFFER_FIRE_FAILURE,
|
STATUS_JOB_OFFER_FIRE_FAILURE,
|
||||||
STATUS_TRANSFER_OFFER,
|
STATUS_TRANSFER_OFFER,
|
||||||
STATUS_CUSTOM_STRUCTURE,
|
STATUS_CUSTOM_STRUCTURE,
|
||||||
|
STATUS_SHOW_LEAGUE_RESULTS,
|
||||||
STATUS_END
|
STATUS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -957,3 +957,24 @@ fixture_get_matches(const Team *tm1, const Team *tm2)
|
|||||||
|
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Return the matches the teams play in their league. */
|
||||||
|
GPtrArray*
|
||||||
|
fixture_get_league_matches(const Team *tm1, const Team *tm2)
|
||||||
|
{
|
||||||
|
gint i, j;
|
||||||
|
GPtrArray *matches = g_ptr_array_new();
|
||||||
|
|
||||||
|
for(i=0;i<ligs->len;i++)
|
||||||
|
if(lig(i).id == tm1->clid)
|
||||||
|
for(j=0;j<lig(i).fixtures->len;j++)
|
||||||
|
{
|
||||||
|
if((g_array_index(lig(i).fixtures, Fixture, j).teams[0] == tm1 &&
|
||||||
|
g_array_index(lig(i).fixtures, Fixture, j).teams[1] == tm2) ||
|
||||||
|
(g_array_index(lig(i).fixtures, Fixture, j).teams[0] == tm2 &&
|
||||||
|
g_array_index(lig(i).fixtures, Fixture, j).teams[1] == tm1))
|
||||||
|
g_ptr_array_add(matches, &g_array_index(lig(i).fixtures, Fixture, j));
|
||||||
|
}
|
||||||
|
|
||||||
|
return matches;
|
||||||
|
}
|
||||||
|
@ -103,4 +103,7 @@ fixture_compare_func(gconstpointer a, gconstpointer b, gpointer data);
|
|||||||
GPtrArray*
|
GPtrArray*
|
||||||
fixture_get_matches(const Team *tm1, const Team *tm2);
|
fixture_get_matches(const Team *tm1, const Team *tm2);
|
||||||
|
|
||||||
|
GPtrArray*
|
||||||
|
fixture_get_league_matches(const Team *tm1, const Team *tm2);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -563,7 +563,7 @@ game_substitute_player(Team *tm, gint player_number)
|
|||||||
game_gui_write_av_skills();
|
game_gui_write_av_skills();
|
||||||
|
|
||||||
selected_row[0] = -1;
|
selected_row[0] = -1;
|
||||||
treeview_show_user_player_list(¤t_user);
|
treeview_show_user_player_list();
|
||||||
}
|
}
|
||||||
|
|
||||||
return substitute;
|
return substitute;
|
||||||
@ -688,7 +688,7 @@ game_substitute_player_send_off(Team *tm, gint player_number,
|
|||||||
game_gui_write_av_skills();
|
game_gui_write_av_skills();
|
||||||
|
|
||||||
selected_row[0] = -1;
|
selected_row[0] = -1;
|
||||||
treeview_show_user_player_list(¤t_user);
|
treeview_show_user_player_list();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ void
|
|||||||
game_gui_show_main(void)
|
game_gui_show_main(void)
|
||||||
{
|
{
|
||||||
game_gui_set_main_window_header();
|
game_gui_set_main_window_header();
|
||||||
treeview_show_user_player_list(¤t_user);
|
treeview_show_user_player_list();
|
||||||
treeview_show_next_opponent(GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right")));
|
treeview_show_next_opponent(GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1440,7 +1440,7 @@ live_game_finish_unit(void)
|
|||||||
match->home_advantage);
|
match->home_advantage);
|
||||||
if(stat2 == cur_user && show &&
|
if(stat2 == cur_user && show &&
|
||||||
unit->minute % opt_int("int_opt_live_game_player_list_refresh") == 0)
|
unit->minute % opt_int("int_opt_live_game_player_list_refresh") == 0)
|
||||||
treeview_show_user_player_list(¤t_user);
|
treeview_show_user_player_list();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fixture_user_team_involved(match->fix) != -1)
|
if(fixture_user_team_involved(match->fix) != -1)
|
||||||
|
@ -56,7 +56,7 @@ misc2_callback_transfer_user_player(void)
|
|||||||
transfer_remove_player(stat1);
|
transfer_remove_player(stat1);
|
||||||
}
|
}
|
||||||
|
|
||||||
treeview_show_user_player_list(¤t_user);
|
treeview_show_user_player_list();
|
||||||
game_gui_set_main_window_header();
|
game_gui_set_main_window_header();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,5 +75,5 @@ misc2_callback_change_structure(gint structure)
|
|||||||
}
|
}
|
||||||
|
|
||||||
team_change_structure(current_user.tm, structure);
|
team_change_structure(current_user.tm, structure);
|
||||||
treeview_show_user_player_list(¤t_user);
|
treeview_show_user_player_list();
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ misc_callback_pause_live_game(void)
|
|||||||
game_save_team_states();
|
game_save_team_states();
|
||||||
|
|
||||||
if(stat2 == cur_user)
|
if(stat2 == cur_user)
|
||||||
treeview_show_user_player_list(¤t_user);
|
treeview_show_user_player_list();
|
||||||
|
|
||||||
stat0 = STATUS_LIVE_GAME_PAUSE;
|
stat0 = STATUS_LIVE_GAME_PAUSE;
|
||||||
}
|
}
|
||||||
|
104
src/treeview.c
104
src/treeview.c
@ -524,10 +524,9 @@ treeview_show_player_list(GtkTreeView *treeview, GPtrArray *players, PlayerListA
|
|||||||
g_ptr_array_free(players, TRUE);
|
g_ptr_array_free(players, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Show the list of the user's players in the left view.
|
/** Show the list of the current user's players in the left view. */
|
||||||
@param user The user we show the players of. */
|
|
||||||
void
|
void
|
||||||
treeview_show_user_player_list(const User *user)
|
treeview_show_user_player_list(void)
|
||||||
{
|
{
|
||||||
gint i;
|
gint i;
|
||||||
GPtrArray *players = NULL;
|
GPtrArray *players = NULL;
|
||||||
@ -538,8 +537,8 @@ treeview_show_user_player_list(const User *user)
|
|||||||
|
|
||||||
for(i=0;i<2;i++)
|
for(i=0;i<2;i++)
|
||||||
{
|
{
|
||||||
players = team_get_player_pointers(user->tm);
|
players = team_get_player_pointers(current_user.tm);
|
||||||
user_set_player_list_attributes(user, &attribute, i + 1);
|
user_set_player_list_attributes(¤t_user, &attribute, i + 1);
|
||||||
treeview_show_player_list(GTK_TREE_VIEW(treeview[i]), players, attribute, TRUE);
|
treeview_show_player_list(GTK_TREE_VIEW(treeview[i]), players, attribute, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1809,3 +1808,98 @@ treeview_show_next_opponent(GtkTreeView *treeview)
|
|||||||
gtk_tree_view_set_model(treeview, model);
|
gtk_tree_view_set_model(treeview, model);
|
||||||
g_object_unref(model);
|
g_object_unref(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GtkTreeModel*
|
||||||
|
treeview_create_league_results(void)
|
||||||
|
{
|
||||||
|
gint i, j;
|
||||||
|
gchar buf[2][SMALL],
|
||||||
|
name[SMALL], away[SMALL];
|
||||||
|
GPtrArray *matches = NULL;
|
||||||
|
GArray *table_elements =
|
||||||
|
league_from_clid(current_user.tm->clid)->table.elements;
|
||||||
|
GtkListStore *liststore =
|
||||||
|
gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_STRING,
|
||||||
|
G_TYPE_STRING);
|
||||||
|
GtkTreeIter iter;
|
||||||
|
|
||||||
|
for(i=0;i<table_elements->len;i++)
|
||||||
|
if(g_array_index(table_elements, TableElement, i).team != current_user.tm)
|
||||||
|
{
|
||||||
|
if(team_is_user(g_array_index(table_elements, TableElement, i).team) != -1)
|
||||||
|
sprintf(name, "<span background='%s'>%s</span>",
|
||||||
|
const_str("string_treeview_user_bg"),
|
||||||
|
g_array_index(table_elements, TableElement, i).team->name->str);
|
||||||
|
else
|
||||||
|
strcpy(name, g_array_index(table_elements, TableElement, i).team->name->str);
|
||||||
|
|
||||||
|
matches = fixture_get_league_matches(current_user.tm,
|
||||||
|
g_array_index(table_elements, TableElement, i).team);
|
||||||
|
|
||||||
|
for(j=0;j<2;j++)
|
||||||
|
if(((Fixture*)g_ptr_array_index(matches, j))->attendance != -1)
|
||||||
|
sprintf(buf[(((Fixture*)g_ptr_array_index(matches, j))->teams[0] != current_user.tm)],
|
||||||
|
"%d - %d",
|
||||||
|
((Fixture*)g_ptr_array_index(matches, j))->result
|
||||||
|
[(((Fixture*)g_ptr_array_index(matches, j))->teams[0] != current_user.tm)][0],
|
||||||
|
((Fixture*)g_ptr_array_index(matches, j))->result
|
||||||
|
[(((Fixture*)g_ptr_array_index(matches, j))->teams[0] == current_user.tm)][0]);
|
||||||
|
else
|
||||||
|
strcpy(buf[(((Fixture*)g_ptr_array_index(matches, j))->teams[0] != current_user.tm)],
|
||||||
|
"--:--");
|
||||||
|
|
||||||
|
sprintf(away, "<span background='%s' foreground='%s'>%s</span>",
|
||||||
|
const_str("string_treeview_league_results_away_bg"),
|
||||||
|
const_str("string_treeview_league_results_away_fg"),
|
||||||
|
buf[1]);
|
||||||
|
gtk_list_store_append(liststore, &iter);
|
||||||
|
gtk_list_store_set(liststore, &iter, 0, name,
|
||||||
|
1, buf[0], 2, away, -1);
|
||||||
|
|
||||||
|
g_ptr_array_free(matches, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return GTK_TREE_MODEL(liststore);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
treeview_set_up_league_results(GtkTreeView *treeview)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
gchar *titles[3] =
|
||||||
|
{_("Team"),
|
||||||
|
_("Home"),
|
||||||
|
_("Away")};
|
||||||
|
GtkTreeViewColumn *col;
|
||||||
|
GtkCellRenderer *renderer;
|
||||||
|
|
||||||
|
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview),
|
||||||
|
GTK_SELECTION_NONE);
|
||||||
|
|
||||||
|
for(i=0;i<3;i++)
|
||||||
|
{
|
||||||
|
col = gtk_tree_view_column_new();
|
||||||
|
gtk_tree_view_column_set_title(col, titles[i]);
|
||||||
|
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 the results of the current user against fellow
|
||||||
|
league teams. */
|
||||||
|
void
|
||||||
|
treeview_show_league_results(GtkTreeView *treeview)
|
||||||
|
{
|
||||||
|
GtkTreeModel *model = NULL;
|
||||||
|
|
||||||
|
treeview_clear(treeview);
|
||||||
|
gtk_tree_view_set_headers_visible(treeview, TRUE);
|
||||||
|
|
||||||
|
treeview_set_up_league_results(treeview);
|
||||||
|
model = treeview_create_league_results();
|
||||||
|
gtk_tree_view_set_model(treeview, model);
|
||||||
|
g_object_unref(model);
|
||||||
|
}
|
||||||
|
@ -53,7 +53,7 @@ treeview_show_player_list(GtkTreeView *treeview, GPtrArray *players, PlayerListA
|
|||||||
gboolean show_separator);
|
gboolean show_separator);
|
||||||
|
|
||||||
void
|
void
|
||||||
treeview_show_user_player_list(const User *user);
|
treeview_show_user_player_list(void);
|
||||||
|
|
||||||
void
|
void
|
||||||
treeview_live_game_show_commentary(const LiveGameUnit *unit);
|
treeview_live_game_show_commentary(const LiveGameUnit *unit);
|
||||||
@ -165,4 +165,13 @@ treeview_create_next_opponent_results(const Team *tm, gchar *result_buf, gchar *
|
|||||||
void
|
void
|
||||||
treeview_create_own_results(const Team *tm, gchar *buf);
|
treeview_create_own_results(const Team *tm, gchar *buf);
|
||||||
|
|
||||||
|
void
|
||||||
|
treeview_show_league_results(GtkTreeView *treeview);
|
||||||
|
|
||||||
|
void
|
||||||
|
treeview_set_up_league_results(GtkTreeView *treeview);
|
||||||
|
|
||||||
|
GtkTreeModel*
|
||||||
|
treeview_create_league_results(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -720,3 +720,7 @@ string_treeview_stadium_event_bg orange
|
|||||||
# in the oppononent info
|
# in the oppononent info
|
||||||
string_treeview_opponent_skill_positive_fg darkred
|
string_treeview_opponent_skill_positive_fg darkred
|
||||||
string_treeview_opponent_skill_negative_fg darkgreen
|
string_treeview_opponent_skill_negative_fg darkgreen
|
||||||
|
|
||||||
|
# background of the home column in the league results
|
||||||
|
string_treeview_league_results_away_bg lightgrey
|
||||||
|
string_treeview_league_results_away_fg black
|
||||||
|
Loading…
x
Reference in New Issue
Block a user