4
Bygfoot Football Manager -- a small and simple GTK2-based
5
football management game.
7
http://bygfoot.sourceforge.net
9
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
11
This program is free software; you can redistribute it and/or
12
modify it under the terms of the GNU General Public License
13
as published by the Free Software Foundation; either version 2
14
of the License, or (at your option) any later version.
16
This program is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
GNU General Public License for more details.
21
You should have received a copy of the GNU General Public License
22
along with this program; if not, write to the Free Software
23
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2
28
#include "finance.h"
3
29
#include "fixture.h"
6
33
#include "language.h"
8
35
#include "live_game.h"
100
127
gtk_tree_view_set_headers_visible(treeview, TRUE);
101
128
gtk_tree_view_set_rules_hint(treeview, TRUE);
130
gtk_tree_view_set_search_column(treeview, 2);
131
gtk_tree_view_set_search_equal_func(treeview,
132
treeview_helper_search_equal,
103
135
/* Numbering the teams */
104
136
col = gtk_tree_view_column_new();
105
137
gtk_tree_view_append_column(treeview, col);
716
fixture_result_to_buf(live_game->fix, buf[0], FALSE);
748
if(live_game->fix != NULL)
749
fixture_result_to_buf(live_game->fix, buf[0], FALSE);
753
g_array_index(live_game->units, LiveGameUnit, live_game->units->len - 1).
755
g_array_index(live_game->units, LiveGameUnit, live_game->units->len - 1).
717
757
gtk_list_store_append(ls, &iter);
718
gtk_list_store_set(ls, &iter, 0, live_game->fix->teams[0]->name,
758
gtk_list_store_set(ls, &iter, 0, live_game->team_names[0],
720
2, live_game->fix->teams[1]->name,
760
2, live_game->team_names[1],
723
763
for(k=0;k<LIVE_GAME_STAT_ARRAY_END;k++)
762
misc_print_grouped_int(live_game->fix->attendance, buf[0]);
802
misc_print_grouped_int(live_game->attendance, buf[0]);
763
803
sprintf(buf[1], _("Attendance\n%s"), buf[0]);
764
804
gtk_list_store_append(ls, &iter);
765
805
gtk_list_store_set(ls, &iter, 0, buf[1], 1, "", 2, "", -1);
906
946
gchar *symbol[2] = {NULL, NULL};
907
947
gchar buf_result[SMALL], buf[3][SMALL];
908
948
gchar *colour_fg = NULL, *colour_bg = NULL;
949
gint user_idx = fixture_user_team_involved(fix);
910
951
if(fix->clid >= ID_CUP_START &&
911
952
query_cup_is_international(fix->clid))
913
954
symbol[i] = fix->teams[i]->symbol;
915
if(fixture_user_team_involved(fix) != -1)
916
treeview_helper_set_user_colours(usr(fixture_user_team_involved(fix)).tm,
957
treeview_helper_set_user_colours(usr(user_idx).tm->name,
917
958
&colour_bg, &colour_fg);
1122
1163
colour_bg, colour_fg, i + 1);
1124
1165
treeview_helper_get_table_element_colours(table, i, &colour_fg, &colour_bg, TRUE);
1125
sprintf(buf[1], "<span background='%s' foreground='%s'>%s</span>",
1126
colour_bg, colour_fg, elem->team->name);
1167
sprintf(buf[1], "<span background='%s' foreground='%s'>%s</span>",
1168
colour_bg, colour_fg, elem->team->name);
1170
sprintf(buf[1], "<span background='%s' foreground='%s'>%s (%s)</span>",
1171
colour_bg, colour_fg, elem->team->name, elem->team->strategy_sid);
1128
1173
gtk_list_store_set(ls, &iter, 1, buf[0], 3, buf[1], -1);
1327
1376
gtk_list_store_append(ls, &iter);
1328
1377
/* Finances balance. */
1329
gtk_list_store_set(ls, &iter, 0, _("Bi-weekly balance"), 1, "", 2, "", -1);
1381
sprintf(buf, _("Bi-weekly balance\n(Week %d and %d)"),
1382
week - 2, week - 1);
1384
sprintf(buf, _("Bi-weekly balance\n(Week %d and %d)"),
1385
week - 3, week - 2);
1388
strcpy(buf, _("Bi-weekly balance"));
1390
gtk_list_store_set(ls, &iter, 0, buf, 1, "", 2, "", -1);
1331
1392
for(i=0;i<MON_IN_TRANSFERS;i++)
1545
1606
if(opp == NULL)
1609
ls = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
1548
1611
if(fix->clid < ID_CUP_START)
1549
1612
strcpy(buf, league_cup_get_name_string(fix->clid));
1988
2051
gtk_list_store_set(ls, &iter,
1989
2052
0, g_array_index(current_user.history, UserHistory, i).season,
1990
2053
1, g_array_index(current_user.history, UserHistory, i).week,
1991
2, team_of_id(g_array_index(current_user.history, UserHistory, i).team_id)->name,
2054
2, g_array_index(current_user.history, UserHistory, i).team_name,
2077
2140
gchar *colour_fg = NULL, *colour_bg = NULL;
2079
2142
gtk_list_store_append(ls, &iter);
2080
treeview_helper_insert_icon(ls, &iter, 0, league_from_clid(league_stat->clid)->symbol);
2143
treeview_helper_insert_icon(ls, &iter, 0,
2144
league_stat->league_symbol);
2081
2145
gtk_list_store_set(ls, &iter, 1, const_int("int_treeview_helper_int_empty"),
2082
2, league_cup_get_name_string(league_stat->clid), 3, "", 4, "", 5, "", -1);
2146
2, league_stat->league_name, 3, "", 4, "", 5, "", -1);
2084
2148
for(i=0;i<2;i++)
2099
2163
g_array_index(teams[i], Stat, j).value1,
2100
2164
g_array_index(teams[i], Stat, j).value2);
2102
treeview_helper_set_user_colours(team_of_id(g_array_index(teams[i], Stat, j).team_id),
2103
&colour_bg, &colour_fg);
2166
treeview_helper_set_user_colours(
2167
g_array_index(teams[i], Stat, j).team_name,
2168
&colour_bg, &colour_fg);
2105
2170
sprintf(buf2, "<span background='%s' foreground='%s'>%s</span>",
2106
colour_bg, colour_fg, team_of_id(g_array_index(teams[i], Stat, j).team_id)->name);
2171
colour_bg, colour_fg,
2172
g_array_index(teams[i], Stat, j).team_name);
2108
2174
gtk_list_store_append(ls, &iter);
2109
2175
gtk_list_store_set(ls, &iter, 0, NULL, 1, j + 1,
2141
2207
100 * (1 - (gfloat)g_array_index(players[i], Stat, j).value1 /
2142
2208
(gfloat)g_array_index(players[i], Stat, j).value3) : 0);
2144
treeview_helper_set_user_colours(team_of_id(g_array_index(players[i], Stat, j).team_id),
2145
&colour_bg, &colour_fg);
2210
treeview_helper_set_user_colours(
2211
g_array_index(players[i], Stat, j).team_name,
2212
&colour_bg, &colour_fg);
2146
2213
sprintf(buf3, "<span background='%s' foreground='%s'>%s (%s)</span>",
2147
2214
colour_bg, colour_fg,
2148
2215
g_array_index(players[i], Stat, j).value_string,
2149
team_of_id(g_array_index(players[i], Stat, j).team_id)->name);
2216
g_array_index(players[i], Stat, j).team_name);
2150
2217
sprintf(buf4, "%d", g_array_index(players[i], Stat, j).value1);
2152
2219
gtk_list_store_append(ls, &iter);
2251
/** Show the season history of the specified season
2252
and the specified page. Page is either a page of league stats
2318
/** Show the season history with given index in the season_stats array
2319
and the specified page.
2320
@param page Either a page of league stats
2253
2321
(if != -1) or -1 which means we show the champions. */
2255
treeview_show_season_history(gint page, gint season_number)
2323
treeview_show_season_history(gint page, gint idx)
2257
2325
gchar buf[SMALL];
2258
2326
GtkTreeView *treeview = GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right"));
2260
2328
gtk_list_store_new(6, GDK_TYPE_PIXBUF, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING,
2261
2329
G_TYPE_STRING, G_TYPE_STRING);
2262
2330
GtkTreeIter iter;
2263
SeasonStat *stat = &g_array_index(season_stats, SeasonStat, season_number);
2331
SeasonStat *stat = &g_array_index(season_stats, SeasonStat, idx);
2265
2333
treeview_helper_clear(treeview);
2267
2335
treeview_set_up_league_stats(treeview);
2269
sprintf(buf, _("Season %d"), season_number + 1);
2337
sprintf(buf, _("Season %d"), stat->season_number);
2270
2338
gtk_list_store_append(model, &iter);
2271
2339
gtk_list_store_set(model, &iter, 0, NULL,
2272
2340
1, const_int("int_treeview_helper_int_empty"),
2276
treeview_create_league_stats(model,
2277
&g_array_index(stat->league_stats, LeagueStat, page));
2344
treeview_create_league_stats(
2345
model, &g_array_index(stat->league_stats, LeagueStat, page));
2279
treeview_create_season_history_champions(model, stat->league_champs,
2347
treeview_create_season_history_champions(
2348
model, stat->league_champs, stat->cup_champs);
2282
2350
gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(model));
2283
2351
g_object_unref(model);
2311
2379
/** Show the list of contributors in the help window.*/
2313
treeview_show_contributors(const OptionList *help_list)
2381
treeview_show_contributors(GtkTreeView *treeview)
2315
GtkTreeView *treeview = GTK_TREE_VIEW(lookup_widget(window.help, "treeview_contributors"));
2383
gchar *help_file = file_find_support_file("bygfoot_help", TRUE);
2384
OptionList help_list;
2316
2385
GtkListStore *ls = gtk_list_store_new(1, G_TYPE_STRING);
2317
2386
GtkTreeIter iter;
2318
2387
GtkTreeViewColumn *col;
2321
2390
gchar buf[SMALL];
2393
if(help_file == NULL)
2395
game_gui_show_warning(_("Didn't find file 'bygfoot_help'."));
2399
help_list.list = NULL;
2400
help_list.datalist = NULL;
2401
file_load_opt_file(help_file, &help_list);
2323
2403
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview),
2324
2404
GTK_SELECTION_NONE);
2325
2405
gtk_tree_view_set_rules_hint(treeview, FALSE);
2332
2412
gtk_tree_view_column_add_attribute(col, renderer,
2335
for(i=0;i<help_list->list->len;i++)
2415
for(i=0;i<help_list.list->len;i++)
2337
2417
gtk_list_store_append(ls, &iter);
2339
if(g_str_has_prefix(g_array_index(help_list->list, Option, i).name,
2419
if(g_str_has_prefix(g_array_index(help_list.list, Option, i).name,
2340
2420
"string_contrib_title"))
2342
2422
sprintf(buf, "\n<span %s>%s</span>",
2343
2423
const_app("string_help_window_title_attribute"),
2344
g_array_index(help_list->list, Option, i).string_value);
2424
g_array_index(help_list.list, Option, i).string_value);
2345
2425
gtk_list_store_set(ls, &iter, 0, buf, -1);
2347
else if(g_str_has_prefix(g_array_index(help_list->list, Option, i).name,
2427
else if(g_str_has_prefix(g_array_index(help_list.list, Option, i).name,
2348
2428
"string_contrib_"))
2350
strcpy(buf, g_array_index(help_list->list, Option, i).string_value);
2430
strcpy(buf, g_array_index(help_list.list, Option, i).string_value);
2351
2431
gtk_list_store_set(ls, &iter, 0, buf, -1);