mirror of
https://github.com/tstellar/bygfoot.git
synced 2025-03-05 19:47:55 +01:00
Newspaper progresssing.
This commit is contained in:
parent
6660499d89
commit
440fbfea6e
39
src/news.c
39
src/news.c
@ -71,14 +71,17 @@ news_generate_match(const LiveGame *live_game)
|
|||||||
{
|
{
|
||||||
new_article.week_number = week;
|
new_article.week_number = week;
|
||||||
new_article.week_round_number = week_round;
|
new_article.week_round_number = week_round;
|
||||||
|
|
||||||
fixture_result_to_buf(live_game->fix, buf, FALSE);
|
fixture_result_to_buf(live_game->fix, buf, FALSE);
|
||||||
sprintf(title_small, "%s %s %s",
|
sprintf(title_small, "%s %s %s",
|
||||||
live_game->fix->teams[0]->name, buf, live_game->fix->teams[1]->name);
|
live_game->fix->teams[0]->name, buf, live_game->fix->teams[1]->name);
|
||||||
new_article.title_small = g_strdup(title_small);
|
new_article.title_small = g_strdup(title_small);
|
||||||
|
|
||||||
new_article.title = g_strdup(title);
|
new_article.title = g_strdup(title);
|
||||||
new_article.subtitle = g_strdup(subtitle);
|
new_article.subtitle = g_strdup(subtitle);
|
||||||
new_article.title_id = title_id;
|
new_article.title_id = title_id;
|
||||||
new_article.subtitle_id = subtitle_id;
|
new_article.subtitle_id = subtitle_id;
|
||||||
|
new_article.user_idx = fixture_user_team_involved(live_game->fix);
|
||||||
/* printf("%s / %s -- %d %d\n", title, subtitle, title_id, subtitle_id); */
|
/* printf("%s / %s -- %d %d\n", title, subtitle, title_id, subtitle_id); */
|
||||||
g_array_append_val(newspaper.articles, new_article);
|
g_array_append_val(newspaper.articles, new_article);
|
||||||
|
|
||||||
@ -310,7 +313,8 @@ news_set_streak_tokens(const Fixture *fix)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
gint i, j, k,
|
gint i, j, k,
|
||||||
streak_won, streak_lost;
|
streak_won, streak_lost, streak_unbeaten;
|
||||||
|
gboolean draw;
|
||||||
gint res[2];
|
gint res[2];
|
||||||
gchar buf[SMALL], buf2[SMALL];
|
gchar buf[SMALL], buf2[SMALL];
|
||||||
GPtrArray *latest_fixtures;
|
GPtrArray *latest_fixtures;
|
||||||
@ -319,16 +323,29 @@ news_set_streak_tokens(const Fixture *fix)
|
|||||||
{
|
{
|
||||||
for(k = 0; k < 2; k++)
|
for(k = 0; k < 2; k++)
|
||||||
{
|
{
|
||||||
latest_fixtures = fixture_get_latest(fix->teams[0], (k == 0));
|
latest_fixtures = fixture_get_latest(fix->teams[i], (k == 0));
|
||||||
streak_won = streak_lost = 0;
|
streak_won = streak_lost = streak_unbeaten = 0;
|
||||||
|
draw = FALSE;
|
||||||
|
|
||||||
for(j=latest_fixtures->len - 1;j>=0;j--)
|
for(j=latest_fixtures->len - 1;j>=0;j--)
|
||||||
{
|
{
|
||||||
res[0] = math_sum_int_array(((Fixture*)g_ptr_array_index(latest_fixtures, j))->result[0], 3);
|
res[0] = math_sum_int_array(((Fixture*)g_ptr_array_index(latest_fixtures, j))->result[0], 3);
|
||||||
res[1] = math_sum_int_array(((Fixture*)g_ptr_array_index(latest_fixtures, j))->result[1], 3);
|
res[1] = math_sum_int_array(((Fixture*)g_ptr_array_index(latest_fixtures, j))->result[1], 3);
|
||||||
|
|
||||||
|
/* printf("%s %s %d %d str %d %d %d\n", ((Fixture*)g_ptr_array_index(latest_fixtures, j))->teams[0]->name, */
|
||||||
|
/* ((Fixture*)g_ptr_array_index(latest_fixtures, j))->teams[1]->name, res[0], res[1], */
|
||||||
|
/* streak_won, streak_lost, streak_unbeaten); */
|
||||||
|
|
||||||
if(res[0] == res[1])
|
if(res[0] == res[1])
|
||||||
break;
|
{
|
||||||
|
if(streak_lost == 0)
|
||||||
|
{
|
||||||
|
draw = TRUE;
|
||||||
|
streak_unbeaten++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
else if(res[(((Fixture*)g_ptr_array_index(latest_fixtures, j))->teams[0] == fix->teams[i])] >
|
else if(res[(((Fixture*)g_ptr_array_index(latest_fixtures, j))->teams[0] == fix->teams[i])] >
|
||||||
res[(((Fixture*)g_ptr_array_index(latest_fixtures, j))->teams[0] != fix->teams[i])])
|
res[(((Fixture*)g_ptr_array_index(latest_fixtures, j))->teams[0] != fix->teams[i])])
|
||||||
{
|
{
|
||||||
@ -340,7 +357,12 @@ news_set_streak_tokens(const Fixture *fix)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(streak_lost == 0)
|
if(streak_lost == 0)
|
||||||
streak_won++;
|
{
|
||||||
|
streak_unbeaten++;
|
||||||
|
|
||||||
|
if(!draw)
|
||||||
|
streak_won++;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -359,7 +381,10 @@ news_set_streak_tokens(const Fixture *fix)
|
|||||||
misc_token_add(token_rep_news,
|
misc_token_add(token_rep_news,
|
||||||
option_int(buf, &tokens),
|
option_int(buf, &tokens),
|
||||||
misc_int_to_char(streak_lost));
|
misc_int_to_char(streak_lost));
|
||||||
|
sprintf(buf, "string_token_streak_%sunbeaten%d", buf2, i);
|
||||||
|
misc_token_add(token_rep_news,
|
||||||
|
option_int(buf, &tokens),
|
||||||
|
misc_int_to_char(streak_unbeaten));
|
||||||
|
|
||||||
g_ptr_array_free(latest_fixtures, TRUE);
|
g_ptr_array_free(latest_fixtures, TRUE);
|
||||||
}
|
}
|
||||||
|
@ -597,7 +597,7 @@ treeview2_create_news(GtkListStore *ls)
|
|||||||
sprintf(buf, "\n<span %s>%s</span>",
|
sprintf(buf, "\n<span %s>%s</span>",
|
||||||
const_app("string_news_window_title_attribute"),
|
const_app("string_news_window_title_attribute"),
|
||||||
_("No news available."));
|
_("No news available."));
|
||||||
gtk_list_store_set(ls, &iter, 0, buf, -1);
|
gtk_list_store_set(ls, &iter, 0, buf, 1, NULL, -1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -611,35 +611,22 @@ treeview2_create_news(GtkListStore *ls)
|
|||||||
g_array_index(newspaper.articles, NewsPaperArticle, i + 1).week_round_number)))
|
g_array_index(newspaper.articles, NewsPaperArticle, i + 1).week_round_number)))
|
||||||
{
|
{
|
||||||
gtk_list_store_append(ls, &iter);
|
gtk_list_store_append(ls, &iter);
|
||||||
gtk_list_store_set(ls, &iter, 0, "", -1);
|
gtk_list_store_set(ls, &iter, 0, "", 1, NULL, -1);
|
||||||
|
|
||||||
gtk_list_store_append(ls, &iter);
|
gtk_list_store_append(ls, &iter);
|
||||||
sprintf(buf2, _("Week %d, Week round %d"),
|
sprintf(buf2, _("Week %d Round %d"),
|
||||||
g_array_index(newspaper.articles, NewsPaperArticle, i).week_number,
|
g_array_index(newspaper.articles, NewsPaperArticle, i).week_number,
|
||||||
g_array_index(newspaper.articles, NewsPaperArticle, i).week_round_number);
|
g_array_index(newspaper.articles, NewsPaperArticle, i).week_round_number);
|
||||||
sprintf(buf, "<span %s>%s</span>",
|
sprintf(buf, "<span %s>%s</span>\n\n",
|
||||||
const_app("string_news_window_week_number_attribute"),
|
const_app("string_news_window_week_number_attribute"),
|
||||||
buf2);
|
buf2);
|
||||||
gtk_list_store_set(ls, &iter, 0, buf, -1);
|
gtk_list_store_set(ls, &iter, 0, buf, 1, &g_array_index(newspaper.articles, NewsPaperArticle, i), -1);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
gtk_list_store_append(ls, &iter);
|
{
|
||||||
sprintf(buf, "<span %s>%s</span>",
|
gtk_list_store_append(ls, &iter);
|
||||||
const_app("string_news_window_title_small_attribute"),
|
gtk_list_store_set(ls, &iter, 0, "", 1, &g_array_index(newspaper.articles, NewsPaperArticle, i), -1);
|
||||||
g_array_index(newspaper.articles, NewsPaperArticle, i).title_small);
|
}
|
||||||
gtk_list_store_set(ls, &iter, 0, buf, -1);
|
|
||||||
|
|
||||||
gtk_list_store_append(ls, &iter);
|
|
||||||
sprintf(buf, "<span %s>%s</span>",
|
|
||||||
const_app("string_news_window_title_attribute"),
|
|
||||||
g_array_index(newspaper.articles, NewsPaperArticle, i).title);
|
|
||||||
gtk_list_store_set(ls, &iter, 0, buf, -1);
|
|
||||||
|
|
||||||
gtk_list_store_append(ls, &iter);
|
|
||||||
sprintf(buf, "<span %s>%s</span>\n",
|
|
||||||
const_app("string_news_window_subtitle_attribute"),
|
|
||||||
g_array_index(newspaper.articles, NewsPaperArticle, i).subtitle);
|
|
||||||
gtk_list_store_set(ls, &iter, 0, buf, -1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -656,14 +643,21 @@ treeview2_set_up_news(GtkTreeView *treeview)
|
|||||||
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview),
|
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview),
|
||||||
GTK_SELECTION_NONE);
|
GTK_SELECTION_NONE);
|
||||||
gtk_tree_view_set_headers_visible(treeview, FALSE);
|
gtk_tree_view_set_headers_visible(treeview, FALSE);
|
||||||
gtk_tree_view_set_rules_hint(treeview, TRUE);
|
gtk_tree_view_set_rules_hint(treeview, FALSE);
|
||||||
|
|
||||||
col = gtk_tree_view_column_new();
|
col = gtk_tree_view_column_new();
|
||||||
gtk_tree_view_append_column(treeview, col);
|
gtk_tree_view_append_column(treeview, col);
|
||||||
renderer = treeview_helper_cell_renderer_text_new();
|
renderer = treeview_helper_cell_renderer_text_new();
|
||||||
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
||||||
gtk_tree_view_column_add_attribute(col, renderer,
|
gtk_tree_view_column_add_attribute(col, renderer,
|
||||||
"markup", 0);
|
"markup", 0);
|
||||||
|
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_news,
|
||||||
|
NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Show the news in the news treeview. */
|
/** Show the news in the news treeview. */
|
||||||
@ -677,7 +671,7 @@ treeview2_show_news(void)
|
|||||||
GtkTreeView *treeview =
|
GtkTreeView *treeview =
|
||||||
GTK_TREE_VIEW(lookup_widget(window.news, "treeview_news"));
|
GTK_TREE_VIEW(lookup_widget(window.news, "treeview_news"));
|
||||||
GtkListStore *model =
|
GtkListStore *model =
|
||||||
gtk_list_store_new(1, G_TYPE_STRING);
|
gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_POINTER);
|
||||||
|
|
||||||
treeview_helper_clear(treeview);
|
treeview_helper_clear(treeview);
|
||||||
|
|
||||||
|
@ -1838,6 +1838,62 @@ treeview_helper_search_equal(GtkTreeModel *model,
|
|||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
treeview_helper_news(GtkTreeViewColumn *col,
|
||||||
|
GtkCellRenderer *renderer,
|
||||||
|
GtkTreeModel *model,
|
||||||
|
GtkTreeIter *iter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
const NewsPaperArticle *article = NULL;
|
||||||
|
const gchar *colour_fg;
|
||||||
|
const gchar *colour_bg;
|
||||||
|
gchar buf[SMALL];
|
||||||
|
GString *news_string;
|
||||||
|
|
||||||
|
gtk_tree_model_get(model, iter, 1, &article, -1);
|
||||||
|
|
||||||
|
colour_fg = const_app("string_treeview_helper_color_default_foreground");
|
||||||
|
colour_bg = const_app("string_treeview_helper_color_default_background");
|
||||||
|
|
||||||
|
if(article == NULL)
|
||||||
|
{
|
||||||
|
g_object_set(renderer, "markup", "",
|
||||||
|
"background", colour_bg, "foreground", colour_fg, NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(article->user_idx == cur_user)
|
||||||
|
{
|
||||||
|
colour_fg = const_app("string_treeview_current_user_fg");
|
||||||
|
colour_bg = const_app("string_treeview_current_user_bg");
|
||||||
|
}
|
||||||
|
else if(article->user_idx != -1)
|
||||||
|
{
|
||||||
|
colour_fg = const_app("string_treeview_user_fg");
|
||||||
|
colour_bg = const_app("string_treeview_user_bg");
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(buf, "<span %s>%s</span>",
|
||||||
|
const_app("string_news_window_title_small_attribute"),
|
||||||
|
article->title_small);
|
||||||
|
|
||||||
|
news_string = g_string_new(buf);
|
||||||
|
|
||||||
|
g_string_append_printf(news_string, "\n<span %s>%s</span>",
|
||||||
|
const_app("string_news_window_title_attribute"),
|
||||||
|
article->title);
|
||||||
|
|
||||||
|
g_string_append_printf(news_string, "\n<span %s>%s</span>",
|
||||||
|
const_app("string_news_window_subtitle_attribute"),
|
||||||
|
article->subtitle);
|
||||||
|
|
||||||
|
g_object_set(renderer, "markup", news_string->str,
|
||||||
|
"background", colour_bg, "foreground", colour_fg, NULL);
|
||||||
|
|
||||||
|
g_string_free(news_string, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
treeview_helper_job_exchange(GtkTreeViewColumn *col,
|
treeview_helper_job_exchange(GtkTreeViewColumn *col,
|
||||||
GtkCellRenderer *renderer,
|
GtkCellRenderer *renderer,
|
||||||
|
@ -229,4 +229,11 @@ treeview_helper_job_exchange(GtkTreeViewColumn *col,
|
|||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
treeview_helper_news(GtkTreeViewColumn *col,
|
||||||
|
GtkCellRenderer *renderer,
|
||||||
|
GtkTreeModel *model,
|
||||||
|
GtkTreeIter *iter,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -42,6 +42,7 @@ enum
|
|||||||
TAG_NEWS_PAPER_ARTICLE_TITLE_SMALL,
|
TAG_NEWS_PAPER_ARTICLE_TITLE_SMALL,
|
||||||
TAG_NEWS_PAPER_ARTICLE_TITLE,
|
TAG_NEWS_PAPER_ARTICLE_TITLE,
|
||||||
TAG_NEWS_PAPER_ARTICLE_SUBTITLE,
|
TAG_NEWS_PAPER_ARTICLE_SUBTITLE,
|
||||||
|
TAG_NEWS_PAPER_ARTICLE_USER_IDX,
|
||||||
TAG_END
|
TAG_END
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -101,6 +102,7 @@ xml_loadsave_newspaper_end_element (GMarkupParseContext *context,
|
|||||||
tag == TAG_NEWS_PAPER_ARTICLE_TITLE ||
|
tag == TAG_NEWS_PAPER_ARTICLE_TITLE ||
|
||||||
tag == TAG_NEWS_PAPER_ARTICLE_TITLE_ID ||
|
tag == TAG_NEWS_PAPER_ARTICLE_TITLE_ID ||
|
||||||
tag == TAG_NEWS_PAPER_ARTICLE_SUBTITLE ||
|
tag == TAG_NEWS_PAPER_ARTICLE_SUBTITLE ||
|
||||||
|
tag == TAG_NEWS_PAPER_ARTICLE_USER_IDX ||
|
||||||
tag == TAG_NEWS_PAPER_ARTICLE_SUBTITLE_ID)
|
tag == TAG_NEWS_PAPER_ARTICLE_SUBTITLE_ID)
|
||||||
{
|
{
|
||||||
state = TAG_NEWS_PAPER_ARTICLE;
|
state = TAG_NEWS_PAPER_ARTICLE;
|
||||||
@ -143,6 +145,8 @@ xml_loadsave_newspaper_text (GMarkupParseContext *context,
|
|||||||
new_article.title_id = int_value;
|
new_article.title_id = int_value;
|
||||||
else if(state == TAG_NEWS_PAPER_ARTICLE_SUBTITLE_ID)
|
else if(state == TAG_NEWS_PAPER_ARTICLE_SUBTITLE_ID)
|
||||||
new_article.subtitle_id = int_value;
|
new_article.subtitle_id = int_value;
|
||||||
|
else if(state == TAG_NEWS_PAPER_ARTICLE_USER_IDX)
|
||||||
|
new_article.user_idx = int_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -222,6 +226,8 @@ xml_loadsave_newspaper_write(const gchar *prefix)
|
|||||||
TAG_NEWS_PAPER_ARTICLE_TITLE_ID, I1);
|
TAG_NEWS_PAPER_ARTICLE_TITLE_ID, I1);
|
||||||
xml_write_int(fil, g_array_index(newspaper.articles, NewsPaperArticle, i).subtitle_id,
|
xml_write_int(fil, g_array_index(newspaper.articles, NewsPaperArticle, i).subtitle_id,
|
||||||
TAG_NEWS_PAPER_ARTICLE_SUBTITLE_ID, I1);
|
TAG_NEWS_PAPER_ARTICLE_SUBTITLE_ID, I1);
|
||||||
|
xml_write_int(fil, g_array_index(newspaper.articles, NewsPaperArticle, i).user_idx,
|
||||||
|
TAG_NEWS_PAPER_ARTICLE_USER_IDX, I1);
|
||||||
|
|
||||||
fprintf(fil, "%s</_%d>\n", I0, TAG_NEWS_PAPER_ARTICLE);
|
fprintf(fil, "%s</_%d>\n", I0, TAG_NEWS_PAPER_ARTICLE);
|
||||||
}
|
}
|
||||||
|
@ -235,8 +235,9 @@ string_treeview_helper_color_user_bet_bg lightblue
|
|||||||
string_treeview_helper_color_job_international_fg black
|
string_treeview_helper_color_job_international_fg black
|
||||||
string_treeview_helper_color_job_international_bg lightblue
|
string_treeview_helper_color_job_international_bg lightblue
|
||||||
|
|
||||||
# font attributes for the news window
|
# attributes for the news window
|
||||||
string_news_window_week_number_attribute weight='bold' size='x-large'
|
string_news_window_week_number_attribute style='oblique'
|
||||||
string_news_window_title_small_attribute size='small'
|
string_news_window_title_small_attribute size='small'
|
||||||
string_news_window_title_attribute weight='bold' size='large'
|
string_news_window_title_attribute weight='bold' size='large'
|
||||||
string_news_window_subtitle_attribute style='oblique'
|
string_news_window_subtitle_attribute style='oblique'
|
||||||
|
string_news_window_alternate_background lightgrey
|
||||||
|
@ -107,3 +107,7 @@ string_token_streak_league_won0 _LEAGUEWON0_
|
|||||||
string_token_streak_league_lost0 _LEAGUELOST0_
|
string_token_streak_league_lost0 _LEAGUELOST0_
|
||||||
string_token_streak_league_won1 _LEAGUEWON1_
|
string_token_streak_league_won1 _LEAGUEWON1_
|
||||||
string_token_streak_league_lost1 _LEAGUELOST1_
|
string_token_streak_league_lost1 _LEAGUELOST1_
|
||||||
|
string_token_streak_unbeaten0 _UNBEATEN0_
|
||||||
|
string_token_streak_unbeaten1 _UNBEATEN1_
|
||||||
|
string_token_streak_league_unbeaten0 _LEAGUEUNBEATEN0_
|
||||||
|
string_token_streak_league_unbeaten1 _LEAGUEUNBEATEN1_
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
<title>_TL_ loses again!</title>
|
<title>_TL_ loses again!</title>
|
||||||
<title>_TL_ in a world of misery!</title>
|
<title>_TL_ in a world of misery!</title>
|
||||||
<title>_LEAGUECUPNAME_: _TL_ loses to _TW_!</title>
|
<title>_LEAGUECUPNAME_: _TL_ loses to _TW_!</title>
|
||||||
|
<subtitle priority="20" condition= "_UNBEATEN_TWN__ > 2">_TW_ unbeaten since _UNBEATEN_TWN__ matches.</subtitle>
|
||||||
<subtitle>Result: _RE_</subtitle>
|
<subtitle>Result: _RE_</subtitle>
|
||||||
<subtitle>_TL_ doesn't stand a chance against a _GOALS_TWN__ goal barrage.</subtitle>
|
<subtitle>_TL_ doesn't stand a chance against a _GOALS_TWN__ goal barrage.</subtitle>
|
||||||
<subtitle>_RE_ is flattering for _TL_.</subtitle>
|
<subtitle>_RE_ is flattering for _TL_.</subtitle>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user