forked from mirror/openmw-tes3mp
Create hardware cursors in advance (Fixes #2660)
This commit is contained in:
parent
5a0af772dd
commit
de6dc21552
4 changed files with 36 additions and 40 deletions
|
@ -235,8 +235,9 @@ namespace MWGui
|
|||
|
||||
MyGUI::InputManager::getInstance().eventChangeKeyFocus += MyGUI::newDelegate(this, &WindowManager::onKeyFocusChanged);
|
||||
|
||||
// Create all cursors in advance
|
||||
createCursors();
|
||||
onCursorChange(MyGUI::PointerManager::getInstance().getDefaultPointer());
|
||||
|
||||
mCursorManager->setEnabled(true);
|
||||
|
||||
// hide mygui's pointer
|
||||
|
@ -1181,31 +1182,7 @@ namespace MWGui
|
|||
|
||||
void WindowManager::onCursorChange(const std::string &name)
|
||||
{
|
||||
if(!mCursorManager->cursorChanged(name))
|
||||
return; //the cursor manager doesn't want any more info about this cursor
|
||||
//See if we can get the information we need out of the cursor resource
|
||||
ResourceImageSetPointerFix* imgSetPtr = dynamic_cast<ResourceImageSetPointerFix*>(MyGUI::PointerManager::getInstance().getByName(name));
|
||||
if(imgSetPtr != NULL)
|
||||
{
|
||||
MyGUI::ResourceImageSet* imgSet = imgSetPtr->getImageSet();
|
||||
|
||||
std::string tex_name = imgSet->getIndexInfo(0,0).texture;
|
||||
|
||||
osg::ref_ptr<osg::Texture2D> tex = mResourceSystem->getTextureManager()->getTexture2D(tex_name, osg::Texture::CLAMP, osg::Texture::CLAMP);
|
||||
tex->setUnRefImageDataAfterApply(false); // FIXME?
|
||||
|
||||
//everything looks good, send it to the cursor manager
|
||||
if(tex.valid())
|
||||
{
|
||||
Uint8 size_x = imgSetPtr->getSize().width;
|
||||
Uint8 size_y = imgSetPtr->getSize().height;
|
||||
Uint8 hotspot_x = imgSetPtr->getHotSpot().left;
|
||||
Uint8 hotspot_y = imgSetPtr->getHotSpot().top;
|
||||
int rotation = imgSetPtr->getRotation();
|
||||
|
||||
mCursorManager->receiveCursorInfo(name, rotation, tex->getImage(), size_x, size_y, hotspot_x, hotspot_y);
|
||||
}
|
||||
}
|
||||
mCursorManager->cursorChanged(name);
|
||||
}
|
||||
|
||||
void WindowManager::popGuiMode()
|
||||
|
@ -1963,6 +1940,33 @@ namespace MWGui
|
|||
return Misc::ResourceHelpers::correctTexturePath(path, mResourceSystem->getVFS());
|
||||
}
|
||||
|
||||
void WindowManager::createCursors()
|
||||
{
|
||||
MyGUI::ResourceManager::EnumeratorPtr enumerator = MyGUI::ResourceManager::getInstance().getEnumerator();
|
||||
while (enumerator.next())
|
||||
{
|
||||
MyGUI::IResource* resource = enumerator.current().second;
|
||||
ResourceImageSetPointerFix* imgSetPointer = dynamic_cast<ResourceImageSetPointerFix*>(resource);
|
||||
if (!imgSetPointer)
|
||||
continue;
|
||||
std::string tex_name = imgSetPointer->getImageSet()->getIndexInfo(0,0).texture;
|
||||
|
||||
osg::ref_ptr<osg::Texture2D> tex = mResourceSystem->getTextureManager()->getTexture2D(tex_name, osg::Texture::CLAMP, osg::Texture::CLAMP);
|
||||
|
||||
if(tex.valid())
|
||||
{
|
||||
//everything looks good, send it to the cursor manager
|
||||
Uint8 size_x = imgSetPointer->getSize().width;
|
||||
Uint8 size_y = imgSetPointer->getSize().height;
|
||||
Uint8 hotspot_x = imgSetPointer->getHotSpot().left;
|
||||
Uint8 hotspot_y = imgSetPointer->getHotSpot().top;
|
||||
int rotation = imgSetPointer->getRotation();
|
||||
|
||||
mCursorManager->createCursor(imgSetPointer->getResourceName(), rotation, tex->getImage(), size_x, size_y, hotspot_x, hotspot_y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WindowManager::createTextures()
|
||||
{
|
||||
{
|
||||
|
|
|
@ -511,6 +511,7 @@ namespace MWGui
|
|||
void onClipboardRequested(const std::string& _type, std::string& _data);
|
||||
|
||||
void createTextures();
|
||||
void createCursors();
|
||||
void setMenuTransparency(float value);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -175,23 +175,16 @@ namespace SDLUtil
|
|||
}
|
||||
}
|
||||
|
||||
bool SDLCursorManager::cursorChanged(const std::string& name)
|
||||
void SDLCursorManager::cursorChanged(const std::string& name)
|
||||
{
|
||||
mCurrentCursor = name;
|
||||
|
||||
CursorMap::const_iterator curs_iter = mCursorMap.find(name);
|
||||
|
||||
//we have this cursor
|
||||
if(curs_iter != mCursorMap.end())
|
||||
{
|
||||
//we have this cursor
|
||||
_setGUICursor(name);
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//they should get back to us with more info
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -200,7 +193,7 @@ namespace SDLUtil
|
|||
SDL_SetCursor(mCursorMap.find(name)->second);
|
||||
}
|
||||
|
||||
void SDLCursorManager::receiveCursorInfo(const std::string& name, int rotDegrees, osg::Image* image, Uint8 size_x, Uint8 size_y, Uint8 hotspot_x, Uint8 hotspot_y)
|
||||
void SDLCursorManager::createCursor(const std::string& name, int rotDegrees, osg::Image* image, Uint8 size_x, Uint8 size_y, Uint8 hotspot_x, Uint8 hotspot_y)
|
||||
{
|
||||
_createCursorFromResource(name, rotDegrees, image, size_x, size_y, hotspot_x, hotspot_y);
|
||||
}
|
||||
|
|
|
@ -27,11 +27,9 @@ namespace SDLUtil
|
|||
|
||||
/// \brief Tell the manager that the cursor has changed, giving the
|
||||
/// name of the cursor we changed to ("arrow", "ibeam", etc)
|
||||
/// \return Whether the manager is interested in more information about the cursor
|
||||
virtual bool cursorChanged(const std::string &name);
|
||||
virtual void cursorChanged(const std::string &name);
|
||||
|
||||
/// \brief Follow up a cursorChanged() call with enough info to create an cursor.
|
||||
virtual void receiveCursorInfo(const std::string &name, int rotDegrees, osg::Image* image, Uint8 size_x, Uint8 size_y, Uint8 hotspot_x, Uint8 hotspot_y);
|
||||
virtual void createCursor(const std::string &name, int rotDegrees, osg::Image* image, Uint8 size_x, Uint8 size_y, Uint8 hotspot_x, Uint8 hotspot_y);
|
||||
|
||||
private:
|
||||
void _createCursorFromResource(const std::string &name, int rotDegrees, osg::Image* image, Uint8 size_x, Uint8 size_y, Uint8 hotspot_x, Uint8 hotspot_y);
|
||||
|
|
Loading…
Reference in a new issue