mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-12 18:42:36 +01:00
Fix clear scenery window closing (again) (#22456)
* Move ClearSceneryToolIsActive into ClearScenery window * Actually apply/paint map selection in clear scenery tool * LandRightsWindow: fix invalidation
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
|
||||
namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
enum WindowClearSceneryWidgetIdx
|
||||
enum WindowClearSceneryWidgetIdx : WidgetIndex
|
||||
{
|
||||
WIDX_BACKGROUND,
|
||||
WIDX_TITLE,
|
||||
@@ -226,12 +226,80 @@ namespace OpenRCT2::Ui::Windows
|
||||
return ClearAction(range, itemsToClear);
|
||||
}
|
||||
|
||||
int8_t ToolUpdateClearLandPaint(const ScreenCoordsXY& screenPos)
|
||||
{
|
||||
uint8_t state_changed = 0;
|
||||
|
||||
MapInvalidateSelectionRect();
|
||||
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
|
||||
|
||||
auto mapTile = ScreenGetMapXY(screenPos, nullptr);
|
||||
|
||||
if (!mapTile.has_value())
|
||||
{
|
||||
return state_changed;
|
||||
}
|
||||
|
||||
if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE))
|
||||
{
|
||||
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
|
||||
state_changed++;
|
||||
}
|
||||
|
||||
if (gMapSelectType != MAP_SELECT_TYPE_FULL)
|
||||
{
|
||||
gMapSelectType = MAP_SELECT_TYPE_FULL;
|
||||
state_changed++;
|
||||
}
|
||||
|
||||
int16_t tool_size = std::max<uint16_t>(1, gLandToolSize);
|
||||
int16_t tool_length = (tool_size - 1) * 32;
|
||||
|
||||
// Move to tool bottom left
|
||||
mapTile->x -= (tool_size - 1) * 16;
|
||||
mapTile->y -= (tool_size - 1) * 16;
|
||||
mapTile = mapTile->ToTileStart();
|
||||
|
||||
if (gMapSelectPositionA.x != mapTile->x)
|
||||
{
|
||||
gMapSelectPositionA.x = mapTile->x;
|
||||
state_changed++;
|
||||
}
|
||||
|
||||
if (gMapSelectPositionA.y != mapTile->y)
|
||||
{
|
||||
gMapSelectPositionA.y = mapTile->y;
|
||||
state_changed++;
|
||||
}
|
||||
|
||||
mapTile->x += tool_length;
|
||||
mapTile->y += tool_length;
|
||||
|
||||
if (gMapSelectPositionB.x != mapTile->x)
|
||||
{
|
||||
gMapSelectPositionB.x = mapTile->x;
|
||||
state_changed++;
|
||||
}
|
||||
|
||||
if (gMapSelectPositionB.y != mapTile->y)
|
||||
{
|
||||
gMapSelectPositionB.y = mapTile->y;
|
||||
state_changed++;
|
||||
}
|
||||
|
||||
MapInvalidateSelectionRect();
|
||||
return state_changed;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0068E213
|
||||
*/
|
||||
void ToolUpdateSceneryClear(const ScreenCoordsXY& screenPos)
|
||||
{
|
||||
if (!ToolUpdateClearLandPaint(screenPos))
|
||||
return;
|
||||
|
||||
auto action = GetClearAction();
|
||||
auto result = GameActions::Query(&action);
|
||||
auto cost = (result.Error == GameActions::Status::Ok ? result.Cost : kMoney64Undefined);
|
||||
@@ -307,17 +375,23 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
WindowBase* ClearSceneryOpen()
|
||||
{
|
||||
auto* w = static_cast<CleanSceneryWindow*>(WindowBringToFrontByClass(WindowClass::ClearScenery));
|
||||
return WindowFocusOrCreate<CleanSceneryWindow>(
|
||||
WindowClass::ClearScenery, ScreenCoordsXY(ContextGetWidth() - WW, 29), WW, WH, 0);
|
||||
}
|
||||
|
||||
if (w != nullptr)
|
||||
return w;
|
||||
|
||||
w = WindowCreate<CleanSceneryWindow>(WindowClass::ClearScenery, ScreenCoordsXY(ContextGetWidth() - WW, 29), WW, WH, 0);
|
||||
|
||||
if (w != nullptr)
|
||||
return w;
|
||||
|
||||
return nullptr;
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0066D125
|
||||
*/
|
||||
bool ClearSceneryToolIsActive()
|
||||
{
|
||||
if (!(InputTestFlag(INPUT_FLAG_TOOL_ACTIVE)))
|
||||
return false;
|
||||
if (gCurrentToolWidget.window_classification != WindowClass::ClearScenery)
|
||||
return false;
|
||||
if (gCurrentToolWidget.widget_index != WIDX_BACKGROUND)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -250,7 +250,7 @@ static Widget window_land_rights_widgets[] = {
|
||||
if (_landRightsCost != kMoney64Undefined)
|
||||
{
|
||||
_landRightsCost = kMoney64Undefined;
|
||||
WindowInvalidateByClass(WindowClass::ClearScenery);
|
||||
WindowInvalidateByClass(WindowClass::LandRights);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1016,21 +1016,6 @@ namespace OpenRCT2::Ui::Windows
|
||||
return window;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0066D125
|
||||
*/
|
||||
bool ClearSceneryToolIsActive()
|
||||
{
|
||||
if (!(InputTestFlag(INPUT_FLAG_TOOL_ACTIVE)))
|
||||
return false;
|
||||
if (gCurrentToolWidget.window_classification != WindowClass::ClearScenery)
|
||||
return false;
|
||||
if (gCurrentToolWidget.widget_index != WIDX_CLEAR_SCENERY)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void TopToolbar::InitViewMenu(Widget& widget)
|
||||
{
|
||||
using namespace Dropdown;
|
||||
|
||||
Reference in New Issue
Block a user