Files
OpenRCT2-Web/src/openrct2/object/FootpathObject.cpp
T

83 lines
3.4 KiB
C++
Raw Normal View History

2016-06-25 17:09:56 +01:00
/*****************************************************************************
2026-01-05 14:42:59 +01:00
* Copyright (c) 2014-2026 OpenRCT2 developers
2016-06-25 17:09:56 +01: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
2016-06-25 17:09:56 +01:00
*
2018-06-15 14:07:34 +02:00
* OpenRCT2 is licensed under the GNU General Public License version 3.
2016-06-25 17:09:56 +01:00
*****************************************************************************/
2018-06-22 23:03:20 +02:00
#include "FootpathObject.h"
2016-06-25 17:09:56 +01:00
#include "../core/IStream.hpp"
2020-08-12 23:05:23 +01:00
#include "../core/Json.hpp"
2018-01-05 21:17:33 +00:00
#include "../drawing/Drawing.h"
2018-01-06 18:32:25 +01:00
#include "../localisation/Language.h"
2018-01-11 10:59:26 +01:00
#include "../world/Footpath.h"
2016-06-25 17:09:56 +01:00
namespace OpenRCT2
2016-06-25 17:09:56 +01:00
{
void FootpathObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
2016-07-02 17:23:06 +01:00
{
stream->Seek(10, STREAM_SEEK_CURRENT);
_legacyType.support_type = static_cast<RailingEntrySupportType>(stream->ReadValue<uint8_t>());
_legacyType.flags = stream->ReadValue<uint8_t>();
_legacyType.scrolling_mode = stream->ReadValue<uint8_t>();
stream->Seek(1, STREAM_SEEK_CURRENT);
2025-10-07 22:08:15 +02:00
GetStringTable().Read(context, stream, ObjectStringID::name);
GetImageTable().Read(context, stream);
// Validate properties
2026-01-11 17:10:23 +01:00
if (_legacyType.support_type >= RailingEntrySupportType::count)
{
2025-10-07 22:01:22 +02:00
context->LogError(ObjectError::invalidProperty, "RailingEntrySupportType not supported.");
}
2016-07-02 17:23:06 +01:00
}
2016-06-25 17:09:56 +01:00
void FootpathObject::Load()
{
GetStringTable().Sort();
_legacyType.string_idx = LanguageAllocateObjectString(GetName());
_legacyType.image = LoadImages();
_legacyType.bridge_image = _legacyType.image + 109;
2019-01-20 21:38:38 +01:00
2026-01-11 17:11:53 +01:00
_pathSurfaceDescriptor.name = _legacyType.string_idx;
_pathSurfaceDescriptor.image = _legacyType.image;
_pathSurfaceDescriptor.previewImage = _legacyType.GetPreviewImage();
_pathSurfaceDescriptor.flags = _legacyType.flags;
2019-01-20 21:38:38 +01:00
2026-01-11 17:11:53 +01:00
_queueSurfaceDescriptor.name = _legacyType.string_idx;
_queueSurfaceDescriptor.image = _legacyType.GetQueueImage();
_queueSurfaceDescriptor.previewImage = _legacyType.GetQueuePreviewImage();
_queueSurfaceDescriptor.flags = _legacyType.flags | FOOTPATH_ENTRY_FLAG_IS_QUEUE;
2026-01-11 17:20:48 +01:00
_pathRailingsDescriptor.name = _legacyType.string_idx;
_pathRailingsDescriptor.bridgeImage = _legacyType.bridge_image;
_pathRailingsDescriptor.previewImage = _legacyType.GetPreviewImage();
_pathRailingsDescriptor.flags = _legacyType.flags;
_pathRailingsDescriptor.scrollingMode = _legacyType.scrolling_mode;
_pathRailingsDescriptor.supportType = _legacyType.support_type;
_pathRailingsDescriptor.railingsImage = _legacyType.GetRailingsImage();
}
2016-06-25 17:09:56 +01:00
void FootpathObject::Unload()
{
LanguageFreeObjectString(_legacyType.string_idx);
UnloadImages();
_legacyType.string_idx = 0;
_legacyType.image = 0;
}
2016-06-25 17:09:56 +01:00
2025-12-26 12:58:33 +01:00
void FootpathObject::DrawPreview(Drawing::RenderTarget& rt, int32_t width, int32_t height) const
{
auto screenCoords = ScreenCoordsXY{ width / 2, height / 2 };
2026-01-11 17:11:53 +01:00
GfxDrawSprite(rt, ImageId(_pathSurfaceDescriptor.previewImage), screenCoords - ScreenCoordsXY{ 49, 17 });
GfxDrawSprite(rt, ImageId(_queueSurfaceDescriptor.previewImage), screenCoords + ScreenCoordsXY{ 4, -17 });
}
2017-12-08 18:27:30 +00:00
void FootpathObject::ReadJson(IReadObjectContext* context, json_t& root)
{
}
} // namespace OpenRCT2