mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-23 06:44:38 +01:00
Restore old selection when the tool gets interupted
And re-type the selection variables to use LocationXY8 instead of storing them separately.
This commit is contained in:
@@ -67,7 +67,10 @@ static rct_widget window_view_clipping_widgets[] = {
|
||||
#pragma region Members
|
||||
|
||||
static LocationXY16 _selectionStart;
|
||||
static bool _dragging = false;
|
||||
static LocationXY8 _previousClipSelectionA;
|
||||
static LocationXY8 _previousClipSelectionB;
|
||||
static bool _toolActive;
|
||||
static bool _dragging;
|
||||
|
||||
#pragma endregion
|
||||
|
||||
@@ -163,6 +166,9 @@ rct_window * window_view_clipping_open()
|
||||
window_invalidate(mainWindow);
|
||||
}
|
||||
|
||||
_toolActive = false;
|
||||
_dragging = false;
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
@@ -229,12 +235,14 @@ static void window_view_clipping_mouseup(rct_window *w, rct_widgetindex widgetIn
|
||||
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
|
||||
gClipXMin = 0;
|
||||
gClipXMax = MAXIMUM_MAP_SIZE_TECHNICAL - 1;
|
||||
gClipYMin = 0;
|
||||
gClipYMax = MAXIMUM_MAP_SIZE_TECHNICAL - 1;
|
||||
_previousClipSelectionA = gClipSelectionA;
|
||||
_previousClipSelectionB = gClipSelectionB;
|
||||
gClipSelectionA = { 0, 0 };
|
||||
gClipSelectionB = { MAXIMUM_MAP_SIZE_TECHNICAL - 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1 };
|
||||
gfx_invalidate_screen();
|
||||
break;
|
||||
}
|
||||
@@ -247,7 +255,7 @@ static bool window_view_clipping_tool_is_active()
|
||||
return false;
|
||||
if (gCurrentToolWidget.window_classification != WC_VIEW_CLIPPING)
|
||||
return false;
|
||||
return true;
|
||||
return _toolActive;
|
||||
}
|
||||
|
||||
static void window_view_clipping_update(rct_window *w)
|
||||
@@ -266,9 +274,12 @@ static void window_view_clipping_update(rct_window *w)
|
||||
}
|
||||
}
|
||||
|
||||
if (window_view_clipping_tool_is_active())
|
||||
// Restore previous selection if the tool has been interrupted
|
||||
if (_toolActive && !window_view_clipping_tool_is_active())
|
||||
{
|
||||
// TODO: Deactivate selection tool and restore previous selection
|
||||
_toolActive = false;
|
||||
gClipSelectionA = _previousClipSelectionA;
|
||||
gClipSelectionB = _previousClipSelectionB;
|
||||
}
|
||||
|
||||
widget_invalidate(w, WIDX_CLIP_HEIGHT_SLIDER);
|
||||
@@ -335,11 +346,9 @@ static void window_view_clipping_tool_drag(rct_window* w, rct_widgetindex widget
|
||||
|
||||
static void window_view_clipping_tool_up(struct rct_window*, rct_widgetindex, sint32, sint32)
|
||||
{
|
||||
gClipXMin = gMapSelectPositionA.x / 32;
|
||||
gClipXMax = gMapSelectPositionB.x / 32;
|
||||
gClipYMin = gMapSelectPositionA.y / 32;
|
||||
gClipYMax = gMapSelectPositionB.y / 32;
|
||||
_dragging = false;
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -26,10 +26,8 @@
|
||||
|
||||
// Globals for paint clipping
|
||||
uint8 gClipHeight = 128; // Default to middle value
|
||||
uint8 gClipXMin = 0;
|
||||
uint8 gClipXMax = MAXIMUM_MAP_SIZE_TECHNICAL - 1;
|
||||
uint8 gClipYMin = 0;
|
||||
uint8 gClipYMax = MAXIMUM_MAP_SIZE_TECHNICAL - 1;
|
||||
LocationXY8 gClipSelectionA = { 0, 0 };
|
||||
LocationXY8 gClipSelectionB = { MAXIMUM_MAP_SIZE_TECHNICAL - 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1 };
|
||||
|
||||
paint_session gPaintSession;
|
||||
static bool _paintSessionInUse;
|
||||
|
||||
@@ -172,10 +172,8 @@ extern paint_session gPaintSession;
|
||||
|
||||
// Globals for paint clipping
|
||||
extern uint8 gClipHeight;
|
||||
extern uint8 gClipXMin;
|
||||
extern uint8 gClipXMax;
|
||||
extern uint8 gClipYMin;
|
||||
extern uint8 gClipYMax;
|
||||
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);
|
||||
|
||||
@@ -77,9 +77,9 @@ void sprite_paint_setup(paint_session * session, const uint16 eax, const uint16
|
||||
{
|
||||
if (spr->unknown.z > (gClipHeight * 8))
|
||||
continue;
|
||||
if (spr->unknown.x / 32 < gClipXMin || spr->unknown.x / 32 > gClipXMax)
|
||||
if (spr->unknown.x / 32 < gClipSelectionA.x || spr->unknown.x / 32 > gClipSelectionB.x)
|
||||
continue;
|
||||
if (spr->unknown.y / 32 < gClipYMin || spr->unknown.y / 32 > gClipYMax)
|
||||
if (spr->unknown.y / 32 < gClipSelectionA.y || spr->unknown.y / 32 > gClipSelectionB.y)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -146,9 +146,9 @@ static void sub_68B3FB(paint_session * session, sint32 x, sint32 y)
|
||||
|
||||
if ((gCurrentViewportFlags & VIEWPORT_FLAG_CLIP_VIEW))
|
||||
{
|
||||
if (x / 32 < gClipXMin || x / 32 > gClipXMax)
|
||||
if (x / 32 < gClipSelectionA.x || x / 32 > gClipSelectionB.x)
|
||||
return;
|
||||
if (y / 32 < gClipYMin || y / 32 > gClipYMax)
|
||||
if (y / 32 < gClipSelectionA.y || y / 32 > gClipSelectionB.y)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user