diff --git a/src/callback_func.c b/src/callback_func.c index 2480bbd5..ce4b9e3b 100644 --- a/src/callback_func.c +++ b/src/callback_func.c @@ -59,6 +59,9 @@ callback_show_next_live_game(void) for(i=0;ilen;i++) usr(i).counters[COUNT_USER_TOOK_TURN] = 0; + counters[COUNT_NEWS_SHOWN] = + counters[COUNT_NEW_NEWS] = 0; + for(i=0;ilen;i++) for(j=0;jlen;j++) if(g_array_index(lig(i).fixtures, Fixture, j).week_number == week && diff --git a/src/callbacks.c b/src/callbacks.c index bc3ffe34..4e01c45b 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -218,6 +218,13 @@ on_button_back_to_main_clicked (GtkButton *button, game_gui_show_main(); 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); treeview2_show_news(); + counters[COUNT_NEWS_SHOWN] = 1; } diff --git a/src/enums.h b/src/enums.h index 24dc2e8f..74818f7b 100644 --- a/src/enums.h +++ b/src/enums.h @@ -42,6 +42,8 @@ enum Counters COUNT_NEWS_ARTICLE_ID, COUNT_SHOW_DEBUG, COUNT_HINT_NUMBER, + COUNT_NEWS_SHOWN, + COUNT_NEW_NEWS, COUNT_END }; diff --git a/src/news.c b/src/news.c index 7b6e389b..85c0e4b7 100644 --- a/src/news.c +++ b/src/news.c @@ -83,6 +83,13 @@ news_generate_match(const LiveGame *live_game) new_article.title_id = title_id; new_article.subtitle_id = subtitle_id; 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); } @@ -748,20 +755,23 @@ news_check_match_relevant(const LiveGame *live_game) gint i; 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; user_leagues = g_array_new(FALSE, FALSE, sizeof(gint)); 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; for(i = 0; i < users->len; i++) if(!query_misc_integer_is_in_g_array(usr(i).tm->clid, user_leagues)) 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); return TRUE; diff --git a/src/option_gui.c b/src/option_gui.c index b4ea8eaf..856d6cbd 100644 --- a/src/option_gui.c +++ b/src/option_gui.c @@ -205,19 +205,19 @@ option_gui_write_bool_widgets(gint **bool_options, GtkToggleButton **bool_widget bool_widgets[BOOL_OPT_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] = 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] = 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] = 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] = 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_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 @@ -569,7 +569,7 @@ option_gui_write_options(void) for(i = 0; i < 3; 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; } diff --git a/src/start_end.c b/src/start_end.c index 558d75e6..48b5641c 100644 --- a/src/start_end.c +++ b/src/start_end.c @@ -526,7 +526,8 @@ end_week_round_generate_news(void) for(i = 0; i < users->len; i++) if(usr(i).live_game.fix != NULL && 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 for other matches. */ diff --git a/src/treeview2.c b/src/treeview2.c index 17dc281e..4e5b2f1d 100644 --- a/src/treeview2.c +++ b/src/treeview2.c @@ -603,29 +603,33 @@ treeview2_create_news(GtkListStore *ls) for(i = newspaper.articles->len - 1; i >= 0; i--) { - if(i == newspaper.articles->len - 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, "%s\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 + if(!opt_int("int_opt_news_show_recent") || + g_array_index(newspaper.articles, NewsPaperArticle, i).week_number == week - 1) { - gtk_list_store_append(ls, &iter); - gtk_list_store_set(ls, &iter, 0, "", 1, &g_array_index(newspaper.articles, NewsPaperArticle, i), -1); + if(i == newspaper.articles->len - 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, "%s\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); + } } } } diff --git a/support_files/bygfoot.conf b/support_files/bygfoot.conf index e731051a..2c03f81a 100644 --- a/support_files/bygfoot.conf +++ b/support_files/bygfoot.conf @@ -19,9 +19,9 @@ string_opt_language_code int_opt_calodds 0 int_opt_load_defs 1 int_opt_randomise_teams 0 -int_opt_calodds 0 -int_opt_load_defs 1 -int_opt_randomise_teams 0 -int_opt_calodds 0 -int_opt_load_defs 1 -int_opt_randomise_teams 0 + +int_opt_news_create_user 1 +int_opt_news_create_cup 1 +int_opt_news_create_league 1 +int_opt_news_show_recent 0 +int_opt_news_popup 0 diff --git a/support_files/bygfoot_user.conf b/support_files/bygfoot_user.conf index 65bda00d..88dbec7a 100644 --- a/support_files/bygfoot_user.conf +++ b/support_files/bygfoot_user.conf @@ -31,12 +31,6 @@ int_opt_user_bet_default_wager 5000 int_opt_user_training_camp_hotel 1 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 # don't change it, only the values int_opt_user_pl1_att_name 1