00001 // ///////////////////////////////////////////////////////////////////////////// 00002 // 00003 // Name: components.cpp 00004 // Author: Michael Bartsch (ZCCdark203) 00005 // 00006 // Desc : Implements global functions regarding components. 00007 // 00008 // License: Copyright (C) 2009 Michael Bartsch and Contributors 00009 // 00010 // This program is free software: you can redistribute it 00011 // and/or modify it under the terms of the zlib/libpng License. 00012 // See main.cpp for conditions of distribution and use. 00013 // 00014 // ///////////////////////////////////////////////////////////////////////////// 00015 00016 // Include files 00017 #include "components.h" 00018 00019 00020 // Parses the given XML file for components. 00021 void parseComponentsXML(IXMLReader *file, Entity *entity) 00022 { 00023 // Did we get a valid pointer? 00024 if(!file) 00025 return; 00026 00027 // Create a list of available parse functions. 00028 std::vector<bool (*)(IXMLReader*, Entity*)> parsers; 00029 00030 parsers.push_back(AnimatedMeshComponent::parseXML); 00031 parsers.push_back(BillboardComponent::parseXML); 00032 parsers.push_back(CameraComponent::parseXML); 00033 parsers.push_back(ImageComponent::parseXML); 00034 parsers.push_back(LightComponent::parseXML); 00035 parsers.push_back(MeshComponent::parseXML); 00036 parsers.push_back(OctTreeComponent::parseXML); 00037 parsers.push_back(ParticleSysComponent::parseXML); 00038 parsers.push_back(SceneComponent::parseXML); 00039 parsers.push_back(SkyBoxComponent::parseXML); 00040 parsers.push_back(SkyDomeComponent::parseXML); 00041 parsers.push_back(TerrainComponent::parseXML); 00042 parsers.push_back(TextBillboardComponent::parseXML); 00043 00044 #ifdef __COMPILE_WITH_SFML_AUDIO__ 00045 parsers.push_back(SoundListenerComponent::parseXML); 00046 parsers.push_back(SoundSourceComponent::parseXML); 00047 #endif // __COMPILE_WITH_SFML_AUDIO__ 00048 00049 // Read from the file. 00050 while(file->read()) 00051 { 00052 switch(file->getNodeType()) 00053 { 00054 case io::EXN_ELEMENT_END: 00055 00056 // </components> 00057 if(stringw("components") == file->getNodeName()) 00058 return; 00059 00060 break; 00061 00062 default: 00063 00064 // Parse for components. 00065 std::vector<bool (*)(IXMLReader*, Entity*)>::iterator it; 00066 00067 for(it = parsers.begin(); it != parsers.end(); it++) 00068 { 00069 if( (*it)(file, entity) ) 00070 break; 00071 } 00072 00073 break; 00074 } 00075 } 00076 } 00077 00078 // End of File