[Scummvm-cvs-logs] SF.net SVN: scummvm:[45029] scummvm/trunk/engines/sci
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Tue Oct 13 19:09:32 CEST 2009
Revision: 45029
http://scummvm.svn.sourceforge.net/scummvm/?rev=45029&view=rev
Author: thebluegr
Date: 2009-10-13 17:09:32 +0000 (Tue, 13 Oct 2009)
Log Message:
-----------
Merged the rest of the cursor code
Modified Paths:
--------------
scummvm/trunk/engines/sci/console.cpp
scummvm/trunk/engines/sci/engine/kgraphics.cpp
scummvm/trunk/engines/sci/gfx/gfx_driver.cpp
scummvm/trunk/engines/sci/gfx/gfx_driver.h
scummvm/trunk/engines/sci/gfx/operations.cpp
scummvm/trunk/engines/sci/gfx/operations.h
scummvm/trunk/engines/sci/gui/gui.cpp
scummvm/trunk/engines/sci/gui/gui.h
scummvm/trunk/engines/sci/gui/gui_cursor.cpp
scummvm/trunk/engines/sci/gui/gui_cursor.h
scummvm/trunk/engines/sci/gui32/gui32.cpp
scummvm/trunk/engines/sci/gui32/gui32.h
Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp 2009-10-13 16:22:07 UTC (rev 45028)
+++ scummvm/trunk/engines/sci/console.cpp 2009-10-13 17:09:32 UTC (rev 45029)
@@ -1197,7 +1197,7 @@
}
bool Console::cmdFlushPorts(int argc, const char **argv) {
- _vm->_gamestate->_cursor->setShape(GFXOP_NO_POINTER);
+ _vm->_gamestate->_gui->hideCursor();
DebugPrintf("Flushing dynamically allocated ports (for memory profiling)...\n");
delete _vm->_gamestate->visual;
_vm->_gamestate->gfx_state->gfxResMan->freeAllResources();
Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp 2009-10-13 16:22:07 UTC (rev 45028)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp 2009-10-13 17:09:32 UTC (rev 45029)
@@ -516,7 +516,7 @@
hotspot = new Common::Point(argv[3].toSint16(), argv[4].toSint16());
// Fallthrough
case 3:
- gfxop_set_pointer_view(s->gfx_state, argv[0].toUint16(), argv[1].toUint16(), argv[2].toUint16(), hotspot);
+ s->_gui->setCursorView(argv[0].toUint16(), argv[1].toUint16(), argv[2].toUint16(), hotspot);
if (hotspot)
delete hotspot;
break;
Modified: scummvm/trunk/engines/sci/gfx/gfx_driver.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_driver.cpp 2009-10-13 16:22:07 UTC (rev 45028)
+++ scummvm/trunk/engines/sci/gfx/gfx_driver.cpp 2009-10-13 17:09:32 UTC (rev 45029)
@@ -183,45 +183,6 @@
memcpy(_screen->_controlScreen, priority->index_data, _mode->xsize * _mode->ysize);
}
-// Mouse pointer operations
-
-void GfxDriver::setPointer(gfx_pixmap_t *pointer, Common::Point *hotspot) {
- if (!pointer || !hotspot) {
- CursorMan.showMouse(false);
- return;
- }
-
- pointer->palette->mergeInto(_mode->palette);
-
- // Scale cursor and map its colors to the global palette
- byte *cursorData = new byte[pointer->width * pointer->height];
-
- for (int yc = 0; yc < pointer->index_height; yc++) {
- byte *linebase = &cursorData[yc * (pointer->width * _mode->scaleFactor)];
-
- for (int xc = 0; xc < pointer->index_width; xc++) {
- byte color = pointer->index_data[yc * pointer->index_width + xc];
- if (color < pointer->palette->size())
- color = pointer->palette->getColor(color).getParentIndex();
- memset(&linebase[xc], color, _mode->scaleFactor);
- }
-
- // Scale vertically
- for (int scalectr = 1; scalectr < _mode->scaleFactor; scalectr++)
- memcpy(&linebase[pointer->width * scalectr], linebase, pointer->width);
- }
-
- byte color_key = pointer->color_key;
- if ((pointer->color_key != GFX_PIXMAP_COLOR_KEY_NONE) && ((uint)pointer->color_key < pointer->palette->size()))
- color_key = pointer->palette->getColor(pointer->color_key).getParentIndex();
-
- CursorMan.replaceCursor(cursorData, pointer->width, pointer->height, hotspot->x, hotspot->y, color_key);
- CursorMan.showMouse(true);
-
- delete[] cursorData;
- cursorData = 0;
-}
-
void GfxDriver::animatePalette(int fromColor, int toColor, int stepCount) {
int i;
PaletteEntry firstColor = _mode->palette->getColor(fromColor);
Modified: scummvm/trunk/engines/sci/gfx/gfx_driver.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_driver.h 2009-10-13 16:22:07 UTC (rev 45028)
+++ scummvm/trunk/engines/sci/gfx/gfx_driver.h 2009-10-13 17:09:32 UTC (rev 45029)
@@ -206,25 +206,6 @@
void setStaticBuffer(gfx_pixmap_t *pic, gfx_pixmap_t *priority);
/** @} */
- /** @name Mouse pointer operations */
- /** @{ */
-
- /**
- * Sets a new mouse pointer.
- *
- * If pointer is not NULL, it will have been scaled to the appropriate
- * size and registered as a pixmap (if neccessary) beforehand. If this
- * function is called for a target that supports only two-color
- * pointers, the image is a color index image, where only color index
- * values 0, 1, and GFX_COLOR_INDEX_TRANSPARENT are used.
- *
- * @param[in] pointer The pointer to set, or NULL to set no pointer.
- * @param[in] hotspot The coordinates of the hotspot, or NULL to set
- * no pointer.
- */
- void setPointer(gfx_pixmap_t *pointer, Common::Point *hotspot);
- /** @} */
-
gfx_mode_t *getMode() { return _mode; }
/**
Modified: scummvm/trunk/engines/sci/gfx/operations.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.cpp 2009-10-13 16:22:07 UTC (rev 45028)
+++ scummvm/trunk/engines/sci/gfx/operations.cpp 2009-10-13 17:09:32 UTC (rev 45029)
@@ -967,25 +967,6 @@
}
}
-void gfxop_set_pointer_view(GfxState *state, int nr, int loop, int cel, Common::Point *hotspot) {
- // FIXME: For now, don't palettize pointers
- gfx_pixmap_t *new_pointer = state->gfxResMan->getView(nr, &loop, &cel, 0)->loops[loop].cels[cel];
-
- // Eco Quest 1 uses a 1x1 transparent cursor to hide the cursor from the user. Some scalers don't seem to support this.
- if (new_pointer->width < 2 || new_pointer->height < 2) {
- state->driver->setPointer(NULL, NULL);
- return;
- }
-
- if (hotspot)
- state->driver->setPointer(new_pointer, hotspot);
- else {
- // Compute hotspot from xoffset/yoffset
- Common::Point p = Common::Point(new_pointer->xoffset + (new_pointer->width >> 1), new_pointer->yoffset + new_pointer->height - 1);
- state->driver->setPointer(new_pointer, &p);
- }
-}
-
#define SCANCODE_ROWS_NR 3
struct scancode_row {
Modified: scummvm/trunk/engines/sci/gfx/operations.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.h 2009-10-13 16:22:07 UTC (rev 45028)
+++ scummvm/trunk/engines/sci/gfx/operations.h 2009-10-13 17:09:32 UTC (rev 45029)
@@ -40,8 +40,6 @@
struct TextFragment;
-#define GFXOP_NO_POINTER -1
-
/* Threshold in color index mode to differentiate between visible and non-visible stuff.
** GFXOP_ALPHA_THRESHOLD itself should be treated as non-visible.
*/
@@ -364,19 +362,6 @@
void gfxop_sleep(GfxState *state, uint32 msecs);
/**
- * Sets the mouse pointer to a view resource.
- *
- * Use gfxop_set_pointer_cursor(state, GFXOP_NO_POINTER) to disable the pointer.
- *
- * @param[in] state The affected state
- * @param[in] nr Number of the view resource to use
- * @param[in] loop View loop to use
- * @param[in] cel View cel to use
- * @param[in] hotspot Manually set hotspot to use, or NULL for default.
- */
-void gfxop_set_pointer_view(GfxState *state, int nr, int loop, int cel, Common::Point *hotspot);
-
-/**
* Retrieves the next input event from the driver.
*
* @param[in] state The affected state
Modified: scummvm/trunk/engines/sci/gui/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.cpp 2009-10-13 16:22:07 UTC (rev 45028)
+++ scummvm/trunk/engines/sci/gui/gui.cpp 2009-10-13 17:09:32 UTC (rev 45029)
@@ -601,6 +601,10 @@
_cursor->setShape(cursorId);
}
+void SciGui::setCursorView(GuiResourceId viewNum, int loopNum, int cellNum, Common::Point *hotspot) {
+ _cursor->setView(viewNum, loopNum, cellNum, hotspot);
+}
+
void SciGui::setCursorPos(Common::Point pos) {
pos.y += _gfx->GetPort()->top;
pos.x += _gfx->GetPort()->left;
Modified: scummvm/trunk/engines/sci/gui/gui.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.h 2009-10-13 16:22:07 UTC (rev 45028)
+++ scummvm/trunk/engines/sci/gui/gui.h 2009-10-13 17:09:32 UTC (rev 45029)
@@ -105,6 +105,7 @@
virtual void hideCursor();
virtual void showCursor();
virtual void setCursorShape(GuiResourceId cursorId);
+ virtual void setCursorView(GuiResourceId viewNum, int loopNum, int cellNum, Common::Point *hotspot);
virtual void setCursorPos(Common::Point pos);
virtual void moveCursor(Common::Point pos);
Modified: scummvm/trunk/engines/sci/gui/gui_cursor.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_cursor.cpp 2009-10-13 16:22:07 UTC (rev 45028)
+++ scummvm/trunk/engines/sci/gui/gui_cursor.cpp 2009-10-13 17:09:32 UTC (rev 45029)
@@ -38,7 +38,6 @@
SciGuiCursor::SciGuiCursor(ResourceManager *resMan, SciGuiPalette *palette)
: _resMan(resMan), _palette(palette) {
- _rawBitmap = NULL;
setPosition(Common::Point(160, 150)); // TODO: how is that different in 640x400 games?
setMoveZone(Common::Rect(0, 0, 320, 200)); // TODO: hires games
@@ -64,10 +63,12 @@
byte color;
int16 maskA, maskB;
byte *pOut;
+ byte *rawBitmap = new byte[SCI_CURSOR_SCI0_HEIGHTWIDTH * SCI_CURSOR_SCI0_HEIGHTWIDTH];
if (resourceId == -1) {
// no resourceId given, so we actually hide the cursor
hide();
+ delete rawBitmap;
return;
}
@@ -95,10 +96,7 @@
// Seek to actual data
resourceData += 4;
- if (!_rawBitmap)
- _rawBitmap = new byte[SCI_CURSOR_SCI0_HEIGHTWIDTH*SCI_CURSOR_SCI0_HEIGHTWIDTH];
-
- pOut = _rawBitmap;
+ pOut = rawBitmap;
for (y = 0; y < SCI_CURSOR_SCI0_HEIGHTWIDTH; y++) {
maskA = READ_LE_UINT16(resourceData + (y << 1));
maskB = READ_LE_UINT16(resourceData + 32 + (y << 1));
@@ -109,10 +107,41 @@
}
}
- CursorMan.replaceCursor(_rawBitmap, SCI_CURSOR_SCI0_HEIGHTWIDTH, SCI_CURSOR_SCI0_HEIGHTWIDTH, hotspot.x, hotspot.y, SCI_CURSOR_SCI0_TRANSPARENCYCOLOR);
+ CursorMan.replaceCursor(rawBitmap, SCI_CURSOR_SCI0_HEIGHTWIDTH, SCI_CURSOR_SCI0_HEIGHTWIDTH, hotspot.x, hotspot.y, SCI_CURSOR_SCI0_TRANSPARENCYCOLOR);
CursorMan.showMouse(true);
+
+ delete rawBitmap;
}
+void SciGuiCursor::setView(GuiResourceId viewNum, int loopNum, int celNum, Common::Point *hotspot) {
+ SciGuiView *cursorView = new SciGuiView(_resMan, _screen, _palette, viewNum);
+
+ sciViewCelInfo *celInfo = cursorView->getCelInfo(loopNum, celNum);
+ int16 width = celInfo->width;
+ int16 height = celInfo->height;
+ byte clearKey = celInfo->clearKey;
+ Common::Point *cursorHotspot = hotspot;
+ if (!cursorHotspot)
+ // Compute hotspot from xoffset/yoffset
+ cursorHotspot = new Common::Point((celInfo->width >> 1) - celInfo->displaceX, celInfo->height - celInfo->displaceY - 1);
+
+ // Eco Quest 1 uses a 1x1 transparent cursor to hide the cursor from the user. Some scalers don't seem to support this
+ if (width < 2 || height < 2) {
+ hide();
+ delete cursorHotspot;
+ delete cursorView;
+ return;
+ }
+
+ cursorView->getBitmap(loopNum, celNum);
+
+ CursorMan.replaceCursor(celInfo->rawBitmap, width, height, cursorHotspot->x, cursorHotspot->y, clearKey);
+ show();
+
+ delete cursorHotspot;
+ delete cursorView;
+}
+
void SciGuiCursor::setPosition(Common::Point pos) {
g_system->warpMouse(pos.x, pos.y);
}
Modified: scummvm/trunk/engines/sci/gui/gui_cursor.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_cursor.h 2009-10-13 16:22:07 UTC (rev 45028)
+++ scummvm/trunk/engines/sci/gui/gui_cursor.h 2009-10-13 17:09:32 UTC (rev 45029)
@@ -43,6 +43,7 @@
void show();
void hide();
void setShape(GuiResourceId resourceId);
+ void setView(GuiResourceId viewNum, int loopNum, int celNum, Common::Point *hotspot);
void setPosition(Common::Point pos);
Common::Point getPosition();
void refreshPosition();
@@ -59,7 +60,6 @@
SciGuiScreen *_screen;
SciGuiPalette *_palette;
- byte *_rawBitmap;
Common::Rect _moveZone; // Rectangle in which the pointer can move
};
Modified: scummvm/trunk/engines/sci/gui32/gui32.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui32/gui32.cpp 2009-10-13 16:22:07 UTC (rev 45028)
+++ scummvm/trunk/engines/sci/gui32/gui32.cpp 2009-10-13 17:09:32 UTC (rev 45029)
@@ -2457,6 +2457,10 @@
_cursor->setShape(cursorId);
}
+void SciGui32::setCursorView(GuiResourceId viewNum, int loopNum, int cellNum, Common::Point *hotspot) {
+ _cursor->setView(viewNum, loopNum, cellNum, hotspot);
+}
+
void SciGui32::setCursorPos(Common::Point pos) {
pos.y += s->port->_bounds.y;
pos.x += s->port->_bounds.x;
Modified: scummvm/trunk/engines/sci/gui32/gui32.h
===================================================================
--- scummvm/trunk/engines/sci/gui32/gui32.h 2009-10-13 16:22:07 UTC (rev 45028)
+++ scummvm/trunk/engines/sci/gui32/gui32.h 2009-10-13 17:09:32 UTC (rev 45029)
@@ -95,6 +95,7 @@
void hideCursor();
void showCursor();
void setCursorShape(GuiResourceId cursorId);
+ void setCursorView(GuiResourceId viewNum, int loopNum, int cellNum, Common::Point *hotspot);
void setCursorPos(Common::Point pos);
void moveCursor(Common::Point pos);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list