示例#1
0
//注册属性
bool CAttributeManager::RegisterAttribute(LPCTSTR pszName, WORD * pWord, bool bReadOnly)
{
	//查找属性项
	IAttribute * pAttribute=QueryAttribute(pszName);
	if (pAttribute) return false;

	//增加属性项
	CAttribute Attribute(pszName,pWord,bReadOnly);
	m_Attribute.Add(Attribute);

	return true;
}
示例#2
0
// list all the attributes
void ListAttributes()
{
    tPvUint32 lCount;
    tPvAttrListPtr lAttrs;

    if(!PvAttrList(GCamera.Handle,&lAttrs,&lCount))
    {
        for(tPvUint32 i=0;i<lCount;i++)
            QueryAttribute(lAttrs[i]);
    }
    else
        printf("failed get the attributes list\n");
}
示例#3
0
// list all attributes
void ListAttributes()
{
    tPvUint32 lCount;
    tPvAttrListPtr lAttrs;

    //Get all attributes
	if(PvAttrList(GCamera.Handle,&lAttrs,&lCount) == ePvErrSuccess)
    {
        //Get info and display each attribute
		for(tPvUint32 i=0;i<lCount;i++)
            QueryAttribute(lAttrs[i]);
    }
    else
        printf("failed get the attributes list\n");
}
示例#4
0
    SpriteAnimDefinition* SpriteAnimDefinition::createFromFile(const std::string& filename, onut::ContentManager* pContentManager)
    {
        SpriteAnimDefinition* pRet = new SpriteAnimDefinition();

        pRet->m_filename = pContentManager->find(filename);
        if (pRet->m_filename.empty())
        {
            pRet->m_filename = filename;
        }

        tinyxml2::XMLDocument doc;
        doc.LoadFile(pRet->m_filename.c_str());
        auto pXMLSheet = doc.FirstChildElement("sheet");
        assert(pXMLSheet);
        std::string textureName = pXMLSheet->Attribute("texture");
        onut::Texture* pTexture = pContentManager->getResource<onut::Texture>(textureName);
        assert(pTexture);
        int spriteW = pTexture->getSize().x;
        int spriteH = pTexture->getSize().y;
        int originX = 0;
        int originY = 0;
        pXMLSheet->QueryAttribute("spriteWidth", &spriteW);
        pXMLSheet->QueryAttribute("spriteHeight", &spriteH);
        pXMLSheet->QueryAttribute("originX", &originX);
        pXMLSheet->QueryAttribute("originY", &originY);
        Vector2 origin((float)originX / (float)spriteW, (float)originY / (float)spriteH);
        for (auto pXMLAnim = pXMLSheet->FirstChildElement("anim"); pXMLAnim; pXMLAnim = pXMLAnim->NextSiblingElement("anim"))
        {
            std::string name = pXMLAnim->Attribute("name");
            auto& anim = pRet->m_anims[name];
            int fps = 30;
            pXMLAnim->QueryAttribute("fps", &fps);
            pXMLAnim->QueryAttribute("loop", &anim.loop);
            Frame frame;
            frame.pTexture = pTexture;
            frame.origin = origin;
            for (auto pXMLFrame = pXMLAnim->FirstChildElement("frame"); pXMLFrame; pXMLFrame = pXMLFrame->NextSiblingElement("frame"))
            {
                int repeat = 1;
                int id = 0;
                pXMLFrame->QueryAttribute("id", &id);
                pXMLFrame->QueryAttribute("repeat", &repeat);
                int col = id % (pTexture->getSize().x / spriteW);
                int row = id / (pTexture->getSize().x / spriteW);
                col *= spriteW;
                row *= spriteH;
                frame.UVs = Vector4(
                    (float)col / (float)pTexture->getSize().x,
                    (float)row / (float)pTexture->getSize().y,
                    (float)(col + spriteW) / (float)pTexture->getSize().x,
                    (float)(row + spriteH) / (float)pTexture->getSize().y);
                for (auto i = 0; i < repeat; ++i)
                {
                    anim.frames.push_back(frame);
                }
            }
            anim.frames.push_back(frame); // Repeat last frame
            anim.duration = (float)anim.frames.size() / (float)fps;
        }

        return pRet;
    }
示例#5
0
//设置属性
bool CAttributeManager::SetAttributeValue(LPCTSTR pszName, LPCTSTR pszValue)
{
	IAttribute * pAttribute=QueryAttribute(pszName);
	if (pAttribute==NULL) return false;
	return pAttribute->SetValue(pszValue);
}
示例#6
0
//获取属性
bool CAttributeManager::GetAttributeVarValue(LPCTSTR pszName, CString & strValue)
{
	IAttribute * pAttribute=QueryAttribute(pszName);
	if (pAttribute==NULL) return false;
	return pAttribute->GetVarValue(strValue);
}
示例#7
0
//获取属性
bool CAttributeManager::GetAttributeValue(LPCTSTR pszName, DOUBLE & dValue)
{
	IAttribute * pAttribute=QueryAttribute(pszName);
	if (pAttribute==NULL) return false;
	return pAttribute->GetValue(dValue);
}