Replaced several dynamic_cast with getIrrlichtElement
(which avoids dynamic_casts in non-debug mode and on windows, where irrlicht as default is compiled without RTTI information). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3808 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
0b98a1eaea
commit
fedb99fb34
@ -196,7 +196,17 @@ namespace GUIEngine
|
||||
return out;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
template<typename T> const T* getIrrlichtElement() const
|
||||
{
|
||||
#if defined(WIN32) || defined(NDEBUG)
|
||||
return static_cast<T*>(m_element);
|
||||
#else
|
||||
T* out = dynamic_cast<T*>(m_element);
|
||||
return out;
|
||||
#endif
|
||||
}
|
||||
|
||||
IGUIElement* getIrrlichtElement() { return m_element; }
|
||||
|
||||
void setParent(IGUIElement* parent);
|
||||
|
@ -32,7 +32,7 @@ void ListWidget::add()
|
||||
|
||||
void ListWidget::clear()
|
||||
{
|
||||
IGUIListBox* list = dynamic_cast<IGUIListBox*>(m_element);
|
||||
IGUIListBox* list = getIrrlichtElement<IGUIListBox>();
|
||||
assert(list != NULL);
|
||||
|
||||
list->clear();
|
||||
@ -40,20 +40,20 @@ void ListWidget::clear()
|
||||
|
||||
void ListWidget::addItem(const char* item)
|
||||
{
|
||||
IGUIListBox* list = dynamic_cast<IGUIListBox*>(m_element);
|
||||
IGUIListBox* list = getIrrlichtElement<IGUIListBox>();
|
||||
assert(list != NULL);
|
||||
list->addItem( stringw(item).c_str() );
|
||||
}
|
||||
|
||||
int ListWidget::getSelection() const
|
||||
{
|
||||
IGUIListBox* list = dynamic_cast<IGUIListBox*>(m_element);
|
||||
const IGUIListBox* list = getIrrlichtElement<IGUIListBox>();
|
||||
assert(list != NULL);
|
||||
return list->getSelected();
|
||||
}
|
||||
std::string ListWidget::getSelectionName() const
|
||||
{
|
||||
IGUIListBox* list = dynamic_cast<IGUIListBox*>(m_element);
|
||||
const IGUIListBox* list = getIrrlichtElement<IGUIListBox>();
|
||||
assert(list != NULL);
|
||||
return stringc( list->getListItem( list->getSelected() ) ).c_str();
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ void TextBoxWidget::add()
|
||||
// -----------------------------------------------------------------------------
|
||||
stringw TextBoxWidget::getText() const
|
||||
{
|
||||
IGUIEditBox* textCtrl = dynamic_cast<IGUIEditBox*>(m_element);
|
||||
const IGUIEditBox* textCtrl = Widget::getIrrlichtElement<IGUIEditBox>();
|
||||
assert(textCtrl != NULL);
|
||||
|
||||
return stringw(textCtrl->getText());
|
||||
|
Loading…
Reference in New Issue
Block a user