1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-28 01:04:50 +01:00

Move all construction related logic into OnOpen (#20632)

This commit is contained in:
Duncan
2023-09-07 07:20:28 +01:00
committed by GitHub
parent 37caebdde9
commit 77dd3cf8e2
6 changed files with 56 additions and 40 deletions

View File

@@ -390,28 +390,32 @@ namespace OpenRCT2::Ui::Windows
public:
CustomWindow(std::shared_ptr<Plugin> owner, const CustomWindowDesc& desc)
: _info(owner, desc)
{
}
void OnOpen() override
{
number = GetNewWindowNumber();
// Set window tab
page = desc.TabIndex.value_or(0);
page = _info.Desc.TabIndex.value_or(0);
// Set window colours
colours[0] = COLOUR_GREY;
colours[1] = COLOUR_GREY;
colours[2] = COLOUR_GREY;
auto numColours = std::min(std::size(colours), std::size(desc.Colours));
auto numColours = std::min(std::size(colours), std::size(_info.Desc.Colours));
for (size_t i = 0; i < numColours; i++)
{
colours[i] = desc.Colours[i];
colours[i] = _info.Desc.Colours[i];
}
if (desc.IsResizable())
if (_info.Desc.IsResizable())
{
min_width = desc.MinWidth.value_or(0);
min_height = desc.MinHeight.value_or(0);
max_width = desc.MaxWidth.value_or(std::numeric_limits<uint16_t>::max());
max_height = desc.MaxHeight.value_or(std::numeric_limits<uint16_t>::max());
min_width = _info.Desc.MinWidth.value_or(0);
min_height = _info.Desc.MinHeight.value_or(0);
max_width = _info.Desc.MaxWidth.value_or(std::numeric_limits<uint16_t>::max());
max_height = _info.Desc.MaxHeight.value_or(std::numeric_limits<uint16_t>::max());
}
RefreshWidgets();
}