diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -454,54 +454,54 @@ void LinkGraphOverlay::SetCompanyMask(Co } /** Make a number of rows with buttons for each company for the linkgraph legend window. */ -NWidgetBase *MakeCompanyButtonRowsLinkGraphGUI() +std::unique_ptr MakeCompanyButtonRowsLinkGraphGUI() { return MakeCompanyButtonRows(WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST, COLOUR_GREY, 3, STR_NULL); } -NWidgetBase *MakeSaturationLegendLinkGraphGUI() +std::unique_ptr MakeSaturationLegendLinkGraphGUI() { - NWidgetVertical *panel = new NWidgetVertical(NC_EQUALSIZE); + auto panel = std::make_unique(NC_EQUALSIZE); for (uint i = 0; i < lengthof(LinkGraphOverlay::LINK_COLOURS[0]); ++i) { - NWidgetBackground * wid = new NWidgetBackground(WWT_PANEL, COLOUR_DARK_GREEN, i + WID_LGL_SATURATION_FIRST); + auto wid = std::make_unique(WWT_PANEL, COLOUR_DARK_GREEN, i + WID_LGL_SATURATION_FIRST); wid->SetMinimalSize(50, 0); wid->SetMinimalTextLines(1, 0, FS_SMALL); wid->SetFill(1, 1); wid->SetResize(0, 0); - panel->Add(wid); + panel->Add(std::move(wid)); } return panel; } -NWidgetBase *MakeCargoesLegendLinkGraphGUI() +std::unique_ptr MakeCargoesLegendLinkGraphGUI() { uint num_cargo = static_cast(_sorted_cargo_specs.size()); static const uint ENTRIES_PER_COL = 5; - NWidgetHorizontal *panel = new NWidgetHorizontal(NC_EQUALSIZE); - NWidgetVertical *col = nullptr; + auto panel = std::make_unique(NC_EQUALSIZE); + std::unique_ptr col = nullptr; for (uint i = 0; i < num_cargo; ++i) { if (i % ENTRIES_PER_COL == 0) { - if (col != nullptr) panel->Add(col); - col = new NWidgetVertical(NC_EQUALSIZE); + if (col != nullptr) panel->Add(std::move(col)); + col = std::make_unique(NC_EQUALSIZE); } - NWidgetBackground * wid = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, i + WID_LGL_CARGO_FIRST); + auto wid = std::make_unique(WWT_PANEL, COLOUR_GREY, i + WID_LGL_CARGO_FIRST); wid->SetMinimalSize(25, 0); wid->SetMinimalTextLines(1, 0, FS_SMALL); wid->SetFill(1, 1); wid->SetResize(0, 0); - col->Add(wid); + col->Add(std::move(wid)); } /* Fill up last row */ for (uint i = num_cargo; i < Ceil(num_cargo, ENTRIES_PER_COL); ++i) { - NWidgetSpacer *spc = new NWidgetSpacer(25, 0); + auto spc = std::make_unique(25, 0); spc->SetMinimalTextLines(1, 0, FS_SMALL); spc->SetFill(1, 1); spc->SetResize(0, 0); - col->Add(spc); + col->Add(std::move(spc)); } /* If there are no cargo specs defined, then col won't have been created so don't add it. */ - if (col != nullptr) panel->Add(col); + if (col != nullptr) panel->Add(std::move(col)); return panel; }