mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #7510 from Broxzier/feature/horizontal-clipping
Horizontal Clipping
This commit is contained in:
commit
19442eb6c2
|
@ -4545,6 +4545,10 @@ STR_6235 :Server Information
|
|||
STR_6236 :Players
|
||||
STR_6237 :Groups
|
||||
STR_6238 :Multiplayer Options
|
||||
STR_6239 :Vertical Clipping
|
||||
STR_6240 :Horizontal Clipping
|
||||
STR_6241 :Select area
|
||||
STR_6242 :Clear selection
|
||||
|
||||
#############
|
||||
# Scenarios #
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
- Improved: [#5339] Change eyedropper icon to actual eyedropper and change cursor to crosshair.
|
||||
- Improved: [#7302] Raising land near the map edge makes the affected area smaller instead of showing an 'off edge map' error.
|
||||
- Improved: [#7435] Object indexing now supports multi-threading.
|
||||
- Improved: [#7510] Add horizontal clipping to cut-away view options.
|
||||
|
||||
0.1.2 (2018-03-18)
|
||||
------------------------------------------------------------------------
|
||||
|
|
|
@ -3315,7 +3315,7 @@ static void top_toolbar_init_view_menu(rct_window* w, rct_widget* widget) {
|
|||
dropdown_set_checked(11, true);
|
||||
if (mainViewport->flags & VIEWPORT_FLAG_PATH_HEIGHTS)
|
||||
dropdown_set_checked(12, true);
|
||||
if (mainViewport->flags & VIEWPORT_FLAG_PAINT_CLIP_TO_HEIGHT)
|
||||
if (mainViewport->flags & VIEWPORT_FLAG_CLIP_VIEW)
|
||||
dropdown_set_checked(DDIDX_VIEW_CLIPPING, true);
|
||||
if (mainViewport->flags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES)
|
||||
dropdown_set_checked(DDIDX_HIGHLIGHT_PATH_ISSUES, true);
|
||||
|
@ -3370,7 +3370,7 @@ static void top_toolbar_view_menu_dropdown(sint16 dropdownIndex)
|
|||
context_open_window(WC_VIEW_CLIPPING);
|
||||
} else {
|
||||
// If window is already open, toggle the view clipping on/off
|
||||
w->viewport->flags ^= VIEWPORT_FLAG_PAINT_CLIP_TO_HEIGHT;
|
||||
w->viewport->flags ^= VIEWPORT_FLAG_CLIP_VIEW;
|
||||
}
|
||||
break;
|
||||
case DDIDX_HIGHLIGHT_PATH_ISSUES:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers
|
||||
#pragma region Copyright (c) 2014-2018 OpenRCT2 Developers
|
||||
/*****************************************************************************
|
||||
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
||||
*
|
||||
|
@ -15,24 +15,30 @@
|
|||
#pragma endregion
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <openrct2/config/Config.h>
|
||||
#include <openrct2-ui/windows/Window.h>
|
||||
|
||||
#include <openrct2-ui/interface/Widget.h>
|
||||
#include <openrct2-ui/interface/Viewport.h>
|
||||
#include <openrct2-ui/interface/Widget.h>
|
||||
#include <openrct2-ui/windows/Window.h>
|
||||
#include <openrct2/Input.h>
|
||||
#include <openrct2/config/Config.h>
|
||||
#include <openrct2/drawing/Drawing.h>
|
||||
#include <openrct2/localisation/Localisation.h>
|
||||
#include <openrct2/paint/Paint.h>
|
||||
#include <openrct2/sprites.h>
|
||||
#include <openrct2/world/Location.hpp>
|
||||
|
||||
enum WINDOW_VIEW_CLIPPING_WIDGET_IDX {
|
||||
WIDX_BACKGROUND,
|
||||
WIDX_TITLE,
|
||||
WIDX_CLOSE,
|
||||
WIDX_CLIP_HEIGHT_CHECKBOX,
|
||||
WIDX_CLIP_CHECKBOX_ENABLE,
|
||||
WIDX_GROUPBOX_VERTICAL,
|
||||
WIDX_CLIP_HEIGHT_VALUE,
|
||||
WIDX_CLIP_HEIGHT_INCREASE,
|
||||
WIDX_CLIP_HEIGHT_DECREASE,
|
||||
WIDX_CLIP_HEIGHT_SLIDER
|
||||
WIDX_CLIP_HEIGHT_SLIDER,
|
||||
WIDX_GROUPBOX_HORIZONTAL,
|
||||
WIDX_CLIP_SELECTOR,
|
||||
WIDX_CLIP_CLEAR,
|
||||
};
|
||||
|
||||
enum class DISPLAY_TYPE {
|
||||
|
@ -45,30 +51,48 @@ static DISPLAY_TYPE gClipHeightDisplayType = DISPLAY_TYPE::DISPLAY_UNITS;
|
|||
#pragma region Widgets
|
||||
|
||||
#define WW 160
|
||||
#define WH 70
|
||||
#define WH 155
|
||||
|
||||
static rct_widget window_view_clipping_widgets[] = {
|
||||
{ WWT_FRAME, 0, 0, WW - 1, 0, WH - 1, STR_NONE, STR_NONE }, // panel / background
|
||||
{ WWT_CAPTION, 0, 1, WW - 2, 1, 14, STR_VIEW_CLIPPING_TITLE, STR_WINDOW_TITLE_TIP }, // title bar
|
||||
{ WWT_CLOSEBOX, 0, WW - 13, WW - 3, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, // close x button
|
||||
{ WWT_CHECKBOX, 0, 11, 149, 19, 29, STR_VIEW_CLIPPING_HEIGHT_ENABLE, STR_VIEW_CLIPPING_HEIGHT_ENABLE_TIP }, // clip height enable/disable check box
|
||||
{ WWT_SPINNER, 0, 90, 149, 34, 45, STR_NONE, STR_VIEW_CLIPPING_HEIGHT_VALUE_TOGGLE }, // clip height value
|
||||
{ WWT_BUTTON, 0, 138, 148, 35, 39, STR_NUMERIC_UP, STR_NONE }, // clip height increase
|
||||
{ WWT_BUTTON, 0, 138, 148, 40, 44, STR_NUMERIC_DOWN, STR_NONE }, // clip height decrease
|
||||
{ WWT_SCROLL, 0, 11, 149, 49, 61, SCROLL_HORIZONTAL, STR_VIEW_CLIPPING_HEIGHT_SCROLL_TIP }, // clip height scrollbar
|
||||
{ WWT_FRAME, 0, 0, WW - 1, 0, WH - 1, STR_NONE, STR_NONE }, // panel / background
|
||||
{ WWT_CAPTION, 0, 1, WW - 2, 1, 14, STR_VIEW_CLIPPING_TITLE, STR_WINDOW_TITLE_TIP }, // title bar
|
||||
{ WWT_CLOSEBOX, 0, WW - 13, WW - 3, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, // close x button
|
||||
{ WWT_CHECKBOX, 0, 11, WW - 11, 19, 29, STR_VIEW_CLIPPING_HEIGHT_ENABLE, STR_VIEW_CLIPPING_HEIGHT_ENABLE_TIP }, // clip enable/disable check box
|
||||
{ WWT_GROUPBOX, 0, 5, WW - 6, 36, 83, STR_VIEW_CLIPPING_VERTICAL_CLIPPING, STR_NONE },
|
||||
{ WWT_SPINNER, 0, 90, WW - 12, 51, 62, STR_NONE, STR_VIEW_CLIPPING_HEIGHT_VALUE_TOGGLE }, // clip height value
|
||||
{ WWT_BUTTON, 0, 138, WW - 13, 52, 56, STR_NUMERIC_UP, STR_NONE }, // clip height increase
|
||||
{ WWT_BUTTON, 0, 138, WW - 13, 57, 61, STR_NUMERIC_DOWN, STR_NONE }, // clip height decrease
|
||||
{ WWT_SCROLL, 0, 11, WW - 12, 66, 78, SCROLL_HORIZONTAL, STR_VIEW_CLIPPING_HEIGHT_SCROLL_TIP }, // clip height scrollbar
|
||||
{ WWT_GROUPBOX, 0, 5, WW - 6, 90, WH - 6, STR_VIEW_CLIPPING_HORIZONTAL_CLIPPING, STR_NONE },
|
||||
{ WWT_BUTTON, 0, 11, WW - 12, 105, 121, STR_VIEW_CLIPPING_SELECT_AREA, STR_NONE }, // selector
|
||||
{ WWT_BUTTON, 0, 11, WW - 12, 126, 143, STR_VIEW_CLIPPING_CLEAR_SELECTION, STR_NONE }, // clear
|
||||
{ WIDGETS_END }
|
||||
};
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Members
|
||||
|
||||
static LocationXY16 _selectionStart;
|
||||
static LocationXY8 _previousClipSelectionA;
|
||||
static LocationXY8 _previousClipSelectionB;
|
||||
static bool _toolActive;
|
||||
static bool _dragging;
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Events
|
||||
|
||||
static void window_view_clipping_close_button(rct_window *w);
|
||||
static void window_view_clipping_mouseup(rct_window *w, rct_widgetindex widgetIndex);
|
||||
static void window_view_clipping_update(rct_window *w);
|
||||
static void window_view_clipping_invalidate(rct_window *w);
|
||||
static void window_view_clipping_paint(rct_window *w, rct_drawpixelinfo *dpi);
|
||||
static void window_view_clipping_scrollgetsize(rct_window *w, int scrollIndex, int *width, int *height);
|
||||
static void window_view_clipping_close_button(rct_window* w);
|
||||
static void window_view_clipping_mouseup(rct_window* w, rct_widgetindex widgetIndex);
|
||||
static void window_view_clipping_update(rct_window* w);
|
||||
static void window_view_clipping_tool_update(rct_window* w, rct_widgetindex widgetIndex, sint32 x, sint32 y);
|
||||
static void window_view_clipping_tool_down(rct_window* w, rct_widgetindex widgetIndex, sint32 x, sint32 y);
|
||||
static void window_view_clipping_tool_drag(rct_window* w, rct_widgetindex widgetIndex, sint32 x, sint32 y);
|
||||
static void window_view_clipping_tool_up(rct_window* w, rct_widgetindex, sint32, sint32);
|
||||
static void window_view_clipping_invalidate(rct_window* w);
|
||||
static void window_view_clipping_paint(rct_window* w, rct_drawpixelinfo* dpi);
|
||||
static void window_view_clipping_scrollgetsize(rct_window* w, int scrollIndex, int* width, int* height);
|
||||
static void window_view_clipping_close();
|
||||
|
||||
static rct_window_event_list window_view_clipping_events = {
|
||||
|
@ -81,10 +105,10 @@ static rct_window_event_list window_view_clipping_events = {
|
|||
window_view_clipping_update,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
window_view_clipping_tool_update,
|
||||
window_view_clipping_tool_down,
|
||||
window_view_clipping_tool_drag,
|
||||
window_view_clipping_tool_up,
|
||||
nullptr,
|
||||
nullptr,
|
||||
window_view_clipping_scrollgetsize,
|
||||
|
@ -129,11 +153,13 @@ rct_window * window_view_clipping_open()
|
|||
window = window_create(32, 32, WW, WH, &window_view_clipping_events, WC_VIEW_CLIPPING, 0);
|
||||
window->widgets = window_view_clipping_widgets;
|
||||
window->enabled_widgets = (1ULL << WIDX_CLOSE) |
|
||||
(1ULL << WIDX_CLIP_HEIGHT_CHECKBOX) |
|
||||
(1ULL << WIDX_CLIP_CHECKBOX_ENABLE) |
|
||||
(1ULL << WIDX_CLIP_HEIGHT_VALUE) |
|
||||
(1ULL << WIDX_CLIP_HEIGHT_INCREASE) |
|
||||
(1ULL << WIDX_CLIP_HEIGHT_DECREASE) |
|
||||
(1ULL << WIDX_CLIP_HEIGHT_SLIDER);
|
||||
(1ULL << WIDX_CLIP_HEIGHT_SLIDER) |
|
||||
(1ULL << WIDX_CLIP_SELECTOR) |
|
||||
(1ULL << WIDX_CLIP_CLEAR);
|
||||
|
||||
window_init_scroll_widgets(window);
|
||||
|
||||
|
@ -144,10 +170,13 @@ rct_window * window_view_clipping_open()
|
|||
|
||||
// Turn on view clipping when the window is opened.
|
||||
if (mainWindow != nullptr) {
|
||||
mainWindow->viewport->flags |= VIEWPORT_FLAG_PAINT_CLIP_TO_HEIGHT;
|
||||
mainWindow->viewport->flags |= VIEWPORT_FLAG_CLIP_VIEW;
|
||||
window_invalidate(mainWindow);
|
||||
}
|
||||
|
||||
_toolActive = false;
|
||||
_dragging = false;
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
|
@ -156,7 +185,7 @@ static void window_view_clipping_close()
|
|||
// Turn off view clipping when the window is closed.
|
||||
rct_window *mainWindow = window_get_main();
|
||||
if (mainWindow != nullptr) {
|
||||
mainWindow->viewport->flags &= ~VIEWPORT_FLAG_PAINT_CLIP_TO_HEIGHT;
|
||||
mainWindow->viewport->flags &= ~VIEWPORT_FLAG_CLIP_VIEW;
|
||||
window_invalidate(mainWindow);
|
||||
}
|
||||
|
||||
|
@ -167,6 +196,16 @@ static void window_view_clipping_close_button(rct_window *w)
|
|||
window_view_clipping_close();
|
||||
}
|
||||
|
||||
// Returns true when the tool is active
|
||||
static bool window_view_clipping_tool_is_active()
|
||||
{
|
||||
if (!(input_test_flag(INPUT_FLAG_TOOL_ACTIVE)))
|
||||
return false;
|
||||
if (gCurrentToolWidget.window_classification != WC_VIEW_CLIPPING)
|
||||
return false;
|
||||
return _toolActive;
|
||||
}
|
||||
|
||||
static void window_view_clipping_mouseup(rct_window *w, rct_widgetindex widgetIndex)
|
||||
{
|
||||
rct_window *mainWindow;
|
||||
|
@ -176,11 +215,11 @@ static void window_view_clipping_mouseup(rct_window *w, rct_widgetindex widgetIn
|
|||
case WIDX_CLOSE:
|
||||
window_close(w);
|
||||
break;
|
||||
case WIDX_CLIP_HEIGHT_CHECKBOX:
|
||||
case WIDX_CLIP_CHECKBOX_ENABLE:
|
||||
// Toggle height clipping.
|
||||
mainWindow = window_get_main();
|
||||
if (mainWindow != nullptr) {
|
||||
mainWindow->viewport->flags ^= VIEWPORT_FLAG_PAINT_CLIP_TO_HEIGHT;
|
||||
mainWindow->viewport->flags ^= VIEWPORT_FLAG_CLIP_VIEW;
|
||||
window_invalidate(mainWindow);
|
||||
}
|
||||
window_invalidate(w);
|
||||
|
@ -211,6 +250,29 @@ static void window_view_clipping_mouseup(rct_window *w, rct_widgetindex widgetIn
|
|||
}
|
||||
window_invalidate(w);
|
||||
break;
|
||||
case WIDX_CLIP_SELECTOR:
|
||||
// Activate the selection tool
|
||||
tool_set(w, WIDX_BACKGROUND, TOOL_CROSSHAIR);
|
||||
_toolActive = true;
|
||||
_dragging = false;
|
||||
|
||||
// Reset clip selection to show all tiles
|
||||
_previousClipSelectionA = gClipSelectionA;
|
||||
_previousClipSelectionB = gClipSelectionB;
|
||||
gClipSelectionA = { 0, 0 };
|
||||
gClipSelectionB = { MAXIMUM_MAP_SIZE_TECHNICAL - 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1 };
|
||||
gfx_invalidate_screen();
|
||||
break;
|
||||
case WIDX_CLIP_CLEAR:
|
||||
if (window_view_clipping_tool_is_active())
|
||||
{
|
||||
_toolActive = false;
|
||||
tool_cancel();
|
||||
}
|
||||
gClipSelectionA = { 0, 0 };
|
||||
gClipSelectionB = { MAXIMUM_MAP_SIZE_TECHNICAL - 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1 };
|
||||
gfx_invalidate_screen();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,16 +291,102 @@ static void window_view_clipping_update(rct_window *w)
|
|||
window_invalidate(mainWindow);
|
||||
}
|
||||
}
|
||||
|
||||
// Restore previous selection if the tool has been interrupted
|
||||
if (_toolActive && !window_view_clipping_tool_is_active())
|
||||
{
|
||||
_toolActive = false;
|
||||
gClipSelectionA = _previousClipSelectionA;
|
||||
gClipSelectionB = _previousClipSelectionB;
|
||||
}
|
||||
|
||||
widget_invalidate(w, WIDX_CLIP_HEIGHT_SLIDER);
|
||||
}
|
||||
|
||||
static void window_view_clipping_tool_update(rct_window* w, rct_widgetindex widgetIndex, sint32 x, sint32 y)
|
||||
{
|
||||
if (_dragging)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
sint16 mapX = x;
|
||||
sint16 mapY = y;
|
||||
sint32 direction;
|
||||
screen_pos_to_map_pos(&mapX, &mapY, &direction);
|
||||
if (mapX != LOCATION_NULL)
|
||||
{
|
||||
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
|
||||
map_invalidate_tile_full(gMapSelectPositionA.x, gMapSelectPositionA.y);
|
||||
gMapSelectPositionA.x = gMapSelectPositionB.x = mapX;
|
||||
gMapSelectPositionA.y = gMapSelectPositionB.y = mapY;
|
||||
map_invalidate_tile_full(mapX, mapY);
|
||||
gMapSelectType = MAP_SELECT_TYPE_FULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void window_view_clipping_tool_down(rct_window* w, rct_widgetindex widgetIndex, sint32 x, sint32 y)
|
||||
{
|
||||
sint16 mapX = x;
|
||||
sint16 mapY = y;
|
||||
sint32 direction;
|
||||
screen_pos_to_map_pos(&mapX, &mapY, &direction);
|
||||
if (mapX != LOCATION_NULL)
|
||||
{
|
||||
_dragging = true;
|
||||
_selectionStart = { mapX, mapY };
|
||||
}
|
||||
}
|
||||
|
||||
static void window_view_clipping_tool_drag(rct_window* w, rct_widgetindex widgetIndex, sint32 x, sint32 y)
|
||||
{
|
||||
if (!_dragging)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
sint16 mapX = x;
|
||||
sint16 mapY = y;
|
||||
sint32 direction;
|
||||
screen_pos_to_map_pos(&mapX, &mapY, &direction);
|
||||
if (mapX != LOCATION_NULL)
|
||||
{
|
||||
map_invalidate_selection_rect();
|
||||
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
|
||||
gMapSelectPositionA.x = std::min(_selectionStart.x, mapX);
|
||||
gMapSelectPositionB.x = std::max(_selectionStart.x, mapX);
|
||||
gMapSelectPositionA.y = std::min(_selectionStart.y, mapY);
|
||||
gMapSelectPositionB.y = std::max(_selectionStart.y, mapY);
|
||||
gMapSelectType = MAP_SELECT_TYPE_FULL;
|
||||
map_invalidate_selection_rect();
|
||||
}
|
||||
}
|
||||
|
||||
static void window_view_clipping_tool_up(struct rct_window*, rct_widgetindex, sint32, sint32)
|
||||
{
|
||||
gClipSelectionA = { uint8(gMapSelectPositionA.x / 32), uint8(gMapSelectPositionA.y / 32) };
|
||||
gClipSelectionB = { uint8(gMapSelectPositionB.x / 32), uint8(gMapSelectPositionB.y / 32) };
|
||||
_toolActive = false;
|
||||
tool_cancel();
|
||||
gfx_invalidate_screen();
|
||||
}
|
||||
|
||||
static void window_view_clipping_invalidate(rct_window *w)
|
||||
{
|
||||
widget_scroll_update_thumbs(w, WIDX_CLIP_HEIGHT_SLIDER);
|
||||
|
||||
rct_window *mainWindow = window_get_main();
|
||||
if (mainWindow != nullptr) {
|
||||
widget_set_checkbox_value(w, WIDX_CLIP_HEIGHT_CHECKBOX, mainWindow->viewport->flags & VIEWPORT_FLAG_PAINT_CLIP_TO_HEIGHT);
|
||||
widget_set_checkbox_value(w, WIDX_CLIP_CHECKBOX_ENABLE, mainWindow->viewport->flags & VIEWPORT_FLAG_CLIP_VIEW);
|
||||
}
|
||||
|
||||
if (window_view_clipping_tool_is_active())
|
||||
{
|
||||
w->pressed_widgets |= 1ULL << WIDX_CLIP_SELECTOR;
|
||||
}
|
||||
else
|
||||
{
|
||||
w->pressed_widgets &= ~(1ULL << WIDX_CLIP_SELECTOR);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -879,7 +879,7 @@ static void viewport_paint_column(rct_drawpixelinfo * dpi, uint32 viewFlags)
|
|||
{
|
||||
gCurrentViewportFlags = viewFlags;
|
||||
|
||||
if (viewFlags & (VIEWPORT_FLAG_HIDE_VERTICAL | VIEWPORT_FLAG_HIDE_BASE | VIEWPORT_FLAG_UNDERGROUND_INSIDE | VIEWPORT_FLAG_PAINT_CLIP_TO_HEIGHT)) {
|
||||
if (viewFlags & (VIEWPORT_FLAG_HIDE_VERTICAL | VIEWPORT_FLAG_HIDE_BASE | VIEWPORT_FLAG_UNDERGROUND_INSIDE | VIEWPORT_FLAG_CLIP_VIEW)) {
|
||||
uint8 colour = 10;
|
||||
if (viewFlags & VIEWPORT_FLAG_INVISIBLE_SPRITES) {
|
||||
colour = 0;
|
||||
|
|
|
@ -48,7 +48,7 @@ enum {
|
|||
VIEWPORT_FLAG_INVISIBLE_SPRITES = (1 << 14),
|
||||
VIEWPORT_FLAG_15 = (1 << 15),
|
||||
VIEWPORT_FLAG_SEETHROUGH_PATHS = (1 << 16),
|
||||
VIEWPORT_FLAG_PAINT_CLIP_TO_HEIGHT = (1 << 17),
|
||||
VIEWPORT_FLAG_CLIP_VIEW = (1 << 17),
|
||||
VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES = (1 << 18),
|
||||
};
|
||||
|
||||
|
|
|
@ -3905,6 +3905,11 @@ enum {
|
|||
STR_MULTIPLAYER_GROUPS_TITLE = 6237,
|
||||
STR_MULTIPLAYER_OPTIONS_TITLE = 6238,
|
||||
|
||||
STR_VIEW_CLIPPING_VERTICAL_CLIPPING = 6239,
|
||||
STR_VIEW_CLIPPING_HORIZONTAL_CLIPPING = 6240,
|
||||
STR_VIEW_CLIPPING_SELECT_AREA = 6241,
|
||||
STR_VIEW_CLIPPING_CLEAR_SELECTION = 6242,
|
||||
|
||||
// Have to include resource strings (from scenarios and objects) for the time being now that language is partially working
|
||||
STR_COUNT = 32768
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers
|
||||
#pragma region Copyright (c) 2014-2018 OpenRCT2 Developers
|
||||
/*****************************************************************************
|
||||
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
||||
*
|
||||
|
@ -25,8 +25,10 @@
|
|||
#include "sprite/Sprite.h"
|
||||
#include "tile_element/TileElement.h"
|
||||
|
||||
// Global for paint clipping height
|
||||
// Globals for paint clipping
|
||||
uint8 gClipHeight = 128; // Default to middle value
|
||||
LocationXY8 gClipSelectionA = { 0, 0 };
|
||||
LocationXY8 gClipSelectionB = { MAXIMUM_MAP_SIZE_TECHNICAL - 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1 };
|
||||
|
||||
paint_session gPaintSession;
|
||||
static bool _paintSessionInUse;
|
||||
|
@ -1209,4 +1211,4 @@ void paint_draw_money_structs(rct_drawpixelinfo * dpi, paint_string_struct * ps)
|
|||
|
||||
gfx_draw_string_with_y_offsets(&dpi2, buffer, COLOUR_BLACK, ps->x, ps->y, (sint8 *)ps->y_offsets, forceSpriteFont);
|
||||
} while ((ps = ps->next) != nullptr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers
|
||||
#pragma region Copyright (c) 2014-2018 OpenRCT2 Developers
|
||||
/*****************************************************************************
|
||||
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
||||
*
|
||||
|
@ -170,8 +170,10 @@ struct paint_session
|
|||
|
||||
extern paint_session gPaintSession;
|
||||
|
||||
// Global for paint clipping height.
|
||||
// Globals for paint clipping
|
||||
extern uint8 gClipHeight;
|
||||
extern LocationXY8 gClipSelectionA;
|
||||
extern LocationXY8 gClipSelectionB;
|
||||
|
||||
/** rct2: 0x00993CC4. The white ghost that indicates not-yet-built elements. */
|
||||
#define CONSTRUCTION_MARKER (COLOUR_DARK_GREEN << 19 | COLOUR_GREY << 24 | IMAGE_TYPE_REMAP);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers
|
||||
#pragma region Copyright (c) 2014-2018 OpenRCT2 Developers
|
||||
/*****************************************************************************
|
||||
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
||||
*
|
||||
|
@ -69,11 +69,19 @@ void sprite_paint_setup(paint_session * session, const uint16 eax, const uint16
|
|||
}
|
||||
}
|
||||
|
||||
// Only paint sprites that are below the clip height.
|
||||
// Only paint sprites that are below the clip height and inside the clip selection.
|
||||
// Here converting from land/path/etc height scale to pixel height scale.
|
||||
// Note: peeps/scenery on slopes will be above the base
|
||||
// height of the slope element, and consequently clipped.
|
||||
if ((gCurrentViewportFlags & VIEWPORT_FLAG_PAINT_CLIP_TO_HEIGHT) && (spr->unknown.z > (gClipHeight * 8) )) continue;
|
||||
if ((gCurrentViewportFlags & VIEWPORT_FLAG_CLIP_VIEW))
|
||||
{
|
||||
if (spr->unknown.z > (gClipHeight * 8))
|
||||
continue;
|
||||
if (spr->unknown.x / 32 < gClipSelectionA.x || spr->unknown.x / 32 > gClipSelectionB.x)
|
||||
continue;
|
||||
if (spr->unknown.y / 32 < gClipSelectionA.y || spr->unknown.y / 32 > gClipSelectionB.y)
|
||||
continue;
|
||||
}
|
||||
|
||||
dpi = session->Unk140E9A8;
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "../../OpenRCT2.h"
|
||||
#include "../../Cheats.h"
|
||||
#include "../../config/Config.h"
|
||||
#include "../../core/Guard.hpp"
|
||||
#include "../../core/Math.hpp"
|
||||
#include "../../core/Util.hpp"
|
||||
#include "../../drawing/Drawing.h"
|
||||
|
@ -424,6 +425,7 @@ static constexpr const uint32 dword_97B898[][2] =
|
|||
|
||||
struct tile_descriptor
|
||||
{
|
||||
TileCoordsXY tile_coords;
|
||||
const rct_tile_element * tile_element;
|
||||
uint8 terrain;
|
||||
uint8 slope;
|
||||
|
@ -612,12 +614,26 @@ static void viewport_surface_smoothen_edge(paint_session * session, enum edge_t
|
|||
}
|
||||
}
|
||||
|
||||
static bool tile_is_inside_clip_view(const tile_descriptor& tile)
|
||||
{
|
||||
Guard::ArgumentNotNull(tile.tile_element);
|
||||
|
||||
if (tile.tile_element->base_height > gClipHeight)
|
||||
return false;
|
||||
if (tile.tile_coords.x < gClipSelectionA.x || tile.tile_coords.x > gClipSelectionB.x)
|
||||
return false;
|
||||
if (tile.tile_coords.y < gClipSelectionA.y || tile.tile_coords.y > gClipSelectionB.y)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void viewport_surface_draw_tile_side_bottom(paint_session * session, enum edge_t edge, uint8 height, uint8 edgeStyle, struct tile_descriptor self, struct tile_descriptor neighbour, bool isWater)
|
||||
{
|
||||
if (!is_csg_loaded() && edgeStyle >= TERRAIN_EDGE_RCT2_COUNT)
|
||||
edgeStyle = TERRAIN_EDGE_ROCK;
|
||||
|
||||
sint16 al, ah, cl, ch, dl = 0, dh;
|
||||
sint16 cornerHeight1, neighbourCornerHeight1, cornerHeight2, neighbourCornerHeight2;
|
||||
|
||||
LocationXY8 offset = { 0, 0 };
|
||||
LocationXY8 bounds = { 0, 0 };
|
||||
|
@ -628,11 +644,11 @@ static void viewport_surface_draw_tile_side_bottom(paint_session * session, enum
|
|||
switch (edge)
|
||||
{
|
||||
case EDGE_BOTTOMLEFT:
|
||||
al = self.corner_heights.left;
|
||||
cl = self.corner_heights.bottom;
|
||||
cornerHeight1 = self.corner_heights.left;
|
||||
cornerHeight2 = self.corner_heights.bottom;
|
||||
|
||||
ah = neighbour.corner_heights.top;
|
||||
ch = neighbour.corner_heights.right;
|
||||
neighbourCornerHeight1 = neighbour.corner_heights.top;
|
||||
neighbourCornerHeight2 = neighbour.corner_heights.right;
|
||||
|
||||
offset.x = 30;
|
||||
bounds.y = 30;
|
||||
|
@ -643,11 +659,11 @@ static void viewport_surface_draw_tile_side_bottom(paint_session * session, enum
|
|||
break;
|
||||
|
||||
case EDGE_BOTTOMRIGHT:
|
||||
al = self.corner_heights.right;
|
||||
cl = self.corner_heights.bottom;
|
||||
cornerHeight1 = self.corner_heights.right;
|
||||
cornerHeight2 = self.corner_heights.bottom;
|
||||
|
||||
ah = neighbour.corner_heights.top;
|
||||
ch = neighbour.corner_heights.left;
|
||||
neighbourCornerHeight1 = neighbour.corner_heights.top;
|
||||
neighbourCornerHeight2 = neighbour.corner_heights.left;
|
||||
|
||||
offset.y = 30;
|
||||
bounds.x = 30;
|
||||
|
@ -661,31 +677,31 @@ static void viewport_surface_draw_tile_side_bottom(paint_session * session, enum
|
|||
return;
|
||||
}
|
||||
|
||||
bool neighbourIsClippedAway = (gCurrentViewportFlags & VIEWPORT_FLAG_CLIP_VIEW) && !tile_is_inside_clip_view(neighbour);
|
||||
|
||||
if (neighbour.tile_element == nullptr || neighbourIsClippedAway)
|
||||
{
|
||||
// The neighbour tile doesn't exist or isn't drawn - assume minimum height to draw full edges
|
||||
neighbourCornerHeight2 = MINIMUM_LAND_HEIGHT / 2;
|
||||
neighbourCornerHeight1 = MINIMUM_LAND_HEIGHT / 2;
|
||||
}
|
||||
|
||||
if (isWater)
|
||||
dl = height;
|
||||
|
||||
if (neighbour.tile_element == nullptr)
|
||||
{
|
||||
ch = 1;
|
||||
ah = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isWater)
|
||||
uint8 waterHeight = surface_get_water_height(neighbour.tile_element);
|
||||
if (waterHeight == height && !neighbourIsClippedAway)
|
||||
{
|
||||
dh = surface_get_water_height(neighbour.tile_element);
|
||||
if (dl == dh)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
al = dl;
|
||||
cl = dl;
|
||||
// Don't draw the edge when the neighbour's water level is the same
|
||||
return;
|
||||
}
|
||||
|
||||
cornerHeight1 = height;
|
||||
cornerHeight2 = height;
|
||||
}
|
||||
|
||||
if (al <= ah && cl <= ch)
|
||||
if (cornerHeight1 <= neighbourCornerHeight1 && cornerHeight2 <= neighbourCornerHeight2)
|
||||
{
|
||||
// The edge is not visible behind the neighbour's slope
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -703,18 +719,18 @@ static void viewport_surface_draw_tile_side_bottom(paint_session * session, enum
|
|||
base_image_id += 5;
|
||||
}
|
||||
|
||||
uint8 curHeight = Math::Min(ah, ch);
|
||||
if (ch != ah)
|
||||
uint8 curHeight = Math::Min(neighbourCornerHeight1, neighbourCornerHeight2);
|
||||
if (neighbourCornerHeight2 != neighbourCornerHeight1)
|
||||
{
|
||||
// If bottom part of edge isn't straight, add a filler
|
||||
uint32 image_offset = 3;
|
||||
|
||||
if (ch >= ah)
|
||||
if (neighbourCornerHeight2 >= neighbourCornerHeight1)
|
||||
{
|
||||
image_offset = 4;
|
||||
}
|
||||
|
||||
if (curHeight != al && curHeight != cl)
|
||||
if (curHeight != cornerHeight1 && curHeight != cornerHeight2)
|
||||
{
|
||||
uint32 image_id = base_image_id + image_offset;
|
||||
sub_98196C(session, image_id, offset.x, offset.y, bounds.x, bounds.y, 15, curHeight * 16);
|
||||
|
@ -722,19 +738,19 @@ static void viewport_surface_draw_tile_side_bottom(paint_session * session, enum
|
|||
}
|
||||
}
|
||||
|
||||
ah = cl;
|
||||
neighbourCornerHeight1 = cornerHeight2;
|
||||
|
||||
for(uint32 tunnelIndex = 0; tunnelIndex < TUNNEL_MAX_COUNT;)
|
||||
{
|
||||
if (curHeight >= al || curHeight >= cl)
|
||||
if (curHeight >= cornerHeight1 || curHeight >= cornerHeight2)
|
||||
{
|
||||
// If top of edge isn't straight, add a filler
|
||||
uint32 image_offset = 1;
|
||||
if (curHeight >= al)
|
||||
if (curHeight >= cornerHeight1)
|
||||
{
|
||||
image_offset = 2;
|
||||
|
||||
if (curHeight >= cl)
|
||||
if (curHeight >= cornerHeight2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -768,7 +784,7 @@ static void viewport_surface_draw_tile_side_bottom(paint_session * session, enum
|
|||
uint8 tunnelHeight = _tunnelHeights[tunnelType][0];
|
||||
sint16 zOffset = curHeight;
|
||||
|
||||
if ((zOffset + tunnelHeight) > ah || (zOffset + tunnelHeight) > al)
|
||||
if ((zOffset + tunnelHeight) > neighbourCornerHeight1 || (zOffset + tunnelHeight) > cornerHeight1)
|
||||
{
|
||||
tunnelType = byte_97B5B0[tunnelType];
|
||||
}
|
||||
|
@ -1000,6 +1016,7 @@ void surface_paint(paint_session * session, uint8 direction, uint16 height, cons
|
|||
|
||||
tile_descriptor selfDescriptor =
|
||||
{
|
||||
{ base.x / 32, base.y / 32 },
|
||||
tileElement,
|
||||
(uint8)terrain_type,
|
||||
surfaceShape,
|
||||
|
@ -1041,6 +1058,7 @@ void surface_paint(paint_session * session, uint8 direction, uint16 height, cons
|
|||
const uint8 baseHeight = surfaceElement->base_height / 2;
|
||||
const corner_height& ch = corner_heights[surfaceSlope];
|
||||
|
||||
descriptor.tile_coords = { position.x / 32, position.y / 32 };
|
||||
descriptor.tile_element = surfaceElement;
|
||||
descriptor.terrain = surface_get_terrain(surfaceElement);
|
||||
descriptor.slope = surfaceSlope;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers
|
||||
#pragma region Copyright (c) 2014-2018 OpenRCT2 Developers
|
||||
/*****************************************************************************
|
||||
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
||||
*
|
||||
|
@ -144,6 +144,14 @@ static void sub_68B3FB(paint_session * session, sint32 x, sint32 y)
|
|||
{
|
||||
rct_drawpixelinfo *dpi = session->Unk140E9A8;
|
||||
|
||||
if ((gCurrentViewportFlags & VIEWPORT_FLAG_CLIP_VIEW))
|
||||
{
|
||||
if (x / 32 < gClipSelectionA.x || x / 32 > gClipSelectionB.x)
|
||||
return;
|
||||
if (y / 32 < gClipSelectionA.y || y / 32 > gClipSelectionB.y)
|
||||
return;
|
||||
}
|
||||
|
||||
session->LeftTunnelCount = 0;
|
||||
session->RightTunnelCount = 0;
|
||||
session->LeftTunnels[0] = {0xFF, 0xFF};
|
||||
|
@ -247,7 +255,7 @@ static void sub_68B3FB(paint_session * session, sint32 x, sint32 y)
|
|||
sint32 previousHeight = 0;
|
||||
do {
|
||||
// Only paint tile_elements below the clip height.
|
||||
if ((gCurrentViewportFlags & VIEWPORT_FLAG_PAINT_CLIP_TO_HEIGHT) && (tile_element->base_height > gClipHeight))
|
||||
if ((gCurrentViewportFlags & VIEWPORT_FLAG_CLIP_VIEW) && (tile_element->base_height > gClipHeight))
|
||||
continue;
|
||||
|
||||
sint32 direction = tile_element_get_direction_with_offset(tile_element, rotation);
|
||||
|
@ -362,7 +370,7 @@ static void sub_68B3FB(paint_session * session, sint32 x, sint32 y)
|
|||
}
|
||||
|
||||
// Only draw supports below the clipping height.
|
||||
if ((gCurrentViewportFlags & VIEWPORT_FLAG_PAINT_CLIP_TO_HEIGHT) && (segmentHeight > gClipHeight)) continue;
|
||||
if ((gCurrentViewportFlags & VIEWPORT_FLAG_CLIP_VIEW) && (segmentHeight > gClipHeight)) continue;
|
||||
|
||||
sint32 xOffset = sy * 10;
|
||||
sint32 yOffset = -22 + sx * 10;
|
||||
|
|
|
@ -14,17 +14,18 @@
|
|||
*****************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#include "Addresses.h"
|
||||
|
||||
#include <openrct2/config/Config.h>
|
||||
#include <openrct2/object/Object.h>
|
||||
#include <openrct2/interface/Colour.h>
|
||||
#include <openrct2/interface/Viewport.h>
|
||||
#include <openrct2/ride/Ride.h>
|
||||
#include <openrct2/ride/Track.h>
|
||||
#include <openrct2/world/Sprite.h>
|
||||
#include <openrct2/object/Object.h>
|
||||
#include <openrct2/paint/tile_element/TileElement.h>
|
||||
#include <openrct2/ride/Ride.h>
|
||||
#include <openrct2/ride/Track.h>
|
||||
#include <openrct2/world/Location.hpp>
|
||||
#include <openrct2/world/Sprite.h>
|
||||
#include <openrct2/world/Surface.h>
|
||||
#include "Addresses.h"
|
||||
|
||||
#define gRideEntries RCT2_ADDRESS(0x009ACFA4, rct_ride_entry *)
|
||||
#define gTileElementTilePointers RCT2_ADDRESS(0x013CE9A4, rct_tile_element *)
|
||||
|
@ -36,6 +37,8 @@ sint16 gMapBaseZ;
|
|||
bool gTrackDesignSaveMode = false;
|
||||
uint8 gTrackDesignSaveRideIndex = 255;
|
||||
uint8 gClipHeight = 255;
|
||||
LocationXY8 gClipSelectionA = { 0, 0 };
|
||||
LocationXY8 gClipSelectionB = { MAXIMUM_MAP_SIZE_TECHNICAL - 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1 };
|
||||
uint32 gCurrentViewportFlags;
|
||||
uint32 gScenarioTicks;
|
||||
uint8 gCurrentRotation;
|
||||
|
@ -319,4 +322,4 @@ TileCoordsXYZD ride_get_entrance_location(const Ride * ride, const sint32 statio
|
|||
TileCoordsXYZD ride_get_exit_location(const Ride * ride, const sint32 stationIndex)
|
||||
{
|
||||
return ride->exits[stationIndex];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue