diff options
author | Max Horn | 2011-06-04 00:14:09 +0200 |
---|---|---|
committer | Max Horn | 2011-06-04 11:55:56 +0200 |
commit | ce32745d9c26a0b97dce6a137a46ff2004c7be02 (patch) | |
tree | bbf618410aa42cd69b0a140de7fb225a9f769ada | |
parent | 6575cd195bef842697ea0b0ec80c3c1aa91f58e5 (diff) | |
download | scummvm-rg350-ce32745d9c26a0b97dce6a137a46ff2004c7be02.tar.gz scummvm-rg350-ce32745d9c26a0b97dce6a137a46ff2004c7be02.tar.bz2 scummvm-rg350-ce32745d9c26a0b97dce6a137a46ff2004c7be02.zip |
BACKENDS: Replace OSystem::disableCursorPalette by setFeatureState calls
26 files changed, 74 insertions, 88 deletions
diff --git a/backends/graphics/graphics.h b/backends/graphics/graphics.h index 4e681eb155..20924ed581 100644 --- a/backends/graphics/graphics.h +++ b/backends/graphics/graphics.h @@ -82,7 +82,6 @@ public: virtual void warpMouse(int x, int y) = 0; virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL) = 0; virtual void setCursorPalette(const byte *colors, uint start, uint num) = 0; - virtual void disableCursorPalette(bool disable) = 0; virtual void displayMessageOnOSD(const char *msg) {} }; diff --git a/backends/graphics/null/null-graphics.h b/backends/graphics/null/null-graphics.h index 673d59814e..28b24f6aca 100644 --- a/backends/graphics/null/null-graphics.h +++ b/backends/graphics/null/null-graphics.h @@ -79,7 +79,6 @@ public: void warpMouse(int x, int y) {} void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL) {} void setCursorPalette(const byte *colors, uint start, uint num) {} - void disableCursorPalette(bool disable) {} }; #endif diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index 03f959381b..c1bbdb2724 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -105,6 +105,11 @@ void OpenGLGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) { _transactionDetails.needRefresh = true; break; + case OSystem::kFeatureCursorPalette: + _cursorPaletteDisabled = !enable; + _cursorNeedsRedraw = true; + break; + default: break; } @@ -118,6 +123,9 @@ bool OpenGLGraphicsManager::getFeatureState(OSystem::Feature f) { case OSystem::kFeatureAspectRatioCorrection: return _videoMode.aspectRatioCorrection; + case OSystem::kFeatureCursorPalette: + return !_cursorPaletteDisabled; + default: return false; } @@ -642,11 +650,6 @@ void OpenGLGraphicsManager::setCursorPalette(const byte *colors, uint start, uin _cursorNeedsRedraw = true; } -void OpenGLGraphicsManager::disableCursorPalette(bool disable) { - _cursorPaletteDisabled = disable; - _cursorNeedsRedraw = true; -} - // // Misc // diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h index daba7748bc..463715aad8 100644 --- a/backends/graphics/opengl/opengl-graphics.h +++ b/backends/graphics/opengl/opengl-graphics.h @@ -107,7 +107,6 @@ public: virtual void warpMouse(int x, int y); virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL); virtual void setCursorPalette(const byte *colors, uint start, uint num); - virtual void disableCursorPalette(bool disable); virtual void displayMessageOnOSD(const char *msg); diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp index 8bc59a9200..ab09c3e44e 100644 --- a/backends/graphics/sdl/sdl-graphics.cpp +++ b/backends/graphics/sdl/sdl-graphics.cpp @@ -235,6 +235,10 @@ void SdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) { case OSystem::kFeatureAspectRatioCorrection: setAspectRatioCorrection(enable); break; + case OSystem::kFeatureCursorPalette: + _cursorPaletteDisabled = !enable; + blitCursor(); + break; case OSystem::kFeatureIconifyWindow: if (enable) SDL_WM_IconifyWindow(); @@ -245,13 +249,15 @@ void SdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) { } bool SdlGraphicsManager::getFeatureState(OSystem::Feature f) { - assert (_transactionMode == kTransactionNone); + assert(_transactionMode == kTransactionNone); switch (f) { case OSystem::kFeatureFullscreenMode: return _videoMode.fullscreen; case OSystem::kFeatureAspectRatioCorrection: return _videoMode.aspectRatioCorrection; + case OSystem::kFeatureCursorPalette: + return !_cursorPaletteDisabled; default: return false; } @@ -1458,11 +1464,6 @@ void SdlGraphicsManager::setCursorPalette(const byte *colors, uint start, uint n blitCursor(); } -void SdlGraphicsManager::disableCursorPalette(bool disable) { - _cursorPaletteDisabled = disable; - blitCursor(); -} - void SdlGraphicsManager::setShakePos(int shake_pos) { assert (_transactionMode == kTransactionNone); diff --git a/backends/graphics/sdl/sdl-graphics.h b/backends/graphics/sdl/sdl-graphics.h index 86e52a0bf6..9627ab23a3 100644 --- a/backends/graphics/sdl/sdl-graphics.h +++ b/backends/graphics/sdl/sdl-graphics.h @@ -132,7 +132,6 @@ public: virtual void warpMouse(int x, int y); virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL); virtual void setCursorPalette(const byte *colors, uint start, uint num); - virtual void disableCursorPalette(bool disable); #ifdef USE_OSD virtual void displayMessageOnOSD(const char *msg); diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp index c5f147ffe1..a1c227b33f 100644 --- a/backends/modular-backend.cpp +++ b/backends/modular-backend.cpp @@ -222,10 +222,6 @@ void ModularBackend::setCursorPalette(const byte *colors, uint start, uint num) _graphicsManager->setCursorPalette(colors, start, num); } -void ModularBackend::disableCursorPalette(bool disable) { - _graphicsManager->disableCursorPalette(disable); -} - Common::TimerManager *ModularBackend::getTimerManager() { assert(_timerManager); return _timerManager; diff --git a/backends/modular-backend.h b/backends/modular-backend.h index e46fbfdd21..74603e35a3 100644 --- a/backends/modular-backend.h +++ b/backends/modular-backend.h @@ -106,7 +106,6 @@ public: virtual void warpMouse(int x, int y); virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL); virtual void setCursorPalette(const byte *colors, uint start, uint num); - virtual void disableCursorPalette(bool disable); //@} diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index 453b64b642..5ae0239bab 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -420,6 +420,11 @@ void OSystem_Android::setFeatureState(Feature f, bool enable) { _virtkeybd_on = enable; showVirtualKeyboard(enable); break; + case kFeatureCursorPalette: + _use_mouse_palette = !enable; + if (!enable) + disableCursorPalette(); + break; default: break; } @@ -433,6 +438,8 @@ bool OSystem_Android::getFeatureState(Feature f) { return _ar_correction; case kFeatureVirtualKeyboard: return _virtkeybd_on; + case kFeatureCursorPalette: + return _use_mouse_palette; default: return false; } diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h index 752a31a4db..b70fdb7c30 100644 --- a/backends/platform/android/android.h +++ b/backends/platform/android/android.h @@ -237,6 +237,7 @@ private: void clipMouse(Common::Point &p); void scaleMouse(Common::Point &p, int x, int y, bool deductDrawRect = true); void updateEventScale(); + void disableCursorPalette(); protected: // PaletteManager API @@ -272,7 +273,6 @@ public: int cursorTargetScale, const Graphics::PixelFormat *format); virtual void setCursorPalette(const byte *colors, uint start, uint num); - virtual void disableCursorPalette(bool disable); virtual bool pollEvent(Common::Event &event); virtual uint32 getMillis(); diff --git a/backends/platform/android/gfx.cpp b/backends/platform/android/gfx.cpp index 89e918a34e..b8a9e74437 100644 --- a/backends/platform/android/gfx.cpp +++ b/backends/platform/android/gfx.cpp @@ -801,12 +801,10 @@ void OSystem_Android::setCursorPalette(const byte *colors, _use_mouse_palette = true; } -void OSystem_Android::disableCursorPalette(bool disable) { - ENTER("%d", disable); - +void OSystem_Android::disableCursorPalette() { // when disabling the cursor palette, and we're running a clut8 game, // it expects the game palette to be used for the cursor - if (disable && _game_texture->hasPalette()) { + if (_game_texture->hasPalette()) { const byte *src = _game_texture->palette_const(); byte *dst = _mouse_texture_palette->palette(); @@ -825,8 +823,6 @@ void OSystem_Android::disableCursorPalette(bool disable) { byte *p = _mouse_texture_palette->palette() + _mouse_keycolor * 2; WRITE_UINT16(p, READ_UINT16(p) & ~1); } - - _use_mouse_palette = !disable; } #endif diff --git a/backends/platform/dc/dc.h b/backends/platform/dc/dc.h index e31b817d7c..0ae4e09afb 100644 --- a/backends/platform/dc/dc.h +++ b/backends/platform/dc/dc.h @@ -145,9 +145,6 @@ public: // Replace the specified range of cursor the palette with new colors. void setCursorPalette(const byte *colors, uint start, uint num); - // Disable or enable cursor palette. - void disableCursorPalette(bool disable); - // Shaking is used in SCUMM. Set current shake position. void setShakePos(int shake_pos); diff --git a/backends/platform/dc/dcmain.cpp b/backends/platform/dc/dcmain.cpp index b06e9aead0..916dfb8229 100644 --- a/backends/platform/dc/dcmain.cpp +++ b/backends/platform/dc/dcmain.cpp @@ -181,6 +181,9 @@ void OSystem_Dreamcast::setFeatureState(Feature f, bool enable) case kFeatureVirtualKeyboard: _softkbd_on = enable; break; + case kFeatureCursorPalette: + _enable_cursor_palette = enable; + break; default: break; } @@ -193,6 +196,8 @@ bool OSystem_Dreamcast::getFeatureState(Feature f) return _aspect_stretch; case kFeatureVirtualKeyboard: return _softkbd_on; + case kFeatureCursorPalette: + return _enable_cursor_palette; default: return false; } diff --git a/backends/platform/dc/display.cpp b/backends/platform/dc/display.cpp index 56eef870c0..a11e329df3 100644 --- a/backends/platform/dc/display.cpp +++ b/backends/platform/dc/display.cpp @@ -171,11 +171,6 @@ void OSystem_Dreamcast::setCursorPalette(const byte *colors, uint start, uint nu _enable_cursor_palette = true; } -void OSystem_Dreamcast::disableCursorPalette(bool disable) -{ - _enable_cursor_palette = !disable; -} - void OSystem_Dreamcast::grabPalette(byte *colors, uint start, uint num) { const unsigned short *src = palette + start; diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp index 528e4df748..db274b723f 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.cpp +++ b/backends/platform/ds/arm9/source/osystem_ds.cpp @@ -128,11 +128,17 @@ bool OSystem_DS::hasFeature(Feature f) { void OSystem_DS::setFeatureState(Feature f, bool enable) { if (f == kFeatureVirtualKeyboard) DS::setKeyboardIcon(enable); + else if (f == kFeatureCursorPalette) { + _disableCursorPalette = !enable; + refreshCursor(); + } } bool OSystem_DS::getFeatureState(Feature f) { if (f == kFeatureVirtualKeyboard) return DS::getKeyboardIcon(); + if (f == kFeatureCursorPalette) + return !_disableCursorPalette; return false; } diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h index 4ab2e36322..ecb8011060 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.h +++ b/backends/platform/ds/arm9/source/osystem_ds.h @@ -172,8 +172,6 @@ public: virtual void setCursorPalette(const byte *colors, uint start, uint num); - virtual void disableCursorPalette(bool dis) { _disableCursorPalette = dis; refreshCursor(); } - FilesystemFactory *getFilesystemFactory(); void refreshCursor(); diff --git a/backends/platform/n64/osys_n64.h b/backends/platform/n64/osys_n64.h index 8c0b34ce32..f22b221ccc 100644 --- a/backends/platform/n64/osys_n64.h +++ b/backends/platform/n64/osys_n64.h @@ -189,7 +189,6 @@ public: virtual void warpMouse(int x, int y); virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format); virtual void setCursorPalette(const byte *colors, uint start, uint num); - virtual void disableCursorPalette(bool disable); virtual bool pollEvent(Common::Event &event); virtual uint32 getMillis(); diff --git a/backends/platform/n64/osys_n64_base.cpp b/backends/platform/n64/osys_n64_base.cpp index e70c2a6c43..ba2aa2090e 100644 --- a/backends/platform/n64/osys_n64_base.cpp +++ b/backends/platform/n64/osys_n64_base.cpp @@ -203,10 +203,19 @@ bool OSystem_N64::hasFeature(Feature f) { } void OSystem_N64::setFeatureState(Feature f, bool enable) { - return; + if (f == kFeatureCursorPalette) { + _cursorPaletteDisabled = !enable; + + // Rebuild cursor hicolor buffer + rebuildOffscreenMouseBuffer(); + + _dirtyOffscreen = true; + } } bool OSystem_N64::getFeatureState(Feature f) { + if (f == kFeatureCursorPalette) + return !_cursorPaletteDisabled return false; } @@ -437,15 +446,6 @@ void OSystem_N64::setCursorPalette(const byte *colors, uint start, uint num) { _dirtyOffscreen = true; } -void OSystem_N64::disableCursorPalette(bool disable) { - _cursorPaletteDisabled = disable; - - // Rebuild cursor hicolor buffer - rebuildOffscreenMouseBuffer(); - - _dirtyOffscreen = true; -} - void OSystem_N64::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { //Clip the coordinates if (x < 0) { diff --git a/backends/platform/psp/cursor.h b/backends/platform/psp/cursor.h index 9c24d001fb..f79968243b 100644 --- a/backends/platform/psp/cursor.h +++ b/backends/platform/psp/cursor.h @@ -53,6 +53,7 @@ public: Buffer &buffer() { return _buffer; } void setCursorPalette(const byte *colors, uint start, uint num); void enableCursorPalette(bool enable); + bool isCursorPaletteEnabled() const { return _useCursorPalette; } void setLimits(uint32 width, uint32 height); void setXY(int x, int y); int32 getX() const { return _x; } diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp index 2b37460241..eb629376d2 100644 --- a/backends/platform/psp/osys_psp.cpp +++ b/backends/platform/psp/osys_psp.cpp @@ -114,9 +114,16 @@ bool OSystem_PSP::hasFeature(Feature f) { } void OSystem_PSP::setFeatureState(Feature f, bool enable) { + if (f == kFeatureCursorPalette) { + _pendingUpdate = false; + _cursor.enableCursorPalette(enable); + } } bool OSystem_PSP::getFeatureState(Feature f) { + if (f == kFeatureCursorPalette) { + return _cursor.isCursorPaletteEnabled(); + } return false; } @@ -198,12 +205,6 @@ void OSystem_PSP::setCursorPalette(const byte *colors, uint start, uint num) { _cursor.clearKeyColor(); // Do we need this? } -void OSystem_PSP::disableCursorPalette(bool disable) { - DEBUG_ENTER_FUNC(); - _pendingUpdate = false; - _cursor.enableCursorPalette(!disable); -} - void OSystem_PSP::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { DEBUG_ENTER_FUNC(); _displayManager.waitUntilRenderFinished(); diff --git a/backends/platform/psp/osys_psp.h b/backends/platform/psp/osys_psp.h index 00eec3da90..8b7c960125 100644 --- a/backends/platform/psp/osys_psp.h +++ b/backends/platform/psp/osys_psp.h @@ -99,7 +99,6 @@ protected: void grabPalette(byte *colors, uint start, uint num); public: void setCursorPalette(const byte *colors, uint start, uint num); - void disableCursorPalette(bool disable); // Screen related void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); diff --git a/backends/platform/wii/osystem.cpp b/backends/platform/wii/osystem.cpp index 02ebc02479..d2938284a9 100644 --- a/backends/platform/wii/osystem.cpp +++ b/backends/platform/wii/osystem.cpp @@ -188,6 +188,13 @@ void OSystem_Wii::setFeatureState(Feature f, bool enable) { case kFeatureAspectRatioCorrection: _arCorrection = enable; break; + case kFeatureCursorPalette: + _cursorPaletteDisabled = !enable; + if (_texMouse.palette && !enable) { + memcpy(_texMouse.palette, _cursorPalette, 256 * 2); + _cursorPaletteDirty = true; + } + break; default: break; } @@ -199,6 +206,8 @@ bool OSystem_Wii::getFeatureState(Feature f) { return _fullscreen; case kFeatureAspectRatioCorrection: return _arCorrection; + case kFeatureCursorPalette: + return !_cursorPaletteDisabled; default: return false; } diff --git a/backends/platform/wii/osystem.h b/backends/platform/wii/osystem.h index 0db5f92fff..981b25f69c 100644 --- a/backends/platform/wii/osystem.h +++ b/backends/platform/wii/osystem.h @@ -171,7 +171,6 @@ protected: virtual void grabPalette(byte *colors, uint start, uint num); public: virtual void setCursorPalette(const byte *colors, uint start, uint num); - virtual void disableCursorPalette(bool disable); virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); virtual void updateScreen(); diff --git a/backends/platform/wii/osystem_gfx.cpp b/backends/platform/wii/osystem_gfx.cpp index b44c1270f5..859e3a1395 100644 --- a/backends/platform/wii/osystem_gfx.cpp +++ b/backends/platform/wii/osystem_gfx.cpp @@ -394,15 +394,6 @@ void OSystem_Wii::setCursorPalette(const byte *colors, uint start, uint num) { _cursorPaletteDirty = true; } -void OSystem_Wii::disableCursorPalette(bool disable) { - _cursorPaletteDisabled = disable; - - if (_texMouse.palette && disable) { - memcpy(_texMouse.palette, _cursorPalette, 256 * 2); - _cursorPaletteDirty = true; - } -} - void OSystem_Wii::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { assert(x >= 0 && x < _gameWidth); diff --git a/common/system.h b/common/system.h index e74b878fb7..b7fc870af7 100644 --- a/common/system.h +++ b/common/system.h @@ -167,14 +167,14 @@ public: kFeatureVirtualKeyboard, /** - * This flag determines whether or not the cursor can have its own palette. + * Backends supporting this feature allow specifying a custom palette + * for the cursor. The custom palette is used if the feature state + * is set to true by the client code via setFeatureState(). + * * It is currently used only by some Macintosh versions of Humongous - * Entertainment games. If the backend doesn't implement this feature then - * the engine switches to b/w versions of cursors. + * Entertainment games. If the backend doesn't implement this feature + * then the engine switches to b/w versions of cursors. * The GUI also relies on this feature for mouse cursors. - * - * To enable the cursor palette call "disableCursorPalette" with false. - * @see disableCursorPalette */ kFeatureCursorPalette, @@ -800,18 +800,6 @@ public: */ virtual void setCursorPalette(const byte *colors, uint start, uint num) {} - /** - * Disable or enable cursor palette. - * - * Backends which implement it should have kFeatureCursorPalette flag set - * - * @param disable True to disable, false to enable. - * - * @see setPalette - * @see kFeatureCursorPalette - */ - virtual void disableCursorPalette(bool disable) {} - //@} diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index 3d21e49e2d..a5498903e2 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -154,7 +154,7 @@ void CursorManager::disableCursorPalette(bool disable) { Palette *pal = _cursorPaletteStack.top(); pal->_disabled = disable; - g_system->disableCursorPalette(disable); + g_system->setFeatureState(OSystem::kFeatureCursorPalette, !disable); } void CursorManager::pushCursorPalette(const byte *colors, uint start, uint num) { @@ -167,7 +167,7 @@ void CursorManager::pushCursorPalette(const byte *colors, uint start, uint num) if (num) g_system->setCursorPalette(colors, start, num); else - g_system->disableCursorPalette(true); + g_system->setFeatureState(OSystem::kFeatureCursorPalette, false); } void CursorManager::popCursorPalette() { @@ -181,7 +181,7 @@ void CursorManager::popCursorPalette() { delete pal; if (_cursorPaletteStack.empty()) { - g_system->disableCursorPalette(true); + g_system->setFeatureState(OSystem::kFeatureCursorPalette, false); return; } @@ -190,7 +190,7 @@ void CursorManager::popCursorPalette() { if (pal->_num && !pal->_disabled) g_system->setCursorPalette(pal->_data, pal->_start, pal->_num); else - g_system->disableCursorPalette(true); + g_system->setFeatureState(OSystem::kFeatureCursorPalette, false); } void CursorManager::replaceCursorPalette(const byte *colors, uint start, uint num) { @@ -219,7 +219,7 @@ void CursorManager::replaceCursorPalette(const byte *colors, uint start, uint nu memcpy(pal->_data, colors, size); g_system->setCursorPalette(pal->_data, pal->_start, pal->_num); } else { - g_system->disableCursorPalette(true); + g_system->setFeatureState(OSystem::kFeatureCursorPalette, false); } } |