mirror of
https://github.com/tstellar/bygfoot.git
synced 2025-01-10 22:14:07 +01:00
Restructured treeview source files.
This commit is contained in:
parent
c852e415c3
commit
10206f76b8
@ -1,582 +0,0 @@
|
||||
#include "cup.h"
|
||||
#include "league.h"
|
||||
#include "misc.h"
|
||||
#include "option.h"
|
||||
#include "player.h"
|
||||
#include "team.h"
|
||||
#include "treeview.h"
|
||||
#include "treeview_cell.h"
|
||||
#include "user.h"
|
||||
#include "variables.h"
|
||||
|
||||
/** Render a cell in the team selection treeview.
|
||||
@see The GTK reference. */
|
||||
void
|
||||
treeview_cell_team_selection(GtkTreeViewColumn *col,
|
||||
GtkCellRenderer *renderer,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data)
|
||||
{
|
||||
gchar buf[SMALL];
|
||||
gint column = treeview_get_col_number_column(col);
|
||||
gpointer team_pointer;
|
||||
|
||||
gtk_tree_model_get(model, iter, column, &team_pointer, -1);
|
||||
|
||||
if(column == 2)
|
||||
g_object_set(renderer, "text", ((Team*)team_pointer)->name->str, NULL);
|
||||
else if(column == 4)
|
||||
{
|
||||
sprintf(buf, "%.1f", team_get_average_skill((Team*)team_pointer, FALSE));
|
||||
g_object_set(renderer, "text", buf, NULL);
|
||||
}
|
||||
else
|
||||
g_warning("treeview_cell_team_selection: unknown column: %d\n", column);
|
||||
}
|
||||
|
||||
/** Render an integer. This is only so that we know when to draw nothing. */
|
||||
void
|
||||
treeview_cell_int_to_cell(GtkTreeViewColumn *col,
|
||||
GtkCellRenderer *renderer,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data)
|
||||
{
|
||||
gint column = treeview_get_col_number_column(col);
|
||||
gint value;
|
||||
gchar buf[SMALL];
|
||||
|
||||
gtk_tree_model_get(model, iter, column, &value, -1);
|
||||
|
||||
if(value == const_int("int_treeview_cell_int_empty"))
|
||||
strcpy(buf, "");
|
||||
else
|
||||
sprintf(buf, "%d", value);
|
||||
|
||||
g_object_set(renderer, "text", buf, NULL);
|
||||
}
|
||||
|
||||
/** Render a cell in the player info view. */
|
||||
void
|
||||
treeview_cell_player_ext_info_to_cell(GtkTreeViewColumn *col,
|
||||
GtkCellRenderer *renderer,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data)
|
||||
{
|
||||
gint column = treeview_get_col_number_column(col);
|
||||
gint row_idx = treeview_iter_get_row(model, iter);
|
||||
const Player *pl;
|
||||
|
||||
g_object_set(renderer, "text", "", "foreground",
|
||||
const_str("string_treeview_cell_color_default_foreground"),
|
||||
"background",
|
||||
const_str("string_treeview_cell_color_default_background"), NULL);
|
||||
|
||||
gtk_tree_model_get(model, iter, column, &pl, -1);
|
||||
|
||||
if(pl == NULL)
|
||||
return;
|
||||
|
||||
switch(row_idx)
|
||||
{
|
||||
default:
|
||||
g_warning("treeview_cell_player_ext_info_to_cell: unknown row index %d\n",
|
||||
row_idx);
|
||||
break;
|
||||
case PLAYER_INFO_ATTRIBUTE_NAME:
|
||||
treeview_cell_player_to_cell(col, renderer, model,
|
||||
iter, GINT_TO_POINTER(PLAYER_LIST_ATTRIBUTE_NAME));
|
||||
break;
|
||||
case PLAYER_INFO_ATTRIBUTE_POS:
|
||||
treeview_cell_player_to_cell(col, renderer, model,
|
||||
iter, GINT_TO_POINTER(PLAYER_LIST_ATTRIBUTE_POS));
|
||||
break;
|
||||
case PLAYER_INFO_ATTRIBUTE_CPOS:
|
||||
treeview_cell_player_to_cell(col, renderer, model,
|
||||
iter, GINT_TO_POINTER(PLAYER_LIST_ATTRIBUTE_CPOS));
|
||||
break;
|
||||
case PLAYER_INFO_ATTRIBUTE_SKILL:
|
||||
treeview_cell_player_to_cell(col, renderer, model,
|
||||
iter, GINT_TO_POINTER(PLAYER_LIST_ATTRIBUTE_SKILL));
|
||||
break;
|
||||
case PLAYER_INFO_ATTRIBUTE_CSKILL:
|
||||
treeview_cell_player_to_cell(col, renderer, model,
|
||||
iter, GINT_TO_POINTER(PLAYER_LIST_ATTRIBUTE_CSKILL));
|
||||
break;
|
||||
case PLAYER_INFO_ATTRIBUTE_FITNESS:
|
||||
treeview_cell_player_to_cell(col, renderer, model,
|
||||
iter, GINT_TO_POINTER(PLAYER_LIST_ATTRIBUTE_FITNESS));
|
||||
break;
|
||||
case PLAYER_INFO_ATTRIBUTE_ETAL:
|
||||
treeview_cell_player_to_cell(col, renderer, model,
|
||||
iter, GINT_TO_POINTER(PLAYER_LIST_ATTRIBUTE_ETAL));
|
||||
break;
|
||||
case PLAYER_INFO_ATTRIBUTE_AGE:
|
||||
treeview_cell_player_to_cell(col, renderer, model,
|
||||
iter, GINT_TO_POINTER(PLAYER_LIST_ATTRIBUTE_AGE));
|
||||
break;
|
||||
case PLAYER_INFO_ATTRIBUTE_VALUE:
|
||||
treeview_cell_player_to_cell(col, renderer, model,
|
||||
iter, GINT_TO_POINTER(PLAYER_LIST_ATTRIBUTE_VALUE));
|
||||
break;
|
||||
case PLAYER_INFO_ATTRIBUTE_WAGE:
|
||||
treeview_cell_player_to_cell(col, renderer, model,
|
||||
iter, GINT_TO_POINTER(PLAYER_LIST_ATTRIBUTE_WAGE));
|
||||
break;
|
||||
case PLAYER_INFO_ATTRIBUTE_CONTRACT:
|
||||
treeview_cell_player_to_cell(col, renderer, model,
|
||||
iter, GINT_TO_POINTER(PLAYER_LIST_ATTRIBUTE_CONTRACT));
|
||||
break;
|
||||
case PLAYER_INFO_ATTRIBUTE_HEALTH:
|
||||
treeview_cell_player_info_health_to_cell(renderer, pl);
|
||||
break;
|
||||
case PLAYER_INFO_ATTRIBUTE_GAMES_GOALS:
|
||||
treeview_cell_player_info_games_goals_to_cell(renderer, pl->games_goals);
|
||||
break;
|
||||
case PLAYER_INFO_ATTRIBUTE_YELLOW_CARDS:
|
||||
treeview_cell_player_info_yellow_to_cell(renderer, pl->cards);
|
||||
break;
|
||||
case PLAYER_INFO_ATTRIBUTE_BANNED:
|
||||
treeview_cell_player_info_banned_to_cell(renderer, pl->cards);
|
||||
break;
|
||||
case PLAYER_INFO_ATTRIBUTE_OFFERS:
|
||||
if(pl->offers > 0)
|
||||
g_object_set(renderer, "text", _("Player doesn't negotiate anymore"), NULL);
|
||||
else
|
||||
g_object_set(renderer, "text", _("Player accepts new offers"), NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
treeview_cell_player_info_banned_to_cell(GtkCellRenderer *renderer, const GArray *cards)
|
||||
{
|
||||
gint i;
|
||||
gchar buf[SMALL], buf2[SMALL];
|
||||
|
||||
strcpy(buf, "");
|
||||
|
||||
for(i=0;i<cards->len;i++)
|
||||
if(g_array_index(cards, PlayerCard, i).red > 0)
|
||||
{
|
||||
sprintf(buf2, "%s: %d weeks\n",
|
||||
league_cup_get_name_string(g_array_index(cards, PlayerCard, i).clid),
|
||||
g_array_index(cards, PlayerCard, i).red);
|
||||
strcat(buf, buf2);
|
||||
}
|
||||
|
||||
g_object_set(renderer, "text", buf, NULL);
|
||||
|
||||
if(strlen(buf) > 0)
|
||||
g_object_set(renderer, "background",
|
||||
const_str("string_treeview_cell_color_player_banned"), NULL);
|
||||
}
|
||||
|
||||
void
|
||||
treeview_cell_player_info_yellow_to_cell(GtkCellRenderer *renderer, const GArray *cards)
|
||||
{
|
||||
gint i;
|
||||
gint yellow_red = -1;
|
||||
gchar buf[SMALL], buf2[SMALL];
|
||||
|
||||
strcpy(buf, "");
|
||||
|
||||
for(i=0;i<cards->len;i++)
|
||||
{
|
||||
yellow_red = league_cup_get_yellow_red(g_array_index(cards, PlayerCard, i).clid);
|
||||
|
||||
if(g_array_index(cards, PlayerCard, i).yellow > 0)
|
||||
{
|
||||
if(yellow_red < 1000)
|
||||
{
|
||||
sprintf(buf2, "%s: %d (%d)\n",
|
||||
league_cup_get_name_string(g_array_index(cards, PlayerCard, i).clid),
|
||||
g_array_index(cards, PlayerCard, i).yellow, yellow_red);
|
||||
}
|
||||
else
|
||||
sprintf(buf2, "%s: %d (no limit)\n",
|
||||
league_cup_get_name_string(g_array_index(cards, PlayerCard, i).clid),
|
||||
g_array_index(cards, PlayerCard, i).yellow);
|
||||
|
||||
strcat(buf, buf2);
|
||||
}
|
||||
}
|
||||
|
||||
g_object_set(renderer, "text", buf, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
treeview_cell_player_info_games_goals_to_cell(GtkCellRenderer *renderer, const GArray *games_goals)
|
||||
{
|
||||
gint i;
|
||||
gchar buf[SMALL], buf2[SMALL];
|
||||
|
||||
strcpy(buf, "");
|
||||
|
||||
for(i=0;i<games_goals->len;i++)
|
||||
{
|
||||
sprintf(buf2, "%s: %d/%d\n",
|
||||
league_cup_get_name_string(g_array_index(games_goals, PlayerGamesGoals, i).clid),
|
||||
g_array_index(games_goals, PlayerGamesGoals, i).games,
|
||||
g_array_index(games_goals, PlayerGamesGoals, i).goals);
|
||||
strcat(buf, buf2);
|
||||
}
|
||||
|
||||
g_object_set(renderer, "text", buf, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
treeview_cell_player_info_health_to_cell(GtkCellRenderer *renderer, const Player *pl)
|
||||
{
|
||||
gchar buf[SMALL];
|
||||
|
||||
if(pl->health != 0)
|
||||
{
|
||||
sprintf(buf, "%s (expected recovery in %d weeks)",
|
||||
player_injury_to_char(pl->health), pl->recovery);
|
||||
g_object_set(renderer, "background",
|
||||
const_str("string_treeview_cell_color_player_injury"), NULL);
|
||||
}
|
||||
else
|
||||
strcpy(buf, "OK");
|
||||
|
||||
g_object_set(renderer, "text", buf, NULL);
|
||||
}
|
||||
|
||||
/** Render a player list cell. */
|
||||
void
|
||||
treeview_cell_player_to_cell(GtkTreeViewColumn *col,
|
||||
GtkCellRenderer *renderer,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data)
|
||||
{
|
||||
gint column = treeview_get_col_number_column(col);
|
||||
gint attribute = GPOINTER_TO_INT(user_data);
|
||||
gchar buf[SMALL];
|
||||
const Player *pl;
|
||||
|
||||
g_object_set(renderer, "text", "", "foreground",
|
||||
const_str("string_treeview_cell_color_default_foreground"),
|
||||
"background",
|
||||
const_str("string_treeview_cell_color_default_background"), NULL);
|
||||
strcpy(buf, "");
|
||||
|
||||
gtk_tree_model_get(model, iter, column, &pl, -1);
|
||||
|
||||
if(pl == NULL)
|
||||
return;
|
||||
|
||||
switch(attribute)
|
||||
{
|
||||
default:
|
||||
g_warning("treeview_cell_player_to_cell: unknown attribute %d.\n", attribute);
|
||||
break;
|
||||
case PLAYER_LIST_ATTRIBUTE_NAME:
|
||||
strcpy(buf, pl->name->str);
|
||||
if(pl->team == current_user.tm &&
|
||||
opt_user_int("int_opt_user_penalty_shooter") == pl->id)
|
||||
strcat(buf, _(" (P)"));
|
||||
break;
|
||||
case PLAYER_LIST_ATTRIBUTE_CPOS:
|
||||
treeview_cell_player_pos_to_cell(renderer, buf, pl->cpos);
|
||||
break;
|
||||
case PLAYER_LIST_ATTRIBUTE_POS:
|
||||
treeview_cell_player_pos_to_cell(renderer, buf, pl->pos);
|
||||
break;
|
||||
case PLAYER_LIST_ATTRIBUTE_CSKILL:
|
||||
treeview_cell_player_cskill_to_cell(renderer, buf, pl);
|
||||
break;
|
||||
case PLAYER_LIST_ATTRIBUTE_SKILL:
|
||||
sprintf(buf, "%.*f", opt_int("int_opt_player_precision"), pl->skill);
|
||||
break;
|
||||
case PLAYER_LIST_ATTRIBUTE_FITNESS:
|
||||
treeview_cell_player_fitness_to_cell(renderer, buf, pl->fitness);
|
||||
break;
|
||||
case PLAYER_LIST_ATTRIBUTE_GAMES:
|
||||
treeview_cell_player_games_goals_to_cell(buf, pl, PLAYER_VALUE_GAMES);
|
||||
break;
|
||||
case PLAYER_LIST_ATTRIBUTE_GOALS:
|
||||
treeview_cell_player_games_goals_to_cell(buf, pl, PLAYER_VALUE_GOALS);
|
||||
break;
|
||||
case PLAYER_LIST_ATTRIBUTE_SHOTS:
|
||||
treeview_cell_player_games_goals_to_cell(buf, pl, PLAYER_VALUE_SHOTS);
|
||||
break;
|
||||
case PLAYER_LIST_ATTRIBUTE_STATUS:
|
||||
treeview_cell_player_status_to_cell(renderer, buf, pl);
|
||||
break;
|
||||
case PLAYER_LIST_ATTRIBUTE_CARDS:
|
||||
treeview_cell_player_cards_to_cell(buf, pl);
|
||||
break;
|
||||
case PLAYER_LIST_ATTRIBUTE_AGE:
|
||||
sprintf(buf, "%.*f", opt_int("int_opt_player_precision"), pl->age);
|
||||
break;
|
||||
case PLAYER_LIST_ATTRIBUTE_ETAL:
|
||||
sprintf(buf, "%.*f", opt_int("int_opt_player_precision"),
|
||||
pl->etal[current_user.scout % 10]);
|
||||
break;
|
||||
case PLAYER_LIST_ATTRIBUTE_VALUE:
|
||||
misc_print_grouped_int(pl->value, buf, FALSE);
|
||||
break;
|
||||
case PLAYER_LIST_ATTRIBUTE_WAGE:
|
||||
misc_print_grouped_int(pl->wage, buf, FALSE);
|
||||
break;
|
||||
case PLAYER_LIST_ATTRIBUTE_CONTRACT:
|
||||
treeview_cell_player_contract_to_cell(renderer, buf, pl->contract);
|
||||
break;
|
||||
case PLAYER_LIST_ATTRIBUTE_TEAM:
|
||||
sprintf(buf, "%s", pl->team->name->str);
|
||||
break;
|
||||
case PLAYER_LIST_ATTRIBUTE_LEAGUE_CUP:
|
||||
team_get_league_cup_string(pl->team, LEAGUE_CUP_VALUE_NAME, buf);
|
||||
break;
|
||||
}
|
||||
|
||||
g_object_set(renderer, "text", buf, NULL);
|
||||
}
|
||||
|
||||
/** Render a cell of a player contract.
|
||||
@param renderer The cell renderer.
|
||||
@param buf The string the cell will contain.
|
||||
@param contract_time The contract time in weeks. */
|
||||
void
|
||||
treeview_cell_player_contract_to_cell(GtkCellRenderer *renderer, gchar *buf, gfloat contract_time)
|
||||
{
|
||||
sprintf(buf, "%.*f", 1 + opt_int("int_opt_player_precision"),
|
||||
contract_time);
|
||||
|
||||
if(contract_time < const_float("float_treeview_cell_limit_player_contract_below3"))
|
||||
g_object_set(renderer, "foreground",
|
||||
const_str("string_treeview_cell_color_player_contract_below3"), NULL);
|
||||
else if(contract_time < const_float("float_treeview_cell_limit_player_contract_below2"))
|
||||
g_object_set(renderer, "foreground",
|
||||
const_str("string_treeview_cell_color_player_contract_below2"), NULL);
|
||||
else if(contract_time < const_float("float_treeview_cell_limit_player_contract_below1"))
|
||||
g_object_set(renderer, "foreground",
|
||||
const_str("string_treeview_cell_color_player_contract_below1"), NULL);
|
||||
else
|
||||
g_object_set(renderer, "foreground",
|
||||
const_str("string_treeview_cell_color_player_contract_normal"), NULL);
|
||||
}
|
||||
|
||||
/** Render a cell of player yellow cards.
|
||||
@param buf The string the cell will contain.
|
||||
@param pl The pointer to the player. */
|
||||
void
|
||||
treeview_cell_player_cards_to_cell(gchar *buf, const Player *pl)
|
||||
{
|
||||
gint yellow;
|
||||
Fixture *fix =
|
||||
team_get_fixture(pl->team, FALSE);
|
||||
|
||||
if(fix == NULL)
|
||||
{
|
||||
if(pl->cards->len == 0)
|
||||
strcpy(buf, "0");
|
||||
else
|
||||
{
|
||||
if(opt_user_int("int_opt_user_show_overall"))
|
||||
sprintf(buf, "%d(%d)", g_array_index(pl->cards, PlayerCard, 0).yellow,
|
||||
player_all_cards(pl));
|
||||
else
|
||||
sprintf(buf, "%d", g_array_index(pl->cards, PlayerCard, 0).yellow);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
yellow = player_card_get(pl, fix->clid, PLAYER_VALUE_CARD_YELLOW);
|
||||
|
||||
if(yellow != -1)
|
||||
{
|
||||
if(opt_user_int("int_opt_user_show_overall"))
|
||||
sprintf(buf, "%d(%d)", yellow,
|
||||
player_all_cards(pl));
|
||||
else
|
||||
sprintf(buf, "%d", yellow);
|
||||
}
|
||||
else
|
||||
strcpy(buf, "0");
|
||||
}
|
||||
|
||||
/** Render a cell of player status.
|
||||
@param render The cell renderer.
|
||||
@param buf The string the cell will contain.
|
||||
@param pl The pointer to the player. */
|
||||
void
|
||||
treeview_cell_player_status_to_cell(GtkCellRenderer *renderer, gchar *buf, const Player *pl)
|
||||
{
|
||||
gint ban = player_is_banned(pl);
|
||||
|
||||
if(pl->health != PLAYER_INJURY_NONE)
|
||||
{
|
||||
sprintf(buf, _("INJ(%d)"), pl->recovery);
|
||||
g_object_set(renderer, "background",
|
||||
const_str("string_treeview_cell_color_player_injury"), NULL);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(ban > 0)
|
||||
{
|
||||
sprintf(buf, _("BAN(%d)"), ban);
|
||||
g_object_set(renderer, "background",
|
||||
const_str("string_treeview_cell_color_player_banned"), NULL);
|
||||
}
|
||||
else
|
||||
strcpy(buf, _("OK"));
|
||||
|
||||
if(ban == -1)
|
||||
g_object_set(renderer, "background",
|
||||
const_str("string_treeview_cell_color_player_yellow_danger"), NULL);
|
||||
}
|
||||
|
||||
/** Render a cell of player games or goals.
|
||||
@param buf The string the cell will contain.
|
||||
@param pl The pointer to the player.
|
||||
@param goals Whether we render games or goals. */
|
||||
void
|
||||
treeview_cell_player_games_goals_to_cell(gchar *buf, const Player *pl, gint type)
|
||||
{
|
||||
Fixture *fix = team_get_fixture(pl->team, FALSE);
|
||||
gint clid = pl->team->clid;
|
||||
|
||||
if(pl->games_goals->len == 0)
|
||||
{
|
||||
strcpy(buf, "0");
|
||||
return;
|
||||
}
|
||||
|
||||
if(fix != NULL)
|
||||
clid = fix->clid;
|
||||
|
||||
if(opt_user_int("int_opt_user_show_overall"))
|
||||
sprintf(buf, "%d(%d)", player_games_goals_get(pl, clid, type),
|
||||
player_all_games_goals(pl, type));
|
||||
else
|
||||
sprintf(buf, "%d", player_games_goals_get(pl, clid, type));
|
||||
}
|
||||
|
||||
/** Render a cell of player fitness.
|
||||
@param render The cell renderer.
|
||||
@param buf The string the cell will contain.
|
||||
@param fitness The fitness of the player. */
|
||||
void
|
||||
treeview_cell_player_fitness_to_cell(GtkCellRenderer *renderer, gchar *buf, gfloat fitness)
|
||||
{
|
||||
sprintf(buf, "%.*f%%", opt_int("int_opt_player_precision"),
|
||||
fitness * 100);
|
||||
|
||||
if(fitness < const_float("float_treeview_cell_limit_player_fitness_below3"))
|
||||
g_object_set(renderer, "foreground",
|
||||
const_str("string_treeview_cell_color_player_fitness_below3"), NULL);
|
||||
else if(fitness < const_float("float_treeview_cell_limit_player_fitness_below2"))
|
||||
g_object_set(renderer, "foreground",
|
||||
const_str("string_treeview_cell_color_player_fitness_below2"), NULL);
|
||||
else if(fitness < const_float("float_treeview_cell_limit_player_fitness_below2"))
|
||||
g_object_set(renderer, "foreground",
|
||||
const_str("string_treeview_cell_color_player_fitness_below2"), NULL);
|
||||
else
|
||||
g_object_set(renderer, "foreground",
|
||||
const_str("string_treeview_cell_color_player_fitness_normal"), NULL);
|
||||
}
|
||||
|
||||
/** Render a cell of player position or cposition.
|
||||
@param render The cell renderer.
|
||||
@param buf The string the cell will contain.
|
||||
@param pos The position of the player. */
|
||||
void
|
||||
treeview_cell_player_pos_to_cell(GtkCellRenderer *renderer, gchar *buf, gint pos)
|
||||
{
|
||||
switch(pos)
|
||||
{
|
||||
default:
|
||||
strcpy(buf, "G");
|
||||
g_object_set(renderer, "background",
|
||||
const_str("string_treeview_cell_color_player_pos_goalie_bg"),
|
||||
"foreground",
|
||||
const_str("string_treeview_cell_color_player_pos_goalie_fg"), NULL);
|
||||
break;
|
||||
case PLAYER_POS_DEFENDER:
|
||||
strcpy(buf, "D");
|
||||
g_object_set(renderer, "background",
|
||||
const_str("string_treeview_cell_color_player_pos_defender_bg"),
|
||||
"foreground",
|
||||
const_str("string_treeview_cell_color_player_pos_defender_fg"), NULL);
|
||||
break;
|
||||
case PLAYER_POS_MIDFIELDER:
|
||||
strcpy(buf, "M");
|
||||
g_object_set(renderer, "background",
|
||||
const_str("string_treeview_cell_color_player_pos_midfielder_bg"),
|
||||
"foreground",
|
||||
const_str("string_treeview_cell_color_player_pos_midfielder_fg"), NULL);
|
||||
break;
|
||||
case PLAYER_POS_FORWARD:
|
||||
strcpy(buf, "F");
|
||||
g_object_set(renderer, "background",
|
||||
const_str("string_treeview_cell_color_player_pos_forward_bg"),
|
||||
"foreground",
|
||||
const_str("string_treeview_cell_color_player_pos_forward_fg"), NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** Render a cell of player cskill.
|
||||
@param render The cell renderer.
|
||||
@param buf The string the cell will contain.
|
||||
@param pl The pointer to the player. */
|
||||
void
|
||||
treeview_cell_player_cskill_to_cell(GtkCellRenderer *renderer, gchar *buf, const Player *pl)
|
||||
{
|
||||
sprintf(buf, "%.*f", opt_int("int_opt_player_precision"),
|
||||
player_get_game_skill(pl, FALSE));
|
||||
|
||||
if(pl->cskill < pl->skill)
|
||||
g_object_set(renderer, "background",
|
||||
const_str("string_treeview_cell_color_player_bad_cskill_bg"),
|
||||
"foreground",
|
||||
const_str("string_treeview_cell_color_player_bad_cskill_fg"), NULL);
|
||||
else
|
||||
g_object_set(renderer, "background",
|
||||
const_str("string_treeview_cell_color_default_background"),
|
||||
"foreground",
|
||||
const_str("string_treeview_cell_color_default_foreground"), NULL);
|
||||
|
||||
}
|
||||
|
||||
/** Render the result (team names and goals) in the live game view. */
|
||||
void
|
||||
treeview_cell_live_game_result(GtkTreeViewColumn *col,
|
||||
GtkCellRenderer *renderer,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data)
|
||||
{
|
||||
|
||||
gint column = treeview_get_col_number_column(col);
|
||||
gchar buf[SMALL];
|
||||
Fixture *fix = NULL;
|
||||
LiveGameUnit *unit = NULL;
|
||||
|
||||
strcpy(buf, "");
|
||||
|
||||
if(column == 0 || column == 2)
|
||||
{
|
||||
gtk_tree_model_get(model, iter, column, &fix, -1);
|
||||
sprintf(buf, "<span %s>%s</span>",
|
||||
const_str("string_treeview_cell_live_game_result_attributes"),
|
||||
fix->teams[column == 2]->name->str);
|
||||
}
|
||||
else if(column == 1)
|
||||
{
|
||||
gtk_tree_model_get(model, iter, column, &unit, -1);
|
||||
sprintf(buf, "<span %s>%d : %d</span>",
|
||||
const_str("string_treeview_cell_live_game_result_attributes"),
|
||||
unit->result[0], unit->result[1]);
|
||||
|
||||
}
|
||||
|
||||
g_object_set(renderer, "markup", buf, NULL);
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
#ifndef TREEVIEW_CELL_H
|
||||
#define TREEVIEW_CELL_H
|
||||
|
||||
#include "bygfoot.h"
|
||||
|
||||
void
|
||||
treeview_cell_team_selection(GtkTreeViewColumn *col,
|
||||
GtkCellRenderer *renderer,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
void
|
||||
treeview_cell_int_to_cell(GtkTreeViewColumn *col,
|
||||
GtkCellRenderer *renderer,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data);
|
||||
|
||||
void
|
||||
treeview_cell_player_to_cell(GtkTreeViewColumn *col,
|
||||
GtkCellRenderer *renderer,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data);
|
||||
|
||||
void
|
||||
treeview_cell_player_ext_info_to_cell(GtkTreeViewColumn *col,
|
||||
GtkCellRenderer *renderer,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data);
|
||||
|
||||
void
|
||||
treeview_cell_player_contract_to_cell(GtkCellRenderer *renderer, gchar *buf, gfloat contract_time);
|
||||
|
||||
void
|
||||
treeview_cell_player_cards_to_cell(gchar *buf, const Player *pl);
|
||||
|
||||
void
|
||||
treeview_cell_player_status_to_cell(GtkCellRenderer *renderer, gchar *buf, const Player *pl);
|
||||
|
||||
void
|
||||
treeview_cell_player_games_goals_to_cell(gchar *buf, const Player *pl, gint type);
|
||||
|
||||
void
|
||||
treeview_cell_player_fitness_to_cell(GtkCellRenderer *renderer, gchar *buf, gfloat fitness);
|
||||
|
||||
void
|
||||
treeview_cell_player_pos_to_cell(GtkCellRenderer *renderer, gchar *buf, gint pos);
|
||||
|
||||
void
|
||||
treeview_cell_live_game_result(GtkTreeViewColumn *col,
|
||||
GtkCellRenderer *renderer,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data);
|
||||
|
||||
void
|
||||
treeview_cell_player_cskill_to_cell(GtkCellRenderer *renderer, gchar *buf, const Player *pl);
|
||||
|
||||
void
|
||||
treeview_cell_player_info_health_to_cell(GtkCellRenderer *renderer, const Player *pl);
|
||||
|
||||
void
|
||||
treeview_cell_player_info_games_goals_to_cell(GtkCellRenderer *renderer, const GArray *games_goals);
|
||||
|
||||
void
|
||||
treeview_cell_player_info_yellow_to_cell(GtkCellRenderer *renderer, const GArray *cards);
|
||||
|
||||
void
|
||||
treeview_cell_player_info_banned_to_cell(GtkCellRenderer *renderer, const GArray *cards);
|
||||
|
||||
#endif
|
1076
src/treeview_helper.c
Normal file
1076
src/treeview_helper.c
Normal file
File diff suppressed because it is too large
Load Diff
128
src/treeview_helper.h
Normal file
128
src/treeview_helper.h
Normal file
@ -0,0 +1,128 @@
|
||||
#ifndef TREEVIEW_CELL_H
|
||||
#define TREEVIEW_CELL_H
|
||||
|
||||
#include "bygfoot.h"
|
||||
|
||||
gint
|
||||
treeview_helper_iter_get_row(GtkTreeModel *model, GtkTreeIter *iter);
|
||||
|
||||
gboolean
|
||||
treeview_helper_select_row(GtkTreeView *treeview, GdkEventButton *event);
|
||||
|
||||
GdkPixbuf*
|
||||
treeview_helper_pixbuf_from_filename(gchar *filename);
|
||||
|
||||
GtkCellRenderer*
|
||||
treeview_helper_cell_renderer_text_new(void);
|
||||
|
||||
gchar*
|
||||
treeview_helper_live_game_icon(gint event_type);
|
||||
|
||||
gint
|
||||
treeview_helper_get_index(GtkTreeView *treeview, gint column);
|
||||
|
||||
gpointer
|
||||
treeview_helper_get_pointer(GtkTreeView *treeview, gint column);
|
||||
|
||||
void
|
||||
treeview_helper_clear(GtkTreeView *treeview);
|
||||
|
||||
gint
|
||||
treeview_helper_get_col_number_column (GtkTreeViewColumn *col);
|
||||
|
||||
void
|
||||
treeview_helper_get_table_element_colours(const Table *table, gint idx, gchar *colour_fg,
|
||||
gchar *colour_bg, gboolean user);
|
||||
|
||||
gboolean
|
||||
treeview_helper_get_table_element_colour_cups(const League *league, gint idx, gchar *colour_bg);
|
||||
|
||||
PlayerListAttribute
|
||||
treeview_helper_get_attributes_from_scout(gint scout);
|
||||
|
||||
gint
|
||||
treeview_helper_team_compare(GtkTreeModel *model,
|
||||
GtkTreeIter *a,
|
||||
GtkTreeIter *b,
|
||||
gpointer user_data);
|
||||
|
||||
gint
|
||||
treeview_helper_player_compare(GtkTreeModel *model,
|
||||
GtkTreeIter *a,
|
||||
GtkTreeIter *b,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
void
|
||||
treeview_helper_team_selection(GtkTreeViewColumn *col,
|
||||
GtkCellRenderer *renderer,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
void
|
||||
treeview_helper_int_to_cell(GtkTreeViewColumn *col,
|
||||
GtkCellRenderer *renderer,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data);
|
||||
|
||||
void
|
||||
treeview_helper_player_to_cell(GtkTreeViewColumn *col,
|
||||
GtkCellRenderer *renderer,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data);
|
||||
|
||||
void
|
||||
treeview_helper_player_ext_info_to_cell(GtkTreeViewColumn *col,
|
||||
GtkCellRenderer *renderer,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data);
|
||||
|
||||
void
|
||||
treeview_helper_player_contract_to_cell(GtkCellRenderer *renderer, gchar *buf, gfloat contract_time);
|
||||
|
||||
void
|
||||
treeview_helper_player_cards_to_cell(gchar *buf, const Player *pl);
|
||||
|
||||
void
|
||||
treeview_helper_player_status_to_cell(GtkCellRenderer *renderer, gchar *buf, const Player *pl);
|
||||
|
||||
void
|
||||
treeview_helper_player_games_goals_to_cell(gchar *buf, const Player *pl, gint type);
|
||||
|
||||
void
|
||||
treeview_helper_player_fitness_to_cell(GtkCellRenderer *renderer, gchar *buf, gfloat fitness);
|
||||
|
||||
void
|
||||
treeview_helper_player_pos_to_cell(GtkCellRenderer *renderer, gchar *buf, gint pos);
|
||||
|
||||
void
|
||||
treeview_helper_live_game_result(GtkTreeViewColumn *col,
|
||||
GtkCellRenderer *renderer,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data);
|
||||
|
||||
void
|
||||
treeview_helper_player_cskill_to_cell(GtkCellRenderer *renderer, gchar *buf, const Player *pl);
|
||||
|
||||
void
|
||||
treeview_helper_player_info_health_to_cell(GtkCellRenderer *renderer, const Player *pl);
|
||||
|
||||
void
|
||||
treeview_helper_player_info_games_goals_to_cell(GtkCellRenderer *renderer, const GArray *games_goals);
|
||||
|
||||
void
|
||||
treeview_helper_player_info_yellow_to_cell(GtkCellRenderer *renderer, const GArray *cards);
|
||||
|
||||
void
|
||||
treeview_helper_player_info_banned_to_cell(GtkCellRenderer *renderer, const GArray *cards);
|
||||
|
||||
gchar*
|
||||
treeview_helper_get_user_history_icon(gint history_type);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user