mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 15:52:55 +01:00
Merge pull request #10220 from tupaschoal/coords-for-footpath
Use ScreenCoordsXY for windows/Footpath
This commit is contained in:
@@ -176,10 +176,10 @@ static constexpr const uint8_t ConstructionPreviewImages[][4] = {
|
||||
static void window_footpath_mousedown_direction(int32_t direction);
|
||||
static void window_footpath_mousedown_slope(int32_t slope);
|
||||
static void window_footpath_show_footpath_types_dialog(rct_window* w, rct_widget* widget, bool showQueues);
|
||||
static void window_footpath_set_provisional_path_at_point(int32_t x, int32_t y);
|
||||
static void window_footpath_set_selection_start_bridge_at_point(int32_t screenX, int32_t screenY);
|
||||
static void window_footpath_place_path_at_point(int32_t x, int32_t y);
|
||||
static void window_footpath_start_bridge_at_point(int32_t screenX, int32_t screenY);
|
||||
static void window_footpath_set_provisional_path_at_point(ScreenCoordsXY screenCoords);
|
||||
static void window_footpath_set_selection_start_bridge_at_point(ScreenCoordsXY screenCoords);
|
||||
static void window_footpath_place_path_at_point(ScreenCoordsXY screenCoords);
|
||||
static void window_footpath_start_bridge_at_point(ScreenCoordsXY screenCoords);
|
||||
static void window_footpath_construct();
|
||||
static void window_footpath_remove();
|
||||
static void window_footpath_set_enabled_and_pressed_widgets();
|
||||
@@ -409,11 +409,11 @@ static void window_footpath_toolupdate(rct_window* w, rct_widgetindex widgetInde
|
||||
{
|
||||
if (widgetIndex == WIDX_CONSTRUCT_ON_LAND)
|
||||
{
|
||||
window_footpath_set_provisional_path_at_point(screenCoords.x, screenCoords.y);
|
||||
window_footpath_set_provisional_path_at_point(screenCoords);
|
||||
}
|
||||
else if (widgetIndex == WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL)
|
||||
{
|
||||
window_footpath_set_selection_start_bridge_at_point(screenCoords.x, screenCoords.y);
|
||||
window_footpath_set_selection_start_bridge_at_point(screenCoords);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -425,11 +425,11 @@ static void window_footpath_tooldown(rct_window* w, rct_widgetindex widgetIndex,
|
||||
{
|
||||
if (widgetIndex == WIDX_CONSTRUCT_ON_LAND)
|
||||
{
|
||||
window_footpath_place_path_at_point(screenCoords.x, screenCoords.y);
|
||||
window_footpath_place_path_at_point(screenCoords);
|
||||
}
|
||||
else if (widgetIndex == WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL)
|
||||
{
|
||||
window_footpath_start_bridge_at_point(screenCoords.x, screenCoords.y);
|
||||
window_footpath_start_bridge_at_point(screenCoords);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,7 +441,7 @@ static void window_footpath_tooldrag(rct_window* w, rct_widgetindex widgetIndex,
|
||||
{
|
||||
if (widgetIndex == WIDX_CONSTRUCT_ON_LAND)
|
||||
{
|
||||
window_footpath_place_path_at_point(screenCoords.x, screenCoords.y);
|
||||
window_footpath_place_path_at_point(screenCoords);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -708,7 +708,7 @@ static void window_footpath_mousedown_slope(int32_t slope)
|
||||
*
|
||||
* rct2: 0x006A81FB
|
||||
*/
|
||||
static void window_footpath_set_provisional_path_at_point(int32_t x, int32_t y)
|
||||
static void window_footpath_set_provisional_path_at_point(ScreenCoordsXY screenCoords)
|
||||
{
|
||||
map_invalidate_selection_rect();
|
||||
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
|
||||
@@ -717,10 +717,8 @@ static void window_footpath_set_provisional_path_at_point(int32_t x, int32_t y)
|
||||
TileElement* tileElement{};
|
||||
LocationXY16 mapCoord = {};
|
||||
get_map_coordinates_from_pos(
|
||||
x, y, VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_TERRAIN, &mapCoord.x, &mapCoord.y,
|
||||
&interactionType, &tileElement, nullptr);
|
||||
x = mapCoord.x;
|
||||
y = mapCoord.y;
|
||||
screenCoords.x, screenCoords.y, VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_TERRAIN, &mapCoord.x,
|
||||
&mapCoord.y, &interactionType, &tileElement, nullptr);
|
||||
|
||||
if (interactionType == VIEWPORT_INTERACTION_ITEM_NONE || tileElement == nullptr)
|
||||
{
|
||||
@@ -730,8 +728,8 @@ static void window_footpath_set_provisional_path_at_point(int32_t x, int32_t y)
|
||||
else
|
||||
{
|
||||
// Check for change
|
||||
if ((gFootpathProvisionalFlags & PROVISIONAL_PATH_FLAG_1) && gFootpathProvisionalPosition.x == x
|
||||
&& gFootpathProvisionalPosition.y == y && gFootpathProvisionalPosition.z == tileElement->base_height)
|
||||
if ((gFootpathProvisionalFlags & PROVISIONAL_PATH_FLAG_1) && gFootpathProvisionalPosition.x == mapCoord.x
|
||||
&& gFootpathProvisionalPosition.y == mapCoord.y && gFootpathProvisionalPosition.z == tileElement->base_height)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -739,10 +737,10 @@ static void window_footpath_set_provisional_path_at_point(int32_t x, int32_t y)
|
||||
// Set map selection
|
||||
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
|
||||
gMapSelectType = MAP_SELECT_TYPE_FULL;
|
||||
gMapSelectPositionA.x = x;
|
||||
gMapSelectPositionA.y = y;
|
||||
gMapSelectPositionB.x = x;
|
||||
gMapSelectPositionB.y = y;
|
||||
gMapSelectPositionA.x = mapCoord.x;
|
||||
gMapSelectPositionA.y = mapCoord.y;
|
||||
gMapSelectPositionB.x = mapCoord.x;
|
||||
gMapSelectPositionB.y = mapCoord.y;
|
||||
|
||||
footpath_provisional_update();
|
||||
|
||||
@@ -781,7 +779,7 @@ static void window_footpath_set_provisional_path_at_point(int32_t x, int32_t y)
|
||||
}
|
||||
int32_t pathType = (gFootpathSelectedType << 7) + (gFootpathSelectedId & 0xFF);
|
||||
|
||||
_window_footpath_cost = footpath_provisional_set(pathType, x, y, z, slope);
|
||||
_window_footpath_cost = footpath_provisional_set(pathType, mapCoord.x, mapCoord.y, z, slope);
|
||||
window_invalidate_by_class(WC_FOOTPATH);
|
||||
}
|
||||
}
|
||||
@@ -790,7 +788,7 @@ static void window_footpath_set_provisional_path_at_point(int32_t x, int32_t y)
|
||||
*
|
||||
* rct2: 0x006A8388
|
||||
*/
|
||||
static void window_footpath_set_selection_start_bridge_at_point(int32_t screenX, int32_t screenY)
|
||||
static void window_footpath_set_selection_start_bridge_at_point(ScreenCoordsXY screenCoords)
|
||||
{
|
||||
int32_t x, y, direction;
|
||||
TileElement* tileElement;
|
||||
@@ -799,7 +797,7 @@ static void window_footpath_set_selection_start_bridge_at_point(int32_t screenX,
|
||||
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
|
||||
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
|
||||
|
||||
footpath_bridge_get_info_from_pos(screenX, screenY, &x, &y, &direction, &tileElement);
|
||||
footpath_bridge_get_info_from_pos(screenCoords, &x, &y, &direction, &tileElement);
|
||||
if (x == LOCATION_NULL)
|
||||
{
|
||||
return;
|
||||
@@ -839,7 +837,7 @@ static void window_footpath_set_selection_start_bridge_at_point(int32_t screenX,
|
||||
*
|
||||
* rct2: 0x006A82C5
|
||||
*/
|
||||
static void window_footpath_place_path_at_point(int32_t x, int32_t y)
|
||||
static void window_footpath_place_path_at_point(ScreenCoordsXY screenCoords)
|
||||
{
|
||||
int32_t interactionType, currentType, selectedType, z;
|
||||
TileElement* tileElement;
|
||||
@@ -853,10 +851,8 @@ static void window_footpath_place_path_at_point(int32_t x, int32_t y)
|
||||
|
||||
LocationXY16 mapCoord = {};
|
||||
get_map_coordinates_from_pos(
|
||||
x, y, VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_TERRAIN, &mapCoord.x, &mapCoord.y,
|
||||
&interactionType, &tileElement, nullptr);
|
||||
x = mapCoord.x;
|
||||
y = mapCoord.y;
|
||||
screenCoords.x, screenCoords.y, VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_TERRAIN, &mapCoord.x,
|
||||
&mapCoord.y, &interactionType, &tileElement, nullptr);
|
||||
|
||||
if (interactionType == VIEWPORT_INTERACTION_ITEM_NONE)
|
||||
{
|
||||
@@ -888,7 +884,7 @@ static void window_footpath_place_path_at_point(int32_t x, int32_t y)
|
||||
|
||||
// Try and place path
|
||||
gGameCommandErrorTitle = STR_CANT_BUILD_FOOTPATH_HERE;
|
||||
auto footpathPlaceAction = FootpathPlaceAction({ x, y, z * 8 }, currentType, selectedType);
|
||||
auto footpathPlaceAction = FootpathPlaceAction({ mapCoord.x, mapCoord.y, z * 8 }, currentType, selectedType);
|
||||
footpathPlaceAction.SetCallback([](const GameAction* ga, const GameActionResult* result) {
|
||||
if (result->Error == GA_ERROR::OK)
|
||||
{
|
||||
@@ -910,12 +906,12 @@ static void window_footpath_place_path_at_point(int32_t x, int32_t y)
|
||||
*
|
||||
* rct2: 0x006A840F
|
||||
*/
|
||||
static void window_footpath_start_bridge_at_point(int32_t screenX, int32_t screenY)
|
||||
static void window_footpath_start_bridge_at_point(ScreenCoordsXY screenCoords)
|
||||
{
|
||||
int32_t x, y, z, direction;
|
||||
TileElement* tileElement;
|
||||
|
||||
footpath_bridge_get_info_from_pos(screenX, screenY, &x, &y, &direction, &tileElement);
|
||||
footpath_bridge_get_info_from_pos(screenCoords, &x, &y, &direction, &tileElement);
|
||||
if (x == LOCATION_NULL)
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -1231,7 +1231,7 @@ void window_guest_overview_tool_update(rct_window* w, rct_widgetindex widgetInde
|
||||
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
|
||||
|
||||
int32_t map_x, map_y;
|
||||
footpath_get_coordinates_from_pos(screenCoords.x, screenCoords.y + 16, &map_x, &map_y, nullptr, nullptr);
|
||||
footpath_get_coordinates_from_pos({ screenCoords.x, screenCoords.y + 16 }, &map_x, &map_y, nullptr, nullptr);
|
||||
if (map_x != LOCATION_NULL)
|
||||
{
|
||||
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
|
||||
@@ -1282,7 +1282,7 @@ void window_guest_overview_tool_down(rct_window* w, rct_widgetindex widgetIndex,
|
||||
|
||||
int32_t dest_x, dest_y;
|
||||
TileElement* tileElement;
|
||||
footpath_get_coordinates_from_pos(screenCoords.x, screenCoords.y + 16, &dest_x, &dest_y, nullptr, &tileElement);
|
||||
footpath_get_coordinates_from_pos({ screenCoords.x, screenCoords.y + 16 }, &dest_x, &dest_y, nullptr, &tileElement);
|
||||
|
||||
if (dest_x == LOCATION_NULL)
|
||||
return;
|
||||
|
||||
@@ -1271,7 +1271,7 @@ static void window_map_set_peep_spawn_tool_update(int32_t x, int32_t y)
|
||||
map_invalidate_selection_rect();
|
||||
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
|
||||
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
|
||||
footpath_bridge_get_info_from_pos(x, y, &mapX, &mapY, &direction, &tileElement);
|
||||
footpath_bridge_get_info_from_pos({ x, y }, &mapX, &mapY, &direction, &tileElement);
|
||||
if ((mapX & 0xFFFF) == 0x8000)
|
||||
return;
|
||||
|
||||
@@ -1329,7 +1329,7 @@ static void window_map_set_peep_spawn_tool_down(int32_t x, int32_t y)
|
||||
int32_t mapX, mapY, mapZ, direction;
|
||||
|
||||
// Verify footpath exists at location, and retrieve coordinates
|
||||
footpath_get_coordinates_from_pos(x, y, &mapX, &mapY, &direction, &tileElement);
|
||||
footpath_get_coordinates_from_pos({ x, y }, &mapX, &mapY, &direction, &tileElement);
|
||||
if (mapX == LOCATION_NULL)
|
||||
return;
|
||||
|
||||
|
||||
@@ -1147,7 +1147,7 @@ void window_staff_overview_tool_update(rct_window* w, rct_widgetindex widgetInde
|
||||
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
|
||||
|
||||
int32_t map_x, map_y;
|
||||
footpath_get_coordinates_from_pos(screenCoords.x, screenCoords.y + 16, &map_x, &map_y, nullptr, nullptr);
|
||||
footpath_get_coordinates_from_pos({ screenCoords.x, screenCoords.y + 16 }, &map_x, &map_y, nullptr, nullptr);
|
||||
if (map_x != LOCATION_NULL)
|
||||
{
|
||||
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
|
||||
@@ -1197,7 +1197,7 @@ void window_staff_overview_tool_down(rct_window* w, rct_widgetindex widgetIndex,
|
||||
{
|
||||
int32_t dest_x, dest_y;
|
||||
TileElement* tileElement;
|
||||
footpath_get_coordinates_from_pos(screenCoords.x, screenCoords.y + 16, &dest_x, &dest_y, nullptr, &tileElement);
|
||||
footpath_get_coordinates_from_pos({ screenCoords.x, screenCoords.y + 16 }, &dest_x, &dest_y, nullptr, &tileElement);
|
||||
|
||||
if (dest_x == LOCATION_NULL)
|
||||
return;
|
||||
@@ -1216,7 +1216,7 @@ void window_staff_overview_tool_down(rct_window* w, rct_widgetindex widgetIndex,
|
||||
else if (widgetIndex == WIDX_PATROL)
|
||||
{
|
||||
int32_t dest_x, dest_y;
|
||||
footpath_get_coordinates_from_pos(screenCoords.x, screenCoords.y, &dest_x, &dest_y, nullptr, nullptr);
|
||||
footpath_get_coordinates_from_pos(screenCoords, &dest_x, &dest_y, nullptr, nullptr);
|
||||
|
||||
if (dest_x == LOCATION_NULL)
|
||||
return;
|
||||
@@ -1257,7 +1257,7 @@ void window_staff_overview_tool_drag(rct_window* w, rct_widgetindex widgetIndex,
|
||||
return; // Do nothing if we do not have a paintvalue(this should never happen)
|
||||
|
||||
int32_t dest_x, dest_y;
|
||||
footpath_get_coordinates_from_pos(screenCoords.x, screenCoords.y, &dest_x, &dest_y, nullptr, nullptr);
|
||||
footpath_get_coordinates_from_pos(screenCoords, &dest_x, &dest_y, nullptr, nullptr);
|
||||
|
||||
if (dest_x == LOCATION_NULL)
|
||||
return;
|
||||
|
||||
@@ -343,8 +343,7 @@ static void window_staff_list_tooldown(rct_window* w, rct_widgetindex widgetInde
|
||||
int32_t direction;
|
||||
TileElement* tileElement;
|
||||
CoordsXY footpathCoords;
|
||||
footpath_get_coordinates_from_pos(
|
||||
screenCoords.x, screenCoords.y, &footpathCoords.x, &footpathCoords.y, &direction, &tileElement);
|
||||
footpath_get_coordinates_from_pos(screenCoords, &footpathCoords.x, &footpathCoords.y, &direction, &tileElement);
|
||||
if (footpathCoords.x == LOCATION_NULL)
|
||||
return;
|
||||
|
||||
|
||||
@@ -247,7 +247,7 @@ void footpath_provisional_update()
|
||||
* tileElement: edx
|
||||
*/
|
||||
void footpath_get_coordinates_from_pos(
|
||||
int32_t screenX, int32_t screenY, int32_t* x, int32_t* y, int32_t* direction, TileElement** tileElement)
|
||||
ScreenCoordsXY screenCoords, int32_t* x, int32_t* y, int32_t* direction, TileElement** tileElement)
|
||||
{
|
||||
int32_t z = 0, interactionType;
|
||||
TileElement* myTileElement;
|
||||
@@ -255,14 +255,14 @@ void footpath_get_coordinates_from_pos(
|
||||
LocationXY16 position16 = {};
|
||||
|
||||
get_map_coordinates_from_pos(
|
||||
screenX, screenY, VIEWPORT_INTERACTION_MASK_FOOTPATH, &position16.x, &position16.y, &interactionType, &myTileElement,
|
||||
&viewport);
|
||||
screenCoords.x, screenCoords.y, VIEWPORT_INTERACTION_MASK_FOOTPATH, &position16.x, &position16.y, &interactionType,
|
||||
&myTileElement, &viewport);
|
||||
if (interactionType != VIEWPORT_INTERACTION_ITEM_FOOTPATH
|
||||
|| !(viewport->flags & (VIEWPORT_FLAG_UNDERGROUND_INSIDE | VIEWPORT_FLAG_HIDE_BASE | VIEWPORT_FLAG_HIDE_VERTICAL)))
|
||||
{
|
||||
get_map_coordinates_from_pos(
|
||||
screenX, screenY, VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_TERRAIN, &position16.x,
|
||||
&position16.y, &interactionType, &myTileElement, &viewport);
|
||||
screenCoords.x, screenCoords.y, VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_TERRAIN,
|
||||
&position16.x, &position16.y, &interactionType, &myTileElement, &viewport);
|
||||
if (interactionType == VIEWPORT_INTERACTION_ITEM_NONE)
|
||||
{
|
||||
if (x != nullptr)
|
||||
@@ -286,7 +286,7 @@ void footpath_get_coordinates_from_pos(
|
||||
}
|
||||
}
|
||||
|
||||
LocationXY16 start_vp_pos = screen_coord_to_viewport_coord(viewport, screenX, screenY);
|
||||
LocationXY16 start_vp_pos = screen_coord_to_viewport_coord(viewport, screenCoords.x, screenCoords.y);
|
||||
|
||||
for (int32_t i = 0; i < 5; i++)
|
||||
{
|
||||
@@ -346,7 +346,7 @@ void footpath_get_coordinates_from_pos(
|
||||
* tileElement: edx
|
||||
*/
|
||||
void footpath_bridge_get_info_from_pos(
|
||||
int32_t screenX, int32_t screenY, int32_t* x, int32_t* y, int32_t* direction, TileElement** tileElement)
|
||||
ScreenCoordsXY screenCoords, int32_t* x, int32_t* y, int32_t* direction, TileElement** tileElement)
|
||||
{
|
||||
// First check if we point at an entrance or exit. In that case, we would want the path coming from the entrance/exit.
|
||||
int32_t interactionType;
|
||||
@@ -354,7 +354,8 @@ void footpath_bridge_get_info_from_pos(
|
||||
|
||||
LocationXY16 map_pos = {};
|
||||
get_map_coordinates_from_pos(
|
||||
screenX, screenY, VIEWPORT_INTERACTION_MASK_RIDE, &map_pos.x, &map_pos.y, &interactionType, tileElement, &viewport);
|
||||
screenCoords.x, screenCoords.y, VIEWPORT_INTERACTION_MASK_RIDE, &map_pos.x, &map_pos.y, &interactionType, tileElement,
|
||||
&viewport);
|
||||
*x = map_pos.x;
|
||||
*y = map_pos.y;
|
||||
|
||||
@@ -375,7 +376,7 @@ void footpath_bridge_get_info_from_pos(
|
||||
}
|
||||
|
||||
get_map_coordinates_from_pos(
|
||||
screenX, screenY,
|
||||
screenCoords.x, screenCoords.y,
|
||||
VIEWPORT_INTERACTION_MASK_RIDE & VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_TERRAIN, &map_pos.x,
|
||||
&map_pos.y, &interactionType, tileElement, &viewport);
|
||||
*x = map_pos.x;
|
||||
@@ -393,7 +394,7 @@ void footpath_bridge_get_info_from_pos(
|
||||
}
|
||||
|
||||
// We point at something else
|
||||
footpath_get_coordinates_from_pos(screenX, screenY, x, y, direction, tileElement);
|
||||
footpath_get_coordinates_from_pos(screenCoords, x, y, direction, tileElement);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -181,9 +181,9 @@ money32 footpath_provisional_set(int32_t type, int32_t x, int32_t y, int32_t z,
|
||||
void footpath_provisional_remove();
|
||||
void footpath_provisional_update();
|
||||
void footpath_get_coordinates_from_pos(
|
||||
int32_t screenX, int32_t screenY, int32_t* x, int32_t* y, int32_t* direction, TileElement** tileElement);
|
||||
ScreenCoordsXY screenCoords, int32_t* x, int32_t* y, int32_t* direction, TileElement** tileElement);
|
||||
void footpath_bridge_get_info_from_pos(
|
||||
int32_t screenX, int32_t screenY, int32_t* x, int32_t* y, int32_t* direction, TileElement** tileElement);
|
||||
ScreenCoordsXY screenCoords, int32_t* x, int32_t* y, int32_t* direction, TileElement** tileElement);
|
||||
void footpath_remove_litter(int32_t x, int32_t y, int32_t z);
|
||||
void footpath_connect_edges(int32_t x, int32_t y, TileElement* tileElement, int32_t flags);
|
||||
void footpath_update_queue_chains();
|
||||
|
||||
Reference in New Issue
Block a user