Codechange: Use std::initializer_list for NWidgetPart data. (#14749)

Avoids using C/C++ arrays.
This commit is contained in:
Peter Nelson
2025-11-01 22:33:00 +00:00
committed by dP
parent 49dd74ea89
commit c2d92433c6
62 changed files with 160 additions and 158 deletions

View File

@@ -104,7 +104,7 @@ static TileIndex GetReferenceTile(const NewsReference &reference)
}
/* Normal news items. */
static constexpr NWidgetPart _nested_normal_news_widgets[] = {
static constexpr std::initializer_list<NWidgetPart> _nested_normal_news_widgets = {
NWidget(WWT_PANEL, COLOUR_WHITE, WID_N_PANEL),
NWidget(NWID_VERTICAL), SetPadding(WidgetDimensions::unscaled.fullbevel),
NWidget(NWID_LAYER, INVALID_COLOUR),
@@ -136,7 +136,7 @@ static WindowDesc _normal_news_desc(
);
/* New vehicles news items. */
static constexpr NWidgetPart _nested_vehicle_news_widgets[] = {
static constexpr std::initializer_list<NWidgetPart> _nested_vehicle_news_widgets = {
NWidget(WWT_PANEL, COLOUR_WHITE, WID_N_PANEL),
NWidget(NWID_VERTICAL), SetPadding(WidgetDimensions::unscaled.fullbevel),
NWidget(NWID_LAYER, INVALID_COLOUR),
@@ -184,7 +184,7 @@ static WindowDesc _vehicle_news_desc(
);
/* Company news items. */
static constexpr NWidgetPart _nested_company_news_widgets[] = {
static constexpr std::initializer_list<NWidgetPart> _nested_company_news_widgets = {
NWidget(WWT_PANEL, COLOUR_WHITE, WID_N_PANEL),
NWidget(NWID_VERTICAL), SetPadding(WidgetDimensions::unscaled.fullbevel),
NWidget(NWID_LAYER, INVALID_COLOUR),
@@ -229,7 +229,7 @@ static WindowDesc _company_news_desc(
);
/* Thin news items. */
static constexpr NWidgetPart _nested_thin_news_widgets[] = {
static constexpr std::initializer_list<NWidgetPart> _nested_thin_news_widgets = {
NWidget(WWT_PANEL, COLOUR_WHITE, WID_N_PANEL),
NWidget(NWID_VERTICAL), SetPadding(WidgetDimensions::unscaled.fullbevel),
NWidget(NWID_LAYER, INVALID_COLOUR),
@@ -263,7 +263,7 @@ static WindowDesc _thin_news_desc(
);
/* Small news items. */
static constexpr NWidgetPart _nested_small_news_widgets[] = {
static constexpr std::initializer_list<NWidgetPart> _nested_small_news_widgets = {
/* Caption + close box. The caption is not WWT_CAPTION as the window shall not be moveable and so on. */
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE, WID_N_CLOSEBOX),
@@ -1277,7 +1277,7 @@ struct MessageHistoryWindow : Window {
}
};
static constexpr NWidgetPart _nested_message_history[] = {
static constexpr std::initializer_list<NWidgetPart> _nested_message_history = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
NWidget(WWT_CAPTION, COLOUR_BROWN), SetStringTip(STR_MESSAGE_HISTORY, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),