news_gui.c
changeset 4874 afafed841c6d
parent 4873 11880cbbc9f6
child 4912 0f51b47cb983
equal deleted inserted replaced
4873:11880cbbc9f6 4874:afafed841c6d
   233  * @param flags various control bits that will show various news-types. See macro NEWS_FLAGS()
   233  * @param flags various control bits that will show various news-types. See macro NEWS_FLAGS()
   234  * @param data_a news-specific value based on news type
   234  * @param data_a news-specific value based on news type
   235  * @param data_b news-specific value based on news type
   235  * @param data_b news-specific value based on news type
   236  * @note flags exists of 4 byte-sized extra parameters.<br/>
   236  * @note flags exists of 4 byte-sized extra parameters.<br/>
   237  * 1.  0 -  7 display_mode, any of the NewsMode enums (NM_)<br/>
   237  * 1.  0 -  7 display_mode, any of the NewsMode enums (NM_)<br/>
   238  * 2.  8 - 15 news flags, any of the NewsFlags enums (NF_) NF_NOEXPIRE and
   238  * 2.  8 - 15 news flags, any of the NewsFlags enums (NF_) NF_INCOLOR are set automatically if needed<br/>
   239  * NF_INCOLOR are set automatically if needed<br/>
       
   240  * 3. 16 - 23 news category, any of the NewsType enums (NT_)<br/>
   239  * 3. 16 - 23 news category, any of the NewsType enums (NT_)<br/>
   241  * 4. 24 - 31 news callback function, any of the NewsCallback enums (DNC_)<br/>
   240  * 4. 24 - 31 news callback function, any of the NewsCallback enums (DNC_)<br/>
   242  * If the display mode is NM_CALLBACK special news is shown and parameter
   241  * If the display mode is NM_CALLBACK special news is shown and parameter
   243  * stringid has a special meaning.<br/>
   242  * stringid has a special meaning.<br/>
   244  * DNC_TRAINAVAIL, DNC_ROADAVAIL, DNC_SHIPAVAIL, DNC_AIRCRAFTAVAIL: StringID is
   243  * DNC_TRAINAVAIL, DNC_ROADAVAIL, DNC_SHIPAVAIL, DNC_AIRCRAFTAVAIL: StringID is
   274 	ni = &_news_items[_latest_news];
   273 	ni = &_news_items[_latest_news];
   275 	memset(ni, 0, sizeof(*ni));
   274 	memset(ni, 0, sizeof(*ni));
   276 
   275 
   277 	ni->string_id = string;
   276 	ni->string_id = string;
   278 	ni->display_mode = (byte)flags;
   277 	ni->display_mode = (byte)flags;
   279 	ni->flags = (byte)(flags >> 8) | NF_NOEXPIRE;
   278 	ni->flags = (byte)(flags >> 8);
   280 
   279 
   281 	// show this news message in color?
   280 	// show this news message in color?
   282 	if (_cur_year >= _patches.colored_news_year)
   281 	if (_cur_year >= _patches.colored_news_year)
   283 		ni->flags |= NF_INCOLOR;
   282 		ni->flags |= NF_INCOLOR;
   284 
   283 
   382 static void ShowNewspaper(NewsItem *ni)
   381 static void ShowNewspaper(NewsItem *ni)
   383 {
   382 {
   384 	Window *w;
   383 	Window *w;
   385 	SoundFx sound;
   384 	SoundFx sound;
   386 	int top;
   385 	int top;
   387 	ni->flags &= ~(NF_NOEXPIRE | NF_FORCE_BIG);
   386 	ni->flags &= ~NF_FORCE_BIG;
   388 	ni->duration = 555;
   387 	ni->duration = 555;
   389 
   388 
   390 	sound = _news_sounds[ni->type];
   389 	sound = _news_sounds[ni->type];
   391 	if (sound != 0) SndPlayFx(sound);
   390 	if (sound != 0) SndPlayFx(sound);
   392 
   391 
   524 	_forced_news = i;
   523 	_forced_news = i;
   525 
   524 
   526 	if (_forced_news != INVALID_NEWS) {
   525 	if (_forced_news != INVALID_NEWS) {
   527 		NewsItem *ni = &_news_items[_forced_news];
   526 		NewsItem *ni = &_news_items[_forced_news];
   528 		ni->duration = 555;
   527 		ni->duration = 555;
   529 		ni->flags |= NF_NOEXPIRE | NF_FORCE_BIG;
   528 		ni->flags |= NF_FORCE_BIG;
   530 		DeleteWindowById(WC_NEWS_WINDOW, 0);
   529 		DeleteWindowById(WC_NEWS_WINDOW, 0);
   531 		ShowNewspaper(ni);
   530 		ShowNewspaper(ni);
   532 	}
   531 	}
   533 }
   532 }
   534 
   533