mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-17 20:13:07 +01:00
Add path edges and corner toggle to MP
This commit is contained in:
committed by
Michał Janiszewski
parent
577d1d1128
commit
31aa7f045a
@@ -755,6 +755,20 @@ static void window_tile_inspector_surface_toggle_diagonal()
|
||||
);
|
||||
}
|
||||
|
||||
static void window_tile_inspector_path_toggle_edge(sint32 element_index, sint32 corner_index)
|
||||
{
|
||||
assert(corner_index >= 0 && corner_index < 8);
|
||||
game_do_command(
|
||||
TILE_INSPECTOR_PATH_TOGGLE_EDGE,
|
||||
GAME_COMMAND_FLAG_APPLY,
|
||||
windowTileInspectorTileX | (windowTileInspectorTileY << 8),
|
||||
element_index,
|
||||
GAME_COMMAND_MODIFY_TILE,
|
||||
corner_index,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
// Copied from track.c (track_remove), and modified for raising/lowering
|
||||
// Not sure if this should be in this file, track.c, or maybe another one
|
||||
static void window_tile_inspector_track_block_height_offset(rct_map_element *mapElement, uint8 offset)
|
||||
@@ -1080,18 +1094,26 @@ static void window_tile_inspector_mouseup(rct_window *w, sint32 widgetIndex)
|
||||
case WIDX_PATH_CHECK_EDGE_S:
|
||||
case WIDX_PATH_CHECK_EDGE_W:
|
||||
case WIDX_PATH_CHECK_EDGE_N:
|
||||
widget_set_checkbox_value(w, widgetIndex, !widget_is_pressed(w, widgetIndex));
|
||||
mapElement->properties.path.edges ^= (1 << (4 + (((widgetIndex - WIDX_PATH_CHECK_EDGE_E) / 2 - get_current_rotation()) & 3))) & 0xF0;
|
||||
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
|
||||
{
|
||||
// 0 = east/right, 1 = south/bottom, 2 = west/left, 3 = north/top
|
||||
const sint32 eswn = (widgetIndex - WIDX_PATH_CHECK_EDGE_E) / 2;
|
||||
// Transform to world orientation
|
||||
const sint32 index = (4 + eswn - get_current_rotation()) & 3;
|
||||
window_tile_inspector_path_toggle_edge(w->selected_list_item, index + 4); // The corners are stored in the 4 most significant bits, hence the + 4
|
||||
break;
|
||||
}
|
||||
case WIDX_PATH_CHECK_EDGE_NE:
|
||||
case WIDX_PATH_CHECK_EDGE_SE:
|
||||
case WIDX_PATH_CHECK_EDGE_SW:
|
||||
case WIDX_PATH_CHECK_EDGE_NW:
|
||||
widget_set_checkbox_value(w, widgetIndex, !widget_is_pressed(w, widgetIndex));
|
||||
mapElement->properties.path.edges ^= (1 << (((widgetIndex - WIDX_PATH_CHECK_EDGE_NE) / 2 - get_current_rotation()) & 3)) & 0x0F;
|
||||
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
|
||||
{
|
||||
// 0 = NE, 1 = SE, 2 = SW, 3 = NW
|
||||
const sint32 neseswnw = (widgetIndex - WIDX_PATH_CHECK_EDGE_NE) / 2;
|
||||
// Transform to world orientation
|
||||
const sint32 index = (4 + neseswnw - get_current_rotation()) & 3;
|
||||
window_tile_inspector_path_toggle_edge(w->selected_list_item, index);
|
||||
break;
|
||||
}
|
||||
} // switch widget index
|
||||
break;
|
||||
|
||||
|
||||
@@ -5677,6 +5677,13 @@ void game_command_modify_tile(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx
|
||||
*ebx = tile_inspector_surface_toggle_diagonal(x, y, flags);
|
||||
return;
|
||||
}
|
||||
case TILE_INSPECTOR_PATH_TOGGLE_EDGE:
|
||||
{
|
||||
const sint32 element_index = *edx;
|
||||
const sint32 edge_index = *edi;
|
||||
*ebx = tile_inspector_path_toggle_edge(x, y, element_index, edge_index, flags);
|
||||
return;
|
||||
}
|
||||
default:
|
||||
log_error("invalid instruction");
|
||||
*ebx = MONEY32_UNDEFINED;
|
||||
|
||||
@@ -464,3 +464,23 @@ sint32 tile_inspector_surface_toggle_diagonal(sint32 x, sint32 y, sint32 flags)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sint32 tile_inspector_path_toggle_edge(sint32 x, sint32 y, sint32 element_index, sint32 edge_index, sint32 flags)
|
||||
{
|
||||
rct_map_element *const path_element = map_get_first_element_at(x, y) + element_index;
|
||||
|
||||
if (flags & GAME_COMMAND_FLAG_APPLY)
|
||||
{
|
||||
path_element->properties.path.edges ^= 1 << edge_index;
|
||||
|
||||
map_invalidate_tile_full(x << 5, y << 5);
|
||||
|
||||
rct_window *const tile_inspector_window = window_find_by_class(WC_TILE_INSPECTOR);
|
||||
if (tile_inspector_window != NULL && (uint32)x == windowTileInspectorTileX && (uint32)y == windowTileInspectorTileY)
|
||||
{
|
||||
window_invalidate(tile_inspector_window);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ typedef enum {
|
||||
TILE_INSPECTOR_SURFACE_SHOW_PARK_FENCES,
|
||||
TILE_INSPECTOR_SURFACE_TOGGLE_CORNER,
|
||||
TILE_INSPECTOR_SURFACE_TOGGLE_DIAGONAL,
|
||||
TILE_INSPECTOR_PATH_TOGGLE_EDGE,
|
||||
} tile_inspector_instruction;
|
||||
|
||||
sint32 tile_inspector_insert_corrupt_at(sint32 x, sint32 y, sint16 element_index, sint32 flags);
|
||||
@@ -55,3 +56,4 @@ sint32 tile_inspector_change_base_height_at(sint32 x, sint32 y, sint16 element_i
|
||||
sint32 tile_inspector_surface_show_park_fences(sint32 x, sint32 y, bool enabled, sint32 flags);
|
||||
sint32 tile_inspector_surface_toggle_corner(sint32 x, sint32 y, sint32 corner_index, sint32 flags);
|
||||
sint32 tile_inspector_surface_toggle_diagonal(sint32 x, sint32 y, sint32 flags);
|
||||
sint32 tile_inspector_path_toggle_edge(sint32 x, sint32 y, sint32 element_index, sint32 corner_index, sint32 flags);
|
||||
|
||||
Reference in New Issue
Block a user