MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / ShowLastNewsMessage

Function ShowLastNewsMessage

src/news_gui.cpp:1138–1176  ·  view source on GitHub ↗

Show previous news item */

Source from the content-addressed store, hash-verified

1136
1137/** Show previous news item */
1138void ShowLastNewsMessage()
1139{
1140 if (std::empty(_news)) return;
1141
1142 NewsIterator ni;
1143 if (_forced_news == std::end(_news)) {
1144 /* Not forced any news yet, show the current one, unless a news window is
1145 * open (which can only be the current one), then show the previous item */
1146 if (_current_news == std::end(_news)) {
1147 /* No news were shown yet resp. the last shown one was already deleted.
1148 * Treat this as if _forced_news reached the oldest news; so, wrap around and start anew with the latest. */
1149 ni = std::begin(_news);
1150 } else {
1151 const Window *w = FindWindowById(WC_NEWS_WINDOW, 0);
1152 ni = (w == nullptr || (std::next(_current_news) == std::end(_news))) ? _current_news : std::next(_current_news);
1153 }
1154 } else if (std::next(_forced_news) == std::end(_news)) {
1155 /* We have reached the oldest news, start anew with the latest */
1156 ni = std::begin(_news);
1157 } else {
1158 /* 'Scrolling' through news history show each one in turn */
1159 ni = std::next(_forced_news);
1160 }
1161 bool wrap = false;
1162 for (;;) {
1163 if (_news_type_data[to_underlying(ni->type)].GetDisplay() != NewsDisplay::Off) {
1164 ShowNewsMessage(ni);
1165 break;
1166 }
1167
1168 ++ni;
1169 if (ni == std::end(_news)) {
1170 if (wrap) break;
1171 /* We have reached the oldest news, start anew with the latest */
1172 ni = std::begin(_news);
1173 wrap = true;
1174 }
1175 }
1176}
1177
1178
1179/**

Callers 2

MenuClickNewspaperFunction · 0.85
OnClickMethod · 0.85

Calls 7

emptyFunction · 0.85
FindWindowByIdFunction · 0.85
to_underlyingFunction · 0.85
ShowNewsMessageFunction · 0.85
GetDisplayMethod · 0.80
endFunction · 0.50
beginFunction · 0.50

Tested by

no test coverage detected