1
1
mirror of https://github.com/tstellar/bygfoot.git synced 2024-12-16 10:21:15 +01:00

Adjusted table highlight colours for multiple tables.

This commit is contained in:
gyboth 2008-11-23 11:48:36 +00:00
parent 83908c2c8d
commit c48a361342
8 changed files with 45 additions and 24 deletions

View File

@ -95,7 +95,8 @@ prom_rel_element_new(void)
{
PromRelElement new;
new.ranks[0] = new.ranks[1] = 0;
new.ranks[0] = new.ranks[1] =
new.from_table = 0;
new.dest_sid = NULL;
new.type = PROM_REL_NONE;
@ -517,13 +518,15 @@ league_get_team_movements_prom_rel(const League *league, GArray *team_movements)
gint i, j, k;
TeamMove new_move;
const GArray *elements = league->prom_rel.elements;
PromRelElement *elem;
GArray *dest_idcs = NULL;
GPtrArray *dest_sids = NULL;
for(i=0;i<elements->len;i++)
{
elem = &g_array_index(elements, PromRelElement, i);
dest_sids = misc_separate_strings(
g_array_index(elements, PromRelElement, i).dest_sid);
elem->dest_sid);
gint dest_idcs_int[dest_sids->len];
gint dest_idcs_order[dest_sids->len];
@ -531,8 +534,8 @@ league_get_team_movements_prom_rel(const League *league, GArray *team_movements)
dest_idcs_int[j] =
league_index_from_sid((gchar*)g_ptr_array_index(dest_sids, j));
for(j=g_array_index(elements, PromRelElement, i).ranks[0];
j<=g_array_index(elements, PromRelElement, i).ranks[1]; j++)
for(j=elem->ranks[0];
j<=elem->ranks[1]; j++)
{
dest_idcs = g_array_new(FALSE, FALSE, sizeof(gint));
math_generate_permutation(dest_idcs_order, 0, dest_sids->len - 1);
@ -540,8 +543,8 @@ league_get_team_movements_prom_rel(const League *league, GArray *team_movements)
for(k=0;k<dest_sids->len;k++)
g_array_append_val(dest_idcs, dest_idcs_int[dest_idcs_order[k]]);
new_move.tm = *(g_array_index(league_table_cumul(league)->elements, TableElement, j - 1).team);
new_move.prom_rel_type = g_array_index(elements, PromRelElement, i).type;
new_move.tm = *(g_array_index(g_array_index(league->tables, Table, elem->from_table).elements, TableElement, j - 1).team);
new_move.prom_rel_type = elem->type;
new_move.dest_idcs = dest_idcs;
new_move.dest_assigned = FALSE;
g_array_append_val(team_movements, new_move);

View File

@ -47,6 +47,7 @@ enum PromRelType
typedef struct
{
gint ranks[2]; /**< The range of teams; default 0 and 0 */
gint from_table; /**< From which table to pick the teams in case there are several. Default: 0. */
gchar *dest_sid; /**< The id of the destination league. Default "" */
gint type; /**< Type. Promotion or relegation or none. */
} PromRelElement;

View File

@ -1100,7 +1100,7 @@ treeview_show_fixtures(GtkTreeView *treeview, gint clid,
@param clid The cup or league id.
@param number The number of the table if we display more than one. */
void
treeview_table_write_header(GtkListStore *ls, const Table *table, gint number)
treeview_table_write_header(GtkListStore *ls, const Table *table, gint table_index)
{
gint i;
gchar buf[SMALL];
@ -1118,7 +1118,7 @@ treeview_table_write_header(GtkListStore *ls, const Table *table, gint number)
if(g_array_index(cup_from_clid(table->clid)->rounds, CupRound,
table->round).tables->len > 1)
/* A group of a round robin stage of a cup. */
sprintf(buf, _("%s Group %d"), cup_from_clid(table->clid)->name, number);
sprintf(buf, _("%s Group %d"), cup_from_clid(table->clid)->name, table_index + 1);
else
sprintf(buf, "%s", cup_from_clid(table->clid)->name);
}
@ -1135,7 +1135,7 @@ treeview_table_write_header(GtkListStore *ls, const Table *table, gint number)
@param number The number of the table if we display more than one
(cups, round robin); or -1 for leagues. */
void
treeview_create_single_table(GtkListStore *ls, const Table *table, gint number)
treeview_create_single_table(GtkListStore *ls, const Table *table, gint table_index)
{
gint i, j;
GtkTreeIter iter;
@ -1143,7 +1143,7 @@ treeview_create_single_table(GtkListStore *ls, const Table *table, gint number)
gchar buf[10][SMALL];
gchar *colour_bg = NULL, *colour_fg = NULL;
treeview_table_write_header(ls, table, number);
treeview_table_write_header(ls, table, table_index);
for(i=0;i<table->elements->len;i++)
{
@ -1164,12 +1164,12 @@ treeview_create_single_table(GtkListStore *ls, const Table *table, gint number)
treeview_helper_insert_icon(ls, &iter, 2,
const_app("string_treeview_table_stay_icon"));
treeview_helper_get_table_element_colours(table, i,
treeview_helper_get_table_element_colours(table, table_index, i,
&colour_fg, &colour_bg, FALSE);
sprintf(buf[0], "<span background='%s' foreground='%s'>%d</span>",
colour_bg, colour_fg, i + 1);
treeview_helper_get_table_element_colours(table, i, &colour_fg, &colour_bg, TRUE);
treeview_helper_get_table_element_colours(table, table_index, i, &colour_fg, &colour_bg, TRUE);
if(debug < 50)
sprintf(buf[1], "<span background='%s' foreground='%s'>%s</span>",
colour_bg, colour_fg, elem->team->name);
@ -1220,13 +1220,13 @@ treeview_create_table(gint clid)
{
tables = league_from_clid(clid)->tables;
for(i = tables->len - 1; i >= 0; i--)
treeview_create_single_table(ls, &g_array_index(tables, Table, i), i + 1);
treeview_create_single_table(ls, &g_array_index(tables, Table, i), i);
}
else
{
tables = cup_get_last_tables(clid);
for(i=0;i< tables->len;i++)
treeview_create_single_table(ls, &g_array_index(tables, Table, i), i + 1);
treeview_create_single_table(ls, &g_array_index(tables, Table, i), i);
}
return GTK_TREE_MODEL(ls);

View File

@ -124,10 +124,10 @@ GtkTreeModel*
treeview_create_table(gint clid);
void
treeview_create_single_table(GtkListStore *liststore, const Table *table, gint number);
treeview_create_single_table(GtkListStore *liststore, const Table *table, gint table_index);
void
treeview_table_write_header(GtkListStore *ls, const Table *table, gint number);
treeview_table_write_header(GtkListStore *ls, const Table *table, gint table_index);
void
treeview_show_finances(GtkTreeView *treeview, const User* user);

View File

@ -449,7 +449,7 @@ treeview_helper_player_compare(GtkTreeModel *model,
table would participate in an international cup and set the
colours accordingly. */
gboolean
treeview_helper_get_table_element_colour_cups(const League *league,
treeview_helper_get_table_element_colour_cups(const League *league, gint table_index,
gint idx, gchar **colour_bg)
{
gint i, j, k;
@ -469,10 +469,12 @@ treeview_helper_get_table_element_colour_cups(const League *league,
{
cup_round = &g_array_index(cp(i).rounds, CupRound, k);
for(j=0;j<cup_round->choose_teams->len;j++)
if(strcmp(g_array_index(cup_round->choose_teams,
if((strcmp(g_array_index(cup_round->choose_teams,
CupChooseTeam, j).sid, buf) == 0 ||
strcmp(g_array_index(cup_round->choose_teams,
CupChooseTeam, j).sid, league->sid) == 0)
CupChooseTeam, j).sid, league->sid) == 0) &&
g_array_index(cup_round->choose_teams,
CupChooseTeam, j).from_table == table_index)
{
if((idx + 1 >= g_array_index(cup_round->choose_teams,
CupChooseTeam, j).start_idx &&
@ -561,7 +563,7 @@ treeview_helper_get_table_element_colour_cups_cup(const Cup *cup,
@param idx The index of the element we're looking at.
@param user Whether to take into account user colours. */
void
treeview_helper_get_table_element_colours(const Table *table, gint idx,
treeview_helper_get_table_element_colours(const Table *table, gint table_index, gint idx,
gchar **colour_fg, gchar **colour_bg,
gboolean user)
{
@ -592,12 +594,12 @@ treeview_helper_get_table_element_colours(const Table *table, gint idx,
*colour_bg = const_app("string_treeview_table_first");
else
{
if(!treeview_helper_get_table_element_colour_cups(league, idx, colour_bg))
if(!treeview_helper_get_table_element_colour_cups(league, table_index, idx, colour_bg))
{
for(i=0;i<league->prom_rel.elements->len;i++)
{
pelem = &g_array_index(league_from_clid(table->clid)->prom_rel.elements, PromRelElement, i);
if(pelem->ranks[0] <= idx + 1 && idx + 1 <= pelem->ranks[1])
if(pelem->ranks[0] <= idx + 1 && idx + 1 <= pelem->ranks[1] && pelem->from_table == table_index)
{
if(pelem->type == PROM_REL_PROMOTION)
*colour_bg = const_app("string_treeview_table_promotion");

View File

@ -68,12 +68,12 @@ gint
treeview_helper_get_col_number_column (GtkTreeViewColumn *col);
void
treeview_helper_get_table_element_colours(const Table *table, gint idx,
treeview_helper_get_table_element_colours(const Table *table, gint table_index, gint idx,
gchar **colour_fg,
gchar **colour_bg, gboolean user);
gboolean
treeview_helper_get_table_element_colour_cups(const League *league,
treeview_helper_get_table_element_colour_cups(const League *league, gint table_index,
gint idx, gchar **colour_bg);
gboolean

View File

@ -65,6 +65,7 @@
#define TAG_PROM_REL_ELEMENT_RANK_END "rank_end"
#define TAG_PROM_REL_ELEMENT_DEST_SID "dest_sid"
#define TAG_PROM_REL_ELEMENT_TYPE "prom_rel_type"
#define TAG_PROM_REL_ELEMENT_FROM_TABLE "from_table"
#define TAG_TEAMS "teams"
#define TAG_TEAM "team"
#define TAG_TEAM_NAME "team_name"
@ -107,6 +108,7 @@ enum XmlLeagueStates
STATE_PROM_REL_ELEMENT_RANK_END,
STATE_PROM_REL_ELEMENT_DEST_SID,
STATE_PROM_REL_ELEMENT_TYPE,
STATE_PROM_REL_ELEMENT_FROM_TABLE,
STATE_TEAMS,
STATE_TEAM,
STATE_TEAM_NAME,
@ -231,6 +233,8 @@ xml_league_read_start_element (GMarkupParseContext *context,
state = STATE_PROM_REL_ELEMENT_DEST_SID;
else if(strcmp(element_name, TAG_PROM_REL_ELEMENT_TYPE) == 0)
state = STATE_PROM_REL_ELEMENT_TYPE;
else if(strcmp(element_name, TAG_PROM_REL_ELEMENT_FROM_TABLE) == 0)
state = STATE_PROM_REL_ELEMENT_FROM_TABLE;
else if(strcmp(element_name, TAG_TEAMS) == 0)
state = STATE_TEAMS;
else if(strcmp(element_name, TAG_TEAM) == 0)
@ -300,6 +304,7 @@ xml_league_read_end_element (GMarkupParseContext *context,
else if(strcmp(element_name, TAG_PROM_REL_ELEMENT_RANK_START) == 0 ||
strcmp(element_name, TAG_PROM_REL_ELEMENT_RANK_END) == 0 ||
strcmp(element_name, TAG_PROM_REL_ELEMENT_DEST_SID) == 0 ||
strcmp(element_name, TAG_PROM_REL_ELEMENT_FROM_TABLE) == 0 ||
strcmp(element_name, TAG_PROM_REL_ELEMENT_TYPE) == 0)
state = STATE_PROM_REL_ELEMENT;
else if(strcmp(element_name, TAG_TEAM) == 0)
@ -396,6 +401,10 @@ xml_league_read_text (GMarkupParseContext *context,
misc_string_assign(&g_array_index(new_league.prom_rel.elements,
PromRelElement,
new_league.prom_rel.elements->len - 1).dest_sid, buf);
else if(state == STATE_PROM_REL_ELEMENT_FROM_TABLE)
g_array_index(new_league.prom_rel.elements,
PromRelElement,
new_league.prom_rel.elements->len - 1).from_table = int_value;
else if(state == STATE_PROM_REL_ELEMENT_TYPE)
{
if(strcmp(buf, "promotion") == 0)

View File

@ -56,6 +56,7 @@ enum
TAG_LEAGUE_PROM_REL_ELEMENT_RANK,
TAG_LEAGUE_PROM_REL_ELEMENT_DEST_SID,
TAG_LEAGUE_PROM_REL_ELEMENT_TYPE,
TAG_LEAGUE_PROM_REL_ELEMENT_FROM_TABLE,
TAG_LEAGUE_BREAK,
TAG_LEAGUE_JOINED_LEAGUE_SID,
TAG_LEAGUE_JOINED_LEAGUE_RR,
@ -165,6 +166,7 @@ xml_loadsave_league_end_element (GMarkupParseContext *context,
}
else if(tag == TAG_LEAGUE_PROM_REL_ELEMENT_RANK ||
tag == TAG_LEAGUE_PROM_REL_ELEMENT_DEST_SID ||
tag == TAG_LEAGUE_PROM_REL_ELEMENT_FROM_TABLE ||
tag == TAG_LEAGUE_PROM_REL_ELEMENT_TYPE)
{
state = TAG_LEAGUE_PROM_REL_ELEMENT;
@ -262,6 +264,8 @@ xml_loadsave_league_text (GMarkupParseContext *context,
new_element.ranks[promrankidx] = int_value;
else if(state == TAG_LEAGUE_PROM_REL_ELEMENT_TYPE)
new_element.type = int_value;
else if(state == TAG_LEAGUE_PROM_REL_ELEMENT_FROM_TABLE)
new_element.from_table = int_value;
else if(state == TAG_LEAGUE_PROM_REL_ELEMENT_DEST_SID)
misc_string_assign(&new_element.dest_sid, buf);
}
@ -395,6 +399,8 @@ xml_loadsave_league_write(const gchar *prefix, const League *league)
TAG_LEAGUE_PROM_REL_ELEMENT_RANK, I2);
xml_write_int(fil, g_array_index(league->prom_rel.elements, PromRelElement, i).type,
TAG_LEAGUE_PROM_REL_ELEMENT_TYPE, I2);
xml_write_int(fil, g_array_index(league->prom_rel.elements, PromRelElement, i).from_table,
TAG_LEAGUE_PROM_REL_ELEMENT_FROM_TABLE, I2);
xml_write_string(fil, g_array_index(league->prom_rel.elements, PromRelElement, i).dest_sid,
TAG_LEAGUE_PROM_REL_ELEMENT_DEST_SID, I2);
fprintf(fil, "%s</_%d>\n", I1, TAG_LEAGUE_PROM_REL_ELEMENT);