mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-20 06:12:57 +01:00
Add Ctrl + Click to select tile elements
Co-authored-by: wolfreak99 <jbminor1991@gmail.com>
This commit is contained in:
@@ -40,6 +40,7 @@
|
|||||||
- Improved: [#7435] Object indexing now supports multi-threading.
|
- Improved: [#7435] Object indexing now supports multi-threading.
|
||||||
- Improved: [#7510] Add horizontal clipping to cut-away view options.
|
- Improved: [#7510] Add horizontal clipping to cut-away view options.
|
||||||
- Improved: [#7531] "Save track design" dropdown now stays open.
|
- Improved: [#7531] "Save track design" dropdown now stays open.
|
||||||
|
- Improved: [#7548] Ctrl-clicking with the tile inspector open now directly selects an element and its tile.
|
||||||
|
|
||||||
0.1.2 (2018-03-18)
|
0.1.2 (2018-03-18)
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -464,10 +464,17 @@ static struct {
|
|||||||
{ COR_GBDT, COR_GBDB, COR_GBPT, COR_GBPB, STR_TILE_INSPECTOR_GROUPBOX_CORRUPT_INFO }
|
{ COR_GBDT, COR_GBDB, COR_GBPT, COR_GBPB, STR_TILE_INSPECTOR_GROUPBOX_CORRUPT_INFO }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// clang-format on
|
||||||
|
static constexpr sint32 ViewportInteractionFlags = VIEWPORT_INTERACTION_MASK_TERRAIN & VIEWPORT_INTERACTION_MASK_SPRITE
|
||||||
|
& VIEWPORT_INTERACTION_MASK_RIDE & VIEWPORT_INTERACTION_MASK_SCENERY & VIEWPORT_INTERACTION_MASK_FOOTPATH
|
||||||
|
& VIEWPORT_INTERACTION_MASK_FOOTPATH_ITEM & VIEWPORT_INTERACTION_MASK_PARK & VIEWPORT_INTERACTION_MASK_WALL
|
||||||
|
& VIEWPORT_INTERACTION_MASK_LARGE_SCENERY & VIEWPORT_INTERACTION_MASK_BANNER;
|
||||||
|
|
||||||
static sint16 windowTileInspectorHighlightedIndex = -1;
|
static sint16 windowTileInspectorHighlightedIndex = -1;
|
||||||
static bool windowTileInspectorTileSelected = false;
|
static bool windowTileInspectorTileSelected = false;
|
||||||
static sint32 windowTileInspectorToolMouseX = 0;
|
static sint32 windowTileInspectorToolMouseX = 0;
|
||||||
static sint32 windowTileInspectorToolMouseY = 0;
|
static sint32 windowTileInspectorToolMouseY = 0;
|
||||||
|
static bool windowTileInspectorToolCtrlDown = false;
|
||||||
static sint32 windowTileInspectorToolMapX = 0;
|
static sint32 windowTileInspectorToolMapX = 0;
|
||||||
static sint32 windowTileInspectorToolMapY = 0;
|
static sint32 windowTileInspectorToolMapY = 0;
|
||||||
static bool windowTileInspectorApplyToAll = false;
|
static bool windowTileInspectorApplyToAll = false;
|
||||||
@@ -490,6 +497,7 @@ static void window_tile_inspector_invalidate(rct_window *w);
|
|||||||
static void window_tile_inspector_paint(rct_window *w, rct_drawpixelinfo *dpi);
|
static void window_tile_inspector_paint(rct_window *w, rct_drawpixelinfo *dpi);
|
||||||
static void window_tile_inspector_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, sint32 scrollIndex);
|
static void window_tile_inspector_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, sint32 scrollIndex);
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
static rct_window_event_list TileInspectorWindowEvents = {
|
static rct_window_event_list TileInspectorWindowEvents = {
|
||||||
nullptr,
|
nullptr,
|
||||||
window_tile_inspector_mouseup,
|
window_tile_inspector_mouseup,
|
||||||
@@ -608,20 +616,25 @@ static void window_tile_inspector_select_element_from_list(rct_window *w, sint32
|
|||||||
window_invalidate(w);
|
window_invalidate(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void window_tile_inspector_load_tile(rct_window* w)
|
static void window_tile_inspector_load_tile(rct_window* w, rct_tile_element* elementToSelect)
|
||||||
{
|
{
|
||||||
rct_tile_element *element = map_get_first_element_at(windowTileInspectorTileX, windowTileInspectorTileY);
|
w->selected_list_item = -1;
|
||||||
sint32 numItems = 0;
|
w->scrolls[0].v_top = 0;
|
||||||
do {
|
|
||||||
|
rct_tile_element* element = map_get_first_element_at(windowTileInspectorTileX, windowTileInspectorTileY);
|
||||||
|
sint16 numItems = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (element == elementToSelect)
|
||||||
|
{
|
||||||
|
w->selected_list_item = numItems;
|
||||||
|
}
|
||||||
|
|
||||||
numItems++;
|
numItems++;
|
||||||
} while (!tile_element_is_last_for_tile(element++));
|
} while (!tile_element_is_last_for_tile(element++));
|
||||||
|
|
||||||
windowTileInspectorElementCount = numItems;
|
windowTileInspectorElementCount = numItems;
|
||||||
|
|
||||||
// Clear selection
|
|
||||||
w->selected_list_item = -1;
|
|
||||||
|
|
||||||
w->scrolls[0].v_top = 0;
|
|
||||||
window_invalidate(w);
|
window_invalidate(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -934,19 +947,19 @@ static void window_tile_inspector_mouseup(rct_window *w, rct_widgetindex widgetI
|
|||||||
break;
|
break;
|
||||||
case WIDX_SPINNER_X_INCREASE:
|
case WIDX_SPINNER_X_INCREASE:
|
||||||
windowTileInspectorTileX = Math::Min<uint32>(windowTileInspectorTileX + 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1);
|
windowTileInspectorTileX = Math::Min<uint32>(windowTileInspectorTileX + 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1);
|
||||||
window_tile_inspector_load_tile(w);
|
window_tile_inspector_load_tile(w, nullptr);
|
||||||
break;
|
break;
|
||||||
case WIDX_SPINNER_X_DECREASE:
|
case WIDX_SPINNER_X_DECREASE:
|
||||||
windowTileInspectorTileX = Math::Max<uint32>(windowTileInspectorTileX - 1, 0);
|
windowTileInspectorTileX = Math::Max<uint32>(windowTileInspectorTileX - 1, 0);
|
||||||
window_tile_inspector_load_tile(w);
|
window_tile_inspector_load_tile(w, nullptr);
|
||||||
break;
|
break;
|
||||||
case WIDX_SPINNER_Y_INCREASE:
|
case WIDX_SPINNER_Y_INCREASE:
|
||||||
windowTileInspectorTileY = Math::Min<uint32>(windowTileInspectorTileY + 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1);
|
windowTileInspectorTileY = Math::Min<uint32>(windowTileInspectorTileY + 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1);
|
||||||
window_tile_inspector_load_tile(w);
|
window_tile_inspector_load_tile(w, nullptr);
|
||||||
break;
|
break;
|
||||||
case WIDX_SPINNER_Y_DECREASE:
|
case WIDX_SPINNER_Y_DECREASE:
|
||||||
windowTileInspectorTileY = Math::Max<uint32>(windowTileInspectorTileY - 1, 0);
|
windowTileInspectorTileY = Math::Max<uint32>(windowTileInspectorTileY - 1, 0);
|
||||||
window_tile_inspector_load_tile(w);
|
window_tile_inspector_load_tile(w, nullptr);
|
||||||
break;
|
break;
|
||||||
case WIDX_BUTTON_CORRUPT:
|
case WIDX_BUTTON_CORRUPT:
|
||||||
window_tile_inspector_insert_corrupt_element(w->selected_list_item);
|
window_tile_inspector_insert_corrupt_element(w->selected_list_item);
|
||||||
@@ -1267,17 +1280,30 @@ static void window_tile_inspector_tool_update(rct_window* w, rct_widgetindex wid
|
|||||||
|
|
||||||
sint16 mapX = x;
|
sint16 mapX = x;
|
||||||
sint16 mapY = y;
|
sint16 mapY = y;
|
||||||
sint32 direction;
|
rct_tile_element* clickedElement = nullptr;
|
||||||
screen_pos_to_map_pos(&mapX, &mapY, &direction);
|
if (input_test_place_object_modifier(PLACE_OBJECT_MODIFIER_COPY_Z))
|
||||||
if (mapX != LOCATION_NULL) {
|
{
|
||||||
|
get_map_coordinates_from_pos(x, y, ViewportInteractionFlags, &mapX, &mapY, nullptr, &clickedElement, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Even if Ctrl was pressed, fall back to normal selection when there was nothing under the cursor
|
||||||
|
if (clickedElement == nullptr)
|
||||||
|
{
|
||||||
|
screen_pos_to_map_pos(&mapX, &mapY, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mapX != LOCATION_NULL)
|
||||||
|
{
|
||||||
gMapSelectPositionA.x = gMapSelectPositionB.x = mapX;
|
gMapSelectPositionA.x = gMapSelectPositionB.x = mapX;
|
||||||
gMapSelectPositionA.y = gMapSelectPositionB.y = mapY;
|
gMapSelectPositionA.y = gMapSelectPositionB.y = mapY;
|
||||||
}
|
}
|
||||||
else if (windowTileInspectorTileSelected){
|
else if (windowTileInspectorTileSelected)
|
||||||
|
{
|
||||||
gMapSelectPositionA.x = gMapSelectPositionB.x = windowTileInspectorTileX << 5;
|
gMapSelectPositionA.x = gMapSelectPositionB.x = windowTileInspectorTileX << 5;
|
||||||
gMapSelectPositionA.y = gMapSelectPositionB.y = windowTileInspectorTileY << 5;
|
gMapSelectPositionA.y = gMapSelectPositionB.y = windowTileInspectorTileY << 5;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
|
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1285,26 +1311,44 @@ static void window_tile_inspector_tool_update(rct_window* w, rct_widgetindex wid
|
|||||||
map_invalidate_selection_rect();
|
map_invalidate_selection_rect();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void window_tile_inspector_update_selected_tile(rct_window *w, sint32 x, sint32 y)
|
static void window_tile_inspector_update_selected_tile(rct_window* w, sint32 x, sint32 y)
|
||||||
{
|
{
|
||||||
|
const bool ctrlIsHeldDown = input_test_place_object_modifier(PLACE_OBJECT_MODIFIER_COPY_Z);
|
||||||
|
|
||||||
// Mouse hasn't moved
|
// Mouse hasn't moved
|
||||||
if (x == windowTileInspectorToolMouseX && y == windowTileInspectorToolMouseY) {
|
if (x == windowTileInspectorToolMouseX && y == windowTileInspectorToolMouseY
|
||||||
|
&& windowTileInspectorToolCtrlDown == ctrlIsHeldDown)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
windowTileInspectorToolMouseX = x;
|
windowTileInspectorToolMouseX = x;
|
||||||
windowTileInspectorToolMouseY = y;
|
windowTileInspectorToolMouseY = y;
|
||||||
|
windowTileInspectorToolCtrlDown = ctrlIsHeldDown;
|
||||||
|
|
||||||
sint16 mapX = x;
|
sint16 mapX = x;
|
||||||
sint16 mapY = y;
|
sint16 mapY = y;
|
||||||
sint32 direction;
|
rct_tile_element* clickedElement = nullptr;
|
||||||
screen_pos_to_map_pos(&mapX, &mapY, &direction);
|
if (ctrlIsHeldDown)
|
||||||
if (mapX == LOCATION_NULL) {
|
{
|
||||||
return;
|
get_map_coordinates_from_pos(x, y, ViewportInteractionFlags, &mapX, &mapY, nullptr, &clickedElement, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tile is already selected
|
// Even if Ctrl was pressed, fall back to normal selection when there was nothing under the cursor
|
||||||
if (windowTileInspectorTileSelected && mapX == windowTileInspectorToolMapX && mapY == windowTileInspectorToolMapY) {
|
if (clickedElement == nullptr)
|
||||||
return;
|
{
|
||||||
|
screen_pos_to_map_pos(&mapX, &mapY, nullptr);
|
||||||
|
|
||||||
|
if (mapX == LOCATION_NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tile is already selected
|
||||||
|
if (windowTileInspectorTileSelected && mapX == windowTileInspectorToolMapX && mapY == windowTileInspectorToolMapY)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
windowTileInspectorTileSelected = true;
|
windowTileInspectorTileSelected = true;
|
||||||
@@ -1313,7 +1357,7 @@ static void window_tile_inspector_update_selected_tile(rct_window *w, sint32 x,
|
|||||||
windowTileInspectorTileX = mapX >> 5;
|
windowTileInspectorTileX = mapX >> 5;
|
||||||
windowTileInspectorTileY = mapY >> 5;
|
windowTileInspectorTileY = mapY >> 5;
|
||||||
|
|
||||||
window_tile_inspector_load_tile(w);
|
window_tile_inspector_load_tile(w, clickedElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void window_tile_inspector_tool_down(rct_window* w, rct_widgetindex widgetIndex, sint32 x, sint32 y)
|
static void window_tile_inspector_tool_down(rct_window* w, rct_widgetindex widgetIndex, sint32 x, sint32 y)
|
||||||
|
|||||||
Reference in New Issue
Block a user