2014-11-05 19:42:19 +00:00
|
|
|
/*****************************************************************************
|
2022-10-01 03:42:14 -04:00
|
|
|
* Copyright (c) 2014-2022 OpenRCT2 developers
|
2014-11-10 00:40:59 +00: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-11-10 00:40:59 +00:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
2014-11-05 19:42:19 +00:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
2020-09-29 01:45:28 +01:00
|
|
|
#include "../windows/Window.h"
|
2018-06-22 23:20:47 +02:00
|
|
|
#include "Viewport.h"
|
|
|
|
|
#include "Window.h"
|
|
|
|
|
|
2018-08-12 12:50:40 +01:00
|
|
|
#include <algorithm>
|
2018-06-22 23:20:47 +02:00
|
|
|
#include <openrct2/Context.h>
|
2018-06-02 14:34:01 +01:00
|
|
|
#include <openrct2/Editor.h>
|
|
|
|
|
#include <openrct2/Game.h>
|
2019-07-21 10:33:15 +01:00
|
|
|
#include <openrct2/GameState.h>
|
2018-06-02 14:34:01 +01:00
|
|
|
#include <openrct2/Input.h>
|
|
|
|
|
#include <openrct2/OpenRCT2.h>
|
2020-12-09 23:39:10 -07:00
|
|
|
#include <openrct2/actions/BalloonPressAction.h>
|
|
|
|
|
#include <openrct2/actions/FootpathAdditionRemoveAction.h>
|
2022-08-11 00:00:58 +02:00
|
|
|
#include <openrct2/actions/FootpathRemoveAction.h>
|
2020-12-09 23:39:10 -07:00
|
|
|
#include <openrct2/actions/LargeSceneryRemoveAction.h>
|
|
|
|
|
#include <openrct2/actions/ParkEntranceRemoveAction.h>
|
|
|
|
|
#include <openrct2/actions/SmallSceneryRemoveAction.h>
|
|
|
|
|
#include <openrct2/actions/WallRemoveAction.h>
|
2021-11-24 16:48:33 +02:00
|
|
|
#include <openrct2/entity/Balloon.h>
|
|
|
|
|
#include <openrct2/entity/Duck.h>
|
2021-11-24 16:58:01 +02:00
|
|
|
#include <openrct2/entity/EntityRegistry.h>
|
2021-11-25 23:47:24 +02:00
|
|
|
#include <openrct2/entity/Staff.h>
|
2021-12-11 18:06:06 -05:00
|
|
|
#include <openrct2/localisation/Formatter.h>
|
2018-06-22 23:20:47 +02:00
|
|
|
#include <openrct2/localisation/Localisation.h>
|
2018-06-02 14:34:01 +01:00
|
|
|
#include <openrct2/ride/Ride.h>
|
2021-12-18 19:50:29 +01:00
|
|
|
#include <openrct2/ride/RideConstruction.h>
|
2018-06-02 14:34:01 +01:00
|
|
|
#include <openrct2/ride/RideData.h>
|
|
|
|
|
#include <openrct2/ride/Track.h>
|
2021-05-29 06:01:32 +01:00
|
|
|
#include <openrct2/ride/Vehicle.h>
|
2018-06-02 14:34:01 +01:00
|
|
|
#include <openrct2/scenario/Scenario.h>
|
|
|
|
|
#include <openrct2/windows/Intent.h>
|
|
|
|
|
#include <openrct2/world/Banner.h>
|
|
|
|
|
#include <openrct2/world/Footpath.h>
|
|
|
|
|
#include <openrct2/world/LargeScenery.h>
|
2018-06-22 23:20:47 +02:00
|
|
|
#include <openrct2/world/Map.h>
|
2018-06-02 14:34:01 +01:00
|
|
|
#include <openrct2/world/Park.h>
|
2018-06-22 23:20:47 +02:00
|
|
|
#include <openrct2/world/Scenery.h>
|
2018-06-02 14:34:01 +01:00
|
|
|
#include <openrct2/world/Surface.h>
|
|
|
|
|
#include <openrct2/world/Wall.h>
|
2014-11-05 19:42:19 +00:00
|
|
|
|
2020-11-03 03:59:00 -07:00
|
|
|
static void ViewportInteractionRemoveScenery(TileElement* tileElement, const CoordsXY& mapCoords);
|
|
|
|
|
static void ViewportInteractionRemoveFootpath(TileElement* tileElement, const CoordsXY& mapCoords);
|
|
|
|
|
static void ViewportInteractionRemoveFootpathItem(TileElement* tileElement, const CoordsXY& mapCoords);
|
|
|
|
|
static void ViewportInteractionRemoveParkWall(TileElement* tileElement, const CoordsXY& mapCoords);
|
|
|
|
|
static void ViewportInteractionRemoveLargeScenery(TileElement* tileElement, const CoordsXY& mapCoords);
|
|
|
|
|
static void ViewportInteractionRemoveParkEntrance(TileElement* tileElement, CoordsXY mapCoords);
|
|
|
|
|
static Peep* ViewportInteractionGetClosestPeep(ScreenCoordsXY screenCoords, int32_t maxDistance);
|
2014-11-05 19:42:19 +00:00
|
|
|
|
2014-11-05 20:28:51 +00:00
|
|
|
/**
|
2014-11-10 00:40:59 +00:00
|
|
|
*
|
2014-11-05 20:28:51 +00:00
|
|
|
* rct2: 0x006ED9D0
|
|
|
|
|
*/
|
2020-11-03 03:59:00 -07:00
|
|
|
InteractionInfo ViewportInteractionGetItemLeft(const ScreenCoordsXY& screenCoords)
|
2014-11-05 20:28:51 +00:00
|
|
|
{
|
2020-08-02 08:32:59 +01:00
|
|
|
InteractionInfo info{};
|
2020-06-10 12:31:33 -05:00
|
|
|
// No click input for scenario editor or track manager
|
|
|
|
|
if (gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_MANAGER))
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
2014-11-10 00:40:59 +00:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
//
|
2021-04-05 18:01:43 +01:00
|
|
|
if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gEditorStep != EditorStep::RollercoasterDesigner)
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
2014-11-10 00:40:59 +00:00
|
|
|
|
2020-08-02 08:32:59 +01:00
|
|
|
info = get_map_coordinates_from_pos(
|
2020-12-29 19:09:15 +01:00
|
|
|
screenCoords,
|
2021-02-10 01:06:18 +00:00
|
|
|
EnumsToFlags(ViewportInteractionItem::Entity, ViewportInteractionItem::Ride, ViewportInteractionItem::ParkEntrance));
|
2020-12-29 19:09:15 +01:00
|
|
|
auto tileElement = info.SpriteType != ViewportInteractionItem::Entity ? info.Element : nullptr;
|
|
|
|
|
// Only valid when info.SpriteType == ViewportInteractionItem::Entity, but can't assign nullptr without compiler
|
2020-08-09 08:27:26 +02:00
|
|
|
// complaining
|
|
|
|
|
auto sprite = info.Entity;
|
2014-11-10 00:40:59 +00:00
|
|
|
|
2020-06-10 12:31:33 -05:00
|
|
|
// Allows only balloons to be popped and ducks to be quacked in title screen
|
|
|
|
|
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
|
|
|
|
|
{
|
2020-12-29 19:09:15 +01:00
|
|
|
if (info.SpriteType == ViewportInteractionItem::Entity && (sprite->Is<Balloon>() || sprite->Is<Duck>()))
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
2021-09-15 22:22:15 +02:00
|
|
|
|
|
|
|
|
info.SpriteType = ViewportInteractionItem::None;
|
|
|
|
|
return info;
|
2020-06-10 12:31:33 -05:00
|
|
|
}
|
|
|
|
|
|
2020-08-02 08:32:59 +01:00
|
|
|
switch (info.SpriteType)
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::Entity:
|
2021-03-17 08:04:41 +00:00
|
|
|
switch (sprite->Type)
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
2021-03-17 08:04:41 +00:00
|
|
|
case EntityType::Vehicle:
|
2020-08-01 11:29:54 +01:00
|
|
|
{
|
|
|
|
|
auto vehicle = sprite->As<Vehicle>();
|
2021-04-01 17:02:57 +02:00
|
|
|
if (vehicle != nullptr && vehicle->ride_subtype != OBJECT_ENTRY_INDEX_NULL)
|
2020-04-19 02:17:53 -03:00
|
|
|
vehicle->SetMapToolbar();
|
2018-06-22 23:20:47 +02:00
|
|
|
else
|
2020-12-29 19:09:15 +01:00
|
|
|
info.SpriteType = ViewportInteractionItem::None;
|
2020-08-01 11:29:54 +01:00
|
|
|
}
|
|
|
|
|
break;
|
2021-03-17 08:04:41 +00:00
|
|
|
case EntityType::Guest:
|
|
|
|
|
case EntityType::Staff:
|
2020-08-01 11:29:54 +01:00
|
|
|
{
|
|
|
|
|
auto peep = sprite->As<Peep>();
|
|
|
|
|
if (peep != nullptr)
|
|
|
|
|
{
|
|
|
|
|
peep_set_map_tooltip(peep);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-12-29 19:09:15 +01:00
|
|
|
info.SpriteType = ViewportInteractionItem::None;
|
2020-08-01 11:29:54 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
2021-03-17 08:04:41 +00:00
|
|
|
default:
|
2020-10-27 18:52:56 -03:00
|
|
|
break;
|
2018-06-22 23:20:47 +02:00
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
break;
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::Ride:
|
2018-06-22 23:20:47 +02:00
|
|
|
ride_set_map_tooltip(tileElement);
|
|
|
|
|
break;
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::ParkEntrance:
|
2019-07-21 10:33:15 +01:00
|
|
|
{
|
|
|
|
|
auto& park = OpenRCT2::GetContext()->GetGameState()->GetPark();
|
|
|
|
|
auto parkName = park.Name.c_str();
|
|
|
|
|
|
2020-09-29 01:45:28 +01:00
|
|
|
auto ft = Formatter();
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(STR_STRING);
|
2020-04-21 07:38:59 -03:00
|
|
|
ft.Add<const char*>(parkName);
|
2020-09-29 01:45:28 +01:00
|
|
|
SetMapTooltip(ft);
|
2018-06-22 23:20:47 +02:00
|
|
|
break;
|
2019-07-21 10:33:15 +01:00
|
|
|
}
|
2018-06-22 23:20:47 +02:00
|
|
|
default:
|
2020-12-29 19:09:15 +01:00
|
|
|
info.SpriteType = ViewportInteractionItem::None;
|
2017-06-06 23:24:18 +02:00
|
|
|
break;
|
|
|
|
|
}
|
2014-11-10 00:40:59 +00:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
// If nothing is under cursor, find a close by peep
|
2020-12-29 19:09:15 +01:00
|
|
|
if (info.SpriteType == ViewportInteractionItem::None)
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
2020-11-03 03:59:00 -07:00
|
|
|
auto peep = ViewportInteractionGetClosestPeep(screenCoords, 32);
|
2020-08-02 08:32:59 +01:00
|
|
|
if (peep != nullptr)
|
|
|
|
|
{
|
|
|
|
|
info.Entity = peep;
|
2020-12-29 19:09:15 +01:00
|
|
|
info.SpriteType = ViewportInteractionItem::Entity;
|
2020-08-02 08:32:59 +01:00
|
|
|
info.Loc.x = peep->x;
|
|
|
|
|
info.Loc.y = peep->y;
|
|
|
|
|
peep_set_map_tooltip(peep);
|
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-11-10 00:40:59 +00:00
|
|
|
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
2014-11-05 20:28:51 +00:00
|
|
|
}
|
|
|
|
|
|
2020-11-03 03:59:00 -07:00
|
|
|
bool ViewportInteractionLeftOver(const ScreenCoordsXY& screenCoords)
|
2014-11-05 20:28:51 +00:00
|
|
|
{
|
2020-11-03 03:59:00 -07:00
|
|
|
auto info = ViewportInteractionGetItemLeft(screenCoords);
|
2014-11-05 20:28:51 +00:00
|
|
|
|
2020-08-02 08:32:59 +01:00
|
|
|
switch (info.SpriteType)
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::Entity:
|
|
|
|
|
case ViewportInteractionItem::Ride:
|
|
|
|
|
case ViewportInteractionItem::ParkEntrance:
|
2020-08-02 08:32:59 +01:00
|
|
|
return true;
|
2018-06-22 23:20:47 +02:00
|
|
|
default:
|
2020-08-02 08:32:59 +01:00
|
|
|
return false;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-11-05 20:28:51 +00:00
|
|
|
}
|
|
|
|
|
|
2020-11-03 03:59:00 -07:00
|
|
|
bool ViewportInteractionLeftClick(const ScreenCoordsXY& screenCoords)
|
2014-11-05 20:28:51 +00:00
|
|
|
{
|
2020-11-03 03:59:00 -07:00
|
|
|
auto info = ViewportInteractionGetItemLeft(screenCoords);
|
2014-11-05 20:28:51 +00:00
|
|
|
|
2020-08-02 08:32:59 +01:00
|
|
|
switch (info.SpriteType)
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::Entity:
|
2020-08-02 08:32:59 +01:00
|
|
|
{
|
|
|
|
|
auto entity = info.Entity;
|
2021-03-17 08:04:41 +00:00
|
|
|
switch (entity->Type)
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
2021-03-17 08:04:41 +00:00
|
|
|
case EntityType::Vehicle:
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
|
|
|
|
auto intent = Intent(WD_VEHICLE);
|
2020-08-02 08:32:59 +01:00
|
|
|
intent.putExtra(INTENT_EXTRA_VEHICLE, entity);
|
2022-11-06 20:49:07 +00:00
|
|
|
ContextOpenIntent(&intent);
|
2017-06-06 23:24:18 +02:00
|
|
|
break;
|
|
|
|
|
}
|
2021-03-17 08:04:41 +00:00
|
|
|
case EntityType::Guest:
|
|
|
|
|
case EntityType::Staff:
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
2022-08-21 18:38:25 +02:00
|
|
|
auto intent = Intent(WindowClass::Peep);
|
2020-08-02 08:32:59 +01:00
|
|
|
intent.putExtra(INTENT_EXTRA_PEEP, entity);
|
2022-11-06 20:49:07 +00:00
|
|
|
ContextOpenIntent(&intent);
|
2018-06-22 23:20:47 +02:00
|
|
|
break;
|
|
|
|
|
}
|
2021-03-17 08:04:41 +00:00
|
|
|
case EntityType::Balloon:
|
|
|
|
|
{
|
2018-06-22 23:20:47 +02:00
|
|
|
if (game_is_not_paused())
|
|
|
|
|
{
|
2021-03-17 08:04:41 +00:00
|
|
|
auto balloonPress = BalloonPressAction(entity->sprite_index);
|
|
|
|
|
GameActions::Execute(&balloonPress);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case EntityType::Duck:
|
|
|
|
|
{
|
|
|
|
|
if (game_is_not_paused())
|
|
|
|
|
{
|
|
|
|
|
auto duck = entity->As<Duck>();
|
|
|
|
|
if (duck != nullptr)
|
2021-01-14 23:19:10 +01:00
|
|
|
{
|
2021-05-12 07:56:32 +01:00
|
|
|
duck->Press();
|
2018-06-22 23:20:47 +02:00
|
|
|
}
|
|
|
|
|
}
|
2021-03-17 08:04:41 +00:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2020-10-27 18:52:56 -03:00
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2020-08-02 08:32:59 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::Ride:
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
|
|
|
|
auto intent = Intent(WD_TRACK);
|
2020-08-02 08:32:59 +01:00
|
|
|
intent.putExtra(INTENT_EXTRA_TILE_ELEMENT, info.Element);
|
2022-11-06 20:49:07 +00:00
|
|
|
ContextOpenIntent(&intent);
|
2018-06-22 23:20:47 +02:00
|
|
|
return true;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::ParkEntrance:
|
2022-11-06 20:49:07 +00:00
|
|
|
ContextOpenWindow(WindowClass::ParkInformation);
|
2020-08-02 08:32:59 +01:00
|
|
|
return true;
|
2018-06-22 23:20:47 +02:00
|
|
|
default:
|
2020-08-02 08:32:59 +01:00
|
|
|
return false;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-11-05 20:28:51 +00:00
|
|
|
}
|
|
|
|
|
|
2014-11-05 19:42:19 +00:00
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2014-11-05 19:42:19 +00:00
|
|
|
* rct2: 0x006EDE88
|
|
|
|
|
*/
|
2020-11-03 03:59:00 -07:00
|
|
|
InteractionInfo ViewportInteractionGetItemRight(const ScreenCoordsXY& screenCoords)
|
2014-11-05 19:42:19 +00:00
|
|
|
{
|
2018-06-22 23:20:47 +02:00
|
|
|
Ride* ride;
|
2022-01-26 13:28:19 +01:00
|
|
|
int32_t i;
|
2020-08-02 08:32:59 +01:00
|
|
|
InteractionInfo info{};
|
2017-06-06 23:24:18 +02:00
|
|
|
// No click input for title screen or track manager
|
|
|
|
|
if (gScreenFlags & (SCREEN_FLAGS_TITLE_DEMO | SCREEN_FLAGS_TRACK_MANAGER))
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
2014-11-05 19:42:19 +00:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
//
|
2021-04-05 18:01:43 +01:00
|
|
|
if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) && gEditorStep != EditorStep::RollercoasterDesigner)
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
2014-11-05 19:42:19 +00:00
|
|
|
|
2021-06-26 07:43:05 +03:00
|
|
|
constexpr auto flags = static_cast<int32_t>(
|
|
|
|
|
~EnumsToFlags(ViewportInteractionItem::Terrain, ViewportInteractionItem::Water));
|
2021-02-10 01:06:18 +00:00
|
|
|
info = get_map_coordinates_from_pos(screenCoords, flags);
|
2020-08-02 08:32:59 +01:00
|
|
|
auto tileElement = info.Element;
|
2014-11-05 19:42:19 +00:00
|
|
|
|
2020-08-02 08:32:59 +01:00
|
|
|
switch (info.SpriteType)
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::Entity:
|
2020-08-01 11:29:54 +01:00
|
|
|
{
|
2020-08-02 08:32:59 +01:00
|
|
|
auto sprite = info.Entity;
|
2021-03-17 08:04:41 +00:00
|
|
|
if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || sprite->Type != EntityType::Vehicle)
|
2020-08-02 08:32:59 +01:00
|
|
|
{
|
2020-12-29 19:09:15 +01:00
|
|
|
info.SpriteType = ViewportInteractionItem::None;
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
|
|
|
|
}
|
2018-06-22 23:20:47 +02:00
|
|
|
|
2020-08-01 11:29:54 +01:00
|
|
|
auto vehicle = sprite->As<Vehicle>();
|
|
|
|
|
if (vehicle == nullptr)
|
|
|
|
|
{
|
2020-12-29 19:09:15 +01:00
|
|
|
info.SpriteType = ViewportInteractionItem::None;
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
2020-08-01 11:29:54 +01:00
|
|
|
}
|
|
|
|
|
ride = get_ride(vehicle->ride);
|
2021-06-10 07:09:58 +01:00
|
|
|
if (ride != nullptr && ride->status == RideStatus::Closed)
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
2020-09-29 01:45:28 +01:00
|
|
|
auto ft = Formatter();
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(STR_MAP_TOOLTIP_STRINGID_CLICK_TO_MODIFY);
|
2020-04-21 07:38:59 -03:00
|
|
|
ride->FormatNameTo(ft);
|
2020-09-29 01:45:28 +01:00
|
|
|
SetMapTooltip(ft);
|
2018-06-22 23:20:47 +02:00
|
|
|
}
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
2020-08-01 11:29:54 +01:00
|
|
|
}
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::Ride:
|
2019-07-21 13:50:01 +01:00
|
|
|
{
|
2018-06-22 23:20:47 +02:00
|
|
|
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR)
|
2020-08-02 08:32:59 +01:00
|
|
|
{
|
2020-12-29 19:09:15 +01:00
|
|
|
info.SpriteType = ViewportInteractionItem::None;
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
|
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
if (tileElement->GetType() == TileElementType::Path)
|
2020-08-02 08:32:59 +01:00
|
|
|
{
|
2020-12-29 19:09:15 +01:00
|
|
|
info.SpriteType = ViewportInteractionItem::None;
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
|
|
|
|
}
|
2018-06-22 23:20:47 +02:00
|
|
|
|
2020-10-27 21:59:55 +01:00
|
|
|
ride = get_ride(tileElement->GetRideIndex());
|
2019-08-09 08:06:25 +01:00
|
|
|
if (ride == nullptr)
|
2020-08-02 08:32:59 +01:00
|
|
|
{
|
2020-12-29 19:09:15 +01:00
|
|
|
info.SpriteType = ViewportInteractionItem::None;
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
|
|
|
|
}
|
2019-08-09 08:06:25 +01:00
|
|
|
|
2021-06-10 07:09:58 +01:00
|
|
|
if (ride->status != RideStatus::Closed)
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
2018-06-22 23:20:47 +02:00
|
|
|
|
2020-09-29 01:45:28 +01:00
|
|
|
auto ft = Formatter();
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(STR_MAP_TOOLTIP_STRINGID_CLICK_TO_MODIFY);
|
2018-06-22 23:20:47 +02:00
|
|
|
|
2021-12-11 00:39:39 +01:00
|
|
|
if (tileElement->GetType() == TileElementType::Entrance)
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
2022-07-31 14:22:58 +02:00
|
|
|
StringId stringId;
|
2018-09-26 12:13:44 +02:00
|
|
|
if (tileElement->AsEntrance()->GetEntranceType() == ENTRANCE_TYPE_RIDE_ENTRANCE)
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
|
|
|
|
if (ride->num_stations > 1)
|
|
|
|
|
{
|
|
|
|
|
stringId = STR_RIDE_STATION_X_ENTRANCE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
stringId = STR_RIDE_ENTRANCE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (ride->num_stations > 1)
|
|
|
|
|
{
|
|
|
|
|
stringId = STR_RIDE_STATION_X_EXIT;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
stringId = STR_RIDE_EXIT;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(stringId);
|
2018-06-22 23:20:47 +02:00
|
|
|
}
|
2020-06-05 22:55:15 +02:00
|
|
|
else if (tileElement->AsTrack()->IsStation())
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
2022-07-31 14:22:58 +02:00
|
|
|
StringId stringId;
|
2018-06-22 23:20:47 +02:00
|
|
|
if (ride->num_stations > 1)
|
|
|
|
|
{
|
|
|
|
|
stringId = STR_RIDE_STATION_X;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
stringId = STR_RIDE_STATION;
|
|
|
|
|
}
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(stringId);
|
2018-06-22 23:20:47 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-12-27 15:26:40 +01:00
|
|
|
// FIXME: Why does it *2 the value?
|
2022-10-12 06:35:20 +01:00
|
|
|
if (!gCheatsSandboxMode && !MapIsLocationOwned({ info.Loc, tileElement->GetBaseZ() * 2 }))
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
2020-12-29 19:09:15 +01:00
|
|
|
info.SpriteType = ViewportInteractionItem::None;
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
2018-06-22 23:20:47 +02:00
|
|
|
}
|
|
|
|
|
|
2020-04-21 07:38:59 -03:00
|
|
|
ride->FormatNameTo(ft);
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-11-05 19:42:19 +00:00
|
|
|
|
2020-04-21 07:38:59 -03:00
|
|
|
ride->FormatNameTo(ft);
|
2020-12-12 22:53:50 +01:00
|
|
|
|
|
|
|
|
const auto& rtd = ride->GetRideTypeDescriptor();
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(GetRideComponentName(rtd.NameConvention.station).capitalised);
|
2018-09-23 11:55:37 +02:00
|
|
|
|
2022-01-26 13:28:19 +01:00
|
|
|
StationIndex::UnderlyingType stationIndex;
|
2021-12-11 00:39:39 +01:00
|
|
|
if (tileElement->GetType() == TileElementType::Entrance)
|
2022-01-26 13:28:19 +01:00
|
|
|
stationIndex = tileElement->AsEntrance()->GetStationIndex().ToUnderlying();
|
2018-09-17 22:51:28 +02:00
|
|
|
else
|
2022-01-26 13:28:19 +01:00
|
|
|
stationIndex = tileElement->AsTrack()->GetStationIndex().ToUnderlying();
|
2018-09-23 11:55:37 +02:00
|
|
|
|
2018-06-22 23:20:47 +02:00
|
|
|
for (i = stationIndex; i >= 0; i--)
|
2022-01-28 00:34:04 +01:00
|
|
|
if (ride->GetStations()[i].Start.IsNull())
|
2018-06-22 23:20:47 +02:00
|
|
|
stationIndex--;
|
|
|
|
|
stationIndex++;
|
2020-04-21 07:38:59 -03:00
|
|
|
ft.Add<uint16_t>(stationIndex);
|
2020-09-29 01:45:28 +01:00
|
|
|
SetMapTooltip(ft);
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
2019-07-21 13:50:01 +01:00
|
|
|
}
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::Wall:
|
2021-06-03 13:26:00 +01:00
|
|
|
{
|
|
|
|
|
auto* wallEntry = tileElement->AsWall()->GetEntry();
|
|
|
|
|
if (wallEntry->scrolling_mode != SCROLLING_MODE_NONE)
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
2019-07-25 17:51:22 +01:00
|
|
|
auto banner = tileElement->AsWall()->GetBanner();
|
2020-03-27 13:04:45 +01:00
|
|
|
if (banner != nullptr)
|
|
|
|
|
{
|
2020-09-29 01:45:28 +01:00
|
|
|
auto ft = Formatter();
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(STR_MAP_TOOLTIP_BANNER_STRINGID_STRINGID);
|
2020-04-21 07:38:59 -03:00
|
|
|
banner->FormatTextTo(ft);
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(STR_MAP_TOOLTIP_STRINGID_CLICK_TO_MODIFY);
|
|
|
|
|
ft.Add<StringId>(wallEntry->name);
|
2020-09-29 01:45:28 +01:00
|
|
|
SetMapTooltip(ft);
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
2020-03-27 13:04:45 +01:00
|
|
|
}
|
2018-06-22 23:20:47 +02:00
|
|
|
}
|
|
|
|
|
break;
|
2021-06-03 13:26:00 +01:00
|
|
|
}
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::LargeScenery:
|
2021-06-04 02:14:41 +01:00
|
|
|
{
|
|
|
|
|
auto* sceneryEntry = tileElement->AsLargeScenery()->GetEntry();
|
2021-06-04 12:41:23 +01:00
|
|
|
if (sceneryEntry->scrolling_mode != SCROLLING_MODE_NONE)
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
2019-07-25 17:51:22 +01:00
|
|
|
auto banner = tileElement->AsLargeScenery()->GetBanner();
|
2020-03-27 13:04:45 +01:00
|
|
|
if (banner != nullptr)
|
|
|
|
|
{
|
2020-09-29 01:45:28 +01:00
|
|
|
auto ft = Formatter();
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(STR_MAP_TOOLTIP_BANNER_STRINGID_STRINGID);
|
2020-04-21 07:38:59 -03:00
|
|
|
banner->FormatTextTo(ft);
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(STR_MAP_TOOLTIP_STRINGID_CLICK_TO_MODIFY);
|
|
|
|
|
ft.Add<StringId>(sceneryEntry->name);
|
2020-09-29 01:45:28 +01:00
|
|
|
SetMapTooltip(ft);
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
2020-03-27 13:04:45 +01:00
|
|
|
}
|
2018-06-22 23:20:47 +02:00
|
|
|
}
|
|
|
|
|
break;
|
2021-06-04 02:14:41 +01:00
|
|
|
}
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::Banner:
|
2019-07-21 15:16:44 +01:00
|
|
|
{
|
2019-07-25 17:51:22 +01:00
|
|
|
auto banner = tileElement->AsBanner()->GetBanner();
|
2021-07-27 10:25:58 +01:00
|
|
|
if (banner != nullptr)
|
|
|
|
|
{
|
2022-10-08 10:56:17 +01:00
|
|
|
auto* bannerEntry = GetBannerEntry(banner->type);
|
2014-11-05 19:42:19 +00:00
|
|
|
|
2021-07-27 10:25:58 +01:00
|
|
|
auto ft = Formatter();
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(STR_MAP_TOOLTIP_BANNER_STRINGID_STRINGID);
|
2021-07-27 10:25:58 +01:00
|
|
|
banner->FormatTextTo(ft, /*addColour*/ true);
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(STR_MAP_TOOLTIP_STRINGID_CLICK_TO_MODIFY);
|
|
|
|
|
ft.Add<StringId>(bannerEntry->name);
|
2021-07-27 10:25:58 +01:00
|
|
|
SetMapTooltip(ft);
|
|
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2019-07-21 15:16:44 +01:00
|
|
|
}
|
2020-08-02 08:32:59 +01:00
|
|
|
default:
|
|
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-11-05 19:42:19 +00:00
|
|
|
|
2018-06-22 23:20:47 +02:00
|
|
|
if (!(input_test_flag(INPUT_FLAG_6)) || !(input_test_flag(INPUT_FLAG_TOOL_ACTIVE)))
|
|
|
|
|
{
|
2022-08-21 18:38:25 +02:00
|
|
|
if (window_find_by_class(WindowClass::RideConstruction) == nullptr
|
|
|
|
|
&& window_find_by_class(WindowClass::Footpath) == nullptr)
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
2020-12-29 19:09:15 +01:00
|
|
|
info.SpriteType = ViewportInteractionItem::None;
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
}
|
2014-11-05 19:42:19 +00:00
|
|
|
|
2020-09-29 01:45:28 +01:00
|
|
|
auto ft = Formatter();
|
2020-08-02 08:32:59 +01:00
|
|
|
switch (info.SpriteType)
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::Scenery:
|
2021-06-04 02:14:41 +01:00
|
|
|
{
|
|
|
|
|
auto* sceneryEntry = tileElement->AsSmallScenery()->GetEntry();
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(STR_MAP_TOOLTIP_STRINGID_CLICK_TO_REMOVE);
|
|
|
|
|
ft.Add<StringId>(sceneryEntry->name);
|
2020-09-29 01:45:28 +01:00
|
|
|
SetMapTooltip(ft);
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
2021-06-04 02:14:41 +01:00
|
|
|
}
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::Footpath:
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(STR_MAP_TOOLTIP_STRINGID_CLICK_TO_REMOVE);
|
2018-10-03 10:57:29 +02:00
|
|
|
if (tileElement->AsPath()->IsQueue())
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(STR_QUEUE_LINE_MAP_TIP);
|
2020-04-21 07:38:59 -03:00
|
|
|
else
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(STR_FOOTPATH_MAP_TIP);
|
2020-09-29 01:45:28 +01:00
|
|
|
SetMapTooltip(ft);
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
2014-11-05 19:42:19 +00:00
|
|
|
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::FootpathItem:
|
2021-06-03 21:23:00 +01:00
|
|
|
{
|
|
|
|
|
auto* pathAddEntry = tileElement->AsPath()->GetAdditionEntry();
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(STR_MAP_TOOLTIP_STRINGID_CLICK_TO_REMOVE);
|
2019-02-26 09:29:25 +00:00
|
|
|
if (tileElement->AsPath()->IsBroken())
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(STR_BROKEN);
|
2018-06-22 23:20:47 +02:00
|
|
|
}
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(pathAddEntry != nullptr ? pathAddEntry->name : STR_NONE);
|
2020-09-29 01:45:28 +01:00
|
|
|
SetMapTooltip(ft);
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
2021-06-03 21:23:00 +01:00
|
|
|
}
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::ParkEntrance:
|
2018-06-22 23:20:47 +02:00
|
|
|
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode)
|
|
|
|
|
break;
|
2014-11-05 19:42:19 +00:00
|
|
|
|
2021-12-11 00:39:39 +01:00
|
|
|
if (tileElement->GetType() != TileElementType::Entrance)
|
2018-06-22 23:20:47 +02:00
|
|
|
break;
|
2014-11-05 19:42:19 +00:00
|
|
|
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(STR_MAP_TOOLTIP_STRINGID_CLICK_TO_REMOVE);
|
|
|
|
|
ft.Add<StringId>(STR_OBJECT_SELECTION_PARK_ENTRANCE);
|
2020-09-29 01:45:28 +01:00
|
|
|
SetMapTooltip(ft);
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
2018-06-22 23:20:47 +02:00
|
|
|
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::Wall:
|
2021-06-03 13:26:00 +01:00
|
|
|
{
|
|
|
|
|
auto* wallEntry = tileElement->AsWall()->GetEntry();
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(STR_MAP_TOOLTIP_STRINGID_CLICK_TO_REMOVE);
|
|
|
|
|
ft.Add<StringId>(wallEntry->name);
|
2020-09-29 01:45:28 +01:00
|
|
|
SetMapTooltip(ft);
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
2021-06-03 13:26:00 +01:00
|
|
|
}
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::LargeScenery:
|
2021-06-04 02:14:41 +01:00
|
|
|
{
|
|
|
|
|
auto* sceneryEntry = tileElement->AsLargeScenery()->GetEntry();
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(STR_MAP_TOOLTIP_STRINGID_CLICK_TO_REMOVE);
|
|
|
|
|
ft.Add<StringId>(sceneryEntry->name);
|
2020-09-29 01:45:28 +01:00
|
|
|
SetMapTooltip(ft);
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
2021-06-04 02:14:41 +01:00
|
|
|
}
|
2020-08-02 08:32:59 +01:00
|
|
|
default:
|
|
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-11-05 19:42:19 +00:00
|
|
|
|
2020-12-29 19:09:15 +01:00
|
|
|
info.SpriteType = ViewportInteractionItem::None;
|
2020-08-02 08:32:59 +01:00
|
|
|
return info;
|
2014-11-05 19:42:19 +00:00
|
|
|
}
|
|
|
|
|
|
2020-11-03 03:59:00 -07:00
|
|
|
bool ViewportInteractionRightOver(const ScreenCoordsXY& screenCoords)
|
2014-11-05 19:42:19 +00:00
|
|
|
{
|
2020-11-03 03:59:00 -07:00
|
|
|
auto info = ViewportInteractionGetItemRight(screenCoords);
|
2014-11-05 19:42:19 +00:00
|
|
|
|
2020-12-29 19:09:15 +01:00
|
|
|
return info.SpriteType != ViewportInteractionItem::None;
|
2014-11-05 19:42:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2014-11-05 19:42:19 +00:00
|
|
|
* rct2: 0x006E8A62
|
|
|
|
|
*/
|
2020-11-03 03:59:00 -07:00
|
|
|
bool ViewportInteractionRightClick(const ScreenCoordsXY& screenCoords)
|
2014-11-05 19:42:19 +00:00
|
|
|
{
|
2018-02-15 17:42:53 +01:00
|
|
|
CoordsXYE tileElement;
|
2020-11-03 03:59:00 -07:00
|
|
|
auto info = ViewportInteractionGetItemRight(screenCoords);
|
2014-11-05 19:42:19 +00:00
|
|
|
|
2020-08-02 08:32:59 +01:00
|
|
|
switch (info.SpriteType)
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::None:
|
|
|
|
|
case ViewportInteractionItem::Terrain:
|
|
|
|
|
case ViewportInteractionItem::Water:
|
|
|
|
|
case ViewportInteractionItem::Label:
|
2020-08-02 08:32:59 +01:00
|
|
|
return false;
|
2014-11-15 18:22:06 +00:00
|
|
|
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::Entity:
|
2020-08-02 08:32:59 +01:00
|
|
|
{
|
|
|
|
|
auto entity = info.Entity;
|
2021-03-17 08:04:41 +00:00
|
|
|
if (entity->Type == EntityType::Vehicle)
|
2019-08-09 18:29:34 +01:00
|
|
|
{
|
2020-08-02 08:32:59 +01:00
|
|
|
auto vehicle = entity->As<Vehicle>();
|
2020-08-01 11:29:54 +01:00
|
|
|
if (vehicle == nullptr)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
auto ride = get_ride(vehicle->ride);
|
2019-08-09 18:29:34 +01:00
|
|
|
if (ride != nullptr)
|
|
|
|
|
{
|
2022-12-17 17:16:34 +01:00
|
|
|
RideConstructionStart(*ride);
|
2019-08-09 18:29:34 +01:00
|
|
|
}
|
|
|
|
|
}
|
2020-08-02 08:32:59 +01:00
|
|
|
}
|
|
|
|
|
break;
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::Ride:
|
2020-08-02 08:32:59 +01:00
|
|
|
tileElement = { info.Loc, info.Element };
|
2022-08-13 17:21:34 +02:00
|
|
|
ride_modify(tileElement);
|
2018-06-22 23:20:47 +02:00
|
|
|
break;
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::Scenery:
|
2020-11-03 03:59:00 -07:00
|
|
|
ViewportInteractionRemoveScenery(info.Element, info.Loc);
|
2018-06-22 23:20:47 +02:00
|
|
|
break;
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::Footpath:
|
2020-11-03 03:59:00 -07:00
|
|
|
ViewportInteractionRemoveFootpath(info.Element, info.Loc);
|
2018-06-22 23:20:47 +02:00
|
|
|
break;
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::FootpathItem:
|
2020-11-03 03:59:00 -07:00
|
|
|
ViewportInteractionRemoveFootpathItem(info.Element, info.Loc);
|
2018-06-22 23:20:47 +02:00
|
|
|
break;
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::ParkEntrance:
|
2020-11-03 03:59:00 -07:00
|
|
|
ViewportInteractionRemoveParkEntrance(info.Element, info.Loc);
|
2018-06-22 23:20:47 +02:00
|
|
|
break;
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::Wall:
|
2020-11-03 03:59:00 -07:00
|
|
|
ViewportInteractionRemoveParkWall(info.Element, info.Loc);
|
2018-06-22 23:20:47 +02:00
|
|
|
break;
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::LargeScenery:
|
2020-11-03 03:59:00 -07:00
|
|
|
ViewportInteractionRemoveLargeScenery(info.Element, info.Loc);
|
2018-06-22 23:20:47 +02:00
|
|
|
break;
|
2020-12-29 19:09:15 +01:00
|
|
|
case ViewportInteractionItem::Banner:
|
2022-11-06 20:49:07 +00:00
|
|
|
ContextOpenDetailWindow(WD_BANNER, info.Element->AsBanner()->GetIndex().ToUnderlying());
|
2018-06-22 23:20:47 +02:00
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-11-05 20:28:51 +00:00
|
|
|
|
2020-08-02 08:32:59 +01:00
|
|
|
return true;
|
2014-11-05 19:42:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2014-11-05 19:42:19 +00:00
|
|
|
* rct2: 0x006E08D2
|
|
|
|
|
*/
|
2020-11-03 03:59:00 -07:00
|
|
|
static void ViewportInteractionRemoveScenery(TileElement* tileElement, const CoordsXY& mapCoords)
|
2014-11-05 19:42:19 +00:00
|
|
|
{
|
2019-01-03 02:20:35 +01:00
|
|
|
auto removeSceneryAction = SmallSceneryRemoveAction(
|
2019-12-22 22:14:02 +01:00
|
|
|
{ mapCoords.x, mapCoords.y, tileElement->GetBaseZ() }, tileElement->AsSmallScenery()->GetSceneryQuadrant(),
|
2018-12-22 18:11:08 +01:00
|
|
|
tileElement->AsSmallScenery()->GetEntryIndex());
|
|
|
|
|
|
|
|
|
|
GameActions::Execute(&removeSceneryAction);
|
2014-11-05 19:42:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2014-11-05 19:42:19 +00:00
|
|
|
* rct2: 0x006A614A
|
|
|
|
|
*/
|
2020-11-03 03:59:00 -07:00
|
|
|
static void ViewportInteractionRemoveFootpath(TileElement* tileElement, const CoordsXY& mapCoords)
|
2014-11-05 19:42:19 +00:00
|
|
|
{
|
2018-06-22 23:20:47 +02:00
|
|
|
rct_window* w;
|
2018-11-01 13:53:50 +01:00
|
|
|
TileElement* tileElement2;
|
2014-11-05 19:42:19 +00:00
|
|
|
|
2019-12-22 22:14:02 +01:00
|
|
|
auto z = tileElement->GetBaseZ();
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2022-08-21 18:38:25 +02:00
|
|
|
w = window_find_by_class(WindowClass::Footpath);
|
2018-01-07 21:43:07 +01:00
|
|
|
if (w != nullptr)
|
2022-10-04 07:51:27 +01:00
|
|
|
FootpathProvisionalUpdate();
|
2014-11-05 19:42:19 +00:00
|
|
|
|
2022-10-11 19:39:24 +01:00
|
|
|
tileElement2 = MapGetFirstElementAt(mapCoords);
|
2019-10-13 09:24:19 -03:00
|
|
|
if (tileElement2 == nullptr)
|
|
|
|
|
return;
|
2018-06-22 23:20:47 +02:00
|
|
|
do
|
|
|
|
|
{
|
2021-12-11 00:39:39 +01:00
|
|
|
if (tileElement2->GetType() == TileElementType::Path && tileElement2->GetBaseZ() == z)
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
2022-08-11 00:00:58 +02:00
|
|
|
auto action = FootpathRemoveAction({ mapCoords, z });
|
|
|
|
|
GameActions::Execute(&action);
|
2017-06-06 23:24:18 +02:00
|
|
|
break;
|
|
|
|
|
}
|
2018-05-24 11:44:53 +02:00
|
|
|
} while (!(tileElement2++)->IsLastForTile());
|
2014-11-05 19:42:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2014-11-05 19:42:19 +00:00
|
|
|
* rct2: 0x006A61AB
|
|
|
|
|
*/
|
2020-11-03 03:59:00 -07:00
|
|
|
static void ViewportInteractionRemoveFootpathItem(TileElement* tileElement, const CoordsXY& mapCoords)
|
2014-11-05 19:42:19 +00:00
|
|
|
{
|
2020-11-03 09:17:29 +01:00
|
|
|
auto footpathAdditionRemoveAction = FootpathAdditionRemoveAction({ mapCoords.x, mapCoords.y, tileElement->GetBaseZ() });
|
|
|
|
|
GameActions::Execute(&footpathAdditionRemoveAction);
|
2014-11-05 19:42:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2014-11-05 19:42:19 +00:00
|
|
|
* rct2: 0x00666C0E
|
|
|
|
|
*/
|
2020-11-03 03:59:00 -07:00
|
|
|
void ViewportInteractionRemoveParkEntrance(TileElement* tileElement, CoordsXY mapCoords)
|
2014-11-05 19:42:19 +00:00
|
|
|
{
|
2018-09-14 11:14:19 +02:00
|
|
|
int32_t rotation = tileElement->GetDirectionWithOffset(1);
|
2018-09-26 12:54:44 +02:00
|
|
|
switch (tileElement->AsEntrance()->GetSequenceIndex())
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
|
|
|
|
case 1:
|
2019-11-25 23:08:31 -03:00
|
|
|
mapCoords += CoordsDirectionDelta[rotation];
|
2018-06-22 23:20:47 +02:00
|
|
|
break;
|
|
|
|
|
case 2:
|
2019-11-25 23:08:31 -03:00
|
|
|
mapCoords -= CoordsDirectionDelta[rotation];
|
2018-06-22 23:20:47 +02:00
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2019-12-22 22:14:02 +01:00
|
|
|
auto parkEntranceRemoveAction = ParkEntranceRemoveAction({ mapCoords.x, mapCoords.y, tileElement->GetBaseZ() });
|
2019-03-24 20:41:14 +00:00
|
|
|
GameActions::Execute(&parkEntranceRemoveAction);
|
2014-11-05 19:42:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2014-11-05 19:42:19 +00:00
|
|
|
* rct2: 0x006E57A9
|
|
|
|
|
*/
|
2020-11-03 03:59:00 -07:00
|
|
|
static void ViewportInteractionRemoveParkWall(TileElement* tileElement, const CoordsXY& mapCoords)
|
2014-11-05 19:42:19 +00:00
|
|
|
{
|
2021-06-03 13:26:00 +01:00
|
|
|
auto* wallEntry = tileElement->AsWall()->GetEntry();
|
|
|
|
|
if (wallEntry->scrolling_mode != SCROLLING_MODE_NONE)
|
2018-04-22 19:11:06 +02:00
|
|
|
{
|
2022-11-06 20:49:07 +00:00
|
|
|
ContextOpenDetailWindow(WD_SIGN_SMALL, tileElement->AsWall()->GetBannerIndex().ToUnderlying());
|
2018-04-22 19:11:06 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-12-22 22:14:02 +01:00
|
|
|
CoordsXYZD wallLocation = { mapCoords.x, mapCoords.y, tileElement->GetBaseZ(), tileElement->GetDirection() };
|
2018-05-14 12:36:45 +02:00
|
|
|
auto wallRemoveAction = WallRemoveAction(wallLocation);
|
2018-04-22 19:11:06 +02:00
|
|
|
GameActions::Execute(&wallRemoveAction);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-11-05 19:42:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2014-11-05 19:42:19 +00:00
|
|
|
* rct2: 0x006B88DC
|
|
|
|
|
*/
|
2020-11-03 03:59:00 -07:00
|
|
|
static void ViewportInteractionRemoveLargeScenery(TileElement* tileElement, const CoordsXY& mapCoords)
|
2014-11-05 19:42:19 +00:00
|
|
|
{
|
2021-06-04 12:41:23 +01:00
|
|
|
auto* sceneryEntry = tileElement->AsLargeScenery()->GetEntry();
|
2014-11-05 19:42:19 +00:00
|
|
|
|
2021-06-04 12:41:23 +01:00
|
|
|
if (sceneryEntry->scrolling_mode != SCROLLING_MODE_NONE)
|
2017-11-17 17:15:55 +01:00
|
|
|
{
|
2020-02-08 17:42:36 +01:00
|
|
|
auto bannerIndex = tileElement->AsLargeScenery()->GetBannerIndex();
|
2022-11-06 20:49:07 +00:00
|
|
|
ContextOpenDetailWindow(WD_SIGN, bannerIndex.ToUnderlying());
|
2018-06-22 23:20:47 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-01-03 02:20:35 +01:00
|
|
|
auto removeSceneryAction = LargeSceneryRemoveAction(
|
2019-12-22 22:14:02 +01:00
|
|
|
{ mapCoords.x, mapCoords.y, tileElement->GetBaseZ(), tileElement->GetDirection() },
|
2019-07-07 04:53:59 +03:00
|
|
|
tileElement->AsLargeScenery()->GetSequenceIndex());
|
2018-12-22 19:46:59 +01:00
|
|
|
GameActions::Execute(&removeSceneryAction);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-11-10 00:40:59 +00:00
|
|
|
}
|
|
|
|
|
|
2021-01-20 13:21:22 +00:00
|
|
|
struct PeepDistance
|
|
|
|
|
{
|
|
|
|
|
Peep* peep = nullptr;
|
|
|
|
|
int32_t distance = std::numeric_limits<decltype(distance)>::max();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
|
PeepDistance GetClosestPeep(const ScreenCoordsXY& viewportCoords, const int32_t maxDistance, PeepDistance goal)
|
|
|
|
|
{
|
2021-03-16 11:18:06 +00:00
|
|
|
for (auto peep : EntityList<T>())
|
2021-01-20 13:21:22 +00:00
|
|
|
{
|
2021-09-18 19:07:35 +01:00
|
|
|
if (peep->x == LOCATION_NULL)
|
2021-01-20 13:21:22 +00:00
|
|
|
continue;
|
|
|
|
|
|
2021-09-18 19:07:35 +01:00
|
|
|
auto distance = abs(((peep->SpriteRect.GetLeft() + peep->SpriteRect.GetRight()) / 2) - viewportCoords.x)
|
|
|
|
|
+ abs(((peep->SpriteRect.GetTop() + peep->SpriteRect.GetBottom()) / 2) - viewportCoords.y);
|
2021-01-20 13:21:22 +00:00
|
|
|
if (distance > maxDistance)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (distance < goal.distance)
|
|
|
|
|
{
|
|
|
|
|
goal.peep = peep;
|
|
|
|
|
goal.distance = distance;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return goal;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-03 03:59:00 -07:00
|
|
|
static Peep* ViewportInteractionGetClosestPeep(ScreenCoordsXY screenCoords, int32_t maxDistance)
|
2014-11-10 00:40:59 +00:00
|
|
|
{
|
2022-03-04 02:46:37 +00:00
|
|
|
auto* w = window_find_from_point(screenCoords);
|
2018-01-07 21:43:07 +01:00
|
|
|
if (w == nullptr)
|
|
|
|
|
return nullptr;
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2022-03-04 02:46:37 +00:00
|
|
|
auto* viewport = w->viewport;
|
2021-09-29 20:04:56 +02:00
|
|
|
if (viewport == nullptr || viewport->zoom >= ZoomLevel{ 2 })
|
2018-01-07 21:43:07 +01:00
|
|
|
return nullptr;
|
2014-11-10 00:40:59 +00:00
|
|
|
|
2020-10-13 02:25:11 +01:00
|
|
|
auto viewportCoords = viewport->ScreenToViewportCoord(screenCoords);
|
2014-11-10 00:40:59 +00:00
|
|
|
|
2022-03-04 02:46:37 +00:00
|
|
|
PeepDistance goal;
|
2022-03-06 14:26:36 +00:00
|
|
|
if (!(viewport->flags & VIEWPORT_FLAG_HIDE_GUESTS))
|
2022-03-04 02:46:37 +00:00
|
|
|
goal = GetClosestPeep<Guest>(viewportCoords, maxDistance, goal);
|
2022-03-06 14:26:36 +00:00
|
|
|
if (!(viewport->flags & VIEWPORT_FLAG_HIDE_STAFF))
|
2022-03-04 02:46:37 +00:00
|
|
|
goal = GetClosestPeep<Staff>(viewportCoords, maxDistance, goal);
|
2021-01-20 13:21:22 +00:00
|
|
|
return goal.peep;
|
2015-04-21 18:19:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* rct2: 0x0068A15E
|
|
|
|
|
*/
|
2020-11-03 03:59:00 -07:00
|
|
|
CoordsXY ViewportInteractionGetTileStartAtCursor(const ScreenCoordsXY& screenCoords)
|
2015-04-21 18:19:11 +01:00
|
|
|
{
|
2020-08-02 08:32:59 +01:00
|
|
|
rct_window* window = window_find_from_point(screenCoords);
|
2020-08-02 20:13:09 +01:00
|
|
|
if (window == nullptr || window->viewport == nullptr)
|
|
|
|
|
{
|
|
|
|
|
CoordsXY ret{};
|
2021-09-09 01:48:53 +02:00
|
|
|
ret.SetNull();
|
2020-08-02 20:13:09 +01:00
|
|
|
return ret;
|
|
|
|
|
}
|
2020-08-02 08:32:59 +01:00
|
|
|
auto viewport = window->viewport;
|
|
|
|
|
auto info = get_map_coordinates_from_pos_window(
|
2021-02-10 01:06:18 +00:00
|
|
|
window, screenCoords, EnumsToFlags(ViewportInteractionItem::Terrain, ViewportInteractionItem::Water));
|
2020-08-02 08:32:59 +01:00
|
|
|
auto initialPos = info.Loc;
|
2015-04-21 18:19:11 +01:00
|
|
|
|
2020-12-29 19:09:15 +01:00
|
|
|
if (info.SpriteType == ViewportInteractionItem::None)
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
2021-09-09 01:48:53 +02:00
|
|
|
initialPos.SetNull();
|
2019-11-14 19:09:27 -03:00
|
|
|
return initialPos;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-04-21 18:19:11 +01:00
|
|
|
|
2019-10-07 18:56:31 +01:00
|
|
|
int16_t waterHeight = 0;
|
2020-12-29 19:09:15 +01:00
|
|
|
if (info.SpriteType == ViewportInteractionItem::Water)
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
2020-08-02 08:32:59 +01:00
|
|
|
waterHeight = info.Element->AsSurface()->GetWaterHeight();
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-04-21 18:19:11 +01:00
|
|
|
|
2020-10-13 02:25:11 +01:00
|
|
|
auto initialVPPos = viewport->ScreenToViewportCoord(screenCoords);
|
2019-10-30 20:24:13 +00:00
|
|
|
CoordsXY mapPos = initialPos + CoordsXY{ 16, 16 };
|
2015-04-21 18:19:11 +01:00
|
|
|
|
2018-06-22 23:20:47 +02:00
|
|
|
for (int32_t i = 0; i < 5; i++)
|
|
|
|
|
{
|
2019-10-07 18:56:31 +01:00
|
|
|
int16_t z = waterHeight;
|
2020-12-29 19:09:15 +01:00
|
|
|
if (info.SpriteType != ViewportInteractionItem::Water)
|
2018-06-22 23:20:47 +02:00
|
|
|
{
|
2022-10-12 06:35:20 +01:00
|
|
|
z = TileElementHeight(mapPos);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2020-07-12 17:42:54 -04:00
|
|
|
mapPos = viewport_coord_to_map_coord(initialVPPos, z);
|
2019-10-30 20:24:13 +00:00
|
|
|
mapPos.x = std::clamp(mapPos.x, initialPos.x, initialPos.x + 31);
|
|
|
|
|
mapPos.y = std::clamp(mapPos.y, initialPos.y, initialPos.y + 31);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-04-21 18:19:11 +01:00
|
|
|
|
2019-11-30 12:47:23 -03:00
|
|
|
return mapPos.ToTileStart();
|
2015-06-09 17:19:05 +02:00
|
|
|
}
|