Exemple #1
0
        void GearConstraint::ProtoDeSerialize(const XML::Node& OneNode)
        {
            if ( Mezzanine::String(OneNode.Name())==this->GearConstraint::SerializableName() )
            {
                if(OneNode.GetAttribute("Version").AsInt() == 1)
                {
                    this->Constraint::ProtoDeSerialize(OneNode.GetChild("Constraint"));

                    this->SetRotationRatio(OneNode.GetAttribute("Ratio").AsReal());

                    XML::Node ActorANode = OneNode.GetChild("ActorA");
                    if(!ActorANode)
                        { DeSerializeError("Could not find ActorA axis",SerializableName()); }

                    XML::Node ActorBNode = OneNode.GetChild("ActorB");
                    if(!ActorBNode)
                        { DeSerializeError("Could not find ActorB axis",SerializableName()); }

                    Vector3 temp;
                    temp.ProtoDeSerialize(ActorANode.GetFirstChild());
                    this->SetAxisA(temp);
                    temp.ProtoDeSerialize(ActorBNode.GetFirstChild());
                    this->SetAxisB(temp);
                }else{
                    DeSerializeError("find usable serialization version",SerializableName());
                }
            }else{
                DeSerializeError(String("find correct class to deserialize, found a ")+OneNode.Name(),SerializableName());
            }
        }
Exemple #2
0
 void Transform::ProtoDeSerialize(const XML::Node& OneNode)
 {
     if ( Mezzanine::String(OneNode.Name())==Mezzanine::String(SerializableName()) )
     {
         if(OneNode.GetAttribute("Version").AsInt() == 1)
         {
             this->Location.ProtoDeSerialize(OneNode.GetChild("Vector3"));
             this->Rotation.ProtoDeSerialize(OneNode.GetChild("Quaternion"));
         }else{
             MEZZ_EXCEPTION(Exception::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + SerializableName() + ": Not Version 1.");
         }
     }else{
         MEZZ_EXCEPTION(Exception::II_IDENTITY_INVALID_EXCEPTION,"Attempting to deserialize a " + SerializableName() + ", found a " + String(OneNode.Name()));
     }
 }
Exemple #3
0
    void WorldObject::ProtoDeSerialize(const XML::Node& OneNode)
    {
        if ( Mezzanine::String(OneNode.Name())==this->WorldObject::SerializableName() )
        {
            if(OneNode.GetAttribute("Version").AsInt() == 1)
            {
                Vector3 TempVec;
                XML::Node LocationNode = OneNode.GetChild("Location").GetFirstChild();
                if(!LocationNode)
                    { DeSerializeError("locate Location node",SerializableName()); }
                TempVec.ProtoDeSerialize(LocationNode);
                this->SetLocation(TempVec);

                XML::Node GraphicsSettingsNode = OneNode.GetChild(this->GraphicsSettingsSerializableName());
                if(!GraphicsSettingsNode)
                    { DeSerializeError("locate Graphics Settings node",SerializableName()); }
                this->GetGraphicsSettings()->ProtoDeSerialize(GraphicsSettingsNode);

                XML::Node PhysicsSettingsNode = OneNode.GetChild(this->PhysicsSettingsSerializableName());
                if(!PhysicsSettingsNode)
                    { DeSerializeError(String("locate Physics Settings node, ")+this->PhysicsSettingsSerializableName()+", ",SerializableName()); }
                this->GetPhysicsSettings()->ProtoDeSerialize(PhysicsSettingsNode);

                XML::Node ScalingNode = OneNode.GetChild("Scaling").GetFirstChild();
                if(!ScalingNode)
                    { DeSerializeError("locate Scaling node",SerializableName()); }
                TempVec.ProtoDeSerialize(ScalingNode);
                this->SetScaling(TempVec);

                if( this->IsInWorld() != OneNode.GetAttribute("IsInWorld").AsBool() )
                {
                    if(this->IsInWorld())
                        { this->RemoveFromWorld(); }
                    else
                        { this->AddToWorld(); }
                }

                /*if( 0!=OneNode.GetAttribute("SoundSet") && ""!=OneNode.GetAttribute("SoundSet").AsString())
                    { this->ObjectSounds = Audio::AudioManager::GetSingletonPtr()->GetSoundSet(OneNode.GetAttribute("SoundSet").AsString()); }
                else
                    { this->ObjectSounds = 0; }//*/
            }else{
                DeSerializeError("find usable serialization version",SerializableName());
            }
        }else{
            DeSerializeError(String("find correct class to deserialize, found a ")+OneNode.Name(),SerializableName());
        }
    }
Exemple #4
0
        void Widget::ProtoDeSerializeEvents(const XML::Node& SelfRoot)
        {
            this->RemoveAllEvents();

            XML::Attribute CurrAttrib;
            XML::Node EventsNode = SelfRoot.GetChild( "Events" );

            if( !EventsNode.Empty() ) {
                if( EventsNode.GetAttribute("Version").AsInt() == 1 ) {
                    for( XML::NodeIterator EvNodeIt = EventsNode.begin() ; EvNodeIt != EventsNode.end() ; ++EvNodeIt )
                    {
                        if( (*EvNodeIt).GetAttribute("Version").AsInt() == 1 ) {
                            String EvName;

                            CurrAttrib = (*EvNodeIt).GetAttribute("Name");
                            if( !CurrAttrib.Empty() )
                                EvName = CurrAttrib.AsString();

                            if( !EvName.empty() ) {
                                this->AddEvent(EvName);
                            }
                        }else{
                            MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + String("Events") + ": Not Version 1.");
                        }
                    }
                }else{
                    MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + String("Events") + ": Not Version 1.");
                }
            }
        }
Exemple #5
0
    void GravityWell::ProtoDeSerializeProperties(const XML::Node& SelfRoot)
    {
        this->AreaEffect::ProtoDeSerializeProperties(SelfRoot);

        XML::Attribute CurrAttrib;
        XML::Node PropertiesNode = SelfRoot.GetChild( GravityWell::GetSerializableName() + "Properties" );

        if( !PropertiesNode.Empty() ) {
            if(PropertiesNode.GetAttribute("Version").AsInt() == 1) {
                CurrAttrib = PropertiesNode.GetAttribute("AttenAmount");
                if( !CurrAttrib.Empty() )
                    this->SetAttenuationAmount( CurrAttrib.AsReal() );

                CurrAttrib = PropertiesNode.GetAttribute("AttenStyle");
                if( !CurrAttrib.Empty() )
                    this->SetAttenuationStyle( static_cast<Mezzanine::AttenuationStyle>( CurrAttrib.AsWhole() ) );

                CurrAttrib = PropertiesNode.GetAttribute("Strength");
                if( !CurrAttrib.Empty() )
                    this->SetFieldStrength( CurrAttrib.AsReal() );

                CurrAttrib = PropertiesNode.GetAttribute("AllowWorldGravity");
                if( !CurrAttrib.Empty() )
                    this->SetAllowWorldGravity( StringTools::ConvertToBool( CurrAttrib.AsString() ) );
            }else{
                MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + (GravityWell::GetSerializableName() + "Properties" ) + ": Not Version 1.");
            }
        }else{
            MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_NOT_FOUND_EXCEPTION,GravityWell::GetSerializableName() + "Properties" + " was not found in the provided XML node, which was expected.");
        }
    }
Exemple #6
0
        void ParticleAffector::ProtoDeSerializeCustomParameters(const XML::Node& SelfRoot)
        {
            XML::Attribute CurrAttrib;
            XML::Node CustomParametersNode = SelfRoot.GetChild( ParticleAffector::GetSerializableName() + "CustomParameters" );

            if( !CustomParametersNode.Empty() ) {
                if(CustomParametersNode.GetAttribute("Version").AsInt() == 1) {
                    String ParamName, ParamValue;

                    for( XML::NodeIterator ParamIt = CustomParametersNode.begin() ; ParamIt != CustomParametersNode.end() ; ++ParamIt )
                    {
                        if( !(*ParamIt).Empty() ) {
                            if((*ParamIt).GetAttribute("Version").AsInt() == 1) {
                                CurrAttrib = (*ParamIt).GetAttribute("ParamName");
                                if( !CurrAttrib.Empty() )
                                    ParamName = CurrAttrib.AsString();

                                CurrAttrib = (*ParamIt).GetAttribute("ParamValue");
                                if( !CurrAttrib.Empty() )
                                    ParamValue = CurrAttrib.AsString();

                                if( !ParamName.empty() && !ParamValue.empty() ) {
                                    this->SetCustomParam(ParamName,ParamValue);
                                }
                            }
                        }
                    }
                }else{
                    MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + (ParticleAffector::GetSerializableName() + "CustomParameters" ) + ": Not Version 1.");
                }
            }else{
                MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_NOT_FOUND_EXCEPTION,ParticleAffector::GetSerializableName() + "CustomParameters" + " was not found in the provided XML node, which was expected.");
            }
        }
Exemple #7
0
CapsuleCollisionShape::CapsuleCollisionShape(XML::Node OneNode)
{
    if(OneNode.GetAttribute("Version").AsInt() == 1)
    {
        XML::Attribute OneName = OneNode.GetChild("PrimitiveCollisionShape").GetChild("CollisionShape").GetAttribute("Name");               // get name
        if(!OneName) {
            MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_EXCEPTION,"Could not find Name Attribute on CollsionShape Node during preparation for deserialization");
        }
        String Name_(OneName.AsString());

        XML::Attribute Axis = OneNode.GetAttribute("Axis");
        if (!Axis) {
            DeSerializeError("find Axis Attribute",CapsuleCollisionShape::GetSerializableName());
        }
        /*
        XML::Attribute Radius = OneNode.GetAttribute("Radius");
        if (!Radius) { DeSerializeError("find Radius Attribute",CapsuleCollisionShape::GetSerializableName()); }
        XML::Attribute Height = OneNode.GetAttribute("Height");
        if (!Height) { DeSerializeError("find Height Attribute",CapsuleCollisionShape::GetSerializableName()); }
        //SetPointers(new CapsuleCollisionShape(Name_,Radius.AsReal(),Height.AsReal(), (StandardAxis)Axis.AsInteger());  // make and deserialize the shape
        this->Construct(Name_,Radius.AsReal(),Height.AsReal(),(StandardAxis)Axis.AsInteger());
        */
        this->Construct(Name_,0,0,(StandardAxis)Axis.AsInteger());

        this->ProtoDeSerialize(OneNode);

    } else {
        DeSerializeError("find usable serialization version",CapsuleCollisionShape::GetSerializableName());
    }
}
Exemple #8
0
void cheats_code_raw_add(Xml::Node node) {
	// Add a Raw code
	Cheats cheats(emulator);
	Cheats::Code code;
	
	code.useCompare = false;
	
	code.address = node.GetChild(L"address").GetUnsignedValue();
	if (node.GetChild(L"value")) {
		code.value = node.GetChild(L"value").GetUnsignedValue();
	}
	if (node.GetChild(L"compare")) {
		code.compare = node.GetChild(L"compare").GetUnsignedValue();
		code.useCompare = true;
	}
	cheats.SetCode(code);
}
Exemple #9
0
 void AreaEffect::ProtoDeSerialize(const XML::Node& OneNode)
 {
     if ( Mezzanine::String(OneNode.Name())==this->AreaEffect::SerializableName() )
     {
         if(OneNode.GetAttribute("Version").AsInt() == 1)
         {
             NonStaticWorldObject::ProtoDeSerialize(OneNode.GetChild(this->NonStaticWorldObject::SerializableName()));
         }
     }
 }
Exemple #10
0
void LevelZone::ProtoDeSerializeProperties(const XML::Node& SelfRoot)
{
    this->AreaEffect::ProtoDeSerializeProperties(SelfRoot);
    //XML::Attribute CurrAttrib;
    XML::Node PropertiesNode = SelfRoot.GetChild( LevelZone::GetSerializableName() + "Properties" );

    if( !PropertiesNode.Empty() ) {
        if(PropertiesNode.GetAttribute("Version").AsInt() == 1) {
            XML::Node ZoneSizeNode = PropertiesNode.GetChild("ZoneSize").GetFirstChild();
            if( !ZoneSizeNode.Empty() ) {
                this->ZoneSize.ProtoDeSerialize( ZoneSizeNode );
            }
        }else{
            MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + (LevelZone::GetSerializableName() + "Properties" ) + ": Not Version 1.");
        }
    }else{
        MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_NOT_FOUND_EXCEPTION,LevelZone::GetSerializableName() + "Properties" + " was not found in the provided XML node, which was expected.");
    }
}
Exemple #11
0
    void NonStaticWorldObject::ProtoDeSerialize(const XML::Node& OneNode)
    {
        if ( Mezzanine::String(OneNode.Name())==this->NonStaticWorldObject::SerializableName() )
        {
            if(OneNode.GetAttribute("Version").AsInt() == 1)
            {
                this->WorldObject::ProtoDeSerialize(OneNode.GetChild(this->WorldObject::SerializableName()));

                Quaternion TempQuat;
                XML::Node OrientationNode = OneNode.GetChild("Orientation").GetFirstChild();
                if(!OrientationNode)
                    { DeSerializeError("locate Orientation node",SerializableName()); }
                TempQuat.ProtoDeSerialize(OrientationNode);
                this->SetOrientation(TempQuat);

                /*if(0==OneNode.GetAttribute("WorldNode"))         // Are we dealing with a WorldNode Node or WorldNode Attribute.
                {
                    //Since the Attribute didn't exist we must have a node
                    XML::Node ObjectWorldNode = OneNode.GetChild("WorldNode");                               // Assumption made base on old style serialization
                    if(!ObjectWorldNode)
                        { DeSerializeError("locate ObjectWorldNode node",SerializableName()); }
                    if (0!=this->ObjectWorldNode && !Entresol::GetSingletonPtr()->GetSceneManager()->GetNode(this->ObjectWorldNode->GetName()) )    //If the current worldnode is not null and it is not in the manager, then delete it
                        { delete this->ObjectWorldNode; }
                    this->ObjectWorldNode = new WorldNode(ObjectWorldNode.GetAttribute("Name").AsString(),0);
                    ObjectWorldNode >> *(this->ObjectWorldNode);                                              // Deserialized with old style serialization
                }else{
                    WorldNode *TempWorldNode = Entresol::GetSingletonPtr()->GetSceneManager()->GetNode(OneNode.GetAttribute("WorldNode").AsString());
                    if( TempWorldNode == this->ObjectWorldNode )
                        { return; }                                                                         //This already has the correct node we are done
                    if (0!=this->ObjectWorldNode && !Entresol::GetSingletonPtr()->GetSceneManager()->GetNode(this->ObjectWorldNode->GetName()) )    //If the current worldnode is not null and it is not in the manager, then delete it
                        { delete this->ObjectWorldNode; }
                    this->ObjectWorldNode = TempWorldNode;                                                   // The old node has bee cleaned up and the new node is in place
                    if (0==this->ObjectWorldNode)
                        { DeSerializeError("locate ObjectWorldNode attribute",SerializableName()); }
                }//*/
            }else{
                DeSerializeError("find usable serialization version",SerializableName());
            }
        }else{
            DeSerializeError(String("find correct class to deserialize, found a ")+OneNode.Name(),SerializableName());
        }
    }
Exemple #12
0
        void SimpleRenderer::ProtoDeSerializeProperties(const XML::Node& SelfRoot)
        {
            XML::Attribute CurrAttrib;
            XML::Node PropertiesNode = SelfRoot.GetChild( SimpleRenderer::GetSerializableName() + "Properties" );

            if( !PropertiesNode.Empty() ) {
                if(PropertiesNode.GetAttribute("Version").AsInt() == 1) {
                    CurrAttrib = PropertiesNode.GetAttribute("PriAtlas");
                    if( !CurrAttrib.Empty() )
                        this->PriAtlas = CurrAttrib.AsString();
                }else{
                    MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + (SimpleRenderer::GetSerializableName() + "Properties") + ": Not Version 1.");
                }
            }else{
                MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_NOT_FOUND_EXCEPTION,SimpleRenderer::GetSerializableName() + "Properties" + " was not found in the provided XML node, which was expected.");
            }
        }
 void CapsuleCollisionShape::ProtoDeSerialize(const XML::Node& OneNode)
 {
     if ( Mezzanine::String(OneNode.Name())==this->CapsuleCollisionShape::SerializableName() )
     {
         if(OneNode.GetAttribute("Version").AsInt() == 1)
         {
             XML::Node CollisionNode = OneNode.GetChild(this->PrimitiveCollisionShape::SerializableName());
             if(!CollisionNode)
                 { DeSerializeError("locate PrimitiveCollisionShape node",SerializableName()); }
             this->PrimitiveCollisionShape::ProtoDeSerialize(CollisionNode);
         }else{
             DeSerializeError("find usable serialization version",SerializableName());
         }
     }else{
         DeSerializeError(String("find correct class to deserialize, found a ")+OneNode.Name(),SerializableName());
     }
 }
Exemple #14
0
        void RadioButton::ProtoDeSerializeProperties(const XML::Node& SelfRoot)
        {
            this->CheckBox::ProtoDeSerializeProperties(SelfRoot);

            XML::Attribute CurrAttrib;
            XML::Node PropertiesNode = SelfRoot.GetChild( RadioButton::GetSerializableName() + "Properties" );

            if( !PropertiesNode.Empty() ) {
                if(PropertiesNode.GetAttribute("Version").AsInt() == 1) {
                    CurrAttrib = PropertiesNode.GetAttribute("LockoutTime");
                    if( !CurrAttrib.Empty() )
                        this->SelectLock = StringTools::ConvertToBool( CurrAttrib.AsString() );
                }else{
                    MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + (RadioButton::GetSerializableName() + "Properties") + ": Not Version 1.");
                }
            }else{
                MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_NOT_FOUND_EXCEPTION,RadioButton::GetSerializableName() + "Properties" + " was not found in the provided XML node, which was expected.");
            }
        }
Exemple #15
0
        void TabSet::ProtoDeSerializeButtonBindings(const XML::Node& SelfRoot)
        {
            this->SubSetBindings.clear();

            XML::Attribute CurrAttrib;
            XML::Node BindingsNode = SelfRoot.GetChild( "SubSetBindings" );

            if( !BindingsNode.Empty() ) {
                if( BindingsNode.GetAttribute("Version").AsInt() == 1 ) {
                    for( XML::NodeIterator BindingNodeIt = BindingsNode.begin() ; BindingNodeIt != BindingsNode.end() ; ++BindingNodeIt )
                    {
                        if( (*BindingNodeIt).GetAttribute("Version").AsInt() == 1 ) {
                            UInt16 ConfigID = 0;
                            String ButtonName;

                            CurrAttrib = (*BindingNodeIt).GetAttribute("ConfigID");
                            if( !CurrAttrib.Empty() )
                                ConfigID = static_cast<UInt16>( CurrAttrib.AsUint() );

                            CurrAttrib = (*BindingNodeIt).GetAttribute("ButtonName");
                            if( !CurrAttrib.Empty() )
                                ButtonName = CurrAttrib.AsString();

                            if( !ButtonName.empty() ) {
                                Widget* NamedButton = this->ParentScreen->GetWidget(ButtonName);
                                if( NamedButton != NULL && NamedButton->GetTypeName() == StackButton::TypeName ) {
                                    this->SetButtonConfig(ConfigID,static_cast<StackButton*>(NamedButton));
                                }else{
                                    StringStream ExceptionStream;
                                    ExceptionStream << "Named StackButton \"" << ButtonName << "\" not found when deserializing Widget named \"" << this->GetName() << "\".";
                                    MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_EXCEPTION,ExceptionStream.str());
                                }
                            }
                        }else{
                            MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + String("SubSetBindings") + ": Not Version 1.");
                        }
                    }
                }else{
                    MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + String("SubSetBindings") + ": Not Version 1.");
                }
            }
        }
Exemple #16
0
        void Widget::ProtoDeSerializeStateGroupBindings(const XML::Node& SelfRoot)
        {
            this->StateGroupBindings.clear();

            XML::Attribute CurrAttrib;
            XML::Node BindingsNode = SelfRoot.GetChild( "StateGroupBindings" );

            if( !BindingsNode.Empty() ) {
                if( BindingsNode.GetAttribute("Version").AsInt() == 1 ) {
                    for( XML::NodeIterator BindingNodeIt = BindingsNode.begin() ; BindingNodeIt != BindingsNode.end() ; ++BindingNodeIt )
                    {
                        if( (*BindingNodeIt).GetAttribute("Version").AsInt() == 1 ) {
                            UInt32 StateID = 0;

                            CurrAttrib = (*BindingNodeIt).GetAttribute("StateID");
                            if( !CurrAttrib.Empty() )
                                StateID = CurrAttrib.AsUint();

                            CurrAttrib = (*BindingNodeIt).GetAttribute("LayerGroupID");
                            if( !CurrAttrib.Empty() ) {
                                UInt16 LayerGroupID = CurrAttrib.AsUint();
                                RenderLayerGroup* NamedGroup = this->GetRenderLayerGroup( LayerGroupID );
                                if( NamedGroup != NULL ) {
                                    this->StateGroupBindings.insert( std::pair<UInt32,RenderLayerGroup*>(StateID,NamedGroup) );
                                }else{
                                    StringStream ExceptionStream;
                                    ExceptionStream << "Named RenderLayerGroup \"" << LayerGroupID << "\" not found when deserializing Widget named \"" << this->GetName() << "\".";
                                    MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_EXCEPTION,ExceptionStream.str());
                                }
                            }
                        }else{
                            MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + String("StateGroupBindings") + ": Not Version 1.");
                        }
                    }
                }else{
                    MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + String("StateGroupBindings") + ": Not Version 1.");
                }
            }
        }
Exemple #17
0
        void RadioButton::ProtoDeSerializeGroupButtons(const XML::Node& SelfRoot)
        {
            this->RemoveFromButtonGroup();

            XML::Attribute CurrAttrib;
            XML::Node ButtonsNode = SelfRoot.GetChild( "GroupButtons" );

            if( !ButtonsNode.Empty() ) {
                if( ButtonsNode.GetAttribute("Version").AsInt() == 1 ) {
                    for( XML::NodeIterator ButtonNodeIt = ButtonsNode.begin() ; ButtonNodeIt != ButtonsNode.end() ; ++ButtonNodeIt )
                    {
                        if( (*ButtonNodeIt).GetAttribute("Version").AsInt() == 1 ) {
                            String GroupButtonName;

                            CurrAttrib = (*ButtonNodeIt).GetAttribute("GroupButtonName");
                            if( !CurrAttrib.Empty() )
                                GroupButtonName = CurrAttrib.AsString();

                            if( !GroupButtonName.empty() ) {
                                Widget* NamedButton = this->ParentScreen->GetWidget(GroupButtonName);
                                if( NamedButton != NULL && NamedButton->GetTypeName() == RadioButton::TypeName ) {
                                    this->AddToButtonGroup( static_cast<RadioButton*>( NamedButton ) );
                                }else{
                                    StringStream ExceptionStream;
                                    ExceptionStream << "Named Widget \"" << GroupButtonName << "\" not found or not a RadioButton when deserializing Widget named \"" << this->GetName() << "\".";
                                    MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_EXCEPTION,ExceptionStream.str());
                                }
                            }
                        }else{
                            MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + String("GroupButtons") + ": Not Version 1.");
                        }
                    }
                }else{
                    MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + String("GroupButtons") + ": Not Version 1.");
                }
            }
        }
Exemple #18
0
    void Entresol::ConstructFromXML(const String& EngineDataPath, const Mezzanine::ArchiveType ArchType, const String& InitializerFile)
    {
        //Add default manager factories
        AddAllEngineDefaultManagerFactories();
        //Set some sane Defaults for some values.
        this->ManualLoopBreak = false;

        // Create Ogre.
        SetupOgre();

        // Load the necessary plugins.
        SubSystemParticleFXPlugin = new Ogre::ParticleFXPlugin();
        Ogre::Root::getSingleton().installPlugin(SubSystemParticleFXPlugin);

        // Set up the data we'll be populating.
        XML::Attribute CurrAttrib;
        String GUIInit, ResourceInit, PluginsInit, LogFileName;
        String PluginExtension, PluginPath;

        // Create or set the resource manager.
        /// @todo This currently forces our default resource manager to be constructed, which isn't in line with our factory/initiailzation design.
        /// This should be addressed somehow.
        if(ResourceManager::SingletonValid())
            { AddManager(ResourceManager::GetSingletonPtr()); }
        else
            { AddManager(new ResourceManager(EngineDataPath, ArchType)); }

        // Open and load the initializer doc.
        ResourceManager* ResourceMan = GetResourceManager();
        /// @todo Replace this stack allocated stream for one initialized from the Resource Manager, after the system is ready.
        Resource::FileStream InitStream(InitializerFile,EngineDataPath);
        XML::Document InitDoc;
        XML::ParseResult DocResult = InitDoc.Load(InitStream);
        if( DocResult.Status != XML::StatusOk )
        {
            StringStream ExceptionStream;
            ExceptionStream << "Failed to parse XML file \"" << InitializerFile << "\".";
            MEZZ_EXCEPTION(Exception::SYNTAX_ERROR_EXCEPTION_XML,ExceptionStream.str());
        }
        XML::Node InitRoot = InitDoc.GetChild("InitializerRoot");
        if( InitRoot.Empty() )
        {
            StringStream ExceptionStream;
            ExceptionStream << "Failed to find expected Root node in \"" << InitializerFile << "\".";
            MEZZ_EXCEPTION(Exception::SYNTAX_ERROR_EXCEPTION_XML,ExceptionStream.str());
        }

        // Get the world settings and set them.
        XML::Node WorldSettings = InitRoot.GetChild("WorldSettings");
        for( XML::NodeIterator SetIt = WorldSettings.begin() ; SetIt != WorldSettings.end() ; ++SetIt )
        {
            String SecName = (*SetIt).Name();
            if( "FrameSettings" == SecName )
            {
                CurrAttrib = (*SetIt).GetAttribute("TargetFrameRate");
                if(CurrAttrib.Empty())
                {
                    CurrAttrib = (*SetIt).GetAttribute("TargetFrameTime");
                    if(!CurrAttrib.Empty())
                        SetTargetFrameTimeMicroseconds(CurrAttrib.AsWhole());
                }else{
                    this->SetTargetFrameRate(CurrAttrib.AsWhole());
                }
            }
            else
            {
                MEZZ_EXCEPTION(Exception::SYNTAX_ERROR_EXCEPTION_XML,String("Unknown WorldSetting ")+SecName);
            }

        }

        SetupLogging(LogFileName);

        // Get the other initializer files we'll be using, since we'll need the plugins initializer.
        XML::Node InitFiles = InitRoot.GetChild("OtherInitializers");
        for( XML::NodeIterator InitIt = InitFiles.begin() ; InitIt != InitFiles.end() ; ++InitIt )
        {
            String InitFileName = (*InitIt).Name();
            if( "PluginInit" == InitFileName )
            {
                CurrAttrib = (*InitIt).GetAttribute("FileName");
                if(!CurrAttrib.Empty())
                    PluginsInit = CurrAttrib.AsString();
            }
            else if( "ResourceInit" == InitFileName )
            {
                CurrAttrib = (*InitIt).GetAttribute("FileName");
                if(!CurrAttrib.Empty())
                    ResourceInit = CurrAttrib.AsString();
            }
            else if( "GUIInit" == InitFileName )
            {
                CurrAttrib = (*InitIt).GetAttribute("FileName");
                if(!CurrAttrib.Empty())
                    GUIInit = CurrAttrib.AsString();
            }
        }

        // Load additional resource groups
        /*if(!ResourceInit.empty())
        {
            /// @todo Replace this stack allocated stream for one initialized from the Resource Manager, after the system is ready.
            Resource::FileStream ResourceStream(ResourceInit,EngineDataPath);
            XML::Document ResourceDoc;
            ResourceDoc.Load(ResourceStream);
            // Get an iterator to the first resource group node, and declare them all.
            XML::Node ResourceLocations = ResourceDoc.GetChild("ResourceLocations");
            for( XML::NodeIterator GroupIt = ResourceLocations.begin() ; GroupIt != ResourceLocations.end() ; ++GroupIt )
            {
                String GroupName, GroupType, GroupPath;
                bool GroupRecursive = false;
                // Get the group path
                CurrAttrib = (*GroupIt).GetAttribute("GroupPath");
                if(!CurrAttrib.Empty())
                    GroupPath = CurrAttrib.AsString();
                // Get the group type
                CurrAttrib = (*GroupIt).GetAttribute("GroupType");
                if(!CurrAttrib.Empty())
                    GroupType = CurrAttrib.AsString();
                // Get the group name
                CurrAttrib = (*GroupIt).GetAttribute("GroupName");
                if(!CurrAttrib.Empty())
                    GroupName = CurrAttrib.AsString();
                // Get whether this is recursive
                CurrAttrib = (*GroupIt).GetAttribute("Recursive");
                if(!CurrAttrib.Empty())
                    GroupRecursive = StringTool::ConvertToBool(CurrAttrib.AsString());
                // Finally create the resource location.
                ResourceMan->AddAssetLocation(GroupPath,GroupType,GroupName,GroupRecursive);
            }
            // Get what resource groups should be initialized.
            XML::Node InitGroups = ResourceDoc.GetChild("InitGroups");
            for( XML::NodeIterator InitIt = InitGroups.begin() ; InitIt != InitGroups.end() ; ++InitIt )
            {
                String GroupName;
                CurrAttrib = (*InitIt).GetAttribute("GroupName");
                if(!CurrAttrib.Empty())
                    GroupName = CurrAttrib.AsString();
                ResourceMan->InitAssetGroup(GroupName);
            }
        }//*/

        // Create the requested managers and set their necessary values.
        XML::Node Managers = InitRoot.GetChild("Managers");
        for( XML::NodeIterator ManIt = Managers.begin() ; ManIt != Managers.end() ; ++ManIt )
        {
            CreateManager( (*ManIt).Name(), (*ManIt) );
        }

        // Load additional resource groups
        if(!ResourceInit.empty())
        {
            /// @todo Replace this stack allocated stream for one initialized from the Resource Manager, after the system is ready.
            Resource::FileStream ResourceStream(ResourceInit,EngineDataPath);
            XML::Document ResourceDoc;
            ResourceDoc.Load(ResourceStream);
            // Get an iterator to the first resource group node, and declare them all.
            XML::Node ResourceLocations = ResourceDoc.GetChild("ResourceLocations");
            for( XML::NodeIterator GroupIt = ResourceLocations.begin() ; GroupIt != ResourceLocations.end() ; ++GroupIt )
            {
                String GroupName, GroupPath;
                ArchiveType GroupType;
                bool GroupRecursive = false;
                // Get the group path
                CurrAttrib = (*GroupIt).GetAttribute("GroupPath");
                if(!CurrAttrib.Empty())
                    GroupPath = CurrAttrib.AsString();
                // Get the group type
                CurrAttrib = (*GroupIt).GetAttribute("GroupType");
                if(!CurrAttrib.Empty())
                    GroupType = ResourceManager::GetArchiveTypeFromString(CurrAttrib.AsString());
                // Get the group name
                CurrAttrib = (*GroupIt).GetAttribute("GroupName");
                if(!CurrAttrib.Empty())
                    GroupName = CurrAttrib.AsString();
                // Get whether this is recursive
                CurrAttrib = (*GroupIt).GetAttribute("Recursive");
                if(!CurrAttrib.Empty())
                    GroupRecursive = StringTools::ConvertToBool(CurrAttrib.AsString());
                // Finally create the resource location.
                ResourceMan->AddAssetLocation(GroupPath,GroupType,GroupName,GroupRecursive);
            }
            // Get what resource groups should be initialized.
            XML::Node InitGroups = ResourceDoc.GetChild("InitGroups");
            for( XML::NodeIterator InitIt = InitGroups.begin() ; InitIt != InitGroups.end() ; ++InitIt )
            {
                String GroupName;
                CurrAttrib = (*InitIt).GetAttribute("GroupName");
                if(!CurrAttrib.Empty())
                    GroupName = CurrAttrib.AsString();
                ResourceMan->InitAssetGroup(GroupName);
            }
        }

        // Configure the UI
        if(!GUIInit.empty())
        {
            /// @todo This is currently not implemented.
        }

        SanityChecks();
    }
Exemple #19
0
        void SliderConstraint::ProtoDeSerializeProperties(const XML::Node& SelfRoot)
        {
            this->Constraint::ProtoDeSerializeProperties(SelfRoot);

            XML::Attribute CurrAttrib;
            XML::Node PropertiesNode = SelfRoot.GetChild( SliderConstraint::GetSerializableName() + "Properties" );

            if( !PropertiesNode.Empty() ) {
                if( PropertiesNode.GetAttribute("Version").AsInt() == 1 ) {
                    CurrAttrib = PropertiesNode.GetAttribute("UseFrameOffset");
                    if( !CurrAttrib.Empty() )
                        this->SetUseFrameOffset( CurrAttrib.AsBool() );

                    CurrAttrib = PropertiesNode.GetAttribute("UpperLinLimit");
                    if( !CurrAttrib.Empty() )
                        this->SetUpperLinLimit( CurrAttrib.AsReal() );

                    CurrAttrib = PropertiesNode.GetAttribute("UpperAngLimit");
                    if( !CurrAttrib.Empty() )
                        this->SetUpperAngLimit( CurrAttrib.AsReal() );

                    CurrAttrib = PropertiesNode.GetAttribute("LowerLinLimit");
                    if( !CurrAttrib.Empty() )
                        this->SetLowerLinLimit( CurrAttrib.AsReal() );

                    CurrAttrib = PropertiesNode.GetAttribute("LowerAngLimit");
                    if( !CurrAttrib.Empty() )
                        this->SetLowerAngLimit( CurrAttrib.AsReal() );

                    CurrAttrib = PropertiesNode.GetAttribute("PoweredLinMotor");
                    if( !CurrAttrib.Empty() )
                        this->SetPoweredLinMotor( CurrAttrib.AsBool() );

                    CurrAttrib = PropertiesNode.GetAttribute("PoweredAngMotor");
                    if( !CurrAttrib.Empty() )
                        this->SetPoweredAngMotor( CurrAttrib.AsBool() );

                    CurrAttrib = PropertiesNode.GetAttribute("TargetLinMotorVelocity");
                    if( !CurrAttrib.Empty() )
                        this->SetTargetLinMotorVelocity( CurrAttrib.AsReal() );

                    CurrAttrib = PropertiesNode.GetAttribute("TargetAngMotorVelocity");
                    if( !CurrAttrib.Empty() )
                        this->SetTargetAngMotorVelocity( CurrAttrib.AsReal() );

                    CurrAttrib = PropertiesNode.GetAttribute("MaxLinMotorForce");
                    if( !CurrAttrib.Empty() )
                        this->SetMaxLinMotorForce( CurrAttrib.AsReal() );

                    CurrAttrib = PropertiesNode.GetAttribute("MaxAngMotorForce");
                    if( !CurrAttrib.Empty() )
                        this->SetMaxAngMotorForce( CurrAttrib.AsReal() );

                    CurrAttrib = PropertiesNode.GetAttribute("SoftnessLimLin");
                    if( !CurrAttrib.Empty() )
                        this->SetSoftnessLimLin( CurrAttrib.AsReal() );

                    CurrAttrib = PropertiesNode.GetAttribute("SoftnessLimAng");
                    if( !CurrAttrib.Empty() )
                        this->SetSoftnessLimAng( CurrAttrib.AsReal() );

                    CurrAttrib = PropertiesNode.GetAttribute("SoftnessOrthoLin");
                    if( !CurrAttrib.Empty() )
                        this->SetSoftnessOrthoLin( CurrAttrib.AsReal() );

                    CurrAttrib = PropertiesNode.GetAttribute("SoftnessOrthoAng");
                    if( !CurrAttrib.Empty() )
                        this->SetSoftnessOrthoAng( CurrAttrib.AsReal() );
                }else{
                    MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + ( SliderConstraint::GetSerializableName() + "Properties" ) + ": Not Version 1.");
                }
            }else{
                MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_NOT_FOUND_EXCEPTION,SliderConstraint::GetSerializableName() + "Properties" + " was not found in the provided XML node, which was expected.");
            }
        }
Exemple #20
0
        void MultiImageLayer::ProtoDeSerializeProperties(const XML::Node& SelfRoot)
        {
            this->ImageLayer::ProtoDeSerializeProperties(SelfRoot);
            XML::Attribute CurrAttrib;
            XML::Node PropertiesNode = SelfRoot.GetChild( MultiImageLayer::GetSerializableName() + "Properties" );

            if( !PropertiesNode.Empty() ) {
                if(PropertiesNode.GetAttribute("Version").AsInt() == 1) {
                    XML::Node LayerImagesNode = PropertiesNode.GetChild( MultiImageLayer::GetSerializableName() + "Properties" );

                    CurrAttrib = LayerImagesNode.GetAttribute("NumImages");
                    if( !CurrAttrib.Empty() )
                        this->ReserveMultiImageData( CurrAttrib.AsWhole() );

                    /// @todo This loop expects the listed order in the XML to match the order in which they were serialized.  Within PugiXML at least this
                    /// shouldn't be a problem, however if Images start appearing out of order it may be worthwhile to investigate or add some ordering redundancy.
                    ImageDataIterator ImageIt = this->LayerImages.begin();
                    for( XML::NodeIterator ImageNodeIt = LayerImagesNode.begin() ; ImageNodeIt != LayerImagesNode.end() ; ++ImageNodeIt )
                    {
                        String SpriteName, SpriteAtlas;

                        if( ImageIt == this->LayerImages.end() ) {
                            MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_RANGE_EXCEPTION,"Seriailzed value for \"NumImages\" is smaller than number of nodes to deserialize.  Verify serialized XML.");
                        }

                        CurrAttrib = (*ImageNodeIt).GetAttribute("SpriteName");
                        if( !CurrAttrib.Empty() )
                            SpriteName = CurrAttrib.AsString();

                        CurrAttrib = (*ImageNodeIt).GetAttribute("SpriteAtlas");
                        if( !CurrAttrib.Empty() )
                            SpriteAtlas = CurrAttrib.AsString();

                        (*ImageIt).LayerSprite = this->Parent->GetScreen()->GetSprite(SpriteName,SpriteAtlas);

                        XML::Node FillRectNode = (*ImageNodeIt).GetChild("FillRect").GetFirstChild();
                        if( !FillRectNode.Empty() )
                            (*ImageIt).FillRect.ProtoDeSerialize(FillRectNode);

                        XML::Node FillColoursNode = (*ImageNodeIt).GetChild("FillColours");
                        XML::Node TopLeftFillNode = FillColoursNode.GetChild("TopLeft").GetFirstChild();
                        if( !TopLeftFillNode.Empty() )
                            (*ImageIt).FillColours[UI::QC_TopLeft].ProtoDeSerialize(TopLeftFillNode);

                        XML::Node TopRightFillNode = FillColoursNode.GetChild("TopRight").GetFirstChild();
                        if( !TopRightFillNode.Empty() )
                            (*ImageIt).FillColours[UI::QC_TopRight].ProtoDeSerialize(TopRightFillNode);

                        XML::Node BottomLeftFillNode = FillColoursNode.GetChild("BottomLeft").GetFirstChild();
                        if( !BottomLeftFillNode.Empty() )
                            (*ImageIt).FillColours[UI::QC_BottomLeft].ProtoDeSerialize(BottomLeftFillNode);

                        XML::Node BottomRightFillNode = FillColoursNode.GetChild("BottomRight").GetFirstChild();
                        if( !BottomRightFillNode.Empty() )
                            (*ImageIt).FillColours[UI::QC_BottomRight].ProtoDeSerialize(BottomRightFillNode);

                        ++ImageIt;
                    }
                }else{
                    MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + (String("MultiImageData") + "Properties") + ": Not Version 1.");
                }
            }else{
                MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_NOT_FOUND_EXCEPTION,String("MultiImageData") + "Properties" + " was not found in the provided XML node, which was expected.");
            }
        }