mirror of https://github.com/OpenRCT2/OpenRCT2.git
Use ScreenCoordsXY on viewport interactions
This commit is contained in:
parent
dfe8335e91
commit
c91bdadb47
|
@ -352,7 +352,7 @@ static void game_handle_input_mouse(ScreenCoordsXY screenCoords, int32_t state)
|
||||||
if (_ticksSinceDragStart < 500)
|
if (_ticksSinceDragStart < 500)
|
||||||
{
|
{
|
||||||
// If the user pressed the right mouse button for less than 500 ticks, interpret as right click
|
// If the user pressed the right mouse button for less than 500 ticks, interpret as right click
|
||||||
viewport_interaction_right_click(screenCoords.x, screenCoords.y);
|
viewport_interaction_right_click(screenCoords);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -405,7 +405,7 @@ static void game_handle_input_mouse(ScreenCoordsXY screenCoords, int32_t state)
|
||||||
}
|
}
|
||||||
else if (!(_inputFlags & INPUT_FLAG_4))
|
else if (!(_inputFlags & INPUT_FLAG_4))
|
||||||
{
|
{
|
||||||
viewport_interaction_left_click(screenCoords.x, screenCoords.y);
|
viewport_interaction_left_click(screenCoords);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1108,7 +1108,7 @@ void process_mouse_over(ScreenCoordsXY screenCoords)
|
||||||
case WWT_VIEWPORT:
|
case WWT_VIEWPORT:
|
||||||
if (!(_inputFlags & INPUT_FLAG_TOOL_ACTIVE))
|
if (!(_inputFlags & INPUT_FLAG_TOOL_ACTIVE))
|
||||||
{
|
{
|
||||||
if (viewport_interaction_left_over(screenCoords.x, screenCoords.y))
|
if (viewport_interaction_left_over(screenCoords))
|
||||||
{
|
{
|
||||||
set_cursor(CURSOR_HAND_POINT);
|
set_cursor(CURSOR_HAND_POINT);
|
||||||
return;
|
return;
|
||||||
|
@ -1177,7 +1177,7 @@ void process_mouse_over(ScreenCoordsXY screenCoords)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
viewport_interaction_right_over(screenCoords.x, screenCoords.y);
|
viewport_interaction_right_over(screenCoords);
|
||||||
set_cursor(cursorId);
|
set_cursor(cursorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,13 +45,13 @@ static void viewport_interaction_remove_footpath_item(TileElement* tileElement,
|
||||||
static void viewport_interaction_remove_park_wall(TileElement* tileElement, int32_t x, int32_t y);
|
static void viewport_interaction_remove_park_wall(TileElement* tileElement, int32_t x, int32_t y);
|
||||||
static void viewport_interaction_remove_large_scenery(TileElement* tileElement, int32_t x, int32_t y);
|
static void viewport_interaction_remove_large_scenery(TileElement* tileElement, int32_t x, int32_t y);
|
||||||
static void viewport_interaction_remove_park_entrance(TileElement* tileElement, int32_t x, int32_t y);
|
static void viewport_interaction_remove_park_entrance(TileElement* tileElement, int32_t x, int32_t y);
|
||||||
static Peep* viewport_interaction_get_closest_peep(int32_t x, int32_t y, int32_t maxDistance);
|
static Peep* viewport_interaction_get_closest_peep(ScreenCoordsXY screenCoords, int32_t maxDistance);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* rct2: 0x006ED9D0
|
* rct2: 0x006ED9D0
|
||||||
*/
|
*/
|
||||||
int32_t viewport_interaction_get_item_left(int32_t x, int32_t y, viewport_interaction_info* info)
|
int32_t viewport_interaction_get_item_left(ScreenCoordsXY screenCoords, viewport_interaction_info* info)
|
||||||
{
|
{
|
||||||
TileElement* tileElement;
|
TileElement* tileElement;
|
||||||
rct_sprite* sprite;
|
rct_sprite* sprite;
|
||||||
|
@ -65,10 +65,10 @@ int32_t viewport_interaction_get_item_left(int32_t x, int32_t y, viewport_intera
|
||||||
if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gS6Info.editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER)
|
if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gS6Info.editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER)
|
||||||
return info->type = VIEWPORT_INTERACTION_ITEM_NONE;
|
return info->type = VIEWPORT_INTERACTION_ITEM_NONE;
|
||||||
|
|
||||||
LocationXY16 mapCoord = {};
|
CoordsXY mapCoord = {};
|
||||||
get_map_coordinates_from_pos(
|
get_map_coordinates_from_pos(
|
||||||
x, y, VIEWPORT_INTERACTION_MASK_SPRITE & VIEWPORT_INTERACTION_MASK_RIDE & VIEWPORT_INTERACTION_MASK_PARK, &mapCoord.x,
|
screenCoords, VIEWPORT_INTERACTION_MASK_SPRITE & VIEWPORT_INTERACTION_MASK_RIDE & VIEWPORT_INTERACTION_MASK_PARK,
|
||||||
&mapCoord.y, &info->type, &info->tileElement, nullptr);
|
mapCoord, &info->type, &info->tileElement, nullptr);
|
||||||
info->x = mapCoord.x;
|
info->x = mapCoord.x;
|
||||||
info->y = mapCoord.y;
|
info->y = mapCoord.y;
|
||||||
tileElement = info->tileElement;
|
tileElement = info->tileElement;
|
||||||
|
@ -111,7 +111,7 @@ int32_t viewport_interaction_get_item_left(int32_t x, int32_t y, viewport_intera
|
||||||
// If nothing is under cursor, find a close by peep
|
// If nothing is under cursor, find a close by peep
|
||||||
if (info->type == VIEWPORT_INTERACTION_ITEM_NONE)
|
if (info->type == VIEWPORT_INTERACTION_ITEM_NONE)
|
||||||
{
|
{
|
||||||
info->peep = viewport_interaction_get_closest_peep(x, y, 32);
|
info->peep = viewport_interaction_get_closest_peep(screenCoords, 32);
|
||||||
if (info->peep == nullptr)
|
if (info->peep == nullptr)
|
||||||
return VIEWPORT_INTERACTION_ITEM_NONE;
|
return VIEWPORT_INTERACTION_ITEM_NONE;
|
||||||
|
|
||||||
|
@ -124,11 +124,11 @@ int32_t viewport_interaction_get_item_left(int32_t x, int32_t y, viewport_intera
|
||||||
return info->type;
|
return info->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t viewport_interaction_left_over(int32_t x, int32_t y)
|
int32_t viewport_interaction_left_over(ScreenCoordsXY screenCoords)
|
||||||
{
|
{
|
||||||
viewport_interaction_info info;
|
viewport_interaction_info info;
|
||||||
|
|
||||||
switch (viewport_interaction_get_item_left(x, y, &info))
|
switch (viewport_interaction_get_item_left(screenCoords, &info))
|
||||||
{
|
{
|
||||||
case VIEWPORT_INTERACTION_ITEM_SPRITE:
|
case VIEWPORT_INTERACTION_ITEM_SPRITE:
|
||||||
case VIEWPORT_INTERACTION_ITEM_RIDE:
|
case VIEWPORT_INTERACTION_ITEM_RIDE:
|
||||||
|
@ -139,11 +139,11 @@ int32_t viewport_interaction_left_over(int32_t x, int32_t y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t viewport_interaction_left_click(int32_t x, int32_t y)
|
int32_t viewport_interaction_left_click(ScreenCoordsXY screenCoords)
|
||||||
{
|
{
|
||||||
viewport_interaction_info info;
|
viewport_interaction_info info;
|
||||||
|
|
||||||
switch (viewport_interaction_get_item_left(x, y, &info))
|
switch (viewport_interaction_get_item_left(screenCoords, &info))
|
||||||
{
|
{
|
||||||
case VIEWPORT_INTERACTION_ITEM_SPRITE:
|
case VIEWPORT_INTERACTION_ITEM_SPRITE:
|
||||||
switch (info.sprite->generic.sprite_identifier)
|
switch (info.sprite->generic.sprite_identifier)
|
||||||
|
@ -200,7 +200,7 @@ int32_t viewport_interaction_left_click(int32_t x, int32_t y)
|
||||||
*
|
*
|
||||||
* rct2: 0x006EDE88
|
* rct2: 0x006EDE88
|
||||||
*/
|
*/
|
||||||
int32_t viewport_interaction_get_item_right(int32_t x, int32_t y, viewport_interaction_info* info)
|
int32_t viewport_interaction_get_item_right(ScreenCoordsXY screenCoords, viewport_interaction_info* info)
|
||||||
{
|
{
|
||||||
TileElement* tileElement;
|
TileElement* tileElement;
|
||||||
rct_scenery_entry* sceneryEntry;
|
rct_scenery_entry* sceneryEntry;
|
||||||
|
@ -215,9 +215,9 @@ int32_t viewport_interaction_get_item_right(int32_t x, int32_t y, viewport_inter
|
||||||
if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gS6Info.editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER)
|
if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gS6Info.editor_step != EDITOR_STEP_ROLLERCOASTER_DESIGNER)
|
||||||
return info->type = VIEWPORT_INTERACTION_ITEM_NONE;
|
return info->type = VIEWPORT_INTERACTION_ITEM_NONE;
|
||||||
|
|
||||||
LocationXY16 mapCoord = {};
|
CoordsXY mapCoord = {};
|
||||||
get_map_coordinates_from_pos(
|
get_map_coordinates_from_pos(
|
||||||
x, y, ~(VIEWPORT_INTERACTION_MASK_TERRAIN & VIEWPORT_INTERACTION_MASK_WATER), &mapCoord.x, &mapCoord.y, &info->type,
|
screenCoords, ~(VIEWPORT_INTERACTION_MASK_TERRAIN & VIEWPORT_INTERACTION_MASK_WATER), mapCoord, &info->type,
|
||||||
&info->tileElement, nullptr);
|
&info->tileElement, nullptr);
|
||||||
info->x = mapCoord.x;
|
info->x = mapCoord.x;
|
||||||
info->y = mapCoord.y;
|
info->y = mapCoord.y;
|
||||||
|
@ -435,23 +435,23 @@ int32_t viewport_interaction_get_item_right(int32_t x, int32_t y, viewport_inter
|
||||||
return info->type = VIEWPORT_INTERACTION_ITEM_NONE;
|
return info->type = VIEWPORT_INTERACTION_ITEM_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t viewport_interaction_right_over(int32_t x, int32_t y)
|
int32_t viewport_interaction_right_over(ScreenCoordsXY screenCoords)
|
||||||
{
|
{
|
||||||
viewport_interaction_info info;
|
viewport_interaction_info info;
|
||||||
|
|
||||||
return viewport_interaction_get_item_right(x, y, &info) != 0;
|
return viewport_interaction_get_item_right(screenCoords, &info) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* rct2: 0x006E8A62
|
* rct2: 0x006E8A62
|
||||||
*/
|
*/
|
||||||
int32_t viewport_interaction_right_click(int32_t x, int32_t y)
|
int32_t viewport_interaction_right_click(ScreenCoordsXY screenCoords)
|
||||||
{
|
{
|
||||||
CoordsXYE tileElement;
|
CoordsXYE tileElement;
|
||||||
viewport_interaction_info info;
|
viewport_interaction_info info;
|
||||||
|
|
||||||
switch (viewport_interaction_get_item_right(x, y, &info))
|
switch (viewport_interaction_get_item_right(screenCoords, &info))
|
||||||
{
|
{
|
||||||
case VIEWPORT_INTERACTION_ITEM_NONE:
|
case VIEWPORT_INTERACTION_ITEM_NONE:
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -613,7 +613,7 @@ static void viewport_interaction_remove_large_scenery(TileElement* tileElement,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Peep* viewport_interaction_get_closest_peep(int32_t x, int32_t y, int32_t maxDistance)
|
static Peep* viewport_interaction_get_closest_peep(ScreenCoordsXY screenCoords, int32_t maxDistance)
|
||||||
{
|
{
|
||||||
int32_t distance, closestDistance;
|
int32_t distance, closestDistance;
|
||||||
uint16_t spriteIndex;
|
uint16_t spriteIndex;
|
||||||
|
@ -621,7 +621,7 @@ static Peep* viewport_interaction_get_closest_peep(int32_t x, int32_t y, int32_t
|
||||||
rct_viewport* viewport;
|
rct_viewport* viewport;
|
||||||
Peep *peep, *closestPeep;
|
Peep *peep, *closestPeep;
|
||||||
|
|
||||||
w = window_find_from_point(ScreenCoordsXY(x, y));
|
w = window_find_from_point(screenCoords);
|
||||||
if (w == nullptr)
|
if (w == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -629,8 +629,8 @@ static Peep* viewport_interaction_get_closest_peep(int32_t x, int32_t y, int32_t
|
||||||
if (viewport == nullptr || viewport->zoom >= 2)
|
if (viewport == nullptr || viewport->zoom >= 2)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
x = ((x - viewport->x) << viewport->zoom) + viewport->view_x;
|
screenCoords.x = ((screenCoords.x - viewport->x) << viewport->zoom) + viewport->view_x;
|
||||||
y = ((y - viewport->y) << viewport->zoom) + viewport->view_y;
|
screenCoords.y = ((screenCoords.y - viewport->y) << viewport->zoom) + viewport->view_y;
|
||||||
|
|
||||||
closestPeep = nullptr;
|
closestPeep = nullptr;
|
||||||
closestDistance = 0xFFFF;
|
closestDistance = 0xFFFF;
|
||||||
|
@ -639,8 +639,8 @@ static Peep* viewport_interaction_get_closest_peep(int32_t x, int32_t y, int32_t
|
||||||
if (peep->sprite_left == LOCATION_NULL)
|
if (peep->sprite_left == LOCATION_NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
distance = abs(((peep->sprite_left + peep->sprite_right) / 2) - x)
|
distance = abs(((peep->sprite_left + peep->sprite_right) / 2) - screenCoords.x)
|
||||||
+ abs(((peep->sprite_top + peep->sprite_bottom) / 2) - y);
|
+ abs(((peep->sprite_top + peep->sprite_bottom) / 2) - screenCoords.y);
|
||||||
if (distance > maxDistance)
|
if (distance > maxDistance)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -612,7 +612,7 @@ static void window_title_command_editor_update(rct_window* w)
|
||||||
static void window_title_command_editor_tool_down(rct_window* w, rct_widgetindex widgetIndex, ScreenCoordsXY screenCoords)
|
static void window_title_command_editor_tool_down(rct_window* w, rct_widgetindex widgetIndex, ScreenCoordsXY screenCoords)
|
||||||
{
|
{
|
||||||
viewport_interaction_info info;
|
viewport_interaction_info info;
|
||||||
viewport_interaction_get_item_left(screenCoords.x, screenCoords.y, &info);
|
viewport_interaction_get_item_left(screenCoords, &info);
|
||||||
|
|
||||||
if (info.type == VIEWPORT_INTERACTION_ITEM_SPRITE)
|
if (info.type == VIEWPORT_INTERACTION_ITEM_SPRITE)
|
||||||
{
|
{
|
||||||
|
|
|
@ -162,12 +162,12 @@ void get_map_coordinates_from_pos_window(
|
||||||
rct_window* window, ScreenCoordsXY screenCoords, int32_t flags, CoordsXY& mapCoords, int32_t* interactionType,
|
rct_window* window, ScreenCoordsXY screenCoords, int32_t flags, CoordsXY& mapCoords, int32_t* interactionType,
|
||||||
TileElement** tileElement, rct_viewport** viewport);
|
TileElement** tileElement, rct_viewport** viewport);
|
||||||
|
|
||||||
int32_t viewport_interaction_get_item_left(int32_t x, int32_t y, viewport_interaction_info* info);
|
int32_t viewport_interaction_get_item_left(ScreenCoordsXY screenCoords, viewport_interaction_info* info);
|
||||||
int32_t viewport_interaction_left_over(int32_t x, int32_t y);
|
int32_t viewport_interaction_left_over(ScreenCoordsXY screenCoords);
|
||||||
int32_t viewport_interaction_left_click(int32_t x, int32_t y);
|
int32_t viewport_interaction_left_click(ScreenCoordsXY screenCoords);
|
||||||
int32_t viewport_interaction_get_item_right(int32_t x, int32_t y, viewport_interaction_info* info);
|
int32_t viewport_interaction_get_item_right(ScreenCoordsXY screenCoords, viewport_interaction_info* info);
|
||||||
int32_t viewport_interaction_right_over(int32_t x, int32_t y);
|
int32_t viewport_interaction_right_over(ScreenCoordsXY screenCoords);
|
||||||
int32_t viewport_interaction_right_click(int32_t x, int32_t y);
|
int32_t viewport_interaction_right_click(ScreenCoordsXY screenCoords);
|
||||||
|
|
||||||
CoordsXY sub_68A15E(ScreenCoordsXY screenCoords);
|
CoordsXY sub_68A15E(ScreenCoordsXY screenCoords);
|
||||||
void sub_68B2B7(paint_session* session, CoordsXY mapCoords);
|
void sub_68B2B7(paint_session* session, CoordsXY mapCoords);
|
||||||
|
|
Loading…
Reference in New Issue