diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CGUIModalScreen.cpp Irrlicht_starsonata/source/Irrlicht/CGUIModalScreen.cpp --- irrlicht-svn-ss/trunk/source/Irrlicht/CGUIModalScreen.cpp 2007-07-26 02:11:08.000000000 +0200 +++ Irrlicht_starsonata/source/Irrlicht/CGUIModalScreen.cpp 2008-05-28 20:59:00.000000000 +0200 @@ -37,17 +37,35 @@ CGUIModalScreen::~CGUIModalScreen() //! called if an event happened. bool CGUIModalScreen::OnEvent(SEvent event) { + if (!IsEnabled) + return IGUIElement::OnEvent(event); + + if ( !isVisible() ) + return IGUIElement::OnEvent(event); + switch(event.EventType) { case EET_GUI_EVENT: switch(event.GUIEvent.EventType) { case EGET_ELEMENT_FOCUSED: - if (event.GUIEvent.Caller != this && !isMyChild(event.GUIEvent.Caller)) + if ( event.GUIEvent.Caller != this + && !isMyChild(event.GUIEvent.Caller) + && (!event.GUIEvent.Element + || ( event.GUIEvent.Element->getType() != EGUIET_MODAL_SCREEN + && event.GUIEvent.Element->getType() != EGUIET_MESSAGE_BOX ) + ) + ) Environment->setFocus(this); return false; case EGET_ELEMENT_FOCUS_LOST: - if (!(isMyChild(event.GUIEvent.Element) || event.GUIEvent.Element == this)) + if ( (!isMyChild(event.GUIEvent.Element) + && (!event.GUIEvent.Element + || ( event.GUIEvent.Element->getType() != EGUIET_MODAL_SCREEN + && event.GUIEvent.Element->getType() != EGUIET_MESSAGE_BOX ) + ) + ) + || event.GUIEvent.Element == this) { MouseDownTime = os::Timer::getTime(); return true; @@ -74,6 +92,9 @@ bool CGUIModalScreen::OnEvent(SEvent eve //! draws the element and its children void CGUIModalScreen::draw() { + if ( !isVisible() ) + return; + IGUISkin *skin = Environment->getSkin(); if (!skin) @@ -137,15 +158,15 @@ void CGUIModalScreen::updateAbsolutePosi } //! Writes attributes of the element. -void CGUIModalScreen::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) +void CGUIModalScreen::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) { - // these don't get serialized, their status is added to their children. + IGUIElement::serializeAttributes(out,options); } //! Reads attributes of the element -void CGUIModalScreen::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) +void CGUIModalScreen::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) { - // these don't get deserialized. children create them if required + IGUIElement::deserializeAttributes(in, options); } diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CGUIModalScreen.h Irrlicht_starsonata/source/Irrlicht/CGUIModalScreen.h --- irrlicht-svn-ss/trunk/source/Irrlicht/CGUIModalScreen.h 2007-07-26 02:11:08.000000000 +0200 +++ Irrlicht_starsonata/source/Irrlicht/CGUIModalScreen.h 2008-03-23 05:15:34.000000000 +0100 @@ -38,6 +38,33 @@ namespace gui //! Updates the absolute position. virtual void updateAbsolutePosition(); + + //! Starsonata, Micha: added this to get around some trouble with modalscreens + //! Unlike other elements CGUIModalScreen is visible unless all it's children are invisible + //! or any if parents is invisible. + virtual bool isVisible() + { + IGUIElement * parentElement = getParent(); + while ( parentElement ) + { + if ( !parentElement->isVisible() ) + return false; + parentElement = parentElement->getParent(); + } + + bool visible = false; + core::list::Iterator it = Children.begin(); + for (; it != Children.end(); ++it) + { + if ( (*it)->isVisible() ) + { + visible = true; + break; + } + } + return visible; + } + //! Writes attributes of the element. virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options);