Newspaper options.

This commit is contained in:
gyboth 2008-12-16 13:55:51 +00:00
parent e7285746aa
commit 729f2a7671
9 changed files with 66 additions and 44 deletions

View File

@ -59,6 +59,9 @@ callback_show_next_live_game(void)
for(i=0;i<users->len;i++) for(i=0;i<users->len;i++)
usr(i).counters[COUNT_USER_TOOK_TURN] = 0; usr(i).counters[COUNT_USER_TOOK_TURN] = 0;
counters[COUNT_NEWS_SHOWN] =
counters[COUNT_NEW_NEWS] = 0;
for(i=0;i<ligs->len;i++) for(i=0;i<ligs->len;i++)
for(j=0;j<lig(i).fixtures->len;j++) for(j=0;j<lig(i).fixtures->len;j++)
if(g_array_index(lig(i).fixtures, Fixture, j).week_number == week && if(g_array_index(lig(i).fixtures, Fixture, j).week_number == week &&

View File

@ -218,6 +218,13 @@ on_button_back_to_main_clicked (GtkButton *button,
game_gui_show_main(); game_gui_show_main();
gui_set_arrows(); gui_set_arrows();
if((opt_int("int_opt_news_popup") == 2 ||
(opt_int("int_opt_news_popup") == 1 &&
counters[COUNT_NEW_NEWS] == 1)) &&
counters[COUNT_NEWS_SHOWN] == 0 &&
counters[COUNT_NEW_NEWS] != 0)
on_menu_news_activate(NULL, NULL);
} }
@ -1659,5 +1666,6 @@ on_menu_news_activate (GtkMenuItem *menuitem,
{ {
window_create(WINDOW_NEWS); window_create(WINDOW_NEWS);
treeview2_show_news(); treeview2_show_news();
counters[COUNT_NEWS_SHOWN] = 1;
} }

View File

@ -42,6 +42,8 @@ enum Counters
COUNT_NEWS_ARTICLE_ID, COUNT_NEWS_ARTICLE_ID,
COUNT_SHOW_DEBUG, COUNT_SHOW_DEBUG,
COUNT_HINT_NUMBER, COUNT_HINT_NUMBER,
COUNT_NEWS_SHOWN,
COUNT_NEW_NEWS,
COUNT_END COUNT_END
}; };

View File

@ -83,6 +83,13 @@ news_generate_match(const LiveGame *live_game)
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); new_article.user_idx = fixture_user_team_involved(live_game->fix);
if(counters[COUNT_NEW_NEWS] == 0)
counters[COUNT_NEW_NEWS] = 2;
if(new_article.user_idx != -1)
counters[COUNT_NEW_NEWS] = 1;
g_array_append_val(newspaper.articles, new_article); g_array_append_val(newspaper.articles, new_article);
} }
@ -748,20 +755,23 @@ news_check_match_relevant(const LiveGame *live_game)
gint i; gint i;
GArray *user_leagues; GArray *user_leagues;
if(fixture_user_team_involved(live_game->fix) != -1) if(fixture_user_team_involved(live_game->fix) != -1 &&
opt_int("int_opt_news_create_user"))
return TRUE; return TRUE;
user_leagues = g_array_new(FALSE, FALSE, sizeof(gint)); user_leagues = g_array_new(FALSE, FALSE, sizeof(gint));
if(live_game->fix->clid >= ID_CUP_START && if(live_game->fix->clid >= ID_CUP_START &&
live_game->fix->round >= cup_from_clid(live_game->fix->clid)->rounds->len - 4) live_game->fix->round >= cup_from_clid(live_game->fix->clid)->rounds->len - 4 &&
opt_int("int_opt_news_create_cup"))
return TRUE; return TRUE;
for(i = 0; i < users->len; i++) for(i = 0; i < users->len; i++)
if(!query_misc_integer_is_in_g_array(usr(i).tm->clid, user_leagues)) if(!query_misc_integer_is_in_g_array(usr(i).tm->clid, user_leagues))
g_array_append_val(user_leagues, usr(i).tm->clid); g_array_append_val(user_leagues, usr(i).tm->clid);
if(query_misc_integer_is_in_g_array(live_game->fix->clid, user_leagues)) if(query_misc_integer_is_in_g_array(live_game->fix->clid, user_leagues) &&
opt_int("int_opt_news_create_league"))
{ {
g_array_free(user_leagues, TRUE); g_array_free(user_leagues, TRUE);
return TRUE; return TRUE;

View File

@ -205,19 +205,19 @@ option_gui_write_bool_widgets(gint **bool_options, GtkToggleButton **bool_widget
bool_widgets[BOOL_OPT_NEWS_USER] = bool_widgets[BOOL_OPT_NEWS_USER] =
GTK_TOGGLE_BUTTON(lookup_widget(window.options, "checkbutton_news_user")); GTK_TOGGLE_BUTTON(lookup_widget(window.options, "checkbutton_news_user"));
bool_options[BOOL_OPT_NEWS_USER] = opt_user_intp("int_opt_user_news_create_user"); bool_options[BOOL_OPT_NEWS_USER] = opt_intp("int_opt_news_create_user");
bool_widgets[BOOL_OPT_NEWS_CUP] = bool_widgets[BOOL_OPT_NEWS_CUP] =
GTK_TOGGLE_BUTTON(lookup_widget(window.options, "checkbutton_news_cup")); GTK_TOGGLE_BUTTON(lookup_widget(window.options, "checkbutton_news_cup"));
bool_options[BOOL_OPT_NEWS_CUP] = opt_user_intp("int_opt_user_news_create_cup"); bool_options[BOOL_OPT_NEWS_CUP] = opt_intp("int_opt_news_create_cup");
bool_widgets[BOOL_OPT_NEWS_LEAGUE] = bool_widgets[BOOL_OPT_NEWS_LEAGUE] =
GTK_TOGGLE_BUTTON(lookup_widget(window.options, "checkbutton_news_league")); GTK_TOGGLE_BUTTON(lookup_widget(window.options, "checkbutton_news_league"));
bool_options[BOOL_OPT_NEWS_LEAGUE] = opt_user_intp("int_opt_user_news_create_league"); bool_options[BOOL_OPT_NEWS_LEAGUE] = opt_intp("int_opt_news_create_league");
bool_widgets[BOOL_OPT_NEWS_RECENT] = bool_widgets[BOOL_OPT_NEWS_RECENT] =
GTK_TOGGLE_BUTTON(lookup_widget(window.options, "checkbutton_news_recent")); GTK_TOGGLE_BUTTON(lookup_widget(window.options, "checkbutton_news_recent"));
bool_options[BOOL_OPT_NEWS_RECENT] = opt_user_intp("int_opt_user_news_show_recent"); bool_options[BOOL_OPT_NEWS_RECENT] = opt_intp("int_opt_news_show_recent");
bool_widgets[BOOL_OPT_PL1_ATT_NAME] = bool_widgets[BOOL_OPT_PL1_ATT_NAME] =
GTK_TOGGLE_BUTTON(lookup_widget(window.options, "checkbutton1")); GTK_TOGGLE_BUTTON(lookup_widget(window.options, "checkbutton1"));
@ -513,7 +513,7 @@ option_gui_set_up_window(void)
GTK_SPIN_BUTTON(lookup_widget(window.options, "spinbutton_recreation")))); GTK_SPIN_BUTTON(lookup_widget(window.options, "spinbutton_recreation"))));
gtk_label_set_text(GTK_LABEL(lookup_widget(window.options, "label_training")), buf); gtk_label_set_text(GTK_LABEL(lookup_widget(window.options, "label_training")), buf);
gtk_toggle_button_set_active(news_popup_buttons[opt_user_int("int_opt_user_news_popup")], TRUE); gtk_toggle_button_set_active(news_popup_buttons[opt_int("int_opt_news_popup")], TRUE);
} }
/** Read the widget states in the options window and set the /** Read the widget states in the options window and set the
@ -569,7 +569,7 @@ option_gui_write_options(void)
for(i = 0; i < 3; i++) for(i = 0; i < 3; i++)
if(gtk_toggle_button_get_active(news_popup_buttons[i])) if(gtk_toggle_button_get_active(news_popup_buttons[i]))
{ {
opt_user_set_int("int_opt_user_news_popup", i); opt_set_int("int_opt_news_popup", i);
break; break;
} }

View File

@ -526,7 +526,8 @@ end_week_round_generate_news(void)
for(i = 0; i < users->len; i++) for(i = 0; i < users->len; i++)
if(usr(i).live_game.fix != NULL && if(usr(i).live_game.fix != NULL &&
usr(i).live_game.fix->week_number == week && usr(i).live_game.fix->week_number == week &&
usr(i).live_game.fix->week_round_number == week_round) usr(i).live_game.fix->week_round_number == week_round &&
news_check_match_relevant(&usr(i).live_game))
news_generate_match(&usr(i).live_game); news_generate_match(&usr(i).live_game);
/** News for other matches. */ /** News for other matches. */

View File

@ -603,29 +603,33 @@ treeview2_create_news(GtkListStore *ls)
for(i = newspaper.articles->len - 1; i >= 0; i--) for(i = newspaper.articles->len - 1; i >= 0; i--)
{ {
if(i == newspaper.articles->len - 1 || if(!opt_int("int_opt_news_show_recent") ||
(i < newspaper.articles->len - 1 && g_array_index(newspaper.articles, NewsPaperArticle, i).week_number == week - 1)
(g_array_index(newspaper.articles, NewsPaperArticle, i).week_number !=
g_array_index(newspaper.articles, NewsPaperArticle, i + 1).week_number ||
g_array_index(newspaper.articles, NewsPaperArticle, i).week_round_number !=
g_array_index(newspaper.articles, NewsPaperArticle, i + 1).week_round_number)))
{
gtk_list_store_append(ls, &iter);
gtk_list_store_set(ls, &iter, 0, "", 1, NULL, -1);
gtk_list_store_append(ls, &iter);
sprintf(buf2, _("Week %d Round %d"),
g_array_index(newspaper.articles, NewsPaperArticle, i).week_number,
g_array_index(newspaper.articles, NewsPaperArticle, i).week_round_number);
sprintf(buf, "<span %s>%s</span>\n\n",
const_app("string_news_window_week_number_attribute"),
buf2);
gtk_list_store_set(ls, &iter, 0, buf, 1, &g_array_index(newspaper.articles, NewsPaperArticle, i), -1);
}
else
{ {
gtk_list_store_append(ls, &iter); if(i == newspaper.articles->len - 1 ||
gtk_list_store_set(ls, &iter, 0, "", 1, &g_array_index(newspaper.articles, NewsPaperArticle, i), -1); (i < newspaper.articles->len - 1 &&
(g_array_index(newspaper.articles, NewsPaperArticle, i).week_number !=
g_array_index(newspaper.articles, NewsPaperArticle, i + 1).week_number ||
g_array_index(newspaper.articles, NewsPaperArticle, i).week_round_number !=
g_array_index(newspaper.articles, NewsPaperArticle, i + 1).week_round_number)))
{
gtk_list_store_append(ls, &iter);
gtk_list_store_set(ls, &iter, 0, "", 1, NULL, -1);
gtk_list_store_append(ls, &iter);
sprintf(buf2, _("Week %d Round %d"),
g_array_index(newspaper.articles, NewsPaperArticle, i).week_number,
g_array_index(newspaper.articles, NewsPaperArticle, i).week_round_number);
sprintf(buf, "<span %s>%s</span>\n\n",
const_app("string_news_window_week_number_attribute"),
buf2);
gtk_list_store_set(ls, &iter, 0, buf, 1, &g_array_index(newspaper.articles, NewsPaperArticle, i), -1);
}
else
{
gtk_list_store_append(ls, &iter);
gtk_list_store_set(ls, &iter, 0, "", 1, &g_array_index(newspaper.articles, NewsPaperArticle, i), -1);
}
} }
} }
} }

View File

@ -19,9 +19,9 @@ string_opt_language_code
int_opt_calodds 0 int_opt_calodds 0
int_opt_load_defs 1 int_opt_load_defs 1
int_opt_randomise_teams 0 int_opt_randomise_teams 0
int_opt_calodds 0
int_opt_load_defs 1 int_opt_news_create_user 1
int_opt_randomise_teams 0 int_opt_news_create_cup 1
int_opt_calodds 0 int_opt_news_create_league 1
int_opt_load_defs 1 int_opt_news_show_recent 0
int_opt_randomise_teams 0 int_opt_news_popup 0

View File

@ -31,12 +31,6 @@ int_opt_user_bet_default_wager 5000
int_opt_user_training_camp_hotel 1 int_opt_user_training_camp_hotel 1
int_opt_user_training_camp_recreation 5 int_opt_user_training_camp_recreation 5
int_opt_user_news_create_user 1
int_opt_user_news_create_cup 1
int_opt_user_news_create_league 1
int_opt_user_news_show_recent 0
int_opt_user_news_popup 0
# the order of these attributes is important # the order of these attributes is important
# don't change it, only the values # don't change it, only the values
int_opt_user_pl1_att_name 1 int_opt_user_pl1_att_name 1