File diff r27147:5d938ed2c7b5 → r27148:4e041ae27b9d
src/news_gui.cpp
Show inline comments
 
@@ -10,12 +10,13 @@
 
#include "stdafx.h"
 
#include "gui.h"
 
#include "viewport_func.h"
 
#include "strings_func.h"
 
#include "window_func.h"
 
#include "date_func.h"
 
#include "timer/timer_game_calendar.h"
 
#include "vehicle_base.h"
 
#include "vehicle_func.h"
 
#include "vehicle_gui.h"
 
#include "roadveh.h"
 
#include "station_base.h"
 
#include "industry.h"
 
@@ -683,13 +684,13 @@ static void MoveToNextTickerItem()
 
	while (_statusbar_news_item != _latest_news) {
 
		_statusbar_news_item = (_statusbar_news_item == nullptr) ? _oldest_news : _statusbar_news_item->next;
 
		const NewsItem *ni = _statusbar_news_item;
 
		const NewsType type = ni->type;
 

	
 
		/* check the date, don't show too old items */
 
		if (_date - _news_type_data[type].age > ni->date) continue;
 
		if (TimerGameCalendar::date - _news_type_data[type].age > ni->date) continue;
 

	
 
		switch (_news_type_data[type].GetDisplay()) {
 
			default: NOT_REACHED();
 
			case ND_OFF: // Off - show nothing only a small reminder in the status bar
 
				InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SHOW_REMINDER);
 
				break;
 
@@ -720,13 +721,13 @@ static void MoveToNextNewsItem()
 
	while (_current_news != _latest_news) {
 
		_current_news = (_current_news == nullptr) ? _oldest_news : _current_news->next;
 
		const NewsItem *ni = _current_news;
 
		const NewsType type = ni->type;
 

	
 
		/* check the date, don't show too old items */
 
		if (_date - _news_type_data[type].age > ni->date) continue;
 
		if (TimerGameCalendar::date - _news_type_data[type].age > ni->date) continue;
 

	
 
		switch (_news_type_data[type].GetDisplay()) {
 
			default: NOT_REACHED();
 
			case ND_OFF: // Off - show nothing only a small reminder in the status bar, skipped here
 
				continue;
 

	
 
@@ -797,16 +798,16 @@ static void DeleteNewsItem(NewsItem *ni)
 
 * @param ref2      Reference 2 to some object: Used for scrolling after clicking on the news, and for deleting the news when the object is deleted.
 
 * @param data      Pointer to data that must be released once the news message is cleared.
 
 *
 
 * @see NewsSubtype
 
 */
 
NewsItem::NewsItem(StringID string_id, NewsType type, NewsFlag flags, NewsReferenceType reftype1, uint32 ref1, NewsReferenceType reftype2, uint32 ref2, const NewsAllocatedData *data) :
 
	string_id(string_id), date(_date), type(type), flags(flags), reftype1(reftype1), reftype2(reftype2), ref1(ref1), ref2(ref2), data(data)
 
	string_id(string_id), date(TimerGameCalendar::date), type(type), flags(flags), reftype1(reftype1), reftype2(reftype2), ref1(ref1), ref2(ref2), data(data)
 
{
 
	/* show this news message in colour? */
 
	if (_cur_year >= _settings_client.gui.coloured_news_year) this->flags |= NF_INCOLOUR;
 
	if (TimerGameCalendar::year >= _settings_client.gui.coloured_news_year) this->flags |= NF_INCOLOUR;
 
	CopyOutDParam(this->params, 0, lengthof(this->params));
 
}
 

	
 
/**
 
 * Add a new newsitem to be shown.
 
 * @param string String to display
 
@@ -980,13 +981,13 @@ void DeleteInvalidEngineNews()
 

	
 
static void RemoveOldNewsItems()
 
{
 
	NewsItem *next;
 
	for (NewsItem *cur = _oldest_news; _total_news > MIN_NEWS_AMOUNT && cur != nullptr; cur = next) {
 
		next = cur->next;
 
		if (_date - _news_type_data[cur->type].age * _settings_client.gui.news_message_timeout > cur->date) DeleteNewsItem(cur);
 
		if (TimerGameCalendar::date - _news_type_data[cur->type].age * _settings_client.gui.news_message_timeout > cur->date) DeleteNewsItem(cur);
 
	}
 
}
 

	
 
/**
 
 * Report a change in vehicle IDs (due to autoreplace) to affected vehicle news.
 
 * @note Viewports of currently displayed news is changed via #ChangeVehicleViewports
 
@@ -1006,15 +1007,15 @@ void NewsLoop()
 
{
 
	/* no news item yet */
 
	if (_total_news == 0) return;
 

	
 
	static byte _last_clean_month = 0;
 

	
 
	if (_last_clean_month != _cur_month) {
 
	if (_last_clean_month != TimerGameCalendar::month) {
 
		RemoveOldNewsItems();
 
		_last_clean_month = _cur_month;
 
		_last_clean_month = TimerGameCalendar::month;
 
	}
 

	
 
	if (ReadyForNextTickerItem()) MoveToNextTickerItem();
 
	if (ReadyForNextNewsItem()) MoveToNextNewsItem();
 
}