OpenRCT2/src/openrct2-ui/windows/LandRights.cpp

454 lines
15 KiB
C++
Raw Normal View History

2015-05-15 17:28:27 +02:00
/*****************************************************************************
2020-07-21 15:04:34 +02:00
* Copyright (c) 2014-2020 OpenRCT2 developers
2015-05-15 17:28:27 +02:00
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
2015-05-15 17:28:27 +02:00
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
2015-05-15 17:28:27 +02:00
*****************************************************************************/
#include <algorithm>
2018-06-22 23:21:44 +02:00
#include <openrct2-ui/interface/LandTool.h>
#include <openrct2-ui/interface/Viewport.h>
#include <openrct2-ui/interface/Widget.h>
2017-08-06 21:20:05 +02:00
#include <openrct2-ui/windows/Window.h>
2018-06-22 23:21:44 +02:00
#include <openrct2/Context.h>
2017-11-30 18:17:06 +01:00
#include <openrct2/Game.h>
2017-12-12 14:52:57 +01:00
#include <openrct2/Input.h>
Split actions hpp files into separate h and cpp files (#13548) * Split up SmallSceneryPlace/Remove Added undo function for Remove Scenery * Refactor: Balloon and Banner actions hpp=>h/cpp * Refactor: rename all action *.hpp files to *.cpp This is preparation for separation in later commits. Note that without the complete set of commits in this branch, the code will not build. * Refactor Clear, Climate, Custom, and Footpath actions hpp=>h/cpp * VSCode: add src subdirectories to includePath * Refactor Guest actions hpp=>h/cpp * Refactor Land actions hpp=>h/cpp * Refactor LargeScenery actions hpp=>h/cpp * Refactor Load, Maze, Network actions hpp=>h/cpp * Refactor Park actions hpp=>h/cpp * Refactor/style: move private function declarations in actions *.h Previous action .h files included private function declarations with private member variables, before public function declarations. This commit re-orders the header files to the following order: - public member variables - private member variables - public functions - private functions * Refactor Pause action hpp=>h/cpp * Refactor Peep, Place, Player actions hpp=>h/cpp * Refactor Ride actions hpp=>h/cpp * Refactor Scenario, Set*, Sign* actions hpp=>h/cpp * Refactor SmallScenerySetColourAction hpp=>h/cpp * Refactor Staff actions hpp=>h/cpp * Refactor Surface, Tile, Track* actions hpp=>h/cpp * Refactor Wall and Water actions hpp=>h/cpp * Fix various includes and other compile errors Update includes for tests. Move static function declarations to .h files Add explicit includes to various files that were previously implicit (the required header was a nested include in an action hpp file, and the action .h file does not include that header) Move RideSetStatus string enum to the cpp file to avoid unused imports * Xcode: modify project file for actions refactor * Cleanup whitespace and end-of-file newlines Co-authored-by: duncanspumpkin <duncans_pumpkin@hotmail.co.uk>
2020-12-10 07:39:10 +01:00
#include <openrct2/actions/LandBuyRightsAction.h>
2018-03-19 23:28:40 +01:00
#include <openrct2/drawing/Drawing.h>
2018-06-22 23:21:44 +02:00
#include <openrct2/localisation/Localisation.h>
2018-03-19 23:28:40 +01:00
#include <openrct2/world/Park.h>
2015-05-15 17:28:27 +02:00
2020-05-05 22:26:14 +02:00
static constexpr const rct_string_id WINDOW_TITLE = STR_LAND_RIGHTS;
static constexpr const int32_t WH = 94;
static constexpr const int32_t WW = 98;
// clang-format off
2021-01-13 23:00:35 +01:00
enum WINDOW_LAND_RIGHTS_WIDGET_IDX {
WIDX_BACKGROUND,
WIDX_TITLE,
WIDX_CLOSE,
WIDX_PREVIEW,
WIDX_DECREMENT,
WIDX_INCREMENT,
WIDX_BUY_LAND_RIGHTS,
WIDX_BUY_CONSTRUCTION_RIGHTS
2015-05-15 17:28:27 +02:00
};
2015-05-15 17:28:27 +02:00
static rct_widget window_land_rights_widgets[] = {
2020-05-09 16:44:21 +02:00
WINDOW_SHIM(WINDOW_TITLE, WW, WH),
MakeWidget ({27, 17}, {44, 32}, WindowWidgetType::ImgBtn, WindowColour::Primary , SPR_LAND_TOOL_SIZE_0 ), // preview box
MakeRemapWidget({28, 18}, {16, 16}, WindowWidgetType::TrnBtn, WindowColour::Tertiary, SPR_LAND_TOOL_DECREASE, STR_ADJUST_SMALLER_LAND_RIGHTS_TIP), // decrement size
MakeRemapWidget({54, 32}, {16, 16}, WindowWidgetType::TrnBtn, WindowColour::Tertiary, SPR_LAND_TOOL_INCREASE, STR_ADJUST_LARGER_LAND_RIGHTS_TIP ), // increment size
MakeRemapWidget({22, 53}, {24, 24}, WindowWidgetType::FlatBtn, WindowColour::Tertiary, SPR_BUY_LAND_RIGHTS, STR_BUY_LAND_RIGHTS_TIP ), // land rights
MakeRemapWidget({52, 53}, {24, 24}, WindowWidgetType::FlatBtn, WindowColour::Tertiary, SPR_BUY_CONSTRUCTION_RIGHTS, STR_BUY_CONSTRUCTION_RIGHTS_TIP ), // construction rights
{ WIDGETS_END },
2015-05-15 17:28:27 +02:00
};
static void window_land_rights_close(rct_window *w);
2017-05-01 15:41:45 +02:00
static void window_land_rights_mouseup(rct_window *w, rct_widgetindex widgetIndex);
2017-07-14 19:20:42 +02:00
static void window_land_rights_mousedown(rct_window *w, rct_widgetindex widgetIndex, rct_widget *widget);
static void window_land_rights_update(rct_window *w);
static void window_land_rights_invalidate(rct_window *w);
static void window_land_rights_paint(rct_window *w, rct_drawpixelinfo *dpi);
2017-05-01 15:41:45 +02:00
static void window_land_rights_textinput(rct_window *w, rct_widgetindex widgetIndex, char *text);
2015-05-15 17:28:27 +02:00
static void window_land_rights_inputsize(rct_window *w);
static void window_land_rights_toolupdate(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords);
static void window_land_rights_tooldown(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords);
static void window_land_rights_tooldrag(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords);
2017-06-26 20:01:35 +02:00
static void window_land_rights_toolabort(rct_window *w, rct_widgetindex widgetIndex);
static bool land_rights_tool_is_active();
2015-05-15 17:28:27 +02:00
static rct_window_event_list window_land_rights_events([](auto& events)
{
events.close = &window_land_rights_close;
events.mouse_up = &window_land_rights_mouseup;
events.mouse_down = &window_land_rights_mousedown;
events.update = &window_land_rights_update;
events.tool_update = &window_land_rights_toolupdate;
events.tool_down = &window_land_rights_tooldown;
events.tool_drag = &window_land_rights_tooldrag;
events.tool_abort = &window_land_rights_toolabort;
events.text_input = &window_land_rights_textinput;
events.invalidate = &window_land_rights_invalidate;
events.paint = &window_land_rights_paint;
});
// clang-format on
2015-05-15 17:28:27 +02:00
2019-10-24 05:38:13 +02:00
constexpr uint8_t LAND_RIGHTS_MODE_BUY_CONSTRUCTION_RIGHTS = 0;
constexpr uint8_t LAND_RIGHTS_MODE_BUY_LAND = 1;
2017-06-26 20:01:35 +02:00
static uint8_t _landRightsMode;
2017-06-26 20:01:35 +02:00
static money32 _landRightsCost;
2018-06-22 23:21:44 +02:00
rct_window* window_land_rights_open()
2015-05-15 17:28:27 +02:00
{
rct_window* window;
// Check if window is already open
2017-08-06 05:22:00 +02:00
window = window_find_by_class(WC_LAND_RIGHTS);
2017-08-15 10:07:44 +02:00
if (window != nullptr)
2017-08-06 05:22:00 +02:00
return window;
2017-06-26 20:59:52 +02:00
window = WindowCreate(ScreenCoordsXY(context_get_width() - 98, 29), 98, 94, &window_land_rights_events, WC_LAND_RIGHTS, 0);
window->widgets = window_land_rights_widgets;
window->enabled_widgets = (1ULL << WIDX_CLOSE) | (1ULL << WIDX_DECREMENT) | (1ULL << WIDX_INCREMENT)
| (1ULL << WIDX_PREVIEW) | (1ULL << WIDX_BUY_LAND_RIGHTS) | (1ULL << WIDX_BUY_CONSTRUCTION_RIGHTS);
window->hold_down_widgets = (1ULL << WIDX_INCREMENT) | (1ULL << WIDX_DECREMENT);
WindowInitScrollWidgets(window);
window_push_others_below(window);
2017-06-26 20:01:35 +02:00
_landRightsMode = LAND_RIGHTS_MODE_BUY_LAND;
window->pressed_widgets = (1ULL << WIDX_BUY_LAND_RIGHTS);
2017-06-22 20:49:13 +02:00
gLandToolSize = 1;
2017-06-26 20:01:35 +02:00
show_gridlines();
tool_set(window, WIDX_BUY_LAND_RIGHTS, Tool::UpArrow);
2017-06-26 20:01:35 +02:00
input_set_flag(INPUT_FLAG_6, true);
2017-06-26 20:59:52 +02:00
show_land_rights();
2018-06-22 23:21:44 +02:00
if (gLandRemainingConstructionSales == 0)
{
show_construction_rights();
}
2017-08-06 05:22:00 +02:00
return window;
2015-05-15 17:28:27 +02:00
}
2018-06-22 23:21:44 +02:00
static void window_land_rights_close(rct_window* w)
2015-05-15 17:28:27 +02:00
{
2018-06-22 23:21:44 +02:00
if (gLandRemainingConstructionSales == 0)
{
hide_construction_rights();
}
// If the tool wasn't changed, turn tool off
if (land_rights_tool_is_active())
tool_cancel();
2015-05-15 17:28:27 +02:00
}
2018-06-22 23:21:44 +02:00
static void window_land_rights_mouseup(rct_window* w, rct_widgetindex widgetIndex)
2015-05-15 17:28:27 +02:00
{
2018-06-22 23:21:44 +02:00
switch (widgetIndex)
{
case WIDX_CLOSE:
window_close(w);
break;
case WIDX_PREVIEW:
window_land_rights_inputsize(w);
break;
case WIDX_BUY_LAND_RIGHTS:
if (_landRightsMode != LAND_RIGHTS_MODE_BUY_LAND)
{
tool_set(w, WIDX_BUY_LAND_RIGHTS, Tool::UpArrow);
2018-06-22 23:21:44 +02:00
_landRightsMode = LAND_RIGHTS_MODE_BUY_LAND;
show_land_rights();
w->Invalidate();
2018-06-22 23:21:44 +02:00
}
break;
case WIDX_BUY_CONSTRUCTION_RIGHTS:
if (_landRightsMode != LAND_RIGHTS_MODE_BUY_CONSTRUCTION_RIGHTS)
{
tool_set(w, WIDX_BUY_CONSTRUCTION_RIGHTS, Tool::UpArrow);
2018-06-22 23:21:44 +02:00
_landRightsMode = LAND_RIGHTS_MODE_BUY_CONSTRUCTION_RIGHTS;
show_construction_rights();
w->Invalidate();
2018-06-22 23:21:44 +02:00
}
break;
}
2015-05-15 17:28:27 +02:00
}
2018-06-22 23:21:44 +02:00
static void window_land_rights_mousedown(rct_window* w, rct_widgetindex widgetIndex, rct_widget* widget)
2017-07-04 01:49:37 +02:00
{
2018-06-22 23:21:44 +02:00
switch (widgetIndex)
{
case WIDX_DECREMENT:
// Decrement land rights tool size
gLandToolSize = std::max(MINIMUM_TOOL_SIZE, gLandToolSize - 1);
2017-07-04 01:49:37 +02:00
2018-06-22 23:21:44 +02:00
// Invalidate the window
w->Invalidate();
2018-06-22 23:21:44 +02:00
break;
case WIDX_INCREMENT:
// Decrement land rights tool size
gLandToolSize = std::min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1);
2017-07-04 01:49:37 +02:00
2018-06-22 23:21:44 +02:00
// Invalidate the window
w->Invalidate();
2018-06-22 23:21:44 +02:00
break;
2017-07-04 01:49:37 +02:00
}
}
2018-06-22 23:21:44 +02:00
static void window_land_rights_textinput(rct_window* w, rct_widgetindex widgetIndex, char* text)
2015-05-15 17:28:27 +02:00
{
int32_t size;
char* end;
2017-08-15 10:07:44 +02:00
if (widgetIndex != WIDX_PREVIEW || text == nullptr)
return;
size = strtol(text, &end, 10);
2018-06-22 23:21:44 +02:00
if (*end == '\0')
{
size = std::max(MINIMUM_TOOL_SIZE, size);
size = std::min(MAXIMUM_TOOL_SIZE, size);
gLandToolSize = size;
w->Invalidate();
}
2015-05-15 17:28:27 +02:00
}
2018-06-22 23:21:44 +02:00
static void window_land_rights_inputsize(rct_window* w)
2015-05-15 17:28:27 +02:00
{
Formatter ft;
ft.Add<int16_t>(MINIMUM_TOOL_SIZE);
ft.Add<int16_t>(MAXIMUM_TOOL_SIZE);
window_text_input_open(w, WIDX_PREVIEW, STR_SELECTION_SIZE, STR_ENTER_SELECTION_SIZE, ft, STR_NONE, STR_NONE, 3);
2015-05-15 17:28:27 +02:00
}
2018-06-22 23:21:44 +02:00
static void window_land_rights_update(rct_window* w)
2015-05-15 17:28:27 +02:00
{
2017-07-04 01:49:37 +02:00
w->frame_no++;
// Close window if another tool is open
if (!land_rights_tool_is_active())
window_close(w);
2015-05-15 17:28:27 +02:00
}
2018-06-22 23:21:44 +02:00
static void window_land_rights_invalidate(rct_window* w)
2015-05-15 17:28:27 +02:00
{
// Set the preview image button to be pressed down
w->pressed_widgets |= (1ULL << WIDX_PREVIEW)
| (1ULL << ((_landRightsMode == LAND_RIGHTS_MODE_BUY_LAND) ? WIDX_BUY_LAND_RIGHTS : WIDX_BUY_CONSTRUCTION_RIGHTS));
2018-06-22 23:21:44 +02:00
w->pressed_widgets &= ~(
1ULL
2018-06-22 23:21:44 +02:00
<< ((_landRightsMode == LAND_RIGHTS_MODE_BUY_CONSTRUCTION_RIGHTS) ? WIDX_BUY_LAND_RIGHTS
: WIDX_BUY_CONSTRUCTION_RIGHTS));
// Update the preview image
window_land_rights_widgets[WIDX_PREVIEW].image = LandTool::SizeToSpriteIndex(gLandToolSize);
// Disable ownership and/or construction buying functions if there are no tiles left for sale
2018-06-22 23:21:44 +02:00
if (gLandRemainingOwnershipSales == 0)
{
w->disabled_widgets |= (1ULL << WIDX_BUY_LAND_RIGHTS);
window_land_rights_widgets[WIDX_BUY_LAND_RIGHTS].tooltip = STR_NO_LAND_RIGHTS_FOR_SALE_TIP;
2018-06-22 23:21:44 +02:00
}
else
{
w->disabled_widgets &= ~(1ULL << WIDX_BUY_LAND_RIGHTS);
window_land_rights_widgets[WIDX_BUY_LAND_RIGHTS].tooltip = STR_BUY_LAND_RIGHTS_TIP;
}
2018-06-22 23:21:44 +02:00
if (gLandRemainingConstructionSales == 0)
{
w->disabled_widgets |= (1ULL << WIDX_BUY_CONSTRUCTION_RIGHTS);
window_land_rights_widgets[WIDX_BUY_CONSTRUCTION_RIGHTS].tooltip = STR_NO_CONSTRUCTION_RIGHTS_FOR_SALE_TIP;
2018-06-22 23:21:44 +02:00
}
else
{
w->disabled_widgets &= ~(1ULL << WIDX_BUY_CONSTRUCTION_RIGHTS);
window_land_rights_widgets[WIDX_BUY_CONSTRUCTION_RIGHTS].tooltip = STR_BUY_CONSTRUCTION_RIGHTS_TIP;
}
2015-05-15 17:28:27 +02:00
}
2018-06-22 23:21:44 +02:00
static void window_land_rights_paint(rct_window* w, rct_drawpixelinfo* dpi)
2015-05-15 17:28:27 +02:00
{
auto screenCoords = ScreenCoordsXY{ w->windowPos.x + window_land_rights_widgets[WIDX_PREVIEW].midX(),
w->windowPos.y + window_land_rights_widgets[WIDX_PREVIEW].midY() };
WindowDrawWidgets(w, dpi);
// Draw number for tool sizes bigger than 7
2018-06-22 23:21:44 +02:00
if (gLandToolSize > MAX_TOOL_SIZE_WITH_SPRITE)
{
auto ft = Formatter();
ft.Add<uint16_t>(gLandToolSize);
DrawTextBasic(dpi, screenCoords - ScreenCoordsXY{ 0, 2 }, STR_LAND_TOOL_SIZE_VALUE, ft, { TextAlignment::CENTRE });
}
// Draw cost amount
if (_landRightsCost != MONEY32_UNDEFINED && _landRightsCost != 0 && !(gParkFlags & PARK_FLAGS_NO_MONEY))
2018-06-22 23:21:44 +02:00
{
auto ft = Formatter();
ft.Add<money64>(_landRightsCost);
screenCoords = { window_land_rights_widgets[WIDX_PREVIEW].midX() + w->windowPos.x,
window_land_rights_widgets[WIDX_PREVIEW].bottom + w->windowPos.y + 32 };
DrawTextBasic(dpi, screenCoords, STR_COST_AMOUNT, ft, { TextAlignment::CENTRE });
2017-06-26 20:01:35 +02:00
}
}
static void window_land_rights_tool_update_land_rights(const ScreenCoordsXY& screenCoords)
2017-06-26 20:01:35 +02:00
{
map_invalidate_selection_rect();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
2017-06-26 20:59:52 +02:00
auto mapTile = screen_get_map_xy(screenCoords, nullptr);
2017-06-26 20:59:52 +02:00
2021-09-13 18:47:13 +02:00
if (!mapTile.has_value())
2018-06-22 23:21:44 +02:00
{
if (_landRightsCost != MONEY32_UNDEFINED)
{
2017-06-26 20:01:35 +02:00
_landRightsCost = MONEY32_UNDEFINED;
window_invalidate_by_class(WC_CLEAR_SCENERY);
}
return;
}
2017-06-26 20:59:52 +02:00
uint8_t state_changed = 0;
2017-06-26 20:59:52 +02:00
2018-06-22 23:21:44 +02:00
if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE))
{
2017-06-26 20:01:35 +02:00
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
state_changed++;
}
2017-06-26 20:59:52 +02:00
2018-06-22 23:21:44 +02:00
if (gMapSelectType != MAP_SELECT_TYPE_FULL)
{
2017-06-26 20:01:35 +02:00
gMapSelectType = MAP_SELECT_TYPE_FULL;
state_changed++;
}
2017-06-26 20:59:52 +02:00
int16_t tool_size = gLandToolSize;
2017-06-26 20:01:35 +02:00
if (tool_size == 0)
tool_size = 1;
2017-06-26 20:59:52 +02:00
int16_t tool_length = (tool_size - 1) * 32;
2017-06-26 20:59:52 +02:00
2017-06-26 20:01:35 +02:00
// Move to tool bottom left
mapTile->x -= (tool_size - 1) * 16;
mapTile->y -= (tool_size - 1) * 16;
mapTile = mapTile->ToTileStart();
2017-06-26 20:59:52 +02:00
if (gMapSelectPositionA.x != mapTile->x)
2018-06-22 23:21:44 +02:00
{
gMapSelectPositionA.x = mapTile->x;
2017-06-26 20:01:35 +02:00
state_changed++;
}
2017-06-26 20:59:52 +02:00
if (gMapSelectPositionA.y != mapTile->y)
2018-06-22 23:21:44 +02:00
{
gMapSelectPositionA.y = mapTile->y;
2017-06-26 20:01:35 +02:00
state_changed++;
}
2017-06-26 20:59:52 +02:00
mapTile->x += tool_length;
mapTile->y += tool_length;
2017-06-26 20:59:52 +02:00
if (gMapSelectPositionB.x != mapTile->x)
2018-06-22 23:21:44 +02:00
{
gMapSelectPositionB.x = mapTile->x;
2017-06-26 20:01:35 +02:00
state_changed++;
}
2017-06-26 20:59:52 +02:00
if (gMapSelectPositionB.y != mapTile->y)
2018-06-22 23:21:44 +02:00
{
gMapSelectPositionB.y = mapTile->y;
2017-06-26 20:01:35 +02:00
state_changed++;
}
2017-06-26 20:59:52 +02:00
2017-06-26 20:01:35 +02:00
map_invalidate_selection_rect();
if (!state_changed)
return;
2017-06-26 20:59:52 +02:00
2019-03-17 09:25:51 +01:00
auto landBuyRightsAction = LandBuyRightsAction(
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y },
(_landRightsMode == LAND_RIGHTS_MODE_BUY_LAND) ? LandBuyRightSetting::BuyLand
: LandBuyRightSetting::BuyConstructionRights);
auto res = GameActions::Query(&landBuyRightsAction);
_landRightsCost = res->Error == GameActions::Status::Ok ? res->Cost : MONEY32_UNDEFINED;
2017-06-26 20:01:35 +02:00
}
/**
*
* rct2: 0x0066822A
*/
2018-06-22 23:21:44 +02:00
static void window_land_rights_toolabort(rct_window* w, rct_widgetindex widgetIndex)
2017-06-26 20:01:35 +02:00
{
hide_gridlines();
if (_landRightsMode == LAND_RIGHTS_MODE_BUY_LAND)
{
hide_land_rights();
}
2017-06-26 20:01:35 +02:00
else
{
hide_construction_rights();
}
}
/**
*
* rct2: 0x006681D1
*/
static void window_land_rights_toolupdate(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords)
2017-06-26 20:01:35 +02:00
{
window_land_rights_tool_update_land_rights(screenCoords);
2017-06-26 20:01:35 +02:00
}
/**
*
* rct2: 0x006681E6
*/
static void window_land_rights_tooldown(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords)
2017-06-26 20:01:35 +02:00
{
if (_landRightsMode == LAND_RIGHTS_MODE_BUY_LAND)
{
if (screenCoords.x != LOCATION_NULL)
2017-06-26 20:01:35 +02:00
{
2019-03-17 09:25:51 +01:00
auto landBuyRightsAction = LandBuyRightsAction(
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y },
LandBuyRightSetting::BuyLand);
GameActions::Execute(&landBuyRightsAction);
2017-06-26 20:01:35 +02:00
}
}
else
{
if (screenCoords.x != LOCATION_NULL)
2017-06-26 20:01:35 +02:00
{
2019-03-17 09:25:51 +01:00
auto landBuyRightsAction = LandBuyRightsAction(
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y },
LandBuyRightSetting::BuyConstructionRights);
GameActions::Execute(&landBuyRightsAction);
2017-06-26 20:01:35 +02:00
}
}
}
/**
*
* rct2: 0x006681FB
*/
static void window_land_rights_tooldrag(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords)
2017-06-26 20:01:35 +02:00
{
2018-06-22 23:21:44 +02:00
if (_landRightsMode == LAND_RIGHTS_MODE_BUY_LAND)
{
if (screenCoords.x != LOCATION_NULL)
2017-06-26 20:01:35 +02:00
{
2019-03-17 09:25:51 +01:00
auto landBuyRightsAction = LandBuyRightsAction(
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y },
LandBuyRightSetting::BuyLand);
GameActions::Execute(&landBuyRightsAction);
2017-06-26 20:01:35 +02:00
}
}
else
{
if (screenCoords.x != LOCATION_NULL)
2017-06-26 20:01:35 +02:00
{
2019-03-17 09:25:51 +01:00
auto landBuyRightsAction = LandBuyRightsAction(
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y },
LandBuyRightSetting::BuyConstructionRights);
GameActions::Execute(&landBuyRightsAction);
2017-06-26 20:01:35 +02:00
}
}
}
static bool land_rights_tool_is_active()
{
if (!(input_test_flag(INPUT_FLAG_TOOL_ACTIVE)))
return false;
if (gCurrentToolWidget.window_classification != WC_LAND_RIGHTS)
return false;
return true;
2015-05-15 17:28:27 +02:00
}