void CAsset_SkeletonSkin::SaveInAssetsFile(CDataFileWriter* pFileWriter, int Position) { CStorageType Item; Item.m_Name = pFileWriter->AddData(str_length(m_aName)+1, m_aName); Item.m_SkeletonPath = m_SkeletonPath; //save sprites { CStorageType::CAsset_Sprite* pSprites = new CStorageType::CAsset_Sprite[m_Sprites.size()]; for(int i=0; i<m_Sprites.size(); i++) { pSprites[i].m_SpritePath = m_Sprites[i].m_SpritePath; pSprites[i].m_BonePath = m_Sprites[i].m_BonePath; pSprites[i].m_LayerPath = m_Sprites[i].m_LayerPath; pSprites[i].m_TranslationX = m_Sprites[i].m_Translation.x; pSprites[i].m_TranslationY = m_Sprites[i].m_Translation.y; pSprites[i].m_ScaleX = m_Sprites[i].m_Scale.x; pSprites[i].m_ScaleY = m_Sprites[i].m_Scale.y; pSprites[i].m_Angle = m_Sprites[i].m_Angle; pSprites[i].m_Anchor = m_Sprites[i].m_Anchor; pSprites[i].m_Color = ColorToInt(m_Sprites[i].m_Color); pSprites[i].m_Alignment = m_Sprites[i].m_Alignment; } Item.m_NumSprites = m_Sprites.size(); Item.m_SpritesData = pFileWriter->AddData(Item.m_NumSprites * sizeof(CStorageType::CAsset_Sprite), pSprites); delete[] pSprites; } pFileWriter->AddItem(CAssetPath::TypeToStoredType(TypeId), Position, sizeof(CStorageType), &Item); }
VertexAndUV CreateVUV(Face& face,vector<int> *vlist , int vertexIndex, TextureMaterial* tm) { VertexAndUV vuv; vector<int> *uvlist = face.getUVs(); Vertex& vertex = *face.getParentObject()->getVertex( ( *vlist )[vertexIndex]); vuv.uv = face.getParentObject()->getUVCoord((*uvlist)[vertexIndex])->getPosition(); vuv.position = vertex.getPosition(); if(vertex.isColored()) vuv.color = ColorVectorToInt(vertex.getColor()); else { if(tm) vuv.color = ColorToInt(tm->cDiffuse); else vuv.color = 0; } return vuv; }
void QLineItem::compile(QSqlDatabase &db, int nSceneId,int &count,int index) { count++; //QBasicGraphicsItem::compile(db, nSceneId, count, index); QSqlQuery sqlquery(db); sqlquery.prepare("INSERT INTO line(nItemNumber ,nSceneId ,eLineClass ,eLineType ,nLineWidth ," "nLineColor ,eLineArrow ,nAlpha , eLinePointType ,nZvalue,nCollidindId," "nStartX ,nStartY ,nWidth ,nHeight )" "VALUES (:nItemNumber ,:nSceneId ,:eLineClass ,:eLineType ,:nLineWidth ," ":nLineColor ,:eLineArrow ,:nAlpha , :eLinePointType,:nZvalue,:nCollidindId," ":nStartX ,:nStartY ,:nWidth ,:nHeight)"); sqlquery.bindValue(":nItemNumber",QVariant(count));// 表 id sqlquery.bindValue(":nSceneId",QVariant(nSceneId));// 所在场景 id sqlquery.bindValue(":eLineClass",QVariant(1)); //1 代表类型为直线 sqlquery.bindValue(":eLineType",QVariant(nLineType+1));// 线形 sqlquery.bindValue(":nLineWidth",QVariant(getLineWidth()));// 线宽 sqlquery.bindValue(":nLineColor",QVariant(ColorToInt(getLineColor()))); //颜色 sqlquery.bindValue(":eLineArrow",QVariant(m_eLineEndArrowType+1));// 箭头 sqlquery.bindValue(":nAlpha",QVariant(getAlpha()));// 透明度 sqlquery.bindValue(":eLinePointType",QVariant(m_eLineEndArrowType+1)); //端点类型 sqlquery.bindValue(":nZvalue",QVariant(zValue()));//层次 sqlquery.bindValue(":nCollidindId",QVariant(index));//碰撞ID QRectF rect = sceneBoundingRect(); if(getLineWidth() == 1) { sqlquery.bindValue(":nStartX",QVariant(rect.x()-1));//x sqlquery.bindValue(":nStartY",QVariant(rect.y()-1));//y sqlquery.bindValue(":nWidth",QVariant(rect.width()+2));//w sqlquery.bindValue(":nHeight",QVariant(rect.height()+2));//h } else { sqlquery.bindValue(":nStartX",QVariant(rect.x()));//x sqlquery.bindValue(":nStartY",QVariant(rect.y()));//y sqlquery.bindValue(":nWidth",QVariant(rect.width()));//w sqlquery.bindValue(":nHeight",QVariant(rect.height()));//h } bool result = false; result = sqlquery.exec(); qDebug() << "insert line table :"<<result; sqlquery.prepare("INSERT INTO point(nItemId,nPosX,nPosY,nOrder,ePointType)" "VALUES (:nItemId ,:nPosX ,:nPosY ,:nOrder ,:ePointType )"); for(int i=0; i<2; i++) { QPointF pt = this->path().pointAtPercent(i); pt = mapToScene(pt); sqlquery.bindValue(":nItemId",QVariant(count));// item表 id sqlquery.bindValue(":nPosX",QVariant((int)pt.x()));// X sqlquery.bindValue(":nPosY",QVariant((int)pt.y())); //Y sqlquery.bindValue(":nOrder",QVariant(i));// 顺序 sqlquery.bindValue(":ePointType",QVariant(1));// 显示点 result = sqlquery.exec(); qDebug() << "insert point table :"<<result; } SamDrawScene *pScene = dynamic_cast<SamDrawScene *>(scene()); if(pScene && pScene->nIsSceneOrWindow == 2) { //是自定义键盘的item //先新建键盘——item关联表 item表在派生类中创建 //QSqlQuery sqlquery(db); sqlquery.prepare("INSERT INTO kbAndItem(nKeyBoardId , nItemId ,nId,nItemTableType ) " "VALUES (:nKeyBoardId ,:nItemId ,:nId,:nItemTableType)"); sqlquery.bindValue(":nKeyBoardId",QVariant(nSceneId)); sqlquery.bindValue(":nItemId",QVariant(count)); sqlquery.bindValue(":nId",QVariant(id())); sqlquery.bindValue(":nItemTableType",QVariant((int)SAM_DRAW_OBJECT_LINE)); bool result = false; result = sqlquery.exec(); qDebug() << "insert kbAndItem table :"<<result; } if(pScene && pScene->nIsSceneOrWindow != 2) { //窗口或者场景item //先新建键盘——item关联表 //item表在派生类中创建 //QSqlQuery sqlquery(db); sqlquery.prepare("INSERT INTO sceneAndItem(nSceneId,nItemId,nId,nItemTableType)" "VALUES(:nSceneId,:nItemId,:nId,:nItemTableType)"); sqlquery.bindValue(":nSceneId",QVariant(nSceneId)); sqlquery.bindValue(":nItemId",QVariant(count)); sqlquery.bindValue(":nId",QVariant(id())); //int t = this->GroupType(); sqlquery.bindValue(":nItemTableType",QVariant((int)SAM_DRAW_OBJECT_LINE)); bool result = false; result = sqlquery.exec(); qDebug() << "insert sceneAndItem table :"<<result; } }
void QElipseItem::compile(QSqlDatabase &db, int nSceneId,int &count,int index) { count++; //QBasicGraphicsItem::compile(db, nSceneId, count, index); QSqlQuery sqlquery(db); sqlquery.prepare("INSERT INTO polygon(nItemId ,nSceneId,ePolygonClass,eLineType ,nLineWidth,nLineColor," "eStyle,nBackColor,nForeColor,nAlpha,nPointX,nPointY,nWidth,nHeight,nRadius,eCornerType," "nZvalue,nCollidindId)" "VALUES (:nItemId,:nSceneId,:ePolygonClass ,:eLineType ,:nLineWidth,:nLineColor,:eStyle," ":nBackColor,:nForeColor,:nAlpha,:nPointX,:nPointY,:nWidth,:nHeight,:nRadius,:eCornerType," ":nZvalue,:nCollidindId)"); sqlquery.bindValue(":nItemId",QVariant(count));// 表 id sqlquery.bindValue(":nSceneId",QVariant(nSceneId));// 所在场景 id sqlquery.bindValue(":ePolygonClass",QVariant(1)); //1 代表类型为圆 sqlquery.bindValue(":eLineType",QVariant(nLineType+1));// 线形 sqlquery.bindValue(":nLineWidth",QVariant(GetLineWidth()));// 线宽 sqlquery.bindValue(":nLineColor",QVariant(ColorToInt(GetLineColor()))); //颜色 sqlquery.bindValue(":eStyle",QVariant(GetPattern()+1));// 样式 sqlquery.bindValue(":nBackColor",QVariant(ColorToInt(GetBackColor()))); //背景色 sqlquery.bindValue(":nForeColor",QVariant(ColorToInt(GetFrontColor()))); //前景色 sqlquery.bindValue(":nAlpha",QVariant(GetAlpha()));// 透明度 QRect rect = this->sceneBoundingRect().toRect(); sqlquery.bindValue(":nStartX",QVariant(rect.x()));//x sqlquery.bindValue(":nStartY",QVariant(rect.y()));//y sqlquery.bindValue(":nWidth",QVariant(rect.width()));//w sqlquery.bindValue(":nHeight",QVariant(rect.height()));//h sqlquery.bindValue(":nZvalue",QVariant(zValue()));//层次 sqlquery.bindValue(":nCollidindId",QVariant(index));//碰撞ID bool result = false; result = sqlquery.exec(); qDebug() << "insert Elipse table :"<<result; SamDrawScene *pScene = dynamic_cast<SamDrawScene *>(scene()); if(pScene && pScene->nIsSceneOrWindow == 2) { //是自定义键盘的item //先新建键盘——item关联表 item表在派生类中创建 //QSqlQuery sqlquery(db); sqlquery.prepare("INSERT INTO kbAndItem(nKeyBoardId , nItemId ,nId,nItemTableType ) " "VALUES (:nKeyBoardId ,:nItemId ,:nId,:nItemTableType)"); sqlquery.bindValue(":nKeyBoardId",QVariant(nSceneId)); sqlquery.bindValue(":nItemId",QVariant(count)); sqlquery.bindValue(":nId",QVariant(id())); sqlquery.bindValue(":nItemTableType",QVariant((int)SAM_DRAW_OBJECT_ELIPSE)); bool result = false; result = sqlquery.exec(); qDebug() << "insert kbAndItem table :"<<result; } if(pScene && pScene->nIsSceneOrWindow != 2) { //窗口或者场景item //先新建键盘——item关联表 //item表在派生类中创建 //QSqlQuery sqlquery(db); sqlquery.prepare("INSERT INTO sceneAndItem(nSceneId,nItemId,nId,nItemTableType)" "VALUES(:nSceneId,:nItemId,:nId,:nItemTableType)"); sqlquery.bindValue(":nSceneId",QVariant(nSceneId)); sqlquery.bindValue(":nItemId",QVariant(count)); sqlquery.bindValue(":nId",QVariant(id())); //int t = this->GroupType(); sqlquery.bindValue(":nItemTableType",QVariant((int)SAM_DRAW_OBJECT_ELIPSE)); bool result = false; result = sqlquery.exec(); qDebug() << "insert sceneAndItem table :"<<result; } }
void QRecipeTableItem::compile(QSqlDatabase &db, int nSceneId,int &count,int index) { count++; QVisableItem::compile(db, nSceneId, count,index); int nItemID = count; if(sPro.enableTouch && !sPro.byGroups_T) { //触控受位控制 增一个地址表 count++; } if(sPro.bNotice) { //触控解锁通知到地址 增加一个地址表 count++; } if(sPro.enableVisable && !sPro.byGroups_V) { //显现受位控制 增加一个地址表 count++; } QRectF rect = this->sceneBoundingRect(); QSqlQuery sqlquery(db); bool bReasult = false; bReasult = sqlquery.prepare("INSERT INTO recipeDisplay(nItemId,nSceneId,nStartPosX,nStartPosY,nWidth," "nHeight,nRecipeGroupId,bShowRecipeID,bShowDescrip,eTextAlignType," "nLanguaId,nRowShowNum,nColumShowNum,nHHeadTextColor,nHHeadBackColor," "nHHeadFontSize,sHHeadFontFamily,nVHeadTextColor,nVHeadBackColor," "nVHeadFontSize,sVHeadFontFamily,nDataTextColor,nDataBackColor," "nDataFontSize,nLineColor,nTransparent,nZvalue,nCollidindId,nShowPropId)" "VALUES (:nItemId,:nSceneId,:nStartPosX,:nStartPosY,:nWidth," ":nHeight,:nRecipeGroupId,:bShowRecipeID,:bShowDescrip,:eTextAlignType," ":nLanguaId,:nRowShowNum,:nColumShowNum,:nHHeadTextColor,:nHHeadBackColor," ":nHHeadFontSize,:sHHeadFontFamily,:nVHeadTextColor,:nVHeadBackColor," ":nVHeadFontSize,:sVHeadFontFamily,:nDataTextColor,:nDataBackColor," ":nDataFontSize,:nLineColor,:nTransparent,:nZvalue,:nCollidindId,:nShowPropId)"); sqlquery.bindValue(":nItemId",QVariant(nItemID)); sqlquery.bindValue(":nSceneId",QVariant(nSceneId)); sqlquery.bindValue(":nStartPosX",QVariant(rect.x())); sqlquery.bindValue(":nStartPosY",QVariant(rect.y())); sqlquery.bindValue(":nWidth",QVariant(rect.width())); sqlquery.bindValue(":nHeight",QVariant(rect.height())); sqlquery.bindValue(":nRecipeGroupId",QVariant(m_SaveInfo.nRecipeGroupId)); sqlquery.bindValue(":bShowRecipeID",QVariant(m_SaveInfo.bShowRecipeID)); sqlquery.bindValue(":bShowDescrip",QVariant(m_SaveInfo.bShowDescrip)); int nAlign = 0; if(0 == m_SaveInfo.eTextAlignType)//center { nAlign = 2; } else if(1 == m_SaveInfo.eTextAlignType)//left { nAlign = 1; } else { nAlign = 3; } sqlquery.bindValue(":eTextAlignType",QVariant(nAlign)); sqlquery.bindValue(":nLanguaId",QVariant(m_SaveInfo.nLanguaId)); sqlquery.bindValue(":nRowShowNum",QVariant(m_SaveInfo.nRowShowNum)); sqlquery.bindValue(":nColumShowNum",QVariant(m_SaveInfo.nColumShowNum)); sqlquery.bindValue(":nHHeadTextColor",QVariant(ColorToInt(m_SaveInfo.nHHeadTextColor))); sqlquery.bindValue(":nHHeadBackColor",QVariant(ColorToInt(m_SaveInfo.nHHeadBackColor))); sqlquery.bindValue(":nHHeadFontSize",QVariant(m_SaveInfo.nHHeadFontSize + 5)); sqlquery.bindValue(":sHHeadFontFamily",QVariant(m_SaveInfo.sHHeadFontFamily)); sqlquery.bindValue(":nVHeadTextColor",QVariant(ColorToInt(m_SaveInfo.nVHeadTextColor))); sqlquery.bindValue(":nVHeadBackColor",QVariant(ColorToInt(m_SaveInfo.nVHeadBackColor))); sqlquery.bindValue(":nVHeadFontSize",QVariant(m_SaveInfo.nVHeadFontSize + 5)); sqlquery.bindValue(":sVHeadFontFamily",QVariant(m_SaveInfo.sVHeadFontFamily)); sqlquery.bindValue(":nDataTextColor",QVariant(ColorToInt(m_SaveInfo.nDataTextColor))); sqlquery.bindValue(":nDataBackColor",QVariant(ColorToInt(m_SaveInfo.nDataBackColor))); sqlquery.bindValue(":nDataFontSize",QVariant(m_SaveInfo.nDataFontSize + 5)); sqlquery.bindValue(":nLineColor",QVariant(ColorToInt(m_SaveInfo.nLineColor))); sqlquery.bindValue(":nTransparent",QVariant(ColorToInt(m_SaveInfo.nTransparent))); sqlquery.bindValue(":nZvalue",QVariant(zValue())); sqlquery.bindValue(":nCollidindId",QVariant(index)); sqlquery.bindValue(":nShowPropId",QVariant(-1)); bReasult = sqlquery.exec(); qDebug()<<"INSERT INTO recipeDisplay"<<bReasult; QList<QGraphicsItem *> list = childItems(); QString sName = ""; QVector<qreal> vVLine; //用来存垂直线的数据 QVector<qreal> vHLine; //用来存水平线的数据 vVLine.clear(); vHLine.clear(); vVLine.append(rect.x()); vHLine.append(rect.y()); //vTileTex.clear(); foreach(QGraphicsItem *pItem,list) { QPointF pos = pItem->boundingRect().topLeft()+pItem->scenePos(); sName = pItem->data(GROUP_NAME_KEY).toString(); if(sName.contains("VLine")) //垂直线 { vVLine.append(pos.x()); } if(sName.contains("HLine")) //水平线 { vHLine.append(pos.y()); } }
void DynCircleAttr::compile(QSqlDatabase &db, int nSceneId, int &count, int index)//编译的时候保存item到数据库 { count++; QVisableItem::compile(db, nSceneId, count, index); int itemId = count; if(sPro.enableTouch && !sPro.byGroups_T) { //触控受位控制 增一个地址表 count++; } if(sPro.bNotice) { //触控解锁通知到地址 增加一个地址表 count++; } if(sPro.enableVisable && !sPro.byGroups_V) { //显现受位控制 增加一个地址表 count++; } QSqlQuery sqlquery(db); bool result = sqlquery.prepare("INSERT INTO dynamicRound(nItemId,nSceneId,nAlpha," "nCpXpos,nCpYpos,nRadius,nFillColor,nUseFill,nRimColor," "nRimWidth,nUsePosCtrl,mCpXDataAddr,mCpYDataAddr," "mRadiusDataAddr,nUseSizeCtrl,nAreaLp,nAreaTp,nAreaWidth," "nAreaHeight,nAreaColor,nZvalue,nCollidindId,nShowPropId)" "VALUES(:nItemId,:nSceneId,:nAlpha," ":nCpXpos,:nCpYpos,:nRadius,:nFillColor,:nUseFill,:nRimColor," ":nRimWidth,:nUsePosCtrl,:mCpXDataAddr,:mCpYDataAddr," ":mRadiusDataAddr,:nUseSizeCtrl,:nAreaLp,:nAreaTp,:nAreaWidth," ":nAreaHeight,:nAreaColor,:nZvalue,:nCollidindId,:nShowPropId)"); qDebug() << "sqlquery.prepare" << result; int num = count; int temp; short leftCp; short topCp; short width; short height; short radius; sqlquery.bindValue(":nItemId", QVariant(itemId)); //表id sqlquery.bindValue(":nSceneId", QVariant(nSceneId)); //scene id sqlquery.bindValue(":nAlpha", QVariant(m_nAlpha)); //alpha QRectF rect = sceneBoundingRect();//相对场景的坐标及高宽 width = rect.width(); height = rect.height(); leftCp = rect.left() + width/2; topCp = rect.top() + height/2; radius = width < height ? (width/2) : (height/2); sqlquery.bindValue(":nCpXpos", QVariant(leftCp));//left sqlquery.bindValue(":nCpYpos", QVariant(topCp));//top sqlquery.bindValue(":nRadius", QVariant(radius));//radius temp =ColorToInt(m_nFillColor); sqlquery.bindValue(":nFillColor", QVariant(temp));// if(m_bFillColor) { sqlquery.bindValue(":nUseFill", QVariant(1));// } else { sqlquery.bindValue(":nUseFill", QVariant(0));// } temp =ColorToInt(m_nFrameColor); sqlquery.bindValue(":nRimColor", QVariant(temp));// sqlquery.bindValue(":nRimWidth", QVariant(m_nFrameWidth));// if(m_bPosCtrl)//位置控制开 { sqlquery.bindValue(":nUsePosCtrl", QVariant(1));// num++; sqlquery.bindValue(":mCpXDataAddr", QVariant(num));// num++; sqlquery.bindValue(":mCpYDataAddr", QVariant(num));// } else { sqlquery.bindValue(":nUsePosCtrl", QVariant(0));// sqlquery.bindValue(":mCpXDataAddr", QVariant(0));// sqlquery.bindValue(":mCpYDataAddr", QVariant(0));// } if(m_bSizeCtrl) { sqlquery.bindValue(":nUseSizeCtrl", QVariant(1));// num++; sqlquery.bindValue(":mRadiusDataAddr", QVariant(num));// } else { sqlquery.bindValue(":nUseSizeCtrl", QVariant(0));// sqlquery.bindValue(":mRadiusDataAddr", QVariant(0));// } //sqlquery.bindValue(":nAreaLp", QVariant(m_nBeginX));// //sqlquery.bindValue(":nAreaTp", QVariant(m_nBeginY));// //sqlquery.bindValue(":nAreaWidth", QVariant(m_nWidth));// //sqlquery.bindValue(":nAreaHeight", QVariant(m_nHeight));// sqlquery.bindValue(":nAreaLp", QVariant(rect.left()));// sqlquery.bindValue(":nAreaTp", QVariant(rect.top()));// sqlquery.bindValue(":nAreaWidth", QVariant(rect.width()));// sqlquery.bindValue(":nAreaHeight", QVariant(rect.height()));// temp =ColorToInt(m_nBgColor); sqlquery.bindValue(":nAreaColor", QVariant(temp));// sqlquery.bindValue(":nZvalue", QVariant(zValue()));// sqlquery.bindValue(":nCollidindId", QVariant(index));// sqlquery.bindValue(":nShowPropId", QVariant(0));// bool result1 = false; result1 = sqlquery.exec(); qDebug() << "insert table :" << result1 << endl; int id = count; if(m_bPosCtrl)//位置控制开 { count++; //修改地址编译参数 ADDR_PARAMENTS stParams; stParams.id = count; stParams.itemId = itemId; stParams.eType = OBJ_ITEM; stParams.eRWtype = SCENE_CONTROL_LOOP_R; stParams.addrNum = -1; m_addrH.compile(db, stParams); //m_addrH.compile(db, count, 0, OBJ_ITEM); count++; //修改地址编译参数 //ADDR_PARAMENTS stParams; stParams.id = count; stParams.itemId = itemId; stParams.eType = OBJ_ITEM; stParams.eRWtype = SCENE_CONTROL_LOOP_R; stParams.addrNum = -1; m_addrV.compile(db, stParams); //m_addrV.compile(db, count, 0, OBJ_ITEM); } if(m_bSizeCtrl) { count++; //修改地址编译参数 ADDR_PARAMENTS stParams; stParams.id = count; stParams.itemId = itemId; stParams.eType = OBJ_ITEM; stParams.eRWtype = SCENE_CONTROL_LOOP_R; stParams.addrNum = -1; m_addrCircle.compile(db, stParams); //m_addrCircle.compile(db, count, 0, OBJ_ITEM); } }