Sticky the Misc scenery tab next to the All scenery tab (#19764)

* Sticky the Misc tab next to the All tab

* More robust misc check

Co-authored-by: Hielke Morsink <hielke.morsink@gmail.com>
Co-authored-by: Duncan <duncans_pumpkin@hotmail.co.uk>
This commit is contained in:
Andrew 2023-04-02 04:42:37 -04:00 committed by GitHub
parent fd80b4c822
commit ad0229199d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 4 deletions

View File

@ -1,5 +1,6 @@
0.4.5 (in development)
------------------------------------------------------------------------
- Improved: [#19764] Miscellaneous scenery tab now grouped next to the all-scenery tab.
- Fix: [#19296] Crash due to a race condition for parallel object loading.
- Fix: [#19756] Crash with title sequences containing no commands.
- Fix: [#19767] No message when path is not connected to ride exit and is therefore unreachable for mechanics.

View File

@ -48,7 +48,7 @@ constexpr int32_t TabWidth = 31;
constexpr int32_t TabHeight = 28;
constexpr int32_t ReservedTabCount = 2;
constexpr int32_t MaxTabs = 257; // 255 selected tabs + misc + all
constexpr int32_t MaxTabsPerRow = 19;
constexpr int32_t MaxTabsPerRow = 20;
constexpr uint8_t SceneryContentScrollIndex = 0;
@ -720,6 +720,15 @@ public:
const auto lastTabWidget = &widgets[WIDX_SCENERY_TAB_1 + lastTabIndex];
windowWidth = std::max<int32_t>(windowWidth, lastTabWidget->right + 3);
if (GetSceneryTabInfoForMisc() != nullptr)
{
auto miscTabWidget = &widgets[WIDX_SCENERY_TAB_1 + _tabEntries.size() - 2];
miscTabWidget->left = windowWidth - 2 * TabWidth - 6;
miscTabWidget->right = windowWidth - TabWidth - 7;
miscTabWidget->top = InitTabPosY;
miscTabWidget->bottom = InitTabPosY + TabHeight;
}
if (_tabEntries.back().IsAll())
{
auto allTabWidget = &widgets[WIDX_SCENERY_TAB_1 + _tabEntries.size() - 1];
@ -1223,8 +1232,7 @@ private:
int32_t GetTabRowCount()
{
int32_t tabEntries = static_cast<int32_t>(_tabEntries.size() - 1);
return std::max<int32_t>((tabEntries + MaxTabsPerRow - 1) / MaxTabsPerRow, 0);
return std::max<int32_t>((static_cast<int32_t>(_tabEntries.size()) + MaxTabsPerRow - 1) / MaxTabsPerRow, 0);
}
int32_t GetMaxTabCountInARow()
@ -1251,6 +1259,9 @@ private:
int32_t xInit = InitTabPosX;
int32_t tabsInThisRow = 0;
auto hasMisc = GetSceneryTabInfoForMisc() != nullptr;
auto maxTabsInThisRow = MaxTabsPerRow - 1 - (hasMisc ? 1 : 0);
ScreenCoordsXY pos = { xInit, InitTabPosY };
for (const auto& tabInfo : _tabEntries)
{
@ -1281,12 +1292,13 @@ private:
_widgets.push_back(widget);
tabsInThisRow++;
if (tabsInThisRow >= MaxTabsPerRow)
if (tabsInThisRow >= maxTabsInThisRow)
{
pos.x = xInit;
pos.y += TabHeight;
tabsInThisRow = 0;
_actualMinHeight += TabHeight;
maxTabsInThisRow = MaxTabsPerRow;
}
}