Use MyGUI's castType function

This commit is contained in:
scrawl 2016-03-05 20:00:51 +01:00
parent 763f647412
commit 60a12b3dee

View file

@ -1635,9 +1635,7 @@ namespace MWGui
layout->mMainWidget->setPosition(pos); layout->mMainWidget->setPosition(pos);
layout->mMainWidget->setSize(size); layout->mMainWidget->setSize(size);
MyGUI::Window* window = dynamic_cast<MyGUI::Window*>(layout->mMainWidget); MyGUI::Window* window = layout->mMainWidget->castType<MyGUI::Window>();
if (!window)
throw std::runtime_error("Attempting to track size of a non-resizable window");
window->eventWindowChangeCoord += MyGUI::newDelegate(this, &WindowManager::onWindowChangeCoord); window->eventWindowChangeCoord += MyGUI::newDelegate(this, &WindowManager::onWindowChangeCoord);
mTrackedWindows[window] = name; mTrackedWindows[window] = name;
} }
@ -2010,7 +2008,7 @@ namespace MWGui
while (enumerator.next()) while (enumerator.next())
{ {
MyGUI::IResource* resource = enumerator.current().second; MyGUI::IResource* resource = enumerator.current().second;
ResourceImageSetPointerFix* imgSetPointer = dynamic_cast<ResourceImageSetPointerFix*>(resource); ResourceImageSetPointerFix* imgSetPointer = resource->castType<ResourceImageSetPointerFix>(false);
if (!imgSetPointer) if (!imgSetPointer)
continue; continue;
std::string tex_name = imgSetPointer->getImageSet()->getIndexInfo(0,0).texture; std::string tex_name = imgSetPointer->getImageSet()->getIndexInfo(0,0).texture;