void GMap::generate(int dW, int dH) { // Generate slots for(int mX = 0; mX < alignX(dW); mX++) { // X int gX = cameraX(alignX(dW)) + mX; for(int mY = 0; mY < alignY(dH); mY++) { // Y int gY = cameraY(alignY(dH)) + mY; // Generate if( slot.find(gX) == slot.end() || slot[gX].find(gY) == slot[gX].end() ) { slot[gX][gY] = generateSlot(); } } } }
CQGnuPlotDataDialog:: CQGnuPlotDataDialog(CQGnuPlotMainWindow *window, const CGnuPlotFile &file) : window_(window) { setWindowTitle("Data Dialog"); setObjectName("dataDialog"); enum_ = new CQGnuPlotEnum; enum_->setPlotStyle(CQGnuPlotEnum::PlotLinesPoints); QVBoxLayout *layout = new QVBoxLayout(this); layout->setMargin(2); layout->setSpacing(2); //------ QGroupBox *loadGroup = new QGroupBox("File Data"); QVBoxLayout *loadLayout = new QVBoxLayout(loadGroup); loadLayout->setMargin(2); loadLayout->setSpacing(2); layout->addWidget(loadGroup); //-- QHBoxLayout *fileLayout = new QHBoxLayout; fileLayout->setMargin(2); fileLayout->setSpacing(2); fileEdit_ = new CQGnuPlotFilename; fileEdit_->setName(file.fileName().c_str()); fileEdit_->setPattern("Text (*.txt);; CSV (*.csv);; File (*.*);; All (*)"); QPushButton *loadButton = new QPushButton("Load"); connect(loadButton, SIGNAL(clicked()), this, SLOT(loadSlot())); fileLayout->addWidget(new QLabel("File")); fileLayout->addWidget(fileEdit_); fileLayout->addWidget(loadButton); loadLayout->addLayout(fileLayout); //------ QHBoxLayout *numberLayout = new QHBoxLayout; numberLayout->setMargin(2); numberLayout->setSpacing(2); numberEdit_ = new CQIntegerSpin; numberEdit_->setValue(100); QPushButton *generateButton = new QPushButton("Generate"); connect(generateButton, SIGNAL(clicked()), this, SLOT(generateSlot())); numberLayout->addWidget(generateButton); numberLayout->addWidget(numberEdit_); numberLayout->addWidget(new QLabel("Points")); numberLayout->addStretch(1); loadLayout->addLayout(numberLayout); //------ QHBoxLayout *formatLayout = new QHBoxLayout; formatLayout->setMargin(2); formatLayout->setSpacing(2); formatLayout->addWidget(csvCheck_ = new QCheckBox("CSV")); formatLayout->addWidget(headerCheck_ = new QCheckBox("Header")); formatLayout->addStretch(1); loadLayout->addLayout(formatLayout); //------ QHBoxLayout *separatorLayout = new QHBoxLayout; separatorLayout->setMargin(2); separatorLayout->setSpacing(2); separatorLayout->addWidget(new QLabel("Separator")); separatorLayout->addWidget(separatorEdit_ = new QLineEdit); separatorLayout->addStretch(1); loadLayout->addLayout(separatorLayout); char sepChar = file.separator(); std::string sepStr(&sepChar, 1); separatorEdit_->setText(sepStr.c_str()); //------ QHBoxLayout *missingLayout = new QHBoxLayout; missingLayout->setMargin(2); missingLayout->setSpacing(2); missingLayout->addWidget(new QLabel("Missing")); missingLayout->addWidget(missingEdit_ = new QLineEdit); missingLayout->addStretch(1); loadLayout->addLayout(missingLayout); missingEdit_->setText(file.missingStr().c_str()); //------ tree_ = new CQGnuPlotDataTree(file); layout->addWidget(tree_); //------ QGroupBox *filterGroup = new QGroupBox("Filter Data"); QVBoxLayout *filterLayout = new QVBoxLayout(filterGroup); filterLayout->setMargin(2); filterLayout->setSpacing(2); layout->addWidget(filterGroup); //-- QHBoxLayout *usingLayout = new QHBoxLayout; usingLayout->setMargin(2); usingLayout->setSpacing(2); usingLayout->addWidget(new QLabel("Using")); usingLayout->addWidget(usingEdit_ = new QLineEdit); filterLayout->addLayout(usingLayout); usingEdit_->setText(window_->qapp()->usingString().c_str()); //-- QHBoxLayout *indexLayout = new QHBoxLayout; indexLayout->setMargin(2); indexLayout->setSpacing(2); indexLayout->addWidget(new QLabel("Index")); indexLayout->addWidget(indexEdit_ = new QLineEdit); filterLayout->addLayout(indexLayout); //-- QHBoxLayout *everyLayout = new QHBoxLayout; everyLayout->setMargin(2); everyLayout->setSpacing(2); everyLayout->addWidget(new QLabel("Every")); everyLayout->addWidget(everyEdit_ = new QLineEdit); filterLayout->addLayout(everyLayout); //-- QHBoxLayout *whereLayout = new QHBoxLayout; whereLayout->setMargin(2); whereLayout->setSpacing(2); whereLayout->addWidget(new QLabel("Where")); whereLayout->addWidget(whereEdit_ = new QLineEdit); filterLayout->addLayout(whereLayout); //-- QHBoxLayout *filterOptionsLayout = new QHBoxLayout; filterOptionsLayout->setMargin(2); filterOptionsLayout->setSpacing(2); filterOptionsLayout->addWidget(averageCheck_ = new QCheckBox("Average")); filterOptionsLayout->addWidget(summedCheck_ = new QCheckBox("Summed" )); filterOptionsLayout->addStretch(1); filterLayout->addLayout(filterOptionsLayout); //------ QGroupBox *plotGroup = new QGroupBox("Plot Style"); QVBoxLayout *plotPlayout = new QVBoxLayout(plotGroup); plotPlayout->setMargin(2); plotPlayout->setSpacing(2); layout->addWidget(plotGroup); //-- enum_->setPlotStyle(CQGnuPlotEnum::plotStyleConv(window_->qapp()->plotStyle())); QHBoxLayout *styleLayout = new QHBoxLayout; styleLayout->setMargin(2); styleLayout->setSpacing(2); CQEnumCombo *styleCombo = new CQEnumCombo(this, enum_, "plotStyle"); styleLayout->addWidget(new QLabel("Style")); styleLayout->addWidget(styleCombo); styleLayout->addStretch(1); plotPlayout->addLayout(styleLayout); //-- QHBoxLayout *dimensionLayout = new QHBoxLayout; dimensionLayout->setMargin(2); dimensionLayout->setSpacing(2); dimensionLayout->addWidget(new QLabel("Dimension")); dimensionLayout->addWidget(dimension2DRadio_ = new QRadioButton("2D")); dimensionLayout->addWidget(dimension3DRadio_ = new QRadioButton("3D")); dimensionLayout->addStretch(1); dimension2DRadio_->setChecked(true); plotPlayout->addLayout(dimensionLayout); //-- QHBoxLayout *lineStyleLayout = new QHBoxLayout; lineStyleLayout->setMargin(2); lineStyleLayout->setSpacing(2); lineStyleLayout->addWidget(new QLabel("Line Style")); lineStyleLayout->addWidget(lineTypeEdit_ = new CQIntegerSpin); lineStyleLayout->addStretch(1); lineTypeEdit_->setValue(-1); plotPlayout->addLayout(lineStyleLayout); //-- QHBoxLayout *plotButtonsLayout = new QHBoxLayout; plotButtonsLayout->setMargin(2); plotButtonsLayout->setSpacing(2); QPushButton *filterButton = new QPushButton("Filter"); QPushButton *overlayPlotButton = new QPushButton("Overlay Plot"); QPushButton *addPlotButton = new QPushButton("Add Plot"); connect(filterButton , SIGNAL(clicked()), this, SLOT(filterSlot())); connect(overlayPlotButton, SIGNAL(clicked()), this, SLOT(overlayPlotSlot())); connect(addPlotButton , SIGNAL(clicked()), this, SLOT(addPlotSlot())); plotButtonsLayout->addWidget(filterButton); plotButtonsLayout->addWidget(overlayPlotButton); plotButtonsLayout->addWidget(addPlotButton); plotButtonsLayout->addStretch(1); layout->addLayout(plotButtonsLayout); //--- QHBoxLayout *buttonLayout = new QHBoxLayout; buttonLayout->setMargin(2); buttonLayout->setSpacing(2); buttonLayout->addStretch(1); QPushButton *closeButton = new QPushButton("Close"); buttonLayout->addWidget(closeButton); connect(closeButton, SIGNAL(clicked()), this, SLOT(closeSlot())); layout->addLayout(buttonLayout); }
/** * Build and returns a new Armature instance. * @example * <listing> * var armature:Armature = factory.buildArmature('dragon'); * </listing> * @param armatureName The name of this Armature instance. * @param The name of this animation * @param The name of this SkeletonData. * @param The name of this textureAtlas. * @param The name of this skin. * @return A Armature instance. */ Armature* BaseFactory::buildArmature(const String &armatureName, const String &animationName, const String &skeletonName, const String &textureAtlasName, const String &skinName) { ArmatureData* armatureData = 0; SkeletonData *data = 0; if(!skeletonName.empty()) { std::map<String , SkeletonData*>::iterator iter = _dataDic.find(skeletonName); if(iter != _dataDic.end()) { data = iter->second; armatureData = data->getArmatureData(armatureName); } } //else //{ // for(skeletonName in _dataDic) // { // data = _dataDic[skeletonName]; // armatureData = data->getArmatureData(armatureName); // if(armatureData) // { // break; // } // } //} if(!armatureData) { return nullptr; } _currentDataName = skeletonName; _currentTextureAtlasName = textureAtlasName.empty() ? skeletonName : textureAtlasName; Armature* armature = generateArmature(); armature->name = armatureName; Bone* bone; for(size_t i = 0 ; i < armatureData->boneDataList.size() ; i ++) { BoneData* boneData = armatureData->boneDataList[i]; bone = new Bone(); bone->name = boneData->name; bone->fixedRotation = boneData->fixedRotation; bone->scaleMode = boneData->scaleMode; bone->origin = boneData->transform; if(armatureData->getBoneData(boneData->parent)) { armature->addBone(bone, boneData->parent); } else { armature->addBone(bone); } } ArmatureData* animationArmatureData = 0; SkinData *skinDataCopy = 0; if(!animationName.empty() && animationName != armatureName) { //ArmatureData* animationArmatureData = data->getArmatureData(animationName); // Get the default animation //if(!animationArmatureData) //{ // for (skeletonName in _dataDic) // { // data = _dataDic[skeletonName]; // animationArmatureData = data->getArmatureData(animationName); // if(animationArmatureData) // { // break; // } // } //} ArmatureData* armatureDataCopy = data->getArmatureData(animationName); if(armatureDataCopy) { skinDataCopy = armatureDataCopy->getSkinData(""); } } if(animationArmatureData) { armature->getAnimation()->setAnimationDataList(animationArmatureData->animationDataList); } else { armature->getAnimation()->setAnimationDataList(armatureData->animationDataList); } SkinData* skinData = armatureData->getSkinData(skinName); if(!skinData) { return nullptr; //throw new ArgumentError(); } Slot* slot; DisplayData* displayData; Armature* childArmature; size_t i; //var helpArray:Array = []; for(size_t j = 0 ; j < skinData->slotDataList.size() ; j ++) { SlotData* slotData = skinData->slotDataList[j]; bone = armature->getBone(slotData->parent); if(!bone) { continue; } slot = generateSlot(); slot->name = slotData->name; slot->setBlendMode(slotData->blendMode); slot->_originZOrder = slotData->zOrder; slot->_dislayDataList = slotData->displayDataList; std::vector<Object*> helpArray; i = slotData->displayDataList.size(); helpArray.resize(i); while(i --) { displayData = slotData->displayDataList[i]; if(displayData->type == DisplayData::ARMATURE) { DisplayData* displayDataCopy = 0; if(skinDataCopy) { SlotData* slotDataCopy = skinDataCopy->getSlotData(slotData->name); if(slotDataCopy) { displayDataCopy = slotDataCopy->displayDataList[i]; } } else { displayDataCopy = 0; } childArmature = buildArmature(displayData->name, displayDataCopy?displayDataCopy->name:"", _currentDataName, _currentTextureAtlasName); if(childArmature) { helpArray[i] = childArmature; } //fix by Wayne Dimart: // break; we don't use break here, or will crach the program due to incomplete helpArray. continue; } else { helpArray[i] = generateDisplay(getTextureAtlas(_currentTextureAtlasName), displayData->name, displayData->pivot.x, displayData->pivot.y); } } slot->setDisplayList(helpArray); slot->changeDisplay(0); bone->addChild(slot); } // i = armature->_boneList.size(); while(i --) { armature->_boneList[i]->update(); } i = armature->_slotList.size(); while(i --) { slot = armature->_slotList[i]; slot->update(); } armature->updateSlotsZOrder(); return armature; }
void GMapHome::generate(int dW, int dH) { // Generate home // Set // Width int hWidth = 10 + randi(10); // Height int hHeight = hWidth/2; // Create clear slots for(int mX = -hWidth; mX < alignX(dW) + hWidth*2; mX++) { // X int x = cameraX(alignX(dW)) + mX; for(int mY = -hHeight; mY < alignY(dH) + hHeight*2; mY++) { // Y int y = cameraY(alignY(dH)) + mY; // Create slot[x][y] = new GMapSlot(); } } // Home coords const int homeX = -hWidth/2; const int homeY = -hHeight/2; // Generate // Home for(int mX = -hWidth/2; mX < hWidth/2; mX++) { for(int mY = -hHeight/2; mY < hHeight/2; mY++) { slot[mX][mY] = generateSlot(); } } // Walls // Up / Down for(int mX = -hWidth/2; mX <= hWidth/2; mX++) { // Wall slot[mX][-hHeight/2] = &gMapSlotWall; slot[mX][hHeight/2] = &gMapSlotWall; } // Left / Right for(int mY = -hHeight/2; mY <= hHeight/2; mY++) { // Wall slot[-hWidth/2][mY] = &gMapSlotWall; slot[hWidth/2][mY] = &gMapSlotWall; } // Door // Select angle (left up / right down) // Left Up int angleX = homeX; int angleY = homeY; bool leftUp = true; // Right down if(luck(50.0f)) { angleX *= -1; angleY *= -1; leftUp = false; } // Get indent int indentX = 1+randi(hWidth-2); int indentY = 1+randi(hHeight-2); if(!leftUp) { indentX *= -1; indentY *= -1; } // Set int doorX = angleX + indentX; int doorY = angleY + indentY; if(luck(50.0f)) { slot[homeX][doorY] = &gMapSlotDoor; doorX = angleX; } else { slot[doorX][homeY] = &gMapSlotDoor; doorY = angleY; } // Set player coords // Get int playerX_ = getPlayerX(); int playerY_ = getPlayerY(); if(leftUp) { if(angleX == doorX) { playerX_ = doorX+1; playerY_ = doorY; } else if(angleY == doorY) { playerY_ = doorY+1; playerX_ = doorX; } } else { if(angleX == doorX) { playerX_ = doorX-1; playerY_ = doorY; } else if(angleY == doorY) { playerY_ = doorY-1; playerX_ = doorX; } } // Set setPlayerX(playerX_); setPlayerY(playerY_); // Set free generated slot of player coords GMapSlot *slot_; while(!slot[getPlayerX()][getPlayerY()]->is_free()) { // Generate slot_ = generateSlot(); // Set slot[playerX_][playerY_] = slot_; } // Generated setGenerated(true); }
/** * Generate scez file menu slot function. */ void CreateSceFile::generateCompressedFileSlot() { bool success = false; QString sceFileName = ui->fileLineEdit->text() + "/" + QFileInfo(ui->fileLineEdit->text()).fileName() + ".sce"; ScriptFile fileHelper(this, sceFileName, false); QStringList copiedFiles; if(!isExecutableScriptInFilesTable()) { QMessageBox::information(this, "could not start generation", "No executable script defined."); return; } setEnabled(false); ui->progressBar->setValue(0); ui->progressBar->setMinimum(0); ui->progressBar->setMaximum(ui->filesTableWidget->rowCount() * 2); statusBar()->showMessage("generating scez file", 0); generateSlot(&copiedFiles, ui->progressBar, &success); if(success) { copiedFiles << sceFileName; QString zipFileName = ui->fileLineEdit->text() + ".scez"; (void)fileHelper.deleteFile(zipFileName, false); QList<QStringList> fileList; QString rootDir = QDir(QFileInfo(sceFileName).path()).absolutePath(); for(auto el : copiedFiles) { QStringList entry; entry << el; entry << QFileInfo(el).filePath().remove(0, rootDir.length() + 1); fileList << entry; } success = ScriptFile::zipFiles(zipFileName, fileList, ui->progressBar); if(!success) { (void)QFile::remove(zipFileName); } else { QFile inFile; inFile.setFileName(zipFileName); success = inFile.open(QIODevice::ReadOnly); if(success) { QCryptographicHash hashObject(QCryptographicHash::Sha512); success = hashObject.addData(&inFile); if(success) { inFile.close(); success = inFile.open(QIODevice::Append); if(success) { (void)inFile.seek(inFile.size()); QByteArray hash = hashObject.result(); success = (inFile.write(hash) == hash.length()) ? true : false; } } inFile.close(); } } } //Delete the sce folder. (void)QDir(ui->fileLineEdit->text()).removeRecursively(); if(success) { QMessageBox::information(this, "information", "scez file creation succeeded"); statusBar()->showMessage("scez file created", 5000); } else { statusBar()->showMessage("scez file creation failed", 5000); } setEnabled(true); }
void BaseFactory::buildSlots(Armature *armature, const ArmatureData *armatureData, const SkinData *skinData, const SkinData *skinDataCopy) const { for (size_t i = 0, l = skinData->slotDataList.size(); i < l; ++i) { SlotData *slotData = skinData->slotDataList[i]; Bone *bone = armature->getBone(slotData->parent); if (!bone) { continue; } Slot *slot = generateSlot(slotData); slot->name = slotData->name; slot->_originZOrder = slotData->zOrder; slot->_slotData = slotData; std::vector<std::pair<void*, DisplayType>> displayList; void *frameDisplay = nullptr; for (size_t j = 0, l = slotData->displayDataList.size(); j < l; ++j) { const DisplayData *displayData = slotData->displayDataList[j]; switch (displayData->type) { case DisplayType::DT_ARMATURE: { DisplayData *displayDataCopy = nullptr; if (skinDataCopy) { const SlotData *slotDataCopy = skinDataCopy->getSlotData(slotData->name); if (slotDataCopy) { displayDataCopy = slotDataCopy->displayDataList[i]; } } std::string currentDragonBonesDataName = _currentDragonBonesDataName; std::string currentTextureAtlasName = _currentTextureAtlasName; Armature *childArmature = buildArmature(displayData->name, "", displayDataCopy ? displayDataCopy->name : "", currentDragonBonesDataName, currentTextureAtlasName); displayList.push_back(std::make_pair(childArmature, DisplayType::DT_ARMATURE)); _currentDragonBonesDataName = currentDragonBonesDataName; _currentTextureAtlasName = currentTextureAtlasName; break; } case DisplayType::DT_IMAGE: { void *display = getTextureDisplay(displayData->name, _currentTextureAtlasName, displayData); displayList.push_back(std::make_pair(display, DisplayType::DT_IMAGE)); break; } case DisplayType::DT_FRAME: { //j //frameDisplay = ; break; } default: break; } } bone->addChild(slot); if (!displayList.empty()) { slot->setDisplayList(displayList, false); } } }