420 |
419 |
421 if (_news_ticker_sound) SndPlayFx(SND_16_MORSE); |
420 if (_news_ticker_sound) SndPlayFx(SND_16_MORSE); |
422 |
421 |
423 _statusbar_news_item = *ni; |
422 _statusbar_news_item = *ni; |
424 w = FindWindowById(WC_STATUS_BAR, 0); |
423 w = FindWindowById(WC_STATUS_BAR, 0); |
425 if (w != NULL) |
424 if (w != NULL) WP(w, def_d).data_1 = 360; |
426 WP(w, def_d).data_1 = 360; |
|
427 } |
425 } |
428 |
426 |
429 |
427 |
430 // Are we ready to show another news item? |
428 // Are we ready to show another news item? |
431 // Only if nothing is in the newsticker and no newspaper is displayed |
429 // Only if nothing is in the newsticker and no newspaper is displayed |
439 ni = &_news_items[item]; |
437 ni = &_news_items[item]; |
440 |
438 |
441 // Ticker message |
439 // Ticker message |
442 // Check if the status bar message is still being displayed? |
440 // Check if the status bar message is still being displayed? |
443 w = FindWindowById(WC_STATUS_BAR, 0); |
441 w = FindWindowById(WC_STATUS_BAR, 0); |
444 if (w != NULL && WP(w, def_d).data_1 > -1280) |
442 if (w != NULL && WP(w, const def_d).data_1 > -1280) return false; |
445 return false; |
|
446 |
443 |
447 // Newspaper message |
444 // Newspaper message |
448 // Wait until duration reaches 0 |
445 // Wait until duration reaches 0 |
449 if (ni->duration != 0) { |
446 if (ni->duration != 0) { |
450 ni->duration--; |
447 ni->duration--; |
466 |
463 |
467 _current_news = increaseIndex(_current_news); |
464 _current_news = increaseIndex(_current_news); |
468 ni = &_news_items[_current_news]; |
465 ni = &_news_items[_current_news]; |
469 |
466 |
470 // check the date, don't show too old items |
467 // check the date, don't show too old items |
471 if (_date - _news_items_age[ni->type] > ni->date) |
468 if (_date - _news_items_age[ni->type] > ni->date) return; |
472 return; |
|
473 |
469 |
474 // execute the validation function to see if this item is still valid |
470 // execute the validation function to see if this item is still valid |
475 if ( ni->isValid != NULL && !ni->isValid(ni->data_a, ni->data_b) ) |
471 if (ni->isValid != NULL && !ni->isValid(ni->data_a, ni->data_b)) return; |
476 return; |
472 |
477 |
473 switch (GetNewsDisplayValue(ni->type)) { |
478 switch (GetNewsDisplayValue(ni->type)) { |
474 case 0: { /* Off - show nothing only a small reminder in the status bar */ |
479 case 0: { /* Off - show nothing only a small reminder in the status bar */ |
475 Window* w = FindWindowById(WC_STATUS_BAR, 0); |
480 Window *w = FindWindowById(WC_STATUS_BAR, 0); |
476 |
481 if (w != NULL) { |
477 if (w != NULL) { |
482 WP(w, def_d).data_2 = 91; |
478 WP(w, def_d).data_2 = 91; |
483 SetWindowDirty(w); |
479 SetWindowDirty(w); |
484 } |
480 } |
485 } break; |
481 break; |
486 case 1: /* Summary - show ticker, but if forced big, cascade to full */ |
482 } |
487 if (!(ni->flags & NF_FORCE_BIG)) { |
483 |
488 ShowTicker(ni); |
484 case 1: /* Summary - show ticker, but if forced big, cascade to full */ |
489 break; |
485 if (!(ni->flags & NF_FORCE_BIG)) { |
490 } |
486 ShowTicker(ni); |
491 /* Fallthrough */ |
487 break; |
492 case 2: /* Full - show newspaper*/ |
488 } |
493 ShowNewspaper(ni); |
489 /* Fallthrough */ |
494 break; |
490 |
495 } |
491 case 2: /* Full - show newspaper*/ |
|
492 ShowNewspaper(ni); |
|
493 break; |
|
494 } |
496 } |
495 } |
497 } |
496 } |
498 |
497 |
499 void NewsLoop(void) |
498 void NewsLoop(void) |
500 { |
499 { |
501 // no news item yet |
500 // no news item yet |
502 if (_total_news == 0) return; |
501 if (_total_news == 0) return; |
503 |
502 |
504 if (ReadyForNextItem()) |
503 if (ReadyForNextItem()) MoveToNexItem(); |
505 MoveToNexItem(); |
|
506 } |
504 } |
507 |
505 |
508 /* Do a forced show of a specific message */ |
506 /* Do a forced show of a specific message */ |
509 static void ShowNewsMessage(byte i) |
507 static void ShowNewsMessage(byte i) |
510 { |
508 { |
539 |
537 |
540 /* return news by number, with 0 being the most |
538 /* return news by number, with 0 being the most |
541 recent news. Returns INVALID_NEWS if end of queue reached. */ |
539 recent news. Returns INVALID_NEWS if end of queue reached. */ |
542 static byte getNews(byte i) |
540 static byte getNews(byte i) |
543 { |
541 { |
544 if (i >= _total_news) |
542 if (i >= _total_news) return INVALID_NEWS; |
545 return INVALID_NEWS; |
543 |
546 |
544 if (_latest_news < i) { |
547 if (_latest_news < i) |
|
548 i = _latest_news + MAX_NEWS - i; |
545 i = _latest_news + MAX_NEWS - i; |
549 else |
546 } else { |
550 i = _latest_news - i; |
547 i = _latest_news - i; |
|
548 } |
551 |
549 |
552 i %= MAX_NEWS; |
550 i %= MAX_NEWS; |
553 return i; |
551 return i; |
554 } |
552 } |
555 |
553 |