コード例 #1
0
    Offset<Table> ProjectNodeReader::createOptionsWithFlatBuffers(const tinyxml2::XMLElement *objectData,
                                                                  flatbuffers::FlatBufferBuilder *builder)
    {
        auto temp = NodeReader::getInstance()->createOptionsWithFlatBuffers(objectData, builder);
        auto nodeOptions = *(Offset<WidgetOptions>*)(&temp);
        
        std::string filename = "";
        float innerspeed = 1.0f;

        const tinyxml2::XMLAttribute* objattri = objectData->FirstAttribute();
        // inneraction speed
        while (objattri)
        {
            std::string name = objattri->Name();
            std::string value = objattri->Value();
            if (name == "InnerActionSpeed")
            {
                    innerspeed = atof(objattri->Value());
                    break;
            }
            objattri = objattri->Next();
        }

        // FileData
        const tinyxml2::XMLElement* child = objectData->FirstChildElement();
        while (child)
        {
            std::string name = child->Name();
            
            if (name == "FileData")
            {
                const tinyxml2::XMLAttribute* attribute = child->FirstAttribute();
                
                while (attribute)
                {
                    name = attribute->Name();
                    std::string value = attribute->Value();
                    
                    if (name == "Path")
                    {
                        size_t pos = value.find_last_of('.');
                        std::string convert = value.substr(0, pos).append(".csb");
                        filename = convert;
                    }
                    
                    attribute = attribute->Next();
                }
            }
            
            child = child->NextSiblingElement();
        }
        
        auto options = CreateProjectNodeOptions(*builder,
                                                nodeOptions,
                                                builder->CreateString(filename),
                                                innerspeed);
        
        return *(Offset<Table>*)(&options);
    }
コード例 #2
0
 Offset<Table> ProjectNodeReader::createOptionsWithFlatBuffersForSimulator(const tinyxml2::XMLElement *objectData,
                                                                           flatbuffers::FlatBufferBuilder *builder)
 {
     auto temp = NodeReader::getInstance()->createOptionsWithFlatBuffers(objectData, builder);
     auto nodeOptions = *(Offset<WidgetOptions>*)(&temp);
     
     std::string filename = "";
     
     // FileData
     const tinyxml2::XMLElement* child = objectData->FirstChildElement();
     while (child)
     {
         std::string name = child->Name();
         
         if (name == "FileData")
         {
             const tinyxml2::XMLAttribute* attribute = child->FirstAttribute();
             
             while (attribute)
             {
                 name = attribute->Name();
                 std::string value = attribute->Value();
                 
                 if (name == "Path")
                 {
                     filename = value;
                 }
                 
                 attribute = attribute->Next();
             }
         }
         
         child = child->NextSiblingElement();
     }
     
     auto options = CreateProjectNodeOptions(*builder,
                                             nodeOptions,
                                             builder->CreateString(filename));
     
     return *(Offset<Table>*)(&options);
 }
コード例 #3
0
    Offset<Table> ProjectNodeReader::createOptionsWithFlatBuffers(const tinyxml2::XMLElement *objectData,
                                                                  flatbuffers::FlatBufferBuilder *builder)
    {
        auto temp = NodeReader::getInstance()->createOptionsWithFlatBuffers(objectData, builder);
        auto nodeOptions = *(Offset<WidgetOptions>*)(&temp);
        
        std::string filename = "";
        bool isloop = true;
        bool isAutoPlay = true;

        const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
        while (attribute)
        {
            std::string attriname = attribute->Name();
            std::string value = attribute->Value();

            if (attriname == "IsLoop")
            {
                isloop = (value == "True") ? true : false;
            }
            else if (attriname == "IsAutoPlay")
            {
                isAutoPlay = (value == "True") ? true : false;
            }

            attribute = attribute->Next();
        }

        // FileData
        const tinyxml2::XMLElement* child = objectData->FirstChildElement();
        while (child)
        {
            std::string name = child->Name();
            
            if (name == "FileData")
            {
                const tinyxml2::XMLAttribute* attributeFileData = child->FirstAttribute();
                
                while (attributeFileData)
                {
                    name = attributeFileData->Name();
                    std::string value = attributeFileData->Value();
                    
                    if (name == "Path")
                    {
                        size_t pos = value.find_last_of('.');
                        std::string convert = value.substr(0, pos).append(".csb");
                        filename = convert;
                    }
                    
                    attributeFileData = attributeFileData->Next();
                }
            }
            
            child = child->NextSiblingElement();
        }
        
        auto options = CreateProjectNodeOptions(*builder,
                                                nodeOptions,
                                                builder->CreateString(filename),
                                                isloop,
                                                isAutoPlay);
        
        return *(Offset<Table>*)(&options);
    }