Codechange: Use std::unique_ptr for all NWidgets.
This commit is contained in:

committed by
Peter Nelson

parent
9a3934ae23
commit
7124b4eef1
@@ -2122,7 +2122,7 @@ struct MainToolbarWindow : Window {
|
||||
}};
|
||||
};
|
||||
|
||||
static NWidgetBase *MakeMainToolbar()
|
||||
static std::unique_ptr<NWidgetBase> MakeMainToolbar()
|
||||
{
|
||||
/** Sprites to use for the different toolbar buttons */
|
||||
static const SpriteID toolbar_button_sprites[] = {
|
||||
@@ -2159,7 +2159,7 @@ static NWidgetBase *MakeMainToolbar()
|
||||
SPR_IMG_SWITCH_TOOLBAR, // WID_TN_SWITCH_BAR
|
||||
};
|
||||
|
||||
NWidgetMainToolbarContainer *hor = new NWidgetMainToolbarContainer();
|
||||
auto hor = std::make_unique<NWidgetMainToolbarContainer>();
|
||||
for (WidgetID i = 0; i < WID_TN_END; i++) {
|
||||
switch (i) {
|
||||
case WID_TN_SMALL_MAP:
|
||||
@@ -2168,12 +2168,12 @@ static NWidgetBase *MakeMainToolbar()
|
||||
case WID_TN_ZOOM_IN:
|
||||
case WID_TN_BUILDING_TOOLS_START:
|
||||
case WID_TN_MUSIC_SOUND:
|
||||
hor->Add(new NWidgetSpacer(0, 0));
|
||||
hor->Add(std::make_unique<NWidgetSpacer>(0, 0));
|
||||
break;
|
||||
}
|
||||
NWidgetLeaf *leaf = new NWidgetLeaf(i == WID_TN_SAVE ? WWT_IMGBTN_2 : WWT_IMGBTN, COLOUR_GREY, i, toolbar_button_sprites[i], STR_TOOLBAR_TOOLTIP_PAUSE_GAME + i);
|
||||
auto leaf = std::make_unique<NWidgetLeaf>(i == WID_TN_SAVE ? WWT_IMGBTN_2 : WWT_IMGBTN, COLOUR_GREY, i, toolbar_button_sprites[i], STR_TOOLBAR_TOOLTIP_PAUSE_GAME + i);
|
||||
leaf->SetMinimalSize(20, 20);
|
||||
hor->Add(leaf);
|
||||
hor->Add(std::move(leaf));
|
||||
}
|
||||
|
||||
return hor;
|
||||
@@ -2514,9 +2514,9 @@ static const NWidgetPart _nested_toolb_scen_inner_widgets[] = {
|
||||
NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_SWITCH_BAR), SetDataTip(SPR_IMG_SWITCH_TOOLBAR, STR_TOOLBAR_TOOLTIP_SWITCH_TOOLBAR),
|
||||
};
|
||||
|
||||
static NWidgetBase *MakeScenarioToolbar()
|
||||
static std::unique_ptr<NWidgetBase> MakeScenarioToolbar()
|
||||
{
|
||||
return MakeNWidgets(std::begin(_nested_toolb_scen_inner_widgets), std::end(_nested_toolb_scen_inner_widgets), new NWidgetScenarioToolbarContainer());
|
||||
return MakeNWidgets(std::begin(_nested_toolb_scen_inner_widgets), std::end(_nested_toolb_scen_inner_widgets), std::make_unique<NWidgetScenarioToolbarContainer>());
|
||||
}
|
||||
|
||||
static const NWidgetPart _nested_toolb_scen_widgets[] = {
|
||||
|
Reference in New Issue
Block a user