diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index e7a63a1b50..c7dc06472c 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -159,7 +159,7 @@ namespace MWBase virtual void setFocusObject(const MWWorld::Ptr& focus) = 0; virtual void setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y) = 0; - virtual void setMouseVisible(bool visible) = 0; + virtual void setCursorVisible(bool visible) = 0; virtual void getMousePosition(int &x, int &y) = 0; virtual void getMousePosition(float &x, float &y) = 0; virtual void setDragDrop(bool dragDrop) = 0; diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 7c99d004ed..781f3c86c1 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -190,6 +190,9 @@ WindowManager::WindowManager( mInputBlocker = mGui->createWidget("",0,0,w,h,MyGUI::Align::Default,"Windows",""); + //make sure the cursor in the GL context isn't visible + MyGUI::PointerManager::getInstance().setVisible(false); + // The HUD is always on mHud->setVisible(true); @@ -302,7 +305,7 @@ void WindowManager::updateVisible() mHud->setVisible(true); // Mouse is visible whenever we're not in game mode - MyGUI::PointerManager::getInstance().setVisible(isGuiMode()); + setCursorVisible(isGuiMode()); bool gameMode = !isGuiMode(); @@ -417,13 +420,13 @@ void WindowManager::updateVisible() break; case GM_LoadingWallpaper: mHud->setVisible(false); - MyGUI::PointerManager::getInstance().setVisible(false); + setCursorVisible(false); break; case GM_Loading: - MyGUI::PointerManager::getInstance().setVisible(false); + setCursorVisible(false); break; case GM_Video: - MyGUI::PointerManager::getInstance().setVisible(false); + setCursorVisible(false); mHud->setVisible(false); break; default: @@ -737,9 +740,15 @@ void WindowManager::setSpellVisibility(bool visible) mHud->setEffectVisible (visible); } -void WindowManager::setMouseVisible(bool visible) +void WindowManager::setCursorVisible(bool visible) { - MyGUI::PointerManager::getInstance().setVisible(visible); + if(visible == mCursorVisible) + return; + + mCursorVisible = visible; + + if(mCursorChangeClient != NULL) + mCursorChangeClient->cursorVisible(visible); } void WindowManager::setDragDrop(bool dragDrop) @@ -775,6 +784,7 @@ void WindowManager::onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _r { mCursorChangeClient = client; onCursorChange(PointerManager::getInstance().getDefaultPointer()); + client->cursorVisible(mCursorVisible); } void WindowManager::onCursorChange(const std::string &name) diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index bbcdbbb416..4334de83fb 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -154,7 +154,7 @@ namespace MWGui virtual void setFocusObject(const MWWorld::Ptr& focus); virtual void setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y); - virtual void setMouseVisible(bool visible); + virtual void setCursorVisible(bool visible); virtual void getMousePosition(int &x, int &y); virtual void getMousePosition(float &x, float &y); virtual void setDragDrop(bool dragDrop); @@ -275,6 +275,7 @@ namespace MWGui bool mCrosshairEnabled; bool mSubtitlesEnabled; bool mHudEnabled; + bool mCursorVisible; /// \todo get rid of this stuff. Move it to the respective UI element classes, if needed. // Various stats about player as needed by window manager diff --git a/extern/sdl4ogre/sdlinputwrapper.cpp b/extern/sdl4ogre/sdlinputwrapper.cpp index 1b996ce064..c996924e47 100644 --- a/extern/sdl4ogre/sdlinputwrapper.cpp +++ b/extern/sdl4ogre/sdlinputwrapper.cpp @@ -228,6 +228,11 @@ namespace SFO } } + void InputWrapper::cursorVisible(bool visible) + { + SDL_ShowCursor(visible ? SDL_TRUE : SDL_FALSE); + } + void InputWrapper::receiveCursorInfo(const std::string& name, Ogre::TexturePtr tex, Uint8 size_x, Uint8 size_y, Uint8 hotspot_x, Uint8 hotspot_y) { _createCursorFromResource(name, tex, size_x, size_y, hotspot_x, hotspot_y); @@ -264,7 +269,7 @@ namespace SFO Ogre::PixelBox& pixels = const_cast(new_buffer->lock(box, Ogre::HardwarePixelBuffer::HBL_READ_ONLY)); - SDL_Surface* surf = SDL_CreateRGBSurface(0,size_x,size_y,32,0,0,0,0); + SDL_Surface* surf = SDL_CreateRGBSurface(0,size_x,size_y,32,0xFF000000,0x00FF0000,0x0000FF00,0x000000FF); //copy the Ogre texture to an SDL surface @@ -275,7 +280,7 @@ namespace SFO Ogre::ColourValue clr = pixels.getColourAt(x, y, 0); //set the pixel on the SDL surface to the same value as the Ogre texture's - _putPixel(surf, x, y, SDL_MapRGBA(surf->format, clr.r, clr.g, clr.b, clr.a)); + _putPixel(surf, x, y, SDL_MapRGBA(surf->format, clr.r*255, clr.g*255, clr.b*255, clr.a*255)); } } diff --git a/extern/sdl4ogre/sdlinputwrapper.hpp b/extern/sdl4ogre/sdlinputwrapper.hpp index aac2bf5665..d37a43e339 100644 --- a/extern/sdl4ogre/sdlinputwrapper.hpp +++ b/extern/sdl4ogre/sdlinputwrapper.hpp @@ -28,6 +28,9 @@ namespace SFO /// \brief Follow up a cursorChanged() call with enough info to create an SDL cursor. virtual void receiveCursorInfo(const std::string &name, Ogre::TexturePtr tex, Uint8 size_x, Uint8 size_y, Uint8 hotspot_x, Uint8 hotspot_y) = 0; + + /// \brief Tell the client when the cursor visibility changed + virtual void cursorVisible(bool visible) = 0; }; class InputWrapper : @@ -50,6 +53,7 @@ namespace SFO virtual bool cursorChanged(const std::string &name); virtual void receiveCursorInfo(const std::string &name, Ogre::TexturePtr tex, Uint8 size_x, Uint8 size_y, Uint8 hotspot_x, Uint8 hotspot_y); + virtual void cursorVisible(bool visible); OIS::KeyCode sdl2OISKeyCode(SDL_Keycode code);