SCI: calling most of the cursor functions directly via _gfxCursor instead of SciGui/32

svn-id: r47903
This commit is contained in:
Martin Kiewitz 2010-02-05 14:48:51 +00:00
parent 6c204cc890
commit f8f490c565
13 changed files with 31 additions and 124 deletions

View file

@ -219,7 +219,7 @@ void Console::postEnter() {
_engine->_gamestate->_soundCmd->pauseAll(false); _engine->_gamestate->_soundCmd->pauseAll(false);
if (!_videoFile.empty()) { if (!_videoFile.empty()) {
_engine->_gamestate->_gui->hideCursor(); _engine->_gamestate->_gfxCursor->kernelHide();
if (_videoFile.hasSuffix(".seq")) { if (_videoFile.hasSuffix(".seq")) {
SeqDecoder *seqDecoder = new SeqDecoder(); SeqDecoder *seqDecoder = new SeqDecoder();
@ -255,7 +255,7 @@ void Console::postEnter() {
#endif #endif
} }
_engine->_gamestate->_gui->showCursor(); _engine->_gamestate->_gfxCursor->kernelShow();
_videoFile.clear(); _videoFile.clear();
_videoFrameDelay = 0; _videoFrameDelay = 0;

View file

@ -47,12 +47,7 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) {
SegManager *segMan = s->_segMan; SegManager *segMan = s->_segMan;
Common::Point mousePos; Common::Point mousePos;
#ifdef ENABLE_SCI32 mousePos = s->_gfxCursor->getPosition();
if (s->_gui32)
mousePos = s->_gui32->getCursorPos();
else
#endif
mousePos = s->_gui->getCursorPos();
// If there's a simkey pending, and the game wants a keyboard event, use the // If there's a simkey pending, and the game wants a keyboard event, use the
// simkey instead of a normal event // simkey instead of a normal event

View file

@ -107,7 +107,7 @@ static reg_t kSetCursorSci0(EngineState *s, int argc, reg_t *argv) {
cursorId = -1; cursorId = -1;
} }
s->_gui->setCursorShape(cursorId); s->_gfxCursor->kernelSetShape(cursorId);
return s->r_acc; return s->r_acc;
} }
@ -119,12 +119,7 @@ static reg_t kSetCursorSci11(EngineState *s, int argc, reg_t *argv) {
case 1: case 1:
switch (argv[0].toSint16()) { switch (argv[0].toSint16()) {
case 0: case 0:
#ifdef ENABLE_SCI32 s->_gfxCursor->kernelHide();
if (s->_gui32)
s->_gui32->hideCursor();
else
#endif
s->_gui->hideCursor();
break; break;
case -1: case -1:
// TODO: Special case at least in kq6, check disassembly // TODO: Special case at least in kq6, check disassembly
@ -133,12 +128,7 @@ static reg_t kSetCursorSci11(EngineState *s, int argc, reg_t *argv) {
// TODO: Special case at least in kq6, check disassembly // TODO: Special case at least in kq6, check disassembly
break; break;
default: default:
#ifdef ENABLE_SCI32 s->_gfxCursor->kernelShow();
if (s->_gui32)
s->_gui32->showCursor();
else
#endif
s->_gui->showCursor();
break; break;
} }
case 2: case 2:
@ -176,12 +166,7 @@ static reg_t kSetCursorSci11(EngineState *s, int argc, reg_t *argv) {
hotspot = new Common::Point(argv[3].toSint16(), argv[4].toSint16()); hotspot = new Common::Point(argv[3].toSint16(), argv[4].toSint16());
// Fallthrough // Fallthrough
case 3: case 3:
#ifdef ENABLE_SCI32 s->_gfxCursor->kernelSetView(argv[0].toUint16(), argv[1].toUint16(), argv[2].toUint16(), hotspot);
if (s->_gui32)
s->_gui32->setCursorView(argv[0].toUint16(), argv[1].toUint16(), argv[2].toUint16(), hotspot);
else
#endif
s->_gui->setCursorView(argv[0].toUint16(), argv[1].toUint16(), argv[2].toUint16(), hotspot);
break; break;
default : default :
warning("kSetCursor: Unhandled case: %d arguments given", argc); warning("kSetCursor: Unhandled case: %d arguments given", argc);
@ -1139,19 +1124,9 @@ reg_t kShowMovie(EngineState *s, int argc, reg_t *argv) {
// previously visible. // previously visible.
bool reshowCursor; bool reshowCursor;
#ifdef ENABLE_SCI32 reshowCursor = s->_gfxCursor->isVisible();
if (s->_gui32) {
reshowCursor = s->_gui32->isCursorVisible();
if (reshowCursor) if (reshowCursor)
s->_gui32->hideCursor(); s->_gfxCursor->kernelHide();
} else {
#endif
reshowCursor = s->_gui->isCursorVisible();
if (reshowCursor)
s->_gui->hideCursor();
#ifdef ENABLE_SCI32
}
#endif
// The Windows and DOS versions use different video format as well // The Windows and DOS versions use different video format as well
// as a different argument set. // as a different argument set.
@ -1218,14 +1193,8 @@ reg_t kShowMovie(EngineState *s, int argc, reg_t *argv) {
s->_gfxScreen->kernelSyncWithFramebuffer(); s->_gfxScreen->kernelSyncWithFramebuffer();
} }
if (reshowCursor) { if (reshowCursor)
#ifdef ENABLE_SCI32 s->_gfxCursor->kernelShow();
if (s->_gui32)
s->_gui32->showCursor();
else
#endif
s->_gui->showCursor();
}
return s->r_acc; return s->r_acc;
} }

View file

@ -54,6 +54,7 @@ class SciEvent;
class GfxAnimate; class GfxAnimate;
class GfxCache; class GfxCache;
class GfxControls; class GfxControls;
class GfxCursor;
class GfxMenu; class GfxMenu;
class GfxPaint; class GfxPaint;
class GfxPaint16; class GfxPaint16;
@ -153,6 +154,7 @@ public:
GfxAnimate *_gfxAnimate; // Animate for 16-bit gfx GfxAnimate *_gfxAnimate; // Animate for 16-bit gfx
GfxCache *_gfxCache; GfxCache *_gfxCache;
GfxControls *_gfxControls; // Controls for 16-bit gfx GfxControls *_gfxControls; // Controls for 16-bit gfx
GfxCursor *_gfxCursor;
GfxMenu *_gfxMenu; // Menu for 16-bit gfx GfxMenu *_gfxMenu; // Menu for 16-bit gfx
GfxPalette *_gfxPalette; GfxPalette *_gfxPalette;
GfxPaint *_gfxPaint; GfxPaint *_gfxPaint;

View file

@ -591,12 +591,12 @@ void GfxAnimate::animateShowPic() {
bool previousCursorState = _cursor->isVisible(); bool previousCursorState = _cursor->isVisible();
if (previousCursorState) if (previousCursorState)
_cursor->hide(); _cursor->kernelHide();
// Adjust picRect to become relative to screen // Adjust picRect to become relative to screen
picRect.translate(picPort->left, picPort->top); picRect.translate(picPort->left, picPort->top);
_transitions->doit(picRect); _transitions->doit(picRect);
if (previousCursorState) if (previousCursorState)
_cursor->show(); _cursor->kernelShow();
// We set SCI1.1 priority band information here // We set SCI1.1 priority band information here
_ports->priorityBandsRecall(); _ports->priorityBandsRecall();

View file

@ -51,12 +51,12 @@ GfxCursor::~GfxCursor() {
purgeCache(); purgeCache();
} }
void GfxCursor::show() { void GfxCursor::kernelShow() {
CursorMan.showMouse(true); CursorMan.showMouse(true);
_isVisible = true; _isVisible = true;
} }
void GfxCursor::hide() { void GfxCursor::kernelHide() {
CursorMan.showMouse(false); CursorMan.showMouse(false);
_isVisible = false; _isVisible = false;
} }
@ -74,7 +74,7 @@ void GfxCursor::purgeCache() {
_cachedCursors.clear(); _cachedCursors.clear();
} }
void GfxCursor::setShape(GuiResourceId resourceId) { void GfxCursor::kernelSetShape(GuiResourceId resourceId) {
Resource *resource; Resource *resource;
byte *resourceData; byte *resourceData;
Common::Point hotspot = Common::Point(0, 0); Common::Point hotspot = Common::Point(0, 0);
@ -87,7 +87,7 @@ void GfxCursor::setShape(GuiResourceId resourceId) {
if (resourceId == -1) { if (resourceId == -1) {
// no resourceId given, so we actually hide the cursor // no resourceId given, so we actually hide the cursor
hide(); kernelHide();
delete[] rawBitmap; delete[] rawBitmap;
return; return;
} }
@ -128,12 +128,12 @@ void GfxCursor::setShape(GuiResourceId resourceId) {
} }
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);
show(); kernelShow();
delete[] rawBitmap; delete[] rawBitmap;
} }
void GfxCursor::setView(GuiResourceId viewNum, int loopNum, int celNum, Common::Point *hotspot) { void GfxCursor::kernelSetView(GuiResourceId viewNum, int loopNum, int celNum, Common::Point *hotspot) {
if (_cachedCursors.size() >= MAX_CACHED_CURSORS) if (_cachedCursors.size() >= MAX_CACHED_CURSORS)
purgeCache(); purgeCache();
@ -153,7 +153,7 @@ void GfxCursor::setView(GuiResourceId viewNum, int loopNum, int celNum, Common::
// Eco Quest 1 uses a 1x1 transparent cursor to hide the cursor from the user. Some scalers don't seem to support this // 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) { if (width < 2 || height < 2) {
hide(); kernelHide();
delete cursorHotspot; delete cursorHotspot;
return; return;
} }
@ -175,7 +175,7 @@ void GfxCursor::setView(GuiResourceId viewNum, int loopNum, int celNum, Common::
if (_upscaledHires) if (_upscaledHires)
delete[] cursorBitmap; delete[] cursorBitmap;
show(); kernelShow();
delete cursorHotspot; delete cursorHotspot;
} }

View file

@ -45,11 +45,11 @@ public:
GfxCursor(ResourceManager *resMan, GfxPalette *palette, GfxScreen *screen); GfxCursor(ResourceManager *resMan, GfxPalette *palette, GfxScreen *screen);
~GfxCursor(); ~GfxCursor();
void show(); void kernelShow();
void hide(); void kernelHide();
bool isVisible(); bool isVisible();
void setShape(GuiResourceId resourceId); void kernelSetShape(GuiResourceId resourceId);
void setView(GuiResourceId viewNum, int loopNum, int celNum, Common::Point *hotspot); void kernelSetView(GuiResourceId viewNum, int loopNum, int celNum, Common::Point *hotspot);
void setPosition(Common::Point pos); void setPosition(Common::Point pos);
Common::Point getPosition(); Common::Point getPosition();
void refreshPosition(); void refreshPosition();

View file

@ -391,36 +391,12 @@ void SciGui::baseSetter(reg_t object) {
} }
} }
void SciGui::hideCursor() {
_cursor->hide();
}
void SciGui::showCursor() {
_cursor->show();
}
bool SciGui::isCursorVisible() {
return _cursor->isVisible();
}
void SciGui::setCursorShape(GuiResourceId cursorId) {
_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) { void SciGui::setCursorPos(Common::Point pos) {
pos.y += _ports->getPort()->top; pos.y += _ports->getPort()->top;
pos.x += _ports->getPort()->left; pos.x += _ports->getPort()->left;
moveCursor(pos); moveCursor(pos);
} }
Common::Point SciGui::getCursorPos() {
return _cursor->getPosition();
}
void SciGui::moveCursor(Common::Point pos) { void SciGui::moveCursor(Common::Point pos) {
pos.y += _ports->_picWind->rect.top; pos.y += _ports->_picWind->rect.top;
pos.x += _ports->_picWind->rect.left; pos.x += _ports->_picWind->rect.left;

View file

@ -87,13 +87,7 @@ public:
virtual bool isItSkip(GuiResourceId viewId, int16 loopNo, int16 celNo, Common::Point position); virtual bool isItSkip(GuiResourceId viewId, int16 loopNo, int16 celNo, Common::Point position);
virtual void baseSetter(reg_t object); virtual void baseSetter(reg_t object);
void hideCursor();
void showCursor();
bool isCursorVisible();
void setCursorShape(GuiResourceId cursorId);
void setCursorView(GuiResourceId viewNum, int loopNum, int cellNum, Common::Point *hotspot);
virtual void setCursorPos(Common::Point pos); virtual void setCursorPos(Common::Point pos);
Common::Point getCursorPos();
virtual void moveCursor(Common::Point pos); virtual void moveCursor(Common::Point pos);
void setCursorZone(Common::Rect zone); void setCursorZone(Common::Rect zone);

View file

@ -176,36 +176,12 @@ void SciGui32::baseSetter(reg_t object) {
} }
} }
void SciGui32::hideCursor() {
_cursor->hide();
}
void SciGui32::showCursor() {
_cursor->show();
}
bool SciGui32::isCursorVisible() {
return _cursor->isVisible();
}
void SciGui32::setCursorShape(GuiResourceId cursorId) {
_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) { void SciGui32::setCursorPos(Common::Point pos) {
//pos.y += _gfx->GetPort()->top; //pos.y += _gfx->GetPort()->top;
//pos.x += _gfx->GetPort()->left; //pos.x += _gfx->GetPort()->left;
moveCursor(pos); moveCursor(pos);
} }
Common::Point SciGui32::getCursorPos() {
return _cursor->getPosition();
}
void SciGui32::moveCursor(Common::Point pos) { void SciGui32::moveCursor(Common::Point pos) {
// pos.y += _windowMgr->_picWind->rect.top; // pos.y += _windowMgr->_picWind->rect.top;
// pos.x += _windowMgr->_picWind->rect.left; // pos.x += _windowMgr->_picWind->rect.left;

View file

@ -55,13 +55,7 @@ public:
bool isItSkip(GuiResourceId viewId, int16 loopNo, int16 celNo, Common::Point position); bool isItSkip(GuiResourceId viewId, int16 loopNo, int16 celNo, Common::Point position);
void baseSetter(reg_t object); void baseSetter(reg_t object);
void hideCursor();
void showCursor();
bool isCursorVisible();
void setCursorShape(GuiResourceId cursorId);
void setCursorView(GuiResourceId viewNum, int loopNum, int cellNum, Common::Point *hotspot);
void setCursorPos(Common::Point pos); void setCursorPos(Common::Point pos);
Common::Point getCursorPos();
void moveCursor(Common::Point pos); void moveCursor(Common::Point pos);
void setCursorZone(Common::Rect zone); void setCursorZone(Common::Rect zone);

View file

@ -591,12 +591,12 @@ void GfxMenu::invertMenuSelection(uint16 itemId) {
void GfxMenu::interactiveShowMouse() { void GfxMenu::interactiveShowMouse() {
_mouseOldState = _cursor->isVisible(); _mouseOldState = _cursor->isVisible();
_cursor->show(); _cursor->kernelShow();
} }
void GfxMenu::interactiveRestoreMouse() { void GfxMenu::interactiveRestoreMouse() {
if (!_mouseOldState) if (!_mouseOldState)
_cursor->hide(); _cursor->kernelHide();
} }
uint16 GfxMenu::mouseFindMenuSelection(Common::Point mousePosition) { uint16 GfxMenu::mouseFindMenuSelection(Common::Point mousePosition) {

View file

@ -196,6 +196,7 @@ Common::Error SciEngine::run() {
_gamestate->_gfxPalette = palette; _gamestate->_gfxPalette = palette;
_gamestate->_gfxScreen = screen; _gamestate->_gfxScreen = screen;
_gamestate->_gfxCache = cache; _gamestate->_gfxCache = cache;
_gamestate->_gfxCursor = cursor;
if (game_init(_gamestate)) { /* Initialize */ if (game_init(_gamestate)) { /* Initialize */
warning("Game initialization failed: Aborting..."); warning("Game initialization failed: Aborting...");