2014-05-14 12:43:14 +02:00
|
|
|
/*****************************************************************************
|
2020-07-21 15:04:34 +02:00
|
|
|
* Copyright (c) 2014-2020 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-11-21 23:16:04 +01:00
|
|
|
#include <iterator>
|
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>
|
2021-09-29 17:46:03 +02:00
|
|
|
#include <openrct2/actions/ChangeMapSizeAction.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>
|
|
|
|
#include <openrct2/actions/PlaceParkEntranceAction.h>
|
|
|
|
#include <openrct2/actions/PlacePeepSpawnAction.h>
|
|
|
|
#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>
|
2018-06-22 23:21:44 +02:00
|
|
|
#include <openrct2/localisation/Localisation.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
|
|
|
|
2020-05-05 22:26:14 +02:00
|
|
|
static constexpr const rct_string_id WINDOW_TITLE = STR_MAP_LABEL;
|
|
|
|
static constexpr const int32_t WH = 259;
|
|
|
|
static constexpr const int32_t WW = 245;
|
2019-10-19 04:02:31 +02:00
|
|
|
|
2021-01-23 07:45:14 +01:00
|
|
|
constexpr uint8_t DefaultPeepMapColour = PALETTE_INDEX_20;
|
|
|
|
constexpr uint8_t GuestMapColour = PALETTE_INDEX_172;
|
|
|
|
constexpr uint8_t GuestMapColourAlternate = PALETTE_INDEX_21;
|
|
|
|
constexpr uint8_t StaffMapColour = PALETTE_INDEX_138;
|
|
|
|
constexpr uint8_t StaffMapColourAlternate = PALETTE_INDEX_10;
|
|
|
|
|
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,
|
|
|
|
WIDX_RESIZE = 3,
|
|
|
|
WIDX_PEOPLE_TAB = 4,
|
|
|
|
WIDX_RIDES_TAB = 5,
|
|
|
|
WIDX_MAP = 6,
|
|
|
|
WIDX_MAP_SIZE_SPINNER = 7,
|
|
|
|
WIDX_MAP_SIZE_SPINNER_UP = 8,
|
|
|
|
WIDX_MAP_SIZE_SPINNER_DOWN = 9,
|
|
|
|
WIDX_SET_LAND_RIGHTS = 10,
|
|
|
|
WIDX_BUILD_PARK_ENTRANCE = 11,
|
|
|
|
WIDX_PEOPLE_STARTING_POSITION = 12,
|
|
|
|
WIDX_LAND_TOOL = 13,
|
|
|
|
WIDX_LAND_TOOL_SMALLER = 14,
|
|
|
|
WIDX_LAND_TOOL_LARGER = 15,
|
|
|
|
WIDX_LAND_OWNED_CHECKBOX = 16,
|
|
|
|
WIDX_CONSTRUCTION_RIGHTS_OWNED_CHECKBOX = 17,
|
|
|
|
WIDX_LAND_SALE_CHECKBOX = 18,
|
|
|
|
WIDX_CONSTRUCTION_RIGHTS_SALE_CHECKBOX = 19,
|
|
|
|
WIDX_ROTATE_90 = 20,
|
|
|
|
WIDX_MAP_GENERATOR = 21
|
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
|
2014-05-14 12:43:14 +02:00
|
|
|
static rct_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 ),
|
|
|
|
MakeSpinnerWidgets({104, 229}, { 95, 12}, WindowWidgetType::Spinner, WindowColour::Secondary, STR_MAP_SIZE_VALUE ), // NB: 3 widgets
|
|
|
|
MakeWidget ({ 4, 1}, { 24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, SPR_BUY_LAND_RIGHTS, STR_SELECT_PARK_OWNED_LAND_TIP ),
|
|
|
|
MakeWidget ({ 4, 1}, { 24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, SPR_PARK_ENTRANCE, STR_BUILD_PARK_ENTRANCE_TIP ),
|
|
|
|
MakeWidget ({ 28, 1}, { 24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, 0xFFFFFFFF, STR_SET_STARTING_POSITIONS_TIP ),
|
|
|
|
MakeWidget ({ 4, 17}, { 44, 32}, WindowWidgetType::ImgBtn, WindowColour::Secondary, SPR_LAND_TOOL_SIZE_0 ),
|
|
|
|
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),
|
|
|
|
MakeWidget ({218, 45}, { 24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, SPR_ROTATE_ARROW, STR_ROTATE_OBJECTS_90 ),
|
|
|
|
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
|
|
|
|
2016-08-03 09:37:43 +02:00
|
|
|
/** rct2: 0x00981BCC */
|
2018-06-20 17:28:51 +02:00
|
|
|
static constexpr const uint16_t RideKeyColours[] = {
|
2021-10-17 15:31:56 +02:00
|
|
|
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
|
2016-08-03 09:37:43 +02:00
|
|
|
};
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapClose(rct_window* w);
|
|
|
|
static void WindowMapResize(rct_window* w);
|
|
|
|
static void WindowMapMouseup(rct_window* w, rct_widgetindex widgetIndex);
|
|
|
|
static void WindowMapMousedown(rct_window* w, rct_widgetindex widgetIndex, rct_widget* widget);
|
|
|
|
static void WindowMapUpdate(rct_window* w);
|
|
|
|
static void WindowMapToolupdate(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords);
|
|
|
|
static void WindowMapTooldown(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords);
|
|
|
|
static void WindowMapTooldrag(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords);
|
|
|
|
static void WindowMapToolabort(rct_window* w, rct_widgetindex widgetIndex);
|
|
|
|
static void WindowMapScrollgetsize(rct_window* w, int32_t scrollIndex, int32_t* width, int32_t* height);
|
|
|
|
static void WindowMapScrollmousedown(rct_window* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords);
|
|
|
|
static void WindowMapTextinput(rct_window* w, rct_widgetindex widgetIndex, char* text);
|
|
|
|
static void WindowMapInvalidate(rct_window* w);
|
|
|
|
static void WindowMapPaint(rct_window* w, rct_drawpixelinfo* dpi);
|
|
|
|
static void WindowMapScrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t scrollIndex);
|
2021-10-17 15:31:56 +02:00
|
|
|
|
|
|
|
static rct_window_event_list window_map_events([](auto& events) {
|
2021-11-23 14:18:07 +01:00
|
|
|
events.close = &WindowMapClose;
|
|
|
|
events.mouse_up = &WindowMapMouseup;
|
|
|
|
events.resize = &WindowMapResize;
|
|
|
|
events.mouse_down = &WindowMapMousedown;
|
|
|
|
events.update = &WindowMapUpdate;
|
|
|
|
events.tool_update = &WindowMapToolupdate;
|
|
|
|
events.tool_down = &WindowMapTooldown;
|
|
|
|
events.tool_drag = &WindowMapTooldrag;
|
|
|
|
events.tool_abort = &WindowMapToolabort;
|
|
|
|
events.get_scroll_size = &WindowMapScrollgetsize;
|
|
|
|
events.scroll_mousedown = &WindowMapScrollmousedown;
|
|
|
|
events.scroll_mousedrag = &WindowMapScrollmousedown;
|
|
|
|
events.text_input = &WindowMapTextinput;
|
|
|
|
events.invalidate = &WindowMapInvalidate;
|
|
|
|
events.paint = &WindowMapPaint;
|
|
|
|
events.scroll_paint = &WindowMapScrollpaint;
|
2020-09-28 20:36:15 +02:00
|
|
|
});
|
2014-05-14 12:43:14 +02:00
|
|
|
|
2016-08-31 21:11:11 +02:00
|
|
|
/** rct2: 0x00F1AD61 */
|
2018-06-20 17:28:51 +02:00
|
|
|
static uint8_t _activeTool;
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2016-09-01 00:08:59 +02:00
|
|
|
/** rct2: 0x00F1AD6C */
|
2018-06-20 17:28:51 +02:00
|
|
|
static uint32_t _currentLine;
|
2016-09-01 00:08:59 +02:00
|
|
|
|
|
|
|
/** rct2: 0x00F1AD68 */
|
2018-06-20 17:28:51 +02:00
|
|
|
static std::vector<uint8_t> _mapImageData;
|
2016-09-01 00:08:59 +02:00
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
static uint16_t _landRightsToolSize;
|
2018-04-08 19:34:36 +02:00
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapInitMap();
|
|
|
|
static void WindowMapCentreOnViewPoint();
|
|
|
|
static void WindowMapShowDefaultScenarioEditorButtons(rct_window* w);
|
|
|
|
static void WindowMapDrawTabImages(rct_window* w, rct_drawpixelinfo* dpi);
|
|
|
|
static void WindowMapPaintPeepOverlay(rct_drawpixelinfo* dpi);
|
|
|
|
static void WindowMapPaintTrainOverlay(rct_drawpixelinfo* dpi);
|
|
|
|
static void WindowMapPaintHudRectangle(rct_drawpixelinfo* dpi);
|
|
|
|
static void WindowMapInputsizeLand(rct_window* w);
|
|
|
|
static void WindowMapInputsizeMap(rct_window* w);
|
|
|
|
|
|
|
|
static void WindowMapSetLandRightsToolUpdate(const ScreenCoordsXY& screenCoords);
|
|
|
|
static void WindowMapPlaceParkEntranceToolUpdate(const ScreenCoordsXY& screenCoords);
|
|
|
|
static void WindowMapSetPeepSpawnToolUpdate(const ScreenCoordsXY& screenCoords);
|
|
|
|
static void WindowMapPlaceParkEntranceToolDown(const ScreenCoordsXY& screenCoords);
|
|
|
|
static void WindowMapSetPeepSpawnToolDown(const ScreenCoordsXY& screenCoords);
|
|
|
|
static void MapWindowIncreaseMapSize();
|
|
|
|
static void MapWindowDecreaseMapSize();
|
|
|
|
static void MapWindowSetPixels(rct_window* w);
|
|
|
|
|
|
|
|
static CoordsXY MapWindowScreenToMap(ScreenCoordsXY screenCoords);
|
2015-07-02 18:00:39 +02:00
|
|
|
|
2014-05-14 12:43:14 +02:00
|
|
|
/**
|
2018-06-22 23:21:44 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x0068C88A
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
rct_window* WindowMapOpen()
|
2014-05-14 12:43:14 +02:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
rct_window* w;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Check if window is already open
|
|
|
|
w = window_bring_to_front_by_class(WC_MAP);
|
2018-06-22 23:21:44 +02:00
|
|
|
if (w != nullptr)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->selected_tab = 0;
|
|
|
|
w->list_information_type = 0;
|
2017-10-06 23:03:48 +02:00
|
|
|
return w;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2018-01-21 03:25:20 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
_mapImageData.resize(MAP_WINDOW_MAP_SIZE * MAP_WINDOW_MAP_SIZE);
|
|
|
|
}
|
2018-06-22 23:21:44 +02:00
|
|
|
catch (const std::bad_alloc&)
|
2018-01-21 03:25:20 +01:00
|
|
|
{
|
2017-10-06 23:03:48 +02:00
|
|
|
return nullptr;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2020-11-04 05:52:23 +01:00
|
|
|
w = WindowCreateAutoPos(245, 259, &window_map_events, WC_MAP, WF_10);
|
2017-06-06 23:24:18 +02:00
|
|
|
w->widgets = window_map_widgets;
|
2021-06-26 14:23:15 +02:00
|
|
|
w->enabled_widgets = (1ULL << WIDX_CLOSE) | (1ULL << WIDX_PEOPLE_TAB) | (1ULL << WIDX_RIDES_TAB)
|
|
|
|
| (1ULL << WIDX_MAP_SIZE_SPINNER) | (1ULL << WIDX_MAP_SIZE_SPINNER_UP) | (1ULL << WIDX_MAP_SIZE_SPINNER_DOWN)
|
|
|
|
| (1ULL << WIDX_LAND_TOOL) | (1ULL << WIDX_LAND_TOOL_SMALLER) | (1ULL << WIDX_LAND_TOOL_LARGER)
|
|
|
|
| (1ULL << WIDX_SET_LAND_RIGHTS) | (1ULL << WIDX_LAND_OWNED_CHECKBOX)
|
|
|
|
| (1ULL << WIDX_CONSTRUCTION_RIGHTS_OWNED_CHECKBOX) | (1ULL << WIDX_LAND_SALE_CHECKBOX)
|
|
|
|
| (1ULL << WIDX_CONSTRUCTION_RIGHTS_SALE_CHECKBOX) | (1ULL << WIDX_BUILD_PARK_ENTRANCE) | (1ULL << WIDX_ROTATE_90)
|
|
|
|
| (1ULL << WIDX_PEOPLE_STARTING_POSITION) | (1ULL << WIDX_MAP_GENERATOR);
|
2018-06-22 23:21:44 +02:00
|
|
|
|
2021-06-26 14:23:15 +02:00
|
|
|
w->hold_down_widgets = (1ULL << WIDX_MAP_SIZE_SPINNER_UP) | (1ULL << WIDX_MAP_SIZE_SPINNER_DOWN)
|
|
|
|
| (1ULL << WIDX_LAND_TOOL_LARGER) | (1ULL << WIDX_LAND_TOOL_SMALLER);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2020-11-04 05:52:23 +01:00
|
|
|
WindowInitScrollWidgets(w);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
w->map.rotation = get_current_rotation();
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMapInitMap();
|
2017-06-06 23:24:18 +02:00
|
|
|
gWindowSceneryRotation = 0;
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMapCentreOnViewPoint();
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2018-04-08 19:34:36 +02:00
|
|
|
// Reset land rights tool size
|
|
|
|
_landRightsToolSize = 1;
|
2017-10-06 23:03:48 +02:00
|
|
|
|
|
|
|
return w;
|
2014-05-14 12:43:14 +02:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
void WindowMapReset()
|
2017-02-09 19:54:03 +01:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
rct_window* w;
|
2017-02-09 19:54:03 +01:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
// Check if window is even opened
|
|
|
|
w = window_bring_to_front_by_class(WC_MAP);
|
2018-06-22 23:21:44 +02:00
|
|
|
if (w == nullptr)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
|
|
|
}
|
2017-02-09 19:54:03 +01:00
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMapInitMap();
|
|
|
|
WindowMapCentreOnViewPoint();
|
2017-02-09 19:54:03 +01:00
|
|
|
}
|
|
|
|
|
2014-05-14 12:49:40 +02:00
|
|
|
/**
|
2018-06-22 23:21:44 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x0068D0F1
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapClose(rct_window* w)
|
2014-05-14 12:49:40 +02:00
|
|
|
{
|
2018-01-21 03:25:20 +01:00
|
|
|
_mapImageData.clear();
|
|
|
|
_mapImageData.shrink_to_fit();
|
2018-06-22 23:21:44 +02:00
|
|
|
if ((input_test_flag(INPUT_FLAG_TOOL_ACTIVE)) && gCurrentToolWidget.window_classification == w->classification
|
|
|
|
&& gCurrentToolWidget.window_number == w->number)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
tool_cancel();
|
|
|
|
}
|
2014-05-14 12:49:40 +02:00
|
|
|
}
|
|
|
|
|
2015-02-17 16:03:46 +01:00
|
|
|
/**
|
2015-07-01 01:58:13 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x0068CFC1
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapMouseup(rct_window* w, rct_widgetindex widgetIndex)
|
2015-02-17 16:03:46 +01:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_CLOSE:
|
|
|
|
window_close(w);
|
|
|
|
break;
|
|
|
|
case WIDX_SET_LAND_RIGHTS:
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2020-12-23 05:11:15 +01:00
|
|
|
if (tool_set(w, widgetIndex, Tool::UpArrow))
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
_activeTool = 2;
|
|
|
|
// Prevent mountain tool size.
|
|
|
|
_landRightsToolSize = std::max<uint16_t>(MINIMUM_TOOL_SIZE, _landRightsToolSize);
|
|
|
|
show_gridlines();
|
|
|
|
show_land_rights();
|
|
|
|
show_construction_rights();
|
2017-06-06 23:24:18 +02:00
|
|
|
break;
|
2018-06-22 23:21:44 +02:00
|
|
|
case WIDX_LAND_OWNED_CHECKBOX:
|
|
|
|
_activeTool ^= 2;
|
|
|
|
|
|
|
|
if (_activeTool & 2)
|
|
|
|
_activeTool &= 0xF2;
|
|
|
|
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2017-06-06 23:24:18 +02:00
|
|
|
break;
|
2018-06-22 23:21:44 +02:00
|
|
|
case WIDX_LAND_SALE_CHECKBOX:
|
|
|
|
_activeTool ^= 8;
|
|
|
|
|
|
|
|
if (_activeTool & 8)
|
|
|
|
_activeTool &= 0xF8;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2017-06-06 23:24:18 +02:00
|
|
|
break;
|
2018-06-22 23:21:44 +02:00
|
|
|
case WIDX_CONSTRUCTION_RIGHTS_OWNED_CHECKBOX:
|
|
|
|
_activeTool ^= 1;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
if (_activeTool & 1)
|
|
|
|
_activeTool &= 0xF1;
|
|
|
|
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
case WIDX_CONSTRUCTION_RIGHTS_SALE_CHECKBOX:
|
|
|
|
_activeTool ^= 4;
|
|
|
|
|
|
|
|
if (_activeTool & 4)
|
|
|
|
_activeTool &= 0xF4;
|
|
|
|
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
case WIDX_BUILD_PARK_ENTRANCE:
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2020-12-23 05:11:15 +01:00
|
|
|
if (tool_set(w, widgetIndex, Tool::UpArrow))
|
2017-06-06 23:24:18 +02:00
|
|
|
break;
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
gParkEntranceGhostExists = false;
|
|
|
|
input_set_flag(INPUT_FLAG_6, true);
|
|
|
|
|
|
|
|
show_gridlines();
|
|
|
|
show_land_rights();
|
|
|
|
show_construction_rights();
|
|
|
|
break;
|
|
|
|
case WIDX_ROTATE_90:
|
|
|
|
gWindowSceneryRotation = (gWindowSceneryRotation + 1) & 3;
|
|
|
|
break;
|
|
|
|
case WIDX_PEOPLE_STARTING_POSITION:
|
2020-12-23 05:11:15 +01:00
|
|
|
if (tool_set(w, widgetIndex, Tool::UpArrow))
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
show_gridlines();
|
|
|
|
show_land_rights();
|
|
|
|
show_construction_rights();
|
|
|
|
break;
|
|
|
|
case WIDX_LAND_TOOL:
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMapInputsizeLand(w);
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
case WIDX_MAP_SIZE_SPINNER:
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMapInputsizeMap(w);
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
case WIDX_MAP_GENERATOR:
|
|
|
|
context_open_window(WC_MAPGEN);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (widgetIndex >= WIDX_PEOPLE_TAB && widgetIndex <= WIDX_RIDES_TAB)
|
|
|
|
{
|
|
|
|
widgetIndex -= WIDX_PEOPLE_TAB;
|
|
|
|
if (widgetIndex == w->selected_tab)
|
|
|
|
break;
|
|
|
|
|
|
|
|
w->selected_tab = widgetIndex;
|
|
|
|
w->list_information_type = 0;
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2018-06-22 23:21:44 +02:00
|
|
|
}
|
2014-05-14 12:43:14 +02:00
|
|
|
|
|
|
|
/**
|
2018-06-22 23:21:44 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x0068D7DC
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapResize(rct_window* w)
|
2014-05-14 12:43:14 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->flags |= WF_RESIZABLE;
|
|
|
|
w->min_width = 245;
|
|
|
|
w->max_width = 800;
|
|
|
|
w->min_height = 259;
|
|
|
|
w->max_height = 560;
|
2015-07-01 01:58:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068D040
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapMousedown(rct_window* w, rct_widgetindex widgetIndex, rct_widget* widget)
|
2015-07-01 01:58:13 +02:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_MAP_SIZE_SPINNER_UP:
|
2021-11-23 14:18:07 +01:00
|
|
|
MapWindowIncreaseMapSize();
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
case WIDX_MAP_SIZE_SPINNER_DOWN:
|
2021-11-23 14:18:07 +01:00
|
|
|
MapWindowDecreaseMapSize();
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
case WIDX_LAND_TOOL_SMALLER:
|
|
|
|
// Decrement land rights tool size
|
|
|
|
_landRightsToolSize = std::max(MINIMUM_TOOL_SIZE, _landRightsToolSize - 1);
|
|
|
|
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
case WIDX_LAND_TOOL_LARGER:
|
|
|
|
// Increment land rights tool size
|
|
|
|
_landRightsToolSize = std::min(MAXIMUM_TOOL_SIZE, _landRightsToolSize + 1);
|
|
|
|
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-05-14 12:43:14 +02:00
|
|
|
}
|
|
|
|
|
2015-07-01 01:58:13 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068D7FB
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapUpdate(rct_window* w)
|
2015-07-01 01:58:13 +02:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
if (get_current_rotation() != w->map.rotation)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->map.rotation = get_current_rotation();
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMapInitMap();
|
|
|
|
WindowMapCentreOnViewPoint();
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
for (int32_t i = 0; i < 16; i++)
|
2021-11-23 14:18:07 +01:00
|
|
|
MapWindowSetPixels(w);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Update tab animations
|
|
|
|
w->list_information_type++;
|
2018-06-22 23:21:44 +02:00
|
|
|
switch (w->selected_tab)
|
|
|
|
{
|
|
|
|
case PAGE_PEEPS:
|
|
|
|
if (w->list_information_type >= 32)
|
|
|
|
{
|
|
|
|
w->list_information_type = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PAGE_RIDES:
|
|
|
|
if (w->list_information_type >= 64)
|
|
|
|
{
|
|
|
|
w->list_information_type = 0;
|
|
|
|
}
|
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-07-01 01:58:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068D093
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapToolupdate(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords)
|
2015-05-12 17:37:16 +02:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_SET_LAND_RIGHTS:
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMapSetLandRightsToolUpdate(screenCoords);
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
case WIDX_BUILD_PARK_ENTRANCE:
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMapPlaceParkEntranceToolUpdate(screenCoords);
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
case WIDX_PEOPLE_STARTING_POSITION:
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMapSetPeepSpawnToolUpdate(screenCoords);
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-05-12 17:37:16 +02:00
|
|
|
}
|
|
|
|
|
2015-07-01 01:58:13 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068D074
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapTooldown(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords)
|
2015-05-12 17:37:16 +02:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_BUILD_PARK_ENTRANCE:
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMapPlaceParkEntranceToolDown(screenCoords);
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
case WIDX_PEOPLE_STARTING_POSITION:
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMapSetPeepSpawnToolDown(screenCoords);
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-05-12 17:37:16 +02:00
|
|
|
}
|
|
|
|
|
2015-07-01 01:58:13 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068D088
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapTooldrag(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords)
|
2015-05-12 17:37:16 +02:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_SET_LAND_RIGHTS:
|
|
|
|
if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)
|
|
|
|
{
|
2019-03-17 09:25:51 +01:00
|
|
|
auto landSetRightsAction = LandSetRightsAction(
|
|
|
|
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y },
|
|
|
|
LandSetRightSetting::SetOwnershipWithChecks, _activeTool << 4);
|
|
|
|
GameActions::Execute(&landSetRightsAction);
|
2018-06-22 23:21:44 +02:00
|
|
|
}
|
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-05-12 17:37:16 +02:00
|
|
|
}
|
|
|
|
|
2014-05-14 12:43:14 +02:00
|
|
|
/**
|
2015-07-01 01:58:13 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x0068D055
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapToolabort(rct_window* w, rct_widgetindex widgetIndex)
|
2014-05-14 12:43:14 +02:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_SET_LAND_RIGHTS:
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2018-06-22 23:21:44 +02:00
|
|
|
hide_gridlines();
|
|
|
|
hide_land_rights();
|
|
|
|
hide_construction_rights();
|
|
|
|
break;
|
|
|
|
case WIDX_BUILD_PARK_ENTRANCE:
|
|
|
|
park_entrance_remove_ghost();
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2018-06-22 23:21:44 +02:00
|
|
|
hide_gridlines();
|
|
|
|
hide_land_rights();
|
|
|
|
hide_construction_rights();
|
|
|
|
break;
|
|
|
|
case WIDX_PEOPLE_STARTING_POSITION:
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2018-06-22 23:21:44 +02:00
|
|
|
hide_gridlines();
|
|
|
|
hide_land_rights();
|
|
|
|
hide_construction_rights();
|
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-05-14 12:43:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-07-01 01:58:13 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x0068D7CC
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapScrollgetsize(rct_window* w, int32_t scrollIndex, int32_t* width, int32_t* height)
|
2014-05-14 12:43:14 +02:00
|
|
|
{
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMapInvalidate(w);
|
2015-05-26 20:28:37 +02:00
|
|
|
|
2018-03-08 20:44:12 +01:00
|
|
|
*width = MAP_WINDOW_MAP_SIZE;
|
|
|
|
*height = MAP_WINDOW_MAP_SIZE;
|
2014-05-14 12:43:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-07-01 01:58:13 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x0068D726
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapScrollmousedown(rct_window* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
|
2014-05-14 12:43:14 +02:00
|
|
|
{
|
2021-11-23 14:18:07 +01:00
|
|
|
CoordsXY c = MapWindowScreenToMap(screenCoords);
|
2020-07-16 04:26:27 +02:00
|
|
|
auto mapCoords = CoordsXY{ std::clamp(c.x, 0, MAXIMUM_MAP_SIZE_BIG - 1), std::clamp(c.y, 0, MAXIMUM_MAP_SIZE_BIG - 1) };
|
|
|
|
auto mapZ = tile_element_height(mapCoords);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
rct_window* mainWindow = window_get_main();
|
|
|
|
if (mainWindow != nullptr)
|
|
|
|
{
|
2020-07-16 04:26:27 +02:00
|
|
|
window_scroll_to_location(mainWindow, { mapCoords, mapZ });
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2021-11-23 17:12:07 +01:00
|
|
|
if (LandToolIsActive())
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
// Set land terrain
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t landToolSize = std::max<int32_t>(1, gLandToolSize);
|
|
|
|
int32_t size = (landToolSize * 32) - 32;
|
|
|
|
int32_t radius = (landToolSize * 16) - 16;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2020-07-16 04:26:27 +02:00
|
|
|
mapCoords = (mapCoords - CoordsXY{ radius, radius }).ToTileStart();
|
2017-06-06 23:24:18 +02:00
|
|
|
map_invalidate_selection_rect();
|
|
|
|
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
|
|
|
|
gMapSelectType = MAP_SELECT_TYPE_FULL;
|
2020-07-16 04:26:27 +02:00
|
|
|
gMapSelectPositionA = mapCoords;
|
|
|
|
gMapSelectPositionB = mapCoords + CoordsXY{ size, size };
|
2017-06-06 23:24:18 +02:00
|
|
|
map_invalidate_selection_rect();
|
|
|
|
|
2019-03-10 10:15:22 +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
|
|
|
}
|
2020-11-03 22:29:22 +01:00
|
|
|
else if (WidgetIsActiveTool(w, WIDX_SET_LAND_RIGHTS))
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
// Set land rights
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t landRightsToolSize = std::max<int32_t>(1, _landRightsToolSize);
|
|
|
|
int32_t size = (landRightsToolSize * 32) - 32;
|
|
|
|
int32_t radius = (landRightsToolSize * 16) - 16;
|
2020-07-16 04:26:27 +02:00
|
|
|
mapCoords = (mapCoords - CoordsXY{ radius, radius }).ToTileStart();
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
map_invalidate_selection_rect();
|
|
|
|
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
|
|
|
|
gMapSelectType = MAP_SELECT_TYPE_FULL;
|
2020-07-16 04:26:27 +02:00
|
|
|
gMapSelectPositionA = mapCoords;
|
|
|
|
gMapSelectPositionB = mapCoords + CoordsXY{ size, size };
|
2017-06-06 23:24:18 +02:00
|
|
|
map_invalidate_selection_rect();
|
|
|
|
|
2019-03-17 09:25:51 +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
|
|
|
}
|
2014-05-14 12:43:14 +02:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapTextinput(rct_window* w, rct_widgetindex widgetIndex, char* text)
|
2015-07-01 01:58:13 +02:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t size;
|
2017-06-06 23:24:18 +02:00
|
|
|
char* end;
|
|
|
|
|
2017-08-15 10:07:44 +02:00
|
|
|
if (text == nullptr)
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_LAND_TOOL:
|
|
|
|
size = strtol(text, &end, 10);
|
|
|
|
if (*end == '\0')
|
|
|
|
{
|
2018-08-12 13:50:40 +02:00
|
|
|
size = std::clamp(size, MINIMUM_TOOL_SIZE, MAXIMUM_TOOL_SIZE);
|
2018-06-22 23:21:44 +02:00
|
|
|
_landRightsToolSize = size;
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
case WIDX_MAP_SIZE_SPINNER:
|
|
|
|
size = strtol(text, &end, 10);
|
|
|
|
if (*end == '\0')
|
|
|
|
{
|
|
|
|
// The practical size is 2 lower than the technical size
|
|
|
|
size += 2;
|
2018-08-12 13:50:40 +02:00
|
|
|
size = std::clamp(size, MINIMUM_MAP_SIZE_TECHNICAL, MAXIMUM_MAP_SIZE_TECHNICAL);
|
2018-06-22 23:21:44 +02:00
|
|
|
|
2021-09-29 17:46:03 +02:00
|
|
|
auto changeMapSizeAction = ChangeMapSizeAction(size);
|
|
|
|
GameActions::Execute(&changeMapSizeAction);
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-07-01 01:58:13 +02:00
|
|
|
}
|
|
|
|
|
2014-05-14 12:43:14 +02:00
|
|
|
/**
|
2015-07-01 01:58:13 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x0068CA8F
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapInvalidate(rct_window* w)
|
2014-05-14 12:43:14 +02:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
uint64_t pressedWidgets;
|
|
|
|
int32_t i, height;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Set the pressed widgets
|
|
|
|
pressedWidgets = w->pressed_widgets;
|
|
|
|
pressedWidgets &= (1ULL << WIDX_PEOPLE_TAB);
|
|
|
|
pressedWidgets &= (1ULL << WIDX_RIDES_TAB);
|
|
|
|
pressedWidgets &= (1ULL << WIDX_MAP);
|
|
|
|
pressedWidgets &= (1ULL << WIDX_LAND_OWNED_CHECKBOX);
|
|
|
|
pressedWidgets &= (1ULL << WIDX_CONSTRUCTION_RIGHTS_OWNED_CHECKBOX);
|
|
|
|
pressedWidgets &= (1ULL << WIDX_LAND_SALE_CHECKBOX);
|
|
|
|
pressedWidgets &= (1ULL << WIDX_CONSTRUCTION_RIGHTS_SALE_CHECKBOX);
|
|
|
|
|
|
|
|
pressedWidgets |= (1ULL << (WIDX_PEOPLE_TAB + w->selected_tab));
|
|
|
|
pressedWidgets |= (1ULL << WIDX_LAND_TOOL);
|
|
|
|
|
|
|
|
if (_activeTool & (1 << 3))
|
2021-06-26 14:23:15 +02:00
|
|
|
pressedWidgets |= (1ULL << WIDX_LAND_SALE_CHECKBOX);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
if (_activeTool & (1 << 2))
|
2021-06-26 14:23:15 +02:00
|
|
|
pressedWidgets |= (1ULL << WIDX_CONSTRUCTION_RIGHTS_SALE_CHECKBOX);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
if (_activeTool & (1 << 1))
|
2021-06-26 14:23:15 +02:00
|
|
|
pressedWidgets |= (1ULL << WIDX_LAND_OWNED_CHECKBOX);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
if (_activeTool & (1 << 0))
|
2021-06-26 14:23:15 +02:00
|
|
|
pressedWidgets |= (1ULL << WIDX_CONSTRUCTION_RIGHTS_OWNED_CHECKBOX);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
w->pressed_widgets = pressedWidgets;
|
|
|
|
|
|
|
|
// Resize widgets to window size
|
|
|
|
w->widgets[WIDX_BACKGROUND].right = w->width - 1;
|
|
|
|
w->widgets[WIDX_BACKGROUND].bottom = w->height - 1;
|
|
|
|
w->widgets[WIDX_RESIZE].right = w->width - 1;
|
|
|
|
w->widgets[WIDX_RESIZE].bottom = w->height - 1;
|
|
|
|
w->widgets[WIDX_TITLE].right = w->width - 2;
|
2020-05-05 22:31:04 +02:00
|
|
|
w->widgets[WIDX_CLOSE].left = w->width - 2 - 11;
|
|
|
|
w->widgets[WIDX_CLOSE].right = w->width - 2 - 11 + 10;
|
2017-06-06 23:24:18 +02:00
|
|
|
w->widgets[WIDX_MAP].right = w->width - 4;
|
|
|
|
|
|
|
|
if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode)
|
|
|
|
w->widgets[WIDX_MAP].bottom = w->height - 1 - 72;
|
|
|
|
else if (w->selected_tab == PAGE_RIDES)
|
2017-12-18 16:29:48 +01:00
|
|
|
w->widgets[WIDX_MAP].bottom = w->height - 1 - (4 * LIST_ROW_HEIGHT + 4);
|
2017-06-06 23:24:18 +02:00
|
|
|
else
|
|
|
|
w->widgets[WIDX_MAP].bottom = w->height - 1 - 14;
|
|
|
|
|
|
|
|
w->widgets[WIDX_MAP_SIZE_SPINNER].top = w->height - 15;
|
|
|
|
w->widgets[WIDX_MAP_SIZE_SPINNER].bottom = w->height - 4;
|
|
|
|
w->widgets[WIDX_MAP_SIZE_SPINNER_UP].top = w->height - 14;
|
2018-06-01 15:29:40 +02:00
|
|
|
w->widgets[WIDX_MAP_SIZE_SPINNER_UP].bottom = w->height - 5;
|
|
|
|
w->widgets[WIDX_MAP_SIZE_SPINNER_DOWN].top = w->height - 14;
|
2017-06-06 23:24:18 +02:00
|
|
|
w->widgets[WIDX_MAP_SIZE_SPINNER_DOWN].bottom = w->height - 5;
|
|
|
|
|
|
|
|
w->widgets[WIDX_SET_LAND_RIGHTS].top = w->height - 70;
|
|
|
|
w->widgets[WIDX_SET_LAND_RIGHTS].bottom = w->height - 70 + 23;
|
|
|
|
w->widgets[WIDX_BUILD_PARK_ENTRANCE].top = w->height - 46;
|
|
|
|
w->widgets[WIDX_BUILD_PARK_ENTRANCE].bottom = w->height - 46 + 23;
|
|
|
|
w->widgets[WIDX_ROTATE_90].top = w->height - 46;
|
|
|
|
w->widgets[WIDX_ROTATE_90].bottom = w->height - 46 + 23;
|
|
|
|
w->widgets[WIDX_PEOPLE_STARTING_POSITION].top = w->height - 46;
|
|
|
|
w->widgets[WIDX_PEOPLE_STARTING_POSITION].bottom = w->height - 46 + 23;
|
|
|
|
|
|
|
|
w->widgets[WIDX_LAND_TOOL].top = w->height - 42;
|
|
|
|
w->widgets[WIDX_LAND_TOOL].bottom = w->height - 42 + 30;
|
|
|
|
w->widgets[WIDX_LAND_TOOL_SMALLER].top = w->height - 41;
|
|
|
|
w->widgets[WIDX_LAND_TOOL_SMALLER].bottom = w->height - 41 + 15;
|
|
|
|
w->widgets[WIDX_LAND_TOOL_LARGER].top = w->height - 27;
|
|
|
|
w->widgets[WIDX_LAND_TOOL_LARGER].bottom = w->height - 27 + 15;
|
|
|
|
|
|
|
|
w->widgets[WIDX_MAP_GENERATOR].top = w->height - 69;
|
2020-06-18 23:33:08 +02:00
|
|
|
w->widgets[WIDX_MAP_GENERATOR].bottom = w->height - 69 + 13;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Land tool mode (4 checkboxes)
|
|
|
|
height = w->height - 55;
|
2018-06-22 23:21:44 +02:00
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->widgets[WIDX_LAND_OWNED_CHECKBOX + i].top = height;
|
|
|
|
height += 11;
|
|
|
|
w->widgets[WIDX_LAND_OWNED_CHECKBOX + i].bottom = height;
|
|
|
|
height += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Disable all scenario editor related widgets
|
2018-06-22 23:21:44 +02:00
|
|
|
for (i = WIDX_MAP_SIZE_SPINNER; i <= WIDX_MAP_GENERATOR; i++)
|
|
|
|
{
|
2020-11-27 04:14:20 +01:00
|
|
|
w->widgets[i].type = WindowWidgetType::Empty;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
// scenario editor: build park entrance selected, show rotate button
|
2018-06-22 23:21:44 +02:00
|
|
|
if ((input_test_flag(INPUT_FLAG_TOOL_ACTIVE)) && gCurrentToolWidget.window_classification == WC_MAP
|
|
|
|
&& gCurrentToolWidget.widget_index == WIDX_BUILD_PARK_ENTRANCE)
|
|
|
|
{
|
2020-11-27 04:14:20 +01:00
|
|
|
w->widgets[WIDX_ROTATE_90].type = WindowWidgetType::FlatBtn;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Always show set land rights button
|
2020-11-27 04:14:20 +01:00
|
|
|
w->widgets[WIDX_SET_LAND_RIGHTS].type = WindowWidgetType::FlatBtn;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// If any tool is active
|
2018-06-22 23:21:44 +02:00
|
|
|
if ((input_test_flag(INPUT_FLAG_TOOL_ACTIVE)) && gCurrentToolWidget.window_classification == WC_MAP)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
// if not in set land rights mode: show the default scenario editor buttons
|
2018-06-22 23:21:44 +02:00
|
|
|
if (gCurrentToolWidget.widget_index != WIDX_SET_LAND_RIGHTS)
|
|
|
|
{
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMapShowDefaultScenarioEditorButtons(w);
|
2018-06-22 23:21:44 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // if in set land rights mode: show land tool buttons + modes
|
2020-11-27 04:14:20 +01:00
|
|
|
w->widgets[WIDX_LAND_TOOL].type = WindowWidgetType::ImgBtn;
|
|
|
|
w->widgets[WIDX_LAND_TOOL_SMALLER].type = WindowWidgetType::TrnBtn;
|
|
|
|
w->widgets[WIDX_LAND_TOOL_LARGER].type = WindowWidgetType::TrnBtn;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
2020-11-27 04:14:20 +01:00
|
|
|
w->widgets[WIDX_LAND_OWNED_CHECKBOX + i].type = WindowWidgetType::Checkbox;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2020-11-03 11:59:00 +01:00
|
|
|
w->widgets[WIDX_LAND_TOOL].image = LandTool::SizeToSpriteIndex(_landRightsToolSize);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2018-06-22 23:21:44 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
// if no tool is active: show the default scenario editor buttons
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMapShowDefaultScenarioEditorButtons(w);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
2014-05-14 12:43:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-07-01 01:58:13 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x0068CDA9
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapPaint(rct_window* w, rct_drawpixelinfo* dpi)
|
2014-05-14 12:43:14 +02:00
|
|
|
{
|
2020-11-04 05:52:23 +01:00
|
|
|
WindowDrawWidgets(w, dpi);
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMapDrawTabImages(w, dpi);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2020-06-20 16:56:36 +02:00
|
|
|
auto screenCoords = w->windowPos
|
2020-06-25 10:31:15 +02:00
|
|
|
+ ScreenCoordsXY{ window_map_widgets[WIDX_LAND_TOOL].midX(), window_map_widgets[WIDX_LAND_TOOL].midY() };
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Draw land tool size
|
2020-11-03 22:29:22 +01:00
|
|
|
if (WidgetIsActiveTool(w, WIDX_SET_LAND_RIGHTS) && _landRightsToolSize > MAX_TOOL_SIZE_WITH_SPRITE)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2021-07-27 20:32:27 +02:00
|
|
|
auto ft = Formatter();
|
|
|
|
ft.Add<uint16_t>(_landRightsToolSize);
|
|
|
|
DrawTextBasic(dpi, screenCoords - ScreenCoordsXY{ 0, 2 }, STR_LAND_TOOL_SIZE_VALUE, ft, { TextAlignment::CENTRE });
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2020-05-17 20:29:56 +02:00
|
|
|
screenCoords.y = w->windowPos.y + window_map_widgets[WIDX_LAND_TOOL].bottom + 5;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// People starting position (scenario editor only)
|
2020-11-27 04:14:20 +01:00
|
|
|
if (w->widgets[WIDX_PEOPLE_STARTING_POSITION].type != WindowWidgetType::Empty)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2020-06-20 16:56:36 +02:00
|
|
|
screenCoords = w->windowPos
|
|
|
|
+ ScreenCoordsXY{ w->widgets[WIDX_PEOPLE_STARTING_POSITION].left + 12,
|
|
|
|
w->widgets[WIDX_PEOPLE_STARTING_POSITION].top + 18 };
|
2021-03-23 11:58:09 +01:00
|
|
|
gfx_draw_sprite(dpi, ImageId(SPR_6410, COLOUR_BRIGHT_RED, COLOUR_LIGHT_BROWN), screenCoords);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2017-12-18 16:29:48 +01:00
|
|
|
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
// Render the map legend
|
2017-12-18 16:29:48 +01:00
|
|
|
if (w->selected_tab == PAGE_RIDES)
|
|
|
|
{
|
2020-06-20 16:56:36 +02:00
|
|
|
screenCoords = w->windowPos + ScreenCoordsXY{ 4, w->widgets[WIDX_MAP].bottom + 2 };
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static rct_string_id mapLabels[] = {
|
|
|
|
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,
|
2017-06-06 23:24:18 +02:00
|
|
|
};
|
|
|
|
|
2018-11-21 23:16:04 +01:00
|
|
|
for (uint32_t i = 0; i < std::size(RideKeyColours); i++)
|
2017-12-18 16:29:48 +01:00
|
|
|
{
|
2020-05-17 20:29:56 +02:00
|
|
|
gfx_fill_rect(
|
2020-07-13 19:36:49 +02:00
|
|
|
dpi, { screenCoords + ScreenCoordsXY{ 0, 2 }, screenCoords + ScreenCoordsXY{ 6, 8 } }, RideKeyColours[i]);
|
2021-07-27 20:32:27 +02:00
|
|
|
DrawTextBasic(dpi, screenCoords + ScreenCoordsXY{ LIST_ROW_HEIGHT, 0 }, mapLabels[i], {});
|
2020-05-17 20:29:56 +02:00
|
|
|
screenCoords.y += LIST_ROW_HEIGHT;
|
2017-12-18 16:29:48 +01:00
|
|
|
if (i == 3)
|
|
|
|
{
|
2020-06-20 16:56:36 +02:00
|
|
|
screenCoords += { 118, -(LIST_ROW_HEIGHT * 4) };
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-06-22 23:21:44 +02:00
|
|
|
}
|
2020-11-03 22:29:22 +01:00
|
|
|
else if (!WidgetIsActiveTool(w, WIDX_SET_LAND_RIGHTS))
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2021-02-27 16:49:13 +01:00
|
|
|
DrawTextBasic(
|
|
|
|
dpi, w->windowPos + ScreenCoordsXY{ 4, w->widgets[WIDX_MAP_SIZE_SPINNER].top + 1 }, STR_MAP_SIZE, {},
|
|
|
|
{ w->colours[1] });
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-05-14 12:43:14 +02:00
|
|
|
}
|
|
|
|
|
2015-07-01 01:58:13 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068CF23
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapScrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t scrollIndex)
|
2014-09-12 02:59:43 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
gfx_clear(dpi, PALETTE_INDEX_10);
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2018-06-05 14:37:24 +02:00
|
|
|
rct_g1_element g1temp = {};
|
2018-01-21 03:25:20 +01:00
|
|
|
g1temp.offset = _mapImageData.data();
|
2017-10-28 14:33:02 +02:00
|
|
|
g1temp.width = MAP_WINDOW_MAP_SIZE;
|
|
|
|
g1temp.height = MAP_WINDOW_MAP_SIZE;
|
|
|
|
g1temp.x_offset = -8;
|
|
|
|
g1temp.y_offset = -8;
|
|
|
|
gfx_set_g1_element(SPR_TEMP, &g1temp);
|
2019-05-08 22:33:56 +02:00
|
|
|
drawing_engine_invalidate_image(SPR_TEMP);
|
2021-03-23 11:58:09 +01:00
|
|
|
gfx_draw_sprite(dpi, ImageId(SPR_TEMP), { 0, 0 });
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
if (w->selected_tab == PAGE_PEEPS)
|
2017-10-26 14:14:37 +02:00
|
|
|
{
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMapPaintPeepOverlay(dpi);
|
2017-10-26 14:14:37 +02:00
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
else
|
2017-10-26 14:14:37 +02:00
|
|
|
{
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMapPaintTrainOverlay(dpi);
|
2017-10-26 14:14:37 +02:00
|
|
|
}
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMapPaintHudRectangle(dpi);
|
2014-09-12 02:59:43 +02:00
|
|
|
}
|
|
|
|
|
2015-02-14 14:24:18 +01:00
|
|
|
/**
|
2015-07-01 01:58:13 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x0068CA6C
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapInitMap()
|
2015-07-01 01:58:13 +02:00
|
|
|
{
|
2018-01-21 03:25:20 +01:00
|
|
|
std::fill(_mapImageData.begin(), _mapImageData.end(), PALETTE_INDEX_10);
|
2017-06-06 23:24:18 +02:00
|
|
|
_currentLine = 0;
|
2015-07-01 01:58:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068C990
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapCentreOnViewPoint()
|
2015-07-01 01:58:13 +02:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
rct_window* w = window_get_main();
|
|
|
|
rct_window* w_map;
|
2018-06-20 17:28:51 +02:00
|
|
|
int16_t ax, bx, cx, dx;
|
|
|
|
int16_t bp, di;
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2017-08-15 10:07:44 +02:00
|
|
|
if (w == nullptr || w->viewport == nullptr)
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
w_map = window_find_by_class(WC_MAP);
|
2017-08-15 10:07:44 +02:00
|
|
|
if (w_map == nullptr)
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2020-03-01 21:24:44 +01:00
|
|
|
auto offset = MiniMapOffsets[get_current_rotation()];
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2017-07-01 00:11:28 +02:00
|
|
|
// calculate centre view point of viewport and transform it to minimap coordinates
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2020-03-01 13:56:14 +01:00
|
|
|
cx = ((w->viewport->view_width >> 1) + w->viewport->viewPos.x) >> 5;
|
|
|
|
dx = ((w->viewport->view_height >> 1) + w->viewport->viewPos.y) >> 4;
|
2017-06-06 23:24:18 +02:00
|
|
|
cx += offset.x;
|
|
|
|
dx += offset.y;
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
// calculate width and height of minimap
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2020-06-25 03:44:00 +02:00
|
|
|
ax = w_map->widgets[WIDX_MAP].width() - 11;
|
|
|
|
bx = w_map->widgets[WIDX_MAP].height() - 11;
|
2017-06-06 23:24:18 +02:00
|
|
|
bp = ax;
|
|
|
|
di = bx;
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
ax >>= 1;
|
|
|
|
bx >>= 1;
|
2018-06-20 17:11:35 +02:00
|
|
|
cx = std::max(cx - ax, 0);
|
|
|
|
dx = std::max(dx - bx, 0);
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
bp = w_map->scrolls[0].h_right - bp;
|
|
|
|
di = w_map->scrolls[0].v_bottom - di;
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
if (bp < 0 && (bp - cx) < 0)
|
|
|
|
cx = 0;
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
if (di < 0 && (di - dx) < 0)
|
|
|
|
dx = 0;
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
w_map->scrolls[0].h_left = cx;
|
|
|
|
w_map->scrolls[0].v_top = dx;
|
2020-11-03 22:29:22 +01:00
|
|
|
WidgetScrollUpdateThumbs(w_map, WIDX_MAP);
|
2015-07-01 01:58:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068CD35 (part of 0x0068CA8F)
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapShowDefaultScenarioEditorButtons(rct_window* w)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2020-11-27 04:14:20 +01:00
|
|
|
w->widgets[WIDX_BUILD_PARK_ENTRANCE].type = WindowWidgetType::FlatBtn;
|
|
|
|
w->widgets[WIDX_PEOPLE_STARTING_POSITION].type = WindowWidgetType::FlatBtn;
|
|
|
|
w->widgets[WIDX_MAP_SIZE_SPINNER].type = WindowWidgetType::Spinner;
|
|
|
|
w->widgets[WIDX_MAP_SIZE_SPINNER_UP].type = WindowWidgetType::Button;
|
|
|
|
w->widgets[WIDX_MAP_SIZE_SPINNER_DOWN].type = WindowWidgetType::Button;
|
2016-07-30 21:10:04 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
// Only show this in the scenario editor, even when in sandbox mode.
|
|
|
|
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR)
|
2020-11-27 04:14:20 +01:00
|
|
|
w->widgets[WIDX_MAP_GENERATOR].type = WindowWidgetType::Button;
|
2016-07-30 21:10:04 +02:00
|
|
|
|
2020-06-03 00:40:47 +02:00
|
|
|
auto ft = Formatter::Common();
|
|
|
|
ft.Increment(2);
|
|
|
|
ft.Add<uint16_t>(gMapSize - 2);
|
2015-07-01 01:58:13 +02:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapInputsizeLand(rct_window* w)
|
2015-07-01 01:58:13 +02:00
|
|
|
{
|
2021-08-24 20:12:05 +02:00
|
|
|
Formatter ft;
|
|
|
|
ft.Add<int16_t>(MINIMUM_TOOL_SIZE);
|
|
|
|
ft.Add<int16_t>(MAXIMUM_TOOL_SIZE);
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowTextInputOpen(w, WIDX_LAND_TOOL, STR_SELECTION_SIZE, STR_ENTER_SELECTION_SIZE, ft, STR_NONE, STR_NONE, 3);
|
2015-07-01 01:58:13 +02:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapInputsizeMap(rct_window* w)
|
2015-07-01 01:58:13 +02:00
|
|
|
{
|
2021-08-24 20:12:05 +02:00
|
|
|
Formatter ft;
|
|
|
|
ft.Add<int16_t>(MINIMUM_MAP_SIZE_PRACTICAL);
|
|
|
|
ft.Add<int16_t>(MAXIMUM_MAP_SIZE_PRACTICAL);
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowTextInputOpen(w, WIDX_MAP_SIZE_SPINNER, STR_MAP_SIZE_2, STR_ENTER_MAP_SIZE, ft, STR_NONE, STR_NONE, 4);
|
2015-07-01 01:58:13 +02:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapDrawTabImages(rct_window* w, rct_drawpixelinfo* dpi)
|
2015-07-01 01:58:13 +02:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
uint32_t image;
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
// Guest tab image (animated)
|
|
|
|
image = SPR_TAB_GUESTS_0;
|
|
|
|
if (w->selected_tab == PAGE_PEEPS)
|
|
|
|
image += w->list_information_type / 4;
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2020-03-01 20:32:35 +01:00
|
|
|
gfx_draw_sprite(
|
2021-03-23 11:58:09 +01:00
|
|
|
dpi, ImageId(image),
|
|
|
|
w->windowPos + ScreenCoordsXY{ w->widgets[WIDX_PEOPLE_TAB].left, w->widgets[WIDX_PEOPLE_TAB].top });
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
// Ride/stall tab image (animated)
|
|
|
|
image = SPR_TAB_RIDE_0;
|
|
|
|
if (w->selected_tab == PAGE_RIDES)
|
|
|
|
image += w->list_information_type / 4;
|
2015-07-01 01:58:13 +02:00
|
|
|
|
2020-03-01 20:32:35 +01:00
|
|
|
gfx_draw_sprite(
|
2021-03-23 11:58:09 +01:00
|
|
|
dpi, ImageId(image), w->windowPos + ScreenCoordsXY{ w->widgets[WIDX_RIDES_TAB].left, w->widgets[WIDX_RIDES_TAB].top });
|
2015-07-01 01:58:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2015-12-11 16:38:37 +01:00
|
|
|
* part of window_map_paint_peep_overlay and window_map_paint_train_overlay
|
2015-07-01 01:58:13 +02:00
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static MapCoordsXY WindowMapTransformToMapCoords(CoordsXY c)
|
2015-02-14 14:24:18 +01:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t x = c.x, y = c.y;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
switch (get_current_rotation())
|
|
|
|
{
|
|
|
|
case 3:
|
|
|
|
std::swap(x, y);
|
2019-12-30 16:03:51 +01:00
|
|
|
x = MAXIMUM_MAP_SIZE_BIG - 1 - x;
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2019-12-30 16:03:51 +01:00
|
|
|
x = MAXIMUM_MAP_SIZE_BIG - 1 - x;
|
|
|
|
y = MAXIMUM_MAP_SIZE_BIG - 1 - y;
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
std::swap(x, y);
|
2019-12-30 16:03:51 +01:00
|
|
|
y = MAXIMUM_MAP_SIZE_BIG - 1 - y;
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2018-03-08 21:11:34 +01:00
|
|
|
x /= 32;
|
|
|
|
y /= 32;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
return { -x + y + MAXIMUM_MAP_SIZE_TECHNICAL - 8, x + y - 8 };
|
2015-02-14 14:24:18 +01:00
|
|
|
}
|
|
|
|
|
2021-01-23 07:45:14 +01:00
|
|
|
static void DrawMapPeepPixel(Peep* peep, const uint8_t flashColour, rct_drawpixelinfo* dpi)
|
|
|
|
{
|
|
|
|
if (peep->x == LOCATION_NULL)
|
|
|
|
return;
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
MapCoordsXY c = WindowMapTransformToMapCoords({ peep->x, peep->y });
|
2021-01-23 07:45:14 +01:00
|
|
|
auto leftTop = ScreenCoordsXY{ c.x, c.y };
|
|
|
|
auto rightBottom = leftTop;
|
|
|
|
uint8_t colour = DefaultPeepMapColour;
|
2021-11-24 14:37:47 +01:00
|
|
|
if (EntityGetFlashing(peep))
|
2021-01-23 07:45:14 +01:00
|
|
|
{
|
|
|
|
colour = flashColour;
|
|
|
|
// If flashing then map peep pixel size is increased (by moving left top downwards)
|
|
|
|
if (flashColour != DefaultPeepMapColour)
|
|
|
|
{
|
|
|
|
leftTop.x--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gfx_fill_rect(dpi, { leftTop, rightBottom }, colour);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint8_t MapGetGuestFlashColour()
|
|
|
|
{
|
|
|
|
uint8_t colour = DefaultPeepMapColour;
|
|
|
|
if ((gWindowMapFlashingFlags & MapFlashingFlags::FlashGuests) != 0)
|
|
|
|
{
|
|
|
|
colour = GuestMapColour;
|
|
|
|
if ((gWindowMapFlashingFlags & MapFlashingFlags::SwitchColour) == 0)
|
|
|
|
colour = GuestMapColourAlternate;
|
|
|
|
}
|
|
|
|
return colour;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint8_t MapGetStaffFlashColour()
|
|
|
|
{
|
|
|
|
uint8_t colour = DefaultPeepMapColour;
|
|
|
|
if ((gWindowMapFlashingFlags & MapFlashingFlags::FlashStaff) != 0)
|
|
|
|
{
|
|
|
|
colour = StaffMapColour;
|
|
|
|
if ((gWindowMapFlashingFlags & MapFlashingFlags::SwitchColour) == 0)
|
|
|
|
colour = StaffMapColourAlternate;
|
|
|
|
}
|
|
|
|
return colour;
|
|
|
|
}
|
|
|
|
|
2015-02-14 13:29:09 +01:00
|
|
|
/**
|
2015-07-01 01:58:13 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x0068DADA
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapPaintPeepOverlay(rct_drawpixelinfo* dpi)
|
2015-02-14 13:29:09 +01:00
|
|
|
{
|
2021-01-23 07:45:14 +01:00
|
|
|
auto flashColour = MapGetGuestFlashColour();
|
2021-03-16 12:18:06 +01:00
|
|
|
for (auto guest : EntityList<Guest>())
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2021-01-23 07:45:14 +01:00
|
|
|
DrawMapPeepPixel(guest, flashColour, dpi);
|
|
|
|
}
|
|
|
|
flashColour = MapGetStaffFlashColour();
|
2021-03-16 12:18:06 +01:00
|
|
|
for (auto staff : EntityList<Staff>())
|
2021-01-23 07:45:14 +01:00
|
|
|
{
|
|
|
|
DrawMapPeepPixel(staff, flashColour, dpi);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-02-14 13:29:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-07-01 01:58:13 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x0068DBC1
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapPaintTrainOverlay(rct_drawpixelinfo* dpi)
|
2015-02-14 13:29:09 +01:00
|
|
|
{
|
2021-03-15 09:13:00 +01:00
|
|
|
for (auto train : TrainManager::View())
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2020-07-31 08:48:27 +02:00
|
|
|
for (Vehicle* vehicle = train; vehicle != nullptr; vehicle = GetEntity<Vehicle>(vehicle->next_vehicle_on_train))
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2018-03-08 21:11:34 +01:00
|
|
|
if (vehicle->x == LOCATION_NULL)
|
2017-06-06 23:24:18 +02:00
|
|
|
continue;
|
2015-02-14 14:03:41 +01:00
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
MapCoordsXY c = WindowMapTransformToMapCoords({ vehicle->x, vehicle->y });
|
2015-02-14 14:03:41 +01:00
|
|
|
|
2020-07-13 19:36:49 +02:00
|
|
|
gfx_fill_rect(dpi, { { c.x, c.y }, { c.x, c.y } }, PALETTE_INDEX_171);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
2015-02-14 13:29:09 +01:00
|
|
|
}
|
|
|
|
|
2015-02-15 01:04:48 +01:00
|
|
|
/**
|
2015-12-11 16:38:37 +01:00
|
|
|
* The call to gfx_fill_rect was originally wrapped in sub_68DABD which made sure that arguments were ordered correctly,
|
|
|
|
* but it doesn't look like it's ever necessary here so the call was removed.
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-07-01 01:58:13 +02:00
|
|
|
* rct2: 0x0068D8CE
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapPaintHudRectangle(rct_drawpixelinfo* dpi)
|
2015-02-15 01:04:48 +01:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
rct_window* main_window = window_get_main();
|
2017-08-15 10:07:44 +02:00
|
|
|
if (main_window == nullptr)
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
rct_viewport* viewport = main_window->viewport;
|
2017-08-15 10:07:44 +02:00
|
|
|
if (viewport == nullptr)
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
|
|
|
|
2020-03-01 21:24:44 +01:00
|
|
|
auto offset = MiniMapOffsets[get_current_rotation()];
|
2020-07-13 19:36:49 +02:00
|
|
|
auto leftTop = ScreenCoordsXY{ (viewport->viewPos.x >> 5) + offset.x, (viewport->viewPos.y >> 4) + offset.y };
|
|
|
|
auto rightBottom = ScreenCoordsXY{ ((viewport->viewPos.x + viewport->view_width) >> 5) + offset.x,
|
|
|
|
((viewport->viewPos.y + viewport->view_height) >> 4) + offset.y };
|
|
|
|
auto rightTop = ScreenCoordsXY{ rightBottom.x, leftTop.y };
|
|
|
|
auto leftBottom = ScreenCoordsXY{ leftTop.x, rightBottom.y };
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// top horizontal lines
|
2020-07-13 19:36:49 +02:00
|
|
|
gfx_fill_rect(dpi, { leftTop, leftTop + ScreenCoordsXY{ 3, 0 } }, PALETTE_INDEX_56);
|
|
|
|
gfx_fill_rect(dpi, { rightTop - ScreenCoordsXY{ 3, 0 }, rightTop }, PALETTE_INDEX_56);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// left vertical lines
|
2020-07-13 19:36:49 +02:00
|
|
|
gfx_fill_rect(dpi, { leftTop, leftTop + ScreenCoordsXY{ 0, 3 } }, PALETTE_INDEX_56);
|
|
|
|
gfx_fill_rect(dpi, { leftBottom - ScreenCoordsXY{ 0, 3 }, leftBottom }, PALETTE_INDEX_56);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// bottom horizontal lines
|
2020-07-13 19:36:49 +02:00
|
|
|
gfx_fill_rect(dpi, { leftBottom, leftBottom + ScreenCoordsXY{ 3, 0 } }, PALETTE_INDEX_56);
|
|
|
|
gfx_fill_rect(dpi, { rightBottom - ScreenCoordsXY{ 3, 0 }, rightBottom }, PALETTE_INDEX_56);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// right vertical lines
|
2020-07-13 19:36:49 +02:00
|
|
|
gfx_fill_rect(dpi, { rightTop, rightTop + ScreenCoordsXY{ 0, 3 } }, PALETTE_INDEX_56);
|
|
|
|
gfx_fill_rect(dpi, { rightBottom - ScreenCoordsXY{ 0, 3 }, rightBottom }, PALETTE_INDEX_56);
|
2015-02-15 01:04:48 +01:00
|
|
|
}
|
|
|
|
|
2014-05-14 12:43:14 +02:00
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-07-01 01:58:13 +02:00
|
|
|
* rct2: 0x0068D24E
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapSetLandRightsToolUpdate(const ScreenCoordsXY& screenCoords)
|
2014-05-14 12:43:14 +02:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
rct_viewport* viewport;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
map_invalidate_selection_rect();
|
|
|
|
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
|
2019-11-29 17:17:01 +01:00
|
|
|
auto mapCoords = screen_get_map_xy(screenCoords, &viewport);
|
2021-09-13 18:47:13 +02:00
|
|
|
if (!mapCoords.has_value())
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
|
|
|
|
gMapSelectType = MAP_SELECT_TYPE_FULL;
|
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t landRightsToolSize = _landRightsToolSize;
|
2018-04-08 19:34:36 +02:00
|
|
|
if (landRightsToolSize == 0)
|
|
|
|
landRightsToolSize = 1;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t size = (landRightsToolSize * 32) - 32;
|
|
|
|
int32_t radius = (landRightsToolSize * 16) - 16;
|
2019-11-29 17:17:01 +01:00
|
|
|
mapCoords->x = (mapCoords->x - radius) & 0xFFE0;
|
|
|
|
mapCoords->y = (mapCoords->y - radius) & 0xFFE0;
|
2019-12-12 12:04:40 +01:00
|
|
|
gMapSelectPositionA = *mapCoords;
|
2019-11-29 17:17:01 +01:00
|
|
|
gMapSelectPositionB.x = mapCoords->x + size;
|
|
|
|
gMapSelectPositionB.y = mapCoords->y + size;
|
2017-06-06 23:24:18 +02:00
|
|
|
map_invalidate_selection_rect();
|
2014-05-24 00:00:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-07-01 01:58:13 +02:00
|
|
|
* rct2: 0x00666EEF
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static CoordsXYZD PlaceParkEntranceGetMapPosition(const ScreenCoordsXY& screenCoords)
|
2014-05-24 00:00:08 +02:00
|
|
|
{
|
2019-11-14 23:09:27 +01:00
|
|
|
CoordsXYZD parkEntranceMapPosition{ 0, 0, 0, INVALID_DIRECTION };
|
2020-11-03 11:59:00 +01:00
|
|
|
const CoordsXY mapCoords = ViewportInteractionGetTileStartAtCursor(screenCoords);
|
2019-11-14 23:09:27 +01:00
|
|
|
parkEntranceMapPosition = { mapCoords.x, mapCoords.y, 0, INVALID_DIRECTION };
|
2021-09-09 01:48:53 +02:00
|
|
|
if (parkEntranceMapPosition.IsNull())
|
2019-11-14 23:09:27 +01:00
|
|
|
return parkEntranceMapPosition;
|
|
|
|
|
|
|
|
auto surfaceElement = map_get_surface_element_at(mapCoords);
|
2019-10-08 13:45:30 +02:00
|
|
|
if (surfaceElement == nullptr)
|
|
|
|
{
|
2021-09-09 01:48:53 +02:00
|
|
|
parkEntranceMapPosition.SetNull();
|
2019-10-08 13:45:30 +02:00
|
|
|
return parkEntranceMapPosition;
|
|
|
|
}
|
|
|
|
|
2020-01-19 16:12:48 +01:00
|
|
|
parkEntranceMapPosition.z = surfaceElement->GetWaterHeight();
|
2019-11-14 23:09:27 +01:00
|
|
|
if (parkEntranceMapPosition.z == 0)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2019-12-22 22:14:02 +01:00
|
|
|
parkEntranceMapPosition.z = surfaceElement->GetBaseZ();
|
2019-08-11 10:06:04 +02:00
|
|
|
if ((surfaceElement->GetSlope() & TILE_ELEMENT_SLOPE_ALL_CORNERS_UP) != 0)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2019-11-14 23:09:27 +01:00
|
|
|
parkEntranceMapPosition.z += 16;
|
2019-08-11 10:06:04 +02:00
|
|
|
if (surfaceElement->GetSlope() & TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2019-11-14 23:09:27 +01:00
|
|
|
parkEntranceMapPosition.z += 16;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-11-14 23:09:27 +01:00
|
|
|
parkEntranceMapPosition.direction = (gWindowSceneryRotation - get_current_rotation()) & 3;
|
|
|
|
return parkEntranceMapPosition;
|
2015-07-01 01:58:13 +02:00
|
|
|
}
|
2014-05-24 00:00:08 +02:00
|
|
|
|
2015-07-01 01:58:13 +02:00
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-07-01 01:58:13 +02:00
|
|
|
* rct2: 0x00666FD0
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapPlaceParkEntranceToolUpdate(const ScreenCoordsXY& screenCoords)
|
2015-07-01 01:58:13 +02:00
|
|
|
{
|
2019-11-14 23:09:27 +01:00
|
|
|
int32_t sideDirection;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
map_invalidate_selection_rect();
|
|
|
|
map_invalidate_map_selection_tiles();
|
|
|
|
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
|
2017-11-01 18:14:01 +01:00
|
|
|
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
|
2017-06-06 23:24:18 +02:00
|
|
|
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
|
2021-11-23 14:18:07 +01:00
|
|
|
CoordsXYZD parkEntrancePosition = PlaceParkEntranceGetMapPosition(screenCoords);
|
2021-09-09 01:48:53 +02:00
|
|
|
if (parkEntrancePosition.IsNull())
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
park_entrance_remove_ghost();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-11-14 23:09:27 +01:00
|
|
|
sideDirection = (parkEntrancePosition.direction + 1) & 3;
|
2019-03-28 19:29:51 +01:00
|
|
|
gMapSelectionTiles.clear();
|
2019-11-14 23:09:27 +01:00
|
|
|
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 });
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2019-12-30 17:51:35 +01:00
|
|
|
gMapSelectArrowPosition = parkEntrancePosition;
|
2019-11-14 23:09:27 +01:00
|
|
|
gMapSelectArrowDirection = parkEntrancePosition.direction;
|
2017-11-01 18:14:01 +01:00
|
|
|
|
|
|
|
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT | MAP_SELECT_FLAG_ENABLE_ARROW;
|
2017-06-06 23:24:18 +02:00
|
|
|
map_invalidate_map_selection_tiles();
|
2019-12-12 10:58:27 +01:00
|
|
|
if (gParkEntranceGhostExists && parkEntrancePosition == gParkEntranceGhostPosition)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
park_entrance_remove_ghost();
|
2019-12-12 10:58:27 +01:00
|
|
|
park_entrance_place_ghost(parkEntrancePosition);
|
2015-07-01 01:58:13 +02:00
|
|
|
}
|
2014-05-24 00:00:08 +02:00
|
|
|
|
2015-07-01 01:58:13 +02:00
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-07-01 01:58:13 +02:00
|
|
|
* rct2: 0x0068D4E9
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapSetPeepSpawnToolUpdate(const ScreenCoordsXY& screenCoords)
|
2015-07-01 01:58:13 +02:00
|
|
|
{
|
2020-01-13 02:27:30 +01:00
|
|
|
int32_t mapZ, direction;
|
2018-11-01 13:53:50 +01:00
|
|
|
TileElement* tileElement;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
map_invalidate_selection_rect();
|
|
|
|
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
|
|
|
|
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
|
2020-01-13 02:27:30 +01:00
|
|
|
auto mapCoords = footpath_bridge_get_info_from_pos(screenCoords, &direction, &tileElement);
|
2021-09-09 01:48:53 +02:00
|
|
|
if (mapCoords.IsNull())
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
|
|
|
|
2019-12-22 22:14:02 +01:00
|
|
|
mapZ = tileElement->GetBaseZ();
|
2021-12-11 00:39:39 +01:00
|
|
|
if (tileElement->GetType() == TileElementType::Surface)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2018-09-14 14:54:12 +02:00
|
|
|
if ((tileElement->AsSurface()->GetSlope() & TILE_ELEMENT_SLOPE_ALL_CORNERS_UP) != 0)
|
2017-06-06 23:24:18 +02:00
|
|
|
mapZ += 16;
|
2018-09-14 14:54:12 +02:00
|
|
|
if (tileElement->AsSurface()->GetSlope() & TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT)
|
2017-06-06 23:24:18 +02:00
|
|
|
mapZ += 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
|
|
|
|
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW;
|
|
|
|
gMapSelectType = MAP_SELECT_TYPE_FULL;
|
2020-01-13 02:27:30 +01:00
|
|
|
gMapSelectPositionA = mapCoords;
|
|
|
|
gMapSelectPositionB = mapCoords;
|
|
|
|
gMapSelectArrowPosition = CoordsXYZ{ mapCoords, mapZ };
|
2019-01-05 16:41:19 +01:00
|
|
|
gMapSelectArrowDirection = direction_reverse(direction);
|
2017-06-06 23:24:18 +02:00
|
|
|
map_invalidate_selection_rect();
|
2015-07-01 16:17:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-07-01 16:17:25 +02:00
|
|
|
* rct2: 0x006670A4
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapPlaceParkEntranceToolDown(const ScreenCoordsXY& screenCoords)
|
2015-07-01 16:17:25 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
park_entrance_remove_ghost();
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
CoordsXYZD parkEntrancePosition = PlaceParkEntranceGetMapPosition(screenCoords);
|
2021-09-09 01:48:53 +02:00
|
|
|
if (!parkEntrancePosition.IsNull())
|
2017-10-18 20:57:36 +02:00
|
|
|
{
|
2021-04-14 15:03:09 +02:00
|
|
|
auto gameAction = PlaceParkEntranceAction(parkEntrancePosition, gFootpathSelectedId);
|
2019-12-19 21:48:20 +01:00
|
|
|
auto result = GameActions::Execute(&gameAction);
|
2021-11-24 08:35:08 +01:00
|
|
|
if (result.Error == GameActions::Status::Ok)
|
2017-10-18 20:57:36 +02:00
|
|
|
{
|
2021-11-24 08:35:08 +01:00
|
|
|
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result.Position);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
2015-07-01 16:17:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-07-01 16:17:25 +02:00
|
|
|
* rct2: 0x0068D573
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMapSetPeepSpawnToolDown(const ScreenCoordsXY& screenCoords)
|
2015-07-01 16:17:25 +02:00
|
|
|
{
|
2018-11-01 13:53:50 +01:00
|
|
|
TileElement* tileElement;
|
2020-01-13 02:20:29 +01:00
|
|
|
int32_t mapZ, direction;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2018-02-19 21:11:14 +01:00
|
|
|
// Verify footpath exists at location, and retrieve coordinates
|
2020-01-13 02:20:29 +01:00
|
|
|
auto mapCoords = footpath_get_coordinates_from_pos(screenCoords, &direction, &tileElement);
|
2021-09-09 01:48:53 +02:00
|
|
|
if (mapCoords.IsNull())
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
|
|
|
|
2019-12-22 22:14:02 +01:00
|
|
|
mapZ = tileElement->GetBaseZ();
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2020-01-13 02:20:29 +01:00
|
|
|
auto gameAction = PlacePeepSpawnAction({ mapCoords, mapZ, static_cast<Direction>(direction) });
|
2019-12-19 21:48:20 +01:00
|
|
|
auto result = GameActions::Execute(&gameAction);
|
2021-11-24 08:35:08 +01:00
|
|
|
if (result.Error == GameActions::Status::Ok)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2021-11-24 08:35:08 +01:00
|
|
|
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result.Position);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-07-01 16:17:25 +02:00
|
|
|
}
|
2015-07-02 01:37:55 +02:00
|
|
|
|
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-07-02 01:37:55 +02:00
|
|
|
* rct2: 0x0068D641
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void MapWindowIncreaseMapSize()
|
2015-07-02 01:37:55 +02:00
|
|
|
{
|
2021-09-29 17:46:03 +02:00
|
|
|
auto increaseMapSizeAction = ChangeMapSizeAction(gMapSize + 1);
|
|
|
|
GameActions::Execute(&increaseMapSizeAction);
|
2015-07-02 01:37:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-07-02 01:37:55 +02:00
|
|
|
* rct2: 0x0068D6B4
|
|
|
|
*/
|
2021-11-23 14:18:07 +01:00
|
|
|
static void MapWindowDecreaseMapSize()
|
2015-07-02 01:37:55 +02:00
|
|
|
{
|
2021-09-29 17:46:03 +02:00
|
|
|
auto decreaseMapSizeAction = ChangeMapSizeAction(gMapSize - 1);
|
|
|
|
GameActions::Execute(&decreaseMapSizeAction);
|
2015-07-02 01:37:55 +02:00
|
|
|
}
|
|
|
|
|
2021-01-23 07:45:14 +01:00
|
|
|
static constexpr const uint16_t WaterColour = MapColour(PALETTE_INDEX_195);
|
2018-06-20 17:28:51 +02:00
|
|
|
static constexpr const uint16_t TerrainColour[] = {
|
2021-01-23 07:45:14 +01:00
|
|
|
MapColour(PALETTE_INDEX_73), // TERRAIN_GRASS
|
|
|
|
MapColour(PALETTE_INDEX_40), // TERRAIN_SAND
|
|
|
|
MapColour(PALETTE_INDEX_108), // TERRAIN_DIRT
|
|
|
|
MapColour(PALETTE_INDEX_12), // TERRAIN_ROCK
|
|
|
|
MapColour(PALETTE_INDEX_62), // TERRAIN_MARTIAN
|
|
|
|
MapColour2(PALETTE_INDEX_10, PALETTE_INDEX_16), // TERRAIN_CHECKERBOARD
|
|
|
|
MapColour2(PALETTE_INDEX_73, PALETTE_INDEX_108), // TERRAIN_GRASS_CLUMPS
|
|
|
|
MapColour(PALETTE_INDEX_141), // TERRAIN_ICE
|
|
|
|
MapColour2(PALETTE_INDEX_172, PALETTE_INDEX_10), // TERRAIN_GRID_RED
|
|
|
|
MapColour2(PALETTE_INDEX_54, PALETTE_INDEX_10), // TERRAIN_GRID_YELLOW
|
|
|
|
MapColour2(PALETTE_INDEX_162, PALETTE_INDEX_10), // TERRAIN_GRID_BLUE
|
|
|
|
MapColour2(PALETTE_INDEX_102, PALETTE_INDEX_10), // TERRAIN_GRID_GREEN
|
|
|
|
MapColour(PALETTE_INDEX_111), // TERRAIN_SAND_DARK
|
|
|
|
MapColour(PALETTE_INDEX_222), // TERRAIN_SAND_LIGHT
|
2015-07-02 02:50:13 +02:00
|
|
|
};
|
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
static constexpr const uint16_t ElementTypeMaskColour[] = {
|
2018-06-22 23:21:44 +02:00
|
|
|
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
|
2015-07-02 02:50:13 +02:00
|
|
|
};
|
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
static constexpr const uint16_t ElementTypeAddColour[] = {
|
2021-01-23 07:45:14 +01:00
|
|
|
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
|
|
|
};
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static uint16_t MapWindowGetPixelColourPeep(const CoordsXY& c)
|
2015-07-02 02:50:13 +02:00
|
|
|
{
|
2019-08-11 10:06:04 +02:00
|
|
|
auto* surfaceElement = map_get_surface_element_at(c);
|
2019-10-08 13:45:30 +02:00
|
|
|
if (surfaceElement == nullptr)
|
|
|
|
return 0;
|
2019-08-11 10:06:04 +02:00
|
|
|
uint16_t colour = TerrainColour[surfaceElement->GetSurfaceStyle()];
|
|
|
|
if (surfaceElement->GetWaterHeight() > 0)
|
2017-06-06 23:24:18 +02:00
|
|
|
colour = WaterColour;
|
|
|
|
|
2019-08-11 10:06:04 +02:00
|
|
|
if (!(surfaceElement->GetOwnership() & OWNERSHIP_OWNED))
|
2021-01-23 07:45:14 +01:00
|
|
|
colour = MapColourUnowned(colour);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2020-04-18 13:32:48 +02:00
|
|
|
const int32_t maxSupportedTileElementType = static_cast<int32_t>(std::size(ElementTypeAddColour));
|
2019-08-11 10:06:04 +02:00
|
|
|
auto tileElement = reinterpret_cast<TileElement*>(surfaceElement);
|
2018-05-24 11:44:53 +02:00
|
|
|
while (!(tileElement++)->IsLastForTile())
|
|
|
|
{
|
2018-12-13 03:47:56 +01:00
|
|
|
if (tileElement->IsGhost())
|
2019-05-08 22:33:56 +02:00
|
|
|
{
|
2021-01-23 07:45:14 +01:00
|
|
|
colour = MapColour(PALETTE_INDEX_21);
|
2019-05-08 22:33:56 +02:00
|
|
|
break;
|
|
|
|
}
|
2018-12-13 03:47:56 +01:00
|
|
|
|
2021-12-11 00:39:39 +01:00
|
|
|
auto tileElementType = tileElement->GetType();
|
2021-12-10 22:43:17 +01:00
|
|
|
if (EnumValue(tileElementType) >= maxSupportedTileElementType)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2021-12-11 00:39:39 +01:00
|
|
|
tileElementType = TileElementType::Surface;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2021-12-10 22:43:17 +01:00
|
|
|
colour &= ElementTypeMaskColour[EnumValue(tileElementType)];
|
|
|
|
colour |= ElementTypeAddColour[EnumValue(tileElementType)];
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return colour;
|
2015-07-02 02:50:13 +02:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static uint16_t MapWindowGetPixelColourRide(const CoordsXY& c)
|
2015-07-02 02:50:13 +02:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
Ride* ride;
|
2021-01-23 07:45:14 +01:00
|
|
|
uint16_t colourA = 0; // highlight colour
|
|
|
|
uint16_t colourB = MapColour(PALETTE_INDEX_13); // surface colour (dark grey)
|
2018-06-22 23:21:44 +02:00
|
|
|
|
2018-03-08 20:26:48 +01:00
|
|
|
// as an improvement we could use first_element to show underground stuff?
|
2019-08-11 10:06:04 +02:00
|
|
|
TileElement* tileElement = reinterpret_cast<TileElement*>(map_get_surface_element_at(c));
|
2018-06-22 23:21:44 +02:00
|
|
|
do
|
|
|
|
{
|
2019-10-08 13:45:30 +02:00
|
|
|
if (tileElement == nullptr)
|
|
|
|
break;
|
|
|
|
|
2018-12-13 03:47:56 +01:00
|
|
|
if (tileElement->IsGhost())
|
2019-05-08 22:33:56 +02:00
|
|
|
{
|
2021-01-23 07:45:14 +01:00
|
|
|
colourA = MapColour(PALETTE_INDEX_21);
|
2019-05-08 22:33:56 +02:00
|
|
|
break;
|
|
|
|
}
|
2018-12-13 03:47:56 +01:00
|
|
|
|
2021-12-11 00:39:39 +01:00
|
|
|
switch (tileElement->GetType())
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Surface:
|
2018-09-15 10:56:35 +02:00
|
|
|
if (tileElement->AsSurface()->GetWaterHeight() > 0)
|
2018-06-22 23:21:44 +02:00
|
|
|
// Why is this a different water colour as above (195)?
|
2021-01-23 07:45:14 +01:00
|
|
|
colourB = MapColour(PALETTE_INDEX_194);
|
2018-09-14 14:54:12 +02:00
|
|
|
if (!(tileElement->AsSurface()->GetOwnership() & OWNERSHIP_OWNED))
|
2021-01-23 07:45:14 +01:00
|
|
|
colourB = MapColourUnowned(colourB);
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Path:
|
2021-01-23 07:45:14 +01:00
|
|
|
colourA = MapColour(PALETTE_INDEX_14); // lighter grey
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Entrance:
|
2018-09-26 12:13:44 +02:00
|
|
|
if (tileElement->AsEntrance()->GetEntranceType() == ENTRANCE_TYPE_PARK_ENTRANCE)
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
2018-10-06 14:14:09 +02:00
|
|
|
ride = get_ride(tileElement->AsEntrance()->GetRideIndex());
|
2019-08-09 09:06:25 +02:00
|
|
|
if (ride != nullptr)
|
2020-06-19 20:21:16 +02:00
|
|
|
{
|
2021-02-24 14:02:58 +01:00
|
|
|
const auto& colourKey = ride->GetRideTypeDescriptor().ColourKey;
|
2020-06-19 20:21:16 +02:00
|
|
|
colourA = RideKeyColours[static_cast<size_t>(colourKey)];
|
|
|
|
}
|
2018-10-06 14:14:09 +02:00
|
|
|
break;
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Track:
|
2018-09-18 13:10:29 +02:00
|
|
|
ride = get_ride(tileElement->AsTrack()->GetRideIndex());
|
2019-08-09 09:06:25 +02:00
|
|
|
if (ride != nullptr)
|
2020-06-19 20:21:16 +02:00
|
|
|
{
|
2021-02-24 14:02:58 +01:00
|
|
|
const auto& colourKey = ride->GetRideTypeDescriptor().ColourKey;
|
2020-06-19 20:21:16 +02:00
|
|
|
colourA = RideKeyColours[static_cast<size_t>(colourKey)];
|
|
|
|
}
|
|
|
|
|
2021-12-11 00:30:59 +01:00
|
|
|
break;
|
|
|
|
default:
|
2017-06-06 23:24:18 +02:00
|
|
|
break;
|
|
|
|
}
|
2018-05-24 11:44:53 +02:00
|
|
|
} while (!(tileElement++)->IsLastForTile());
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2018-03-08 20:26:48 +01:00
|
|
|
if (colourA != 0)
|
|
|
|
return colourA;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2018-03-08 20:26:48 +01:00
|
|
|
return colourB;
|
2015-07-02 02:50:13 +02:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void MapWindowSetPixels(rct_window* w)
|
2015-07-02 01:37:55 +02:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
uint16_t colour = 0;
|
|
|
|
int32_t x = 0, y = 0, dx = 0, dy = 0;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t pos = (_currentLine * (MAP_WINDOW_MAP_SIZE - 1)) + MAXIMUM_MAP_SIZE_TECHNICAL - 1;
|
2020-03-01 21:24:44 +01:00
|
|
|
auto destinationPosition = ScreenCoordsXY{ pos % MAP_WINDOW_MAP_SIZE, pos / MAP_WINDOW_MAP_SIZE };
|
2018-01-21 03:25:20 +01:00
|
|
|
auto destination = _mapImageData.data() + (destinationPosition.y * MAP_WINDOW_MAP_SIZE) + destinationPosition.x;
|
2018-06-22 23:21:44 +02:00
|
|
|
switch (get_current_rotation())
|
|
|
|
{
|
|
|
|
case 0:
|
2019-12-30 16:03:51 +01:00
|
|
|
x = _currentLine * COORDS_XY_STEP;
|
2018-06-22 23:21:44 +02:00
|
|
|
y = 0;
|
|
|
|
dx = 0;
|
2019-12-30 16:03:51 +01:00
|
|
|
dy = COORDS_XY_STEP;
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2019-12-30 16:03:51 +01:00
|
|
|
x = MAXIMUM_TILE_START_XY;
|
|
|
|
y = _currentLine * COORDS_XY_STEP;
|
|
|
|
dx = -COORDS_XY_STEP;
|
2018-06-22 23:21:44 +02:00
|
|
|
dy = 0;
|
|
|
|
break;
|
|
|
|
case 2:
|
2019-12-30 16:03:51 +01:00
|
|
|
x = MAXIMUM_MAP_SIZE_BIG - ((_currentLine + 1) * COORDS_XY_STEP);
|
|
|
|
y = MAXIMUM_TILE_START_XY;
|
2018-06-22 23:21:44 +02:00
|
|
|
dx = 0;
|
2019-12-30 16:03:51 +01:00
|
|
|
dy = -COORDS_XY_STEP;
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
x = 0;
|
2019-12-30 16:03:51 +01:00
|
|
|
y = MAXIMUM_MAP_SIZE_BIG - ((_currentLine + 1) * COORDS_XY_STEP);
|
|
|
|
dx = COORDS_XY_STEP;
|
2018-06-22 23:21:44 +02:00
|
|
|
dy = 0;
|
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
for (int32_t i = 0; i < MAXIMUM_MAP_SIZE_TECHNICAL; i++)
|
|
|
|
{
|
2021-06-15 08:49:57 +02:00
|
|
|
if (!map_is_edge({ x, y }))
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
|
|
|
switch (w->selected_tab)
|
|
|
|
{
|
|
|
|
case PAGE_PEEPS:
|
2021-11-23 14:18:07 +01:00
|
|
|
colour = MapWindowGetPixelColourPeep({ x, y });
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
case PAGE_RIDES:
|
2021-11-23 14:18:07 +01:00
|
|
|
colour = MapWindowGetPixelColourRide({ x, y });
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
destination[0] = (colour >> 8) & 0xFF;
|
|
|
|
destination[1] = colour;
|
|
|
|
}
|
|
|
|
x += dx;
|
|
|
|
y += dy;
|
|
|
|
|
|
|
|
destinationPosition.x++;
|
|
|
|
destinationPosition.y++;
|
2018-01-21 03:25:20 +01:00
|
|
|
destination = _mapImageData.data() + (destinationPosition.y * MAP_WINDOW_MAP_SIZE) + destinationPosition.x;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
_currentLine++;
|
|
|
|
if (_currentLine >= MAXIMUM_MAP_SIZE_TECHNICAL)
|
|
|
|
_currentLine = 0;
|
2015-07-02 01:37:55 +02:00
|
|
|
}
|
2015-07-02 18:00:39 +02:00
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static CoordsXY MapWindowScreenToMap(ScreenCoordsXY screenCoords)
|
2015-07-02 18:00:39 +02:00
|
|
|
{
|
2020-03-01 04:47:35 +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-06-22 23:21:44 +02:00
|
|
|
|
|
|
|
switch (get_current_rotation())
|
|
|
|
{
|
|
|
|
case 0:
|
2020-02-29 03:43:29 +01:00
|
|
|
return location;
|
2018-06-22 23:21:44 +02:00
|
|
|
case 1:
|
2020-02-29 03:43:29 +01:00
|
|
|
return { MAXIMUM_MAP_SIZE_BIG - 1 - location.y, location.x };
|
2018-06-22 23:21:44 +02:00
|
|
|
case 2:
|
2020-02-29 03:43:29 +01:00
|
|
|
return { MAXIMUM_MAP_SIZE_BIG - 1 - location.x, MAXIMUM_MAP_SIZE_BIG - 1 - location.y };
|
2018-06-22 23:21:44 +02:00
|
|
|
case 3:
|
2020-02-29 03:43:29 +01:00
|
|
|
return { location.y, MAXIMUM_MAP_SIZE_BIG - 1 - location.x };
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2018-06-22 23:21:44 +02:00
|
|
|
|
|
|
|
return { 0, 0 }; // unreachable
|
2015-07-02 18:00:39 +02:00
|
|
|
}
|