Skip to content

Commit

Permalink
Clip all scenery images in scenery window to prevent overflow/overlap
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfreak99 authored and Gymnasiast committed Dec 8, 2016
1 parent bd02f14 commit d1d6be0
Showing 1 changed file with 38 additions and 41 deletions.
79 changes: 38 additions & 41 deletions src/windows/scenery.c
Expand Up @@ -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) {
uint16 tabSelectedSceneryId = gWindowSceneryTabSelections[tabIndex];

if (gWindowSceneryPaintEnabled == 1)
{
if (gWindowSceneryPaintEnabled == 1) {
if (w->scenery.selected_scenery_id == currentSceneryGlobalId) {
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);
}
} else {
}
else {
if (tabSelectedSceneryId == currentSceneryGlobalId) {
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));
Expand All @@ -1118,39 +1118,40 @@ void window_scenery_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrol
}

rct_scenery_entry* sceneryEntry;
if (currentSceneryGlobalId >= 0x400) {
sceneryEntry = get_banner_entry(currentSceneryGlobalId - 0x400);
uint32 imageId = sceneryEntry->image + gWindowSceneryRotation * 2;
imageId |= (gWindowSceneryPrimaryColour << 19) | 0x20000000;

gfx_draw_sprite(dpi, imageId, left + 0x21, top + 0x28, w->colours[1]);
gfx_draw_sprite(dpi, imageId + 1, left + 0x21, top + 0x28, w->colours[1]);
} else if (currentSceneryGlobalId >= 0x300) {
sceneryEntry = get_large_scenery_entry(currentSceneryGlobalId - 0x300);
uint32 imageId = sceneryEntry->image + gWindowSceneryRotation;
imageId |= (gWindowSceneryPrimaryColour << 19) | 0x20000000;
imageId |= (gWindowScenerySecondaryColour << 24) | 0x80000000;

gfx_draw_sprite(dpi, imageId, left + 0x21, top, w->colours[1]);
} else if (currentSceneryGlobalId >= 0x200) {
sceneryEntry = get_wall_entry(currentSceneryGlobalId - 0x200);
rct_drawpixelinfo clipdpi;
if (clip_drawpixelinfo(&clipdpi, dpi, left + 1, top + 1, 64, 78)) {
rct_drawpixelinfo clipdpi;
if (clip_drawpixelinfo(&clipdpi, dpi, left + 1, top + 1, SCENERY_BUTTON_WIDTH - 2, SCENERY_BUTTON_HEIGHT - 2)) {
if (currentSceneryGlobalId >= 0x400) {
sceneryEntry = get_banner_entry(currentSceneryGlobalId - 0x400);
uint32 imageId = sceneryEntry->image + gWindowSceneryRotation * 2;
imageId |= (gWindowSceneryPrimaryColour << 19) | 0x20000000;

gfx_draw_sprite(&clipdpi, imageId, 0x21, 0x28, w->colours[1]);
gfx_draw_sprite(&clipdpi, imageId + 1, 0x21, 0x28, w->colours[1]);
}
else if (currentSceneryGlobalId >= 0x300) {
sceneryEntry = get_large_scenery_entry(currentSceneryGlobalId - 0x300);
uint32 imageId = sceneryEntry->image + gWindowSceneryRotation;
imageId |= (gWindowSceneryPrimaryColour << 19) | 0x20000000;
imageId |= (gWindowScenerySecondaryColour << 24) | 0x80000000;

gfx_draw_sprite(&clipdpi, imageId, 0x21, 0, w->colours[1]);
}
else if (currentSceneryGlobalId >= 0x200) {
sceneryEntry = get_wall_entry(currentSceneryGlobalId - 0x200);
uint32 imageId = sceneryEntry->image;
uint8 tertiaryColour = w->colours[1];
uint16 spriteTop = (sceneryEntry->wall.height * 2) + 0x32;

if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG2) {
imageId |= (gWindowSceneryPrimaryColour << 19) | 0x20000000;

if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_SECONDARY_COLOUR) {
imageId |= (gWindowScenerySecondaryColour << 24) | 0x80000000;
}
gfx_draw_sprite(&clipdpi, imageId, 0x2F, (sceneryEntry->wall.height * 2) + 0x32,
tertiaryColour);
gfx_draw_sprite(&clipdpi, imageId, 0x2F, spriteTop, tertiaryColour);

imageId = (sceneryEntry->image + 0x40000006) | (GlassPaletteIds[gWindowSceneryPrimaryColour] << 19);
gfx_draw_sprite(&clipdpi, imageId, 0x2F, (sceneryEntry->wall.height * 2) + 0x32,
tertiaryColour);
gfx_draw_sprite(&clipdpi, imageId, 0x2F, spriteTop, tertiaryColour);
}
else {
imageId |= (gWindowSceneryPrimaryColour << 19) | 0x20000000;
Expand All @@ -1162,26 +1163,22 @@ void window_scenery_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrol
imageId &= 0xDFFFFFFF;
tertiaryColour = gWindowSceneryTertiaryColour;
}

}
gfx_draw_sprite(&clipdpi, imageId, 0x2F, (sceneryEntry->wall.height * 2) + 0x32,
tertiaryColour);
gfx_draw_sprite(&clipdpi, imageId, 0x2F, spriteTop, tertiaryColour);

if (sceneryEntry->wall.flags & WALL_SCENERY_IS_DOOR){
gfx_draw_sprite(&clipdpi, imageId + 1, 0x2F, (sceneryEntry->wall.height * 2) + 0x32,
tertiaryColour);
if (sceneryEntry->wall.flags & WALL_SCENERY_IS_DOOR) {
gfx_draw_sprite(&clipdpi, imageId + 1, 0x2F, spriteTop, tertiaryColour);
}
}
}
} else if (currentSceneryGlobalId >= 0x100) {
sceneryEntry = get_footpath_item_entry(currentSceneryGlobalId - 0x100);
uint32 imageId = sceneryEntry->image;

gfx_draw_sprite(dpi, imageId, left + 0x0B, top + 0x10, w->colours[1]);
} else {
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)) {
else if (currentSceneryGlobalId >= 0x100) {
sceneryEntry = get_footpath_item_entry(currentSceneryGlobalId - 0x100);
uint32 imageId = sceneryEntry->image;

gfx_draw_sprite(&clipdpi, imageId, 0x0B, 0x10, w->colours[1]);
}
else {
sceneryEntry = get_small_scenery_entry(currentSceneryGlobalId);
uint32 imageId = sceneryEntry->image + gWindowSceneryRotation;

if (sceneryEntry->small_scenery.flags & SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR) {
Expand All @@ -1195,7 +1192,7 @@ void window_scenery_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrol
uint16 spriteTop = (sceneryEntry->small_scenery.height / 4) + 0x2B;

if (sceneryEntry->small_scenery.flags & SMALL_SCENERY_FLAG_FULL_TILE &&
sceneryEntry->small_scenery.flags & SMALL_SCENERY_FLAG_VOFFSET_CENTRE) {
sceneryEntry->small_scenery.flags & SMALL_SCENERY_FLAG_VOFFSET_CENTRE) {
spriteTop -= 0x0C;
}

Expand Down

0 comments on commit d1d6be0

Please sign in to comment.