mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
Fully working hardware cursors (if you compile SDL2 with XCursor support)
This commit is contained in:
parent
3fb920a66f
commit
eeacb04fe2
5 changed files with 30 additions and 10 deletions
|
@ -159,7 +159,7 @@ namespace MWBase
|
||||||
virtual void setFocusObject(const MWWorld::Ptr& focus) = 0;
|
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 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(int &x, int &y) = 0;
|
||||||
virtual void getMousePosition(float &x, float &y) = 0;
|
virtual void getMousePosition(float &x, float &y) = 0;
|
||||||
virtual void setDragDrop(bool dragDrop) = 0;
|
virtual void setDragDrop(bool dragDrop) = 0;
|
||||||
|
|
|
@ -190,6 +190,9 @@ WindowManager::WindowManager(
|
||||||
|
|
||||||
mInputBlocker = mGui->createWidget<MyGUI::Widget>("",0,0,w,h,MyGUI::Align::Default,"Windows","");
|
mInputBlocker = mGui->createWidget<MyGUI::Widget>("",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
|
// The HUD is always on
|
||||||
mHud->setVisible(true);
|
mHud->setVisible(true);
|
||||||
|
|
||||||
|
@ -302,7 +305,7 @@ void WindowManager::updateVisible()
|
||||||
mHud->setVisible(true);
|
mHud->setVisible(true);
|
||||||
|
|
||||||
// Mouse is visible whenever we're not in game mode
|
// Mouse is visible whenever we're not in game mode
|
||||||
MyGUI::PointerManager::getInstance().setVisible(isGuiMode());
|
setCursorVisible(isGuiMode());
|
||||||
|
|
||||||
bool gameMode = !isGuiMode();
|
bool gameMode = !isGuiMode();
|
||||||
|
|
||||||
|
@ -417,13 +420,13 @@ void WindowManager::updateVisible()
|
||||||
break;
|
break;
|
||||||
case GM_LoadingWallpaper:
|
case GM_LoadingWallpaper:
|
||||||
mHud->setVisible(false);
|
mHud->setVisible(false);
|
||||||
MyGUI::PointerManager::getInstance().setVisible(false);
|
setCursorVisible(false);
|
||||||
break;
|
break;
|
||||||
case GM_Loading:
|
case GM_Loading:
|
||||||
MyGUI::PointerManager::getInstance().setVisible(false);
|
setCursorVisible(false);
|
||||||
break;
|
break;
|
||||||
case GM_Video:
|
case GM_Video:
|
||||||
MyGUI::PointerManager::getInstance().setVisible(false);
|
setCursorVisible(false);
|
||||||
mHud->setVisible(false);
|
mHud->setVisible(false);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -737,9 +740,15 @@ void WindowManager::setSpellVisibility(bool visible)
|
||||||
mHud->setEffectVisible (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)
|
void WindowManager::setDragDrop(bool dragDrop)
|
||||||
|
@ -775,6 +784,7 @@ void WindowManager::onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _r
|
||||||
{
|
{
|
||||||
mCursorChangeClient = client;
|
mCursorChangeClient = client;
|
||||||
onCursorChange(PointerManager::getInstance().getDefaultPointer());
|
onCursorChange(PointerManager::getInstance().getDefaultPointer());
|
||||||
|
client->cursorVisible(mCursorVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onCursorChange(const std::string &name)
|
void WindowManager::onCursorChange(const std::string &name)
|
||||||
|
|
|
@ -154,7 +154,7 @@ namespace MWGui
|
||||||
virtual void setFocusObject(const MWWorld::Ptr& focus);
|
virtual void setFocusObject(const MWWorld::Ptr& focus);
|
||||||
virtual void setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y);
|
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(int &x, int &y);
|
||||||
virtual void getMousePosition(float &x, float &y);
|
virtual void getMousePosition(float &x, float &y);
|
||||||
virtual void setDragDrop(bool dragDrop);
|
virtual void setDragDrop(bool dragDrop);
|
||||||
|
@ -275,6 +275,7 @@ namespace MWGui
|
||||||
bool mCrosshairEnabled;
|
bool mCrosshairEnabled;
|
||||||
bool mSubtitlesEnabled;
|
bool mSubtitlesEnabled;
|
||||||
bool mHudEnabled;
|
bool mHudEnabled;
|
||||||
|
bool mCursorVisible;
|
||||||
|
|
||||||
/// \todo get rid of this stuff. Move it to the respective UI element classes, if needed.
|
/// \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
|
// Various stats about player as needed by window manager
|
||||||
|
|
9
extern/sdl4ogre/sdlinputwrapper.cpp
vendored
9
extern/sdl4ogre/sdlinputwrapper.cpp
vendored
|
@ -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)
|
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);
|
_createCursorFromResource(name, tex, size_x, size_y, hotspot_x, hotspot_y);
|
||||||
|
@ -264,7 +269,7 @@ namespace SFO
|
||||||
Ogre::PixelBox& pixels = const_cast<Ogre::PixelBox&>(new_buffer->lock(box, Ogre::HardwarePixelBuffer::HBL_READ_ONLY));
|
Ogre::PixelBox& pixels = const_cast<Ogre::PixelBox&>(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
|
//copy the Ogre texture to an SDL surface
|
||||||
|
@ -275,7 +280,7 @@ namespace SFO
|
||||||
Ogre::ColourValue clr = pixels.getColourAt(x, y, 0);
|
Ogre::ColourValue clr = pixels.getColourAt(x, y, 0);
|
||||||
|
|
||||||
//set the pixel on the SDL surface to the same value as the Ogre texture's
|
//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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
extern/sdl4ogre/sdlinputwrapper.hpp
vendored
4
extern/sdl4ogre/sdlinputwrapper.hpp
vendored
|
@ -28,6 +28,9 @@ namespace SFO
|
||||||
|
|
||||||
/// \brief Follow up a cursorChanged() call with enough info to create an SDL cursor.
|
/// \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;
|
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 :
|
class InputWrapper :
|
||||||
|
@ -50,6 +53,7 @@ namespace SFO
|
||||||
|
|
||||||
virtual bool cursorChanged(const std::string &name);
|
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 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);
|
OIS::KeyCode sdl2OISKeyCode(SDL_Keycode code);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue