mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 19:13:07 +01:00
@@ -219,7 +219,7 @@ namespace OpenRCT2::Scripting
|
||||
auto coords = GetCoordsFromObject(position);
|
||||
if (coords)
|
||||
{
|
||||
window_scroll_to_location(w, coords->x, coords->y, coords->z);
|
||||
window_scroll_to_location(w, *coords);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ static void window_game_bottom_toolbar_mouseup(rct_window* w, rct_widgetindex wi
|
||||
|
||||
rct_window* mainWindow = window_get_main();
|
||||
if (mainWindow != nullptr)
|
||||
window_scroll_to_location(mainWindow, subjectLoc->x, subjectLoc->y, subjectLoc->z);
|
||||
window_scroll_to_location(mainWindow, *subjectLoc);
|
||||
}
|
||||
break;
|
||||
case WIDX_RIGHT_OUTSET:
|
||||
|
||||
@@ -568,14 +568,13 @@ static void window_map_scrollgetsize(rct_window* w, int32_t scrollIndex, int32_t
|
||||
static void window_map_scrollmousedown(rct_window* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
|
||||
{
|
||||
CoordsXY c = map_window_screen_to_map(screenCoords);
|
||||
int32_t mapX = std::clamp(c.x, 0, MAXIMUM_MAP_SIZE_BIG - 1);
|
||||
int32_t mapY = std::clamp(c.y, 0, MAXIMUM_MAP_SIZE_BIG - 1);
|
||||
int32_t mapZ = tile_element_height({ mapX, mapY });
|
||||
auto mapCoords = CoordsXY{ std::clamp(c.x, 0, MAXIMUM_MAP_SIZE_BIG - 1), std::clamp(c.y, 0, MAXIMUM_MAP_SIZE_BIG - 1) };
|
||||
auto mapZ = tile_element_height(mapCoords);
|
||||
|
||||
rct_window* mainWindow = window_get_main();
|
||||
if (mainWindow != nullptr)
|
||||
{
|
||||
window_scroll_to_location(mainWindow, mapX, mapY, mapZ);
|
||||
window_scroll_to_location(mainWindow, { mapCoords, mapZ });
|
||||
}
|
||||
|
||||
if (land_tool_is_active())
|
||||
@@ -584,16 +583,13 @@ static void window_map_scrollmousedown(rct_window* w, int32_t scrollIndex, const
|
||||
int32_t landToolSize = std::max<int32_t>(1, gLandToolSize);
|
||||
int32_t size = (landToolSize * 32) - 32;
|
||||
int32_t radius = (landToolSize * 16) - 16;
|
||||
mapX = (mapX - radius) & 0xFFE0;
|
||||
mapY = (mapY - radius) & 0xFFE0;
|
||||
|
||||
mapCoords = (mapCoords - CoordsXY{ radius, radius }).ToTileStart();
|
||||
map_invalidate_selection_rect();
|
||||
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
|
||||
gMapSelectType = MAP_SELECT_TYPE_FULL;
|
||||
gMapSelectPositionA.x = mapX;
|
||||
gMapSelectPositionA.y = mapY;
|
||||
gMapSelectPositionB.x = mapX + size;
|
||||
gMapSelectPositionB.y = mapY + size;
|
||||
gMapSelectPositionA = mapCoords;
|
||||
gMapSelectPositionB = mapCoords + CoordsXY{ size, size };
|
||||
map_invalidate_selection_rect();
|
||||
|
||||
auto surfaceSetStyleAction = SurfaceSetStyleAction(
|
||||
@@ -607,16 +603,13 @@ static void window_map_scrollmousedown(rct_window* w, int32_t scrollIndex, const
|
||||
int32_t landRightsToolSize = std::max<int32_t>(1, _landRightsToolSize);
|
||||
int32_t size = (landRightsToolSize * 32) - 32;
|
||||
int32_t radius = (landRightsToolSize * 16) - 16;
|
||||
mapX = (mapX - radius) & 0xFFE0;
|
||||
mapY = (mapY - radius) & 0xFFE0;
|
||||
mapCoords = (mapCoords - CoordsXY{ radius, radius }).ToTileStart();
|
||||
|
||||
map_invalidate_selection_rect();
|
||||
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
|
||||
gMapSelectType = MAP_SELECT_TYPE_FULL;
|
||||
gMapSelectPositionA.x = mapX;
|
||||
gMapSelectPositionA.y = mapY;
|
||||
gMapSelectPositionB.x = mapX + size;
|
||||
gMapSelectPositionB.y = mapY + size;
|
||||
gMapSelectPositionA = mapCoords;
|
||||
gMapSelectPositionB = mapCoords + CoordsXY{ size, size };
|
||||
map_invalidate_selection_rect();
|
||||
|
||||
auto landSetRightsAction = LandSetRightsAction(
|
||||
|
||||
@@ -163,7 +163,7 @@ static void window_news_update(rct_window* w)
|
||||
auto subjectLoc = news_item_get_subject_location(newsItem.Type, newsItem.Assoc);
|
||||
if (subjectLoc != std::nullopt && (w = window_get_main()) != nullptr)
|
||||
{
|
||||
window_scroll_to_location(w, subjectLoc->x, subjectLoc->y, subjectLoc->z);
|
||||
window_scroll_to_location(w, *subjectLoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ void window_player_overview_mouse_up(rct_window* w, rct_widgetindex widgetIndex)
|
||||
auto coord = network_get_player_last_action_coord(player);
|
||||
if (coord.x || coord.y || coord.z)
|
||||
{
|
||||
window_scroll_to_location(mainWindow, coord.x, coord.y, coord.z);
|
||||
window_scroll_to_location(mainWindow, coord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ static void window_viewport_mouseup(rct_window* w, rct_widgetindex widgetIndex)
|
||||
get_map_coordinates_from_pos(
|
||||
{ w->windowPos.x + (w->width / 2), w->windowPos.y + (w->height / 2) }, VIEWPORT_INTERACTION_MASK_NONE,
|
||||
mapCoords, nullptr, nullptr, nullptr);
|
||||
window_scroll_to_location(mainWindow, mapCoords.x, mapCoords.y, tile_element_height(mapCoords));
|
||||
window_scroll_to_location(mainWindow, { mapCoords, tile_element_height(mapCoords) });
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -858,7 +858,7 @@ namespace OpenRCT2
|
||||
{
|
||||
auto* mainWindow = window_get_main();
|
||||
if (mainWindow != nullptr)
|
||||
window_scroll_to_location(mainWindow, result->Position.x, result->Position.y, result->Position.z);
|
||||
window_scroll_to_location(mainWindow, result->Position);
|
||||
}
|
||||
|
||||
replayQueue.erase(replayQueue.begin());
|
||||
|
||||
@@ -809,18 +809,14 @@ rct_window* window_get_main()
|
||||
* @param y (ecx)
|
||||
* @param z (edx)
|
||||
*/
|
||||
void window_scroll_to_location(rct_window* w, int32_t x, int32_t y, int32_t z)
|
||||
void window_scroll_to_location(rct_window* w, const CoordsXYZ& coords)
|
||||
{
|
||||
CoordsXYZ location_3d = { x, y, z };
|
||||
|
||||
assert(w != nullptr);
|
||||
|
||||
window_unfollow_sprite(w);
|
||||
|
||||
if (w->viewport)
|
||||
{
|
||||
int16_t height = tile_element_height({ x, y });
|
||||
if (z < height - 16)
|
||||
int16_t height = tile_element_height(coords);
|
||||
if (coords.z < height - 16)
|
||||
{
|
||||
if (!(w->viewport->flags & 1 << 0))
|
||||
{
|
||||
@@ -837,7 +833,7 @@ void window_scroll_to_location(rct_window* w, int32_t x, int32_t y, int32_t z)
|
||||
}
|
||||
}
|
||||
|
||||
auto screenCoords = translate_3d_to_2d_with_z(get_current_rotation(), location_3d);
|
||||
auto screenCoords = translate_3d_to_2d_with_z(get_current_rotation(), coords);
|
||||
|
||||
int32_t i = 0;
|
||||
if (!(gScreenFlags & SCREEN_FLAGS_TITLE_DEMO))
|
||||
|
||||
@@ -713,7 +713,7 @@ void window_push_others_below(rct_window* w1);
|
||||
|
||||
rct_window* window_get_main();
|
||||
|
||||
void window_scroll_to_location(rct_window* w, int32_t x, int32_t y, int32_t z);
|
||||
void window_scroll_to_location(rct_window* w, const CoordsXYZ& coords);
|
||||
void window_rotate_camera(rct_window* w, int32_t direction);
|
||||
void window_viewport_get_map_coords_by_cursor(
|
||||
rct_window* w, int16_t* map_x, int16_t* map_y, int16_t* offset_x, int16_t* offset_y);
|
||||
|
||||
@@ -4,19 +4,17 @@
|
||||
|
||||
void rct_window::SetLocation(int32_t newX, int32_t newY, int32_t newZ)
|
||||
{
|
||||
window_scroll_to_location(this, newX, newY, newZ);
|
||||
window_scroll_to_location(this, { newX, newY, newZ });
|
||||
flags &= ~WF_SCROLLING_TO_LOCATION;
|
||||
}
|
||||
|
||||
void rct_window::ScrollToViewport()
|
||||
{
|
||||
int32_t newX = LOCATION_NULL, newY = LOCATION_NULL, newZ = LOCATION_NULL;
|
||||
rct_window* mainWindow;
|
||||
|
||||
// In original checked to make sure x and y were not -1 as well.
|
||||
if (viewport == nullptr || viewport_focus_coordinates.y == -1)
|
||||
return;
|
||||
|
||||
CoordsXYZ newCoords = {};
|
||||
if (viewport_focus_sprite.type & VIEWPORT_FOCUS_TYPE_SPRITE)
|
||||
{
|
||||
auto* sprite = GetEntity(viewport_focus_sprite.sprite_id);
|
||||
@@ -24,20 +22,20 @@ void rct_window::ScrollToViewport()
|
||||
{
|
||||
return;
|
||||
}
|
||||
newX = sprite->x;
|
||||
newY = sprite->y;
|
||||
newZ = sprite->z;
|
||||
newCoords.x = sprite->x;
|
||||
newCoords.y = sprite->y;
|
||||
newCoords.z = sprite->z;
|
||||
}
|
||||
else
|
||||
{
|
||||
newX = viewport_focus_coordinates.x;
|
||||
newY = viewport_focus_coordinates.y & VIEWPORT_FOCUS_Y_MASK;
|
||||
newZ = viewport_focus_coordinates.z;
|
||||
newCoords.x = viewport_focus_coordinates.x;
|
||||
newCoords.y = viewport_focus_coordinates.y & VIEWPORT_FOCUS_Y_MASK;
|
||||
newCoords.z = viewport_focus_coordinates.z;
|
||||
}
|
||||
|
||||
mainWindow = window_get_main();
|
||||
auto mainWindow = window_get_main();
|
||||
if (mainWindow != nullptr)
|
||||
window_scroll_to_location(mainWindow, newX, newY, newZ);
|
||||
window_scroll_to_location(mainWindow, newCoords);
|
||||
}
|
||||
|
||||
void rct_window::Invalidate()
|
||||
|
||||
@@ -975,7 +975,7 @@ void ride_construct(Ride* ride)
|
||||
|
||||
rct_window* w = window_get_main();
|
||||
if (w != nullptr && ride_modify(&trackElement))
|
||||
window_scroll_to_location(w, trackElement.x, trackElement.y, trackElement.element->GetBaseZ());
|
||||
window_scroll_to_location(w, { trackElement, trackElement.element->GetBaseZ() });
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -5032,7 +5032,7 @@ static void loc_6B51C0(const Ride* ride)
|
||||
if (ride->type != RIDE_TYPE_MAZE)
|
||||
{
|
||||
auto location = ride->stations[i].GetStart();
|
||||
window_scroll_to_location(w, location.x, location.y, location.z);
|
||||
window_scroll_to_location(w, location);
|
||||
|
||||
CoordsXYE trackElement;
|
||||
ride_try_get_origin_element(ride, &trackElement);
|
||||
@@ -5058,7 +5058,7 @@ static void ride_scroll_to_track_error(CoordsXYE* trackElement)
|
||||
rct_window* w = window_get_main();
|
||||
if (w != nullptr)
|
||||
{
|
||||
window_scroll_to_location(w, trackElement->x, trackElement->y, trackElement->element->GetBaseZ());
|
||||
window_scroll_to_location(w, { *trackElement, trackElement->element->GetBaseZ() });
|
||||
ride_modify(trackElement);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user