2014-05-14 12:43:14 +02:00
|
|
|
/*****************************************************************************
|
2023-01-01 11:58:01 +01:00
|
|
|
* Copyright (c) 2014-2023 OpenRCT2 developers
|
2014-05-14 12:43:14 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* For a complete list of all authors, please refer to contributors.md
|
|
|
|
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
2014-05-14 12:43:14 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
2014-05-14 12:43:14 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2018-01-21 03:25:20 +01: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>
|
|
|
|
#include <openrct2-ui/windows/Window.h>
|
2018-01-21 03:25:20 +01:00
|
|
|
#include <openrct2/Cheats.h>
|
|
|
|
#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>
|
2018-01-21 03:25:20 +01:00
|
|
|
#include <openrct2/OpenRCT2.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/LandSetRightsAction.h>
|
2023-01-02 13:52:38 +01:00
|
|
|
#include <openrct2/actions/MapChangeSizeAction.h>
|
2023-01-05 10:39:15 +01:00
|
|
|
#include <openrct2/actions/ParkEntrancePlaceAction.h>
|
|
|
|
#include <openrct2/actions/PeepSpawnPlaceAction.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/SurfaceSetStyleAction.h>
|
2018-06-22 23:21:44 +02:00
|
|
|
#include <openrct2/audio/audio.h>
|
2021-11-24 16:19:52 +01:00
|
|
|
#include <openrct2/entity/EntityList.h>
|
|
|
|
#include <openrct2/entity/EntityRegistry.h>
|
2021-11-25 22:47:24 +01:00
|
|
|
#include <openrct2/entity/Staff.h>
|
2021-12-12 00:06:06 +01:00
|
|
|
#include <openrct2/localisation/Formatter.h>
|
2022-01-01 16:52:49 +01:00
|
|
|
#include <openrct2/object/TerrainSurfaceObject.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/ride/RideData.h>
|
2017-11-14 13:21:55 +01:00
|
|
|
#include <openrct2/ride/Track.h>
|
2021-03-15 09:13:00 +01:00
|
|
|
#include <openrct2/ride/TrainManager.h>
|
2021-05-29 07:01:32 +02:00
|
|
|
#include <openrct2/ride/Vehicle.h>
|
2017-12-14 10:34:12 +01:00
|
|
|
#include <openrct2/world/Entrance.h>
|
2018-01-11 10:59:26 +01:00
|
|
|
#include <openrct2/world/Footpath.h>
|
|
|
|
#include <openrct2/world/Scenery.h>
|
2018-05-01 16:33:16 +02:00
|
|
|
#include <openrct2/world/Surface.h>
|
2018-06-22 23:21:44 +02:00
|
|
|
#include <vector>
|
2014-10-15 23:59:26 +02:00
|
|
|
|
2021-01-23 07:45:14 +01:00
|
|
|
static constexpr uint16_t MapColour2(uint8_t colourA, uint8_t colourB)
|
|
|
|
{
|
|
|
|
return (colourA << 8) | colourB;
|
|
|
|
}
|
|
|
|
static constexpr uint16_t MapColour(uint8_t colour)
|
|
|
|
{
|
|
|
|
return MapColour2(colour, colour);
|
|
|
|
}
|
|
|
|
static constexpr uint16_t MapColourUnowned(uint16_t colour)
|
|
|
|
{
|
|
|
|
return MapColour2((colour & 0xFF00) >> 8, PALETTE_INDEX_10);
|
|
|
|
}
|
2017-05-21 00:01:45 +02:00
|
|
|
|
2019-10-24 05:38:13 +02:00
|
|
|
constexpr int32_t MAP_WINDOW_MAP_SIZE = MAXIMUM_MAP_SIZE_TECHNICAL * 2;
|
2017-06-03 12:52:34 +02:00
|
|
|
|
2022-07-31 14:22:58 +02:00
|
|
|
static constexpr const StringId WINDOW_TITLE = STR_MAP_LABEL;
|
2020-05-05 22:26:14 +02:00
|
|
|
static constexpr const int32_t WH = 259;
|
|
|
|
static constexpr const int32_t WW = 245;
|
2019-10-19 04:02:31 +02:00
|
|
|
|
2018-03-08 21:11:34 +01:00
|
|
|
// Some functions manipulate coordinates on the map. These are the coordinates of the pixels in the
|
|
|
|
// minimap. In order to distinguish those from actual coordinates, we use a separate name.
|
|
|
|
using MapCoordsXY = TileCoordsXY;
|
|
|
|
|
2021-10-17 15:31:56 +02:00
|
|
|
enum
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
PAGE_PEEPS,
|
|
|
|
PAGE_RIDES
|
2015-07-01 01:58:13 +02:00
|
|
|
};
|
2014-05-14 12:43:14 +02:00
|
|
|
|
2021-11-26 15:25:34 +01:00
|
|
|
enum WindowMapWidgetIdx
|
2021-10-17 15:31:56 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
WIDX_BACKGROUND,
|
|
|
|
WIDX_TITLE,
|
|
|
|
WIDX_CLOSE,
|
2022-05-15 22:25:45 +02:00
|
|
|
WIDX_RESIZE,
|
|
|
|
WIDX_PEOPLE_TAB,
|
|
|
|
WIDX_RIDES_TAB,
|
|
|
|
WIDX_MAP,
|
|
|
|
WIDX_MAP_SIZE_SPINNER_Y,
|
|
|
|
WIDX_MAP_SIZE_SPINNER_Y_UP,
|
|
|
|
WIDX_MAP_SIZE_SPINNER_Y_DOWN,
|
|
|
|
WIDX_MAP_SIZE_LINK,
|
|
|
|
WIDX_MAP_SIZE_SPINNER_X,
|
|
|
|
WIDX_MAP_SIZE_SPINNER_X_UP,
|
|
|
|
WIDX_MAP_SIZE_SPINNER_X_DOWN,
|
|
|
|
WIDX_SET_LAND_RIGHTS,
|
|
|
|
WIDX_BUILD_PARK_ENTRANCE,
|
|
|
|
WIDX_PEOPLE_STARTING_POSITION,
|
|
|
|
WIDX_LAND_TOOL,
|
|
|
|
WIDX_LAND_TOOL_SMALLER,
|
|
|
|
WIDX_LAND_TOOL_LARGER,
|
|
|
|
WIDX_LAND_OWNED_CHECKBOX,
|
|
|
|
WIDX_CONSTRUCTION_RIGHTS_OWNED_CHECKBOX,
|
|
|
|
WIDX_LAND_SALE_CHECKBOX,
|
|
|
|
WIDX_CONSTRUCTION_RIGHTS_SALE_CHECKBOX,
|
|
|
|
WIDX_ROTATE_90,
|
|
|
|
WIDX_MAP_GENERATOR
|
2014-05-14 12:43:14 +02:00
|
|
|
};
|
|
|
|
|
2017-05-02 02:01:29 +02:00
|
|
|
validate_global_widx(WC_MAP, WIDX_ROTATE_90);
|
|
|
|
|
2021-10-17 15:31:56 +02:00
|
|
|
// clang-format off
|
2022-12-24 16:50:29 +01:00
|
|
|
static Widget window_map_widgets[] = {
|
2020-05-09 16:44:21 +02:00
|
|
|
WINDOW_SHIM(WINDOW_TITLE, WW, WH),
|
2020-11-27 04:14:20 +01:00
|
|
|
MakeWidget ({ 0, 43}, {245, 215}, WindowWidgetType::Resize, WindowColour::Secondary ),
|
|
|
|
MakeRemapWidget ({ 3, 17}, { 31, 27}, WindowWidgetType::ColourBtn, WindowColour::Secondary, SPR_TAB, STR_SHOW_PEOPLE_ON_MAP_TIP ),
|
|
|
|
MakeRemapWidget ({ 34, 17}, { 31, 27}, WindowWidgetType::ColourBtn, WindowColour::Secondary, SPR_TAB, STR_SHOW_RIDES_STALLS_ON_MAP_TIP ),
|
|
|
|
MakeWidget ({ 3, 46}, {239, 180}, WindowWidgetType::Scroll, WindowColour::Secondary, SCROLL_BOTH ),
|
2022-05-15 22:25:45 +02:00
|
|
|
MakeSpinnerWidgets({102, 229}, { 50, 12}, WindowWidgetType::Spinner, WindowColour::Secondary, STR_COMMA16 ), // NB: 3 widgets
|
2022-12-24 17:47:22 +01:00
|
|
|
MakeWidget ({153, 230}, { 20, 12}, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_G2_LINK_CHAIN), STR_MAINTAIN_SQUARE_MAP_TOOLTIP ),
|
2022-05-15 22:25:45 +02:00
|
|
|
MakeSpinnerWidgets({174, 229}, { 50, 12}, WindowWidgetType::Spinner, WindowColour::Secondary, STR_POP16_COMMA16 ), // NB: 3 widgets
|
2022-12-24 17:47:22 +01:00
|
|
|
MakeWidget ({ 4, 1}, { 24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_BUY_LAND_RIGHTS), STR_SELECT_PARK_OWNED_LAND_TIP ),
|
|
|
|
MakeWidget ({ 4, 1}, { 24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_PARK_ENTRANCE), STR_BUILD_PARK_ENTRANCE_TIP ),
|
2020-11-27 04:14:20 +01:00
|
|
|
MakeWidget ({ 28, 1}, { 24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, 0xFFFFFFFF, STR_SET_STARTING_POSITIONS_TIP ),
|
2022-12-24 17:47:22 +01:00
|
|
|
MakeWidget ({ 4, 17}, { 44, 32}, WindowWidgetType::ImgBtn, WindowColour::Secondary, ImageId(SPR_LAND_TOOL_SIZE_0) ),
|
2020-11-27 04:14:20 +01:00
|
|
|
MakeRemapWidget ({ 5, 18}, { 16, 16}, WindowWidgetType::TrnBtn, WindowColour::Secondary, SPR_LAND_TOOL_DECREASE, STR_ADJUST_SMALLER_LAND_TIP ),
|
|
|
|
MakeRemapWidget ({ 31, 32}, { 16, 16}, WindowWidgetType::TrnBtn, WindowColour::Secondary, SPR_LAND_TOOL_INCREASE, STR_ADJUST_LARGER_LAND_TIP ),
|
|
|
|
MakeWidget ({ 58, 197}, {184, 12}, WindowWidgetType::Checkbox, WindowColour::Secondary, STR_LAND_OWNED, STR_SET_LAND_TO_BE_OWNED_TIP ),
|
|
|
|
MakeWidget ({ 58, 197}, {184, 12}, WindowWidgetType::Checkbox, WindowColour::Secondary, STR_CONSTRUCTION_RIGHTS_OWNED, STR_SET_CONSTRUCTION_RIGHTS_TO_BE_OWNED_TIP ),
|
|
|
|
MakeWidget ({ 58, 197}, {184, 12}, WindowWidgetType::Checkbox, WindowColour::Secondary, STR_LAND_SALE, STR_SET_LAND_TO_BE_AVAILABLE_TIP ),
|
|
|
|
MakeWidget ({ 58, 197}, {174, 12}, WindowWidgetType::Checkbox, WindowColour::Secondary, STR_CONSTRUCTION_RIGHTS_SALE, STR_SET_CONSTRUCTION_RIGHTS_TO_BE_AVAILABLE_TIP),
|
2022-12-24 17:47:22 +01:00
|
|
|
MakeWidget ({218, 45}, { 24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, ImageId(SPR_ROTATE_ARROW), STR_ROTATE_OBJECTS_90 ),
|
2020-11-27 04:14:20 +01:00
|
|
|
MakeWidget ({110, 189}, {131, 14}, WindowWidgetType::Button, WindowColour::Secondary, STR_MAPGEN_WINDOW_TITLE, STR_MAP_GENERATOR_TIP ),
|
2021-09-26 11:11:42 +02:00
|
|
|
WIDGETS_END,
|
2014-05-14 12:43:14 +02:00
|
|
|
};
|
|
|
|
|
2015-02-17 15:54:42 +01:00
|
|
|
// used in transforming viewport view coordinates to minimap coordinates
|
2015-07-01 01:58:13 +02:00
|
|
|
// rct2: 0x00981BBC
|
2020-03-01 21:24:44 +01:00
|
|
|
static constexpr const ScreenCoordsXY MiniMapOffsets[] = {
|
2018-03-08 20:44:12 +01:00
|
|
|
{ MAXIMUM_MAP_SIZE_TECHNICAL - 8, 0 },
|
|
|
|
{ 2 * MAXIMUM_MAP_SIZE_TECHNICAL - 8, MAXIMUM_MAP_SIZE_TECHNICAL },
|
|
|
|
{ MAXIMUM_MAP_SIZE_TECHNICAL - 8, 2 * MAXIMUM_MAP_SIZE_TECHNICAL },
|
2021-10-17 15:31:56 +02:00
|
|
|
{ 0 - 8, MAXIMUM_MAP_SIZE_TECHNICAL },
|
2015-07-01 01:58:13 +02:00
|
|
|
};
|
2021-10-17 15:31:56 +02:00
|
|
|
// clang-format on
|
2015-02-17 15:54:42 +01:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
class MapWindow final : public Window
|
2014-05-14 12:43:14 +02:00
|
|
|
{
|
2022-06-07 23:08:49 +02:00
|
|
|
uint8_t _rotation;
|
2022-06-07 10:34:44 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
public:
|
|
|
|
MapWindow()
|
|
|
|
{
|
|
|
|
_mapImageData.resize(MAP_WINDOW_MAP_SIZE * MAP_WINDOW_MAP_SIZE);
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
void OnOpen() override
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
widgets = window_map_widgets;
|
|
|
|
|
2022-10-17 19:21:18 +02:00
|
|
|
hold_down_widgets = (1uLL << WIDX_MAP_SIZE_SPINNER_Y_UP) | (1uLL << WIDX_MAP_SIZE_SPINNER_Y_DOWN)
|
|
|
|
| (1uLL << WIDX_MAP_SIZE_SPINNER_X_UP) | (1uLL << WIDX_MAP_SIZE_SPINNER_X_DOWN) | (1uLL << WIDX_LAND_TOOL_LARGER)
|
|
|
|
| (1uLL << WIDX_LAND_TOOL_SMALLER);
|
2022-02-26 21:23:27 +01:00
|
|
|
|
|
|
|
InitScrollWidgets();
|
|
|
|
|
2023-01-16 21:14:50 +01:00
|
|
|
_rotation = GetCurrentRotation();
|
2022-02-26 21:23:27 +01:00
|
|
|
|
|
|
|
InitMap();
|
|
|
|
gWindowSceneryRotation = 0;
|
|
|
|
CentreMapOnViewPoint();
|
2022-07-02 16:02:27 +02:00
|
|
|
FootpathSelectDefault();
|
2022-02-26 21:23:27 +01:00
|
|
|
|
2022-08-28 09:36:18 +02:00
|
|
|
_mapWidthAndHeightLinked = gMapSize.x == gMapSize.y;
|
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
// Reset land rights tool size
|
|
|
|
_landRightsToolSize = 1;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
void OnClose() override
|
2018-01-21 03:25:20 +01:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
_mapImageData.clear();
|
|
|
|
_mapImageData.shrink_to_fit();
|
2023-01-17 13:24:51 +01:00
|
|
|
if ((InputTestFlag(INPUT_FLAG_TOOL_ACTIVE)) && gCurrentToolWidget.window_classification == classification
|
2022-02-26 21:23:27 +01:00
|
|
|
&& gCurrentToolWidget.window_number == number)
|
|
|
|
{
|
2023-01-16 21:13:42 +01:00
|
|
|
ToolCancel();
|
2022-02-26 21:23:27 +01:00
|
|
|
}
|
2018-01-21 03:25:20 +01:00
|
|
|
}
|
2022-02-26 21:23:27 +01:00
|
|
|
|
|
|
|
void OnResize() override
|
2018-01-21 03:25:20 +01:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
flags |= WF_RESIZABLE;
|
|
|
|
min_width = 245;
|
|
|
|
max_width = 800;
|
|
|
|
min_height = 259;
|
|
|
|
max_height = 560;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2022-08-21 18:49:23 +02:00
|
|
|
void OnMouseUp(WidgetIndex widgetIndex) override
|
2022-02-26 21:23:27 +01:00
|
|
|
{
|
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_CLOSE:
|
|
|
|
Close();
|
|
|
|
break;
|
|
|
|
case WIDX_SET_LAND_RIGHTS:
|
|
|
|
Invalidate();
|
2023-01-16 21:13:42 +01:00
|
|
|
if (ToolSet(*this, widgetIndex, Tool::UpArrow))
|
2022-02-26 21:23:27 +01:00
|
|
|
break;
|
|
|
|
_activeTool = 2;
|
|
|
|
// Prevent mountain tool size.
|
|
|
|
_landRightsToolSize = std::max<uint16_t>(MINIMUM_TOOL_SIZE, _landRightsToolSize);
|
2023-01-16 21:14:50 +01:00
|
|
|
ShowGridlines();
|
|
|
|
ShowLandRights();
|
|
|
|
ShowConstructionRights();
|
2022-02-26 21:23:27 +01:00
|
|
|
break;
|
|
|
|
case WIDX_LAND_OWNED_CHECKBOX:
|
|
|
|
_activeTool ^= 2;
|
2018-06-22 23:21:44 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
if (_activeTool & 2)
|
|
|
|
_activeTool &= 0xF2;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
Invalidate();
|
|
|
|
break;
|
|
|
|
case WIDX_LAND_SALE_CHECKBOX:
|
|
|
|
_activeTool ^= 8;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
if (_activeTool & 8)
|
|
|
|
_activeTool &= 0xF8;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
Invalidate();
|
|
|
|
break;
|
|
|
|
case WIDX_CONSTRUCTION_RIGHTS_OWNED_CHECKBOX:
|
|
|
|
_activeTool ^= 1;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
if (_activeTool & 1)
|
|
|
|
_activeTool &= 0xF1;
|
2017-10-06 23:03:48 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
Invalidate();
|
|
|
|
break;
|
|
|
|
case WIDX_CONSTRUCTION_RIGHTS_SALE_CHECKBOX:
|
|
|
|
_activeTool ^= 4;
|
2014-05-14 12:43:14 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
if (_activeTool & 4)
|
|
|
|
_activeTool &= 0xF4;
|
2017-02-09 19:54:03 +01:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
Invalidate();
|
|
|
|
break;
|
|
|
|
case WIDX_BUILD_PARK_ENTRANCE:
|
|
|
|
Invalidate();
|
2023-01-16 21:13:42 +01:00
|
|
|
if (ToolSet(*this, widgetIndex, Tool::UpArrow))
|
2022-02-26 21:23:27 +01:00
|
|
|
break;
|
2017-02-09 19:54:03 +01:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
gParkEntranceGhostExists = false;
|
2023-01-17 13:24:51 +01:00
|
|
|
InputSetFlag(INPUT_FLAG_6, true);
|
2017-02-09 19:54:03 +01:00
|
|
|
|
2023-01-16 21:14:50 +01:00
|
|
|
ShowGridlines();
|
|
|
|
ShowLandRights();
|
|
|
|
ShowConstructionRights();
|
2022-02-26 21:23:27 +01:00
|
|
|
break;
|
|
|
|
case WIDX_ROTATE_90:
|
|
|
|
gWindowSceneryRotation = (gWindowSceneryRotation + 1) & 3;
|
|
|
|
break;
|
|
|
|
case WIDX_PEOPLE_STARTING_POSITION:
|
2023-01-16 21:13:42 +01:00
|
|
|
if (ToolSet(*this, widgetIndex, Tool::UpArrow))
|
2022-02-26 21:23:27 +01:00
|
|
|
break;
|
|
|
|
|
2023-01-16 21:14:50 +01:00
|
|
|
ShowGridlines();
|
|
|
|
ShowLandRights();
|
|
|
|
ShowConstructionRights();
|
2022-02-26 21:23:27 +01:00
|
|
|
break;
|
|
|
|
case WIDX_LAND_TOOL:
|
|
|
|
InputLandSize();
|
|
|
|
break;
|
2022-05-15 22:25:45 +02:00
|
|
|
case WIDX_MAP_SIZE_SPINNER_Y:
|
|
|
|
case WIDX_MAP_SIZE_SPINNER_X:
|
|
|
|
InputMapSize(widgetIndex);
|
|
|
|
break;
|
|
|
|
case WIDX_MAP_SIZE_LINK:
|
|
|
|
_mapWidthAndHeightLinked = !_mapWidthAndHeightLinked;
|
2022-02-26 21:23:27 +01:00
|
|
|
break;
|
|
|
|
case WIDX_MAP_GENERATOR:
|
2022-11-06 21:49:07 +01:00
|
|
|
ContextOpenWindow(WindowClass::Mapgen);
|
2022-02-26 21:23:27 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (widgetIndex >= WIDX_PEOPLE_TAB && widgetIndex <= WIDX_RIDES_TAB)
|
|
|
|
{
|
|
|
|
widgetIndex -= WIDX_PEOPLE_TAB;
|
|
|
|
if (widgetIndex == selected_tab)
|
|
|
|
break;
|
|
|
|
|
|
|
|
selected_tab = widgetIndex;
|
|
|
|
list_information_type = 0;
|
|
|
|
}
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-05-14 12:49:40 +02:00
|
|
|
|
2022-08-21 18:49:23 +02:00
|
|
|
void OnMouseDown(WidgetIndex widgetIndex) override
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
2022-05-15 22:25:45 +02:00
|
|
|
case WIDX_MAP_SIZE_SPINNER_Y_UP:
|
|
|
|
_resizeDirection = ResizeDirection::Y;
|
|
|
|
IncreaseMapSize();
|
|
|
|
break;
|
|
|
|
case WIDX_MAP_SIZE_SPINNER_Y_DOWN:
|
|
|
|
_resizeDirection = ResizeDirection::Y;
|
|
|
|
DecreaseMapSize();
|
|
|
|
break;
|
|
|
|
case WIDX_MAP_SIZE_SPINNER_X_UP:
|
|
|
|
_resizeDirection = ResizeDirection::X;
|
2022-02-26 21:23:27 +01:00
|
|
|
IncreaseMapSize();
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
2022-05-15 22:25:45 +02:00
|
|
|
case WIDX_MAP_SIZE_SPINNER_X_DOWN:
|
|
|
|
_resizeDirection = ResizeDirection::X;
|
2022-02-26 21:23:27 +01:00
|
|
|
DecreaseMapSize();
|
2017-06-06 23:24:18 +02:00
|
|
|
break;
|
2022-02-26 21:23:27 +01:00
|
|
|
case WIDX_LAND_TOOL_SMALLER:
|
|
|
|
// Decrement land rights tool size
|
|
|
|
_landRightsToolSize = std::max(MINIMUM_TOOL_SIZE, _landRightsToolSize - 1);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
Invalidate();
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
2022-02-26 21:23:27 +01:00
|
|
|
case WIDX_LAND_TOOL_LARGER:
|
|
|
|
// Increment land rights tool size
|
|
|
|
_landRightsToolSize = std::min(MAXIMUM_TOOL_SIZE, _landRightsToolSize + 1);
|
2018-06-22 23:21:44 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
Invalidate();
|
|
|
|
break;
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
void OnUpdate() override
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2023-01-16 21:14:50 +01:00
|
|
|
if (GetCurrentRotation() != _rotation)
|
2022-02-26 21:23:27 +01:00
|
|
|
{
|
2023-01-16 21:14:50 +01:00
|
|
|
_rotation = GetCurrentRotation();
|
2022-02-26 21:23:27 +01:00
|
|
|
InitMap();
|
|
|
|
CentreMapOnViewPoint();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int32_t i = 0; i < 16; i++)
|
|
|
|
SetMapPixels();
|
|
|
|
|
|
|
|
Invalidate();
|
|
|
|
|
|
|
|
// Update tab animations
|
|
|
|
list_information_type++;
|
|
|
|
switch (selected_tab)
|
|
|
|
{
|
|
|
|
case PAGE_PEEPS:
|
|
|
|
if (list_information_type >= 32)
|
|
|
|
{
|
|
|
|
list_information_type = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PAGE_RIDES:
|
|
|
|
if (list_information_type >= 64)
|
|
|
|
{
|
|
|
|
list_information_type = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-05-14 12:43:14 +02:00
|
|
|
|
2022-08-21 18:49:23 +02:00
|
|
|
void OnToolUpdate(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) override
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_SET_LAND_RIGHTS:
|
|
|
|
SetLandRightsToolUpdate(screenCoords);
|
|
|
|
break;
|
|
|
|
case WIDX_BUILD_PARK_ENTRANCE:
|
|
|
|
PlaceParkEntranceToolUpdate(screenCoords);
|
|
|
|
break;
|
|
|
|
case WIDX_PEOPLE_STARTING_POSITION:
|
|
|
|
SetPeepSpawnToolUpdate(screenCoords);
|
|
|
|
break;
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2022-08-21 18:49:23 +02:00
|
|
|
void OnToolDown(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) override
|
2022-02-26 21:23:27 +01:00
|
|
|
{
|
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_BUILD_PARK_ENTRANCE:
|
|
|
|
PlaceParkEntranceToolDown(screenCoords);
|
|
|
|
break;
|
|
|
|
case WIDX_PEOPLE_STARTING_POSITION:
|
|
|
|
SetPeepSpawnToolDown(screenCoords);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-08-21 18:49:23 +02:00
|
|
|
void OnToolDrag(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) override
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_SET_LAND_RIGHTS:
|
|
|
|
if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)
|
|
|
|
{
|
|
|
|
auto landSetRightsAction = LandSetRightsAction(
|
|
|
|
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y },
|
|
|
|
LandSetRightSetting::SetOwnershipWithChecks, _activeTool << 4);
|
|
|
|
GameActions::Execute(&landSetRightsAction);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2022-08-21 18:49:23 +02:00
|
|
|
void OnToolAbort(WidgetIndex widgetIndex) override
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_SET_LAND_RIGHTS:
|
|
|
|
Invalidate();
|
2023-01-16 21:14:50 +01:00
|
|
|
HideGridlines();
|
|
|
|
HideLandRights();
|
|
|
|
HideConstructionRights();
|
2022-02-26 21:23:27 +01:00
|
|
|
break;
|
|
|
|
case WIDX_BUILD_PARK_ENTRANCE:
|
2022-10-04 08:38:00 +02:00
|
|
|
ParkEntranceRemoveGhost();
|
2022-02-26 21:23:27 +01:00
|
|
|
Invalidate();
|
2023-01-16 21:14:50 +01:00
|
|
|
HideGridlines();
|
|
|
|
HideLandRights();
|
|
|
|
HideConstructionRights();
|
2022-02-26 21:23:27 +01:00
|
|
|
break;
|
|
|
|
case WIDX_PEOPLE_STARTING_POSITION:
|
|
|
|
Invalidate();
|
2023-01-16 21:14:50 +01:00
|
|
|
HideGridlines();
|
|
|
|
HideLandRights();
|
|
|
|
HideConstructionRights();
|
2022-02-26 21:23:27 +01:00
|
|
|
break;
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-05-12 17:37:16 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
void SetLandRightsToolUpdate(const ScreenCoordsXY& screenCoords)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-10-12 07:35:20 +02:00
|
|
|
MapInvalidateSelectionRect();
|
2022-02-26 21:23:27 +01:00
|
|
|
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
|
2023-01-16 21:14:50 +01:00
|
|
|
auto mapCoords = ScreenGetMapXY(screenCoords, nullptr);
|
2022-02-26 21:23:27 +01:00
|
|
|
if (!mapCoords.has_value())
|
|
|
|
return;
|
|
|
|
|
|
|
|
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
|
|
|
|
gMapSelectType = MAP_SELECT_TYPE_FULL;
|
|
|
|
|
|
|
|
int32_t landRightsToolSize = _landRightsToolSize;
|
|
|
|
if (landRightsToolSize == 0)
|
|
|
|
landRightsToolSize = 1;
|
|
|
|
|
|
|
|
int32_t size = (landRightsToolSize * 32) - 32;
|
|
|
|
int32_t radius = (landRightsToolSize * 16) - 16;
|
|
|
|
mapCoords->x = (mapCoords->x - radius) & 0xFFE0;
|
|
|
|
mapCoords->y = (mapCoords->y - radius) & 0xFFE0;
|
|
|
|
gMapSelectPositionA = *mapCoords;
|
|
|
|
gMapSelectPositionB.x = mapCoords->x + size;
|
|
|
|
gMapSelectPositionB.y = mapCoords->y + size;
|
2022-10-12 07:35:20 +02:00
|
|
|
MapInvalidateSelectionRect();
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-05-12 17:37:16 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
CoordsXYZD PlaceParkEntranceGetMapPosition(const ScreenCoordsXY& screenCoords)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
CoordsXYZD parkEntranceMapPosition{ 0, 0, 0, INVALID_DIRECTION };
|
|
|
|
const CoordsXY mapCoords = ViewportInteractionGetTileStartAtCursor(screenCoords);
|
|
|
|
parkEntranceMapPosition = { mapCoords.x, mapCoords.y, 0, INVALID_DIRECTION };
|
|
|
|
if (parkEntranceMapPosition.IsNull())
|
|
|
|
return parkEntranceMapPosition;
|
|
|
|
|
2022-10-11 20:39:24 +02:00
|
|
|
auto surfaceElement = MapGetSurfaceElementAt(mapCoords);
|
2022-02-26 21:23:27 +01:00
|
|
|
if (surfaceElement == nullptr)
|
|
|
|
{
|
|
|
|
parkEntranceMapPosition.SetNull();
|
|
|
|
return parkEntranceMapPosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
parkEntranceMapPosition.z = surfaceElement->GetWaterHeight();
|
|
|
|
if (parkEntranceMapPosition.z == 0)
|
|
|
|
{
|
|
|
|
parkEntranceMapPosition.z = surfaceElement->GetBaseZ();
|
|
|
|
if ((surfaceElement->GetSlope() & TILE_ELEMENT_SLOPE_ALL_CORNERS_UP) != 0)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
parkEntranceMapPosition.z += 16;
|
|
|
|
if (surfaceElement->GetSlope() & TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT)
|
|
|
|
{
|
|
|
|
parkEntranceMapPosition.z += 16;
|
|
|
|
}
|
2018-06-22 23:21:44 +02:00
|
|
|
}
|
2022-02-26 21:23:27 +01:00
|
|
|
}
|
2023-01-16 21:14:50 +01:00
|
|
|
parkEntranceMapPosition.direction = (gWindowSceneryRotation - GetCurrentRotation()) & 3;
|
2022-02-26 21:23:27 +01:00
|
|
|
return parkEntranceMapPosition;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-05-12 17:37:16 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
void PlaceParkEntranceToolUpdate(const ScreenCoordsXY& screenCoords)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-10-12 07:35:20 +02:00
|
|
|
MapInvalidateSelectionRect();
|
|
|
|
MapInvalidateMapSelectionTiles();
|
2022-02-26 21:23:27 +01:00
|
|
|
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
|
|
|
|
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
|
|
|
|
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
|
|
|
|
CoordsXYZD parkEntrancePosition = PlaceParkEntranceGetMapPosition(screenCoords);
|
|
|
|
if (parkEntrancePosition.IsNull())
|
|
|
|
{
|
2022-10-04 08:38:00 +02:00
|
|
|
ParkEntranceRemoveGhost();
|
2022-02-26 21:23:27 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-05-14 12:43:14 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
int32_t sideDirection = (parkEntrancePosition.direction + 1) & 3;
|
|
|
|
gMapSelectionTiles.clear();
|
|
|
|
gMapSelectionTiles.push_back({ parkEntrancePosition.x, parkEntrancePosition.y });
|
|
|
|
gMapSelectionTiles.push_back({ parkEntrancePosition.x + CoordsDirectionDelta[sideDirection].x,
|
|
|
|
parkEntrancePosition.y + CoordsDirectionDelta[sideDirection].y });
|
|
|
|
gMapSelectionTiles.push_back({ parkEntrancePosition.x - CoordsDirectionDelta[sideDirection].x,
|
|
|
|
parkEntrancePosition.y - CoordsDirectionDelta[sideDirection].y });
|
2015-05-26 20:28:37 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
gMapSelectArrowPosition = parkEntrancePosition;
|
|
|
|
gMapSelectArrowDirection = parkEntrancePosition.direction;
|
2014-05-14 12:43:14 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT | MAP_SELECT_FLAG_ENABLE_ARROW;
|
2022-10-12 07:35:20 +02:00
|
|
|
MapInvalidateMapSelectionTiles();
|
2022-02-26 21:23:27 +01:00
|
|
|
if (gParkEntranceGhostExists && parkEntrancePosition == gParkEntranceGhostPosition)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-10-04 08:38:00 +02:00
|
|
|
ParkEntranceRemoveGhost();
|
2022-08-11 00:00:58 +02:00
|
|
|
|
2023-01-05 10:39:15 +01:00
|
|
|
auto gameAction = ParkEntrancePlaceAction(parkEntrancePosition, gFootpathSelectedId);
|
2022-08-11 00:00:58 +02:00
|
|
|
gameAction.SetFlags(GAME_COMMAND_FLAG_GHOST);
|
|
|
|
|
|
|
|
auto result = GameActions::Execute(&gameAction);
|
|
|
|
if (result.Error == GameActions::Status::Ok)
|
|
|
|
{
|
|
|
|
gParkEntranceGhostPosition = parkEntrancePosition;
|
|
|
|
gParkEntranceGhostExists = true;
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
void PlaceParkEntranceToolDown(const ScreenCoordsXY& screenCoords)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-10-04 08:38:00 +02:00
|
|
|
ParkEntranceRemoveGhost();
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
CoordsXYZD parkEntrancePosition = PlaceParkEntranceGetMapPosition(screenCoords);
|
|
|
|
if (!parkEntrancePosition.IsNull())
|
|
|
|
{
|
2023-01-05 10:39:15 +01:00
|
|
|
auto gameAction = ParkEntrancePlaceAction(parkEntrancePosition, gFootpathSelectedId);
|
2022-02-26 21:23:27 +01:00
|
|
|
auto result = GameActions::Execute(&gameAction);
|
|
|
|
if (result.Error == GameActions::Status::Ok)
|
|
|
|
{
|
|
|
|
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result.Position);
|
|
|
|
}
|
|
|
|
}
|
2018-06-22 23:21:44 +02:00
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
void SetPeepSpawnToolUpdate(const ScreenCoordsXY& screenCoords)
|
|
|
|
{
|
|
|
|
int32_t direction;
|
|
|
|
TileElement* tileElement;
|
2022-10-12 07:35:20 +02:00
|
|
|
MapInvalidateSelectionRect();
|
2022-02-26 21:23:27 +01:00
|
|
|
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
|
|
|
|
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
|
2022-10-04 08:51:27 +02:00
|
|
|
auto mapCoords = FootpathBridgeGetInfoFromPos(screenCoords, &direction, &tileElement);
|
2022-02-26 21:23:27 +01:00
|
|
|
if (mapCoords.IsNull())
|
|
|
|
return;
|
|
|
|
|
|
|
|
int32_t mapZ = tileElement->GetBaseZ();
|
|
|
|
if (tileElement->GetType() == TileElementType::Surface)
|
|
|
|
{
|
|
|
|
if ((tileElement->AsSurface()->GetSlope() & TILE_ELEMENT_SLOPE_ALL_CORNERS_UP) != 0)
|
|
|
|
mapZ += 16;
|
|
|
|
if (tileElement->AsSurface()->GetSlope() & TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT)
|
|
|
|
mapZ += 16;
|
|
|
|
}
|
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
|
2022-02-26 21:23:27 +01:00
|
|
|
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW;
|
2017-06-06 23:24:18 +02:00
|
|
|
gMapSelectType = MAP_SELECT_TYPE_FULL;
|
2020-07-16 04:26:27 +02:00
|
|
|
gMapSelectPositionA = mapCoords;
|
2022-02-26 21:23:27 +01:00
|
|
|
gMapSelectPositionB = mapCoords;
|
|
|
|
gMapSelectArrowPosition = CoordsXYZ{ mapCoords, mapZ };
|
2022-10-04 21:12:38 +02:00
|
|
|
gMapSelectArrowDirection = DirectionReverse(direction);
|
2022-10-12 07:35:20 +02:00
|
|
|
MapInvalidateSelectionRect();
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-05-14 12:43:14 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
void SetPeepSpawnToolDown(const ScreenCoordsXY& screenCoords)
|
|
|
|
{
|
|
|
|
// Verify footpath exists at location, and retrieve coordinates
|
|
|
|
TileElement* tileElement;
|
|
|
|
int32_t direction;
|
2022-10-04 08:51:27 +02:00
|
|
|
auto mapCoords = FootpathGetCoordinatesFromPos(screenCoords, &direction, &tileElement);
|
2022-02-26 21:23:27 +01:00
|
|
|
if (mapCoords.IsNull())
|
|
|
|
return;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
int32_t mapZ = tileElement->GetBaseZ();
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2023-01-05 10:39:15 +01:00
|
|
|
auto gameAction = PeepSpawnPlaceAction({ mapCoords, mapZ, static_cast<Direction>(direction) });
|
2022-02-26 21:23:27 +01:00
|
|
|
auto result = GameActions::Execute(&gameAction);
|
|
|
|
if (result.Error == GameActions::Status::Ok)
|
|
|
|
{
|
|
|
|
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result.Position);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-21 18:49:23 +02:00
|
|
|
void OnTextInput(WidgetIndex widgetIndex, std::string_view text) override
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
if (text.empty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_LAND_TOOL:
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
char* end;
|
|
|
|
std::string textStr = std::string(text);
|
|
|
|
int32_t size = strtol(textStr.c_str(), &end, 10);
|
|
|
|
if (*end == '\0')
|
|
|
|
{
|
|
|
|
size = std::clamp(size, MINIMUM_TOOL_SIZE, MAXIMUM_TOOL_SIZE);
|
|
|
|
_landRightsToolSize = size;
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2022-05-15 22:25:45 +02:00
|
|
|
case WIDX_MAP_SIZE_SPINNER_Y:
|
|
|
|
case WIDX_MAP_SIZE_SPINNER_X:
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
char* end;
|
|
|
|
std::string textStr = std::string(text);
|
|
|
|
int32_t size = strtol(textStr.c_str(), &end, 10);
|
|
|
|
if (*end == '\0')
|
|
|
|
{
|
|
|
|
// The practical size is 2 lower than the technical size
|
|
|
|
size += 2;
|
|
|
|
size = std::clamp(size, MINIMUM_MAP_SIZE_TECHNICAL, MAXIMUM_MAP_SIZE_TECHNICAL);
|
2018-06-22 23:21:44 +02:00
|
|
|
|
2022-05-15 22:25:45 +02:00
|
|
|
TileCoordsXY newMapSize = gMapSize;
|
|
|
|
if (_resizeDirection != ResizeDirection::X)
|
|
|
|
newMapSize.y = size;
|
|
|
|
if (_resizeDirection != ResizeDirection::Y)
|
|
|
|
newMapSize.x = size;
|
|
|
|
|
2023-01-02 13:52:38 +01:00
|
|
|
auto mapChangeSizeAction = MapChangeSizeAction(newMapSize);
|
|
|
|
GameActions::Execute(&mapChangeSizeAction);
|
2022-02-26 21:23:27 +01:00
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2022-02-26 21:23:27 +01:00
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
ScreenSize OnScrollGetSize(int32_t scrollIndex) override
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
return ScreenSize(MAP_WINDOW_MAP_SIZE, MAP_WINDOW_MAP_SIZE);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
void OnScrollMouseDown(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
CoordsXY c = ScreenToMap(screenCoords);
|
|
|
|
auto mapCoords = CoordsXY{ std::clamp(c.x, 0, MAXIMUM_MAP_SIZE_BIG - 1), std::clamp(c.y, 0, MAXIMUM_MAP_SIZE_BIG - 1) };
|
2022-10-12 07:35:20 +02:00
|
|
|
auto mapZ = TileElementHeight(mapCoords);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2023-01-21 20:57:17 +01:00
|
|
|
WindowBase* mainWindow = WindowGetMain();
|
2022-02-26 21:23:27 +01:00
|
|
|
if (mainWindow != nullptr)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2023-01-16 21:13:42 +01:00
|
|
|
WindowScrollToLocation(*mainWindow, { mapCoords, mapZ });
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
if (LandToolIsActive())
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
// Set land terrain
|
|
|
|
int32_t landToolSize = std::max<int32_t>(1, gLandToolSize);
|
|
|
|
int32_t size = (landToolSize * 32) - 32;
|
|
|
|
int32_t radius = (landToolSize * 16) - 16;
|
|
|
|
|
|
|
|
mapCoords = (mapCoords - CoordsXY{ radius, radius }).ToTileStart();
|
2022-10-12 07:35:20 +02:00
|
|
|
MapInvalidateSelectionRect();
|
2022-02-26 21:23:27 +01:00
|
|
|
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
|
|
|
|
gMapSelectType = MAP_SELECT_TYPE_FULL;
|
|
|
|
gMapSelectPositionA = mapCoords;
|
|
|
|
gMapSelectPositionB = mapCoords + CoordsXY{ size, size };
|
2022-10-12 07:35:20 +02:00
|
|
|
MapInvalidateSelectionRect();
|
2022-02-26 21:23:27 +01:00
|
|
|
|
|
|
|
auto surfaceSetStyleAction = SurfaceSetStyleAction(
|
|
|
|
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y },
|
|
|
|
gLandToolTerrainSurface, gLandToolTerrainEdge);
|
|
|
|
GameActions::Execute(&surfaceSetStyleAction);
|
2018-06-22 23:21:44 +02:00
|
|
|
}
|
2022-07-30 22:21:51 +02:00
|
|
|
else if (WidgetIsActiveTool(*this, WIDX_SET_LAND_RIGHTS))
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
// Set land rights
|
|
|
|
int32_t landRightsToolSize = std::max<int32_t>(1, _landRightsToolSize);
|
|
|
|
int32_t size = (landRightsToolSize * 32) - 32;
|
|
|
|
int32_t radius = (landRightsToolSize * 16) - 16;
|
|
|
|
mapCoords = (mapCoords - CoordsXY{ radius, radius }).ToTileStart();
|
|
|
|
|
2022-10-12 07:35:20 +02:00
|
|
|
MapInvalidateSelectionRect();
|
2022-02-26 21:23:27 +01:00
|
|
|
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
|
|
|
|
gMapSelectType = MAP_SELECT_TYPE_FULL;
|
|
|
|
gMapSelectPositionA = mapCoords;
|
|
|
|
gMapSelectPositionB = mapCoords + CoordsXY{ size, size };
|
2022-10-12 07:35:20 +02:00
|
|
|
MapInvalidateSelectionRect();
|
2022-02-26 21:23:27 +01:00
|
|
|
|
|
|
|
auto landSetRightsAction = LandSetRightsAction(
|
|
|
|
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y },
|
|
|
|
LandSetRightSetting::SetOwnershipWithChecks, _activeTool << 4);
|
|
|
|
GameActions::Execute(&landSetRightsAction);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
void OnScrollMouseDrag(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
OnScrollMouseDown(scrollIndex, screenCoords);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2023-01-19 09:16:44 +01:00
|
|
|
void OnScrollDraw(int32_t scrollIndex, DrawPixelInfo& dpi) override
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2023-01-16 14:50:43 +01:00
|
|
|
GfxClear(&dpi, PALETTE_INDEX_10);
|
2022-02-26 21:23:27 +01:00
|
|
|
|
2023-01-19 09:16:44 +01:00
|
|
|
G1Element g1temp = {};
|
2022-02-26 21:23:27 +01:00
|
|
|
g1temp.offset = _mapImageData.data();
|
|
|
|
g1temp.width = MAP_WINDOW_MAP_SIZE;
|
|
|
|
g1temp.height = MAP_WINDOW_MAP_SIZE;
|
|
|
|
g1temp.x_offset = -8;
|
|
|
|
g1temp.y_offset = -8;
|
2023-01-16 19:52:17 +01:00
|
|
|
GfxSetG1Element(SPR_TEMP, &g1temp);
|
2023-01-16 23:31:34 +01:00
|
|
|
DrawingEngineInvalidateImage(SPR_TEMP);
|
2023-01-16 19:52:17 +01:00
|
|
|
GfxDrawSprite(&dpi, ImageId(SPR_TEMP), { 0, 0 });
|
2022-02-26 21:23:27 +01:00
|
|
|
|
|
|
|
if (selected_tab == PAGE_PEEPS)
|
|
|
|
{
|
|
|
|
PaintPeepOverlay(&dpi);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PaintTrainOverlay(&dpi);
|
|
|
|
}
|
|
|
|
PaintHudRectangle(&dpi);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
void OnPrepareDraw() override
|
2017-12-18 16:29:48 +01:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
// Set the pressed widgets
|
2022-05-15 22:25:45 +02:00
|
|
|
pressed_widgets = 0;
|
|
|
|
SetWidgetPressed(WIDX_MAP_SIZE_LINK, _mapWidthAndHeightLinked);
|
2022-10-17 19:21:18 +02:00
|
|
|
pressed_widgets |= (1uLL << (WIDX_PEOPLE_TAB + selected_tab));
|
|
|
|
pressed_widgets |= (1uLL << WIDX_LAND_TOOL);
|
2022-02-26 21:23:27 +01:00
|
|
|
|
|
|
|
if (_activeTool & (1 << 3))
|
2022-10-17 19:21:18 +02:00
|
|
|
pressed_widgets |= (1uLL << WIDX_LAND_SALE_CHECKBOX);
|
2022-02-26 21:23:27 +01:00
|
|
|
|
|
|
|
if (_activeTool & (1 << 2))
|
2022-10-17 19:21:18 +02:00
|
|
|
pressed_widgets |= (1uLL << WIDX_CONSTRUCTION_RIGHTS_SALE_CHECKBOX);
|
2022-02-26 21:23:27 +01:00
|
|
|
|
|
|
|
if (_activeTool & (1 << 1))
|
2022-10-17 19:21:18 +02:00
|
|
|
pressed_widgets |= (1uLL << WIDX_LAND_OWNED_CHECKBOX);
|
2022-02-26 21:23:27 +01:00
|
|
|
|
|
|
|
if (_activeTool & (1 << 0))
|
2022-10-17 19:21:18 +02:00
|
|
|
pressed_widgets |= (1uLL << WIDX_CONSTRUCTION_RIGHTS_OWNED_CHECKBOX);
|
2022-02-26 21:23:27 +01:00
|
|
|
|
2022-05-15 22:25:45 +02:00
|
|
|
// Set disabled widgets
|
|
|
|
SetWidgetDisabled(WIDX_MAP_SIZE_LINK, gMapSize.x != gMapSize.y);
|
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
// Resize widgets to window size
|
2022-11-06 10:29:40 +01:00
|
|
|
ResizeFrameWithPage();
|
2022-02-26 21:23:27 +01:00
|
|
|
widgets[WIDX_MAP].right = width - 4;
|
|
|
|
|
|
|
|
if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode)
|
|
|
|
widgets[WIDX_MAP].bottom = height - 1 - 72;
|
|
|
|
else if (selected_tab == PAGE_RIDES)
|
|
|
|
widgets[WIDX_MAP].bottom = height - 1 - (4 * LIST_ROW_HEIGHT + 4);
|
|
|
|
else
|
|
|
|
widgets[WIDX_MAP].bottom = height - 1 - 14;
|
|
|
|
|
2022-05-15 22:25:45 +02:00
|
|
|
widgets[WIDX_MAP_SIZE_SPINNER_Y].top = height - 15;
|
|
|
|
widgets[WIDX_MAP_SIZE_SPINNER_Y].bottom = height - 4;
|
|
|
|
widgets[WIDX_MAP_SIZE_SPINNER_Y_UP].top = height - 14;
|
|
|
|
widgets[WIDX_MAP_SIZE_SPINNER_Y_UP].bottom = height - 5;
|
|
|
|
widgets[WIDX_MAP_SIZE_SPINNER_Y_DOWN].top = height - 14;
|
|
|
|
widgets[WIDX_MAP_SIZE_SPINNER_Y_DOWN].bottom = height - 5;
|
|
|
|
widgets[WIDX_MAP_SIZE_LINK].top = height - 15;
|
|
|
|
widgets[WIDX_MAP_SIZE_LINK].bottom = height - 4;
|
|
|
|
widgets[WIDX_MAP_SIZE_SPINNER_X].top = height - 15;
|
|
|
|
widgets[WIDX_MAP_SIZE_SPINNER_X].bottom = height - 4;
|
|
|
|
widgets[WIDX_MAP_SIZE_SPINNER_X_UP].top = height - 14;
|
|
|
|
widgets[WIDX_MAP_SIZE_SPINNER_X_UP].bottom = height - 5;
|
|
|
|
widgets[WIDX_MAP_SIZE_SPINNER_X_DOWN].top = height - 14;
|
|
|
|
widgets[WIDX_MAP_SIZE_SPINNER_X_DOWN].bottom = height - 5;
|
2022-02-26 21:23:27 +01:00
|
|
|
|
|
|
|
widgets[WIDX_SET_LAND_RIGHTS].top = height - 70;
|
|
|
|
widgets[WIDX_SET_LAND_RIGHTS].bottom = height - 70 + 23;
|
|
|
|
widgets[WIDX_BUILD_PARK_ENTRANCE].top = height - 46;
|
|
|
|
widgets[WIDX_BUILD_PARK_ENTRANCE].bottom = height - 46 + 23;
|
|
|
|
widgets[WIDX_ROTATE_90].top = height - 46;
|
|
|
|
widgets[WIDX_ROTATE_90].bottom = height - 46 + 23;
|
|
|
|
widgets[WIDX_PEOPLE_STARTING_POSITION].top = height - 46;
|
|
|
|
widgets[WIDX_PEOPLE_STARTING_POSITION].bottom = height - 46 + 23;
|
|
|
|
|
|
|
|
widgets[WIDX_LAND_TOOL].top = height - 42;
|
|
|
|
widgets[WIDX_LAND_TOOL].bottom = height - 42 + 30;
|
|
|
|
widgets[WIDX_LAND_TOOL_SMALLER].top = height - 41;
|
|
|
|
widgets[WIDX_LAND_TOOL_SMALLER].bottom = height - 41 + 15;
|
|
|
|
widgets[WIDX_LAND_TOOL_LARGER].top = height - 27;
|
|
|
|
widgets[WIDX_LAND_TOOL_LARGER].bottom = height - 27 + 15;
|
|
|
|
|
|
|
|
widgets[WIDX_MAP_GENERATOR].top = height - 69;
|
|
|
|
widgets[WIDX_MAP_GENERATOR].bottom = height - 69 + 13;
|
|
|
|
|
|
|
|
// Land tool mode (4 checkboxes)
|
|
|
|
int checkboxY = height - 55;
|
2022-10-17 18:08:55 +02:00
|
|
|
for (int32_t i = WIDX_LAND_OWNED_CHECKBOX; i <= WIDX_CONSTRUCTION_RIGHTS_SALE_CHECKBOX; i++)
|
2017-12-18 16:29:48 +01:00
|
|
|
{
|
2022-10-17 18:08:55 +02:00
|
|
|
widgets[i].top = checkboxY;
|
2022-02-26 21:23:27 +01:00
|
|
|
checkboxY += 11;
|
2022-10-17 18:08:55 +02:00
|
|
|
widgets[i].bottom = checkboxY;
|
2022-02-26 21:23:27 +01:00
|
|
|
checkboxY += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Disable all scenario editor related widgets
|
2022-05-15 22:25:45 +02:00
|
|
|
for (int32_t i = WIDX_MAP_SIZE_SPINNER_Y; i <= WIDX_MAP_GENERATOR; i++)
|
2022-02-26 21:23:27 +01:00
|
|
|
{
|
|
|
|
widgets[i].type = WindowWidgetType::Empty;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode)
|
|
|
|
{
|
|
|
|
// scenario editor: build park entrance selected, show rotate button
|
2023-01-17 13:24:51 +01:00
|
|
|
if ((InputTestFlag(INPUT_FLAG_TOOL_ACTIVE)) && gCurrentToolWidget.window_classification == WindowClass::Map
|
2022-02-26 21:23:27 +01:00
|
|
|
&& gCurrentToolWidget.widget_index == WIDX_BUILD_PARK_ENTRANCE)
|
|
|
|
{
|
|
|
|
widgets[WIDX_ROTATE_90].type = WindowWidgetType::FlatBtn;
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
// Always show set land rights button
|
|
|
|
widgets[WIDX_SET_LAND_RIGHTS].type = WindowWidgetType::FlatBtn;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
// If any tool is active
|
2023-01-17 13:24:51 +01:00
|
|
|
if ((InputTestFlag(INPUT_FLAG_TOOL_ACTIVE)) && gCurrentToolWidget.window_classification == WindowClass::Map)
|
2017-12-18 16:29:48 +01:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
// if not in set land rights mode: show the default scenario editor buttons
|
|
|
|
if (gCurrentToolWidget.widget_index != WIDX_SET_LAND_RIGHTS)
|
2017-12-18 16:29:48 +01:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
ShowDefaultScenarioEditorButtons();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // if in set land rights mode: show land tool buttons + modes
|
|
|
|
widgets[WIDX_LAND_TOOL].type = WindowWidgetType::ImgBtn;
|
|
|
|
widgets[WIDX_LAND_TOOL_SMALLER].type = WindowWidgetType::TrnBtn;
|
|
|
|
widgets[WIDX_LAND_TOOL_LARGER].type = WindowWidgetType::TrnBtn;
|
|
|
|
|
2022-10-17 18:08:55 +02:00
|
|
|
for (int32_t i = WIDX_LAND_OWNED_CHECKBOX; i <= WIDX_CONSTRUCTION_RIGHTS_SALE_CHECKBOX; i++)
|
|
|
|
widgets[i].type = WindowWidgetType::Checkbox;
|
2022-02-26 21:23:27 +01:00
|
|
|
|
2022-12-24 17:47:22 +01:00
|
|
|
widgets[WIDX_LAND_TOOL].image = ImageId(LandTool::SizeToSpriteIndex(_landRightsToolSize));
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
2022-02-26 21:23:27 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// if no tool is active: show the default scenario editor buttons
|
|
|
|
ShowDefaultScenarioEditorButtons();
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2018-06-22 23:21:44 +02:00
|
|
|
}
|
2014-05-14 12:43:14 +02:00
|
|
|
|
2023-01-19 09:16:44 +01:00
|
|
|
void OnDraw(DrawPixelInfo& dpi) override
|
2017-10-26 14:14:37 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
DrawWidgets(dpi);
|
|
|
|
DrawTabImages(&dpi);
|
2014-09-12 02:59:43 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
auto screenCoords = windowPos
|
|
|
|
+ ScreenCoordsXY{ window_map_widgets[WIDX_LAND_TOOL].midX(), window_map_widgets[WIDX_LAND_TOOL].midY() };
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
// Draw land tool size
|
2022-07-30 22:21:51 +02:00
|
|
|
if (WidgetIsActiveTool(*this, WIDX_SET_LAND_RIGHTS) && _landRightsToolSize > MAX_TOOL_SIZE_WITH_SPRITE)
|
2022-02-26 21:23:27 +01:00
|
|
|
{
|
|
|
|
auto ft = Formatter();
|
|
|
|
ft.Add<uint16_t>(_landRightsToolSize);
|
2023-02-24 22:05:07 +01:00
|
|
|
DrawTextBasic(dpi, screenCoords - ScreenCoordsXY{ 0, 2 }, STR_LAND_TOOL_SIZE_VALUE, ft, { TextAlignment::CENTRE });
|
2022-02-26 21:23:27 +01:00
|
|
|
}
|
|
|
|
screenCoords.y = windowPos.y + window_map_widgets[WIDX_LAND_TOOL].bottom + 5;
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
// People starting position (scenario editor only)
|
|
|
|
if (widgets[WIDX_PEOPLE_STARTING_POSITION].type != WindowWidgetType::Empty)
|
|
|
|
{
|
|
|
|
screenCoords = windowPos
|
|
|
|
+ ScreenCoordsXY{ widgets[WIDX_PEOPLE_STARTING_POSITION].left + 12,
|
|
|
|
widgets[WIDX_PEOPLE_STARTING_POSITION].top + 18 };
|
2023-01-16 19:52:17 +01:00
|
|
|
GfxDrawSprite(&dpi, ImageId(SPR_6410, COLOUR_BRIGHT_RED, COLOUR_LIGHT_BROWN), screenCoords);
|
2022-02-26 21:23:27 +01:00
|
|
|
}
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode)
|
|
|
|
{
|
|
|
|
// Render the map legend
|
|
|
|
if (selected_tab == PAGE_RIDES)
|
|
|
|
{
|
|
|
|
screenCoords = windowPos + ScreenCoordsXY{ 4, widgets[WIDX_MAP].bottom + 2 };
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2022-07-31 14:22:58 +02:00
|
|
|
static constexpr StringId _mapLabels[] = {
|
2022-02-26 21:23:27 +01:00
|
|
|
STR_MAP_RIDE, STR_MAP_FOOD_STALL, STR_MAP_DRINK_STALL, STR_MAP_SOUVENIR_STALL,
|
|
|
|
STR_MAP_INFO_KIOSK, STR_MAP_FIRST_AID, STR_MAP_CASH_MACHINE, STR_MAP_TOILET,
|
|
|
|
};
|
2022-05-15 22:25:45 +02:00
|
|
|
static_assert(std::size(RideKeyColours) == std::size(_mapLabels));
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
for (uint32_t i = 0; i < std::size(RideKeyColours); i++)
|
|
|
|
{
|
2023-01-16 14:50:43 +01:00
|
|
|
GfxFillRect(
|
2022-02-26 21:23:27 +01:00
|
|
|
&dpi, { screenCoords + ScreenCoordsXY{ 0, 2 }, screenCoords + ScreenCoordsXY{ 6, 8 } },
|
|
|
|
RideKeyColours[i]);
|
2023-02-24 22:05:07 +01:00
|
|
|
DrawTextBasic(dpi, screenCoords + ScreenCoordsXY{ LIST_ROW_HEIGHT, 0 }, _mapLabels[i], {});
|
2022-02-26 21:23:27 +01:00
|
|
|
screenCoords.y += LIST_ROW_HEIGHT;
|
|
|
|
if (i == 3)
|
|
|
|
{
|
|
|
|
screenCoords += { 118, -(LIST_ROW_HEIGHT * 4) };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-07-30 22:21:51 +02:00
|
|
|
else if (!WidgetIsActiveTool(*this, WIDX_SET_LAND_RIGHTS))
|
2022-02-26 21:23:27 +01:00
|
|
|
{
|
|
|
|
DrawTextBasic(
|
2023-02-24 22:05:07 +01:00
|
|
|
dpi, windowPos + ScreenCoordsXY{ 4, widgets[WIDX_MAP_SIZE_SPINNER_Y].top + 1 }, STR_MAP_SIZE, {},
|
2022-02-26 21:23:27 +01:00
|
|
|
{ colours[1] });
|
|
|
|
}
|
|
|
|
}
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
void ResetMap()
|
|
|
|
{
|
|
|
|
InitMap();
|
|
|
|
CentreMapOnViewPoint();
|
|
|
|
}
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
private:
|
|
|
|
void InitMap()
|
|
|
|
{
|
|
|
|
std::fill(_mapImageData.begin(), _mapImageData.end(), PALETTE_INDEX_10);
|
|
|
|
_currentLine = 0;
|
|
|
|
}
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
void CentreMapOnViewPoint()
|
|
|
|
{
|
2023-01-21 20:57:17 +01:00
|
|
|
WindowBase* mainWindow = WindowGetMain();
|
2022-02-26 21:23:27 +01:00
|
|
|
int16_t ax, bx, cx, dx;
|
|
|
|
int16_t bp, di;
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
if (mainWindow == nullptr || mainWindow->viewport == nullptr)
|
|
|
|
return;
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2023-01-16 21:14:50 +01:00
|
|
|
auto offset = MiniMapOffsets[GetCurrentRotation()];
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
// calculate centre view point of viewport and transform it to minimap coordinates
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
cx = ((mainWindow->viewport->view_width >> 1) + mainWindow->viewport->viewPos.x) >> 5;
|
|
|
|
dx = ((mainWindow->viewport->view_height >> 1) + mainWindow->viewport->viewPos.y) >> 4;
|
|
|
|
cx += offset.x;
|
|
|
|
dx += offset.y;
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
// calculate width and height of minimap
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
ax = widgets[WIDX_MAP].width() - 11;
|
|
|
|
bx = widgets[WIDX_MAP].height() - 11;
|
|
|
|
bp = ax;
|
|
|
|
di = bx;
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
ax >>= 1;
|
|
|
|
bx >>= 1;
|
|
|
|
cx = std::max(cx - ax, 0);
|
|
|
|
dx = std::max(dx - bx, 0);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
bp = scrolls[0].h_right - bp;
|
|
|
|
di = scrolls[0].v_bottom - di;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
if (bp < 0 && (bp - cx) < 0)
|
|
|
|
cx = 0;
|
2015-02-14 14:24:18 +01:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
if (di < 0 && (di - dx) < 0)
|
|
|
|
dx = 0;
|
2021-01-23 07:45:14 +01:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
scrolls[0].h_left = cx;
|
|
|
|
scrolls[0].v_top = dx;
|
2022-07-30 22:40:33 +02:00
|
|
|
WidgetScrollUpdateThumbs(*this, WIDX_MAP);
|
2021-01-23 07:45:14 +01:00
|
|
|
}
|
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
void IncreaseMapSize()
|
2021-01-23 07:45:14 +01:00
|
|
|
{
|
2022-05-15 22:25:45 +02:00
|
|
|
auto newMapSize = gMapSize;
|
|
|
|
if (IsWidgetPressed(WIDX_MAP_SIZE_LINK) || _resizeDirection == ResizeDirection::Y)
|
|
|
|
newMapSize.y++;
|
|
|
|
if (IsWidgetPressed(WIDX_MAP_SIZE_LINK) || _resizeDirection == ResizeDirection::X)
|
|
|
|
newMapSize.x++;
|
|
|
|
|
2023-01-02 13:52:38 +01:00
|
|
|
auto increaseMapSizeAction = MapChangeSizeAction(newMapSize);
|
2022-02-26 21:23:27 +01:00
|
|
|
GameActions::Execute(&increaseMapSizeAction);
|
2021-01-23 07:45:14 +01:00
|
|
|
}
|
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
void DecreaseMapSize()
|
2021-01-23 07:45:14 +01:00
|
|
|
{
|
2022-05-15 22:25:45 +02:00
|
|
|
auto newMapSize = gMapSize;
|
|
|
|
if (IsWidgetPressed(WIDX_MAP_SIZE_LINK) || _resizeDirection == ResizeDirection::Y)
|
|
|
|
newMapSize.y--;
|
|
|
|
if (IsWidgetPressed(WIDX_MAP_SIZE_LINK) || _resizeDirection == ResizeDirection::X)
|
|
|
|
newMapSize.x--;
|
|
|
|
|
2023-01-02 13:52:38 +01:00
|
|
|
auto decreaseMapSizeAction = MapChangeSizeAction(newMapSize);
|
2022-02-26 21:23:27 +01:00
|
|
|
GameActions::Execute(&decreaseMapSizeAction);
|
2021-01-23 07:45:14 +01:00
|
|
|
}
|
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
void SetMapPixels()
|
2021-01-23 07:45:14 +01:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
int32_t x = 0, y = 0, dx = 0, dy = 0;
|
2015-02-14 13:29:09 +01:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
int32_t pos = (_currentLine * (MAP_WINDOW_MAP_SIZE - 1)) + MAXIMUM_MAP_SIZE_TECHNICAL - 1;
|
|
|
|
auto destinationPosition = ScreenCoordsXY{ pos % MAP_WINDOW_MAP_SIZE, pos / MAP_WINDOW_MAP_SIZE };
|
|
|
|
auto destination = _mapImageData.data() + (destinationPosition.y * MAP_WINDOW_MAP_SIZE) + destinationPosition.x;
|
2023-01-16 21:14:50 +01:00
|
|
|
switch (GetCurrentRotation())
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
case 0:
|
|
|
|
x = _currentLine * COORDS_XY_STEP;
|
|
|
|
y = 0;
|
|
|
|
dx = 0;
|
|
|
|
dy = COORDS_XY_STEP;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
x = MAXIMUM_TILE_START_XY;
|
|
|
|
y = _currentLine * COORDS_XY_STEP;
|
|
|
|
dx = -COORDS_XY_STEP;
|
|
|
|
dy = 0;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
x = MAXIMUM_MAP_SIZE_BIG - ((_currentLine + 1) * COORDS_XY_STEP);
|
|
|
|
y = MAXIMUM_TILE_START_XY;
|
|
|
|
dx = 0;
|
|
|
|
dy = -COORDS_XY_STEP;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
x = 0;
|
|
|
|
y = MAXIMUM_MAP_SIZE_BIG - ((_currentLine + 1) * COORDS_XY_STEP);
|
|
|
|
dx = COORDS_XY_STEP;
|
|
|
|
dy = 0;
|
|
|
|
break;
|
|
|
|
}
|
2015-02-14 14:03:41 +01:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
for (int32_t i = 0; i < MAXIMUM_MAP_SIZE_TECHNICAL; i++)
|
|
|
|
{
|
2022-10-12 07:35:20 +02:00
|
|
|
if (!MapIsEdge({ x, y }))
|
2022-02-26 21:23:27 +01:00
|
|
|
{
|
|
|
|
uint16_t colour = 0;
|
|
|
|
switch (selected_tab)
|
|
|
|
{
|
|
|
|
case PAGE_PEEPS:
|
|
|
|
colour = GetPixelColourPeep({ x, y });
|
|
|
|
break;
|
|
|
|
case PAGE_RIDES:
|
|
|
|
colour = GetPixelColourRide({ x, y });
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
destination[0] = (colour >> 8) & 0xFF;
|
|
|
|
destination[1] = colour;
|
|
|
|
}
|
|
|
|
x += dx;
|
|
|
|
y += dy;
|
2015-02-14 14:03:41 +01:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
destinationPosition.x++;
|
|
|
|
destinationPosition.y++;
|
|
|
|
destination = _mapImageData.data() + (destinationPosition.y * MAP_WINDOW_MAP_SIZE) + destinationPosition.x;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2022-02-26 21:23:27 +01:00
|
|
|
_currentLine++;
|
|
|
|
if (_currentLine >= MAXIMUM_MAP_SIZE_TECHNICAL)
|
|
|
|
_currentLine = 0;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-02-14 13:29:09 +01:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
uint16_t GetPixelColourPeep(const CoordsXY& c)
|
|
|
|
{
|
2022-10-11 20:39:24 +02:00
|
|
|
auto* surfaceElement = MapGetSurfaceElementAt(c);
|
2022-02-26 21:23:27 +01:00
|
|
|
if (surfaceElement == nullptr)
|
|
|
|
return 0;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
uint16_t colour = MapColour(PALETTE_INDEX_0);
|
|
|
|
const auto* surfaceObject = surfaceElement->GetSurfaceStyleObject();
|
|
|
|
if (surfaceObject != nullptr)
|
|
|
|
colour = MapColour2(surfaceObject->MapColours[0], surfaceObject->MapColours[1]);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
if (surfaceElement->GetWaterHeight() > 0)
|
|
|
|
colour = WaterColour;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
if (!(surfaceElement->GetOwnership() & OWNERSHIP_OWNED))
|
|
|
|
colour = MapColourUnowned(colour);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
const int32_t maxSupportedTileElementType = static_cast<int32_t>(std::size(ElementTypeAddColour));
|
|
|
|
auto tileElement = reinterpret_cast<TileElement*>(surfaceElement);
|
|
|
|
while (!(tileElement++)->IsLastForTile())
|
|
|
|
{
|
|
|
|
if (tileElement->IsGhost())
|
|
|
|
{
|
|
|
|
colour = MapColour(PALETTE_INDEX_21);
|
|
|
|
break;
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
auto tileElementType = tileElement->GetType();
|
|
|
|
if (EnumValue(tileElementType) >= maxSupportedTileElementType)
|
|
|
|
{
|
|
|
|
tileElementType = TileElementType::Surface;
|
|
|
|
}
|
|
|
|
colour &= ElementTypeMaskColour[EnumValue(tileElementType)];
|
|
|
|
colour |= ElementTypeAddColour[EnumValue(tileElementType)];
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
return colour;
|
|
|
|
}
|
2015-02-15 01:04:48 +01:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
uint16_t GetPixelColourRide(const CoordsXY& c)
|
|
|
|
{
|
|
|
|
uint16_t colourA = 0; // highlight colour
|
|
|
|
uint16_t colourB = MapColour(PALETTE_INDEX_13); // surface colour (dark grey)
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
// as an improvement we could use first_element to show underground stuff?
|
2022-10-11 20:39:24 +02:00
|
|
|
TileElement* tileElement = reinterpret_cast<TileElement*>(MapGetSurfaceElementAt(c));
|
2022-02-26 21:23:27 +01:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (tileElement == nullptr)
|
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
if (tileElement->IsGhost())
|
|
|
|
{
|
|
|
|
colourA = MapColour(PALETTE_INDEX_21);
|
|
|
|
break;
|
|
|
|
}
|
2014-05-24 00:00:08 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
switch (tileElement->GetType())
|
|
|
|
{
|
|
|
|
case TileElementType::Surface:
|
|
|
|
if (tileElement->AsSurface()->GetWaterHeight() > 0)
|
|
|
|
// Why is this a different water colour as above (195)?
|
|
|
|
colourB = MapColour(PALETTE_INDEX_194);
|
|
|
|
if (!(tileElement->AsSurface()->GetOwnership() & OWNERSHIP_OWNED))
|
|
|
|
colourB = MapColourUnowned(colourB);
|
|
|
|
break;
|
|
|
|
case TileElementType::Path:
|
|
|
|
colourA = MapColour(PALETTE_INDEX_14); // lighter grey
|
|
|
|
break;
|
|
|
|
case TileElementType::Entrance:
|
|
|
|
{
|
|
|
|
if (tileElement->AsEntrance()->GetEntranceType() == ENTRANCE_TYPE_PARK_ENTRANCE)
|
|
|
|
break;
|
2023-01-17 01:32:54 +01:00
|
|
|
Ride* targetRide = GetRide(tileElement->AsEntrance()->GetRideIndex());
|
2022-02-26 21:23:27 +01:00
|
|
|
if (targetRide != nullptr)
|
|
|
|
{
|
|
|
|
const auto& colourKey = targetRide->GetRideTypeDescriptor().ColourKey;
|
|
|
|
colourA = RideKeyColours[static_cast<size_t>(colourKey)];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TileElementType::Track:
|
|
|
|
{
|
2023-01-17 01:32:54 +01:00
|
|
|
Ride* targetRide = GetRide(tileElement->AsTrack()->GetRideIndex());
|
2022-02-26 21:23:27 +01:00
|
|
|
if (targetRide != nullptr)
|
|
|
|
{
|
|
|
|
const auto& colourKey = targetRide->GetRideTypeDescriptor().ColourKey;
|
|
|
|
colourA = RideKeyColours[static_cast<size_t>(colourKey)];
|
|
|
|
}
|
2019-11-14 23:09:27 +01:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (!(tileElement++)->IsLastForTile());
|
|
|
|
|
|
|
|
if (colourA != 0)
|
|
|
|
return colourA;
|
|
|
|
|
|
|
|
return colourB;
|
|
|
|
}
|
|
|
|
|
2023-01-19 09:16:44 +01:00
|
|
|
void PaintPeepOverlay(DrawPixelInfo* dpi)
|
2019-10-08 13:45:30 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
auto flashColour = GetGuestFlashColour();
|
|
|
|
for (auto guest : EntityList<Guest>())
|
|
|
|
{
|
|
|
|
DrawMapPeepPixel(guest, flashColour, dpi);
|
|
|
|
}
|
|
|
|
flashColour = GetStaffFlashColour();
|
|
|
|
for (auto staff : EntityList<Staff>())
|
|
|
|
{
|
|
|
|
DrawMapPeepPixel(staff, flashColour, dpi);
|
|
|
|
}
|
2019-10-08 13:45:30 +02:00
|
|
|
}
|
|
|
|
|
2023-01-19 09:16:44 +01:00
|
|
|
void DrawMapPeepPixel(Peep* peep, const uint8_t flashColour, DrawPixelInfo* dpi)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
if (peep->x == LOCATION_NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
MapCoordsXY c = TransformToMapCoords({ peep->x, peep->y });
|
|
|
|
auto leftTop = ScreenCoordsXY{ c.x, c.y };
|
|
|
|
auto rightBottom = leftTop;
|
|
|
|
uint8_t colour = DefaultPeepMapColour;
|
|
|
|
if (EntityGetFlashing(peep))
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
colour = flashColour;
|
|
|
|
// If flashing then map peep pixel size is increased (by moving left top downwards)
|
|
|
|
if (flashColour != DefaultPeepMapColour)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
leftTop.x--;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
2014-05-24 00:00:08 +02:00
|
|
|
|
2023-01-16 14:50:43 +01:00
|
|
|
GfxFillRect(dpi, { leftTop, rightBottom }, colour);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
static uint8_t GetGuestFlashColour()
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
uint8_t colour = DefaultPeepMapColour;
|
|
|
|
if ((gWindowMapFlashingFlags & MapFlashingFlags::FlashGuests) != 0)
|
|
|
|
{
|
|
|
|
colour = GuestMapColour;
|
|
|
|
if ((gWindowMapFlashingFlags & MapFlashingFlags::SwitchColour) == 0)
|
|
|
|
colour = GuestMapColourAlternate;
|
|
|
|
}
|
|
|
|
return colour;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
static uint8_t GetStaffFlashColour()
|
2017-10-18 20:57:36 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
uint8_t colour = DefaultPeepMapColour;
|
|
|
|
if ((gWindowMapFlashingFlags & MapFlashingFlags::FlashStaff) != 0)
|
2017-10-18 20:57:36 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
colour = StaffMapColour;
|
|
|
|
if ((gWindowMapFlashingFlags & MapFlashingFlags::SwitchColour) == 0)
|
|
|
|
colour = StaffMapColourAlternate;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2022-02-26 21:23:27 +01:00
|
|
|
return colour;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-07-01 16:17:25 +02:00
|
|
|
|
2023-01-19 09:16:44 +01:00
|
|
|
void PaintTrainOverlay(DrawPixelInfo* dpi)
|
2022-02-26 21:23:27 +01:00
|
|
|
{
|
|
|
|
for (auto train : TrainManager::View())
|
|
|
|
{
|
|
|
|
for (Vehicle* vehicle = train; vehicle != nullptr; vehicle = GetEntity<Vehicle>(vehicle->next_vehicle_on_train))
|
|
|
|
{
|
|
|
|
if (vehicle->x == LOCATION_NULL)
|
|
|
|
continue;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
MapCoordsXY c = TransformToMapCoords({ vehicle->x, vehicle->y });
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2023-01-16 14:50:43 +01:00
|
|
|
GfxFillRect(dpi, { { c.x, c.y }, { c.x, c.y } }, PALETTE_INDEX_171);
|
2022-02-26 21:23:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
/**
|
2023-01-17 19:05:14 +01:00
|
|
|
* The call to GfxFillRect was originally wrapped in Sub68DABD which made sure that arguments were ordered correctly,
|
2022-02-26 21:23:27 +01:00
|
|
|
* but it doesn't look like it's ever necessary here so the call was removed.
|
|
|
|
*/
|
2023-01-19 09:16:44 +01:00
|
|
|
void PaintHudRectangle(DrawPixelInfo* dpi)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2023-01-21 20:57:17 +01:00
|
|
|
WindowBase* mainWindow = WindowGetMain();
|
2022-02-26 21:23:27 +01:00
|
|
|
if (mainWindow == nullptr)
|
|
|
|
return;
|
|
|
|
|
2023-01-21 20:57:17 +01:00
|
|
|
Viewport* mainViewport = mainWindow->viewport;
|
2022-02-26 21:23:27 +01:00
|
|
|
if (mainViewport == nullptr)
|
|
|
|
return;
|
|
|
|
|
2023-01-16 21:14:50 +01:00
|
|
|
auto offset = MiniMapOffsets[GetCurrentRotation()];
|
2022-02-26 21:23:27 +01:00
|
|
|
auto leftTop = ScreenCoordsXY{ (mainViewport->viewPos.x >> 5) + offset.x, (mainViewport->viewPos.y >> 4) + offset.y };
|
|
|
|
auto rightBottom = ScreenCoordsXY{ ((mainViewport->viewPos.x + mainViewport->view_width) >> 5) + offset.x,
|
|
|
|
((mainViewport->viewPos.y + mainViewport->view_height) >> 4) + offset.y };
|
|
|
|
auto rightTop = ScreenCoordsXY{ rightBottom.x, leftTop.y };
|
|
|
|
auto leftBottom = ScreenCoordsXY{ leftTop.x, rightBottom.y };
|
|
|
|
|
|
|
|
// top horizontal lines
|
2023-01-16 14:50:43 +01:00
|
|
|
GfxFillRect(dpi, { leftTop, leftTop + ScreenCoordsXY{ 3, 0 } }, PALETTE_INDEX_56);
|
|
|
|
GfxFillRect(dpi, { rightTop - ScreenCoordsXY{ 3, 0 }, rightTop }, PALETTE_INDEX_56);
|
2022-02-26 21:23:27 +01:00
|
|
|
|
|
|
|
// left vertical lines
|
2023-01-16 14:50:43 +01:00
|
|
|
GfxFillRect(dpi, { leftTop, leftTop + ScreenCoordsXY{ 0, 3 } }, PALETTE_INDEX_56);
|
|
|
|
GfxFillRect(dpi, { leftBottom - ScreenCoordsXY{ 0, 3 }, leftBottom }, PALETTE_INDEX_56);
|
2022-02-26 21:23:27 +01:00
|
|
|
|
|
|
|
// bottom horizontal lines
|
2023-01-16 14:50:43 +01:00
|
|
|
GfxFillRect(dpi, { leftBottom, leftBottom + ScreenCoordsXY{ 3, 0 } }, PALETTE_INDEX_56);
|
|
|
|
GfxFillRect(dpi, { rightBottom - ScreenCoordsXY{ 3, 0 }, rightBottom }, PALETTE_INDEX_56);
|
2022-02-26 21:23:27 +01:00
|
|
|
|
|
|
|
// right vertical lines
|
2023-01-16 14:50:43 +01:00
|
|
|
GfxFillRect(dpi, { rightTop, rightTop + ScreenCoordsXY{ 0, 3 } }, PALETTE_INDEX_56);
|
|
|
|
GfxFillRect(dpi, { rightBottom - ScreenCoordsXY{ 0, 3 }, rightBottom }, PALETTE_INDEX_56);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-07-02 01:37:55 +02:00
|
|
|
|
2023-01-19 09:16:44 +01:00
|
|
|
void DrawTabImages(DrawPixelInfo* dpi)
|
2022-02-26 21:23:27 +01:00
|
|
|
{
|
|
|
|
// Guest tab image (animated)
|
|
|
|
uint32_t guestTabImage = SPR_TAB_GUESTS_0;
|
|
|
|
if (selected_tab == PAGE_PEEPS)
|
|
|
|
guestTabImage += list_information_type / 4;
|
|
|
|
|
2023-01-16 19:52:17 +01:00
|
|
|
GfxDrawSprite(
|
2022-02-26 21:23:27 +01:00
|
|
|
dpi, ImageId(guestTabImage),
|
|
|
|
windowPos + ScreenCoordsXY{ widgets[WIDX_PEOPLE_TAB].left, widgets[WIDX_PEOPLE_TAB].top });
|
|
|
|
|
|
|
|
// Ride/stall tab image (animated)
|
|
|
|
uint32_t rideTabImage = SPR_TAB_RIDE_0;
|
|
|
|
if (selected_tab == PAGE_RIDES)
|
|
|
|
rideTabImage += list_information_type / 4;
|
|
|
|
|
2023-01-16 19:52:17 +01:00
|
|
|
GfxDrawSprite(
|
2022-02-26 21:23:27 +01:00
|
|
|
dpi, ImageId(rideTabImage),
|
|
|
|
windowPos + ScreenCoordsXY{ widgets[WIDX_RIDES_TAB].left, widgets[WIDX_RIDES_TAB].top });
|
|
|
|
}
|
2022-01-01 16:52:49 +01:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
void ShowDefaultScenarioEditorButtons()
|
|
|
|
{
|
|
|
|
widgets[WIDX_BUILD_PARK_ENTRANCE].type = WindowWidgetType::FlatBtn;
|
|
|
|
widgets[WIDX_PEOPLE_STARTING_POSITION].type = WindowWidgetType::FlatBtn;
|
2022-05-15 22:25:45 +02:00
|
|
|
widgets[WIDX_MAP_SIZE_SPINNER_Y].type = WindowWidgetType::Spinner;
|
|
|
|
widgets[WIDX_MAP_SIZE_SPINNER_Y_UP].type = WindowWidgetType::Button;
|
|
|
|
widgets[WIDX_MAP_SIZE_SPINNER_Y_DOWN].type = WindowWidgetType::Button;
|
|
|
|
widgets[WIDX_MAP_SIZE_LINK].type = WindowWidgetType::FlatBtn;
|
|
|
|
widgets[WIDX_MAP_SIZE_SPINNER_X].type = WindowWidgetType::Spinner;
|
|
|
|
widgets[WIDX_MAP_SIZE_SPINNER_X_UP].type = WindowWidgetType::Button;
|
|
|
|
widgets[WIDX_MAP_SIZE_SPINNER_X_DOWN].type = WindowWidgetType::Button;
|
2022-02-26 21:23:27 +01:00
|
|
|
|
|
|
|
// Only show this in the scenario editor, even when in sandbox mode.
|
|
|
|
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR)
|
|
|
|
widgets[WIDX_MAP_GENERATOR].type = WindowWidgetType::Button;
|
|
|
|
|
2022-05-15 22:25:45 +02:00
|
|
|
// Push width (Y) and height (X) to the common formatter arguments for the map size spinners to use
|
2022-02-26 21:23:27 +01:00
|
|
|
auto ft = Formatter::Common();
|
|
|
|
ft.Add<uint16_t>(gMapSize.y - 2);
|
2022-05-15 22:25:45 +02:00
|
|
|
ft.Add<uint16_t>(gMapSize.x - 2);
|
2022-02-26 21:23:27 +01:00
|
|
|
}
|
2022-01-01 16:52:49 +01:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
void InputLandSize()
|
|
|
|
{
|
|
|
|
Formatter ft;
|
|
|
|
ft.Add<int16_t>(MINIMUM_TOOL_SIZE);
|
|
|
|
ft.Add<int16_t>(MAXIMUM_TOOL_SIZE);
|
|
|
|
TextInputOpen(WIDX_LAND_TOOL, STR_SELECTION_SIZE, STR_ENTER_SELECTION_SIZE, ft, STR_NONE, STR_NONE, 3);
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-08-21 18:49:23 +02:00
|
|
|
void InputMapSize(WidgetIndex callingWidget)
|
2022-02-26 21:23:27 +01:00
|
|
|
{
|
2022-05-15 22:25:45 +02:00
|
|
|
if (IsWidgetPressed(WIDX_MAP_SIZE_LINK))
|
|
|
|
_resizeDirection = ResizeDirection::Both;
|
|
|
|
else
|
|
|
|
_resizeDirection = (callingWidget == WIDX_MAP_SIZE_SPINNER_Y) ? ResizeDirection::Y : ResizeDirection::X;
|
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
Formatter ft;
|
|
|
|
ft.Add<int16_t>(MINIMUM_MAP_SIZE_PRACTICAL);
|
|
|
|
ft.Add<int16_t>(MAXIMUM_MAP_SIZE_PRACTICAL);
|
2022-05-15 22:25:45 +02:00
|
|
|
TextInputOpen(callingWidget, STR_MAP_SIZE_2, STR_ENTER_MAP_SIZE, ft, STR_NONE, STR_NONE, 4);
|
2022-02-26 21:23:27 +01:00
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
CoordsXY ScreenToMap(ScreenCoordsXY screenCoords)
|
2018-05-24 11:44:53 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
screenCoords.x = ((screenCoords.x + 8) - MAXIMUM_MAP_SIZE_TECHNICAL) / 2;
|
|
|
|
screenCoords.y = ((screenCoords.y + 8)) / 2;
|
|
|
|
auto location = TileCoordsXY(screenCoords.y - screenCoords.x, screenCoords.x + screenCoords.y).ToCoordsXY();
|
2018-12-13 03:47:56 +01:00
|
|
|
|
2023-01-16 21:14:50 +01:00
|
|
|
switch (GetCurrentRotation())
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
case 0:
|
|
|
|
return location;
|
|
|
|
case 1:
|
|
|
|
return { MAXIMUM_MAP_SIZE_BIG - 1 - location.y, location.x };
|
|
|
|
case 2:
|
|
|
|
return { MAXIMUM_MAP_SIZE_BIG - 1 - location.x, MAXIMUM_MAP_SIZE_BIG - 1 - location.y };
|
|
|
|
case 3:
|
|
|
|
return { location.y, MAXIMUM_MAP_SIZE_BIG - 1 - location.x };
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-07-02 02:50:13 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
return { 0, 0 }; // unreachable
|
|
|
|
}
|
2018-06-22 23:21:44 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
MapCoordsXY TransformToMapCoords(CoordsXY c)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
int32_t x = c.x, y = c.y;
|
2019-10-08 13:45:30 +02:00
|
|
|
|
2023-01-16 21:14:50 +01:00
|
|
|
switch (GetCurrentRotation())
|
2019-05-08 22:33:56 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
case 3:
|
|
|
|
std::swap(x, y);
|
|
|
|
x = MAXIMUM_MAP_SIZE_BIG - 1 - x;
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
2022-02-26 21:23:27 +01:00
|
|
|
case 2:
|
|
|
|
x = MAXIMUM_MAP_SIZE_BIG - 1 - x;
|
|
|
|
y = MAXIMUM_MAP_SIZE_BIG - 1 - y;
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
2022-02-26 21:23:27 +01:00
|
|
|
case 1:
|
|
|
|
std::swap(x, y);
|
|
|
|
y = MAXIMUM_MAP_SIZE_BIG - 1 - y;
|
2021-12-11 00:30:59 +01:00
|
|
|
break;
|
2022-02-26 21:23:27 +01:00
|
|
|
case 0:
|
2017-06-06 23:24:18 +02:00
|
|
|
break;
|
|
|
|
}
|
2022-02-26 21:23:27 +01:00
|
|
|
x /= 32;
|
|
|
|
y /= 32;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
return { -x + y + MAXIMUM_MAP_SIZE_TECHNICAL - 8, x + y - 8 };
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
uint8_t _activeTool;
|
|
|
|
uint32_t _currentLine;
|
|
|
|
uint16_t _landRightsToolSize;
|
|
|
|
std::vector<uint8_t> _mapImageData;
|
2022-05-15 22:25:45 +02:00
|
|
|
bool _mapWidthAndHeightLinked{ true };
|
|
|
|
enum class ResizeDirection
|
|
|
|
{
|
|
|
|
Both,
|
|
|
|
X,
|
|
|
|
Y,
|
|
|
|
} _resizeDirection{ ResizeDirection::Both };
|
2022-02-26 21:23:27 +01:00
|
|
|
|
|
|
|
static constexpr const uint16_t RideKeyColours[] = {
|
|
|
|
MapColour(PALETTE_INDEX_61), // COLOUR_KEY_RIDE
|
|
|
|
MapColour(PALETTE_INDEX_42), // COLOUR_KEY_FOOD
|
|
|
|
MapColour(PALETTE_INDEX_20), // COLOUR_KEY_DRINK
|
|
|
|
MapColour(PALETTE_INDEX_209), // COLOUR_KEY_SOUVENIR
|
|
|
|
MapColour(PALETTE_INDEX_136), // COLOUR_KEY_KIOSK
|
|
|
|
MapColour(PALETTE_INDEX_102), // COLOUR_KEY_FIRST_AID
|
|
|
|
MapColour(PALETTE_INDEX_55), // COLOUR_KEY_CASH_MACHINE
|
|
|
|
MapColour(PALETTE_INDEX_161), // COLOUR_KEY_TOILETS
|
|
|
|
};
|
|
|
|
|
|
|
|
static constexpr const uint8_t DefaultPeepMapColour = PALETTE_INDEX_20;
|
|
|
|
static constexpr const uint8_t GuestMapColour = PALETTE_INDEX_172;
|
|
|
|
static constexpr const uint8_t GuestMapColourAlternate = PALETTE_INDEX_21;
|
|
|
|
static constexpr const uint8_t StaffMapColour = PALETTE_INDEX_138;
|
|
|
|
static constexpr const uint8_t StaffMapColourAlternate = PALETTE_INDEX_10;
|
|
|
|
|
|
|
|
static constexpr const uint16_t WaterColour = MapColour(PALETTE_INDEX_195);
|
|
|
|
|
|
|
|
static constexpr const uint16_t ElementTypeMaskColour[] = {
|
|
|
|
0xFFFF, // TILE_ELEMENT_TYPE_SURFACE
|
|
|
|
0x0000, // TILE_ELEMENT_TYPE_PATH
|
|
|
|
0x00FF, // TILE_ELEMENT_TYPE_TRACK
|
|
|
|
0xFF00, // TILE_ELEMENT_TYPE_SMALL_SCENERY
|
|
|
|
0x0000, // TILE_ELEMENT_TYPE_ENTRANCE
|
|
|
|
0xFFFF, // TILE_ELEMENT_TYPE_WALL
|
|
|
|
0x0000, // TILE_ELEMENT_TYPE_LARGE_SCENERY
|
|
|
|
0xFFFF, // TILE_ELEMENT_TYPE_BANNER
|
|
|
|
};
|
|
|
|
|
|
|
|
static constexpr const uint16_t ElementTypeAddColour[] = {
|
|
|
|
MapColour(PALETTE_INDEX_0), // TILE_ELEMENT_TYPE_SURFACE
|
|
|
|
MapColour(PALETTE_INDEX_17), // TILE_ELEMENT_TYPE_PATH
|
|
|
|
MapColour2(PALETTE_INDEX_183, PALETTE_INDEX_0), // TILE_ELEMENT_TYPE_TRACK
|
|
|
|
MapColour2(PALETTE_INDEX_0, PALETTE_INDEX_99), // TILE_ELEMENT_TYPE_SMALL_SCENERY
|
|
|
|
MapColour(PALETTE_INDEX_186), // TILE_ELEMENT_TYPE_ENTRANCE
|
|
|
|
MapColour(PALETTE_INDEX_0), // TILE_ELEMENT_TYPE_WALL
|
|
|
|
MapColour(PALETTE_INDEX_99), // TILE_ELEMENT_TYPE_LARGE_SCENERY
|
|
|
|
MapColour(PALETTE_INDEX_0), // TILE_ELEMENT_TYPE_BANNER
|
|
|
|
};
|
|
|
|
};
|
2015-07-02 02:50:13 +02:00
|
|
|
|
2023-01-21 20:57:17 +01:00
|
|
|
WindowBase* WindowMapOpen()
|
2015-07-02 01:37:55 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
try
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2023-01-21 20:57:17 +01:00
|
|
|
WindowBase* w = WindowFocusOrCreate<MapWindow>(WindowClass::Map, 245, 259, WF_10);
|
2022-02-26 21:23:27 +01:00
|
|
|
w->selected_tab = 0;
|
|
|
|
w->list_information_type = 0;
|
|
|
|
return w;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2022-02-26 21:23:27 +01:00
|
|
|
catch (const std::bad_alloc&)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
return nullptr;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-07-02 01:37:55 +02:00
|
|
|
}
|
2015-07-02 18:00:39 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
void WindowMapReset()
|
2015-07-02 18:00:39 +02:00
|
|
|
{
|
2023-01-21 20:57:17 +01:00
|
|
|
WindowBase* w;
|
2018-06-22 23:21:44 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
// Check if window is even opened
|
2023-01-16 21:13:42 +01:00
|
|
|
w = WindowBringToFrontByClass(WindowClass::Map);
|
2022-02-26 21:23:27 +01:00
|
|
|
if (w == nullptr)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2022-02-26 21:23:27 +01:00
|
|
|
return;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2018-06-22 23:21:44 +02:00
|
|
|
|
2022-02-26 21:23:27 +01:00
|
|
|
auto* mapWindow = static_cast<MapWindow*>(w);
|
|
|
|
mapWindow->ResetMap();
|
2015-07-02 18:00:39 +02:00
|
|
|
}
|