Codechange: Use functions to create common drop down list items.
This commit is contained in:

committed by
Peter Nelson

parent
11aa3694fa
commit
56cac21086
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "dropdown_type.h"
|
||||
#include "dropdown_func.h"
|
||||
#include "strings_func.h"
|
||||
#include "timer/timer.h"
|
||||
#include "timer/timer_window.h"
|
||||
@@ -20,6 +21,35 @@
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
std::unique_ptr<DropDownListItem> MakeDropDownListDividerItem()
|
||||
{
|
||||
return std::make_unique<DropDownListDividerItem>(-1);
|
||||
}
|
||||
|
||||
std::unique_ptr<DropDownListItem> MakeDropDownListStringItem(StringID str, int value, bool masked, bool shaded)
|
||||
{
|
||||
return std::make_unique<DropDownListStringItem>(str, value, masked, shaded);
|
||||
}
|
||||
|
||||
std::unique_ptr<DropDownListItem> MakeDropDownListStringItem(const std::string &str, int value, bool masked, bool shaded)
|
||||
{
|
||||
return std::make_unique<DropDownListStringItem>(str, value, masked, shaded);
|
||||
}
|
||||
|
||||
std::unique_ptr<DropDownListItem> MakeDropDownListIconItem(SpriteID sprite, PaletteID palette, StringID str, int value, bool masked, bool shaded)
|
||||
{
|
||||
return std::make_unique<DropDownListIconItem>(sprite, palette, str, value, masked, shaded);
|
||||
}
|
||||
|
||||
std::unique_ptr<DropDownListItem> MakeDropDownListIconItem(const Dimension &dim, SpriteID sprite, PaletteID palette, StringID str, int value, bool masked, bool shaded)
|
||||
{
|
||||
return std::make_unique<DropDownListIconItem>(dim, sprite, palette, str, value, masked, shaded);
|
||||
}
|
||||
|
||||
std::unique_ptr<DropDownListItem> MakeDropDownListCheckedItem(bool checked, StringID str, int value, bool masked, bool shaded)
|
||||
{
|
||||
return std::make_unique<DropDownListCheckedItem>(checked, str, value, masked, shaded);
|
||||
}
|
||||
|
||||
static constexpr NWidgetPart _nested_dropdown_menu_widgets[] = {
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
@@ -408,7 +438,7 @@ void ShowDropDownMenu(Window *w, const StringID *strings, int selected, WidgetID
|
||||
|
||||
for (uint i = 0; strings[i] != INVALID_STRING_ID; i++) {
|
||||
if (!HasBit(hidden_mask, i)) {
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(strings[i], i, HasBit(disabled_mask, i)));
|
||||
list.push_back(MakeDropDownListStringItem(strings[i], i, HasBit(disabled_mask, i)));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user