/** Show previous news item */ void ShowLastNewsMessage() { if (_total_news == 0) { return; } else if (_forced_news == NULL) { /* Not forced any news yet, show the current one, unless a news window is * open (which can only be the current one), then show the previous item */ const Window *w = FindWindowById(WC_NEWS_WINDOW, 0); ShowNewsMessage((w == NULL || (_current_news == _oldest_news)) ? _current_news : _current_news->prev); } else if (_forced_news == _oldest_news) { /* We have reached the oldest news, start anew with the latest */ ShowNewsMessage(_latest_news); } else { /* 'Scrolling' through news history show each one in turn */ ShowNewsMessage(_forced_news->prev); } }
virtual void OnClick(Point pt, int widget, int click_count) { if (widget == WID_MH_BACKGROUND) { NewsItem *ni = _latest_news; if (ni == NULL) return; for (int n = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_MH_BACKGROUND, WD_FRAMERECT_TOP, this->line_height); n > 0; n--) { ni = ni->prev; if (ni == NULL) return; } ShowNewsMessage(ni); } }
virtual void OnClick(Point pt, int widget, int click_count) { if (widget == MHW_BACKGROUND) { NewsItem *ni = _latest_news; if (ni == NULL) return; for (int n = (pt.y - this->GetWidget<NWidgetBase>(MHW_BACKGROUND)->pos_y - WD_FRAMERECT_TOP) / this->line_height + this->vscroll.GetPosition(); n > 0; n--) { ni = ni->prev; if (ni == NULL) return; } ShowNewsMessage(ni); } }
/** Show previous news item */ void ShowLastNewsMessage() { const NewsItem *ni = NULL; if (_total_news == 0) { return; } else if (_forced_news == NULL) { /* Not forced any news yet, show the current one, unless a news window is * open (which can only be the current one), then show the previous item */ if (_current_news == NULL) { /* No news were shown yet resp. the last shown one was already deleted. * Threat this as if _forced_news reached _oldest_news; so, wrap around and start anew with the latest. */ ni = _latest_news; } else { const Window *w = FindWindowById(WC_NEWS_WINDOW, 0); ni = (w == NULL || (_current_news == _oldest_news)) ? _current_news : _current_news->prev; } } else if (_forced_news == _oldest_news) { /* We have reached the oldest news, start anew with the latest */ ni = _latest_news; } else { /* 'Scrolling' through news history show each one in turn */ ni = _forced_news->prev; } bool wrap = false; for (;;) { if (_news_type_data[ni->type].GetDisplay() != ND_OFF) { ShowNewsMessage(ni); break; } ni = ni->prev; if (ni == NULL) { if (wrap) break; /* We have reached the oldest news, start anew with the latest */ ni = _latest_news; wrap = true; } } }