src/news_gui.cpp
changeset 10570 b83e3644d1da
parent 10567 7247abc43c7e
child 10571 55cc869d11e3
equal deleted inserted replaced
10569:1359ca399ddd 10570:b83e3644d1da
    16 #include "vehicle_base.h"
    16 #include "vehicle_base.h"
    17 #include "sound_func.h"
    17 #include "sound_func.h"
    18 #include "string_func.h"
    18 #include "string_func.h"
    19 #include "widgets/dropdown_func.h"
    19 #include "widgets/dropdown_func.h"
    20 #include "map_func.h"
    20 #include "map_func.h"
       
    21 #include "statusbar_gui.h"
    21 
    22 
    22 #include "table/sprites.h"
    23 #include "table/sprites.h"
    23 #include "table/strings.h"
    24 #include "table/strings.h"
    24 
    25 
    25 /** @file news_gui.cpp
    26 /** @file news_gui.cpp
   470 static void ShowTicker(const NewsItem *ni)
   471 static void ShowTicker(const NewsItem *ni)
   471 {
   472 {
   472 	if (_news_ticker_sound) SndPlayFx(SND_16_MORSE);
   473 	if (_news_ticker_sound) SndPlayFx(SND_16_MORSE);
   473 
   474 
   474 	_statusbar_news_item = *ni;
   475 	_statusbar_news_item = *ni;
   475 	Window *w = FindWindowById(WC_STATUS_BAR, 0);
   476 	InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SHOW_TICKER);
   476 	if (w != NULL) WP(w, def_d).data_1 = 360;
       
   477 }
   477 }
   478 
   478 
   479 
   479 
   480 /**
   480 /**
   481  * Are we ready to show another news item?
   481  * Are we ready to show another news item?
   488 	if (item >= _max_news_items) return true;
   488 	if (item >= _max_news_items) return true;
   489 	NewsItem *ni = &_news_items[item];
   489 	NewsItem *ni = &_news_items[item];
   490 
   490 
   491 	/* Ticker message
   491 	/* Ticker message
   492 	 * Check if the status bar message is still being displayed? */
   492 	 * Check if the status bar message is still being displayed? */
   493 	const Window *w = FindWindowById(WC_STATUS_BAR, 0);
   493 	if (IsNewsTickerShown()) return false;
   494 	if (w != NULL && WP(w, const def_d).data_1 > -1280) return false;
       
   495 
   494 
   496 	/* Newspaper message, decrement duration counter */
   495 	/* Newspaper message, decrement duration counter */
   497 	if (ni->duration != 0) ni->duration--;
   496 	if (ni->duration != 0) ni->duration--;
   498 
   497 
   499 	/* neither newsticker nor newspaper are running */
   498 	/* neither newsticker nor newspaper are running */
   515 		/* check the date, don't show too old items */
   514 		/* check the date, don't show too old items */
   516 		if (_date - _news_type_data[type].age > ni->date) return;
   515 		if (_date - _news_type_data[type].age > ni->date) return;
   517 
   516 
   518 		switch (_news_type_data[type].display) {
   517 		switch (_news_type_data[type].display) {
   519 			default: NOT_REACHED();
   518 			default: NOT_REACHED();
   520 			case ND_OFF: { // Off - show nothing only a small reminder in the status bar
   519 			case ND_OFF: // Off - show nothing only a small reminder in the status bar
   521 				Window *w = FindWindowById(WC_STATUS_BAR, 0);
   520 				InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SHOW_REMINDER);
   522 
       
   523 				if (w != NULL) {
       
   524 					WP(w, def_d).data_2 = 91;
       
   525 					w->SetDirty();
       
   526 				}
       
   527 				break;
   521 				break;
   528 			}
       
   529 
   522 
   530 			case ND_SUMMARY: // Summary - show ticker, but if forced big, cascade to full
   523 			case ND_SUMMARY: // Summary - show ticker, but if forced big, cascade to full
   531 				if (!(ni->flags & NF_FORCE_BIG)) {
   524 				if (!(ni->flags & NF_FORCE_BIG)) {
   532 					ShowTicker(ni);
   525 					ShowTicker(ni);
   533 					break;
   526 					break;