mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-20 05:23:04 +01:00
Add path surface object type
This commit is contained in:
63
src/openrct2/object/FootpathSurfaceObject.cpp
Normal file
63
src/openrct2/object/FootpathSurfaceObject.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2014-2021 OpenRCT2 developers
|
||||
*
|
||||
* For a complete list of all authors, please refer to contributors.md
|
||||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
||||
*
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "FootpathSurfaceObject.h"
|
||||
|
||||
#include "../core/IStream.hpp"
|
||||
#include "../core/Json.hpp"
|
||||
|
||||
void FootpathSurfaceObject::Load()
|
||||
{
|
||||
GetStringTable().Sort();
|
||||
NameStringId = language_allocate_object_string(GetName());
|
||||
|
||||
auto numImages = GetImageTable().GetCount();
|
||||
if (numImages != 0)
|
||||
{
|
||||
BaseImageId = gfx_object_allocate_images(GetImageTable().GetImages(), GetImageTable().GetCount());
|
||||
PreviewImageId = BaseImageId + 72;
|
||||
}
|
||||
}
|
||||
|
||||
void FootpathSurfaceObject::Unload()
|
||||
{
|
||||
language_free_object_string(NameStringId);
|
||||
gfx_object_free_images(BaseImageId, GetImageTable().GetCount());
|
||||
|
||||
NameStringId = 0;
|
||||
PreviewImageId = 0;
|
||||
BaseImageId = 0;
|
||||
}
|
||||
|
||||
void FootpathSurfaceObject::DrawPreview(rct_drawpixelinfo* dpi, int32_t width, int32_t height) const
|
||||
{
|
||||
auto screenCoords = ScreenCoordsXY{ width / 2 - 16, height / 2 };
|
||||
gfx_draw_sprite(dpi, BaseImageId + 3, screenCoords, 0);
|
||||
gfx_draw_sprite(dpi, BaseImageId + 16, { screenCoords.x + 32, screenCoords.y - 16 }, 0);
|
||||
gfx_draw_sprite(dpi, BaseImageId + 8, { screenCoords.x + 32, screenCoords.y + 16 }, 0);
|
||||
}
|
||||
|
||||
void FootpathSurfaceObject::ReadJson(IReadObjectContext* context, json_t& root)
|
||||
{
|
||||
Guard::Assert(root.is_object(), "FootpathSurfaceObject::ReadJson expects parameter root to be object");
|
||||
|
||||
auto properties = root["properties"];
|
||||
if (properties.is_object())
|
||||
{
|
||||
Flags = Json::GetFlags<uint8_t>(
|
||||
properties,
|
||||
{
|
||||
{ "editorOnly", FOOTPATH_ENTRY_FLAG_SHOW_ONLY_IN_SCENARIO_EDITOR },
|
||||
{ "isQueue", FOOTPATH_ENTRY_FLAG_IS_QUEUE },
|
||||
{ "noSlopeRailings", FOOTPATH_ENTRY_FLAG_NO_SLOPE_RAILINGS },
|
||||
});
|
||||
}
|
||||
|
||||
PopulateTablesFromJson(context, root);
|
||||
}
|
||||
Reference in New Issue
Block a user