BACKENDS: Replace OSystem::disableCursorPalette by setFeatureState calls

This commit is contained in:
Max Horn 2011-06-04 00:14:09 +02:00
parent 6575cd195b
commit ce32745d9c
26 changed files with 75 additions and 89 deletions

View file

@ -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) {}
};

View file

@ -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

View file

@ -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
//

View file

@ -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);

View file

@ -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();
@ -252,6 +256,8 @@ bool SdlGraphicsManager::getFeatureState(OSystem::Feature f) {
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);

View file

@ -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);

View file

@ -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;

View file

@ -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);
//@}

View file

@ -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;
}

View file

@ -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();

View file

@ -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

View file

@ -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);

View file

@ -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;
}

View file

@ -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;

View file

@ -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;
}

View file

@ -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();

View file

@ -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();

View file

@ -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) {

View file

@ -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; }

View file

@ -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();

View file

@ -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);

View file

@ -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;
}

View file

@ -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();

View file

@ -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);

View file

@ -167,14 +167,14 @@ public:
kFeatureVirtualKeyboard,
/**
* This flag determines whether or not the cursor can have its own palette.
* 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.
* The GUI also relies on this feature for mouse cursors.
* 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().
*
* To enable the cursor palette call "disableCursorPalette" with false.
* @see disableCursorPalette
* 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.
* The GUI also relies on this feature for mouse cursors.
*/
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) {}
//@}

View file

@ -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);
}
}