1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-22 15:23:01 +01:00

Clip all scenery images in scenery window to prevent overflow/overlap

This commit is contained in:
wolfreak99
2016-12-08 14:10:16 -05:00
committed by Michael Steenbeek
parent bd02f14699
commit d1d6be0b93

View File

@@ -1100,13 +1100,13 @@ void window_scenery_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrol
while ((currentSceneryGlobalId = window_scenery_tab_entries[tabIndex][sceneryTabItemIndex]) != -1) { while ((currentSceneryGlobalId = window_scenery_tab_entries[tabIndex][sceneryTabItemIndex]) != -1) {
uint16 tabSelectedSceneryId = gWindowSceneryTabSelections[tabIndex]; uint16 tabSelectedSceneryId = gWindowSceneryTabSelections[tabIndex];
if (gWindowSceneryPaintEnabled == 1) if (gWindowSceneryPaintEnabled == 1) {
{
if (w->scenery.selected_scenery_id == currentSceneryGlobalId) { if (w->scenery.selected_scenery_id == currentSceneryGlobalId) {
gfx_fill_rect_inset(dpi, left, top, left + SCENERY_BUTTON_WIDTH - 1, gfx_fill_rect_inset(dpi, left, top, left + SCENERY_BUTTON_WIDTH - 1,
top + SCENERY_BUTTON_HEIGHT - 1, w->colours[1], INSET_RECT_FLAG_FILL_MID_LIGHT); top + SCENERY_BUTTON_HEIGHT - 1, w->colours[1], INSET_RECT_FLAG_FILL_MID_LIGHT);
} }
} else { }
else {
if (tabSelectedSceneryId == currentSceneryGlobalId) { if (tabSelectedSceneryId == currentSceneryGlobalId) {
gfx_fill_rect_inset(dpi, left, top, left + SCENERY_BUTTON_WIDTH - 1, gfx_fill_rect_inset(dpi, left, top, left + SCENERY_BUTTON_WIDTH - 1,
top + SCENERY_BUTTON_HEIGHT - 1, w->colours[1], (INSET_RECT_FLAG_BORDER_INSET | INSET_RECT_FLAG_FILL_MID_LIGHT)); top + SCENERY_BUTTON_HEIGHT - 1, w->colours[1], (INSET_RECT_FLAG_BORDER_INSET | INSET_RECT_FLAG_FILL_MID_LIGHT));
@@ -1118,26 +1118,29 @@ void window_scenery_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrol
} }
rct_scenery_entry* sceneryEntry; rct_scenery_entry* sceneryEntry;
rct_drawpixelinfo clipdpi;
if (clip_drawpixelinfo(&clipdpi, dpi, left + 1, top + 1, SCENERY_BUTTON_WIDTH - 2, SCENERY_BUTTON_HEIGHT - 2)) {
if (currentSceneryGlobalId >= 0x400) { if (currentSceneryGlobalId >= 0x400) {
sceneryEntry = get_banner_entry(currentSceneryGlobalId - 0x400); sceneryEntry = get_banner_entry(currentSceneryGlobalId - 0x400);
uint32 imageId = sceneryEntry->image + gWindowSceneryRotation * 2; uint32 imageId = sceneryEntry->image + gWindowSceneryRotation * 2;
imageId |= (gWindowSceneryPrimaryColour << 19) | 0x20000000; imageId |= (gWindowSceneryPrimaryColour << 19) | 0x20000000;
gfx_draw_sprite(dpi, imageId, left + 0x21, top + 0x28, w->colours[1]); gfx_draw_sprite(&clipdpi, imageId, 0x21, 0x28, w->colours[1]);
gfx_draw_sprite(dpi, imageId + 1, left + 0x21, top + 0x28, w->colours[1]); gfx_draw_sprite(&clipdpi, imageId + 1, 0x21, 0x28, w->colours[1]);
} else if (currentSceneryGlobalId >= 0x300) { }
else if (currentSceneryGlobalId >= 0x300) {
sceneryEntry = get_large_scenery_entry(currentSceneryGlobalId - 0x300); sceneryEntry = get_large_scenery_entry(currentSceneryGlobalId - 0x300);
uint32 imageId = sceneryEntry->image + gWindowSceneryRotation; uint32 imageId = sceneryEntry->image + gWindowSceneryRotation;
imageId |= (gWindowSceneryPrimaryColour << 19) | 0x20000000; imageId |= (gWindowSceneryPrimaryColour << 19) | 0x20000000;
imageId |= (gWindowScenerySecondaryColour << 24) | 0x80000000; imageId |= (gWindowScenerySecondaryColour << 24) | 0x80000000;
gfx_draw_sprite(dpi, imageId, left + 0x21, top, w->colours[1]); gfx_draw_sprite(&clipdpi, imageId, 0x21, 0, w->colours[1]);
} else if (currentSceneryGlobalId >= 0x200) { }
else if (currentSceneryGlobalId >= 0x200) {
sceneryEntry = get_wall_entry(currentSceneryGlobalId - 0x200); sceneryEntry = get_wall_entry(currentSceneryGlobalId - 0x200);
rct_drawpixelinfo clipdpi;
if (clip_drawpixelinfo(&clipdpi, dpi, left + 1, top + 1, 64, 78)) {
uint32 imageId = sceneryEntry->image; uint32 imageId = sceneryEntry->image;
uint8 tertiaryColour = w->colours[1]; uint8 tertiaryColour = w->colours[1];
uint16 spriteTop = (sceneryEntry->wall.height * 2) + 0x32;
if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG2) { if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG2) {
imageId |= (gWindowSceneryPrimaryColour << 19) | 0x20000000; imageId |= (gWindowSceneryPrimaryColour << 19) | 0x20000000;
@@ -1145,12 +1148,10 @@ void window_scenery_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrol
if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_SECONDARY_COLOUR) { if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_SECONDARY_COLOUR) {
imageId |= (gWindowScenerySecondaryColour << 24) | 0x80000000; imageId |= (gWindowScenerySecondaryColour << 24) | 0x80000000;
} }
gfx_draw_sprite(&clipdpi, imageId, 0x2F, (sceneryEntry->wall.height * 2) + 0x32, gfx_draw_sprite(&clipdpi, imageId, 0x2F, spriteTop, tertiaryColour);
tertiaryColour);
imageId = (sceneryEntry->image + 0x40000006) | (GlassPaletteIds[gWindowSceneryPrimaryColour] << 19); imageId = (sceneryEntry->image + 0x40000006) | (GlassPaletteIds[gWindowSceneryPrimaryColour] << 19);
gfx_draw_sprite(&clipdpi, imageId, 0x2F, (sceneryEntry->wall.height * 2) + 0x32, gfx_draw_sprite(&clipdpi, imageId, 0x2F, spriteTop, tertiaryColour);
tertiaryColour);
} }
else { else {
imageId |= (gWindowSceneryPrimaryColour << 19) | 0x20000000; imageId |= (gWindowSceneryPrimaryColour << 19) | 0x20000000;
@@ -1162,26 +1163,22 @@ void window_scenery_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrol
imageId &= 0xDFFFFFFF; imageId &= 0xDFFFFFFF;
tertiaryColour = gWindowSceneryTertiaryColour; tertiaryColour = gWindowSceneryTertiaryColour;
} }
} }
gfx_draw_sprite(&clipdpi, imageId, 0x2F, (sceneryEntry->wall.height * 2) + 0x32, gfx_draw_sprite(&clipdpi, imageId, 0x2F, spriteTop, tertiaryColour);
tertiaryColour);
if (sceneryEntry->wall.flags & WALL_SCENERY_IS_DOOR) { if (sceneryEntry->wall.flags & WALL_SCENERY_IS_DOOR) {
gfx_draw_sprite(&clipdpi, imageId + 1, 0x2F, (sceneryEntry->wall.height * 2) + 0x32, gfx_draw_sprite(&clipdpi, imageId + 1, 0x2F, spriteTop, tertiaryColour);
tertiaryColour);
} }
} }
} }
} else if (currentSceneryGlobalId >= 0x100) { else if (currentSceneryGlobalId >= 0x100) {
sceneryEntry = get_footpath_item_entry(currentSceneryGlobalId - 0x100); sceneryEntry = get_footpath_item_entry(currentSceneryGlobalId - 0x100);
uint32 imageId = sceneryEntry->image; uint32 imageId = sceneryEntry->image;
gfx_draw_sprite(dpi, imageId, left + 0x0B, top + 0x10, w->colours[1]); gfx_draw_sprite(&clipdpi, imageId, 0x0B, 0x10, w->colours[1]);
} else { }
else {
sceneryEntry = get_small_scenery_entry(currentSceneryGlobalId); sceneryEntry = get_small_scenery_entry(currentSceneryGlobalId);
rct_drawpixelinfo clipdpi;
if (clip_drawpixelinfo(&clipdpi, dpi, left + 1, top + 1, SCENERY_BUTTON_WIDTH - 2, SCENERY_BUTTON_HEIGHT - 2)) {
uint32 imageId = sceneryEntry->image + gWindowSceneryRotation; uint32 imageId = sceneryEntry->image + gWindowSceneryRotation;
if (sceneryEntry->small_scenery.flags & SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR) { if (sceneryEntry->small_scenery.flags & SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR) {