LandRights: deduplicate OnToolDown, OnToolDrag

This commit is contained in:
Aaron van Geffen committed 2024-08-02 14:37:10 +02:00
1 parent dae5b00f05
commit 482071a5ba
1 file changed
+10 -40
+10 -40
View File
@@ -336,50 +336,20 @@ static Widget window_land_rights_widgets[] = {
void OnToolDown(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) override
{
if (_landRightsMode == LAND_RIGHTS_MODE_BUY_LAND)
{
if (screenCoords.x != kLocationNull)
{
auto landBuyRightsAction = LandBuyRightsAction(
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y },
LandBuyRightSetting::BuyLand);
GameActions::Execute(&landBuyRightsAction);
}
}
else
{
if (screenCoords.x != kLocationNull)
{
auto landBuyRightsAction = LandBuyRightsAction(
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y },
LandBuyRightSetting::BuyConstructionRights);
GameActions::Execute(&landBuyRightsAction);
}
}
if (screenCoords.x == kLocationNull)
return;
auto modeSetting = _landRightsMode == LAND_RIGHTS_MODE_BUY_LAND ? LandBuyRightSetting::BuyLand
: LandBuyRightSetting::BuyConstructionRights;
auto landBuyRightsAction = LandBuyRightsAction(
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y }, modeSetting);
GameActions::Execute(&landBuyRightsAction);
}
void OnToolDrag(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) override
{
if (_landRightsMode == LAND_RIGHTS_MODE_BUY_LAND)
{
if (screenCoords.x != kLocationNull)
{
auto landBuyRightsAction = LandBuyRightsAction(
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y },
LandBuyRightSetting::BuyLand);
GameActions::Execute(&landBuyRightsAction);
}
}
else
{
if (screenCoords.x != kLocationNull)
{
auto landBuyRightsAction = LandBuyRightsAction(
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y },
LandBuyRightSetting::BuyConstructionRights);
GameActions::Execute(&landBuyRightsAction);
}
}
OnToolDown(widgetIndex, screenCoords);
}
void OnResize() override