mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-20 06:12:57 +01:00
Allow resizing the New Ride window
This commit is contained in:
committed by
GitHub
parent
5804508da4
commit
dcedb3b492
@@ -1,6 +1,7 @@
|
|||||||
0.4.29 (in development)
|
0.4.29 (in development)
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
- Improved: [#25426] Building the track designs index is now quicker.
|
- Improved: [#25426] Building the track designs index is now quicker.
|
||||||
|
- Improved: [#25490] The ‘New Ride’ window can now be resized.
|
||||||
- Fix: [#6228] The saved queue line path connections are not preserved when placing track designs (original bug).
|
- Fix: [#6228] The saved queue line path connections are not preserved when placing track designs (original bug).
|
||||||
- Fix: [#14365] Track designs with scenery below the lowest track piece do not preview correctly.
|
- Fix: [#14365] Track designs with scenery below the lowest track piece do not preview correctly.
|
||||||
- Fix: [#25451] Dropdown item tooltips stay open if the mouse is moved over an empty space.
|
- Fix: [#25451] Dropdown item tooltips stay open if the mouse is moved over an empty space.
|
||||||
|
|||||||
@@ -46,10 +46,12 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
{
|
{
|
||||||
static constexpr StringId WindowTitle = kStringIdNone;
|
static constexpr StringId WindowTitle = kStringIdNone;
|
||||||
static constexpr ScreenSize kWindowSize = { 601, 382 };
|
static constexpr ScreenSize kWindowSize = { 601, 382 };
|
||||||
|
static constexpr ScreenSize kWindowMaxSize = { 840, 828 };
|
||||||
static constexpr int32_t kWindowHeightResearch = 194;
|
static constexpr int32_t kWindowHeightResearch = 194;
|
||||||
static constexpr int32_t RideListItemsMax = 384;
|
static constexpr int32_t RideListItemsMax = 384;
|
||||||
static constexpr int32_t RideTabCount = 6;
|
static constexpr int32_t RideTabCount = 6;
|
||||||
static constexpr int32_t GroupByTrackTypeWidth = 172;
|
static constexpr int32_t GroupByTrackTypeWidth = 172;
|
||||||
|
static constexpr int32_t kScrollItemSize = 116;
|
||||||
|
|
||||||
#pragma region Ride type view order
|
#pragma region Ride type view order
|
||||||
|
|
||||||
@@ -447,7 +449,8 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
count++;
|
count++;
|
||||||
listItem++;
|
listItem++;
|
||||||
}
|
}
|
||||||
return { widgets[WIDX_RIDE_LIST].width() - 1, ((count + 4) / 5) * 116 };
|
auto itemsPerRow = getNumImagesPerRow();
|
||||||
|
return { widgets[WIDX_RIDE_LIST].width() - 1, ((count + (itemsPerRow - 1)) / itemsPerRow) * kScrollItemSize };
|
||||||
}
|
}
|
||||||
|
|
||||||
void onScrollMouseOver(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
|
void onScrollMouseOver(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
|
||||||
@@ -496,8 +499,8 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
{
|
{
|
||||||
const auto borderStyle = isSelected ? Rectangle::BorderStyle::inset : Rectangle::BorderStyle::outset;
|
const auto borderStyle = isSelected ? Rectangle::BorderStyle::inset : Rectangle::BorderStyle::outset;
|
||||||
Rectangle::fillInset(
|
Rectangle::fillInset(
|
||||||
rt, { coords, coords + ScreenCoordsXY{ 115, 115 } }, colours[1], borderStyle,
|
rt, { coords, coords + ScreenCoordsXY{ kScrollItemSize - 1, kScrollItemSize - 1 } }, colours[1],
|
||||||
Rectangle::FillBrightness::dark);
|
borderStyle, Rectangle::FillBrightness::dark);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw ride image with feathered border
|
// Draw ride image with feathered border
|
||||||
@@ -506,11 +509,11 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
GfxDrawSpriteRawMasked(rt, coords + ScreenCoordsXY{ 2, 2 }, mask, rideImage);
|
GfxDrawSpriteRawMasked(rt, coords + ScreenCoordsXY{ 2, 2 }, mask, rideImage);
|
||||||
|
|
||||||
// Next position
|
// Next position
|
||||||
coords.x += 116;
|
coords.x += kScrollItemSize;
|
||||||
if (coords.x >= 116 * 5 + 1)
|
if (coords.x >= kScrollItemSize * getNumImagesPerRow() + 1)
|
||||||
{
|
{
|
||||||
coords.x = 1;
|
coords.x = 1;
|
||||||
coords.y += 116;
|
coords.y += kScrollItemSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next item
|
// Next item
|
||||||
@@ -809,8 +812,6 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
|
|
||||||
void RefreshWidgetSizing()
|
void RefreshWidgetSizing()
|
||||||
{
|
{
|
||||||
int32_t newWidth{}, newHeight{};
|
|
||||||
|
|
||||||
if (_currentTab < SHOP_TAB)
|
if (_currentTab < SHOP_TAB)
|
||||||
{
|
{
|
||||||
disabledWidgets &= ~(1 << WIDX_GROUP_BY_TRACK_TYPE);
|
disabledWidgets &= ~(1 << WIDX_GROUP_BY_TRACK_TYPE);
|
||||||
@@ -831,6 +832,7 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
widgets[WIDX_GROUP_BY_TRACK_TYPE].type = WidgetType::empty;
|
widgets[WIDX_GROUP_BY_TRACK_TYPE].type = WidgetType::empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScreenSize newMinSize{}, newMaxSize{};
|
||||||
if (_currentTab != RESEARCH_TAB)
|
if (_currentTab != RESEARCH_TAB)
|
||||||
{
|
{
|
||||||
widgets[WIDX_RIDE_LIST].type = WidgetType::scroll;
|
widgets[WIDX_RIDE_LIST].type = WidgetType::scroll;
|
||||||
@@ -841,8 +843,8 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
widgets[WIDX_LAST_DEVELOPMENT_BUTTON].type = WidgetType::empty;
|
widgets[WIDX_LAST_DEVELOPMENT_BUTTON].type = WidgetType::empty;
|
||||||
widgets[WIDX_RESEARCH_FUNDING_BUTTON].type = WidgetType::empty;
|
widgets[WIDX_RESEARCH_FUNDING_BUTTON].type = WidgetType::empty;
|
||||||
|
|
||||||
newWidth = kWindowSize.width;
|
newMinSize = kWindowSize;
|
||||||
newHeight = kWindowSize.height;
|
newMaxSize = kWindowMaxSize;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -855,24 +857,35 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
if (!(getGameState().park.flags & PARK_FLAGS_NO_MONEY))
|
if (!(getGameState().park.flags & PARK_FLAGS_NO_MONEY))
|
||||||
widgets[WIDX_RESEARCH_FUNDING_BUTTON].type = WidgetType::flatBtn;
|
widgets[WIDX_RESEARCH_FUNDING_BUTTON].type = WidgetType::flatBtn;
|
||||||
|
|
||||||
newWidth = 300;
|
newMinSize = { 300, kWindowHeightResearch };
|
||||||
newHeight = kWindowHeightResearch;
|
newMaxSize = newMinSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle new window size
|
// Handle new window size
|
||||||
if (width != newWidth || height != newHeight)
|
if (width != newMinSize.width || height != newMinSize.height)
|
||||||
{
|
{
|
||||||
ScreenSize newSize = { newWidth, newHeight };
|
WindowSetResize(*this, newMinSize, newMaxSize);
|
||||||
WindowSetResize(*this, newSize, newSize);
|
|
||||||
onResize();
|
onResize();
|
||||||
|
|
||||||
widgets[WIDX_GROUP_BY_TRACK_TYPE].left = newWidth - 8 - GroupByTrackTypeWidth;
|
|
||||||
widgets[WIDX_GROUP_BY_TRACK_TYPE].right = newWidth - 8;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
initScrollWidgets();
|
initScrollWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onResize() override
|
||||||
|
{
|
||||||
|
widgets[WIDX_GROUP_BY_TRACK_TYPE].left = width - 8 - GroupByTrackTypeWidth;
|
||||||
|
widgets[WIDX_GROUP_BY_TRACK_TYPE].right = width - 8;
|
||||||
|
widgets[WIDX_RIDE_LIST].right = width - 6 - 1;
|
||||||
|
widgets[WIDX_RIDE_LIST].bottom = height - 65;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t getNumImagesPerRow()
|
||||||
|
{
|
||||||
|
const Widget& listWidget = widgets[WIDX_RIDE_LIST];
|
||||||
|
auto scrollWidth = listWidget.width();
|
||||||
|
return scrollWidth / kScrollItemSize;
|
||||||
|
}
|
||||||
|
|
||||||
RideSelection ScrollGetRideListItemAt(const ScreenCoordsXY& screenCoords)
|
RideSelection ScrollGetRideListItemAt(const ScreenCoordsXY& screenCoords)
|
||||||
{
|
{
|
||||||
RideSelection result;
|
RideSelection result;
|
||||||
@@ -882,12 +895,13 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
if (screenCoords.x <= 0 || screenCoords.y <= 0)
|
if (screenCoords.x <= 0 || screenCoords.y <= 0)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
int32_t column = screenCoords.x / 116;
|
auto itemsPerRow = getNumImagesPerRow();
|
||||||
int32_t row = screenCoords.y / 116;
|
int32_t column = screenCoords.x / kScrollItemSize;
|
||||||
if (column >= 5)
|
int32_t row = screenCoords.y / kScrollItemSize;
|
||||||
|
if (column >= itemsPerRow)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
int32_t index = column + (row * 5);
|
int32_t index = column + (row * itemsPerRow);
|
||||||
|
|
||||||
RideSelection* listItem = _windowNewRideListItems;
|
RideSelection* listItem = _windowNewRideListItems;
|
||||||
while (listItem->Type != kRideTypeNull || listItem->EntryIndex != kObjectEntryIndexNull)
|
while (listItem->Type != kRideTypeNull || listItem->EntryIndex != kObjectEntryIndexNull)
|
||||||
@@ -978,7 +992,7 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
|
|
||||||
ft = Formatter();
|
ft = Formatter();
|
||||||
ft.Add<money64>(price);
|
ft.Add<money64>(price);
|
||||||
DrawTextBasic(rt, screenPos + ScreenCoordsXY{ textWidth, 51 }, stringId, ft, { TextAlignment::right });
|
DrawTextBasic(rt, screenPos + ScreenCoordsXY{ textWidth - 14, 51 }, stringId, ft, { TextAlignment::right });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw object author(s) if debugging tools are active
|
// Draw object author(s) if debugging tools are active
|
||||||
@@ -1086,7 +1100,8 @@ namespace OpenRCT2::Ui::Windows
|
|||||||
windowMgr->CloseByClass(WindowClass::trackDesignPlace);
|
windowMgr->CloseByClass(WindowClass::trackDesignPlace);
|
||||||
|
|
||||||
window = windowMgr->Create<NewRideWindow>(
|
window = windowMgr->Create<NewRideWindow>(
|
||||||
WindowClass::constructRide, kWindowSize, { WindowFlag::higherContrastOnPress, WindowFlag::autoPosition });
|
WindowClass::constructRide, kWindowSize,
|
||||||
|
{ WindowFlag::higherContrastOnPress, WindowFlag::autoPosition, WindowFlag::resizable });
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user