mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
Refactor NEWS_FLAG_* to use strong enum
This commit is contained in:
@@ -343,7 +343,7 @@ static void window_game_bottom_toolbar_invalidate(rct_window* w)
|
||||
window_game_bottom_toolbar_widgets[WIDX_NEWS_SUBJECT].type = WWT_EMPTY;
|
||||
}
|
||||
|
||||
if (newsItem->Flags & NEWS_FLAG_HAS_BUTTON)
|
||||
if (newsItem->HasButton())
|
||||
{
|
||||
w->disabled_widgets |= (1 << WIDX_NEWS_SUBJECT);
|
||||
w->disabled_widgets |= (1 << WIDX_NEWS_LOCATE);
|
||||
@@ -598,7 +598,7 @@ static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo* dpi, rc
|
||||
case News::ItemType::PeepOnRide:
|
||||
case News::ItemType::Peep:
|
||||
{
|
||||
if (newsItem->Flags & NEWS_FLAG_HAS_BUTTON)
|
||||
if (newsItem->HasButton())
|
||||
break;
|
||||
|
||||
rct_drawpixelinfo cliped_dpi;
|
||||
|
||||
@@ -152,7 +152,7 @@ static void window_news_update(rct_window* w)
|
||||
return;
|
||||
|
||||
const auto& newsItem = gNewsItems.GetArchived()[j];
|
||||
if (newsItem.Flags & NEWS_FLAG_HAS_BUTTON)
|
||||
if (newsItem.HasButton())
|
||||
return;
|
||||
if (w->news.var_482 == 1)
|
||||
{
|
||||
@@ -192,7 +192,7 @@ static void window_news_scrollmousedown(rct_window* w, int32_t scrollIndex, cons
|
||||
{
|
||||
if (mutableScreenCoords.y < itemHeight)
|
||||
{
|
||||
if (newsItem.Flags & NEWS_FLAG_HAS_BUTTON || mutableScreenCoords.y < 14 || mutableScreenCoords.y >= 38
|
||||
if (newsItem.HasButton() || mutableScreenCoords.y < 14 || mutableScreenCoords.y >= 38
|
||||
|| mutableScreenCoords.x < 328)
|
||||
{
|
||||
buttonIndex = 0;
|
||||
@@ -269,7 +269,7 @@ static void window_news_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32
|
||||
gfx_draw_string_left_wrapped(dpi, &text, { 2, y + lineHeight }, 325, STR_BOTTOM_TOOLBAR_NEWS_TEXT, COLOUR_BRIGHT_GREEN);
|
||||
|
||||
// Subject button
|
||||
if ((newsItem.TypeHasSubject()) && !(newsItem.Flags & NEWS_FLAG_HAS_BUTTON))
|
||||
if ((newsItem.TypeHasSubject()) && !(newsItem.HasButton()))
|
||||
{
|
||||
auto screenCoords = ScreenCoordsXY{ 328, y + lineHeight + 4 };
|
||||
|
||||
@@ -345,7 +345,7 @@ static void window_news_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32
|
||||
}
|
||||
|
||||
// Location button
|
||||
if ((newsItem.TypeHasLocation()) && !(newsItem.Flags & NEWS_FLAG_HAS_BUTTON))
|
||||
if ((newsItem.TypeHasLocation()) && !(newsItem.HasButton()))
|
||||
{
|
||||
auto screenCoords = ScreenCoordsXY{ 352, y + lineHeight + 4 };
|
||||
|
||||
|
||||
@@ -340,7 +340,7 @@ namespace OpenRCT2
|
||||
_currentRecording.reset();
|
||||
|
||||
NewsItem* news = news_item_add_to_queue_raw(News::ItemType::Blank, "Replay recording stopped", 0);
|
||||
news->Flags |= NEWS_FLAG_HAS_BUTTON; // Has no subject.
|
||||
news->SetFlags(News::ItemFlags::HasButton); // Has no subject.
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -468,7 +468,7 @@ namespace OpenRCT2
|
||||
if (_mode == ReplayMode::PLAYING)
|
||||
{
|
||||
NewsItem* news = news_item_add_to_queue_raw(News::ItemType::Blank, "Replay playback complete", 0);
|
||||
news->Flags |= NEWS_FLAG_HAS_BUTTON; // Has no subject.
|
||||
news->SetFlags(News::ItemFlags::HasButton); // Has no subject.
|
||||
}
|
||||
|
||||
// When normalizing the output we don't touch the mode.
|
||||
|
||||
@@ -422,7 +422,7 @@ void news_item_disable_news(News::ItemType type, uint32_t assoc)
|
||||
gNewsItems.ForeachRecentNews([type, assoc](auto& newsItem) {
|
||||
if (type == newsItem.Type && assoc == newsItem.Assoc)
|
||||
{
|
||||
newsItem.Flags |= NEWS_FLAG_HAS_BUTTON;
|
||||
newsItem.SetFlags(News::ItemFlags::HasButton);
|
||||
if (&newsItem == &gNewsItems.Current())
|
||||
{
|
||||
auto intent = Intent(INTENT_ACTION_INVALIDATE_TICKER_NEWS);
|
||||
@@ -434,7 +434,7 @@ void news_item_disable_news(News::ItemType type, uint32_t assoc)
|
||||
gNewsItems.ForeachArchivedNews([type, assoc](auto& newsItem) {
|
||||
if (type == newsItem.Type && assoc == newsItem.Assoc)
|
||||
{
|
||||
newsItem.Flags |= NEWS_FLAG_HAS_BUTTON;
|
||||
newsItem.SetFlags(News::ItemFlags::HasButton);
|
||||
window_invalidate_by_class(WC_RECENT_NEWS);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -42,12 +42,12 @@ namespace News
|
||||
HasLocation = 1,
|
||||
HasSubject = 2,
|
||||
};
|
||||
} // namespace News
|
||||
|
||||
enum
|
||||
{
|
||||
NEWS_FLAG_HAS_BUTTON = 1 << 0,
|
||||
};
|
||||
enum ItemFlags : uint8_t
|
||||
{
|
||||
HasButton = 1 << 0,
|
||||
};
|
||||
} // namespace News
|
||||
|
||||
/**
|
||||
* A single news item / message.
|
||||
@@ -90,6 +90,11 @@ struct NewsItem
|
||||
}
|
||||
}
|
||||
|
||||
void SetFlags(uint8_t flag)
|
||||
{
|
||||
Flags |= flag;
|
||||
}
|
||||
|
||||
constexpr bool TypeHasSubject() const
|
||||
{
|
||||
return this->GetTypeProperties() & News::ItemTypeProperty::HasSubject;
|
||||
@@ -99,6 +104,11 @@ struct NewsItem
|
||||
{
|
||||
return this->GetTypeProperties() & News::ItemTypeProperty::HasLocation;
|
||||
}
|
||||
|
||||
constexpr bool HasButton() const noexcept
|
||||
{
|
||||
return Flags & News::ItemFlags::HasButton;
|
||||
}
|
||||
};
|
||||
|
||||
constexpr int32_t NEWS_ITEM_HISTORY_START = 11;
|
||||
|
||||
Reference in New Issue
Block a user