changeset 10794 | a6dc0c24f4c9 |
parent 10775 | 7061477bfbcf |
child 10798 | f304b6f7d614 |
10793:645e32bc09e7 | 10794:a6dc0c24f4c9 |
---|---|
166 }; |
166 }; |
167 |
167 |
168 struct NewsWindow : Window { |
168 struct NewsWindow : Window { |
169 uint16 chat_height; |
169 uint16 chat_height; |
170 NewsItem *ni; |
170 NewsItem *ni; |
171 static uint duration; |
|
171 |
172 |
172 NewsWindow(const WindowDesc *desc, NewsItem *ni) : Window(desc), ni(ni) |
173 NewsWindow(const WindowDesc *desc, NewsItem *ni) : Window(desc), ni(ni) |
173 { |
174 { |
175 NewsWindow::duration = 555; |
|
174 const Window *w = FindWindowById(WC_SEND_NETWORK_MSG, 0); |
176 const Window *w = FindWindowById(WC_SEND_NETWORK_MSG, 0); |
175 this->chat_height = (w != NULL) ? w->height : 0; |
177 this->chat_height = (w != NULL) ? w->height : 0; |
176 |
178 |
177 this->ni = _forced_news == NULL ? _current_news : _forced_news; |
179 this->ni = _forced_news == NULL ? _current_news : _forced_news; |
178 this->flags4 |= WF_DISABLE_VP_SCROLL; |
180 this->flags4 |= WF_DISABLE_VP_SCROLL; |
256 |
258 |
257 virtual void OnClick(Point pt, int widget) |
259 virtual void OnClick(Point pt, int widget) |
258 { |
260 { |
259 switch (widget) { |
261 switch (widget) { |
260 case 1: |
262 case 1: |
261 this->ni->duration = 0; |
263 NewsWindow::duration = 0; |
262 delete this; |
264 delete this; |
263 _forced_news = NULL; |
265 _forced_news = NULL; |
264 break; |
266 break; |
265 |
267 |
266 case 0: |
268 case 0: |
312 |
314 |
313 SetDirtyBlocks(this->left, this->top - diff, this->left + this->width, this->top + this->height); |
315 SetDirtyBlocks(this->left, this->top - diff, this->left + this->width, this->top + this->height); |
314 } |
316 } |
315 }; |
317 }; |
316 |
318 |
319 /* static */ uint NewsWindow::duration; ///< Remaining time for showing current news message |
|
320 |
|
317 |
321 |
318 static const Widget _news_type13_widgets[] = { |
322 static const Widget _news_type13_widgets[] = { |
319 { WWT_PANEL, RESIZE_NONE, 15, 0, 429, 0, 169, 0x0, STR_NULL}, |
323 { WWT_PANEL, RESIZE_NONE, 15, 0, 429, 0, 169, 0x0, STR_NULL}, |
320 { WWT_PANEL, RESIZE_NONE, 15, 0, 10, 0, 11, 0x0, STR_NULL}, |
324 { WWT_PANEL, RESIZE_NONE, 15, 0, 10, 0, 11, 0x0, STR_NULL}, |
321 { WIDGETS_END}, |
325 { WIDGETS_END}, |
359 |
363 |
360 /** Open up an own newspaper window for the news item */ |
364 /** Open up an own newspaper window for the news item */ |
361 static void ShowNewspaper(NewsItem *ni) |
365 static void ShowNewspaper(NewsItem *ni) |
362 { |
366 { |
363 ni->flags &= ~NF_FORCE_BIG; |
367 ni->flags &= ~NF_FORCE_BIG; |
364 ni->duration = 555; |
|
365 |
368 |
366 SoundFx sound = _news_type_data[_news_subtype_data[ni->subtype].type].sound; |
369 SoundFx sound = _news_type_data[_news_subtype_data[ni->subtype].type].sound; |
367 if (sound != 0) SndPlayFx(sound); |
370 if (sound != 0) SndPlayFx(sound); |
368 |
371 |
369 int top = _screen.height; |
372 int top = _screen.height; |
436 /* Ticker message |
439 /* Ticker message |
437 * Check if the status bar message is still being displayed? */ |
440 * Check if the status bar message is still being displayed? */ |
438 if (IsNewsTickerShown()) return false; |
441 if (IsNewsTickerShown()) return false; |
439 |
442 |
440 /* Newspaper message, decrement duration counter */ |
443 /* Newspaper message, decrement duration counter */ |
441 if (ni->duration != 0) ni->duration--; |
444 if (NewsWindow::duration != 0) NewsWindow::duration--; |
442 |
445 |
443 /* neither newsticker nor newspaper are running */ |
446 /* neither newsticker nor newspaper are running */ |
444 return (ni->duration == 0 || FindWindowById(WC_NEWS_WINDOW, 0) == NULL); |
447 return (NewsWindow::duration == 0 || FindWindowById(WC_NEWS_WINDOW, 0) == NULL); |
445 } |
448 } |
446 |
449 |
447 /** Move to the next news item */ |
450 /** Move to the next news item */ |
448 static void MoveToNextItem() |
451 static void MoveToNextItem() |
449 { |
452 { |
611 |
614 |
612 /* setup forced news item */ |
615 /* setup forced news item */ |
613 _forced_news = ni; |
616 _forced_news = ni; |
614 |
617 |
615 if (_forced_news != NULL) { |
618 if (_forced_news != NULL) { |
616 ni->duration = 555; |
619 NewsWindow::duration = 555; |
617 ni->flags |= NF_FORCE_BIG; |
620 ni->flags |= NF_FORCE_BIG; |
618 DeleteWindowById(WC_NEWS_WINDOW, 0); |
621 DeleteWindowById(WC_NEWS_WINDOW, 0); |
619 ShowNewspaper(ni); |
622 ShowNewspaper(ni); |
620 } |
623 } |
621 } |
624 } |