mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
Split onToolUpdate function into smaller functions
This commit is contained in:
@@ -1715,35 +1715,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
|
||||
money64 cost = 0;
|
||||
|
||||
switch (selection.SceneryType)
|
||||
{
|
||||
case SCENERY_TYPE_SMALL:
|
||||
void onToolUpdateSmallScenery(WidgetIndex widgetIndex, const ScreenCoordsXY& screenPos, ScenerySelection selection)
|
||||
{
|
||||
CoordsXY mapTile = {};
|
||||
uint8_t quadrant;
|
||||
@@ -1808,6 +1780,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
attemptsLeft = 20;
|
||||
}
|
||||
|
||||
money64 cost = 0;
|
||||
for (; attemptsLeft != 0; attemptsLeft--)
|
||||
{
|
||||
cost = TryPlaceGhostSmallScenery(
|
||||
@@ -1820,9 +1793,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;
|
||||
@@ -1845,20 +1818,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;
|
||||
@@ -1898,12 +1870,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;
|
||||
@@ -1911,9 +1883,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;
|
||||
@@ -1944,8 +1916,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;
|
||||
@@ -1963,7 +1935,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
attemptsLeft = 20;
|
||||
}
|
||||
|
||||
cost = 0;
|
||||
money64 cost = 0;
|
||||
for (; attemptsLeft != 0; attemptsLeft--)
|
||||
{
|
||||
cost = TryPlaceGhostLargeScenery(
|
||||
@@ -1976,9 +1948,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;
|
||||
@@ -2002,18 +1974,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user