1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-20 21:43:06 +01:00

add small scenery preview

This commit is contained in:
Ted John
2016-07-02 11:35:46 +01:00
parent 13a560fb1d
commit 52c11267bc
8 changed files with 69 additions and 10 deletions

View File

@@ -668,7 +668,9 @@ extern "C"
void * object_repository_load_object(const rct_object_entry * objectEntry)
{
IObjectRepository * objRepository = GetObjectRepository();
return (void *)objRepository->LoadObject(objectEntry);
Object * object = objRepository->LoadObject(objectEntry);
object->Load();
return (void *)object;
}
void object_repository_unload(size_t itemIndex)
@@ -791,7 +793,9 @@ extern "C"
void object_delete(void * object)
{
delete ((Object *)object);
Object * baseObject = (Object *)object;
baseObject->Unload();
delete baseObject;
}
const utf8 * object_get_description(const void * object)

View File

@@ -15,6 +15,7 @@
#pragma endregion
#include "../core/IStream.hpp"
#include "../core/Math.hpp"
#include "../core/Memory.hpp"
#include "SmallSceneryObject.h"
@@ -89,6 +90,58 @@ void SmallSceneryObject::Unload()
gfx_object_free_images(_legacyType.image, GetImageTable()->GetCount());
}
void SmallSceneryObject::DrawPreview(rct_drawpixelinfo * dpi) const
{
// rct_drawpixelinfo clipDPI;
// if (!clip_drawpixelinfo(&clipDPI, dpi, x - 56, y - 56, 112, 112)) {
// return;
// }
uint32 flags = _legacyType.small_scenery.flags;
uint32 imageId = _legacyType.image;
if (flags & SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR)
{
imageId |= 0x20D00000;
if (flags & SMALL_SCENERY_FLAG_HAS_SECONDARY_COLOUR)
{
imageId |= 0x92000000;
}
}
int x = dpi->width / 2;
int y = (dpi->height / 2) + (_legacyType.small_scenery.height / 2);
y = Math::Min(y, dpi->height - 16);
if ((flags & SMALL_SCENERY_FLAG_FULL_TILE) &&
(flags & SMALL_SCENERY_FLAG_VOFFSET_CENTRE))
{
y -= 12;
}
gfx_draw_sprite(dpi, imageId, x, y, 0);
if (_legacyType.small_scenery.flags & SMALL_SCENERY_FLAG_HAS_GLASS)
{
imageId = _legacyType.image + 0x44500004;
if (flags & SMALL_SCENERY_FLAG_HAS_SECONDARY_COLOUR)
{
imageId |= 0x92000000;
}
gfx_draw_sprite(dpi, imageId, x, y, 0);
}
if (flags & SMALL_SCENERY_FLAG_ANIMATED_FG)
{
imageId = _legacyType.image + 4;
if (flags & SMALL_SCENERY_FLAG_HAS_SECONDARY_COLOUR)
{
imageId |= 0x92000000;
}
gfx_draw_sprite(dpi, imageId, x, y, 0);
}
}
const utf8 * SmallSceneryObject::GetName() const
{
const utf8 * name = GetStringTable()->GetString(OBJ_STRING_ID_NAME);

View File

@@ -40,6 +40,8 @@ public:
void Load() override;
void Unload() override;
void DrawPreview(rct_drawpixelinfo * dpi) const;
const utf8 * GetName() const override;
private: