mirror of https://github.com/OpenRCT2/OpenRCT2.git
fix drawing of object preview
We can't use dpi->width and dpi->height as they only define the clip region, not the viewport
This commit is contained in:
parent
81a597ab0d
commit
4bf9748143
|
@ -66,10 +66,10 @@ void BannerObject::Unload()
|
|||
_legacyType.image = 0;
|
||||
}
|
||||
|
||||
void BannerObject::DrawPreview(rct_drawpixelinfo * dpi) const
|
||||
void BannerObject::DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const
|
||||
{
|
||||
int x = dpi->width / 2;
|
||||
int y = dpi->height / 2;
|
||||
sint32 x = width / 2;
|
||||
sint32 y = height / 2;
|
||||
|
||||
uint32 imageId = 0x20D00000 | _legacyType.image;
|
||||
gfx_draw_sprite(dpi, imageId + 0, x - 12, y + 8, 0);
|
||||
|
|
|
@ -37,5 +37,5 @@ public:
|
|||
void Load() override;
|
||||
void Unload() override;
|
||||
|
||||
void DrawPreview(rct_drawpixelinfo * dpi) const override;
|
||||
void DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const override;
|
||||
};
|
||||
|
|
|
@ -53,10 +53,10 @@ void EntranceObject::Unload()
|
|||
_legacyType.image_id = 0;
|
||||
}
|
||||
|
||||
void EntranceObject::DrawPreview(rct_drawpixelinfo * dpi) const
|
||||
void EntranceObject::DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const
|
||||
{
|
||||
int x = dpi->width / 2;
|
||||
int y = dpi->height / 2;
|
||||
sint32 x = width / 2;
|
||||
sint32 y = height / 2;
|
||||
|
||||
uint32 imageId = _legacyType.image_id;
|
||||
gfx_draw_sprite(dpi, imageId + 1, x - 32, y + 14, 0);
|
||||
|
|
|
@ -37,5 +37,5 @@ public:
|
|||
void Load() override;
|
||||
void Unload() override;
|
||||
|
||||
void DrawPreview(rct_drawpixelinfo * dpi) const override;
|
||||
void DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const override;
|
||||
};
|
||||
|
|
|
@ -68,9 +68,9 @@ void FootpathItemObject::Unload()
|
|||
_legacyType.image = 0;
|
||||
}
|
||||
|
||||
void FootpathItemObject::DrawPreview(rct_drawpixelinfo * dpi) const
|
||||
void FootpathItemObject::DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const
|
||||
{
|
||||
int x = dpi->width / 2;
|
||||
int y = dpi->height / 2;
|
||||
sint32 x = width / 2;
|
||||
sint32 y = height / 2;
|
||||
gfx_draw_sprite(dpi, _legacyType.image, x - 22, y - 24, 0);
|
||||
}
|
||||
|
|
|
@ -37,5 +37,5 @@ public:
|
|||
void Load() override;
|
||||
void Unload() override;
|
||||
|
||||
void DrawPreview(rct_drawpixelinfo * dpi) const override;
|
||||
void DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const override;
|
||||
};
|
||||
|
|
|
@ -63,10 +63,10 @@ void FootpathObject::Unload()
|
|||
_legacyType.image = 0;
|
||||
}
|
||||
|
||||
void FootpathObject::DrawPreview(rct_drawpixelinfo * dpi) const
|
||||
void FootpathObject::DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const
|
||||
{
|
||||
int x = dpi->width / 2;
|
||||
int y = dpi->height / 2;
|
||||
sint32 x = width / 2;
|
||||
sint32 y = height / 2;
|
||||
gfx_draw_sprite(dpi, _legacyType.image + 71, x - 49, y - 17, 0);
|
||||
gfx_draw_sprite(dpi, _legacyType.image + 72, x + 4, y - 17, 0);
|
||||
}
|
||||
|
|
|
@ -37,5 +37,5 @@ public:
|
|||
void Load() override;
|
||||
void Unload() override;
|
||||
|
||||
void DrawPreview(rct_drawpixelinfo * dpi) const override;
|
||||
void DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const override;
|
||||
};
|
||||
|
|
|
@ -110,10 +110,10 @@ void LargeSceneryObject::Unload()
|
|||
_legacyType.image = 0;
|
||||
}
|
||||
|
||||
void LargeSceneryObject::DrawPreview(rct_drawpixelinfo * dpi) const
|
||||
void LargeSceneryObject::DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const
|
||||
{
|
||||
int x = dpi->width / 2;
|
||||
int y = (dpi->height / 2) - 39;
|
||||
sint32 x = width / 2;
|
||||
sint32 y = (height / 2) - 39;
|
||||
|
||||
uint32 imageId = 0xB2D00000 | _legacyType.image;
|
||||
gfx_draw_sprite(dpi, imageId, x, y, 0);
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
void Load() override;
|
||||
void Unload() override;
|
||||
|
||||
void DrawPreview(rct_drawpixelinfo * dpi) const override;
|
||||
void DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const override;
|
||||
|
||||
private:
|
||||
static rct_large_scenery_tile * ReadTiles(IStream * stream);
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
virtual void Load() abstract;
|
||||
virtual void Unload() abstract;
|
||||
|
||||
virtual void DrawPreview(rct_drawpixelinfo * dpi) const { }
|
||||
virtual void DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const { }
|
||||
|
||||
virtual uint8 GetObjectType() const { return _objectEntry.flags & 0x0F; }
|
||||
virtual const utf8 * GetName() const;
|
||||
|
|
|
@ -903,10 +903,10 @@ extern "C"
|
|||
}
|
||||
}
|
||||
|
||||
void object_draw_preview(const void * object, rct_drawpixelinfo * dpi)
|
||||
void object_draw_preview(const void * object, rct_drawpixelinfo * dpi, sint32 width, sint32 height)
|
||||
{
|
||||
const Object * baseObject = (const Object *)object;
|
||||
baseObject->DrawPreview(dpi);
|
||||
baseObject->DrawPreview(dpi, width, height);
|
||||
}
|
||||
|
||||
bool object_entry_compare(const rct_object_entry * a, const rct_object_entry * b)
|
||||
|
|
|
@ -89,7 +89,7 @@ void * object_repository_load_object(const rct_object_e
|
|||
|
||||
void object_delete(void * object);
|
||||
const utf8 * object_get_description(const void * object);
|
||||
void object_draw_preview(const void * object, rct_drawpixelinfo * dpi);
|
||||
void object_draw_preview(const void * object, rct_drawpixelinfo * dpi, sint32 width, sint32 height);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -348,7 +348,7 @@ void RideObject::Unload()
|
|||
_legacyType.images_offset = 0;
|
||||
}
|
||||
|
||||
void RideObject::DrawPreview(rct_drawpixelinfo * dpi) const
|
||||
void RideObject::DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const
|
||||
{
|
||||
uint32 imageId = _legacyType.images_offset;
|
||||
if (_legacyType.ride_type[0] == 0xFF)
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
void Load() override;
|
||||
void Unload() override;
|
||||
|
||||
void DrawPreview(rct_drawpixelinfo * dpi) const override;
|
||||
void DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const override;
|
||||
|
||||
const utf8 * GetDescription() const;
|
||||
const utf8 * GetCapacity() const;
|
||||
|
|
|
@ -69,10 +69,10 @@ void SceneryGroupObject::Unload()
|
|||
_legacyType.image = 0;
|
||||
}
|
||||
|
||||
void SceneryGroupObject::DrawPreview(rct_drawpixelinfo * dpi) const
|
||||
void SceneryGroupObject::DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const
|
||||
{
|
||||
int x = dpi->width / 2;
|
||||
int y = dpi->height / 2;
|
||||
sint32 x = width / 2;
|
||||
sint32 y = height / 2;
|
||||
|
||||
uint32 imageId = _legacyType.image + 0x20600001;
|
||||
gfx_draw_sprite(dpi, imageId, x - 15, y - 14, 0);
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
void Unload() override;
|
||||
void UpdateEntryIndexes();
|
||||
|
||||
void DrawPreview(rct_drawpixelinfo * dpi) const override;
|
||||
void DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const override;
|
||||
|
||||
void SetRepositoryItem(ObjectRepositoryItem * item) const override;
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ void SmallSceneryObject::Unload()
|
|||
_legacyType.image = 0;
|
||||
}
|
||||
|
||||
void SmallSceneryObject::DrawPreview(rct_drawpixelinfo * dpi) const
|
||||
void SmallSceneryObject::DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const
|
||||
{
|
||||
uint32 flags = _legacyType.small_scenery.flags;
|
||||
uint32 imageId = _legacyType.image;
|
||||
|
@ -112,9 +112,9 @@ void SmallSceneryObject::DrawPreview(rct_drawpixelinfo * dpi) const
|
|||
}
|
||||
}
|
||||
|
||||
int x = dpi->width / 2;
|
||||
int y = (dpi->height / 2) + (_legacyType.small_scenery.height / 2);
|
||||
y = Math::Min(y, dpi->height - 16);
|
||||
sint32 x = width / 2;
|
||||
sint32 y = (height / 2) + (_legacyType.small_scenery.height / 2);
|
||||
y = Math::Min(y, height - 16);
|
||||
|
||||
if ((flags & SMALL_SCENERY_FLAG_FULL_TILE) &&
|
||||
(flags & SMALL_SCENERY_FLAG_VOFFSET_CENTRE))
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
void Load() override;
|
||||
void Unload() override;
|
||||
|
||||
void DrawPreview(rct_drawpixelinfo * dpi) const override;
|
||||
void DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const override;
|
||||
|
||||
private:
|
||||
static uint8 * ReadVar10(IStream * stream);
|
||||
|
|
|
@ -58,11 +58,11 @@ void StexObject::Unload()
|
|||
_legacyType.details = 0;
|
||||
}
|
||||
|
||||
void StexObject::DrawPreview(rct_drawpixelinfo * dpi) const
|
||||
void StexObject::DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const
|
||||
{
|
||||
// Write (no image)
|
||||
int x = dpi->width / 2;
|
||||
int y = dpi->height / 2;
|
||||
sint32 x = width / 2;
|
||||
sint32 y = height / 2;
|
||||
gfx_draw_string_centred(dpi, 3326, x, y, 0, nullptr);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
void Load() override;
|
||||
void Unload() override;
|
||||
|
||||
void DrawPreview(rct_drawpixelinfo * dpi) const override;
|
||||
void DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const override;
|
||||
|
||||
const utf8 * GetName() const override;
|
||||
|
||||
|
|
|
@ -69,10 +69,10 @@ void WallObject::Unload()
|
|||
_legacyType.image = 0;
|
||||
}
|
||||
|
||||
void WallObject::DrawPreview(rct_drawpixelinfo * dpi) const
|
||||
void WallObject::DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const
|
||||
{
|
||||
int x = dpi->width / 2;
|
||||
int y = dpi->height / 2;
|
||||
sint32 x = width / 2;
|
||||
sint32 y = height / 2;
|
||||
|
||||
x += 14;
|
||||
y += (_legacyType.wall.height * 2) + 16;
|
||||
|
|
|
@ -37,5 +37,5 @@ public:
|
|||
void Load() override;
|
||||
void Unload() override;
|
||||
|
||||
void DrawPreview(rct_drawpixelinfo * dpi) const override;
|
||||
void DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const override;
|
||||
};
|
||||
|
|
|
@ -57,10 +57,10 @@ void WaterObject::Unload()
|
|||
_legacyType.string_idx = 0;
|
||||
}
|
||||
|
||||
void WaterObject::DrawPreview(rct_drawpixelinfo * dpi) const
|
||||
void WaterObject::DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const
|
||||
{
|
||||
// Write (no image)
|
||||
int x = dpi->width / 2;
|
||||
int y = dpi->height / 2;
|
||||
sint32 x = width / 2;
|
||||
sint32 y = height / 2;
|
||||
gfx_draw_string_centred(dpi, 3326, x, y, 0, nullptr);
|
||||
}
|
||||
|
|
|
@ -37,5 +37,5 @@ public:
|
|||
void Load() override;
|
||||
void Unload() override;
|
||||
|
||||
void DrawPreview(rct_drawpixelinfo * dpi) const override;
|
||||
void DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const override;
|
||||
};
|
||||
|
|
|
@ -797,7 +797,7 @@ static void window_editor_inventions_list_paint(rct_window *w, rct_drawpixelinfo
|
|||
int width = widget->right - widget->left - 1;
|
||||
int height = widget->bottom - widget->top - 1;
|
||||
if (clip_drawpixelinfo(&clipDPI, dpi, x, y, width, height)) {
|
||||
object_draw_preview(object, &clipDPI);
|
||||
object_draw_preview(object, &clipDPI, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1322,7 +1322,7 @@ static void window_editor_object_selection_paint(rct_window *w, rct_drawpixelinf
|
|||
int width = widget->right - widget->left - 1;
|
||||
int height = widget->bottom - widget->top - 1;
|
||||
if (clip_drawpixelinfo(&clipDPI, dpi, x, y, width, height)) {
|
||||
object_draw_preview(_loadedObject, &clipDPI);
|
||||
object_draw_preview(_loadedObject, &clipDPI, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue