1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-04 13:42:55 +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

@@ -809,7 +809,7 @@ static void object_type_small_scenery_paint(void *objectEntry, rct_drawpixelinfo
}
gfx_draw_sprite(&clipDPI, imageId, x, y, 0);
if (sceneryEntry->small_scenery.flags & SMALL_SCENERY_FLAG10) {
if (sceneryEntry->small_scenery.flags & SMALL_SCENERY_FLAG_HAS_GLASS) {
imageId = sceneryEntry->image + 0x44500004;
if (sceneryEntry->small_scenery.flags & SMALL_SCENERY_FLAG_HAS_SECONDARY_COLOUR) {
imageId |= 0x92000000;
@@ -818,7 +818,7 @@ static void object_type_small_scenery_paint(void *objectEntry, rct_drawpixelinfo
gfx_draw_sprite(&clipDPI, imageId, x, y, 0);
}
if (sceneryEntry->small_scenery.flags & SMALL_SCENERY_FLAG8) {
if (sceneryEntry->small_scenery.flags & SMALL_SCENERY_FLAG_ANIMATED_FG) {
imageId = sceneryEntry->image + 4;
if (sceneryEntry->small_scenery.flags & SMALL_SCENERY_FLAG_HAS_SECONDARY_COLOUR) {
imageId |= 0x92000000;

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:

View File

@@ -130,7 +130,7 @@ void scenery_paint(uint8 direction, int height, rct_map_element* mapElement) {
sub_98197C(baseImageid, x_offset, y_offset, boxlength.x, boxlength.y, boxlength.z - 1, height, boxoffset.x, boxoffset.y, boxoffset.z, get_current_rotation());
}
if (entry->small_scenery.flags & SMALL_SCENERY_FLAG10) {
if (entry->small_scenery.flags & SMALL_SCENERY_FLAG_HAS_GLASS) {
if (dword_F64EB0 == 0) {
// Draw translucent overlay:
int image_id = (baseImageid & 0x7FFFF) + (((mapElement->properties.scenery.colour_1 & 0x1F) + 112) << 19) + 0x40000004;

View File

@@ -986,7 +986,7 @@ void window_scenery_invalidate(rct_window *w)
} else if (tabSelectedSceneryId < 0x100) {
sceneryEntry = get_small_scenery_entry(tabSelectedSceneryId);
if (sceneryEntry->small_scenery.flags & (SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR | SMALL_SCENERY_FLAG10)) {
if (sceneryEntry->small_scenery.flags & (SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR | SMALL_SCENERY_FLAG_HAS_GLASS)) {
window_scenery_widgets[WIDX_SCENERY_PRIMARY_COLOUR_BUTTON].type = WWT_COLOURBTN;
if (sceneryEntry->small_scenery.flags & SMALL_SCENERY_FLAG_HAS_SECONDARY_COLOUR)
@@ -1210,7 +1210,7 @@ void window_scenery_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrol
gfx_draw_sprite(&clipdpi, imageId, 0x20, spriteTop, w->colours[1]);
}
if (sceneryEntry->small_scenery.flags & SMALL_SCENERY_FLAG8) {
if (sceneryEntry->small_scenery.flags & SMALL_SCENERY_FLAG_ANIMATED_FG) {
imageId = (sceneryEntry->image + gWindowSceneryRotation) + 4;
gfx_draw_sprite(&clipdpi, imageId, 0x20, spriteTop, w->colours[1]);
}

View File

@@ -910,7 +910,7 @@ static void repaint_scenery_tool_down(sint16 x, sint16 y, sint16 widgetIndex){
// If can't repaint
if (!(scenery_entry->small_scenery.flags &
(SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR |
SMALL_SCENERY_FLAG10)))
SMALL_SCENERY_FLAG_HAS_GLASS)))
return;
gGameCommandErrorTitle = STR_CANT_REPAINT_THIS;

View File

@@ -44,9 +44,9 @@ typedef enum {
SMALL_SCENERY_FLAG_ANIMATED = (1 << 4), // 0x10
SMALL_SCENERY_FLAG6 = (1 << 5), // 0x20
SMALL_SCENERY_FLAG_CAN_BE_WATERED = (1 << 6), // 0x40
SMALL_SCENERY_FLAG8 = (1 << 7), // 0x80
SMALL_SCENERY_FLAG_ANIMATED_FG = (1 << 7), // 0x80
SMALL_SCENERY_FLAG9 = (1 << 8), // 0x100
SMALL_SCENERY_FLAG10 = (1 << 9), // 0x200
SMALL_SCENERY_FLAG_HAS_GLASS = (1 << 9), // 0x200
SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR = (1 << 10), // 0x400
SMALL_SCENERY_FLAG12 = (1 << 11), // 0x800
SMALL_SCENERY_FLAG13 = (1 << 12), // 0x1000