mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-30 10:15:36 +01:00
Add footpath surface and railings objects from NSF
This commit is contained in:
@@ -60,6 +60,8 @@
|
||||
4C8BB68525533DB9005C8830 /* ZoomLevel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8BB68425533DB9005C8830 /* ZoomLevel.cpp */; };
|
||||
4C91FD5F25AE476700CA5DA4 /* MusicObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C91FD5D25AE476700CA5DA4 /* MusicObject.cpp */; };
|
||||
4C91FD6225AE483700CA5DA4 /* RideAudio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C91FD6025AE483600CA5DA4 /* RideAudio.cpp */; };
|
||||
4C976BC5263976F0002DEBD5 /* FootpathSurfaceObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C976BC1263976F0002DEBD5 /* FootpathSurfaceObject.cpp */; };
|
||||
4C976BC6263976F0002DEBD5 /* FootpathRailingsObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C976BC2263976F0002DEBD5 /* FootpathRailingsObject.cpp */; };
|
||||
4CA23D64263C91D800077AA1 /* ChecksumStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CA23D62263C91D700077AA1 /* ChecksumStream.cpp */; };
|
||||
4CA23DB2263C920900077AA1 /* Entity.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CA23DB1263C920900077AA1 /* Entity.cpp */; };
|
||||
4CA39E512513F8A00094066B /* RTL.ICU.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CA39E4E2513F8A00094066B /* RTL.ICU.cpp */; };
|
||||
@@ -1189,6 +1191,10 @@
|
||||
4C93F1B71F8E185600A9330D /* NewsItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewsItem.h; sourceTree = "<group>"; };
|
||||
4C93F1B81F8E185600A9330D /* Research.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Research.cpp; sourceTree = "<group>"; };
|
||||
4C93F1B91F8E185600A9330D /* Research.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Research.h; sourceTree = "<group>"; };
|
||||
4C976BC1263976F0002DEBD5 /* FootpathSurfaceObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FootpathSurfaceObject.cpp; sourceTree = "<group>"; };
|
||||
4C976BC2263976F0002DEBD5 /* FootpathRailingsObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FootpathRailingsObject.cpp; sourceTree = "<group>"; };
|
||||
4C976BC3263976F0002DEBD5 /* FootpathRailingsObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FootpathRailingsObject.h; sourceTree = "<group>"; };
|
||||
4C976BC4263976F0002DEBD5 /* FootpathSurfaceObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FootpathSurfaceObject.h; sourceTree = "<group>"; };
|
||||
4CA23D62263C91D700077AA1 /* ChecksumStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ChecksumStream.cpp; sourceTree = "<group>"; };
|
||||
4CA23D63263C91D700077AA1 /* ChecksumStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChecksumStream.h; sourceTree = "<group>"; };
|
||||
4CA23DAF263C920900077AA1 /* Entity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Entity.h; sourceTree = "<group>"; };
|
||||
@@ -2739,6 +2745,10 @@
|
||||
F76C84171EC4E7CC00FA49E2 /* FootpathItemObject.h */,
|
||||
F76C84181EC4E7CC00FA49E2 /* FootpathObject.cpp */,
|
||||
F76C84191EC4E7CC00FA49E2 /* FootpathObject.h */,
|
||||
4C976BC2263976F0002DEBD5 /* FootpathRailingsObject.cpp */,
|
||||
4C976BC3263976F0002DEBD5 /* FootpathRailingsObject.h */,
|
||||
4C976BC1263976F0002DEBD5 /* FootpathSurfaceObject.cpp */,
|
||||
4C976BC4263976F0002DEBD5 /* FootpathSurfaceObject.h */,
|
||||
F76C841A1EC4E7CC00FA49E2 /* ImageTable.cpp */,
|
||||
F76C841B1EC4E7CC00FA49E2 /* ImageTable.h */,
|
||||
F76C841C1EC4E7CC00FA49E2 /* LargeSceneryObject.cpp */,
|
||||
@@ -3980,6 +3990,7 @@
|
||||
4CA23DB2263C920900077AA1 /* Entity.cpp in Sources */,
|
||||
C64644F91F3FA4120026AC2D /* EditorInventionsList.cpp in Sources */,
|
||||
C68878C720289B710084B384 /* OpenGLShaderProgram.cpp in Sources */,
|
||||
4C976BC5263976F0002DEBD5 /* FootpathSurfaceObject.cpp in Sources */,
|
||||
4CA39E512513F8A00094066B /* RTL.ICU.cpp in Sources */,
|
||||
93CBA4C420A7502E00867D56 /* Imaging.cpp in Sources */,
|
||||
C6D2BEE61F9BAACE008B557C /* TrackList.cpp in Sources */,
|
||||
@@ -3993,6 +4004,7 @@
|
||||
C68878C520289B710084B384 /* OpenGLDrawingEngine.cpp in Sources */,
|
||||
C6D2BEE71F9BAACE008B557C /* MapTooltip.cpp in Sources */,
|
||||
C666EE7B1F37ACB10061AA04 /* TitleExit.cpp in Sources */,
|
||||
4C976BC6263976F0002DEBD5 /* FootpathRailingsObject.cpp in Sources */,
|
||||
F7D7747F1EC61E5100BE6EBC /* UiContext.macOS.mm in Sources */,
|
||||
F76C887E1EC5324E00FA49E2 /* CursorRepository.cpp in Sources */,
|
||||
C654DF331F69C0430040F43D /* LoadSave.cpp in Sources */,
|
||||
|
||||
@@ -51,7 +51,9 @@ enum : colour_t
|
||||
COLOUR_BRIGHT_PINK,
|
||||
COLOUR_LIGHT_PINK,
|
||||
|
||||
COLOUR_COUNT
|
||||
COLOUR_COUNT,
|
||||
|
||||
COLOUR_NULL = 255,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -256,6 +256,8 @@
|
||||
<ClInclude Include="object\EntranceObject.h" />
|
||||
<ClInclude Include="object\FootpathItemObject.h" />
|
||||
<ClInclude Include="object\FootpathObject.h" />
|
||||
<ClInclude Include="object\FootpathRailingsObject.h" />
|
||||
<ClInclude Include="object\FootpathSurfaceObject.h" />
|
||||
<ClInclude Include="object\ImageTable.h" />
|
||||
<ClInclude Include="object\LargeSceneryObject.h" />
|
||||
<ClInclude Include="object\MusicObject.h" />
|
||||
@@ -696,6 +698,8 @@
|
||||
<ClCompile Include="object\EntranceObject.cpp" />
|
||||
<ClCompile Include="object\FootpathItemObject.cpp" />
|
||||
<ClCompile Include="object\FootpathObject.cpp" />
|
||||
<ClCompile Include="object\FootpathRailingsObject.cpp" />
|
||||
<ClCompile Include="object\FootpathSurfaceObject.cpp" />
|
||||
<ClCompile Include="object\ImageTable.cpp" />
|
||||
<ClCompile Include="object\LargeSceneryObject.cpp" />
|
||||
<ClCompile Include="object\MusicObject.cpp" />
|
||||
@@ -918,4 +922,4 @@
|
||||
<ClCompile Include="world\Wall.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
94
src/openrct2/object/FootpathRailingsObject.cpp
Normal file
94
src/openrct2/object/FootpathRailingsObject.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
/*****************************************************************************
|
||||
* 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 "FootpathRailingsObject.h"
|
||||
|
||||
#include "../core/IStream.hpp"
|
||||
#include "../core/Json.hpp"
|
||||
|
||||
void FootpathRailingsObject::Load()
|
||||
{
|
||||
GetStringTable().Sort();
|
||||
NameStringId = language_allocate_object_string(GetName());
|
||||
|
||||
auto numImages = GetImageTable().GetCount();
|
||||
if (numImages != 0)
|
||||
{
|
||||
PreviewImageId = gfx_object_allocate_images(GetImageTable().GetImages(), GetImageTable().GetCount());
|
||||
BridgeImageId = PreviewImageId + 37;
|
||||
RailingsImageId = PreviewImageId + 1;
|
||||
}
|
||||
}
|
||||
|
||||
void FootpathRailingsObject::Unload()
|
||||
{
|
||||
language_free_object_string(NameStringId);
|
||||
gfx_object_free_images(PreviewImageId, GetImageTable().GetCount());
|
||||
|
||||
NameStringId = 0;
|
||||
PreviewImageId = 0;
|
||||
BridgeImageId = 0;
|
||||
RailingsImageId = 0;
|
||||
}
|
||||
|
||||
void FootpathRailingsObject::DrawPreview(rct_drawpixelinfo* dpi, int32_t width, int32_t height) const
|
||||
{
|
||||
auto x = width / 2;
|
||||
auto y = height / 2;
|
||||
if (SupportType == RailingEntrySupportType::Pole)
|
||||
{
|
||||
auto img = ImageId(BridgeImageId + 20 + 15, Colour);
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
auto h = i * 16;
|
||||
gfx_draw_sprite(dpi, img, { x - 8, y + 8 + h });
|
||||
gfx_draw_sprite(dpi, img, { x + 8, y + 16 + h });
|
||||
}
|
||||
|
||||
gfx_draw_sprite(dpi, BridgeImageId + 5, { x, y - 17 }, 0);
|
||||
gfx_draw_sprite(dpi, RailingsImageId + 1, { x + 4, y - 14 }, 0);
|
||||
gfx_draw_sprite(dpi, RailingsImageId + 1, { x + 27, y - 2 }, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
gfx_draw_sprite(dpi, BridgeImageId + 22, { x + 0, y + 16 }, 0);
|
||||
gfx_draw_sprite(dpi, BridgeImageId + 49, { x, y - 17 }, 0);
|
||||
gfx_draw_sprite(dpi, RailingsImageId + 1, { x + 4, y - 14 }, 0);
|
||||
gfx_draw_sprite(dpi, RailingsImageId + 1, { x + 27, y - 3 }, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void FootpathRailingsObject::ReadJson(IReadObjectContext* context, json_t& root)
|
||||
{
|
||||
Guard::Assert(root.is_object(), "FootpathObject::ReadJson expects parameter root to be object");
|
||||
|
||||
auto properties = root["properties"];
|
||||
if (properties.is_object())
|
||||
{
|
||||
SupportType = ParseSupportType(Json::GetString(properties["supportType"]));
|
||||
ScrollingMode = Json::GetNumber<uint8_t>(properties["scrollingMode"]);
|
||||
Colour = Colour::FromString(Json::GetString(properties["colour"]), COLOUR_NULL);
|
||||
Flags = Json::GetFlags<uint8_t>(
|
||||
properties,
|
||||
{
|
||||
{ "hasSupportImages", RAILING_ENTRY_FLAG_HAS_SUPPORT_BASE_SPRITE },
|
||||
{ "hasElevatedPathImages", RAILING_ENTRY_FLAG_DRAW_PATH_OVER_SUPPORTS },
|
||||
});
|
||||
}
|
||||
|
||||
PopulateTablesFromJson(context, root);
|
||||
}
|
||||
|
||||
RailingEntrySupportType FootpathRailingsObject::ParseSupportType(std::string_view s)
|
||||
{
|
||||
if (s == "pole")
|
||||
return RailingEntrySupportType::Pole;
|
||||
else /* if (s == "box") */
|
||||
return RailingEntrySupportType::Box;
|
||||
}
|
||||
41
src/openrct2/object/FootpathRailingsObject.h
Normal file
41
src/openrct2/object/FootpathRailingsObject.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*****************************************************************************
|
||||
* 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.
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../world/Footpath.h"
|
||||
#include "Object.h"
|
||||
|
||||
class FootpathRailingsObject final : public Object
|
||||
{
|
||||
public:
|
||||
rct_string_id NameStringId{};
|
||||
uint32_t PreviewImageId{};
|
||||
uint32_t BridgeImageId{};
|
||||
uint32_t RailingsImageId{};
|
||||
RailingEntrySupportType SupportType{};
|
||||
uint8_t Flags{};
|
||||
uint8_t ScrollingMode{};
|
||||
colour_t Colour{};
|
||||
|
||||
public:
|
||||
explicit FootpathRailingsObject(const rct_object_entry& entry)
|
||||
: Object(entry)
|
||||
{
|
||||
}
|
||||
|
||||
void ReadJson(IReadObjectContext* context, json_t& root) override;
|
||||
void Load() override;
|
||||
void Unload() override;
|
||||
|
||||
void DrawPreview(rct_drawpixelinfo* dpi, int32_t width, int32_t height) const override;
|
||||
|
||||
private:
|
||||
RailingEntrySupportType ParseSupportType(std::string_view s);
|
||||
};
|
||||
69
src/openrct2/object/FootpathSurfaceObject.cpp
Normal file
69
src/openrct2/object/FootpathSurfaceObject.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
/*****************************************************************************
|
||||
* 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"
|
||||
#include "../object/ObjectRepository.h"
|
||||
|
||||
void FootpathSurfaceObject::Load()
|
||||
{
|
||||
GetStringTable().Sort();
|
||||
NameStringId = language_allocate_object_string(GetName());
|
||||
|
||||
auto numImages = GetImageTable().GetCount();
|
||||
if (numImages != 0)
|
||||
{
|
||||
PreviewImageId = gfx_object_allocate_images(GetImageTable().GetImages(), GetImageTable().GetCount());
|
||||
BaseImageId = PreviewImageId + 1;
|
||||
}
|
||||
}
|
||||
|
||||
void FootpathSurfaceObject::Unload()
|
||||
{
|
||||
language_free_object_string(NameStringId);
|
||||
gfx_object_free_images(PreviewImageId, 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);
|
||||
}
|
||||
|
||||
void FootpathSurfaceObject::SetRepositoryItem(ObjectRepositoryItem* item) const
|
||||
{
|
||||
item->FootpathSurfaceInfo.Flags = Flags;
|
||||
}
|
||||
36
src/openrct2/object/FootpathSurfaceObject.h
Normal file
36
src/openrct2/object/FootpathSurfaceObject.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*****************************************************************************
|
||||
* 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.
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../world/Footpath.h"
|
||||
#include "Object.h"
|
||||
|
||||
class FootpathSurfaceObject final : public Object
|
||||
{
|
||||
public:
|
||||
rct_string_id NameStringId{};
|
||||
uint32_t PreviewImageId{};
|
||||
uint32_t BaseImageId{};
|
||||
uint8_t Flags{};
|
||||
|
||||
public:
|
||||
explicit FootpathSurfaceObject(const rct_object_entry& entry)
|
||||
: Object(entry)
|
||||
{
|
||||
}
|
||||
|
||||
void ReadJson(IReadObjectContext* context, json_t& root) override;
|
||||
void Load() override;
|
||||
void Unload() override;
|
||||
|
||||
void DrawPreview(rct_drawpixelinfo* dpi, int32_t width, int32_t height) const override;
|
||||
|
||||
void SetRepositoryItem(ObjectRepositoryItem* item) const override;
|
||||
};
|
||||
@@ -42,6 +42,8 @@ enum class ObjectType : uint8_t
|
||||
TerrainEdge,
|
||||
Station,
|
||||
Music,
|
||||
FootpathSurface,
|
||||
FootpathRailings,
|
||||
|
||||
Count,
|
||||
None = 255
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include "EntranceObject.h"
|
||||
#include "FootpathItemObject.h"
|
||||
#include "FootpathObject.h"
|
||||
#include "FootpathRailingsObject.h"
|
||||
#include "FootpathSurfaceObject.h"
|
||||
#include "LargeSceneryObject.h"
|
||||
#include "MusicObject.h"
|
||||
#include "Object.h"
|
||||
@@ -356,6 +358,12 @@ namespace ObjectFactory
|
||||
case ObjectType::Music:
|
||||
result = std::make_unique<MusicObject>(entry);
|
||||
break;
|
||||
case ObjectType::FootpathSurface:
|
||||
result = std::make_unique<FootpathSurfaceObject>(entry);
|
||||
break;
|
||||
case ObjectType::FootpathRailings:
|
||||
result = std::make_unique<FootpathRailingsObject>(entry);
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("Invalid object type");
|
||||
}
|
||||
@@ -392,6 +400,10 @@ namespace ObjectFactory
|
||||
return ObjectType::Station;
|
||||
if (s == "music")
|
||||
return ObjectType::Music;
|
||||
if (s == "footpath_surface")
|
||||
return ObjectType::FootpathSurface;
|
||||
if (s == "footpath_railings")
|
||||
return ObjectType::FootpathRailings;
|
||||
return ObjectType::None;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,10 @@ struct ObjectRepositoryItem
|
||||
{
|
||||
std::vector<ObjectEntryDescriptor> Entries;
|
||||
} SceneryGroupInfo;
|
||||
struct
|
||||
{
|
||||
uint8_t Flags{};
|
||||
} FootpathSurfaceInfo;
|
||||
|
||||
[[nodiscard]] ObjectSourceGame GetFirstSourceGame() const
|
||||
{
|
||||
|
||||
@@ -134,6 +134,7 @@ enum
|
||||
{
|
||||
FOOTPATH_ENTRY_FLAG_SHOW_ONLY_IN_SCENARIO_EDITOR = (1 << 2),
|
||||
FOOTPATH_ENTRY_FLAG_IS_QUEUE = (1 << 3),
|
||||
FOOTPATH_ENTRY_FLAG_NO_SLOPE_RAILINGS = (1 << 4),
|
||||
};
|
||||
|
||||
enum
|
||||
|
||||
Reference in New Issue
Block a user