SCI: Fix transparency in view-based mouse cursors.

svn-id: r40116
This commit is contained in:
Walter van Niftrik 2009-04-24 14:30:27 +00:00
parent 6f60e0dd48
commit 8d3cb3bd5f
3 changed files with 10 additions and 4 deletions

View File

@ -271,7 +271,8 @@ static uint8 *create_cursor(gfx_driver_t *drv, gfx_pixmap_t *pointer, int mode)
for (int xc = 0; xc < pointer->index_width; xc++) {
uint8 color = *src;
if (color != 255)
// FIXME: The palette size check is a workaround for cursors using non-palette colour GFX_CURSOR_TRANSPARENT
if (color < pointer->palette->size())
color = pointer->palette->getColor(color).parent_index;
for (int scalectr = 0; scalectr < drv->mode->xfact; scalectr++) {
*pos++ = color;
@ -292,7 +293,13 @@ static int scummvm_set_pointer(gfx_driver_t *drv, gfx_pixmap_t *pointer, Common:
} else {
delete[] S->pointer_data;
S->pointer_data = create_cursor(drv, pointer, 1);
g_system->setMouseCursor(S->pointer_data, pointer->width, pointer->height, hotspot->x, hotspot->y);
// FIXME: The palette size check is a workaround for cursors using non-palette colour GFX_CURSOR_TRANSPARENT
uint8 color_key = GFX_CURSOR_TRANSPARENT;
if ((pointer->color_key != GFX_PIXMAP_COLOR_KEY_NONE) && ((unsigned int)pointer->color_key < pointer->palette->size()))
color_key = pointer->palette->getColor(pointer->color_key).parent_index;
g_system->setMouseCursor(S->pointer_data, pointer->width, pointer->height, hotspot->x, hotspot->y, color_key);
g_system->showMouse(true);
}

View File

@ -164,6 +164,7 @@ extern rect_t gfx_rect_fullscreen;
#define GFX_PIXMAP_FLAG_PALETTIZED (1<<6) /* Indicates a palettized view */
#define GFX_PIXMAP_COLOR_KEY_NONE -1 /* No transpacency colour key */
#define GFX_CURSOR_TRANSPARENT 255 // Cursor colour key
struct gfx_pixmap_t { /* gfx_pixmap_t: Pixel map */

View File

@ -37,8 +37,6 @@ namespace Sci {
#define GFX_SCI01_CURSOR_COLORS_NR 3
#define GFX_SCI0_CURSOR_COLORS_NR 2
#define GFX_CURSOR_TRANSPARENT 255
gfx_pixmap_color_t gfx_sci01_cursor_colors[GFX_SCI01_CURSOR_COLORS_NR] = {
{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x00, 0x00},
{GFX_COLOR_INDEX_UNMAPPED, 0xff, 0xff, 0xff},