mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-24 15:24:30 +01:00
Change base height
This commit is contained in:
committed by
Michał Janiszewski
parent
d57f73673a
commit
efd9fce064
@@ -703,6 +703,19 @@ static void window_tile_inspector_paste_element(rct_window *w)
|
||||
);
|
||||
}
|
||||
|
||||
static void window_tile_inspector_base_height_offset(sint16 element_index, sint8 offset)
|
||||
{
|
||||
game_do_command(
|
||||
TILE_INSPECTOR_ANY_BASE_HEIGHT_OFFSET,
|
||||
GAME_COMMAND_FLAG_APPLY,
|
||||
windowTileInspectorTileX | (windowTileInspectorTileY << 8),
|
||||
element_index,
|
||||
GAME_COMMAND_MODIFY_TILE,
|
||||
offset,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
static void window_tile_inspector_surface_toggle_corner(rct_map_element *mapElement, sint32 cornerIndex)
|
||||
{
|
||||
const uint8 originalSlope = mapElement->properties.surface.slope;
|
||||
@@ -1025,16 +1038,10 @@ static void window_tile_inspector_mouseup(rct_window *w, sint32 widgetIndex)
|
||||
case PAGE_SURFACE:
|
||||
switch (widgetIndex) {
|
||||
case WIDX_SURFACE_SPINNER_HEIGHT_INCREASE:
|
||||
mapElement->base_height++;
|
||||
mapElement->clearance_height++;
|
||||
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
|
||||
widget_invalidate(w, WIDX_PATH_SPINNER_HEIGHT);
|
||||
window_tile_inspector_base_height_offset(w->selected_list_item, 1);
|
||||
break;
|
||||
case WIDX_SURFACE_SPINNER_HEIGHT_DECREASE:
|
||||
mapElement->base_height--;
|
||||
mapElement->clearance_height--;
|
||||
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
|
||||
widget_invalidate(w, WIDX_PATH_SPINNER_HEIGHT);
|
||||
window_tile_inspector_base_height_offset(w->selected_list_item, -1);
|
||||
break;
|
||||
case WIDX_SURFACE_BUTTON_REMOVE_FENCES:
|
||||
mapElement->properties.surface.ownership &= ~0x0F;
|
||||
@@ -1073,16 +1080,10 @@ static void window_tile_inspector_mouseup(rct_window *w, sint32 widgetIndex)
|
||||
case PAGE_PATH:
|
||||
switch (widgetIndex) {
|
||||
case WIDX_PATH_SPINNER_HEIGHT_INCREASE:
|
||||
mapElement->base_height++;
|
||||
mapElement->clearance_height++;
|
||||
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
|
||||
widget_invalidate(w, WIDX_PATH_SPINNER_HEIGHT);
|
||||
window_tile_inspector_base_height_offset(w->selected_list_item, 1);
|
||||
break;
|
||||
case WIDX_PATH_SPINNER_HEIGHT_DECREASE:
|
||||
mapElement->base_height--;
|
||||
mapElement->clearance_height--;
|
||||
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
|
||||
widget_invalidate(w, WIDX_PATH_SPINNER_HEIGHT);
|
||||
window_tile_inspector_base_height_offset(w->selected_list_item, -1);
|
||||
break;
|
||||
case WIDX_PATH_CHECK_EDGE_E:
|
||||
case WIDX_PATH_CHECK_EDGE_S:
|
||||
@@ -1114,9 +1115,7 @@ static void window_tile_inspector_mouseup(rct_window *w, sint32 widgetIndex)
|
||||
window_tile_inspector_track_block_height_offset(mapElement, 1);
|
||||
}
|
||||
else {
|
||||
mapElement->base_height++;
|
||||
mapElement->clearance_height++;
|
||||
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
|
||||
window_tile_inspector_base_height_offset(w->selected_list_item, 1);
|
||||
}
|
||||
widget_invalidate(w, WIDX_TRACK_SPINNER_HEIGHT);
|
||||
break;
|
||||
@@ -1125,9 +1124,7 @@ static void window_tile_inspector_mouseup(rct_window *w, sint32 widgetIndex)
|
||||
window_tile_inspector_track_block_height_offset(mapElement, -1);
|
||||
}
|
||||
else {
|
||||
mapElement->base_height--;
|
||||
mapElement->clearance_height--;
|
||||
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
|
||||
window_tile_inspector_base_height_offset(w->selected_list_item, -1);
|
||||
}
|
||||
widget_invalidate(w, WIDX_TRACK_SPINNER_HEIGHT);
|
||||
break;
|
||||
@@ -1148,16 +1145,10 @@ static void window_tile_inspector_mouseup(rct_window *w, sint32 widgetIndex)
|
||||
case PAGE_SCENERY:
|
||||
switch (widgetIndex) {
|
||||
case WIDX_SCENERY_SPINNER_HEIGHT_INCREASE:
|
||||
mapElement->base_height++;
|
||||
mapElement->clearance_height++;
|
||||
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
|
||||
widget_invalidate(w, WIDX_SCENERY_SPINNER_HEIGHT);
|
||||
window_tile_inspector_base_height_offset(w->selected_list_item, 1);
|
||||
break;
|
||||
case WIDX_SCENERY_SPINNER_HEIGHT_DECREASE:
|
||||
mapElement->base_height--;
|
||||
mapElement->clearance_height--;
|
||||
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
|
||||
widget_invalidate(w, WIDX_SCENERY_SPINNER_HEIGHT);
|
||||
window_tile_inspector_base_height_offset(w->selected_list_item, -1);
|
||||
break;
|
||||
case WIDX_SCENERY_CHECK_QUARTER_N:
|
||||
case WIDX_SCENERY_CHECK_QUARTER_E:
|
||||
@@ -1179,16 +1170,10 @@ static void window_tile_inspector_mouseup(rct_window *w, sint32 widgetIndex)
|
||||
case PAGE_ENTRANCE:
|
||||
switch (widgetIndex) {
|
||||
case WIDX_ENTRANCE_SPINNER_HEIGHT_INCREASE:
|
||||
mapElement->base_height++;
|
||||
mapElement->clearance_height++;
|
||||
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
|
||||
widget_invalidate(w, WIDX_FENCE_SPINNER_HEIGHT);
|
||||
window_tile_inspector_base_height_offset(w->selected_list_item, 1);
|
||||
break;
|
||||
case WIDX_ENTRANCE_SPINNER_HEIGHT_DECREASE:
|
||||
mapElement->base_height--;
|
||||
mapElement->clearance_height--;
|
||||
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
|
||||
widget_invalidate(w, WIDX_FENCE_SPINNER_HEIGHT);
|
||||
window_tile_inspector_base_height_offset(w->selected_list_item, -1);
|
||||
break;
|
||||
} // switch widget index
|
||||
break;
|
||||
@@ -1196,16 +1181,10 @@ static void window_tile_inspector_mouseup(rct_window *w, sint32 widgetIndex)
|
||||
case PAGE_FENCE:
|
||||
switch (widgetIndex) {
|
||||
case WIDX_FENCE_SPINNER_HEIGHT_INCREASE:
|
||||
mapElement->base_height++;
|
||||
mapElement->clearance_height++;
|
||||
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
|
||||
widget_invalidate(w, WIDX_FENCE_SPINNER_HEIGHT);
|
||||
window_tile_inspector_base_height_offset(w->selected_list_item, 1);
|
||||
break;
|
||||
case WIDX_FENCE_SPINNER_HEIGHT_DECREASE:
|
||||
mapElement->base_height--;
|
||||
mapElement->clearance_height--;
|
||||
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
|
||||
widget_invalidate(w, WIDX_FENCE_SPINNER_HEIGHT);
|
||||
window_tile_inspector_base_height_offset(w->selected_list_item, -1);
|
||||
break;
|
||||
} // switch widget index
|
||||
break;
|
||||
@@ -1213,16 +1192,10 @@ static void window_tile_inspector_mouseup(rct_window *w, sint32 widgetIndex)
|
||||
case PAGE_LARGE_SCENERY:
|
||||
switch (widgetIndex) {
|
||||
case WIDX_LARGE_SCENERY_SPINNER_HEIGHT_INCREASE:
|
||||
mapElement->base_height++;
|
||||
mapElement->clearance_height++;
|
||||
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
|
||||
widget_invalidate(w, WIDX_FENCE_SPINNER_HEIGHT);
|
||||
window_tile_inspector_base_height_offset(w->selected_list_item, 1);
|
||||
break;
|
||||
case WIDX_LARGE_SCENERY_SPINNER_HEIGHT_DECREASE:
|
||||
mapElement->base_height--;
|
||||
mapElement->clearance_height--;
|
||||
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
|
||||
widget_invalidate(w, WIDX_FENCE_SPINNER_HEIGHT);
|
||||
window_tile_inspector_base_height_offset(w->selected_list_item, -1);
|
||||
break;
|
||||
} // switch widget index
|
||||
break;
|
||||
@@ -1230,16 +1203,10 @@ static void window_tile_inspector_mouseup(rct_window *w, sint32 widgetIndex)
|
||||
case PAGE_BANNER:
|
||||
switch (widgetIndex) {
|
||||
case WIDX_BANNER_SPINNER_HEIGHT_INCREASE:
|
||||
mapElement->base_height++;
|
||||
mapElement->clearance_height++;
|
||||
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
|
||||
widget_invalidate(w, WIDX_FENCE_SPINNER_HEIGHT);
|
||||
window_tile_inspector_base_height_offset(w->selected_list_item, 1);
|
||||
break;
|
||||
case WIDX_BANNER_SPINNER_HEIGHT_DECREASE:
|
||||
mapElement->base_height--;
|
||||
mapElement->clearance_height--;
|
||||
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
|
||||
widget_invalidate(w, WIDX_FENCE_SPINNER_HEIGHT);
|
||||
window_tile_inspector_base_height_offset(w->selected_list_item, -1);
|
||||
break;
|
||||
case WIDX_BANNER_CHECK_BLOCK_NE:
|
||||
case WIDX_BANNER_CHECK_BLOCK_SE:
|
||||
@@ -1255,16 +1222,10 @@ static void window_tile_inspector_mouseup(rct_window *w, sint32 widgetIndex)
|
||||
case PAGE_CORRUPT:
|
||||
switch (widgetIndex) {
|
||||
case WIDX_CORRUPT_SPINNER_HEIGHT_INCREASE:
|
||||
mapElement->base_height++;
|
||||
mapElement->clearance_height++;
|
||||
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
|
||||
widget_invalidate(w, WIDX_FENCE_SPINNER_HEIGHT);
|
||||
window_tile_inspector_base_height_offset(w->selected_list_item, 1);
|
||||
break;
|
||||
case WIDX_CORRUPT_SPINNER_HEIGHT_DECREASE:
|
||||
mapElement->base_height--;
|
||||
mapElement->clearance_height--;
|
||||
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
|
||||
widget_invalidate(w, WIDX_FENCE_SPINNER_HEIGHT);
|
||||
window_tile_inspector_base_height_offset(w->selected_list_item, -1);
|
||||
break;
|
||||
case WIDX_CORRUPT_BUTTON_CLAMP:
|
||||
if (!map_element_is_last_for_tile(mapElement)) {
|
||||
|
||||
@@ -5616,8 +5616,8 @@ void game_command_modify_tile(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx
|
||||
{
|
||||
case TILE_INSPECTOR_ANY_REMOVE:
|
||||
{
|
||||
const sint16 index = *edx;
|
||||
*ebx = tile_inspector_remove_element_at(x, y, index, flags);
|
||||
const sint16 element_index = *edx;
|
||||
*ebx = tile_inspector_remove_element_at(x, y, element_index, flags);
|
||||
return;
|
||||
}
|
||||
case TILE_INSPECTOR_ANY_SWAP:
|
||||
@@ -5629,14 +5629,14 @@ void game_command_modify_tile(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx
|
||||
}
|
||||
case TILE_INSPECTOR_ANY_INSERT_CORRUPT:
|
||||
{
|
||||
const sint16 index = *edx;
|
||||
*ebx = tile_inspector_insert_corrupt_at(x, y, index, flags);
|
||||
const sint16 element_index = *edx;
|
||||
*ebx = tile_inspector_insert_corrupt_at(x, y, element_index, flags);
|
||||
return;
|
||||
}
|
||||
case TILE_INSPECTOR_ANY_ROTATE:
|
||||
{
|
||||
const sint16 index = *edx;
|
||||
*ebx = tile_inspector_rotate_element_at(x, y, index, flags);
|
||||
const sint16 element_index = *edx;
|
||||
*ebx = tile_inspector_rotate_element_at(x, y, element_index, flags);
|
||||
return;
|
||||
}
|
||||
case TILE_INSPECTOR_ANY_PASTE:
|
||||
@@ -5653,6 +5653,13 @@ void game_command_modify_tile(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx
|
||||
*ebx = tile_inspector_sort_elements_at(x, y, flags);
|
||||
return;
|
||||
}
|
||||
case TILE_INSPECTOR_ANY_BASE_HEIGHT_OFFSET:
|
||||
{
|
||||
const sint16 element_index = *edx;
|
||||
const sint8 height_offset = *edi;
|
||||
*ebx = tile_inspector_change_base_height_at(x, y, element_index, height_offset, flags);
|
||||
return;
|
||||
}
|
||||
default:
|
||||
log_error("invalid instruction");
|
||||
*ebx = MONEY32_UNDEFINED;
|
||||
|
||||
@@ -315,3 +315,25 @@ sint32 tile_inspector_sort_elements_at(sint32 x, sint32 y, sint32 flags)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sint32 tile_inspector_change_base_height_at(sint32 x, sint32 y, sint16 element_index, sint8 height_offset, sint32 flags)
|
||||
{
|
||||
rct_map_element *const map_element = map_get_first_element_at(x, y) + element_index;
|
||||
sint16 new_base_height = (sint16)map_element->base_height + height_offset;
|
||||
sint16 new_clearance_height = (sint16)map_element->clearance_height + height_offset;
|
||||
if (new_base_height < 0 || new_base_height > 0xff || new_clearance_height < 0 || new_clearance_height > 0xff)
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
if (flags & GAME_COMMAND_FLAG_APPLY)
|
||||
{
|
||||
map_element->base_height += height_offset;
|
||||
map_element->clearance_height += height_offset;
|
||||
|
||||
map_invalidate_tile_full(x << 5, y << 5);
|
||||
window_invalidate_by_class(WC_TILE_INSPECTOR);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ typedef enum {
|
||||
TILE_INSPECTOR_ANY_ROTATE,
|
||||
TILE_INSPECTOR_ANY_PASTE,
|
||||
TILE_INSPECTOR_ANY_SORT,
|
||||
TILE_INSPECTOR_ANY_BASE_HEIGHT_OFFSET,
|
||||
} tile_inspector_instruction;
|
||||
|
||||
sint32 tile_inspector_insert_corrupt_at(sint32 x, sint32 y, sint16 element_index, sint32 flags);
|
||||
@@ -46,3 +47,4 @@ sint32 tile_inspector_swap_elements_at(sint32 x, sint32 y, sint16 first, sint16
|
||||
sint32 tile_inspector_rotate_element_at(sint32 x, sint32 y, sint32 element_index, sint32 flags);
|
||||
sint32 tile_inspector_paste_element_at(sint32 x, sint32 y, rct_map_element element, sint32 flags);
|
||||
sint32 tile_inspector_sort_elements_at(sint32 x, sint32 y, sint32 flags);
|
||||
sint32 tile_inspector_change_base_height_at(sint32 x, sint32 y, sint16 element_index, sint8 height_offset, sint32 flags);
|
||||
|
||||
Reference in New Issue
Block a user