2005-10-20 17:45:00 +02:00
|
|
|
/*
|
2005-11-26 17:52:51 +01:00
|
|
|
treeview.c
|
|
|
|
|
2005-10-20 17:45:00 +02:00
|
|
|
Bygfoot Football Manager -- a small and simple GTK2-based
|
|
|
|
football management game.
|
|
|
|
|
|
|
|
http://bygfoot.sourceforge.net
|
|
|
|
|
|
|
|
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2005-03-14 18:47:27 +01:00
|
|
|
#include "cup.h"
|
2006-02-15 13:03:48 +01:00
|
|
|
#include "file.h"
|
2005-03-16 21:48:25 +01:00
|
|
|
#include "finance.h"
|
2005-03-14 18:47:27 +01:00
|
|
|
#include "fixture.h"
|
2005-01-09 21:21:22 +01:00
|
|
|
#include "free.h"
|
2005-03-25 11:54:54 +01:00
|
|
|
#include "game.h"
|
2006-02-15 13:03:48 +01:00
|
|
|
#include "game_gui.h"
|
2005-06-14 17:27:44 +02:00
|
|
|
#include "language.h"
|
2004-12-30 17:48:19 +01:00
|
|
|
#include "league.h"
|
2005-01-09 21:21:22 +01:00
|
|
|
#include "live_game.h"
|
|
|
|
#include "maths.h"
|
|
|
|
#include "misc.h"
|
2005-03-20 21:49:55 +01:00
|
|
|
#include "player.h"
|
2005-03-03 13:46:48 +01:00
|
|
|
#include "option.h"
|
2004-12-30 17:48:19 +01:00
|
|
|
#include "support.h"
|
|
|
|
#include "team.h"
|
2005-03-19 21:04:08 +01:00
|
|
|
#include "transfer.h"
|
2004-12-23 13:58:39 +01:00
|
|
|
#include "treeview.h"
|
2005-04-16 09:46:04 +02:00
|
|
|
#include "treeview_helper.h"
|
2005-03-03 13:46:48 +01:00
|
|
|
#include "user.h"
|
2004-12-30 17:48:19 +01:00
|
|
|
|
2004-12-23 13:58:39 +01:00
|
|
|
/**
|
|
|
|
Creates the model for the treeview in the team selection window.
|
|
|
|
The model contains a list of all the teams from the leagues in
|
|
|
|
the country::leagues array; if show_cup_teams is TRUE, the
|
|
|
|
teams from international cups are shown, too.
|
|
|
|
@param show_cup_teams Whether or not teams from international
|
|
|
|
cups are shown.
|
2005-03-03 13:46:48 +01:00
|
|
|
@param show_user_teams Whether or not user teams are shown.
|
2004-12-23 13:58:39 +01:00
|
|
|
@return The model containing the team names.
|
|
|
|
*/
|
|
|
|
GtkTreeModel*
|
2005-03-03 13:46:48 +01:00
|
|
|
treeview_create_team_selection_list(gboolean show_cup_teams, gboolean show_user_teams)
|
2004-12-23 13:58:39 +01:00
|
|
|
{
|
2005-01-09 21:21:22 +01:00
|
|
|
gint i, j, cnt = 1;
|
2005-04-29 21:48:02 +02:00
|
|
|
GtkListStore *ls;
|
2004-12-23 13:58:39 +01:00
|
|
|
GtkTreeIter iter;
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
ls = gtk_list_store_new(5,
|
|
|
|
G_TYPE_INT,
|
|
|
|
GDK_TYPE_PIXBUF,
|
|
|
|
G_TYPE_POINTER,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_POINTER);
|
2004-12-23 13:58:39 +01:00
|
|
|
|
|
|
|
for(i=0;i<ligs->len;i++)
|
|
|
|
{
|
|
|
|
for(j=0;j<lig(i).teams->len;j++)
|
|
|
|
{
|
2005-03-03 13:46:48 +01:00
|
|
|
if(team_is_user(&g_array_index(lig(i).teams, Team, j)) == -1)
|
|
|
|
{
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
2005-10-09 11:35:44 +02:00
|
|
|
treeview_helper_insert_icon(ls, &iter, 1, g_array_index(lig(i).teams, Team, j).symbol);
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_set(ls, &iter,
|
2005-03-03 13:46:48 +01:00
|
|
|
0, cnt++,
|
|
|
|
2, (gpointer)&g_array_index(lig(i).teams, Team, j),
|
2005-10-09 11:35:44 +02:00
|
|
|
3, lig(i).name,
|
2005-03-25 21:18:35 +01:00
|
|
|
4, (gpointer)&g_array_index(lig(i).teams, Team, j),
|
2005-03-03 13:46:48 +01:00
|
|
|
-1);
|
|
|
|
}
|
2004-12-23 13:58:39 +01:00
|
|
|
}
|
|
|
|
}
|
2005-01-09 21:21:22 +01:00
|
|
|
|
|
|
|
if(!show_cup_teams)
|
2005-04-29 21:48:02 +02:00
|
|
|
return GTK_TREE_MODEL(ls);
|
2005-01-09 21:21:22 +01:00
|
|
|
|
|
|
|
for(i=0;i<cps->len;i++)
|
2005-05-06 18:35:19 +02:00
|
|
|
if(cp(i).teams->len > 0)
|
2005-01-09 21:21:22 +01:00
|
|
|
for(j=0;j<cp(i).teams->len;j++)
|
|
|
|
{
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
treeview_helper_insert_icon(ls, &iter, 1,
|
2005-10-09 11:35:44 +02:00
|
|
|
((Team*)g_ptr_array_index(cp(i).teams, j))->symbol);
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_set(ls, &iter,
|
2005-01-09 21:21:22 +01:00
|
|
|
0, cnt++,
|
2005-05-08 19:56:26 +02:00
|
|
|
2, g_ptr_array_index(cp(i).teams, j),
|
2005-10-09 11:35:44 +02:00
|
|
|
3, cp(i).name,
|
2005-05-08 19:56:26 +02:00
|
|
|
4, g_ptr_array_index(cp(i).teams, j),
|
2005-01-09 21:21:22 +01:00
|
|
|
-1);
|
|
|
|
}
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), 4,
|
2005-04-16 09:46:04 +02:00
|
|
|
treeview_helper_team_compare, GINT_TO_POINTER(TEAM_COMPARE_AV_SKILL), NULL);
|
2005-03-25 21:18:35 +01:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
return GTK_TREE_MODEL(ls);
|
2004-12-23 13:58:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets up the treeview for the team selection window.
|
|
|
|
Columns and cell renderers are added etc.
|
|
|
|
@param treeview The treeview that gets configured.
|
|
|
|
*/
|
|
|
|
void
|
2005-06-17 14:57:05 +02:00
|
|
|
treeview_set_up_team_selection_treeview(GtkTreeView *treeview)
|
2004-12-23 13:58:39 +01:00
|
|
|
{
|
|
|
|
GtkTreeViewColumn *col;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
|
|
|
|
gtk_tree_selection_set_mode(
|
|
|
|
gtk_tree_view_get_selection(treeview),
|
|
|
|
GTK_SELECTION_BROWSE);
|
2005-03-25 21:18:35 +01:00
|
|
|
gtk_tree_view_set_headers_visible(treeview, TRUE);
|
2004-12-23 13:58:39 +01:00
|
|
|
gtk_tree_view_set_rules_hint(treeview, TRUE);
|
|
|
|
|
2005-11-26 17:52:51 +01:00
|
|
|
gtk_tree_view_set_search_column(treeview, 2);
|
|
|
|
gtk_tree_view_set_search_equal_func(treeview,
|
|
|
|
treeview_helper_search_equal,
|
|
|
|
NULL, NULL);
|
|
|
|
|
2005-01-09 21:21:22 +01:00
|
|
|
/* Numbering the teams */
|
2004-12-23 13:58:39 +01:00
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
2005-04-16 09:46:04 +02:00
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
2004-12-23 13:58:39 +01:00
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
|
|
|
"text", 0);
|
|
|
|
|
2005-01-09 21:21:22 +01:00
|
|
|
/* Flags */
|
2004-12-23 13:58:39 +01:00
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
2005-01-09 21:21:22 +01:00
|
|
|
renderer = gtk_cell_renderer_pixbuf_new();
|
2004-12-23 13:58:39 +01:00
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
2005-01-09 21:21:22 +01:00
|
|
|
"pixbuf", 1);
|
2004-12-23 13:58:39 +01:00
|
|
|
|
2005-01-09 21:21:22 +01:00
|
|
|
/* Team column */
|
2004-12-23 13:58:39 +01:00
|
|
|
col = gtk_tree_view_column_new();
|
2005-01-09 21:21:22 +01:00
|
|
|
gtk_tree_view_column_set_title(col, _("Team"));
|
2004-12-23 13:58:39 +01:00
|
|
|
gtk_tree_view_append_column(treeview, col);
|
2005-04-16 09:46:04 +02:00
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
2004-12-23 13:58:39 +01:00
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
2005-01-09 21:21:22 +01:00
|
|
|
gtk_tree_view_column_set_cell_data_func(col, renderer,
|
2005-04-16 09:46:04 +02:00
|
|
|
treeview_helper_team_selection,
|
2005-03-25 21:18:35 +01:00
|
|
|
NULL, NULL);
|
2005-01-09 21:21:22 +01:00
|
|
|
/* League column */
|
2004-12-30 17:48:19 +01:00
|
|
|
col = gtk_tree_view_column_new();
|
2005-01-09 21:21:22 +01:00
|
|
|
gtk_tree_view_column_set_title(col, _("League"));
|
2004-12-30 17:48:19 +01:00
|
|
|
gtk_tree_view_append_column(treeview, col);
|
2005-04-16 09:46:04 +02:00
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
2004-12-30 17:48:19 +01:00
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
|
|
|
"text", 3);
|
2005-03-25 21:18:35 +01:00
|
|
|
|
|
|
|
col = gtk_tree_view_column_new();
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Average skill */
|
2005-03-25 21:18:35 +01:00
|
|
|
gtk_tree_view_column_set_title(col, _("Av.Sk."));
|
|
|
|
gtk_tree_view_column_set_sort_column_id(col, 4);
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
2005-04-16 09:46:04 +02:00
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
2005-03-25 21:18:35 +01:00
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_set_cell_data_func(col, renderer,
|
2005-04-16 09:46:04 +02:00
|
|
|
treeview_helper_team_selection,
|
2005-03-25 21:18:35 +01:00
|
|
|
NULL, NULL);
|
|
|
|
|
2004-12-23 13:58:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Shows the list of teams in the game.
|
|
|
|
If show_cup_teams is TRUE, the teams from
|
|
|
|
international cups are shown, too.
|
|
|
|
@param treeview The treeview we show the list in.
|
|
|
|
@param show_cup_teams Whether or not teams from international
|
|
|
|
cups are shown.
|
2005-03-03 13:46:48 +01:00
|
|
|
@param show_user_teams Whether or not user teams are shown.
|
2004-12-23 13:58:39 +01:00
|
|
|
*/
|
|
|
|
void
|
2005-03-03 13:46:48 +01:00
|
|
|
treeview_show_team_list(GtkTreeView *treeview, gboolean show_cup_teams,
|
|
|
|
gboolean show_user_teams)
|
2004-12-23 13:58:39 +01:00
|
|
|
{
|
|
|
|
GtkTreeModel *team_list =
|
2005-03-03 13:46:48 +01:00
|
|
|
treeview_create_team_selection_list(show_cup_teams, show_user_teams);
|
2004-12-23 13:58:39 +01:00
|
|
|
GtkTreeSelection *selection;
|
2005-06-20 14:46:57 +02:00
|
|
|
GtkTreePath *path = gtk_tree_path_new_from_string("0");
|
2004-12-23 13:58:39 +01:00
|
|
|
|
2005-04-16 09:46:04 +02:00
|
|
|
treeview_helper_clear(treeview);
|
2004-12-23 13:58:39 +01:00
|
|
|
|
|
|
|
treeview_set_up_team_selection_treeview(treeview);
|
|
|
|
|
|
|
|
gtk_tree_view_set_model(treeview, team_list);
|
|
|
|
|
|
|
|
selection = gtk_tree_view_get_selection(treeview);
|
2005-06-20 14:46:57 +02:00
|
|
|
gtk_tree_selection_select_path(selection, path);
|
2004-12-23 13:58:39 +01:00
|
|
|
g_object_unref(team_list);
|
2005-06-20 14:46:57 +02:00
|
|
|
gtk_tree_path_free(path);
|
2004-12-23 13:58:39 +01:00
|
|
|
}
|
2005-01-09 21:21:22 +01:00
|
|
|
|
|
|
|
/** Create the list store for a player list.
|
|
|
|
@param players The array containing the players.
|
|
|
|
@param attributes An array containing the attributes we show.
|
|
|
|
@param max The size of the attribute array.
|
2005-09-18 12:02:10 +02:00
|
|
|
@param separator Whether we draw a blank line after the 11th player.
|
|
|
|
@param status Whether player status is shown (takes two columns). */
|
2005-01-09 21:21:22 +01:00
|
|
|
GtkTreeModel*
|
2005-06-11 18:54:59 +02:00
|
|
|
treeview_create_player_list(GPtrArray *players, gint *attributes, gint max,
|
2005-09-18 12:02:10 +02:00
|
|
|
gboolean show_separator, gboolean sortable, gboolean status)
|
2005-01-09 21:21:22 +01:00
|
|
|
{
|
|
|
|
gint i, j;
|
2005-04-29 21:48:02 +02:00
|
|
|
GtkListStore *ls;
|
2005-01-09 21:21:22 +01:00
|
|
|
GtkTreeIter iter;
|
2005-09-18 12:02:10 +02:00
|
|
|
GType types[max + 1 + status];
|
2005-01-09 21:21:22 +01:00
|
|
|
|
|
|
|
types[0] = G_TYPE_INT;
|
2005-09-18 12:02:10 +02:00
|
|
|
for(i=0;i<max + status;i++)
|
2005-01-09 21:21:22 +01:00
|
|
|
types[i + 1] = G_TYPE_POINTER;
|
|
|
|
|
2005-09-18 12:02:10 +02:00
|
|
|
ls = gtk_list_store_newv(max + 1 + status, types);
|
2005-01-09 21:21:22 +01:00
|
|
|
|
|
|
|
for(i=0;i<players->len;i++)
|
|
|
|
{
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
2005-01-09 21:21:22 +01:00
|
|
|
if(show_separator && i == 11)
|
|
|
|
{
|
2005-09-18 12:02:10 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 0,
|
|
|
|
const_int("int_treeview_helper_int_empty"), -1);
|
|
|
|
|
|
|
|
for(j=0;j<max + status;j++)
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_set(ls, &iter, j + 1, NULL, -1);
|
2005-01-09 21:21:22 +01:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, i + 1, -1);
|
2005-01-09 21:21:22 +01:00
|
|
|
}
|
|
|
|
else
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 0, i + 1, -1);
|
2005-01-09 21:21:22 +01:00
|
|
|
|
2005-09-18 12:02:10 +02:00
|
|
|
for(j=0;j<max + status;j++)
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_set(ls, &iter, j + 1, g_ptr_array_index(players, i), -1);
|
2005-01-09 21:21:22 +01:00
|
|
|
}
|
|
|
|
|
2005-06-11 18:54:59 +02:00
|
|
|
if(sortable)
|
2005-03-27 19:59:57 +02:00
|
|
|
{
|
|
|
|
for(i=0;i<max;i++)
|
|
|
|
if(attributes[i] == PLAYER_LIST_ATTRIBUTE_POS ||
|
|
|
|
attributes[i] == PLAYER_LIST_ATTRIBUTE_SKILL ||
|
|
|
|
attributes[i] == PLAYER_LIST_ATTRIBUTE_GOALS ||
|
|
|
|
attributes[i] == PLAYER_LIST_ATTRIBUTE_SHOTS ||
|
|
|
|
attributes[i] == PLAYER_LIST_ATTRIBUTE_GAMES ||
|
|
|
|
attributes[i] == PLAYER_LIST_ATTRIBUTE_AGE ||
|
|
|
|
attributes[i] == PLAYER_LIST_ATTRIBUTE_ETAL ||
|
|
|
|
attributes[i] == PLAYER_LIST_ATTRIBUTE_VALUE ||
|
|
|
|
attributes[i] == PLAYER_LIST_ATTRIBUTE_WAGE)
|
2005-09-18 12:02:10 +02:00
|
|
|
gtk_tree_sortable_set_sort_func(
|
|
|
|
GTK_TREE_SORTABLE(ls),
|
|
|
|
i + 1 + (status && attributes[i] > PLAYER_LIST_ATTRIBUTE_STATUS),
|
|
|
|
treeview_helper_player_compare, GINT_TO_POINTER(attributes[i]), NULL);
|
2005-03-27 19:59:57 +02:00
|
|
|
}
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
return (GtkTreeModel*)ls;
|
2005-01-09 21:21:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Set up the tree view for a player list */
|
|
|
|
void
|
2005-06-17 14:57:05 +02:00
|
|
|
treeview_set_up_player_list(GtkTreeView *treeview, gint *attributes, gint max,
|
|
|
|
gboolean show_separator, gboolean sortable)
|
2005-01-09 21:21:22 +01:00
|
|
|
{
|
2005-09-18 12:02:10 +02:00
|
|
|
gint i, cnt = 1;
|
2005-01-09 21:21:22 +01:00
|
|
|
GtkTreeViewColumn *col;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
gchar *titles[PLAYER_LIST_ATTRIBUTE_END] =
|
|
|
|
{_("Name"),
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Current position of a player. */
|
2005-01-09 21:21:22 +01:00
|
|
|
_("CPos"),
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Position of a player. */
|
2005-01-09 21:21:22 +01:00
|
|
|
_("Pos"),
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Current skill of a player. */
|
2005-01-09 21:21:22 +01:00
|
|
|
_("CSk"),
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Skill of a player. */
|
2005-01-09 21:21:22 +01:00
|
|
|
_("Sk"),
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Fitness of a player. */
|
2005-01-09 21:21:22 +01:00
|
|
|
_("Fit"),
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Games of a player. */
|
2005-01-09 21:21:22 +01:00
|
|
|
_("Ga"),
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Shots of a player. */
|
2005-03-08 09:25:46 +01:00
|
|
|
_("Sh"),
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Goals of a player. */
|
2005-03-09 14:10:28 +01:00
|
|
|
_("Go"),
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Status of a player. */
|
2005-01-09 21:21:22 +01:00
|
|
|
_("Status"),
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Yellow cards of a player. */
|
2005-01-09 21:21:22 +01:00
|
|
|
_("YC"),
|
|
|
|
_("Age"),
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Estimated talent of a player. */
|
2005-01-09 21:21:22 +01:00
|
|
|
_("Etal"),
|
|
|
|
_("Value"),
|
|
|
|
_("Wage"),
|
|
|
|
_("Contract"),
|
|
|
|
_("Team"),
|
|
|
|
_("League")};
|
|
|
|
|
|
|
|
gtk_tree_selection_set_mode(
|
|
|
|
gtk_tree_view_get_selection(treeview),
|
|
|
|
GTK_SELECTION_SINGLE);
|
2005-03-25 21:18:35 +01:00
|
|
|
gtk_tree_view_set_rules_hint(treeview, FALSE);
|
|
|
|
gtk_tree_view_set_headers_visible(treeview, TRUE);
|
2005-01-09 21:21:22 +01:00
|
|
|
|
|
|
|
/* number the players */
|
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
2005-04-16 09:46:04 +02:00
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
2005-01-09 21:21:22 +01:00
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_set_cell_data_func(col, renderer,
|
2005-04-16 09:46:04 +02:00
|
|
|
treeview_helper_int_to_cell,
|
2005-01-09 21:21:22 +01:00
|
|
|
NULL, NULL);
|
|
|
|
for(i=0;i<max;i++)
|
|
|
|
{
|
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_column_set_title(col, titles[attributes[i]]);
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
2005-04-16 09:46:04 +02:00
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
2005-01-09 21:21:22 +01:00
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_set_cell_data_func(col, renderer,
|
2005-04-16 09:46:04 +02:00
|
|
|
treeview_helper_player_to_cell,
|
2005-01-09 21:21:22 +01:00
|
|
|
GINT_TO_POINTER(attributes[i]),
|
|
|
|
NULL);
|
|
|
|
|
2005-03-19 21:04:08 +01:00
|
|
|
if(attributes[i] != PLAYER_LIST_ATTRIBUTE_NAME &&
|
|
|
|
attributes[i] != PLAYER_LIST_ATTRIBUTE_TEAM &&
|
|
|
|
attributes[i] != PLAYER_LIST_ATTRIBUTE_LEAGUE_CUP)
|
2005-01-09 21:21:22 +01:00
|
|
|
{
|
|
|
|
gtk_tree_view_column_set_alignment(col, 0.5);
|
|
|
|
g_object_set(renderer, "xalign", 0.5,
|
|
|
|
NULL);
|
|
|
|
}
|
2005-03-27 19:59:57 +02:00
|
|
|
|
2005-06-11 18:54:59 +02:00
|
|
|
if(sortable &&
|
2005-03-27 19:59:57 +02:00
|
|
|
(attributes[i] == PLAYER_LIST_ATTRIBUTE_POS ||
|
|
|
|
attributes[i] == PLAYER_LIST_ATTRIBUTE_SKILL ||
|
|
|
|
attributes[i] == PLAYER_LIST_ATTRIBUTE_GOALS ||
|
|
|
|
attributes[i] == PLAYER_LIST_ATTRIBUTE_SHOTS ||
|
|
|
|
attributes[i] == PLAYER_LIST_ATTRIBUTE_GAMES ||
|
|
|
|
attributes[i] == PLAYER_LIST_ATTRIBUTE_AGE ||
|
|
|
|
attributes[i] == PLAYER_LIST_ATTRIBUTE_ETAL ||
|
|
|
|
attributes[i] == PLAYER_LIST_ATTRIBUTE_VALUE ||
|
|
|
|
attributes[i] == PLAYER_LIST_ATTRIBUTE_WAGE))
|
2005-09-18 12:02:10 +02:00
|
|
|
gtk_tree_view_column_set_sort_column_id(col, cnt);
|
|
|
|
|
|
|
|
cnt++;
|
|
|
|
|
|
|
|
if(attributes[i] == PLAYER_LIST_ATTRIBUTE_STATUS)
|
|
|
|
{
|
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
|
|
|
renderer = gtk_cell_renderer_pixbuf_new();
|
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_set_cell_data_func(
|
|
|
|
col, renderer, treeview_helper_player_status_to_cell,
|
|
|
|
NULL, NULL);
|
|
|
|
|
|
|
|
gtk_tree_view_column_set_alignment(col, 0.5);
|
|
|
|
g_object_set(renderer, "xalign", 0.5,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
cnt++;
|
|
|
|
}
|
2005-01-09 21:21:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Fill a treeview with the players from the pointer array. Show
|
|
|
|
player attributes according to 'attrib'.
|
|
|
|
@param treeview The treeview we fill.
|
|
|
|
@param players The pointer array with the players. We free it afterwards.
|
2005-03-03 13:46:48 +01:00
|
|
|
@param attrib The #PlayerListAttribute that determines which attributes to show.
|
2005-01-09 21:21:22 +01:00
|
|
|
@param show_separator Whether we draw a blank line after the 11th player. */
|
|
|
|
void
|
2005-09-18 12:02:10 +02:00
|
|
|
treeview_show_player_list(GtkTreeView *treeview, GPtrArray *players,
|
|
|
|
PlayerListAttribute attribute,
|
2005-01-09 21:21:22 +01:00
|
|
|
gboolean show_separator)
|
|
|
|
{
|
|
|
|
gint i, cnt = 0;
|
|
|
|
gint columns = math_sum_int_array(attribute.on_off, PLAYER_LIST_ATTRIBUTE_END);
|
|
|
|
gint attributes[columns];
|
|
|
|
GtkTreeModel *model = NULL;
|
2005-09-18 12:02:10 +02:00
|
|
|
gboolean sortable =
|
|
|
|
(treeview != GTK_TREE_VIEW(lookup_widget(window.main, "player_list1")));
|
2005-01-09 21:21:22 +01:00
|
|
|
|
2005-04-16 09:46:04 +02:00
|
|
|
treeview_helper_clear(treeview);
|
2005-01-09 21:21:22 +01:00
|
|
|
|
|
|
|
for(i=0;i<PLAYER_LIST_ATTRIBUTE_END;i++)
|
2005-09-18 12:02:10 +02:00
|
|
|
{
|
2005-01-09 21:21:22 +01:00
|
|
|
if(attribute.on_off[i])
|
|
|
|
attributes[cnt++] = i;
|
2005-09-18 12:02:10 +02:00
|
|
|
}
|
2005-01-09 21:21:22 +01:00
|
|
|
|
2005-06-11 18:54:59 +02:00
|
|
|
treeview_set_up_player_list(treeview, attributes, columns, show_separator, sortable);
|
2005-01-09 21:21:22 +01:00
|
|
|
|
2005-09-18 12:02:10 +02:00
|
|
|
model = treeview_create_player_list(players, attributes,
|
|
|
|
columns, show_separator,
|
|
|
|
sortable,
|
|
|
|
attribute.on_off[PLAYER_LIST_ATTRIBUTE_STATUS]);
|
2005-01-09 21:21:22 +01:00
|
|
|
|
|
|
|
gtk_tree_view_set_model(treeview, model);
|
|
|
|
g_object_unref(model);
|
2005-03-08 09:25:46 +01:00
|
|
|
|
|
|
|
g_ptr_array_free(players, TRUE);
|
2005-01-09 21:21:22 +01:00
|
|
|
}
|
|
|
|
|
2005-03-24 21:22:44 +01:00
|
|
|
/** Show the list of the current user's players in the left view. */
|
2005-01-09 21:21:22 +01:00
|
|
|
void
|
2005-03-24 21:22:44 +01:00
|
|
|
treeview_show_user_player_list(void)
|
2005-01-09 21:21:22 +01:00
|
|
|
{
|
2005-03-18 23:03:23 +01:00
|
|
|
gint i;
|
|
|
|
GPtrArray *players = NULL;
|
|
|
|
PlayerListAttribute attribute;
|
2005-04-13 15:01:59 +02:00
|
|
|
GtkWidget *treeview[2] =
|
2005-03-18 23:03:23 +01:00
|
|
|
{lookup_widget(window.main, "player_list1"),
|
|
|
|
lookup_widget(window.main, "player_list2")};
|
|
|
|
|
|
|
|
for(i=0;i<2;i++)
|
|
|
|
{
|
2005-07-08 11:26:00 +02:00
|
|
|
players = player_get_pointers_from_array(current_user.tm->players);
|
2005-03-24 21:22:44 +01:00
|
|
|
user_set_player_list_attributes(¤t_user, &attribute, i + 1);
|
2005-03-18 23:03:23 +01:00
|
|
|
treeview_show_player_list(GTK_TREE_VIEW(treeview[i]), players, attribute, TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Show the player list of a foreign team depending on the
|
|
|
|
scout quality. */
|
|
|
|
void
|
|
|
|
treeview_show_player_list_team(GtkTreeView *treeview, const Team *tm, gint scout)
|
|
|
|
{
|
2005-07-08 11:26:00 +02:00
|
|
|
GPtrArray *players = player_get_pointers_from_array(tm->players);
|
2005-03-18 23:03:23 +01:00
|
|
|
|
|
|
|
treeview_show_player_list(treeview, players,
|
2005-04-16 09:46:04 +02:00
|
|
|
treeview_helper_get_attributes_from_scout(scout), TRUE);
|
2005-01-09 21:21:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Show the commentary and the minute belonging to the unit.
|
|
|
|
@param unit The #LiveGameUnit we show. */
|
|
|
|
void
|
|
|
|
treeview_live_game_show_commentary(const LiveGameUnit *unit)
|
|
|
|
{
|
|
|
|
GtkAdjustment *adjustment =
|
|
|
|
gtk_scrolled_window_get_vadjustment(
|
2005-03-03 13:46:48 +01:00
|
|
|
GTK_SCROLLED_WINDOW(lookup_widget(window.live,
|
2005-01-09 21:21:22 +01:00
|
|
|
"scrolledwindow9")));
|
2005-04-29 21:48:02 +02:00
|
|
|
GtkListStore *ls =
|
2005-01-09 21:21:22 +01:00
|
|
|
GTK_LIST_STORE(
|
2005-03-03 13:46:48 +01:00
|
|
|
gtk_tree_view_get_model(GTK_TREE_VIEW(lookup_widget(window.live, "treeview_commentary"))));
|
2005-01-09 21:21:22 +01:00
|
|
|
GtkTreeIter iter;
|
2005-05-02 16:39:30 +02:00
|
|
|
gchar buf[SMALL], buf2[SMALL];
|
2005-01-09 21:21:22 +01:00
|
|
|
|
2005-03-08 09:25:46 +01:00
|
|
|
sprintf(buf, "%3d.", live_game_unit_get_minute(unit));
|
2005-05-02 16:39:30 +02:00
|
|
|
if(unit->possession == 1)
|
|
|
|
sprintf(buf2, "<span background='%s' foreground='%s'>%s</span>",
|
2005-05-06 18:35:19 +02:00
|
|
|
const_app("string_treeview_live_game_commentary_away_bg"),
|
|
|
|
const_app("string_treeview_live_game_commentary_away_fg"),
|
2005-10-09 11:35:44 +02:00
|
|
|
unit->event.commentary);
|
2005-05-02 16:39:30 +02:00
|
|
|
else
|
|
|
|
sprintf(buf2, "<span background='%s' foreground='%s'>%s</span>",
|
2005-05-06 18:35:19 +02:00
|
|
|
const_app("string_treeview_helper_color_default_background"),
|
|
|
|
const_app("string_treeview_helper_color_default_foreground"),
|
2005-10-09 11:35:44 +02:00
|
|
|
unit->event.commentary);
|
2005-05-02 16:39:30 +02:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_prepend(ls, &iter);
|
|
|
|
treeview_helper_insert_icon(ls, &iter, 1, treeview_helper_live_game_icon(unit->event.type));
|
2005-05-02 16:39:30 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 0, buf, 2, buf2, -1);
|
2005-01-12 21:49:24 +01:00
|
|
|
|
2005-01-09 21:21:22 +01:00
|
|
|
adjustment->value = adjustment->lower - adjustment->page_size;
|
|
|
|
gtk_adjustment_value_changed(adjustment);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Create the list store for the live game
|
|
|
|
commentary treeview.
|
|
|
|
@param unit The unit we show.
|
2005-04-29 21:48:02 +02:00
|
|
|
@return The ls. */
|
2005-01-09 21:21:22 +01:00
|
|
|
GtkTreeModel*
|
|
|
|
treeview_live_game_create_init_commentary(const LiveGameUnit *unit)
|
|
|
|
{
|
2005-04-29 21:48:02 +02:00
|
|
|
GtkListStore *ls;
|
2005-01-09 21:21:22 +01:00
|
|
|
GtkTreeIter iter;
|
|
|
|
gchar buf[SMALL];
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
ls = gtk_list_store_new(3,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
GDK_TYPE_PIXBUF,
|
|
|
|
G_TYPE_STRING);
|
2005-01-09 21:21:22 +01:00
|
|
|
|
2005-03-08 09:25:46 +01:00
|
|
|
sprintf(buf, "%3d.", unit->minute);
|
2005-01-12 21:49:24 +01:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
treeview_helper_insert_icon(ls, &iter, 1, treeview_helper_live_game_icon(unit->event.type));
|
2005-10-09 11:35:44 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 0, buf, 2, unit->event.commentary, -1);
|
2005-01-12 21:49:24 +01:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
return GTK_TREE_MODEL(ls);
|
2005-01-09 21:21:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Set up the commentary treeview for the live game. */
|
|
|
|
void
|
|
|
|
treeview_live_game_set_up_commentary(void)
|
|
|
|
{
|
|
|
|
GtkTreeView *treeview =
|
2005-03-03 13:46:48 +01:00
|
|
|
GTK_TREE_VIEW(lookup_widget(window.live, "treeview_commentary"));
|
2005-01-09 21:21:22 +01:00
|
|
|
GtkTreeViewColumn *col;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
|
|
|
|
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview),
|
|
|
|
GTK_SELECTION_NONE);
|
2005-03-25 21:18:35 +01:00
|
|
|
gtk_tree_view_set_headers_visible(treeview, FALSE);
|
2005-01-09 21:21:22 +01:00
|
|
|
|
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
2005-04-16 09:46:04 +02:00
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
2005-01-09 21:21:22 +01:00
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
|
|
|
"text", 0);
|
|
|
|
|
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
|
|
|
renderer = gtk_cell_renderer_pixbuf_new();
|
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
|
|
|
"pixbuf", 1);
|
|
|
|
|
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
2005-04-16 09:46:04 +02:00
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
2005-01-09 21:21:22 +01:00
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
2005-05-02 16:39:30 +02:00
|
|
|
"markup", 2);
|
2005-01-09 21:21:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Show the first commentary of the live game
|
|
|
|
@param unit The #LiveGameUnit we show. */
|
|
|
|
void
|
|
|
|
treeview_live_game_show_initial_commentary(const LiveGameUnit *unit)
|
|
|
|
{
|
|
|
|
GtkTreeView *treeview =
|
2005-03-03 13:46:48 +01:00
|
|
|
GTK_TREE_VIEW(lookup_widget(window.live, "treeview_commentary"));
|
2005-01-09 21:21:22 +01:00
|
|
|
GtkTreeModel *model = NULL;
|
|
|
|
|
2005-04-16 09:46:04 +02:00
|
|
|
treeview_helper_clear(treeview);
|
2005-01-09 21:21:22 +01:00
|
|
|
|
|
|
|
treeview_live_game_set_up_commentary();
|
|
|
|
|
|
|
|
model = treeview_live_game_create_init_commentary(unit);
|
|
|
|
|
|
|
|
gtk_tree_view_set_model(treeview, model);
|
|
|
|
g_object_unref(model);
|
|
|
|
}
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
/** Fill the ls for the live game result treeview.
|
2005-01-09 21:21:22 +01:00
|
|
|
@param unit The current live game unit.
|
2005-04-29 21:48:02 +02:00
|
|
|
@return The ls we created. */
|
2005-01-09 21:21:22 +01:00
|
|
|
GtkTreeModel*
|
|
|
|
treeview_live_game_create_result(const LiveGameUnit *unit)
|
|
|
|
{
|
2005-04-29 21:48:02 +02:00
|
|
|
GtkListStore *ls;
|
2005-01-09 21:21:22 +01:00
|
|
|
GtkTreeIter iter;
|
2005-08-20 21:39:36 +02:00
|
|
|
gchar buf[SMALL];
|
2005-01-09 21:21:22 +01:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
ls = gtk_list_store_new(3,
|
2005-08-17 22:39:07 +02:00
|
|
|
G_TYPE_STRING,
|
2005-08-20 21:39:36 +02:00
|
|
|
G_TYPE_STRING,
|
2005-08-17 22:39:07 +02:00
|
|
|
G_TYPE_STRING);
|
2005-01-09 21:21:22 +01:00
|
|
|
|
2005-08-20 21:39:36 +02:00
|
|
|
live_game_unit_result_to_buf(unit, buf, FALSE);
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
2005-08-17 22:39:07 +02:00
|
|
|
gtk_list_store_set(ls, &iter,
|
2005-10-09 11:35:44 +02:00
|
|
|
0, ((LiveGame*)statp)->team_names[0],
|
2005-08-20 21:39:36 +02:00
|
|
|
1, buf,
|
2005-10-09 11:35:44 +02:00
|
|
|
2, ((LiveGame*)statp)->team_names[1], -1);
|
2005-01-12 21:56:39 +01:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
return GTK_TREE_MODEL(ls);
|
2005-01-09 21:21:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Set up the treeview columns for the result. */
|
|
|
|
void
|
|
|
|
treeview_live_game_set_up_result(void)
|
|
|
|
{
|
2005-03-14 18:47:27 +01:00
|
|
|
gint i;
|
2005-01-09 21:21:22 +01:00
|
|
|
GtkTreeView *treeview =
|
2005-03-03 13:46:48 +01:00
|
|
|
GTK_TREE_VIEW(lookup_widget(window.live, "treeview_result"));
|
2005-01-09 21:21:22 +01:00
|
|
|
GtkTreeViewColumn *col;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
|
|
|
|
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview),
|
|
|
|
GTK_SELECTION_NONE);
|
2005-03-25 21:18:35 +01:00
|
|
|
gtk_tree_view_set_headers_visible(treeview, FALSE);
|
2005-01-09 21:21:22 +01:00
|
|
|
|
2005-03-14 18:47:27 +01:00
|
|
|
for(i=0;i<3;i++)
|
|
|
|
{
|
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
2005-04-16 09:46:04 +02:00
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
2005-03-14 18:47:27 +01:00
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_set_cell_data_func(col, renderer,
|
2005-04-16 09:46:04 +02:00
|
|
|
treeview_helper_live_game_result,
|
2005-03-14 18:47:27 +01:00
|
|
|
NULL, NULL);
|
|
|
|
}
|
2005-01-09 21:21:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Write the current result of the live game into
|
|
|
|
the corresponding treeview.
|
|
|
|
@param unit The current live game unit. */
|
|
|
|
void
|
|
|
|
treeview_live_game_show_result(const LiveGameUnit *unit)
|
|
|
|
{
|
|
|
|
GtkTreeView *treeview =
|
2005-03-03 13:46:48 +01:00
|
|
|
GTK_TREE_VIEW(lookup_widget(window.live, "treeview_result"));
|
2005-01-09 21:21:22 +01:00
|
|
|
GtkTreeModel *model = NULL;
|
|
|
|
|
2005-04-16 09:46:04 +02:00
|
|
|
treeview_helper_clear(treeview);
|
2005-01-09 21:21:22 +01:00
|
|
|
|
|
|
|
treeview_live_game_set_up_result();
|
|
|
|
|
|
|
|
model = treeview_live_game_create_result(unit);
|
|
|
|
|
|
|
|
gtk_tree_view_set_model(treeview, model);
|
|
|
|
g_object_unref(model);
|
|
|
|
}
|
2005-03-03 13:46:48 +01:00
|
|
|
|
|
|
|
/** Fill a tree model with the users. */
|
|
|
|
GtkTreeModel*
|
2005-03-27 19:59:57 +02:00
|
|
|
treeview_create_users(void)
|
2005-03-03 13:46:48 +01:00
|
|
|
{
|
|
|
|
gint i;
|
2005-04-29 21:48:02 +02:00
|
|
|
GtkListStore *ls;
|
2005-03-03 13:46:48 +01:00
|
|
|
GtkTreeIter iter;
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
ls = gtk_list_store_new(4,
|
|
|
|
G_TYPE_INT,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING);
|
2005-03-03 13:46:48 +01:00
|
|
|
for(i=0;i<users->len;i++)
|
|
|
|
{
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, i + 1,
|
2005-10-09 11:35:44 +02:00
|
|
|
1, usr(i).name,
|
|
|
|
2, usr(i).tm->name,
|
2005-03-03 13:46:48 +01:00
|
|
|
-1);
|
|
|
|
|
2005-06-11 18:54:59 +02:00
|
|
|
if(stat0 == STATUS_TEAM_SELECTION)
|
2005-03-03 13:46:48 +01:00
|
|
|
{
|
2005-06-11 18:54:59 +02:00
|
|
|
if(usr(i).scout == -1)
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 3,
|
2005-10-09 11:35:44 +02:00
|
|
|
league_cup_get_name_string(usr(i).tm->clid), -1);
|
2005-03-03 13:46:48 +01:00
|
|
|
else
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 3,
|
2005-10-09 11:35:44 +02:00
|
|
|
lig(usr(i).scout).name, -1);
|
2005-03-03 13:46:48 +01:00
|
|
|
}
|
|
|
|
else
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 3,
|
2005-10-09 11:35:44 +02:00
|
|
|
league_cup_get_name_string(usr(i).tm->clid), -1);
|
2005-03-03 13:46:48 +01:00
|
|
|
}
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
return GTK_TREE_MODEL(ls);
|
2005-03-03 13:46:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Set up the users treeview.
|
|
|
|
@param treeview The treeview we use. */
|
|
|
|
void
|
2005-03-27 19:59:57 +02:00
|
|
|
treeview_set_up_users(GtkTreeView *treeview)
|
2005-03-03 13:46:48 +01:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
GtkTreeViewColumn *col;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
gchar *titles[4] =
|
2005-03-08 09:25:46 +01:00
|
|
|
{"",
|
2005-03-03 13:46:48 +01:00
|
|
|
_("Name"),
|
|
|
|
_("Team"),
|
2005-03-27 19:59:57 +02:00
|
|
|
_("League")};
|
2005-03-03 13:46:48 +01:00
|
|
|
|
|
|
|
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview),
|
|
|
|
GTK_SELECTION_SINGLE);
|
2005-03-25 21:18:35 +01:00
|
|
|
gtk_tree_view_set_rules_hint(treeview, FALSE);
|
|
|
|
gtk_tree_view_set_headers_visible(treeview, TRUE);
|
2005-03-03 13:46:48 +01:00
|
|
|
|
|
|
|
for(i=0;i<4;i++)
|
|
|
|
{
|
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_column_set_title(col, titles[i]);
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
2005-04-16 09:46:04 +02:00
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
2005-03-27 19:59:57 +02:00
|
|
|
gtk_tree_view_column_pack_start(col, renderer, (i != 3));
|
2005-03-03 13:46:48 +01:00
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
|
|
|
"text", i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Show the list of users at startup.
|
|
|
|
@param treeview The treeview we use. */
|
|
|
|
void
|
2005-03-27 19:59:57 +02:00
|
|
|
treeview_show_users(GtkTreeView *treeview)
|
2005-03-03 13:46:48 +01:00
|
|
|
{
|
|
|
|
GtkTreeModel *model = NULL;
|
|
|
|
|
2005-04-16 09:46:04 +02:00
|
|
|
treeview_helper_clear(treeview);
|
2005-03-03 13:46:48 +01:00
|
|
|
|
2005-03-27 19:59:57 +02:00
|
|
|
treeview_set_up_users(treeview);
|
|
|
|
model = treeview_create_users();
|
2005-03-03 13:46:48 +01:00
|
|
|
gtk_tree_view_set_model(treeview, model);
|
|
|
|
g_object_unref(model);
|
|
|
|
}
|
2005-03-10 21:59:39 +01:00
|
|
|
|
|
|
|
/** Fill a model with live game stats.
|
|
|
|
@param live_game The live game. */
|
|
|
|
GtkTreeModel*
|
|
|
|
treeview_create_game_stats(LiveGame *live_game)
|
|
|
|
{
|
|
|
|
gint i, j, k;
|
|
|
|
LiveGameStats *stats = &live_game->stats;
|
2005-04-29 21:48:02 +02:00
|
|
|
GtkListStore *ls;
|
2005-03-10 21:59:39 +01:00
|
|
|
GtkTreeIter iter;
|
|
|
|
gchar buf[2][SMALL];
|
|
|
|
gchar buf3[SMALL];
|
|
|
|
gchar *categories[LIVE_GAME_STAT_VALUE_END] =
|
2005-06-26 13:42:01 +02:00
|
|
|
/* 'Normal' goals, ie. no penalties or free kicks. */
|
2005-04-09 21:18:28 +02:00
|
|
|
{_("Goals (regular)"),
|
2005-03-10 21:59:39 +01:00
|
|
|
_("Shots"),
|
|
|
|
_("Shot %"),
|
|
|
|
_("Possession"),
|
|
|
|
_("Penalties"),
|
|
|
|
_("Fouls"),
|
|
|
|
_("Yellows"),
|
|
|
|
_("Reds"),
|
|
|
|
_("Injuries")};
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
ls = gtk_list_store_new(3,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING);
|
2005-03-10 21:59:39 +01:00
|
|
|
|
2006-03-26 16:14:45 +02:00
|
|
|
if(live_game->fix != NULL)
|
|
|
|
fixture_result_to_buf(live_game->fix, buf[0], FALSE);
|
|
|
|
else
|
|
|
|
sprintf(
|
|
|
|
buf[0], "%d : %d",
|
|
|
|
g_array_index(live_game->units, LiveGameUnit, live_game->units->len - 1).
|
|
|
|
result[0],
|
|
|
|
g_array_index(live_game->units, LiveGameUnit, live_game->units->len - 1).
|
|
|
|
result[1]);
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
2006-03-26 16:14:45 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 0, live_game->team_names[0],
|
2005-03-10 21:59:39 +01:00
|
|
|
1, buf[0],
|
2006-03-26 17:12:55 +02:00
|
|
|
2, live_game->team_names[1],
|
2005-03-10 21:59:39 +01:00
|
|
|
-1);
|
|
|
|
|
|
|
|
for(k=0;k<LIVE_GAME_STAT_ARRAY_END;k++)
|
|
|
|
{
|
|
|
|
if(k == LIVE_GAME_STAT_ARRAY_SCORERS)
|
|
|
|
{
|
|
|
|
strcpy(buf[0], "");
|
|
|
|
strcpy(buf[1], "");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strcpy(buf[1], " </span>");
|
|
|
|
if(k == LIVE_GAME_STAT_ARRAY_INJURED)
|
|
|
|
sprintf(buf[0], "<span background='%s'> ",
|
2005-05-06 18:35:19 +02:00
|
|
|
const_app("string_treeview_helper_color_player_injury"));
|
2005-03-10 21:59:39 +01:00
|
|
|
else if(k == LIVE_GAME_STAT_ARRAY_REDS)
|
|
|
|
sprintf(buf[0], "<span background='%s'> ",
|
2005-05-06 18:35:19 +02:00
|
|
|
const_app("string_treeview_helper_color_player_banned"));
|
2005-03-10 21:59:39 +01:00
|
|
|
else if(k == LIVE_GAME_STAT_ARRAY_YELLOWS)
|
|
|
|
sprintf(buf[0], "<span background='%s'> ",
|
2005-05-06 18:35:19 +02:00
|
|
|
const_app("string_treeview_helper_color_player_yellow_danger"));
|
2005-03-10 21:59:39 +01:00
|
|
|
}
|
2005-03-11 13:17:48 +01:00
|
|
|
|
|
|
|
for(i=0;i<MAX(stats->players[0][k]->len,
|
|
|
|
stats->players[1][k]->len);i++)
|
2005-03-10 21:59:39 +01:00
|
|
|
{
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 1, "", -1);
|
2005-03-10 21:59:39 +01:00
|
|
|
for(j=0;j<2;j++)
|
|
|
|
{
|
2005-03-11 13:17:48 +01:00
|
|
|
if(i < stats->players[j][k]->len)
|
2005-03-10 21:59:39 +01:00
|
|
|
{
|
|
|
|
sprintf(buf3, "%s%s%s", buf[0],
|
2005-10-09 11:35:44 +02:00
|
|
|
(gchar*)g_ptr_array_index(stats->players[j][k], i),
|
2005-03-10 21:59:39 +01:00
|
|
|
buf[1]);
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_set(ls, &iter, j * 2, buf3, -1);
|
2005-03-10 21:59:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-26 16:14:45 +02:00
|
|
|
misc_print_grouped_int(live_game->attendance, buf[0]);
|
2005-05-26 18:54:22 +02:00
|
|
|
sprintf(buf[1], _("Attendance\n%s"), buf[0]);
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, buf[1], 1, "", 2, "", -1);
|
2005-03-16 21:48:25 +01:00
|
|
|
|
2005-03-19 21:04:08 +01:00
|
|
|
if(live_game->stadium_event != -1)
|
|
|
|
{
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
2005-03-19 21:04:08 +01:00
|
|
|
if(live_game->stadium_event == LIVE_GAME_EVENT_STADIUM_BREAKDOWN)
|
|
|
|
sprintf(buf[0], _("<span background='%s'>There were technical problems\nin the stadium.</span>"),
|
2005-05-06 18:35:19 +02:00
|
|
|
const_app("string_treeview_stadium_event_bg"));
|
2005-03-19 21:04:08 +01:00
|
|
|
else if(live_game->stadium_event == LIVE_GAME_EVENT_STADIUM_RIOTS)
|
|
|
|
sprintf(buf[0], _("<span background='%s'>There were riots\nin the stadium.</span>"),
|
2005-05-06 18:35:19 +02:00
|
|
|
const_app("string_treeview_stadium_event_bg"));
|
2005-03-19 21:04:08 +01:00
|
|
|
else
|
|
|
|
sprintf(buf[0], _("<span background='%s'>There was a fire\nin the stadium.</span>"),
|
2005-05-06 18:35:19 +02:00
|
|
|
const_app("string_treeview_stadium_event_bg"));
|
2005-03-19 21:04:08 +01:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 0, buf[0], 1, "", 2, "", -1);
|
2005-03-19 21:04:08 +01:00
|
|
|
}
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, "", 1, "", 2, "", -1);
|
2005-03-10 21:59:39 +01:00
|
|
|
|
|
|
|
for(i=0;i<LIVE_GAME_STAT_VALUE_END;i++)
|
|
|
|
{
|
2005-03-11 13:17:48 +01:00
|
|
|
if(i != LIVE_GAME_STAT_VALUE_POSSESSION)
|
|
|
|
for(j=0;j<2;j++)
|
|
|
|
sprintf(buf[j], "%d", stats->values[j][i]);
|
|
|
|
else
|
|
|
|
for(j=0;j<2;j++)
|
|
|
|
sprintf(buf[j], "%d", (gint)rint(100 * ((gfloat)stats->values[j][i] /
|
|
|
|
((gfloat)stats->values[0][i] +
|
|
|
|
(gfloat)stats->values[1][i]))));
|
2005-03-10 21:59:39 +01:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, buf[0],
|
2005-03-10 21:59:39 +01:00
|
|
|
1, categories[i],
|
|
|
|
2, buf[1], -1);
|
|
|
|
}
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
return GTK_TREE_MODEL(ls);
|
2005-03-10 21:59:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Configure a treeview to show game stats.
|
|
|
|
@param treeview The treeview. */
|
|
|
|
void
|
|
|
|
treeview_set_up_game_stats(GtkTreeView *treeview)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
GtkTreeViewColumn *col;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
|
|
|
|
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview),
|
|
|
|
GTK_SELECTION_NONE);
|
2005-03-25 21:18:35 +01:00
|
|
|
gtk_tree_view_set_rules_hint(treeview, FALSE);
|
|
|
|
gtk_tree_view_set_headers_visible(treeview, FALSE);
|
2005-03-10 21:59:39 +01:00
|
|
|
|
|
|
|
for(i=0;i<3;i++)
|
|
|
|
{
|
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
2005-04-16 09:46:04 +02:00
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
2005-03-10 21:59:39 +01:00
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
|
|
|
"markup", i);
|
|
|
|
|
|
|
|
g_object_set(renderer, "xalign", 0 + (2 - i) * 0.5,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Show the stats of the live game in a treeview.
|
|
|
|
@param live_game The live game. */
|
|
|
|
void
|
|
|
|
treeview_show_game_stats(GtkTreeView *treeview, LiveGame *live_game)
|
|
|
|
{
|
|
|
|
GtkTreeModel *model = NULL;
|
|
|
|
|
2005-04-16 09:46:04 +02:00
|
|
|
treeview_helper_clear(treeview);
|
2005-03-10 21:59:39 +01:00
|
|
|
|
|
|
|
treeview_set_up_game_stats(treeview);
|
|
|
|
model = treeview_create_game_stats(live_game);
|
|
|
|
gtk_tree_view_set_model(treeview, model);
|
|
|
|
g_object_unref(model);
|
|
|
|
}
|
2005-03-14 18:47:27 +01:00
|
|
|
|
|
|
|
/** Write some general information like cup/league name,
|
2005-04-29 21:48:02 +02:00
|
|
|
week etc. into a ls.
|
2005-03-14 18:47:27 +01:00
|
|
|
@param fix A 'sample' fixture.
|
2005-04-29 21:48:02 +02:00
|
|
|
@param ls The ls we edit.
|
2005-03-27 19:59:57 +02:00
|
|
|
@param blank_line Whether to draw a blank line after the header. */
|
2005-03-14 18:47:27 +01:00
|
|
|
void
|
2005-04-29 21:48:02 +02:00
|
|
|
treeview_create_fixtures_header(const Fixture *fix, GtkListStore *ls, gboolean blank_line)
|
2005-03-14 18:47:27 +01:00
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gchar buf[SMALL], buf2[SMALL], buf3[SMALL],
|
|
|
|
round_name[SMALL];
|
|
|
|
gchar *name = NULL;
|
2005-04-29 21:48:02 +02:00
|
|
|
gchar *symbol = NULL;
|
2005-03-14 18:47:27 +01:00
|
|
|
|
|
|
|
sprintf(buf3, _("Week %d Round %d"), fix->week_number, fix->week_round_number);
|
|
|
|
|
|
|
|
if(fix->clid < ID_CUP_START)
|
|
|
|
{
|
2005-10-09 11:35:44 +02:00
|
|
|
name = league_cup_get_name_string(fix->clid);
|
2005-03-14 18:47:27 +01:00
|
|
|
strcpy(round_name, "");
|
2005-10-09 11:35:44 +02:00
|
|
|
symbol = league_from_clid(fix->clid)->symbol;
|
2005-03-14 18:47:27 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-10-09 11:35:44 +02:00
|
|
|
name = cup_from_clid(fix->clid)->name;
|
2005-03-14 18:47:27 +01:00
|
|
|
cup_round_name(fix, buf);
|
|
|
|
sprintf(round_name, "\n%s", buf);
|
|
|
|
strcat(buf3, "\n");
|
2005-10-09 11:35:44 +02:00
|
|
|
symbol = cup_from_clid(fix->clid)->symbol;
|
2005-03-14 18:47:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(buf, "<span background='%s' foreground='%s'>%s%s</span>",
|
2005-05-06 18:35:19 +02:00
|
|
|
const_app("string_treeview_fixture_header_bg"),
|
|
|
|
const_app("string_treeview_fixture_header_fg"),
|
2005-03-14 18:47:27 +01:00
|
|
|
name, round_name);
|
2005-03-16 21:48:25 +01:00
|
|
|
sprintf(buf2, "<span background='%s' foreground='%s'>%s</span>",
|
2005-05-06 18:35:19 +02:00
|
|
|
const_app("string_treeview_fixture_header_bg"),
|
|
|
|
const_app("string_treeview_fixture_header_fg"), buf3);
|
2005-03-14 18:47:27 +01:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
treeview_helper_insert_icon(ls, &iter, 0, symbol);
|
|
|
|
treeview_helper_insert_icon(ls, &iter, 4, symbol);
|
|
|
|
gtk_list_store_set(ls, &iter, 1, buf, 2, "", 3, buf2, -1);
|
2005-03-14 18:47:27 +01:00
|
|
|
|
2005-03-27 19:59:57 +02:00
|
|
|
if(blank_line)
|
|
|
|
{
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, NULL, 1, "", 2, "", 3, "", 4, NULL, -1);
|
2005-03-27 19:59:57 +02:00
|
|
|
}
|
2005-03-14 18:47:27 +01:00
|
|
|
}
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
/** Display a fixture in a ls. */
|
2005-03-14 18:47:27 +01:00
|
|
|
void
|
2005-04-29 21:48:02 +02:00
|
|
|
treeview_create_fixture(const Fixture *fix, GtkListStore *ls)
|
2005-03-14 18:47:27 +01:00
|
|
|
{
|
2005-04-22 17:17:39 +02:00
|
|
|
gint i, rank;
|
2005-03-14 18:47:27 +01:00
|
|
|
GtkTreeIter iter;
|
2005-04-29 21:48:02 +02:00
|
|
|
gchar *symbol[2] = {NULL, NULL};
|
2005-03-14 18:47:27 +01:00
|
|
|
gchar buf_result[SMALL], buf[3][SMALL];
|
|
|
|
gchar *colour_fg = NULL, *colour_bg = NULL;
|
2005-12-01 12:50:54 +01:00
|
|
|
gint user_idx = fixture_user_team_involved(fix);
|
2005-03-14 18:47:27 +01:00
|
|
|
|
|
|
|
if(fix->clid >= ID_CUP_START &&
|
2005-05-06 18:35:19 +02:00
|
|
|
query_cup_is_international(fix->clid))
|
2005-03-14 18:47:27 +01:00
|
|
|
for(i=0;i<2;i++)
|
2005-10-09 11:35:44 +02:00
|
|
|
symbol[i] = fix->teams[i]->symbol;
|
2005-03-14 18:47:27 +01:00
|
|
|
|
2005-12-01 12:50:54 +01:00
|
|
|
if(user_idx != -1)
|
|
|
|
treeview_helper_set_user_colours(usr(user_idx).tm->name,
|
2005-04-29 21:48:02 +02:00
|
|
|
&colour_bg, &colour_fg);
|
2005-03-14 18:47:27 +01:00
|
|
|
else
|
|
|
|
{
|
2005-05-06 18:35:19 +02:00
|
|
|
colour_fg = const_app("string_treeview_helper_color_default_foreground");
|
|
|
|
colour_bg = const_app("string_treeview_helper_color_default_background");
|
2005-04-29 21:48:02 +02:00
|
|
|
}
|
2005-03-14 18:47:27 +01:00
|
|
|
|
2005-10-04 16:47:15 +02:00
|
|
|
fixture_result_to_buf(fix, buf_result, FALSE);
|
2005-03-14 18:47:27 +01:00
|
|
|
|
|
|
|
for(i=0;i<2;i++)
|
2005-04-22 17:17:39 +02:00
|
|
|
if(query_fixture_has_tables(fix))
|
|
|
|
{
|
|
|
|
if(fix->clid < ID_CUP_START)
|
|
|
|
rank = team_get_league_rank(fix->teams[i]);
|
|
|
|
else
|
2005-09-21 19:42:41 +02:00
|
|
|
rank = team_get_cup_rank(fix->teams[i],
|
2005-09-22 18:41:07 +02:00
|
|
|
cup_get_last_tables_round(fix->clid), TRUE);
|
2005-04-22 17:17:39 +02:00
|
|
|
|
2005-03-14 18:47:27 +01:00
|
|
|
sprintf(buf[i], "<span background='%s' foreground='%s'>%s [%d]</span>",
|
2005-10-09 11:35:44 +02:00
|
|
|
colour_bg, colour_fg, fix->teams[i]->name, rank);
|
2005-04-22 17:17:39 +02:00
|
|
|
}
|
2005-03-14 18:47:27 +01:00
|
|
|
else if(fix->clid >= ID_CUP_START &&
|
2005-05-06 18:35:19 +02:00
|
|
|
query_cup_is_national(fix->clid))
|
2005-03-14 18:47:27 +01:00
|
|
|
sprintf(buf[i], "<span background='%s' foreground='%s'>%s (%d)</span>",
|
2005-10-09 11:35:44 +02:00
|
|
|
colour_bg, colour_fg, fix->teams[i]->name,
|
2005-05-24 20:31:07 +02:00
|
|
|
league_from_clid(fix->teams[i]->clid)->layer);
|
2005-03-14 18:47:27 +01:00
|
|
|
else
|
|
|
|
sprintf(buf[i], "<span background='%s' foreground='%s'>%s</span>",
|
2005-10-09 11:35:44 +02:00
|
|
|
colour_bg, colour_fg, fix->teams[i]->name);
|
2005-03-14 18:47:27 +01:00
|
|
|
|
|
|
|
sprintf(buf[2], "<span background='%s' foreground='%s'>%s</span>",
|
|
|
|
colour_bg, colour_fg, buf_result);
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
treeview_helper_insert_icon(ls, &iter, 0, symbol[0]);
|
|
|
|
treeview_helper_insert_icon(ls, &iter, 4, symbol[1]);
|
|
|
|
gtk_list_store_set(ls, &iter,
|
|
|
|
1, buf[0], 2, buf[2], 3, buf[1], -1);
|
2005-03-14 18:47:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkTreeModel*
|
|
|
|
treeview_create_fixtures(gint clid, gint week_number, gint week_round_number)
|
|
|
|
{
|
|
|
|
gint i;
|
2005-04-29 21:48:02 +02:00
|
|
|
GtkListStore *ls;
|
2005-04-15 15:55:59 +02:00
|
|
|
GPtrArray *fixtures = fixture_get_week_list_clid(clid, week_number, week_round_number);
|
2005-03-14 18:47:27 +01:00
|
|
|
|
|
|
|
if(fixtures->len == 0)
|
|
|
|
{
|
|
|
|
free_g_ptr_array(&fixtures);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
ls = gtk_list_store_new(5,
|
|
|
|
GDK_TYPE_PIXBUF,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
GDK_TYPE_PIXBUF);
|
2005-03-14 18:47:27 +01:00
|
|
|
|
|
|
|
treeview_create_fixtures_header((Fixture*)g_ptr_array_index(fixtures, 0),
|
2005-04-29 21:48:02 +02:00
|
|
|
ls, TRUE);
|
2005-03-14 18:47:27 +01:00
|
|
|
|
|
|
|
for(i=0;i<fixtures->len;i++)
|
2005-04-29 21:48:02 +02:00
|
|
|
treeview_create_fixture((Fixture*)g_ptr_array_index(fixtures, i), ls);
|
2005-03-14 18:47:27 +01:00
|
|
|
|
2005-03-27 19:59:57 +02:00
|
|
|
g_ptr_array_free(fixtures, TRUE);
|
2005-03-14 18:47:27 +01:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
return GTK_TREE_MODEL(ls);
|
2005-03-14 18:47:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
treeview_set_up_fixtures(GtkTreeView *treeview)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
GtkTreeViewColumn *col;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
|
|
|
|
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview),
|
|
|
|
GTK_SELECTION_NONE);
|
2005-03-27 19:59:57 +02:00
|
|
|
gtk_tree_view_set_rules_hint(treeview, FALSE);
|
2005-03-25 21:18:35 +01:00
|
|
|
gtk_tree_view_set_headers_visible(treeview, FALSE);
|
|
|
|
|
2005-03-14 18:47:27 +01:00
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
|
|
|
renderer = gtk_cell_renderer_pixbuf_new();
|
2005-03-15 16:10:57 +01:00
|
|
|
g_object_set(renderer, "cell-background",
|
2005-05-06 18:35:19 +02:00
|
|
|
const_app("string_treeview_symbol_bg"), NULL);
|
2005-03-14 18:47:27 +01:00
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
|
|
|
"pixbuf", 0);
|
|
|
|
|
|
|
|
for(i=0;i<3;i++)
|
|
|
|
{
|
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
2005-04-16 09:46:04 +02:00
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
2005-03-14 18:47:27 +01:00
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
|
|
|
"markup", i + 1);
|
|
|
|
|
|
|
|
g_object_set(renderer, "xalign", 0 + (2 - i) * 0.5,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
|
|
|
renderer = gtk_cell_renderer_pixbuf_new();
|
2005-03-15 16:10:57 +01:00
|
|
|
g_object_set(renderer, "cell-background",
|
2005-05-06 18:35:19 +02:00
|
|
|
const_app("string_treeview_symbol_bg"), NULL);
|
2005-03-15 16:10:57 +01:00
|
|
|
gtk_tree_view_column_pack_start(col, renderer, FALSE);
|
2005-03-14 18:47:27 +01:00
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
|
|
|
"pixbuf", 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Show some fixtures in a treeview.
|
|
|
|
@param treeview The treeview we use.
|
|
|
|
@param clid The cup / league id.
|
|
|
|
@param week_number The week number of the fixtures.
|
|
|
|
@param week_round_number The week round. */
|
|
|
|
void
|
|
|
|
treeview_show_fixtures(GtkTreeView *treeview, gint clid,
|
|
|
|
gint week_number, gint week_round_number)
|
|
|
|
{
|
|
|
|
GtkTreeModel *model = NULL;
|
|
|
|
|
2005-04-16 09:46:04 +02:00
|
|
|
treeview_helper_clear(treeview);
|
2005-03-14 18:47:27 +01:00
|
|
|
|
|
|
|
treeview_set_up_fixtures(treeview);
|
|
|
|
model = treeview_create_fixtures(clid, week_number, week_round_number);
|
|
|
|
gtk_tree_view_set_model(treeview, model);
|
|
|
|
g_object_unref(model);
|
|
|
|
}
|
2005-03-15 16:10:57 +01:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
/** Write the header for a table into the ls
|
2005-03-15 16:10:57 +01:00
|
|
|
@param clid The cup or league id.
|
|
|
|
@param number The number of the table if we display more than one. */
|
|
|
|
void
|
2005-05-25 18:58:31 +02:00
|
|
|
treeview_table_write_header(GtkListStore *ls, const Table *table, gint number)
|
2005-03-15 16:10:57 +01:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
gchar buf[SMALL];
|
2005-04-29 21:48:02 +02:00
|
|
|
gchar *symbol = NULL;
|
2005-03-15 16:10:57 +01:00
|
|
|
GtkTreeIter iter;
|
|
|
|
|
2005-05-25 18:58:31 +02:00
|
|
|
if(table->clid < ID_CUP_START)
|
2005-03-15 16:10:57 +01:00
|
|
|
{
|
2005-10-09 11:35:44 +02:00
|
|
|
symbol = league_from_clid(table->clid)->symbol;
|
|
|
|
strcpy(buf, league_cup_get_name_string(table->clid));
|
2005-03-15 16:10:57 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-10-09 11:35:44 +02:00
|
|
|
symbol = cup_from_clid(table->clid)->symbol;
|
2005-05-25 18:58:31 +02:00
|
|
|
if(g_array_index(cup_from_clid(table->clid)->rounds, CupRound,
|
|
|
|
table->round).tables->len > 1)
|
2005-06-26 13:42:01 +02:00
|
|
|
/* A group of a round robin stage of a cup. */
|
2005-10-09 11:35:44 +02:00
|
|
|
sprintf(buf, _("%s Group %d"), cup_from_clid(table->clid)->name, number);
|
2005-05-25 18:58:31 +02:00
|
|
|
else
|
2005-10-09 11:35:44 +02:00
|
|
|
sprintf(buf, "%s", cup_from_clid(table->clid)->name);
|
2005-03-15 16:10:57 +01:00
|
|
|
}
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
treeview_helper_insert_icon(ls, &iter, 0, symbol);
|
2005-05-02 16:39:30 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 1, "", 2, NULL, 3, buf, -1);
|
2005-03-15 16:10:57 +01:00
|
|
|
|
2005-05-02 16:39:30 +02:00
|
|
|
for(i=4;i<12;i++)
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_set(ls, &iter, i, "", -1);
|
2005-03-15 16:10:57 +01:00
|
|
|
}
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
/** Display a table in the ls.
|
2005-03-15 16:10:57 +01:00
|
|
|
@param number The number of the table if we display more than one
|
|
|
|
(cups, round robin); or -1 for leagues. */
|
|
|
|
void
|
2005-04-29 21:48:02 +02:00
|
|
|
treeview_create_single_table(GtkListStore *ls, const Table *table, gint number)
|
2005-03-15 16:10:57 +01:00
|
|
|
{
|
|
|
|
gint i, j;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
TableElement *elem = NULL;
|
|
|
|
gchar buf[10][SMALL];
|
2005-05-28 16:34:14 +02:00
|
|
|
gchar *colour_bg = NULL, *colour_fg = NULL;
|
2005-03-15 16:10:57 +01:00
|
|
|
|
2005-05-25 18:58:31 +02:00
|
|
|
treeview_table_write_header(ls, table, number);
|
2005-03-15 16:10:57 +01:00
|
|
|
|
|
|
|
for(i=0;i<table->elements->len;i++)
|
|
|
|
{
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
2005-03-15 16:10:57 +01:00
|
|
|
|
|
|
|
elem = &g_array_index(table->elements, TableElement, i);
|
2005-04-22 17:17:39 +02:00
|
|
|
|
2005-03-15 16:10:57 +01:00
|
|
|
if(table->clid >= ID_CUP_START)
|
2005-10-09 11:35:44 +02:00
|
|
|
treeview_helper_insert_icon(ls, &iter, 0, elem->team->symbol);
|
2005-05-02 16:39:30 +02:00
|
|
|
|
|
|
|
if(elem->old_rank > i)
|
|
|
|
treeview_helper_insert_icon(ls, &iter, 2,
|
2005-05-06 18:35:19 +02:00
|
|
|
const_app("string_treeview_table_up_icon"));
|
2005-05-02 16:39:30 +02:00
|
|
|
else if(elem->old_rank < i)
|
|
|
|
treeview_helper_insert_icon(ls, &iter, 2,
|
2005-05-06 18:35:19 +02:00
|
|
|
const_app("string_treeview_table_down_icon"));
|
2005-05-02 16:39:30 +02:00
|
|
|
else
|
|
|
|
treeview_helper_insert_icon(ls, &iter, 2,
|
2005-05-06 18:35:19 +02:00
|
|
|
const_app("string_treeview_table_stay_icon"));
|
2005-03-15 16:10:57 +01:00
|
|
|
|
2005-09-21 19:42:41 +02:00
|
|
|
treeview_helper_get_table_element_colours(table, i,
|
|
|
|
&colour_fg, &colour_bg, FALSE);
|
2005-03-23 20:03:26 +01:00
|
|
|
sprintf(buf[0], "<span background='%s' foreground='%s'>%d</span>",
|
2005-03-15 16:10:57 +01:00
|
|
|
colour_bg, colour_fg, i + 1);
|
|
|
|
|
2005-05-28 16:34:14 +02:00
|
|
|
treeview_helper_get_table_element_colours(table, i, &colour_fg, &colour_bg, TRUE);
|
2005-10-24 22:50:48 +02:00
|
|
|
if(debug < 50)
|
|
|
|
sprintf(buf[1], "<span background='%s' foreground='%s'>%s</span>",
|
|
|
|
colour_bg, colour_fg, elem->team->name);
|
|
|
|
else
|
|
|
|
sprintf(buf[1], "<span background='%s' foreground='%s'>%s (%s)</span>",
|
|
|
|
colour_bg, colour_fg, elem->team->name, elem->team->strategy_sid);
|
2005-03-15 16:10:57 +01:00
|
|
|
|
2005-05-02 16:39:30 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 1, buf[0], 3, buf[1], -1);
|
|
|
|
|
2005-03-15 16:10:57 +01:00
|
|
|
for(j=2;j<10;j++)
|
|
|
|
if(j - 2 != TABLE_GD)
|
|
|
|
sprintf(buf[j], "%d", elem->values[j - 2]);
|
|
|
|
else
|
|
|
|
sprintf(buf[j], "%+d", elem->values[j - 2]);
|
|
|
|
|
2005-05-02 16:39:30 +02:00
|
|
|
for(j=2;j<10;j++)
|
|
|
|
gtk_list_store_set(ls, &iter, j + 2, buf[j], -1);
|
2005-03-15 16:10:57 +01:00
|
|
|
}
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
2005-05-02 16:39:30 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 0, NULL, 1, "", 2, NULL, -1);
|
|
|
|
for(j=3;j<11;j++)
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_set(ls, &iter, j, "", -1);
|
2005-03-15 16:10:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Create a league table or one or more cup tables. */
|
|
|
|
GtkTreeModel*
|
|
|
|
treeview_create_table(gint clid)
|
|
|
|
{
|
|
|
|
gint i;
|
2005-04-29 21:48:02 +02:00
|
|
|
GtkListStore *ls =
|
2005-05-02 16:39:30 +02:00
|
|
|
gtk_list_store_new(12,
|
2005-03-15 16:10:57 +01:00
|
|
|
GDK_TYPE_PIXBUF,
|
|
|
|
G_TYPE_STRING,
|
2005-05-02 16:39:30 +02:00
|
|
|
GDK_TYPE_PIXBUF,
|
2005-03-15 16:10:57 +01:00
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING);
|
2005-04-22 17:17:39 +02:00
|
|
|
|
2005-03-15 16:10:57 +01:00
|
|
|
if(clid < ID_CUP_START)
|
2005-04-29 21:48:02 +02:00
|
|
|
treeview_create_single_table(ls,
|
2005-03-15 16:10:57 +01:00
|
|
|
&league_from_clid(clid)->table, -1);
|
|
|
|
else
|
|
|
|
{
|
2005-04-22 17:17:39 +02:00
|
|
|
for(i=0;i<cup_get_last_tables(clid)->len;i++)
|
2005-04-29 21:48:02 +02:00
|
|
|
treeview_create_single_table(ls,
|
2005-04-22 17:17:39 +02:00
|
|
|
&g_array_index(cup_get_last_tables(clid), Table, i), i + 1);
|
2005-03-15 16:10:57 +01:00
|
|
|
}
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
return GTK_TREE_MODEL(ls);
|
2005-03-15 16:10:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
treeview_set_up_table(GtkTreeView *treeview)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
GtkTreeViewColumn *col;
|
|
|
|
GtkCellRenderer *renderer;
|
2005-05-02 16:39:30 +02:00
|
|
|
gchar *titles[9] =
|
|
|
|
{_("Team"),
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Games played (a number). */
|
2005-03-15 16:10:57 +01:00
|
|
|
_("PL"),
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Games won. */
|
2005-03-15 16:10:57 +01:00
|
|
|
_("W"),
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Games drawn. */
|
2005-05-26 18:54:22 +02:00
|
|
|
_("Dw"),
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Games lost. */
|
2005-03-15 16:10:57 +01:00
|
|
|
_("L"),
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Goals for. */
|
2005-03-15 16:10:57 +01:00
|
|
|
_("GF"),
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Goals against. */
|
2005-03-15 16:10:57 +01:00
|
|
|
_("GA"),
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Goal difference. */
|
2005-03-15 16:10:57 +01:00
|
|
|
_("GD"),
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Points. */
|
2005-03-15 16:10:57 +01:00
|
|
|
_("PTS")};
|
|
|
|
|
|
|
|
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview),
|
|
|
|
GTK_SELECTION_NONE);
|
2005-03-25 21:18:35 +01:00
|
|
|
gtk_tree_view_set_rules_hint(treeview, FALSE);
|
|
|
|
gtk_tree_view_set_headers_visible(treeview, TRUE);
|
|
|
|
|
2005-03-15 16:10:57 +01:00
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
|
|
|
renderer = gtk_cell_renderer_pixbuf_new();
|
|
|
|
g_object_set(renderer, "cell-background",
|
2005-05-06 18:35:19 +02:00
|
|
|
const_app("string_treeview_symbol_bg"), NULL);
|
2005-03-15 16:10:57 +01:00
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
|
|
|
"pixbuf", 0);
|
|
|
|
|
2005-05-02 16:39:30 +02:00
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_column_set_title(col, "");
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
|
|
|
gtk_tree_view_column_pack_start(col, renderer, FALSE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
|
|
|
"markup", 1);
|
|
|
|
g_object_set(renderer, "xalign", 0.5, NULL);
|
|
|
|
|
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
|
|
|
renderer = gtk_cell_renderer_pixbuf_new();
|
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
|
|
|
"pixbuf", 2);
|
|
|
|
|
|
|
|
for(i=0;i<9;i++)
|
2005-03-15 16:10:57 +01:00
|
|
|
{
|
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_column_set_title(col, titles[i]);
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
2005-04-16 09:46:04 +02:00
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
2005-03-15 16:10:57 +01:00
|
|
|
gtk_tree_view_column_pack_start(col, renderer, FALSE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
2005-05-02 16:39:30 +02:00
|
|
|
"markup", i + 3);
|
|
|
|
g_object_set(renderer, "xalign", 0.5 - (0.5 * (i == 0)), NULL);
|
2005-03-15 16:10:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Show the table going with a league or cup. */
|
|
|
|
void
|
|
|
|
treeview_show_table(GtkTreeView *treeview, gint clid)
|
|
|
|
{
|
|
|
|
GtkTreeModel *model = NULL;
|
|
|
|
|
2005-04-16 09:46:04 +02:00
|
|
|
treeview_helper_clear(treeview);
|
2005-03-15 16:10:57 +01:00
|
|
|
|
|
|
|
treeview_set_up_table(treeview);
|
|
|
|
model = treeview_create_table(clid);
|
|
|
|
gtk_tree_view_set_model(treeview, model);
|
|
|
|
g_object_unref(model);
|
|
|
|
}
|
2005-03-16 21:48:25 +01:00
|
|
|
|
2005-04-09 21:18:28 +02:00
|
|
|
/** Print some quick info about the stadium in the finances view. */
|
|
|
|
void
|
2005-04-29 21:48:02 +02:00
|
|
|
treeview_create_stadium_summary(GtkListStore *ls)
|
2005-04-09 21:18:28 +02:00
|
|
|
{
|
|
|
|
gchar buf[SMALL];
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
2005-06-21 15:33:16 +02:00
|
|
|
if(current_user.tm->stadium.name != NULL)
|
|
|
|
{
|
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, _("Stadium"),
|
2005-10-09 11:35:44 +02:00
|
|
|
1, current_user.tm->stadium.name, 2, "", -1);
|
2005-06-21 15:33:16 +02:00
|
|
|
}
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
2005-07-01 22:51:46 +02:00
|
|
|
misc_print_grouped_int(current_user.tm->stadium.capacity, buf);
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 0, _("Stadium capacity"), 1, buf, 2, "", -1);
|
2005-04-09 21:18:28 +02:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
2005-04-10 18:34:27 +02:00
|
|
|
sprintf(buf, "%.0f%%", current_user.tm->stadium.safety * 100);
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 0, _("Stadium safety"), 1, buf, 2, "", -1);
|
2005-04-09 21:18:28 +02:00
|
|
|
|
|
|
|
if(current_user.counters[COUNT_USER_STADIUM_CAPACITY] +
|
|
|
|
current_user.counters[COUNT_USER_STADIUM_SAFETY] != 0)
|
|
|
|
{
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
2005-04-09 21:18:28 +02:00
|
|
|
sprintf(buf, _("Improvement in progress.\n%d seats and %d%% safety still to be done.\nExpected finish: %d weeks."),
|
|
|
|
current_user.counters[COUNT_USER_STADIUM_CAPACITY],
|
|
|
|
current_user.counters[COUNT_USER_STADIUM_SAFETY],
|
|
|
|
MAX(finance_get_stadium_improvement_duration(
|
|
|
|
(gfloat)current_user.counters[COUNT_USER_STADIUM_CAPACITY], TRUE),
|
|
|
|
finance_get_stadium_improvement_duration(
|
|
|
|
(gfloat)current_user.counters[COUNT_USER_STADIUM_SAFETY] / 100, FALSE)));
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 0, _("Stadium status"), 1, buf, 2, "", -1);
|
2005-04-09 21:18:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-16 21:48:25 +01:00
|
|
|
GtkTreeModel*
|
|
|
|
treeview_create_finances(const User* user)
|
|
|
|
{
|
|
|
|
gint i, balance = 0;
|
|
|
|
gchar buf[SMALL], buf2[SMALL], buf3[SMALL];
|
|
|
|
gint *in = user->money_in[0],
|
|
|
|
*out = user->money_out[0];
|
|
|
|
gchar *in_titles[MON_IN_TRANSFERS] =
|
|
|
|
{_("Prize money"),
|
2005-06-20 14:46:57 +02:00
|
|
|
_("Ticket income"),
|
2005-10-27 23:10:15 +02:00
|
|
|
_("Sponsorship"),
|
|
|
|
_("Betting")};
|
2005-03-16 21:48:25 +01:00
|
|
|
gchar *out_titles[MON_OUT_TRANSFERS] =
|
|
|
|
{_("Wages"),
|
|
|
|
_("Physio"),
|
|
|
|
_("Scout"),
|
2005-07-08 11:26:00 +02:00
|
|
|
_("Youth coach"),
|
|
|
|
_("Youth academy"),
|
2005-03-16 21:48:25 +01:00
|
|
|
_("Journey costs"),
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Money paid to players a user fired. */
|
2005-10-27 23:10:15 +02:00
|
|
|
_("Compensations"),
|
2005-11-01 22:20:24 +01:00
|
|
|
_("Betting"),
|
|
|
|
/* Applying boost costs money. */
|
|
|
|
_("Boost costs")};
|
2005-06-22 18:06:08 +02:00
|
|
|
|
2005-03-16 21:48:25 +01:00
|
|
|
GtkTreeIter iter;
|
2005-04-29 21:48:02 +02:00
|
|
|
GtkListStore *ls =
|
2005-03-16 21:48:25 +01:00
|
|
|
gtk_list_store_new(3,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING);
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Finances balance. */
|
2005-11-28 17:27:16 +01:00
|
|
|
if(week > 2)
|
|
|
|
{
|
|
|
|
if(week % 2 == 1)
|
|
|
|
sprintf(buf, _("Bi-weekly balance\n(Week %d and %d)"),
|
|
|
|
week - 2, week - 1);
|
|
|
|
else
|
|
|
|
sprintf(buf, _("Bi-weekly balance\n(Week %d and %d)"),
|
|
|
|
week - 3, week - 2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
strcpy(buf, _("Bi-weekly balance"));
|
|
|
|
|
|
|
|
gtk_list_store_set(ls, &iter, 0, buf, 1, "", 2, "", -1);
|
2005-03-16 21:48:25 +01:00
|
|
|
|
|
|
|
for(i=0;i<MON_IN_TRANSFERS;i++)
|
|
|
|
if(in[i] != 0)
|
|
|
|
{
|
2005-07-01 22:51:46 +02:00
|
|
|
misc_print_grouped_int(in[i], buf);
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, in_titles[i], 1, buf, 2, "", -1);
|
2005-03-16 21:48:25 +01:00
|
|
|
balance += in[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=0;i<MON_OUT_TRANSFERS;i++)
|
|
|
|
if(out[i] != 0)
|
|
|
|
{
|
2005-07-01 22:51:46 +02:00
|
|
|
misc_print_grouped_int(out[i], buf3);
|
2005-03-16 21:48:25 +01:00
|
|
|
sprintf(buf, "<span foreground='%s'>%s</span>",
|
2005-05-06 18:35:19 +02:00
|
|
|
const_app("string_treeview_finances_expenses_fg"), buf3);
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, out_titles[i], 1, "", 2, buf, -1);
|
2005-03-16 21:48:25 +01:00
|
|
|
balance += out[i];
|
|
|
|
}
|
|
|
|
|
2005-07-01 22:51:46 +02:00
|
|
|
misc_print_grouped_int(balance, buf);
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Finances balance. */
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 0, _("Balance"), 1, "", 2, "", -1);
|
2005-03-16 21:48:25 +01:00
|
|
|
if(balance >= 0)
|
|
|
|
strcpy(buf2, buf);
|
|
|
|
else
|
|
|
|
sprintf(buf2, "<span foreground='%s'>%s</span>",
|
2005-05-06 18:35:19 +02:00
|
|
|
const_app("string_treeview_finances_expenses_fg"), buf);
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 1 + (balance < 0), buf2, -1);
|
2005-03-16 21:48:25 +01:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, "", 1, "", 2, "", -1);
|
2005-03-16 21:48:25 +01:00
|
|
|
|
2005-06-22 18:06:08 +02:00
|
|
|
if(in[MON_IN_TRANSFERS] != 0 || out[MON_OUT_TRANSFERS] != 0)
|
|
|
|
{
|
2005-07-01 22:51:46 +02:00
|
|
|
misc_print_grouped_int(in[MON_IN_TRANSFERS], buf);
|
|
|
|
misc_print_grouped_int(out[MON_OUT_TRANSFERS], buf3);
|
2005-06-22 18:06:08 +02:00
|
|
|
sprintf(buf2, "<span foreground='%s'>%s</span>",
|
|
|
|
const_app("string_treeview_finances_expenses_fg"), buf3);
|
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, _("Transfers"), 1, buf, 2, buf2, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(out[MON_OUT_STADIUM_IMPROVEMENT] + out[MON_OUT_STADIUM_BILLS] != 0)
|
|
|
|
{
|
|
|
|
misc_print_grouped_int(out[MON_OUT_STADIUM_IMPROVEMENT] + out[MON_OUT_STADIUM_BILLS],
|
2005-07-01 22:51:46 +02:00
|
|
|
buf);
|
2005-06-22 18:06:08 +02:00
|
|
|
sprintf(buf2, "<span foreground='%s'>%s</span>",
|
|
|
|
const_app("string_treeview_finances_expenses_fg"), buf);
|
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, _("Stadium expenses"), 1, "", 2, buf2, -1);
|
|
|
|
}
|
2007-01-18 18:38:14 +01:00
|
|
|
|
|
|
|
if(out[MON_OUT_TRAINING_CAMP] != 0)
|
|
|
|
{
|
|
|
|
misc_print_grouped_int(out[MON_OUT_TRAINING_CAMP], buf);
|
|
|
|
sprintf(buf2, "<span foreground='%s'>%s</span>", const_app("string_treeview_finances_expenses_fg"), buf);
|
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, _("Training camp"), 1, "", 2, buf2, -1);
|
|
|
|
}
|
2005-06-22 18:06:08 +02:00
|
|
|
|
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, "", 1, "", 2, "", -1);
|
|
|
|
|
2005-07-01 22:51:46 +02:00
|
|
|
misc_print_grouped_int(user->money, buf);
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
2005-03-16 21:48:25 +01:00
|
|
|
if(user->money >= 0)
|
|
|
|
strcpy(buf2, buf);
|
|
|
|
else
|
|
|
|
sprintf(buf2, "<span foreground='%s'>%s</span>",
|
2005-05-06 18:35:19 +02:00
|
|
|
const_app("string_treeview_finances_expenses_fg"), buf);
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 0, _("Money"), 1, buf2, 2, "", -1);
|
2005-03-16 21:48:25 +01:00
|
|
|
|
2005-07-01 22:51:46 +02:00
|
|
|
misc_print_grouped_int(finance_team_drawing_credit_loan(user->tm, FALSE), buf);
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, _("Drawing credit"), 1, buf, 2, "", -1);
|
2005-03-16 21:48:25 +01:00
|
|
|
|
|
|
|
if(user->debt != 0)
|
|
|
|
{
|
2005-07-01 22:51:46 +02:00
|
|
|
misc_print_grouped_int(user->debt, buf);
|
2005-03-16 21:48:25 +01:00
|
|
|
sprintf(buf2, "<span foreground='%s'>%s</span>",
|
2005-05-06 18:35:19 +02:00
|
|
|
const_app("string_treeview_finances_expenses_fg"), buf);
|
2005-03-17 21:26:01 +01:00
|
|
|
sprintf(buf, _("Debt (repay in %d weeks)"), user->counters[COUNT_USER_LOAN]);
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, buf, 1, "", 2, buf2, -1);
|
2005-03-17 21:26:01 +01:00
|
|
|
}
|
2005-03-16 21:48:25 +01:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, "", 1, "", 2, "", -1);
|
2005-04-09 21:18:28 +02:00
|
|
|
|
2005-06-20 14:46:57 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, _("Sponsor"), 1, user->sponsor.name->str,
|
|
|
|
2, "", -1);
|
|
|
|
|
2005-07-01 22:51:46 +02:00
|
|
|
misc_print_grouped_int(user->sponsor.benefit, buf);
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Contract time and money a sponsor pays. */
|
2005-06-20 14:46:57 +02:00
|
|
|
sprintf(buf2, _("%.1f months / %s"), ((gfloat)user->sponsor.contract) / 4, buf);
|
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, _("Contract / Money"), 1, buf2, 2, "", -1);
|
|
|
|
|
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, "", 1, "", 2, "", -1);
|
|
|
|
|
2005-07-08 11:26:00 +02:00
|
|
|
sprintf(buf, "%d%%", user->youth_academy.percentage);
|
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, _("Youth acad. invest."), 1, buf, 2, "", -1);
|
|
|
|
|
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, "", 1, "", 2, "", -1);
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
treeview_create_stadium_summary(ls);
|
2005-04-09 21:18:28 +02:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
return GTK_TREE_MODEL(ls);
|
2005-03-16 21:48:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
treeview_set_up_finances(GtkTreeView *treeview)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
GtkTreeViewColumn *col;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
gchar *titles[3] =
|
|
|
|
{"",
|
|
|
|
_("Income"),
|
|
|
|
_("Expenses")};
|
|
|
|
|
|
|
|
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview),
|
|
|
|
GTK_SELECTION_NONE);
|
2005-03-25 21:18:35 +01:00
|
|
|
gtk_tree_view_set_rules_hint(treeview, FALSE);
|
|
|
|
gtk_tree_view_set_headers_visible(treeview, TRUE);
|
2005-03-16 21:48:25 +01:00
|
|
|
|
|
|
|
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);
|
2005-04-16 09:46:04 +02:00
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
2005-03-16 21:48:25 +01:00
|
|
|
gtk_tree_view_column_pack_start(col, renderer, FALSE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
|
|
|
"markup", i);
|
|
|
|
|
|
|
|
if(i == 0)
|
|
|
|
g_object_set(renderer, "xalign", 1.0, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Show the finance overview of the user. */
|
|
|
|
void
|
|
|
|
treeview_show_finances(GtkTreeView *treeview, const User* user)
|
|
|
|
{
|
|
|
|
GtkTreeModel *model = NULL;
|
|
|
|
|
2005-04-16 09:46:04 +02:00
|
|
|
treeview_helper_clear(treeview);
|
2005-03-16 21:48:25 +01:00
|
|
|
|
|
|
|
treeview_set_up_finances(treeview);
|
|
|
|
model = treeview_create_finances(user);
|
|
|
|
gtk_tree_view_set_model(treeview, model);
|
|
|
|
g_object_unref(model);
|
|
|
|
}
|
2005-03-19 21:04:08 +01:00
|
|
|
|
|
|
|
/** Show the transfer list. */
|
|
|
|
void
|
|
|
|
treeview_show_transfer_list(GtkTreeView *treeview)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
GPtrArray *players = g_ptr_array_new();
|
|
|
|
|
|
|
|
for(i=0;i<transfer_list->len;i++)
|
2005-04-13 15:01:59 +02:00
|
|
|
g_ptr_array_add(players, player_of_id_team(trans(i).tm, trans(i).id));
|
2005-03-19 21:04:08 +01:00
|
|
|
|
|
|
|
treeview_show_player_list(treeview, players,
|
2005-04-16 09:46:04 +02:00
|
|
|
treeview_helper_get_attributes_from_scout(current_user.scout), FALSE);
|
2005-03-19 21:04:08 +01:00
|
|
|
}
|
2005-03-21 13:39:05 +01:00
|
|
|
|
2005-03-25 11:54:54 +01:00
|
|
|
/** Create attack, midfield and defend bars. */
|
|
|
|
void
|
2005-04-29 21:48:02 +02:00
|
|
|
treeview_create_next_opponent_values(GtkListStore *ls, const Fixture *fix)
|
2005-03-25 11:54:54 +01:00
|
|
|
{
|
|
|
|
gint i, j;
|
2005-03-25 12:44:49 +01:00
|
|
|
gchar buf[SMALL], buf2[SMALL];
|
2005-09-19 23:13:36 +02:00
|
|
|
gfloat max_values[4],
|
2005-03-25 11:54:54 +01:00
|
|
|
team_values[2][GAME_TEAM_VALUE_END];
|
2005-09-19 23:13:36 +02:00
|
|
|
gchar *titles[4] =
|
|
|
|
{_("Goalie"),
|
|
|
|
_("Defend"),
|
2005-03-25 11:54:54 +01:00
|
|
|
_("Midfield"),
|
|
|
|
_("Attack")};
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
game_get_values(fix, team_values, 0);
|
|
|
|
game_get_max_values(max_values);
|
|
|
|
|
2005-09-19 23:13:36 +02:00
|
|
|
for(i=0;i<4;i++)
|
2005-03-25 11:54:54 +01:00
|
|
|
{
|
2005-03-25 12:44:49 +01:00
|
|
|
strcpy(buf2, "");
|
2005-03-25 11:54:54 +01:00
|
|
|
for(j=0;j<(gint)rint((gfloat)const_int("int_treeview_max_pipes") *
|
|
|
|
(team_values[fix->teams[0] == current_user.tm][i] / max_values[i]));j++)
|
2005-03-25 12:44:49 +01:00
|
|
|
strcat(buf2, "|");
|
|
|
|
|
|
|
|
sprintf(buf, "%s\n<span foreground='%s'>", buf2,
|
2005-05-06 18:35:19 +02:00
|
|
|
const_app("string_treeview_opponent_value_colour_fg"));
|
2005-03-25 12:44:49 +01:00
|
|
|
for(j=0;j<(gint)rint((gfloat)const_int("int_treeview_max_pipes") *
|
|
|
|
(team_values[fix->teams[0] != current_user.tm][i] / max_values[i]));j++)
|
2005-03-25 11:54:54 +01:00
|
|
|
strcat(buf, "|");
|
2005-03-25 12:44:49 +01:00
|
|
|
strcat(buf, "</span>");
|
2005-03-25 11:54:54 +01:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, titles[i], 1, buf, -1);
|
2005-03-25 11:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-21 13:39:05 +01:00
|
|
|
GtkTreeModel*
|
|
|
|
treeview_create_next_opponent(void)
|
|
|
|
{
|
|
|
|
gchar buf[SMALL], buf2[SMALL];
|
|
|
|
const Fixture *fix = team_get_fixture(current_user.tm, FALSE);
|
|
|
|
const Team *opp = (fix == NULL) ? NULL :
|
|
|
|
fix->teams[fix->teams[0] == current_user.tm];
|
2005-04-29 21:48:02 +02:00
|
|
|
GtkListStore *ls = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
|
2005-03-21 13:39:05 +01:00
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
if(opp == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2005-10-24 22:50:48 +02:00
|
|
|
ls = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
|
|
|
|
|
2005-05-06 18:35:19 +02:00
|
|
|
if(fix->clid < ID_CUP_START)
|
|
|
|
strcpy(buf, league_cup_get_name_string(fix->clid));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cup_round_name(fix, buf2);
|
|
|
|
sprintf(buf, "%s (%s)", league_cup_get_name_string(fix->clid), buf2);
|
|
|
|
}
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
2005-05-06 18:35:19 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 0, _("Your next opponent"), 1, buf, -1);
|
2005-04-13 15:01:59 +02:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
2005-05-18 18:00:49 +02:00
|
|
|
|
|
|
|
if(fix->week_number == week &&
|
|
|
|
fix->week_round_number == week_round)
|
2005-05-26 18:54:22 +02:00
|
|
|
sprintf(buf, _("<span foreground='%s' background='%s'>Week %d Round %d</span>"),
|
2005-05-18 18:00:49 +02:00
|
|
|
const_app("string_treeview_helper_color_default_foreground"),
|
|
|
|
const_app("string_treeview_helper_color_default_background"),
|
|
|
|
fix->week_number, fix->week_round_number);
|
|
|
|
else
|
2005-05-26 18:54:22 +02:00
|
|
|
sprintf(buf, _("<span foreground='%s' background='%s'>Week %d Round %d</span>"),
|
2005-05-18 18:00:49 +02:00
|
|
|
const_app("string_treeview_opponent_match_later_fg"),
|
|
|
|
const_app("string_treeview_opponent_match_later_bg"),
|
|
|
|
fix->week_number, fix->week_round_number);
|
|
|
|
|
2005-04-14 21:07:25 +02:00
|
|
|
if(!fix->home_advantage)
|
|
|
|
strcpy(buf2, _("Neutral ground"));
|
|
|
|
else if(fix->teams[0] == current_user.tm)
|
|
|
|
strcpy(buf2, _("Home"));
|
|
|
|
else
|
|
|
|
strcpy(buf2, _("Away"));
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 0, buf, 1, buf2, -1);
|
2005-04-13 15:01:59 +02:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, "", 1, "", -1);
|
2005-03-21 13:39:05 +01:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
2005-10-09 11:35:44 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 0, _("Team"), 1, opp->name, -1);
|
2005-03-21 13:39:05 +01:00
|
|
|
|
|
|
|
if(opp->clid < ID_CUP_START)
|
|
|
|
{
|
2005-04-22 17:17:39 +02:00
|
|
|
sprintf(buf, "%d (%s)", team_get_league_rank(opp), league_cup_get_name_string(opp->clid));
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, _("Rank"), 1, buf, -1);
|
2005-03-21 13:39:05 +01:00
|
|
|
}
|
|
|
|
|
2005-03-25 21:18:35 +01:00
|
|
|
sprintf(buf, "%.1f", team_get_average_skill(opp, TRUE));
|
|
|
|
if(team_get_average_skill(opp, TRUE) >
|
|
|
|
team_get_average_skill(current_user.tm, TRUE))
|
2005-03-21 13:39:05 +01:00
|
|
|
sprintf(buf2, " (<span foreground='%s'>%+.1f</span>)",
|
2005-05-06 18:35:19 +02:00
|
|
|
const_app("string_treeview_opponent_skill_positive_fg"),
|
2005-03-25 21:18:35 +01:00
|
|
|
team_get_average_skill(opp, TRUE) -
|
|
|
|
team_get_average_skill(current_user.tm, TRUE));
|
2005-03-21 13:39:05 +01:00
|
|
|
else
|
|
|
|
sprintf(buf2, " (<span foreground='%s'>%+.1f</span>)",
|
2005-05-06 18:35:19 +02:00
|
|
|
const_app("string_treeview_opponent_skill_negative_fg"),
|
2005-03-25 21:18:35 +01:00
|
|
|
team_get_average_skill(opp, TRUE) -
|
|
|
|
team_get_average_skill(current_user.tm, TRUE));
|
2005-03-21 13:39:05 +01:00
|
|
|
|
|
|
|
strcat(buf, buf2);
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, _("Average skill"), 1, buf, -1);
|
2005-03-21 13:39:05 +01:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, _("Playing style"), 1,
|
2005-03-21 13:39:05 +01:00
|
|
|
team_attribute_to_char(TEAM_ATTRIBUTE_STYLE, opp->style), -1);
|
|
|
|
|
|
|
|
sprintf(buf, "%d", opp->structure);
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, _("Team structure"), 1, buf, -1);
|
2005-03-21 13:39:05 +01:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
treeview_create_next_opponent_values(ls, fix);
|
2005-03-25 11:54:54 +01:00
|
|
|
|
2005-05-30 19:50:53 +02:00
|
|
|
team_write_results(opp, buf, buf2);
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, _("Latest results"), 1, buf, -1);
|
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, _("Goals"), 1, buf2, -1);
|
2005-03-21 13:39:05 +01:00
|
|
|
|
2005-08-21 21:58:51 +02:00
|
|
|
team_write_own_results(opp, buf, FALSE, TRUE);
|
2005-06-26 13:42:01 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
/* The user's results against a specific team. */
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 0, _("Your results"), 1, buf, -1);
|
2005-03-21 13:39:05 +01:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
return GTK_TREE_MODEL(ls);
|
2005-03-21 13:39:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
treeview_set_up_next_opponent(GtkTreeView *treeview)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
GtkTreeViewColumn *col;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
|
|
|
|
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview),
|
2005-05-19 18:45:29 +02:00
|
|
|
GTK_SELECTION_SINGLE);
|
2005-03-25 21:18:35 +01:00
|
|
|
gtk_tree_view_set_rules_hint(treeview, FALSE);
|
|
|
|
gtk_tree_view_set_headers_visible(treeview, FALSE);
|
2005-03-21 13:39:05 +01:00
|
|
|
|
|
|
|
for(i=0;i<2;i++)
|
|
|
|
{
|
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
2005-04-16 09:46:04 +02:00
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
2005-03-21 13:39:05 +01:00
|
|
|
gtk_tree_view_column_pack_start(col, renderer, FALSE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
|
|
|
"markup", i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Show some information about the next opponent. */
|
|
|
|
void
|
2005-03-25 21:18:35 +01:00
|
|
|
treeview_show_next_opponent(void)
|
2005-03-21 13:39:05 +01:00
|
|
|
{
|
2005-03-25 21:18:35 +01:00
|
|
|
GtkTreeView *treeview =
|
|
|
|
GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right"));
|
2005-03-21 13:39:05 +01:00
|
|
|
GtkTreeModel *model = NULL;
|
|
|
|
|
2005-04-16 09:46:04 +02:00
|
|
|
treeview_helper_clear(treeview);
|
2005-03-21 13:39:05 +01:00
|
|
|
|
|
|
|
treeview_set_up_next_opponent(treeview);
|
|
|
|
model = treeview_create_next_opponent();
|
|
|
|
gtk_tree_view_set_model(treeview, model);
|
2005-04-13 15:01:59 +02:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
treeview_helper_unref(G_OBJECT(model));
|
2005-03-21 13:39:05 +01:00
|
|
|
}
|
2005-03-24 21:22:44 +01:00
|
|
|
|
|
|
|
GtkTreeModel*
|
|
|
|
treeview_create_league_results(void)
|
|
|
|
{
|
2005-05-30 19:50:53 +02:00
|
|
|
gint i;
|
|
|
|
gchar name[SMALL], results[SMALL];
|
2005-03-24 21:22:44 +01:00
|
|
|
GArray *table_elements =
|
|
|
|
league_from_clid(current_user.tm->clid)->table.elements;
|
2005-04-29 21:48:02 +02:00
|
|
|
GtkListStore *ls =
|
2005-03-24 21:22:44 +01:00
|
|
|
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>",
|
2005-05-06 18:35:19 +02:00
|
|
|
const_app("string_treeview_user_bg"),
|
2005-10-09 11:35:44 +02:00
|
|
|
g_array_index(table_elements, TableElement, i).team->name);
|
2005-03-24 21:22:44 +01:00
|
|
|
else
|
2005-10-09 11:35:44 +02:00
|
|
|
strcpy(name, g_array_index(table_elements, TableElement, i).team->name);
|
2005-03-24 21:22:44 +01:00
|
|
|
|
2005-05-30 19:50:53 +02:00
|
|
|
team_write_own_results(g_array_index(table_elements, TableElement, i).team,
|
2005-08-21 21:58:51 +02:00
|
|
|
results, TRUE, FALSE);
|
2005-03-24 21:22:44 +01:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, name,
|
2005-05-30 19:50:53 +02:00
|
|
|
1, results, -1);
|
2005-03-24 21:22:44 +01:00
|
|
|
}
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
return GTK_TREE_MODEL(ls);
|
2005-03-24 21:22:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
treeview_set_up_league_results(GtkTreeView *treeview)
|
|
|
|
{
|
|
|
|
gint i;
|
2005-05-30 19:50:53 +02:00
|
|
|
gchar *titles[2] =
|
2005-03-24 21:22:44 +01:00
|
|
|
{_("Team"),
|
2005-05-30 19:50:53 +02:00
|
|
|
_("Results")};
|
2005-03-24 21:22:44 +01:00
|
|
|
GtkTreeViewColumn *col;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
|
|
|
|
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview),
|
|
|
|
GTK_SELECTION_NONE);
|
2005-03-25 21:18:35 +01:00
|
|
|
gtk_tree_view_set_rules_hint(treeview, TRUE);
|
|
|
|
gtk_tree_view_set_headers_visible(treeview, TRUE);
|
2005-03-24 21:22:44 +01:00
|
|
|
|
2005-05-30 19:50:53 +02:00
|
|
|
for(i=0;i<2;i++)
|
2005-03-24 21:22:44 +01:00
|
|
|
{
|
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_column_set_title(col, titles[i]);
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
2005-04-16 09:46:04 +02:00
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
2005-03-24 21:22:44 +01:00
|
|
|
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;
|
|
|
|
|
2005-04-16 09:46:04 +02:00
|
|
|
treeview_helper_clear(treeview);
|
2005-03-24 21:22:44 +01:00
|
|
|
|
|
|
|
treeview_set_up_league_results(treeview);
|
|
|
|
model = treeview_create_league_results();
|
|
|
|
gtk_tree_view_set_model(treeview, model);
|
|
|
|
g_object_unref(model);
|
|
|
|
}
|
2005-03-27 19:59:57 +02:00
|
|
|
|
2005-05-09 19:06:11 +02:00
|
|
|
/** Show a list of all players in the teams of the cup or league. */
|
2005-03-27 19:59:57 +02:00
|
|
|
void
|
2005-05-09 19:06:11 +02:00
|
|
|
treeview_show_all_players(gint clid)
|
2005-03-27 19:59:57 +02:00
|
|
|
{
|
|
|
|
gint i, j;
|
|
|
|
GPtrArray *players = g_ptr_array_new();
|
2005-05-09 19:06:11 +02:00
|
|
|
const GArray *teams = NULL;
|
|
|
|
const GPtrArray *teamsp = NULL;
|
|
|
|
|
|
|
|
if(clid < ID_CUP_START)
|
|
|
|
{
|
|
|
|
teams = (GArray*)league_cup_get_teams(clid);
|
|
|
|
for(i=0;i<teams->len;i++)
|
|
|
|
if(&g_array_index(teams, Team, i) != current_user.tm)
|
|
|
|
for(j=0;j<g_array_index(teams, Team, i).players->len;j++)
|
|
|
|
g_ptr_array_add(players, &g_array_index(g_array_index(teams, Team, i).players,
|
|
|
|
Player, j));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
teamsp = (GPtrArray*)league_cup_get_teams(clid);
|
|
|
|
for(i=0;i<teamsp->len;i++)
|
|
|
|
if((Team*)g_ptr_array_index(teamsp, i) != current_user.tm)
|
|
|
|
for(j=0;j<((Team*)g_ptr_array_index(teamsp, i))->players->len;j++)
|
|
|
|
g_ptr_array_add(players, &g_array_index(((Team*)g_ptr_array_index(teamsp, i))->players,
|
|
|
|
Player, j));
|
|
|
|
}
|
|
|
|
|
2005-03-27 19:59:57 +02:00
|
|
|
treeview_show_player_list(GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right")),
|
|
|
|
players,
|
2005-04-16 09:46:04 +02:00
|
|
|
treeview_helper_get_attributes_from_scout(current_user.scout), FALSE);
|
2005-03-27 19:59:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkTreeModel*
|
|
|
|
treeview_create_preview(void)
|
|
|
|
{
|
|
|
|
gint i;
|
2005-04-29 21:48:02 +02:00
|
|
|
GtkListStore *ls;
|
2005-03-27 19:59:57 +02:00
|
|
|
GPtrArray *fixtures = fixture_get_coming(current_user.tm);
|
|
|
|
gint max = MIN(const_int("int_treeview_coming_matches"), fixtures->len);
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
if(fixtures->len == 0)
|
|
|
|
{
|
|
|
|
free_g_ptr_array(&fixtures);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
ls = gtk_list_store_new(5,
|
|
|
|
GDK_TYPE_PIXBUF,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
GDK_TYPE_PIXBUF);
|
2005-03-27 19:59:57 +02:00
|
|
|
|
|
|
|
for(i=0;i<max;i++)
|
|
|
|
{
|
|
|
|
treeview_create_fixtures_header((Fixture*)g_ptr_array_index(fixtures, i),
|
2005-04-29 21:48:02 +02:00
|
|
|
ls, FALSE);
|
|
|
|
treeview_create_fixture((Fixture*)g_ptr_array_index(fixtures, i), ls);
|
2005-03-27 19:59:57 +02:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, NULL, 1, "", 2, "", 3, "", 4, NULL, -1);
|
2005-03-27 19:59:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
g_ptr_array_free(fixtures, TRUE);
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
return GTK_TREE_MODEL(ls);
|
2005-03-27 19:59:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Show a preview of the current user's next games. */
|
|
|
|
void
|
|
|
|
treeview_show_preview(void)
|
|
|
|
{
|
|
|
|
GtkTreeView *treeview = GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right"));
|
|
|
|
GtkTreeModel *model = NULL;
|
|
|
|
|
2005-04-16 09:46:04 +02:00
|
|
|
treeview_helper_clear(treeview);
|
2005-03-27 19:59:57 +02:00
|
|
|
|
|
|
|
treeview_set_up_fixtures(treeview);
|
|
|
|
model = treeview_create_preview();
|
|
|
|
gtk_tree_view_set_model(treeview, model);
|
|
|
|
g_object_unref(model);
|
|
|
|
}
|
2005-04-07 18:44:33 +02:00
|
|
|
|
|
|
|
GtkTreeModel*
|
|
|
|
treeview_create_player_info(const Player *pl)
|
|
|
|
{
|
|
|
|
gint i;
|
2005-04-29 21:48:02 +02:00
|
|
|
GtkListStore *ls = gtk_list_store_new(2,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_POINTER);
|
2005-04-07 18:44:33 +02:00
|
|
|
GtkTreeIter iter;
|
2005-04-07 23:10:31 +02:00
|
|
|
gchar *titles[PLAYER_INFO_ATTRIBUTE_END] =
|
|
|
|
{_("Name"),
|
|
|
|
_("Position"),
|
|
|
|
_("Current position"),
|
|
|
|
_("Skill"),
|
|
|
|
_("Current skill"),
|
|
|
|
_("Fitness"),
|
|
|
|
_("Estimated talent"),
|
|
|
|
_("Age"),
|
|
|
|
_("Health"),
|
|
|
|
_("Value"),
|
|
|
|
_("Wage"),
|
|
|
|
_("Contract"),
|
2005-04-13 15:01:59 +02:00
|
|
|
_("Games/Goals\n"),
|
2005-06-26 13:42:01 +02:00
|
|
|
/* 'Limit' is the number of yellow cards until a player gets
|
|
|
|
banned automatically for a match. */
|
2005-04-13 15:01:59 +02:00
|
|
|
_("Yellow cards (limit)\n"),
|
|
|
|
_("Banned\n"),
|
2005-09-18 12:02:10 +02:00
|
|
|
/* Hot streak or cold streak of a player. */
|
|
|
|
_("Streak"),
|
2005-05-19 21:43:22 +02:00
|
|
|
_("Career values"),
|
2005-04-07 23:10:31 +02:00
|
|
|
_("New contract\noffers")};
|
2005-04-07 18:44:33 +02:00
|
|
|
|
2005-04-07 23:10:31 +02:00
|
|
|
for(i=0;i<PLAYER_INFO_ATTRIBUTE_END;i++)
|
|
|
|
{
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, titles[i], 1, pl, -1);
|
2005-04-07 23:10:31 +02:00
|
|
|
}
|
2005-04-07 18:44:33 +02:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
return GTK_TREE_MODEL(ls);
|
2005-04-07 18:44:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
treeview_set_up_player_info(GtkTreeView *treeview)
|
|
|
|
{
|
|
|
|
GtkTreeViewColumn *col;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
|
|
|
|
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview),
|
|
|
|
GTK_SELECTION_NONE);
|
2005-04-07 23:10:31 +02:00
|
|
|
gtk_tree_view_set_rules_hint(treeview, FALSE);
|
2005-04-07 18:44:33 +02:00
|
|
|
gtk_tree_view_set_headers_visible(treeview, FALSE);
|
|
|
|
|
2005-04-07 23:10:31 +02:00
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
2005-04-16 09:46:04 +02:00
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
2005-04-07 23:10:31 +02:00
|
|
|
gtk_tree_view_column_pack_start(col, renderer, FALSE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
|
|
|
"markup", 0);
|
|
|
|
|
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
2005-04-16 09:46:04 +02:00
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
2005-04-07 23:10:31 +02:00
|
|
|
gtk_tree_view_column_pack_start(col, renderer, FALSE);
|
|
|
|
gtk_tree_view_column_set_cell_data_func(col, renderer,
|
2005-04-16 09:46:04 +02:00
|
|
|
treeview_helper_player_ext_info_to_cell,
|
2005-04-07 23:10:31 +02:00
|
|
|
NULL, NULL);
|
2005-04-07 18:44:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** 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;
|
|
|
|
|
2005-04-16 09:46:04 +02:00
|
|
|
treeview_helper_clear(treeview);
|
2005-04-07 18:44:33 +02:00
|
|
|
|
|
|
|
treeview_set_up_player_info(treeview);
|
|
|
|
model = treeview_create_player_info(pl);
|
|
|
|
gtk_tree_view_set_model(treeview, model);
|
|
|
|
g_object_unref(model);
|
|
|
|
}
|
2005-04-15 15:55:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
GtkTreeModel*
|
|
|
|
treeview_create_fixtures_week(gint week_number, gint week_round_number)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
GPtrArray *fixtures = fixture_get_week_list(week_number, week_round_number);
|
2005-04-29 21:48:02 +02:00
|
|
|
GtkListStore *ls = gtk_list_store_new(5,
|
|
|
|
GDK_TYPE_PIXBUF,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
GDK_TYPE_PIXBUF);
|
2005-04-15 15:55:59 +02:00
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
for(i=0;i<fixtures->len;i++)
|
|
|
|
{
|
|
|
|
if(((Fixture*)g_ptr_array_index(fixtures, i))->clid >= ID_CUP_START ||
|
2005-04-29 21:48:02 +02:00
|
|
|
((Fixture*)g_ptr_array_index(fixtures, i))->clid == current_user.tm->clid ||
|
2005-04-15 15:55:59 +02:00
|
|
|
opt_user_int("int_opt_user_show_all_leagues"))
|
|
|
|
{
|
|
|
|
if(i == 0 ||
|
|
|
|
((Fixture*)g_ptr_array_index(fixtures, i))->clid !=
|
|
|
|
((Fixture*)g_ptr_array_index(fixtures, i - 1))->clid)
|
|
|
|
{
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, NULL, -1);
|
2005-04-15 15:55:59 +02:00
|
|
|
treeview_create_fixtures_header((Fixture*)g_ptr_array_index(fixtures, i),
|
2005-04-29 21:48:02 +02:00
|
|
|
ls, TRUE);
|
2005-04-15 15:55:59 +02:00
|
|
|
}
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
treeview_create_fixture((Fixture*)g_ptr_array_index(fixtures, i), ls);
|
2005-04-15 15:55:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_ptr_array_free(fixtures, TRUE);
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
return GTK_TREE_MODEL(ls);
|
2005-04-15 15:55:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Show a fixture list of all matches in the given week and round. */
|
|
|
|
void
|
|
|
|
treeview_show_fixtures_week(gint week_number, gint week_round_number)
|
|
|
|
{
|
|
|
|
GtkTreeView *treeview = GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right"));
|
|
|
|
GtkTreeModel *model = NULL;
|
|
|
|
|
2005-04-16 09:46:04 +02:00
|
|
|
treeview_helper_clear(treeview);
|
2005-04-15 15:55:59 +02:00
|
|
|
|
|
|
|
treeview_set_up_fixtures(treeview);
|
|
|
|
model = treeview_create_fixtures_week(week_number, week_round_number);
|
|
|
|
gtk_tree_view_set_model(treeview, model);
|
|
|
|
g_object_unref(model);
|
|
|
|
}
|
2005-04-16 09:46:04 +02:00
|
|
|
|
|
|
|
GtkTreeModel*
|
|
|
|
treeview_create_user_history(void)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
gchar buf[SMALL];
|
2005-04-29 21:48:02 +02:00
|
|
|
GtkListStore *ls =
|
2005-04-16 09:46:04 +02:00
|
|
|
gtk_list_store_new(5, G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING);
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
for(i=0;i<current_user.history->len;i++)
|
|
|
|
{
|
|
|
|
user_history_to_string(&g_array_index(current_user.history, UserHistory, i), buf);
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
treeview_helper_insert_icon(ls, &iter, 3,
|
|
|
|
treeview_helper_get_user_history_icon(
|
|
|
|
g_array_index(current_user.history, UserHistory, i).type));
|
|
|
|
gtk_list_store_set(ls, &iter,
|
2005-04-16 09:46:04 +02:00
|
|
|
0, g_array_index(current_user.history, UserHistory, i).season,
|
|
|
|
1, g_array_index(current_user.history, UserHistory, i).week,
|
2005-12-01 12:50:54 +01:00
|
|
|
2, g_array_index(current_user.history, UserHistory, i).team_name,
|
2005-04-16 09:46:04 +02:00
|
|
|
4, buf, -1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
return GTK_TREE_MODEL(ls);
|
2005-04-16 09:46:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
treeview_set_up_user_history(GtkTreeView *treeview)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
GtkTreeViewColumn *col;
|
|
|
|
GtkCellRenderer *renderer;
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Season. */
|
|
|
|
gchar *titles[3] ={_("Sea"),
|
|
|
|
_("Week"), _("Team")};
|
2005-04-16 09:46:04 +02:00
|
|
|
|
|
|
|
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, TRUE);
|
|
|
|
|
|
|
|
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_helper_cell_renderer_text_new();
|
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
|
|
|
"text", i);
|
|
|
|
g_object_set(renderer, "xalign", 0.5, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
|
|
|
renderer = gtk_cell_renderer_pixbuf_new();
|
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
|
|
|
"pixbuf", 3);
|
|
|
|
g_object_set(renderer, "xalign", 0.5, NULL);
|
|
|
|
|
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_column_set_title(col, _("Event"));
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
|
|
|
gtk_tree_view_column_pack_start(col, renderer, FALSE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
|
|
|
"text", 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Show the history array of the current user in the
|
|
|
|
right treeview. */
|
|
|
|
void
|
|
|
|
treeview_show_user_history(void)
|
|
|
|
{
|
|
|
|
GtkTreeView *treeview = GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right"));
|
|
|
|
GtkTreeModel *model = NULL;
|
|
|
|
|
|
|
|
treeview_helper_clear(treeview);
|
|
|
|
|
|
|
|
treeview_set_up_user_history(treeview);
|
|
|
|
model = treeview_create_user_history();
|
|
|
|
gtk_tree_view_set_model(treeview, model);
|
|
|
|
g_object_unref(model);
|
|
|
|
}
|
2005-04-29 21:48:02 +02:00
|
|
|
|
|
|
|
void
|
2005-05-02 16:39:30 +02:00
|
|
|
treeview_create_league_stats(GtkListStore *ls, const LeagueStat *league_stat)
|
2005-04-29 21:48:02 +02:00
|
|
|
{
|
|
|
|
gint i, j;
|
|
|
|
gchar buf[SMALL], buf2[SMALL], buf3[SMALL], buf4[SMALL];
|
|
|
|
GtkTreeIter iter;
|
2005-05-02 16:39:30 +02:00
|
|
|
GArray *teams[2] = {league_stat->teams_off, league_stat->teams_def};
|
|
|
|
GArray *players[2] = {league_stat->player_scorers, league_stat->player_goalies};
|
2005-04-29 21:48:02 +02:00
|
|
|
gchar *team_titles[2] = {_("Best offensive teams"),
|
|
|
|
_("Best defensive teams")};
|
2005-05-06 18:35:19 +02:00
|
|
|
gchar *team_icons[2] = {const_app("string_treeview_league_stats_off_teams_icon"),
|
|
|
|
const_app("string_treeview_league_stats_def_teams_icon")};
|
2005-04-29 21:48:02 +02:00
|
|
|
gchar *player_titles[2][2] = {{_("Best goal scorers"), _("Shot %")},
|
2005-06-26 13:42:01 +02:00
|
|
|
{_("Best goalkeepers"),
|
|
|
|
/* % of saves for goalies (#goals / #shots) */
|
|
|
|
_("Save %")}};
|
2005-05-06 18:35:19 +02:00
|
|
|
gchar *player_icons[2] = {const_app("string_treeview_league_stats_scorers_icon"),
|
|
|
|
const_app("string_treeview_league_stats_goalies_icon")};
|
2005-04-29 21:48:02 +02:00
|
|
|
gchar *colour_fg = NULL, *colour_bg = NULL;
|
|
|
|
|
|
|
|
gtk_list_store_append(ls, &iter);
|
2005-12-01 12:50:54 +01:00
|
|
|
treeview_helper_insert_icon(ls, &iter, 0,
|
|
|
|
league_stat->league_symbol);
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 1, const_int("int_treeview_helper_int_empty"),
|
2005-12-01 12:50:54 +01:00
|
|
|
2, league_stat->league_name, 3, "", 4, "", 5, "", -1);
|
2005-04-29 21:48:02 +02:00
|
|
|
|
|
|
|
for(i=0;i<2;i++)
|
|
|
|
{
|
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, NULL,
|
|
|
|
1, const_int("int_treeview_helper_int_empty"),
|
|
|
|
2, "", 3, "", 4, "", 5, "", -1);
|
|
|
|
|
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
treeview_helper_insert_icon(ls, &iter, 0, team_icons[i]);
|
|
|
|
gtk_list_store_set(ls, &iter, 1, const_int("int_treeview_helper_int_empty"),
|
|
|
|
2, team_titles[i], 4, _("Goals"), -1);
|
|
|
|
|
|
|
|
for(j=0;j<teams[i]->len;j++)
|
|
|
|
{
|
|
|
|
sprintf(buf, "%d : %d",
|
|
|
|
g_array_index(teams[i], Stat, j).value1,
|
|
|
|
g_array_index(teams[i], Stat, j).value2);
|
|
|
|
|
2005-12-01 12:50:54 +01:00
|
|
|
treeview_helper_set_user_colours(
|
|
|
|
g_array_index(teams[i], Stat, j).team_name,
|
|
|
|
&colour_bg, &colour_fg);
|
2005-04-29 21:48:02 +02:00
|
|
|
|
|
|
|
sprintf(buf2, "<span background='%s' foreground='%s'>%s</span>",
|
2005-12-01 12:50:54 +01:00
|
|
|
colour_bg, colour_fg,
|
|
|
|
g_array_index(teams[i], Stat, j).team_name);
|
2005-04-29 21:48:02 +02:00
|
|
|
|
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, NULL, 1, j + 1,
|
|
|
|
2, buf2,
|
|
|
|
4, buf, 5, "", -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=0;i<2;i++)
|
|
|
|
{
|
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, NULL,
|
|
|
|
1, const_int("int_treeview_helper_int_empty"),
|
|
|
|
2, "", 3, "", 4, "", 5, "", -1);
|
|
|
|
|
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
treeview_helper_insert_icon(ls, &iter, 0, player_icons[i]);
|
|
|
|
gtk_list_store_set(ls, &iter, 1, const_int("int_treeview_helper_int_empty"),
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Goals. */
|
2005-04-29 21:48:02 +02:00
|
|
|
2, player_titles[i][0], 3, _("Go"),
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Goals per game. */
|
2005-04-29 21:48:02 +02:00
|
|
|
4, _("Go/Ga"), 5, player_titles[i][1], -1);
|
|
|
|
|
|
|
|
for(j=0;j<players[i]->len;j++)
|
|
|
|
{
|
|
|
|
sprintf(buf, "%.1f",
|
|
|
|
(gfloat)g_array_index(players[i], Stat, j).value1 /
|
|
|
|
(gfloat)g_array_index(players[i], Stat, j).value2);
|
|
|
|
if(i == 0)
|
2005-06-16 08:56:12 +02:00
|
|
|
sprintf(buf2, "%.1f %%", (g_array_index(players[i], Stat, j).value3 > 0) ?
|
2005-04-29 21:48:02 +02:00
|
|
|
100 * ((gfloat)g_array_index(players[i], Stat, j).value1 /
|
2005-06-16 08:56:12 +02:00
|
|
|
(gfloat)g_array_index(players[i], Stat, j).value3) : 0);
|
2005-04-29 21:48:02 +02:00
|
|
|
else
|
2005-06-16 08:56:12 +02:00
|
|
|
sprintf(buf2, "%.1f %%", (g_array_index(players[i], Stat, j).value3 > 0) ?
|
2005-04-29 21:48:02 +02:00
|
|
|
100 * (1 - (gfloat)g_array_index(players[i], Stat, j).value1 /
|
2005-06-16 08:56:12 +02:00
|
|
|
(gfloat)g_array_index(players[i], Stat, j).value3) : 0);
|
2005-04-29 21:48:02 +02:00
|
|
|
|
2005-12-01 12:50:54 +01:00
|
|
|
treeview_helper_set_user_colours(
|
|
|
|
g_array_index(players[i], Stat, j).team_name,
|
|
|
|
&colour_bg, &colour_fg);
|
2005-04-29 21:48:02 +02:00
|
|
|
sprintf(buf3, "<span background='%s' foreground='%s'>%s (%s)</span>",
|
|
|
|
colour_bg, colour_fg,
|
2005-10-09 11:35:44 +02:00
|
|
|
g_array_index(players[i], Stat, j).value_string,
|
2005-12-01 12:50:54 +01:00
|
|
|
g_array_index(players[i], Stat, j).team_name);
|
2005-04-29 21:48:02 +02:00
|
|
|
sprintf(buf4, "%d", g_array_index(players[i], Stat, j).value1);
|
|
|
|
|
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, NULL, 1, j + 1,
|
|
|
|
2, buf3, 3, buf4, 4, buf, 5, buf2, -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
treeview_set_up_league_stats(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, FALSE);
|
|
|
|
gtk_tree_view_set_headers_visible(treeview, FALSE);
|
|
|
|
|
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
|
|
|
renderer = gtk_cell_renderer_pixbuf_new();
|
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
|
|
|
"pixbuf", 0);
|
|
|
|
g_object_set(renderer, "xalign", 0.5, NULL);
|
|
|
|
|
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_set_cell_data_func(col, renderer,
|
|
|
|
treeview_helper_int_to_cell,
|
|
|
|
NULL, NULL);
|
|
|
|
for(i=2;i<6;i++)
|
|
|
|
{
|
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
|
|
|
"markup", i);
|
2005-05-02 16:39:30 +02:00
|
|
|
if(i > 3)
|
2005-04-29 21:48:02 +02:00
|
|
|
g_object_set(renderer, "xalign", 0.5, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Show the stats of the league with specified id. */
|
|
|
|
void
|
|
|
|
treeview_show_league_stats(gint clid)
|
|
|
|
{
|
|
|
|
GtkTreeView *treeview = GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right"));
|
|
|
|
GtkListStore *model =
|
|
|
|
gtk_list_store_new(6, GDK_TYPE_PIXBUF, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING, G_TYPE_STRING);
|
|
|
|
|
|
|
|
treeview_helper_clear(treeview);
|
|
|
|
|
|
|
|
treeview_set_up_league_stats(treeview);
|
2005-05-02 16:39:30 +02:00
|
|
|
treeview_create_league_stats(model, &league_from_clid(clid)->stats);
|
|
|
|
gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(model));
|
|
|
|
g_object_unref(model);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
treeview_create_season_history_champions(GtkListStore *ls, const GArray* league_champs,
|
|
|
|
const GArray *cup_champs)
|
|
|
|
{
|
|
|
|
gint i, j;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
const GArray *champs[2] = {league_champs, cup_champs};
|
|
|
|
gchar *titles[2] = {_("League champions"),
|
|
|
|
_("Cup champions")};
|
2005-05-06 18:35:19 +02:00
|
|
|
gchar *icons[2] = {const_app("string_treeview_season_hist_league_champions_icon"),
|
|
|
|
const_app("string_treeview_season_hist_cup_champions_icon")};
|
2005-05-02 16:39:30 +02:00
|
|
|
|
|
|
|
for(i=0;i<2;i++)
|
|
|
|
{
|
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
treeview_helper_insert_icon(ls, &iter, 0, icons[i]);
|
|
|
|
gtk_list_store_set(ls, &iter, 1, const_int("int_treeview_helper_int_empty"),
|
|
|
|
2, titles[i], 3, "", 4, "", 5, "", -1);
|
|
|
|
|
|
|
|
for(j=0;j<champs[i]->len;j++)
|
|
|
|
{
|
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, NULL, 1, const_int("int_treeview_helper_int_empty"),
|
2005-10-09 11:35:44 +02:00
|
|
|
2, g_array_index(champs[i], ChampStat, j).cl_name,
|
|
|
|
3, g_array_index(champs[i], ChampStat, j).team_name,
|
2005-05-02 16:39:30 +02:00
|
|
|
4, "", 5, "", -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter, 0, NULL,
|
|
|
|
1, const_int("int_treeview_helper_int_empty"),
|
|
|
|
2, "", 3, "", 4, "", 5, "", -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-01 12:50:54 +01:00
|
|
|
/** Show the season history with given index in the season_stats array
|
|
|
|
and the specified page.
|
|
|
|
@param page Either a page of league stats
|
2005-05-02 16:39:30 +02:00
|
|
|
(if != -1) or -1 which means we show the champions. */
|
|
|
|
void
|
2005-12-01 12:50:54 +01:00
|
|
|
treeview_show_season_history(gint page, gint idx)
|
2005-05-02 16:39:30 +02:00
|
|
|
{
|
|
|
|
gchar buf[SMALL];
|
|
|
|
GtkTreeView *treeview = GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right"));
|
|
|
|
GtkListStore *model =
|
|
|
|
gtk_list_store_new(6, GDK_TYPE_PIXBUF, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING, G_TYPE_STRING);
|
|
|
|
GtkTreeIter iter;
|
2005-12-01 12:50:54 +01:00
|
|
|
SeasonStat *stat = &g_array_index(season_stats, SeasonStat, idx);
|
2005-05-02 16:39:30 +02:00
|
|
|
|
|
|
|
treeview_helper_clear(treeview);
|
|
|
|
|
|
|
|
treeview_set_up_league_stats(treeview);
|
|
|
|
|
2005-12-01 12:50:54 +01:00
|
|
|
sprintf(buf, _("Season %d"), stat->season_number);
|
2005-05-02 16:39:30 +02:00
|
|
|
gtk_list_store_append(model, &iter);
|
|
|
|
gtk_list_store_set(model, &iter, 0, NULL,
|
|
|
|
1, const_int("int_treeview_helper_int_empty"),
|
|
|
|
2, buf, -1);
|
|
|
|
|
|
|
|
if(page != -1)
|
2005-12-01 12:50:54 +01:00
|
|
|
treeview_create_league_stats(
|
|
|
|
model, &g_array_index(stat->league_stats, LeagueStat, page));
|
2005-05-02 16:39:30 +02:00
|
|
|
else
|
2005-12-01 12:50:54 +01:00
|
|
|
treeview_create_season_history_champions(
|
|
|
|
model, stat->league_champs, stat->cup_champs);
|
2005-05-02 16:39:30 +02:00
|
|
|
|
2005-04-29 21:48:02 +02:00
|
|
|
gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(model));
|
|
|
|
g_object_unref(model);
|
|
|
|
}
|
2005-05-07 16:19:52 +02:00
|
|
|
|
|
|
|
/** Create the model for the startup country files combo.
|
|
|
|
@param country_list The list of country files found. */
|
|
|
|
GtkTreeModel*
|
|
|
|
treeview_create_country_list(const GPtrArray *country_list)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
GtkListStore *ls = gtk_list_store_new(2, GDK_TYPE_PIXBUF, G_TYPE_STRING);
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gchar buf[SMALL], buf2[SMALL], trash[SMALL];
|
|
|
|
|
|
|
|
for(i=0;i<country_list->len;i++)
|
|
|
|
{
|
2005-10-05 21:59:37 +02:00
|
|
|
sscanf((gchar*)g_ptr_array_index(country_list, i), "country_%[^.]%[.xml]",
|
2005-05-07 16:19:52 +02:00
|
|
|
buf2, trash);
|
|
|
|
sprintf(buf, "flag_%s.png", buf2);
|
|
|
|
|
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
treeview_helper_insert_icon(ls, &iter, 0, buf);
|
|
|
|
gtk_list_store_set(ls, &iter, 1,
|
2005-10-05 21:59:37 +02:00
|
|
|
(gchar*)g_ptr_array_index(country_list, i), -1);
|
2005-05-07 16:19:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return GTK_TREE_MODEL(ls);
|
|
|
|
}
|
2005-05-22 15:33:24 +02:00
|
|
|
|
|
|
|
/** Show the list of contributors in the help window.*/
|
|
|
|
void
|
2006-02-15 13:03:48 +01:00
|
|
|
treeview_show_contributors(GtkTreeView *treeview)
|
2005-05-22 15:33:24 +02:00
|
|
|
{
|
2006-02-15 13:03:48 +01:00
|
|
|
gchar *help_file = file_find_support_file("bygfoot_help", TRUE);
|
|
|
|
OptionList help_list;
|
2005-05-22 15:33:24 +02:00
|
|
|
GtkListStore *ls = gtk_list_store_new(1, G_TYPE_STRING);
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeViewColumn *col;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
gint i;
|
|
|
|
gchar buf[SMALL];
|
|
|
|
|
2006-02-15 13:03:48 +01:00
|
|
|
|
|
|
|
if(help_file == NULL)
|
|
|
|
{
|
|
|
|
game_gui_show_warning(_("Didn't find file 'bygfoot_help'."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
help_list.list = NULL;
|
|
|
|
help_list.datalist = NULL;
|
|
|
|
file_load_opt_file(help_file, &help_list);
|
|
|
|
|
2005-05-22 15:33:24 +02:00
|
|
|
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview),
|
|
|
|
GTK_SELECTION_NONE);
|
|
|
|
gtk_tree_view_set_rules_hint(treeview, FALSE);
|
|
|
|
gtk_tree_view_set_headers_visible(treeview, FALSE);
|
|
|
|
|
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_append_column(treeview, col);
|
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
|
|
|
"markup", 0);
|
|
|
|
|
2006-02-15 13:03:48 +01:00
|
|
|
for(i=0;i<help_list.list->len;i++)
|
2005-05-22 15:33:24 +02:00
|
|
|
{
|
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
|
2006-02-15 13:03:48 +01:00
|
|
|
if(g_str_has_prefix(g_array_index(help_list.list, Option, i).name,
|
2005-05-22 15:33:24 +02:00
|
|
|
"string_contrib_title"))
|
|
|
|
{
|
|
|
|
sprintf(buf, "\n<span %s>%s</span>",
|
|
|
|
const_app("string_help_window_title_attribute"),
|
2006-02-15 13:03:48 +01:00
|
|
|
g_array_index(help_list.list, Option, i).string_value);
|
2005-05-22 15:33:24 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 0, buf, -1);
|
|
|
|
}
|
2006-02-15 13:03:48 +01:00
|
|
|
else if(g_str_has_prefix(g_array_index(help_list.list, Option, i).name,
|
2005-05-22 15:33:24 +02:00
|
|
|
"string_contrib_"))
|
|
|
|
{
|
2006-02-15 13:03:48 +01:00
|
|
|
strcpy(buf, g_array_index(help_list.list, Option, i).string_value);
|
2005-05-22 15:33:24 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 0, buf, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(ls));
|
|
|
|
g_object_unref(ls);
|
2006-02-15 13:03:48 +01:00
|
|
|
|
|
|
|
g_free(help_file);
|
|
|
|
free_option_list(&help_list, FALSE);
|
2005-05-22 15:33:24 +02:00
|
|
|
}
|
2005-06-11 18:54:59 +02:00
|
|
|
|
|
|
|
GtkTreeModel*
|
|
|
|
treeview_create_league_list(void)
|
|
|
|
{
|
|
|
|
gint i;
|
2005-06-14 10:02:46 +02:00
|
|
|
GtkListStore *ls = gtk_list_store_new(1, G_TYPE_STRING);
|
2005-06-11 18:54:59 +02:00
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
gtk_list_store_append(ls, &iter);
|
2005-06-14 10:02:46 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 0, _("Current league"), -1);
|
2005-06-11 18:54:59 +02:00
|
|
|
|
|
|
|
for(i=0;i<ligs->len;i++)
|
|
|
|
{
|
|
|
|
gtk_list_store_append(ls, &iter);
|
2005-10-09 11:35:44 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 0, lig(i).name, -1);
|
2005-06-11 18:54:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return GTK_TREE_MODEL(ls);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Show the league list in the combo box
|
|
|
|
in the startup window. */
|
|
|
|
void
|
|
|
|
treeview_show_leagues_combo(void)
|
|
|
|
{
|
|
|
|
GtkTreeModel *model = treeview_create_league_list();
|
|
|
|
GtkComboBox *combo_leagues =
|
|
|
|
GTK_COMBO_BOX(lookup_widget(window.startup, "comboboxentry_start_league"));
|
|
|
|
GtkCellRenderer *renderer = NULL;
|
|
|
|
|
|
|
|
gtk_combo_box_set_model(combo_leagues, model);
|
|
|
|
g_object_unref(model);
|
|
|
|
|
|
|
|
gtk_cell_layout_clear(GTK_CELL_LAYOUT(combo_leagues));
|
|
|
|
|
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
|
|
|
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo_leagues), renderer, FALSE);
|
|
|
|
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_leagues), renderer, "text", 0, NULL);
|
|
|
|
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_leagues), 0);
|
|
|
|
}
|
2005-06-14 17:27:44 +02:00
|
|
|
|
|
|
|
GtkTreeModel*
|
|
|
|
treeview_create_language_list(void)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
GtkListStore *ls = gtk_list_store_new(2, GDK_TYPE_PIXBUF, G_TYPE_STRING);
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GPtrArray *names =
|
|
|
|
misc_separate_strings(const_str("string_language_names"));
|
|
|
|
GPtrArray *symbols =
|
|
|
|
misc_separate_strings(const_str("string_language_symbols"));
|
|
|
|
|
|
|
|
gtk_list_store_append(ls, &iter);
|
2005-06-26 13:42:01 +02:00
|
|
|
/* Language is system-set (not user chosen). */
|
2005-06-14 17:27:44 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 0, NULL, 1, _("System"), -1);
|
|
|
|
|
|
|
|
for(i=0;i<names->len;i++)
|
|
|
|
{
|
|
|
|
gtk_list_store_append(ls, &iter);
|
2005-10-05 21:59:37 +02:00
|
|
|
treeview_helper_insert_icon(ls, &iter, 0, (gchar*)g_ptr_array_index(symbols, i));
|
2005-06-14 17:27:44 +02:00
|
|
|
gtk_list_store_set(ls, &iter, 1,
|
2005-10-05 21:59:37 +02:00
|
|
|
(gchar*)g_ptr_array_index(names, i), -1);
|
2005-06-14 17:27:44 +02:00
|
|
|
}
|
|
|
|
|
2005-10-05 21:59:37 +02:00
|
|
|
free_gchar_array(&names);
|
|
|
|
free_gchar_array(&symbols);
|
2005-06-14 17:27:44 +02:00
|
|
|
|
|
|
|
return GTK_TREE_MODEL(ls);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Show the list of available languages. */
|
|
|
|
void
|
|
|
|
treeview_show_language_combo(void)
|
|
|
|
{
|
|
|
|
GtkTreeModel *model = treeview_create_language_list();
|
|
|
|
GtkComboBox *combo_languages =
|
2005-09-12 23:01:35 +02:00
|
|
|
GTK_COMBO_BOX(lookup_widget(window.options, "combobox_languages"));
|
2005-06-14 17:27:44 +02:00
|
|
|
GtkCellRenderer *renderer = NULL;
|
|
|
|
gint idx = language_get_current_index();
|
|
|
|
|
|
|
|
gtk_cell_layout_clear(GTK_CELL_LAYOUT(combo_languages));
|
|
|
|
|
|
|
|
renderer = gtk_cell_renderer_pixbuf_new();
|
|
|
|
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo_languages), renderer, FALSE);
|
|
|
|
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_languages), renderer, "pixbuf", 0, NULL);
|
|
|
|
|
|
|
|
renderer = treeview_helper_cell_renderer_text_new();
|
|
|
|
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo_languages), renderer, FALSE);
|
|
|
|
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_languages), renderer, "text", 1, NULL);
|
|
|
|
|
2005-09-12 23:01:35 +02:00
|
|
|
gtk_combo_box_set_model(combo_languages, model);
|
|
|
|
g_object_unref(model);
|
|
|
|
|
2005-06-14 17:27:44 +02:00
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_languages), idx + 1);
|
|
|
|
}
|
2005-06-20 14:46:57 +02:00
|
|
|
|
|
|
|
GtkTreeModel*
|
|
|
|
treeview_create_sponsors(const GArray *sponsors)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
GtkListStore *ls = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_INT,
|
|
|
|
G_TYPE_INT);
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
for(i=0;i<sponsors->len;i++)
|
|
|
|
{
|
|
|
|
gtk_list_store_append(ls, &iter);
|
|
|
|
gtk_list_store_set(ls, &iter,
|
|
|
|
0, g_array_index(sponsors, UserSponsor, i).name->str,
|
|
|
|
1, g_array_index(sponsors, UserSponsor, i).contract / 4,
|
|
|
|
2, g_array_index(sponsors, UserSponsor, i).benefit,
|
|
|
|
-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=1;i<3;i++)
|
|
|
|
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), i,
|
|
|
|
treeview_helper_int_compare, GINT_TO_POINTER(i), NULL);
|
|
|
|
|
|
|
|
return GTK_TREE_MODEL(ls);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
treeview_set_up_sponsors(GtkTreeView *treeview)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
GtkTreeViewColumn *col;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
gchar *titles[3] =
|
|
|
|
{_("Company"),
|
|
|
|
_("Contract length\n(Months)"),
|
|
|
|
_("Money / week")};
|
|
|
|
|
|
|
|
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview),
|
|
|
|
GTK_SELECTION_BROWSE);
|
|
|
|
gtk_tree_view_set_rules_hint(treeview, TRUE);
|
|
|
|
gtk_tree_view_set_headers_visible(treeview, TRUE);
|
|
|
|
|
|
|
|
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_helper_cell_renderer_text_new();
|
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, renderer,
|
|
|
|
"markup", i);
|
|
|
|
|
|
|
|
if(i > 0)
|
|
|
|
{
|
|
|
|
g_object_set(renderer, "xalign", 0.5, NULL);
|
|
|
|
gtk_tree_view_column_set_sort_column_id(col, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Show a list of sponsor offers. */
|
|
|
|
void
|
|
|
|
treeview_show_sponsors(const GArray *sponsors)
|
|
|
|
{
|
|
|
|
GtkTreeView *treeview = GTK_TREE_VIEW(lookup_widget(window.sponsors,
|
|
|
|
"treeview_sponsors"));
|
|
|
|
GtkTreeModel *model = treeview_create_sponsors(sponsors);
|
|
|
|
GtkTreePath *path = gtk_tree_path_new_from_string("0");
|
|
|
|
|
|
|
|
treeview_helper_clear(treeview);
|
|
|
|
|
|
|
|
treeview_set_up_sponsors(treeview);
|
|
|
|
gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(model));
|
|
|
|
gtk_tree_selection_select_path(gtk_tree_view_get_selection(treeview), path);
|
|
|
|
g_object_unref(model);
|
|
|
|
gtk_tree_path_free(path);
|
|
|
|
}
|