mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-21 06:43:04 +01:00
Rewrite ParkPreview::drawPreviewImage to use SPR_TEMP
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
#include "../Context.h"
|
#include "../Context.h"
|
||||||
#include "../GameState.h"
|
#include "../GameState.h"
|
||||||
#include "../OpenRCT2.h"
|
#include "../OpenRCT2.h"
|
||||||
|
#include "../SpriteIds.h"
|
||||||
#include "../core/Numerics.hpp"
|
#include "../core/Numerics.hpp"
|
||||||
#include "../drawing/Drawing.h"
|
#include "../drawing/Drawing.h"
|
||||||
#include "../drawing/X8DrawingEngine.h"
|
#include "../drawing/X8DrawingEngine.h"
|
||||||
@@ -244,27 +245,14 @@ namespace OpenRCT2
|
|||||||
|
|
||||||
void drawPreviewImage(const PreviewImage& image, RenderTarget& rt, ScreenCoordsXY screenPos)
|
void drawPreviewImage(const PreviewImage& image, RenderTarget& rt, ScreenCoordsXY screenPos)
|
||||||
{
|
{
|
||||||
auto* drawingEngine = GetContext()->GetDrawingEngine();
|
G1Element g1temp = {};
|
||||||
if (drawingEngine == nullptr)
|
g1temp.offset = const_cast<uint8_t*>(image.pixels);
|
||||||
return;
|
g1temp.width = image.width;
|
||||||
|
g1temp.height = image.height;
|
||||||
|
|
||||||
const auto imageId = ImageId(0);
|
GfxSetG1Element(SPR_TEMP, &g1temp);
|
||||||
auto* g1 = const_cast<G1Element*>(GfxGetG1Element(imageId));
|
DrawingEngineInvalidateImage(SPR_TEMP);
|
||||||
if (g1 != nullptr)
|
GfxDrawSprite(rt, ImageId(SPR_TEMP), screenPos);
|
||||||
{
|
|
||||||
// Temporarily substitute a G1 image with the data in the preview image
|
|
||||||
const auto backupG1 = *g1;
|
|
||||||
*g1 = {};
|
|
||||||
g1->offset = const_cast<uint8_t*>(image.pixels);
|
|
||||||
g1->width = image.width;
|
|
||||||
g1->height = image.height;
|
|
||||||
drawingEngine->InvalidateImage(imageId.GetIndex());
|
|
||||||
|
|
||||||
// Draw preview image and restore original G1 image
|
|
||||||
GfxDrawSprite(rt, imageId, screenPos);
|
|
||||||
*g1 = backupG1;
|
|
||||||
drawingEngine->InvalidateImage(imageId.GetIndex());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace OpenRCT2
|
} // namespace OpenRCT2
|
||||||
|
|||||||
Reference in New Issue
Block a user