mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
Merge pull request #25372 from AaronVanGeffen/scenery-window-refactor
Scenery window refactor
This commit is contained in:
@@ -64,8 +64,6 @@
|
||||
#include <openrct2/world/tile_element/SurfaceElement.h>
|
||||
#include <openrct2/world/tile_element/WallElement.h>
|
||||
|
||||
using namespace Numerics;
|
||||
|
||||
namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
static constexpr StringId kWindowTitle = kStringIdNone;
|
||||
@@ -597,31 +595,6 @@ namespace OpenRCT2::Ui::Windows
|
||||
invalidate();
|
||||
}
|
||||
|
||||
ScreenSize onScrollGetSize(int32_t scrollIndex) override
|
||||
{
|
||||
if (scrollIndex == kSceneryContentScrollIndex)
|
||||
{
|
||||
return ContentScrollGetSize();
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
void onScrollMouseDown(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
|
||||
{
|
||||
if (scrollIndex == kSceneryContentScrollIndex)
|
||||
{
|
||||
ContentScrollMouseDown(screenCoords);
|
||||
}
|
||||
}
|
||||
|
||||
void onScrollMouseOver(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
|
||||
{
|
||||
if (scrollIndex == kSceneryContentScrollIndex)
|
||||
{
|
||||
ContentScrollMouseOver(screenCoords);
|
||||
}
|
||||
}
|
||||
|
||||
OpenRCT2String onTooltip(const WidgetIndex widgetIndex, const StringId fallback) override
|
||||
{
|
||||
if (widgetIndex >= WIDX_SCENERY_TAB_1)
|
||||
@@ -907,47 +880,6 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
}
|
||||
|
||||
void onScrollDraw(int32_t scrollIndex, RenderTarget& rt) override
|
||||
{
|
||||
if (scrollIndex == kSceneryContentScrollIndex)
|
||||
{
|
||||
ContentScrollDraw(rt);
|
||||
}
|
||||
}
|
||||
|
||||
void onToolUpdate(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) override
|
||||
{
|
||||
switch (widgetIndex)
|
||||
{
|
||||
case WIDX_SCENERY_BACKGROUND:
|
||||
ToolUpdateScenery(screenCoords);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void onToolDown(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) override
|
||||
{
|
||||
switch (widgetIndex)
|
||||
{
|
||||
case WIDX_SCENERY_BACKGROUND:
|
||||
SceneryToolDown(screenCoords, widgetIndex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void onToolDrag(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) override
|
||||
{
|
||||
switch (widgetIndex)
|
||||
{
|
||||
case WIDX_SCENERY_BACKGROUND:
|
||||
if (_sceneryPaintEnabled)
|
||||
SceneryToolDown(screenCoords, widgetIndex);
|
||||
if (gWindowSceneryEyedropperEnabled)
|
||||
SceneryToolDown(screenCoords, widgetIndex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void setSelectedItem(
|
||||
const ScenerySelection& scenery, const std::optional<colour_t> primary, const std::optional<colour_t> secondary,
|
||||
const std::optional<colour_t> tertiary, const std::optional<colour_t> rotation)
|
||||
@@ -1499,13 +1431,13 @@ namespace OpenRCT2::Ui::Windows
|
||||
return scenery;
|
||||
}
|
||||
|
||||
ScreenSize ContentScrollGetSize() const
|
||||
ScreenSize onScrollGetSize(int32_t scrollIndex) override
|
||||
{
|
||||
auto rows = CountRows();
|
||||
return { 0, ContentRowsHeight(rows) };
|
||||
}
|
||||
|
||||
void ContentScrollMouseDown(const ScreenCoordsXY& screenCoords)
|
||||
void onScrollMouseDown(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
|
||||
{
|
||||
const auto scenery = GetSceneryIdByCursorPos(screenCoords);
|
||||
if (scenery.IsUndefined())
|
||||
@@ -1527,7 +1459,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void ContentScrollMouseOver(const ScreenCoordsXY& screenCoords)
|
||||
void onScrollMouseOver(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
|
||||
{
|
||||
ScenerySelection scenery = GetSceneryIdByCursorPos(screenCoords);
|
||||
if (!scenery.IsUndefined() && _selectedScenery != scenery)
|
||||
@@ -1537,70 +1469,51 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<StringId, money64> GetNameAndPrice(ScenerySelection selectedScenery)
|
||||
template<typename TObjectType>
|
||||
std::pair<StringId, money64> GetNameAndPriceByType(const ScenerySelection& selectedScenery)
|
||||
{
|
||||
StringId name = STR_UNKNOWN_OBJECT_TYPE;
|
||||
money64 price = kMoney64Undefined;
|
||||
if (selectedScenery.IsUndefined() && gSceneryPlaceCost != kMoney64Undefined)
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<TObjectType>(selectedScenery.EntryIndex);
|
||||
if (sceneryEntry != nullptr)
|
||||
{
|
||||
price = gSceneryPlaceCost;
|
||||
return { sceneryEntry->name, sceneryEntry->price };
|
||||
}
|
||||
else
|
||||
{
|
||||
return { STR_UNKNOWN_OBJECT_TYPE, kMoney64Undefined };
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<StringId, money64> GetNameAndPrice(const ScenerySelection& selectedScenery)
|
||||
{
|
||||
if (!selectedScenery.IsUndefined())
|
||||
{
|
||||
switch (selectedScenery.SceneryType)
|
||||
{
|
||||
case SCENERY_TYPE_SMALL:
|
||||
{
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<SmallSceneryEntry>(selectedScenery.EntryIndex);
|
||||
if (sceneryEntry != nullptr)
|
||||
{
|
||||
price = sceneryEntry->price;
|
||||
name = sceneryEntry->name;
|
||||
}
|
||||
break;
|
||||
return GetNameAndPriceByType<SmallSceneryEntry>(selectedScenery);
|
||||
}
|
||||
case SCENERY_TYPE_PATH_ITEM:
|
||||
{
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<PathAdditionEntry>(selectedScenery.EntryIndex);
|
||||
if (sceneryEntry != nullptr)
|
||||
{
|
||||
price = sceneryEntry->price;
|
||||
name = sceneryEntry->name;
|
||||
}
|
||||
break;
|
||||
return GetNameAndPriceByType<PathAdditionEntry>(selectedScenery);
|
||||
}
|
||||
case SCENERY_TYPE_WALL:
|
||||
{
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<WallSceneryEntry>(selectedScenery.EntryIndex);
|
||||
if (sceneryEntry != nullptr)
|
||||
{
|
||||
price = sceneryEntry->price;
|
||||
name = sceneryEntry->name;
|
||||
}
|
||||
break;
|
||||
return GetNameAndPriceByType<WallSceneryEntry>(selectedScenery);
|
||||
}
|
||||
case SCENERY_TYPE_LARGE:
|
||||
{
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<LargeSceneryEntry>(selectedScenery.EntryIndex);
|
||||
if (sceneryEntry != nullptr)
|
||||
{
|
||||
price = sceneryEntry->price;
|
||||
name = sceneryEntry->name;
|
||||
}
|
||||
break;
|
||||
return GetNameAndPriceByType<LargeSceneryEntry>(selectedScenery);
|
||||
}
|
||||
case SCENERY_TYPE_BANNER:
|
||||
{
|
||||
auto* sceneryEntry = ObjectManager::GetObjectEntry<BannerSceneryEntry>(selectedScenery.EntryIndex);
|
||||
if (sceneryEntry != nullptr)
|
||||
{
|
||||
price = sceneryEntry->price;
|
||||
name = sceneryEntry->name;
|
||||
}
|
||||
break;
|
||||
return GetNameAndPriceByType<BannerSceneryEntry>(selectedScenery);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StringId name = STR_UNKNOWN_OBJECT_TYPE;
|
||||
money64 price = gSceneryPlaceCost != kMoney64Undefined ? gSceneryPlaceCost : kMoney64Undefined;
|
||||
return { name, price };
|
||||
}
|
||||
|
||||
@@ -1722,7 +1635,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
}
|
||||
|
||||
void ContentScrollDraw(RenderTarget& rt)
|
||||
void onScrollDraw(int32_t scrollIndex, RenderTarget& rt) override
|
||||
{
|
||||
GfxClear(rt, ColourMapA[colours[1].colour].mid_light);
|
||||
|
||||
@@ -1781,35 +1694,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006E287B
|
||||
*/
|
||||
void ToolUpdateScenery(const ScreenCoordsXY& screenPos)
|
||||
{
|
||||
MapInvalidateSelectionRect();
|
||||
MapInvalidateMapSelectionTiles();
|
||||
|
||||
gMapSelectFlags.unset(MapSelectFlag::enable);
|
||||
gMapSelectFlags.unset(MapSelectFlag::enableConstruct);
|
||||
|
||||
if (_sceneryPaintEnabled)
|
||||
return;
|
||||
if (gWindowSceneryEyedropperEnabled)
|
||||
return;
|
||||
|
||||
const auto selection = WindowSceneryGetTabSelection();
|
||||
if (selection.IsUndefined())
|
||||
{
|
||||
SceneryRemoveGhostToolPlacement();
|
||||
return;
|
||||
}
|
||||
|
||||
money64 cost = 0;
|
||||
|
||||
switch (selection.SceneryType)
|
||||
{
|
||||
case SCENERY_TYPE_SMALL:
|
||||
void onToolUpdateSmallScenery(WidgetIndex widgetIndex, const ScreenCoordsXY& screenPos, ScenerySelection selection)
|
||||
{
|
||||
CoordsXY mapTile = {};
|
||||
uint8_t quadrant;
|
||||
@@ -1874,6 +1759,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
attemptsLeft = 20;
|
||||
}
|
||||
|
||||
money64 cost = 0;
|
||||
for (; attemptsLeft != 0; attemptsLeft--)
|
||||
{
|
||||
cost = TryPlaceGhostSmallScenery(
|
||||
@@ -1886,9 +1772,9 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
|
||||
gSceneryPlaceCost = cost;
|
||||
break;
|
||||
}
|
||||
case SCENERY_TYPE_PATH_ITEM:
|
||||
|
||||
void onToolUpdatePathItem(WidgetIndex widgetIndex, const ScreenCoordsXY& screenPos, ScenerySelection selection)
|
||||
{
|
||||
CoordsXY mapTile = {};
|
||||
int32_t z;
|
||||
@@ -1911,20 +1797,19 @@ namespace OpenRCT2::Ui::Windows
|
||||
MapInvalidateSelectionRect();
|
||||
|
||||
// If no change in ghost placement
|
||||
if ((gSceneryGhostType & SCENERY_GHOST_FLAG_1) && mapTile == gSceneryGhostPosition
|
||||
&& z == gSceneryGhostPosition.z)
|
||||
if ((gSceneryGhostType & SCENERY_GHOST_FLAG_1) && mapTile == gSceneryGhostPosition && z == gSceneryGhostPosition.z)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SceneryRemoveGhostToolPlacement();
|
||||
|
||||
cost = TryPlaceGhostPathAddition({ mapTile, z }, selection.EntryIndex);
|
||||
money64 cost = TryPlaceGhostPathAddition({ mapTile, z }, selection.EntryIndex);
|
||||
|
||||
gSceneryPlaceCost = cost;
|
||||
break;
|
||||
}
|
||||
case SCENERY_TYPE_WALL:
|
||||
|
||||
void onToolUpdateWall(WidgetIndex widgetIndex, const ScreenCoordsXY& screenPos, ScenerySelection selection)
|
||||
{
|
||||
CoordsXY mapTile = {};
|
||||
uint8_t edge;
|
||||
@@ -1964,12 +1849,12 @@ namespace OpenRCT2::Ui::Windows
|
||||
attemptsLeft = 20;
|
||||
}
|
||||
|
||||
cost = 0;
|
||||
money64 cost = 0;
|
||||
for (; attemptsLeft != 0; attemptsLeft--)
|
||||
{
|
||||
cost = TryPlaceGhostWall(
|
||||
{ mapTile, gSceneryPlaceZ }, edge, selection.EntryIndex, _sceneryPrimaryColour,
|
||||
_scenerySecondaryColour, _sceneryTertiaryColour);
|
||||
{ mapTile, gSceneryPlaceZ }, edge, selection.EntryIndex, _sceneryPrimaryColour, _scenerySecondaryColour,
|
||||
_sceneryTertiaryColour);
|
||||
|
||||
if (cost != kMoney64Undefined)
|
||||
break;
|
||||
@@ -1977,9 +1862,9 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
|
||||
gSceneryPlaceCost = cost;
|
||||
break;
|
||||
}
|
||||
case SCENERY_TYPE_LARGE:
|
||||
|
||||
void onToolUpdateLargeScenery(WidgetIndex widgetIndex, const ScreenCoordsXY& screenPos, ScenerySelection selection)
|
||||
{
|
||||
CoordsXY mapTile = {};
|
||||
Direction direction;
|
||||
@@ -2010,8 +1895,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
MapInvalidateMapSelectionTiles();
|
||||
|
||||
// If no change in ghost placement
|
||||
if ((gSceneryGhostType & SCENERY_GHOST_FLAG_3) && mapTile == gSceneryGhostPosition
|
||||
&& gSceneryPlaceZ == _unkF64F0A && gSceneryPlaceObject.SceneryType == SCENERY_TYPE_LARGE
|
||||
if ((gSceneryGhostType & SCENERY_GHOST_FLAG_3) && mapTile == gSceneryGhostPosition && gSceneryPlaceZ == _unkF64F0A
|
||||
&& gSceneryPlaceObject.SceneryType == SCENERY_TYPE_LARGE
|
||||
&& gSceneryPlaceObject.EntryIndex == selection.EntryIndex)
|
||||
{
|
||||
return;
|
||||
@@ -2029,7 +1914,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
attemptsLeft = 20;
|
||||
}
|
||||
|
||||
cost = 0;
|
||||
money64 cost = 0;
|
||||
for (; attemptsLeft != 0; attemptsLeft--)
|
||||
{
|
||||
cost = TryPlaceGhostLargeScenery(
|
||||
@@ -2042,9 +1927,9 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
|
||||
gSceneryPlaceCost = cost;
|
||||
break;
|
||||
}
|
||||
case SCENERY_TYPE_BANNER:
|
||||
|
||||
void onToolUpdateBanner(WidgetIndex widgetIndex, const ScreenCoordsXY& screenPos, ScenerySelection selection)
|
||||
{
|
||||
CoordsXY mapTile = {};
|
||||
Direction direction;
|
||||
@@ -2068,18 +1953,64 @@ namespace OpenRCT2::Ui::Windows
|
||||
MapInvalidateSelectionRect();
|
||||
|
||||
// If no change in ghost placement
|
||||
if ((gSceneryGhostType & SCENERY_GHOST_FLAG_4) && mapTile == gSceneryGhostPosition
|
||||
&& z == gSceneryGhostPosition.z && direction == gSceneryPlaceRotation)
|
||||
if ((gSceneryGhostType & SCENERY_GHOST_FLAG_4) && mapTile == gSceneryGhostPosition && z == gSceneryGhostPosition.z
|
||||
&& direction == gSceneryPlaceRotation)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SceneryRemoveGhostToolPlacement();
|
||||
|
||||
cost = TryPlaceGhostBanner({ mapTile, z, direction }, selection.EntryIndex);
|
||||
money64 cost = TryPlaceGhostBanner({ mapTile, z, direction }, selection.EntryIndex);
|
||||
|
||||
gSceneryPlaceCost = cost;
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006E287B
|
||||
*/
|
||||
void onToolUpdate(WidgetIndex widgetIndex, const ScreenCoordsXY& screenPos) override
|
||||
{
|
||||
MapInvalidateSelectionRect();
|
||||
MapInvalidateMapSelectionTiles();
|
||||
|
||||
gMapSelectFlags.unset(MapSelectFlag::enable);
|
||||
gMapSelectFlags.unset(MapSelectFlag::enableConstruct);
|
||||
|
||||
if (_sceneryPaintEnabled)
|
||||
return;
|
||||
if (gWindowSceneryEyedropperEnabled)
|
||||
return;
|
||||
|
||||
const auto selection = WindowSceneryGetTabSelection();
|
||||
if (selection.IsUndefined())
|
||||
{
|
||||
SceneryRemoveGhostToolPlacement();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (selection.SceneryType)
|
||||
{
|
||||
case SCENERY_TYPE_SMALL:
|
||||
{
|
||||
return onToolUpdateSmallScenery(widgetIndex, screenPos, selection);
|
||||
}
|
||||
case SCENERY_TYPE_PATH_ITEM:
|
||||
{
|
||||
return onToolUpdatePathItem(widgetIndex, screenPos, selection);
|
||||
}
|
||||
case SCENERY_TYPE_WALL:
|
||||
{
|
||||
return onToolUpdateWall(widgetIndex, screenPos, selection);
|
||||
}
|
||||
case SCENERY_TYPE_LARGE:
|
||||
{
|
||||
return onToolUpdateLargeScenery(widgetIndex, screenPos, selection);
|
||||
}
|
||||
case SCENERY_TYPE_BANNER:
|
||||
{
|
||||
return onToolUpdateBanner(widgetIndex, screenPos, selection);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2453,7 +2384,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
gSceneryShiftPressZOffset = mainWnd->viewport->zoom.ApplyTo(gSceneryShiftPressZOffset);
|
||||
}
|
||||
gSceneryShiftPressZOffset = floor2(gSceneryShiftPressZOffset, 8);
|
||||
gSceneryShiftPressZOffset = Numerics::floor2(gSceneryShiftPressZOffset, 8);
|
||||
|
||||
screenPos.x = gSceneryShiftPressX;
|
||||
screenPos.y = gSceneryShiftPressY;
|
||||
@@ -2942,39 +2873,12 @@ namespace OpenRCT2::Ui::Windows
|
||||
*outZ = z;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006E2CC6
|
||||
*/
|
||||
void SceneryToolDown(const ScreenCoordsXY& screenCoords, WidgetIndex widgetIndex)
|
||||
void onToolDownSmallScenery(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords, uint16_t selectedScenery)
|
||||
{
|
||||
SceneryRemoveGhostToolPlacement();
|
||||
|
||||
if (_sceneryPaintEnabled)
|
||||
{
|
||||
RepaintSceneryToolDown(screenCoords, widgetIndex);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gWindowSceneryEyedropperEnabled)
|
||||
{
|
||||
SceneryEyedropperToolDown(screenCoords, widgetIndex);
|
||||
return;
|
||||
}
|
||||
|
||||
auto tabSelection = WindowSceneryGetTabSelection();
|
||||
uint8_t sceneryType = tabSelection.SceneryType;
|
||||
uint16_t selectedScenery = tabSelection.EntryIndex;
|
||||
CoordsXY gridPos;
|
||||
|
||||
auto& gameState = getGameState();
|
||||
|
||||
switch (sceneryType)
|
||||
{
|
||||
case SCENERY_TYPE_SMALL:
|
||||
{
|
||||
uint8_t quadrant;
|
||||
Direction rotation;
|
||||
|
||||
Sub6E1F34SmallScenery(screenCoords, selectedScenery, gridPos, &quadrant, &rotation);
|
||||
if (gridPos.IsNull())
|
||||
return;
|
||||
@@ -3047,6 +2951,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
auto smallSceneryPlaceAction = GameActions::SmallSceneryPlaceAction(
|
||||
{ cur_grid_x, cur_grid_y, gSceneryPlaceZ, gSceneryPlaceRotation }, quadrant, selectedScenery,
|
||||
_sceneryPrimaryColour, _scenerySecondaryColour, _sceneryTertiaryColour);
|
||||
|
||||
auto& gameState = getGameState();
|
||||
auto res = GameActions::Query(&smallSceneryPlaceAction, gameState);
|
||||
success = res.Error;
|
||||
if (res.Error == GameActions::Status::Ok)
|
||||
@@ -3078,6 +2984,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
Audio::Play3D(Audio::SoundId::placeItem, result->Position);
|
||||
}
|
||||
});
|
||||
|
||||
auto& gameState = getGameState();
|
||||
auto res = GameActions::Execute(&smallSceneryPlaceAction, gameState);
|
||||
if (res.Error == GameActions::Status::Ok)
|
||||
{
|
||||
@@ -3091,31 +2999,34 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
gSceneryPlaceZ = zCoordinate;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SCENERY_TYPE_PATH_ITEM:
|
||||
|
||||
void onToolDownPathItem(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords, uint16_t selectedScenery)
|
||||
{
|
||||
CoordsXY gridPos;
|
||||
int32_t z;
|
||||
|
||||
Sub6E1F34PathItem(screenCoords, selectedScenery, gridPos, &z);
|
||||
if (gridPos.IsNull())
|
||||
return;
|
||||
|
||||
auto footpathAdditionPlaceAction = GameActions::FootpathAdditionPlaceAction(
|
||||
{ gridPos, z }, selectedScenery);
|
||||
auto footpathAdditionPlaceAction = GameActions::FootpathAdditionPlaceAction({ gridPos, z }, selectedScenery);
|
||||
|
||||
footpathAdditionPlaceAction.SetCallback(
|
||||
[](const GameActions::GameAction* ga, const GameActions::Result* result) {
|
||||
footpathAdditionPlaceAction.SetCallback([](const GameActions::GameAction* ga, const GameActions::Result* result) {
|
||||
if (result->Error != GameActions::Status::Ok)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Audio::Play3D(Audio::SoundId::placeItem, result->Position);
|
||||
});
|
||||
|
||||
auto& gameState = getGameState();
|
||||
auto res = GameActions::Execute(&footpathAdditionPlaceAction, gameState);
|
||||
break;
|
||||
}
|
||||
case SCENERY_TYPE_WALL:
|
||||
|
||||
void onToolDownWall(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords, uint16_t selectedScenery)
|
||||
{
|
||||
CoordsXY gridPos;
|
||||
uint8_t edges;
|
||||
Sub6E1F34Wall(screenCoords, selectedScenery, gridPos, &edges);
|
||||
if (gridPos.IsNull())
|
||||
@@ -3133,6 +3044,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
selectedScenery, { gridPos, gSceneryPlaceZ }, edges, _sceneryPrimaryColour, _scenerySecondaryColour,
|
||||
_sceneryTertiaryColour);
|
||||
|
||||
auto& gameState = getGameState();
|
||||
auto res = GameActions::Query(&wallPlaceAction, gameState);
|
||||
if (res.Error == GameActions::Status::Ok)
|
||||
{
|
||||
@@ -3163,11 +3075,14 @@ namespace OpenRCT2::Ui::Windows
|
||||
Audio::Play3D(Audio::SoundId::placeItem, result->Position);
|
||||
}
|
||||
});
|
||||
|
||||
auto& gameState = getGameState();
|
||||
auto res = GameActions::Execute(&wallPlaceAction, gameState);
|
||||
break;
|
||||
}
|
||||
case SCENERY_TYPE_LARGE:
|
||||
|
||||
void onToolDownLargeScenery(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords, uint16_t selectedScenery)
|
||||
{
|
||||
CoordsXY gridPos;
|
||||
Direction direction;
|
||||
Sub6E1F34LargeScenery(screenCoords, selectedScenery, gridPos, &direction);
|
||||
if (gridPos.IsNull())
|
||||
@@ -3186,6 +3101,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
auto sceneryPlaceAction = GameActions::LargeSceneryPlaceAction(
|
||||
loc, selectedScenery, _sceneryPrimaryColour, _scenerySecondaryColour, _sceneryTertiaryColour);
|
||||
|
||||
auto& gameState = getGameState();
|
||||
auto res = GameActions::Query(&sceneryPlaceAction, gameState);
|
||||
if (res.Error == GameActions::Status::Ok)
|
||||
{
|
||||
@@ -3220,11 +3136,14 @@ namespace OpenRCT2::Ui::Windows
|
||||
Audio::Play3D(Audio::SoundId::error, { loc.x, loc.y, gSceneryPlaceZ });
|
||||
}
|
||||
});
|
||||
|
||||
auto& gameState = getGameState();
|
||||
auto res = GameActions::Execute(&sceneryPlaceAction, gameState);
|
||||
break;
|
||||
}
|
||||
case SCENERY_TYPE_BANNER:
|
||||
|
||||
void onToolDownBanner(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords, uint16_t selectedScenery)
|
||||
{
|
||||
CoordsXY gridPos;
|
||||
int32_t z;
|
||||
Direction direction;
|
||||
Sub6E1F34Banner(screenCoords, selectedScenery, gridPos, &z, &direction);
|
||||
@@ -3242,11 +3161,66 @@ namespace OpenRCT2::Ui::Windows
|
||||
ContextOpenDetailWindow(WindowDetail::banner, data.bannerId.ToUnderlying());
|
||||
}
|
||||
});
|
||||
|
||||
auto& gameState = getGameState();
|
||||
GameActions::Execute(&bannerPlaceAction, gameState);
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006E2CC6
|
||||
*/
|
||||
void onToolDown(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) override
|
||||
{
|
||||
SceneryRemoveGhostToolPlacement();
|
||||
|
||||
if (_sceneryPaintEnabled)
|
||||
{
|
||||
RepaintSceneryToolDown(screenCoords, widgetIndex);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gWindowSceneryEyedropperEnabled)
|
||||
{
|
||||
SceneryEyedropperToolDown(screenCoords, widgetIndex);
|
||||
return;
|
||||
}
|
||||
|
||||
auto tabSelection = WindowSceneryGetTabSelection();
|
||||
uint8_t sceneryType = tabSelection.SceneryType;
|
||||
uint16_t selectedScenery = tabSelection.EntryIndex;
|
||||
|
||||
switch (sceneryType)
|
||||
{
|
||||
case SCENERY_TYPE_SMALL:
|
||||
{
|
||||
return onToolDownSmallScenery(widgetIndex, screenCoords, selectedScenery);
|
||||
}
|
||||
|
||||
case SCENERY_TYPE_PATH_ITEM:
|
||||
{
|
||||
return onToolDownPathItem(widgetIndex, screenCoords, selectedScenery);
|
||||
}
|
||||
case SCENERY_TYPE_WALL:
|
||||
{
|
||||
return onToolDownWall(widgetIndex, screenCoords, selectedScenery);
|
||||
}
|
||||
case SCENERY_TYPE_LARGE:
|
||||
{
|
||||
return onToolDownLargeScenery(widgetIndex, screenCoords, selectedScenery);
|
||||
}
|
||||
case SCENERY_TYPE_BANNER:
|
||||
{
|
||||
return onToolDownBanner(widgetIndex, screenCoords, selectedScenery);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void onToolDrag(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) override
|
||||
{
|
||||
if (_sceneryPaintEnabled || gWindowSceneryEyedropperEnabled)
|
||||
onToolDown(widgetIndex, screenCoords);
|
||||
}
|
||||
};
|
||||
|
||||
WindowBase* SceneryOpen()
|
||||
|
||||
Reference in New Issue
Block a user