--- Vago/trunk/Vago/mainwindow.cpp 2013/04/10 22:01:56 803 +++ Vago/trunk/Vago/mainwindow.cpp 2016/03/13 16:11:45 1031 @@ -57,6 +57,14 @@ MainWindow::MainWindow(QWidget *parent) this->vagoSettings->setValue("AeFolder", aefolder); iniChanged=true; } + if(!this->vagoSettings->contains("WindowWidth")){ + this->vagoSettings->setValue("WindowWidth", GlobalVars::DefaultWindowWidth); + iniChanged=true; + } + if(!this->vagoSettings->contains("WindowHeight")){ + this->vagoSettings->setValue("WindowHeight", GlobalVars::DefaultWindowHeight); + iniChanged=true; + } if(!this->vagoSettings->contains("OniWindow")){ this->vagoSettings->setValue("OniWindow", true); iniChanged=true; @@ -69,6 +77,12 @@ MainWindow::MainWindow(QWidget *parent) this->vagoSettings->setValue("ConfirmExit", false); iniChanged=true; } +#ifdef Q_OS_MAC + if(!this->vagoSettings->contains("useYesAsDefaultWhenRemovingItems")){ + this->vagoSettings->setValue("useYesAsDefaultWhenRemovingItems", false); + iniChanged=true; + } +#endif if(iniChanged){ this->vagoSettings->sync(); @@ -79,6 +93,11 @@ MainWindow::MainWindow(QWidget *parent) this->workspaceWizardsLocation=this->workspaceLocation+"/Wizards"; this->AeLocation=this->vagoSettings->value("AeFolder").toString(); this->outputFolder=this->workspaceLocation; + this->startedWindowWidth=this->vagoSettings->value("WindowWidth").toInt(); + this->startedWindowHeight=this->vagoSettings->value("WindowHeight").toInt(); +#ifdef Q_OS_MAC + this->useYesAsDefaultWhenRemovingItems=this->vagoSettings->value("useYesAsDefaultWhenRemovingItems").toBool(); +#endif //Create our workspace if it doesn't exists yet if(!QDir(this->workspaceLocation).exists()){ @@ -92,14 +111,16 @@ MainWindow::MainWindow(QWidget *parent) this->myBar->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Fixed); this->myBar->setMinimumWidth(150); this->myBar->hide(); //hide while not being used + ui->tbAbortConversion->hide(); //hide while not being used - ui->statusBar->addPermanentWidget(myBar); //this adds automatically in right + ui->statusBar->addPermanentWidget(this->myBar); //this adds automatically in right + ui->statusBar->addPermanentWidget(ui->tbAbortConversion); //Initialize list pointers this->listToProccess = new QStringList; //Create a thread for do the conversion in background - this->myConverter = new Converter(this->myLogger,this->listToProccess); + this->myConverter = new Converter(this->AppDir,this->myLogger,this->listToProccess); // User interface ui->mainToolBar->addWidget(ui->tbAE); //add ae installer launch button @@ -114,7 +135,7 @@ MainWindow::MainWindow(QWidget *parent) setConverterButtonsSize(); -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC // setUnifiedTitleAndToolBarOnMac(true); // Qt suggests to use it on mac | http://www.slideshare.net/qtbynokia/how-to-make-your-qt-app-look-native // align on left doesn't work if active ui->tbOni->setIcon(QIcon(":/new/icons/oni_icon_mac.png")); // Oni executable on mac have a different icon than windows // Set mac platform the first one in the menu, and also make it checkable by default @@ -122,19 +143,21 @@ MainWindow::MainWindow(QWidget *parent) ui->menuTarget_Platform->addAction(ui->actionWindows); ui->actionWindows->setChecked(false); ui->actionMac_Windows_demo->setChecked(true); - resize(800,600); // Mac OS pcs should be able to render this resolution without any problem. It's also better - // because the components on mac use more space + // resize(800,600); // Mac OS pcs should be able to render this resolution without any problem. It's also better + //// because the components on mac use more space #else - resize(640,480); + //resize(640,480); // windows stuff #endif + resize(this->startedWindowWidth,this->startedWindowHeight); + connectSlots(); //Commands Mapping this->commandMap = QHash(); mapCommands(); - updateItemsLoaded(ui->twSourcesGeneral); + updateItemsLoaded(ui->twSourcesXML); this->myLogger->writeString("Application started."); } @@ -176,7 +199,7 @@ void MainWindow::on_tbOni_clicked() if(this->vagoSettings->value("OniWindow").toBool()){ // Run in a window? arguments << "-noswitch"; } -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN else{ arguments << "-switch"; // only supported on windows. Was added by daodan dll. } @@ -203,6 +226,13 @@ void MainWindow::on_tbOpenFolder_clicked QDesktopServices::openUrl(QUrl("file:///"+this->outputFolder)); } +void MainWindow::on_tbAbortConversion_clicked() +{ + if(Util::showQuestionPopUp(this,"Are you sure you want to abort the current conversion?")){ + emit terminateCurrProcess(); + } +} + void MainWindow::on_cbEnvMap_toggled(bool checked) { ui->leEnvMapTexture->setEnabled(checked); @@ -218,19 +248,9 @@ void MainWindow::on_cbWithAnimation_togg ui->leAnimationName->setEnabled(checked); } -void MainWindow::on_cbCamera_toggled(bool checked) +void MainWindow::on_cbSpecificFilesLevels_toggled(bool checked) { - if(checked){ - ui->cbGeometry->setChecked(false); - } -} - -void MainWindow::on_cbGeometry_toggled(bool checked) -{ - ui->leGeometryName->setEnabled(checked); - if(checked){ - ui->cbCamera->setChecked(false); - } + ui->leSpecificFilesLevels->setEnabled(checked); } void MainWindow::on_actionCheck_For_Updates_triggered() @@ -269,14 +289,9 @@ void MainWindow::checkVagoLastVersion(QN result->deleteLater(); } -void MainWindow::on_pbAddSourceGeneral_clicked() +void MainWindow::on_pbAddSourceXML_clicked() { - if(QString::compare(ui->cbFromGeneral->currentText(),"ONI",Qt::CaseSensitive)==0 && QString::compare(ui->cbToGeneral->currentText(),"DAT",Qt::CaseSensitive)==0){ //CaseSensitive is faster) - addFilesSource(ui->twSourcesGeneral,Util::multipleDirDialog("Choose folders with ONIs...")); - } - else{ - addFilesSource( ui->twSourcesGeneral,QFileDialog::getOpenFileNames(this,"Choose the files...","./" , "All Files (*.*)")); - } + addFilesSource( ui->twSourcesXML,QFileDialog::getOpenFileNames(this,"Choose the files...","./" , "All Files (*.*)")); } void MainWindow::on_pbAddSourceTextures_clicked() @@ -284,19 +299,24 @@ void MainWindow::on_pbAddSourceTextures_ addFilesSource( ui->twSourcesTextures, QFileDialog::getOpenFileNames(this,"Choose the files...","./" , "All Files (*.*)")); } -void MainWindow::on_pbAddSourceModels_clicked() +void MainWindow::on_pbAddSourceObjects_clicked() { - addFilesSource( ui->twSourcesModels,QFileDialog::getOpenFileNames(this,"Choose the files...","./" , "All Files (*.*)")); + addFilesSource( ui->twSourcesObjects,QFileDialog::getOpenFileNames(this,"Choose the files...","./" , "All Files (*.*)")); } -void MainWindow::on_pbAddSourceAnimations_clicked() +void MainWindow::on_pbAddSourceCharacters_clicked() { - addFilesSource( ui->twSourcesAnimations,QFileDialog::getOpenFileNames(this,"Choose the files...","./" , "All Files (*.*)")); + addFilesSource( ui->twSourcesCharacters,QFileDialog::getOpenFileNames(this,"Choose the files...","./" , "All Files (*.*)")); } void MainWindow::on_pbAddSourceLevels_clicked() { - addFilesSource( ui->twSourcesLevels,QFileDialog::getOpenFileNames(this,"Choose the files...","./" , "All Files (*.*)")); + if(QString::compare(ui->cbFromXML->currentText(),"ONI FILES",Qt::CaseSensitive)==0 && QString::compare(ui->cbToXML->currentText(),"DAT",Qt::CaseSensitive)==0){ //CaseSensitive is faster) + addFilesSource(ui->twSourcesLevels,Util::multipleDirDialog("Choose folders with ONIs...")); + } + else{ + addFilesSource(ui->twSourcesLevels,QFileDialog::getOpenFileNames(this,"Choose the files...","./" , "All Files (*.*)")); + } } void MainWindow::on_pbAddSourceMisc_clicked() @@ -328,7 +348,7 @@ void MainWindow::addFilesSource(DropTabl to = QString(fromTo).remove(0,fromTo.lastIndexOf("> ")+2); //+2 to start after "> " //Pre-processing (check if the files/folders received are valid), e.g. check for ONI->DAT if are only given folders and not files - if(QString::compare(from,"ONI",Qt::CaseSensitive)==0 && QString::compare(to,"DAT",Qt::CaseSensitive)==0){ + if(from=="ONI FILES" && to=="DAT"){ //check if it's a folder foreach(QString myFile, files){ if(!QDir(myFile).exists()){ @@ -380,87 +400,60 @@ void MainWindow::addFilesSource(DropTabl updateItemsLoaded(myTable); } -QString MainWindow::fileParsingGeneral(QString myOutputFolder, QString from, QString to , QString file){ +QString MainWindow::fileParsingXML(QString tabTitle, QString myOutputFolder, QString from, QString to , QString file){ QString command; - if(QString::compare(from,"ONI",Qt::CaseSensitive)==0 && QString::compare(to,"DAT",Qt::CaseSensitive)==0){ //CaseSensitive is faster - - QString datName; - - if(ui->cbDatGeneral->isChecked()){ - if(ui->leTargetDatGeneral->text().isEmpty()){ - showErrStatusMessage("Checkbox '"+ui->cbDatGeneral->text()+"' is selected. The name cannot be empty."); - return ""; - } - datName+=QString(myOutputFolder).insert(myOutputFolder.size()-1,ui->leTargetDatGeneral->text()); //set name inputted by user - if(!ui->leTargetDatGeneral->text().toUpper().endsWith(".DAT")){ - datName.insert(datName.size()-1,".dat"); //append extension if necessary (-1 to maintain final quote) - } - } - else{ - datName=QString(myOutputFolder).insert(myOutputFolder.size()-1,Util::cutName(file).remove("/")+".dat"); //if none iputted set the same name of input file - } - - if(ui->actionWindows->isChecked()){ //is target plataform select windows? - return command=this->commandMap.value("general->"+from+"->"+to+"(PC)")+" "+ file + " "+datName; - } - else{ - return command=this->commandMap.value("general->"+from+"->"+to+"(demoPCMAC)")+" "+ file + " "+datName; - } - } - else if(QString::compare(from,"ONI",Qt::CaseSensitive)==0 && QString::compare(to,"XML",Qt::CaseSensitive)==0 && ui->cbTRAMGeneral->isChecked()){ - if(ui->leTRAMGeneral->text().isEmpty()){ - showErrStatusMessage("Checkbox '"+ui->cbTRAMGeneral->text()+"' is selected. The source cannot be empty."); - return ""; - } - return command=this->commandMap.value("general->"+from+"->"+to)+" "+myOutputFolder+" "+this->commandMap.value("general->"+ui->cbTRAMGeneral->text())+file + " "+ Util::normalizeAndQuote(ui->leTRAMGeneral->text()); + if(from=="ONI" && to=="XML"){ + return command=this->commandMap.value(tabTitle+"->"+from+"->"+to)+" "+myOutputFolder+" "+file; } - else{ - return command=this->commandMap.value("general->"+from+"->"+to)+" "+myOutputFolder+" "+file; + else if(from=="XML" && to=="ONI"){ + return command=this->commandMap.value(tabTitle+"->"+from+"->"+to)+" "+myOutputFolder+" "+file; } + return ""; + } -QString MainWindow::fileParsingTextures(QString myOutputFolder, QString from, QString to , QString file){ +QString MainWindow::fileParsingTextures(QString tabTitle, QString myOutputFolder, QString from, QString to , QString file){ - QString command=this->commandMap.value("textures->"+from+"->"+to)+" "+myOutputFolder; + QString command=this->commandMap.value(tabTitle+"->"+from+"->"+to)+" "+myOutputFolder; if(ui->gbTextures->isEnabled()){ //faster than compare strings (if is DAT/ONI) if(ui->cbMipMapsTextures->isChecked()){ - command+=" "+this->commandMap.value("textures->"+ui->cbMipMapsTextures->text()); + command+=" "+this->commandMap.value(tabTitle+"->"+ui->cbMipMapsTextures->text()); } if(ui->cbNoUwrap->isChecked()){ - command+=" "+this->commandMap.value("textures->"+ui->cbNoUwrap->text()); + command+=" "+this->commandMap.value(tabTitle+"->"+ui->cbNoUwrap->text()); } if(ui->cbNoVwrap->isChecked()){ - command+=" "+this->commandMap.value("textures->"+ui->cbNoVwrap->text()); + command+=" "+this->commandMap.value(tabTitle+"->"+ui->cbNoVwrap->text()); } if(ui->cbLarge->isChecked()){ - command+=" "+this->commandMap.value("textures->"+ui->cbLarge->text()); + command+=" "+this->commandMap.value(tabTitle+"->"+ui->cbLarge->text()); } if(ui->rbBGR32->isChecked()){ - command+=" "+this->commandMap.value("textures->"+ui->rbBGR32->text()); + command+=" "+this->commandMap.value(tabTitle+"->"+ui->rbBGR32->text()); } else if(ui->rbBGRA32->isChecked()){ - command+=" "+this->commandMap.value("textures->"+ui->rbBGRA32->text()); + command+=" "+this->commandMap.value(tabTitle+"->"+ui->rbBGRA32->text()); } else if(ui->rbBGR555->isChecked()){ - command+=" "+this->commandMap.value("textures->"+ui->rbBGR555->text()); + command+=" "+this->commandMap.value(tabTitle+"->"+ui->rbBGR555->text()); } else if(ui->rbBGRA5551->isChecked()){ - command+=" "+this->commandMap.value("textures->"+ui->rbBGRA5551->text()); + command+=" "+this->commandMap.value(tabTitle+"->"+ui->rbBGRA5551->text()); } else if(ui->rbBGRA444->isChecked()){ - command+=" "+this->commandMap.value("textures->"+ui->rbBGRA444->text()); + command+=" "+this->commandMap.value(tabTitle+"->"+ui->rbBGRA444->text()); } else{ //dxt1 checked - command+=" "+this->commandMap.value("textures->"+ui->rbDxt1->text()); + command+=" "+this->commandMap.value(tabTitle+"->"+ui->rbDxt1->text()); } if(ui->cbEnvMap->isChecked()){ @@ -468,75 +461,101 @@ QString MainWindow::fileParsingTextures( showErrStatusMessage("Checkbox '"+ui->cbEnvMap->text()+"' is selected. The name texture name cannot be empty."); return ""; } - command+=" "+this->commandMap.value("textures->"+ui->cbEnvMap->text()) + ui->leEnvMapTexture->text().remove(".oni",Qt::CaseInsensitive); + command+=" "+this->commandMap.value(tabTitle+"->"+ui->cbEnvMap->text()) + ui->leEnvMapTexture->text().remove(".oni",Qt::CaseInsensitive); } } return command+=" "+file; //add source } -QString MainWindow::fileParsingModels(QString myOutputFolder, QString from, QString to , QString file){ +QString MainWindow::fileParsingCharacters(QString tabTitle, QString myOutputFolder, QString from, QString to , QString file){ - QString command=this->commandMap.value("models->"+from+"->"+to)+" "+myOutputFolder; + QString command=this->commandMap.value(tabTitle+"->"+from+"->"+to)+" "+myOutputFolder + " " + file ; - //TODO: This can be optimized. When some are not enable others are. - if(ui->cbTexture->isChecked()){ - if(ui->leTextureName->text().isEmpty()){ - showErrStatusMessage("Checkbox '"+ui->cbTexture->text()+"' is selected. The name cannot be empty."); - return ""; - } - command+=" "+this->commandMap.value("models->"+ui->cbTexture->text()) + ui->leTextureName->text().remove(".oni",Qt::CaseInsensitive); - } if(ui->cbCellShading->isChecked()){ - command+=" "+this->commandMap.value("models->"+ui->cbCellShading->text()); + command+=" "+this->commandMap.value(tabTitle+"->"+ui->cbCellShading->text()); } if(ui->cbNormals->isChecked()){ - command+=" "+this->commandMap.value("models->"+ui->cbNormals->text()); + command+=" "+this->commandMap.value(tabTitle+"->"+ui->cbNormals->text()); } - if(ui->cbWithAnimation->isEnabled()){ - if(ui->cbWithAnimation->isChecked()){ - command+=" "+this->commandMap.value("models->"+ui->cbWithAnimation->text())+ui->leAnimationName->text().remove(".oni",Qt::CaseInsensitive); - } - else{ - command+=" "+this->commandMap.value("models->No Animation"); + if(ui->cbWithTRBS_ONCC->isChecked()){ + if(ui->leTRBS_ONCC->text().isEmpty()){ + showErrStatusMessage("Checkbox '"+ui->cbWithTRBS_ONCC->text()+"' is selected. The name cannot be empty."); + return ""; } - } + command+=" "+this->commandMap.value(tabTitle+"->"+ui->cbWithTRBS_ONCC->text())+Util::normalizeAndQuote(ui->leTRBS_ONCC->text()); + } - return command+=" "+file; //add source + return command; } -QString MainWindow::fileParsingAnimations(QString myOutputFolder, QString from, QString to , QString file){ - QString command=this->commandMap.value("animations->"+from+"->"+to)+" "+myOutputFolder + " " + file ; +QString MainWindow::fileParsingObjects(QString tabTitle, QString myOutputFolder, QString from, QString to , QString file){ + + QString command=this->commandMap.value(tabTitle+"->"+from+"->"+to)+" "+myOutputFolder; - if(ui->cbCamera->isChecked()){ - command+=" "+this->commandMap.value("animations->"+ui->cbCamera->text()); + //TODO: This can be optimized. When some are not enable others are. + if(ui->cbTexture->isChecked()){ + if(ui->leTextureName->text().isEmpty()){ + showErrStatusMessage("Checkbox '"+ui->cbTexture->text()+"' is selected. The file source cannot be empty."); + return ""; + } + command+=" "+this->commandMap.value(tabTitle+"->"+ui->cbTexture->text()) + ui->leTextureName->text(); } - else if(ui->cbGeometry->isChecked()){ - if(ui->leGeometryName->text().isEmpty()){ - showErrStatusMessage("Checkbox '"+ui->cbGeometry->text()+"' is selected. The geometry file path cannot be empty."); + else if(ui->cbWithAnimation->isChecked()){ + if(ui->leAnimationName->text().isEmpty()){ + showErrStatusMessage("Checkbox '"+ui->cbWithAnimation->text()+"' is selected. The file source cannot be empty."); return ""; } - command+=" "+this->commandMap.value("animations->"+ui->cbGeometry->text()) + (ui->leGeometryName->text().startsWith('"')?ui->leGeometryName->text():Util::insertQuotes(ui->leGeometryName->text())); + command+=" "+Util::normalizeAndQuote(ui->leAnimationName->text()) + " " + this->commandMap.value(tabTitle+"->"+ui->cbWithAnimation->text()) + file; + return command; } - return command; + if(from=="OBAN ONI (cam)"){ + command+=" -geom:camera"; + } + + return command+=" "+file; //add source } -QString MainWindow::fileParsingLevels(QString myOutputFolder, QString from, QString to , QString file){ +QString MainWindow::fileParsingLevels(QString tabTitle, QString myOutputFolder, QString from, QString to , QString file){ QString datName, command; - command=this->commandMap.value("levels->"+from+"->"+to)+" "+myOutputFolder+" "+file; + if(!(from=="ONI FILES" && to=="DAT")){ // to all except this one + + command=this->commandMap.value(tabTitle+"->"+from+"->"+to); + + if(ui->cbSpecificFilesLevels->isChecked()){ + + if(ui->leSpecificFilesLevels->text().isEmpty()){ + showErrStatusMessage("Checkbox '"+ui->cbSpecificFilesLevels->text()+"' is selected. The files pattern cannot be empty."); + return ""; + } + + command+=":"+ui->leSpecificFilesLevels->text(); + } + + if(from=="DAT" && to=="ONI FILES"){ // extract files to a subdir with the files name ex: level0_Final + command += " " + myOutputFolder.insert(myOutputFolder.size()-2,QString(Util::cutName(file)).replace(".dat","")) + " " + file; + } + else{ + command+=" "+myOutputFolder+" "+file; + } - if(from=="MASTER XML" && to=="DAT"){ - command+=GlobalVars::OniSplitProcSeparator; //insert mark so we know this action will take 2 commands + } + if((from=="ONI FILES" || from=="MASTER XML") && to=="DAT"){ // almost the same command for both QString datName; + + if(from=="MASTER XML"){ + command+=GlobalVars::OniSplitProcSeparator; //insert mark so we know this action will take 2 commands + } + if(ui->cbDatLevels->isChecked()){ if(ui->leTargetDatLevels->text().isEmpty()){ showErrStatusMessage("Checkbox '"+ui->cbDatLevels->text()+"' is selected. The name cannot be empty."); @@ -548,14 +567,28 @@ QString MainWindow::fileParsingLevels(QS } } else{ - datName=QString(myOutputFolder).insert(myOutputFolder.size()-1,Util::cutName(file).remove("/").replace(".xml",".dat",Qt::CaseInsensitive)); //if none iputted set the same name of input file + if(from=="ONI FILES"){ + datName=QString(myOutputFolder).insert(myOutputFolder.size()-1,Util::cutName(file).remove("/")+".dat"); //if none iputted set the same name of input file + } + else if(from=="MASTER XML"){ + datName=QString(myOutputFolder).insert(myOutputFolder.size()-1,Util::cutName(file).remove("/").replace(".xml",".dat",Qt::CaseInsensitive)); //if none iputted set the same name of input file + } } - - if(ui->actionWindows->isChecked()){ //is target plataform select windows? - command+=this->commandMap.value("general->ONI->"+to+"(PC)")+" "+myOutputFolder+" "+datName; //add second command + if(from=="ONI FILES"){ + if(ui->actionWindows->isChecked()){ //is target plataform select windows? + return command=this->commandMap.value(tabTitle+"->"+from+"->"+to+"(PC)")+" "+ file + " "+datName; + } + else{ + return command=this->commandMap.value(tabTitle+"->"+from+"->"+to+"(demoPCMAC)")+" "+ file + " "+datName; + } } - else{ - command+=this->commandMap.value("general->ONI->"+to+"(demoPCMAC)")+" "+myOutputFolder+" "+datName; //add second command + else if(from=="MASTER XML"){ + if(ui->actionWindows->isChecked()){ //is target plataform select windows? + command+=this->commandMap.value(tabTitle+"->ONI FILES->"+to+"(PC)")+" "+myOutputFolder+" "+datName; //add second command + } + else{ + command+=this->commandMap.value(tabTitle+"->ONI FILES->"+to+"(demoPCMAC)")+" "+myOutputFolder+" "+datName; //add second command + } } } @@ -581,7 +614,7 @@ QString MainWindow::fileParsingLevels(QS //parse all files (separated by spaces) while(true){ - nextIndex=additionalFiles.indexOf(" ",currentIndex+1); + nextIndex=additionalFiles.indexOf(";",currentIndex+1); command += " "+Util::normalizeAndQuote(additionalFiles.mid(currentIndex,(nextIndex-currentIndex))); @@ -593,7 +626,7 @@ QString MainWindow::fileParsingLevels(QS } if(ui->cbGridsLevels->isChecked()){ - command+=GlobalVars::OniSplitProcSeparator+this->commandMap.value("levels->"+ui->cbGridsLevels->text())+" "+Util::normalizeAndQuote(ui->leBnvLevels->text())+" "+file+" -out:"+myOutputFolder; + command+=GlobalVars::OniSplitProcSeparator+this->commandMap.value(tabTitle+"->"+ui->cbGridsLevels->text())+" "+Util::normalizeAndQuote(ui->leBnvLevels->text())+" "+file+" -out:"+myOutputFolder; } return command; @@ -622,9 +655,9 @@ void MainWindow::addRowTable(DropTableWi myTable->updateTableToolTips(twSize); //Update tool tips } -void MainWindow::on_pbConvertGeneral_clicked() +void MainWindow::on_pbConvertXML_clicked() { - startConversion(ui->twSourcesGeneral); + startConversion(ui->twSourcesXML); } void MainWindow::on_pbConvertTextures_clicked() @@ -632,14 +665,14 @@ void MainWindow::on_pbConvertTextures_cl startConversion(ui->twSourcesTextures); } -void MainWindow::on_pbConvertModels_clicked() +void MainWindow::on_pbConvertObjects_clicked() { - startConversion(ui->twSourcesModels); + startConversion(ui->twSourcesObjects); } -void MainWindow::on_pbConvertAnimations_clicked() +void MainWindow::on_pbConvertCharacters_clicked() { - startConversion(ui->twSourcesAnimations); + startConversion(ui->twSourcesCharacters); } void MainWindow::on_pbConvertLevels_clicked() @@ -667,7 +700,7 @@ void MainWindow::startConversion(DropTab return; } - if(myBar->isVisible()){ + if(this->myBar->isVisible()){ Util::showErrorPopUp("Another conversion is progress. Please wait until it finishes."); return; } @@ -686,6 +719,7 @@ void MainWindow::TsetupProgressBar(int m this->myBar->setValue(0); this->myBar->show(); this->myBar->setMaximum(max); + ui->tbAbortConversion->show(); } void MainWindow::TupdateProgressBar(){ @@ -695,6 +729,7 @@ void MainWindow::TupdateProgressBar(){ void MainWindow::TresultConversion(QString result, int numErrors){ QApplication::alert(this); //Show a notification if window is not active this->myBar->hide(); + ui->tbAbortConversion->hide(); if(numErrors!=0){ QString sNumErrors=QString::number(numErrors); @@ -713,6 +748,13 @@ void MainWindow::TresultConversion(QStri } } +void MainWindow::TconversionAborted(){ + this->myBar->hide(); + ui->tbAbortConversion->hide(); + + showErrStatusMessage("Conversion was aborted."); +} + void MainWindow::showErrStatusMessage(QString message){ QPalette myPalete = QPalette(); @@ -732,27 +774,21 @@ void MainWindow::showSuccessStatusMessag } void MainWindow::mapCommands(){ - ////////////////////////////////////////////////////////////////////////General Commands - this->commandMap.insert("general->DAT->ONI","-export"); - //this->commandMap.insert("general->ONI->DAT","-import"); //Not used. - this->commandMap.insert("general->ONI->DAT(PC)","-import:nosep"); - this->commandMap.insert("general->ONI->DAT(demoPCMAC)","-import:sep"); - this->commandMap.insert("general->ONI->XML","-extract:xml"); - this->commandMap.insert("general->XML->ONI","-create"); + ////////////////////////////////////////////////////////////////////////XML Commands + this->commandMap.insert("xml->ONI->XML","-extract:xml"); + this->commandMap.insert("xml->XML->ONI","-create"); //######################General Options - this->commandMap.insert("general->"+ui->cbTRAMGeneral->text(),"-anim-body:"); + //Possible Combinations - this->commandMap.insertMulti("general->DAT","ONI"); - this->commandMap.insertMulti("general->ONI","DAT"); - this->commandMap.insertMulti("general->ONI","XML"); - this->commandMap.insertMulti("general->XML","ONI"); + this->commandMap.insertMulti("xml->ONI","XML"); + this->commandMap.insertMulti("xml->XML","ONI"); ////////////////////////////////////////////////////////////////////////Textures Commands - this->commandMap.insert("textures->DAT / ONI->DDS","-extract:dds"); - this->commandMap.insert("textures->DAT / ONI->TGA","-extract:tga"); - this->commandMap.insert("textures->DAT / ONI->PNG","-extract:png"); - this->commandMap.insert("textures->DAT / ONI->JPG","-extract:jpg"); - this->commandMap.insert("textures->DDS / TGA / PNG / JPG->ONI","-create:txmp"); + this->commandMap.insert("textures->DAT / TXMP ONI->DDS","-extract:dds"); + this->commandMap.insert("textures->DAT / TXMP ONI->TGA","-extract:tga"); + this->commandMap.insert("textures->DAT / TXMP ONI->PNG","-extract:png"); + this->commandMap.insert("textures->DAT / TXMP ONI->JPG","-extract:jpg"); + this->commandMap.insert("textures->TGA / DDS / PNG / JPG->TXMP ONI","-create:txmp"); //######################Textures Options this->commandMap.insert("textures->"+ui->rbBGR32->text(),"-format:bgr32"); this->commandMap.insert("textures->"+ui->rbBGRA32->text(),"-format:bgra32"); @@ -766,73 +802,90 @@ void MainWindow::mapCommands(){ this->commandMap.insert("textures->"+ui->cbLarge->text(),"-large"); this->commandMap.insert("textures->"+ui->cbEnvMap->text(),"-envmap:"); //Possible Combinations - this->commandMap.insertMulti("textures->DAT / ONI","DDS"); - this->commandMap.insertMulti("textures->DAT / ONI","TGA"); - this->commandMap.insertMulti("textures->DAT / ONI","PNG"); - this->commandMap.insertMulti("textures->DAT / ONI","JPG"); - this->commandMap.insertMulti("textures->DDS / TGA / PNG / JPG","ONI"); - - ////////////////////////////////////////////////////////////////////////Models Commands - this->commandMap.insert("models->ONI->OBJ","-extract:obj"); - this->commandMap.insert("models->ONI->DAE","-extract:dae -search "+Util::insertQuotes(this->AeLocation+"/GameDataFolder/level0_Final")); - this->commandMap.insert("models->OBJ->ONI","-create:m3gm"); - this->commandMap.insert("models->DAE->ONI","-create:trbs"); - //######################Models Options - this->commandMap.insert("models->"+ui->cbCellShading->text(),"-cel"); - this->commandMap.insert("models->"+ui->cbNormals->text(),"-normals"); - this->commandMap.insert("models->"+ui->cbTexture->text(),"-tex:"); - this->commandMap.insert("models->"+ui->cbWithAnimation->text(),"-anim:"); - this->commandMap.insert("models->No Animation","-noanim"); //No label with this name so can't be dynamic + this->commandMap.insertMulti("textures->DAT / TXMP ONI","TGA"); + this->commandMap.insertMulti("textures->DAT / TXMP ONI","DDS"); + this->commandMap.insertMulti("textures->DAT / TXMP ONI","PNG"); + this->commandMap.insertMulti("textures->DAT / TXMP ONI","JPG"); + this->commandMap.insertMulti("textures->TGA / DDS / PNG / JPG","TXMP ONI"); + + ////////////////////////////////////////////////////////////////////////Characters Commands + this->commandMap.insert("characters->TRAM ONI->XML / XML & DAE","-extract:xml"); + this->commandMap.insert("characters->TRBS / ONCC ONI->DAE","-extract:dae"); + this->commandMap.insert("characters->TRBS XML->TRBS ONI","-create"); + this->commandMap.insert("characters->TRBS DAE->TRBS ONI","-create:trbs"); + this->commandMap.insert("characters->FILM DAT->XML","film2xml"); + + //######################Characters Options + this->commandMap.insert("characters->"+ui->cbWithTRBS_ONCC->text(),"-anim-body:"); + this->commandMap.insert("characters->"+ui->cbCellShading->text(),"-cel"); + this->commandMap.insert("characters->"+ui->cbNormals->text(),"-normals"); //Possible Combinations - this->commandMap.insertMulti("models->ONI","OBJ"); - this->commandMap.insertMulti("models->ONI","DAE"); - this->commandMap.insertMulti("models->OBJ","ONI"); - this->commandMap.insertMulti("models->DAE","ONI"); - - ////////////////////////////////////////////////////////////////////////Animations Commands - this->commandMap.insert("animations->ONI->DAE","-extract:dae"); - this->commandMap.insert("animations->FILM DAT->XML","film2xml"); - //######################Animations Options - this->commandMap.insert("animations->"+ui->cbCamera->text(),"-geom:camera"); - this->commandMap.insert("animations->"+ui->cbGeometry->text(),"-geom:"); + this->commandMap.insertMulti("characters->TRAM ONI","XML / XML & DAE"); + this->commandMap.insertMulti("characters->TRBS / ONCC ONI","DAE"); + this->commandMap.insertMulti("characters->DAE","TRBS ONI"); + this->commandMap.insertMulti("characters->TRBS DAE","TRBS ONI"); + this->commandMap.insertMulti("characters->TRBS XML","TRBS ONI"); + this->commandMap.insertMulti("characters->FILM DAT","XML"); + + ////////////////////////////////////////////////////////////////////////Objects Commands + this->commandMap.insert("objects->M3GM ONI->OBJ","-extract:obj"); + this->commandMap.insert("objects->M3GM ONI->DAE","-extract:dae"); + this->commandMap.insert("objects->ONWC ONI->OBJ","-extract:obj"); + this->commandMap.insert("objects->ONWC ONI->DAE","-extract:dae"); + this->commandMap.insert("objects->OBAN ONI (cam)->DAE","-extract:dae"); + this->commandMap.insert("objects->OBJ->M3GM ONI","-create:m3gm"); + //######################Characters Options + this->commandMap.insert("objects->"+ui->cbTexture->text(),"-tex:"); + this->commandMap.insert("objects->"+ui->cbWithAnimation->text(),"-geom:"); //Possible Combinations - this->commandMap.insertMulti("animations->ONI","DAE"); - this->commandMap.insertMulti("animations->DAE","ONI"); - this->commandMap.insertMulti("animations->FILM DAT","XML"); + this->commandMap.insertMulti("objects->M3GM ONI","OBJ"); + this->commandMap.insertMulti("objects->M3GM ONI","DAE"); + this->commandMap.insertMulti("objects->ONWC ONI","OBJ"); + this->commandMap.insertMulti("objects->ONWC ONI","DAE"); + this->commandMap.insertMulti("objects->OBAN ONI (cam)","DAE"); + this->commandMap.insertMulti("objects->OBJ","M3GM ONI"); + ////////////////////////////////////////////////////////////////////////Levels Commands - this->commandMap.insert("levels->ONI->DAE","-extract:dae -search "+Util::insertQuotes(this->AeLocation+"/GameDataFolder/level0_Final")); - this->commandMap.insert("levels->DAE->ONI","-create:akev"); + this->commandMap.insert("levels->DAT->ONI FILES","-export"); + //this->commandMap.insert("levels->ONI FILES->DAT","-import"); //Not used. + this->commandMap.insert("levels->ONI FILES->DAT(PC)","-import:nosep"); + this->commandMap.insert("levels->ONI FILES->DAT(demoPCMAC)","-import:sep"); + this->commandMap.insert("levels->AKEV ONI->DAE","-extract:dae"); + this->commandMap.insert("levels->DAE->AKEV ONI","-create:akev"); this->commandMap.insert("levels->MASTER XML->DAT","-create:level"); this->commandMap.insert("levels->MASTER XML->ONI FILES","-create:level"); //######################Levels Options this->commandMap.insert("levels->"+ui->cbGridsLevels->text(),"-grid:create"); //Possible Combinations - this->commandMap.insertMulti("levels->ONI","DAE"); - this->commandMap.insertMulti("levels->DAE","ONI"); + this->commandMap.insertMulti("levels->DAT","ONI FILES"); + this->commandMap.insertMulti("levels->ONI FILES","DAT"); + this->commandMap.insertMulti("levels->AKEV ONI","DAE"); + this->commandMap.insertMulti("levels->DAE","AKEV ONI"); this->commandMap.insertMulti("levels->MASTER XML","DAT"); this->commandMap.insertMulti("levels->MASTER XML","ONI FILES"); ////////////////////////////////////////////////////////////////////////Misc Commands - this->commandMap.insert("misc->DAT / ONI->WAV","-extract:wav"); - this->commandMap.insert("misc->DAT / ONI->AIF","-extract:aif"); - this->commandMap.insert("misc->DAT / ONI->TXT","-extract:txt"); - this->commandMap.insert("misc->WAV / AIF->ONI","-create"); - this->commandMap.insert("misc->TXT->ONI","-create:subt"); + this->commandMap.insert("misc->DAT / SNDD ONI->WAV","-extract:wav"); + this->commandMap.insert("misc->DAT / SNDD ONI->AIF","-extract:aif"); + this->commandMap.insert("misc->DAT / SUBT ONI->TXT","-extract:txt"); + this->commandMap.insert("misc->WAV / AIF->SNDD ONI","-create"); + this->commandMap.insert("misc->TXT->SUBT ONI","-create:subt"); //Possible Combinations - this->commandMap.insertMulti("misc->DAT / ONI","WAV"); - this->commandMap.insertMulti("misc->DAT / ONI","AIF"); - this->commandMap.insertMulti("misc->DAT / ONI","TXT"); - this->commandMap.insertMulti("misc->WAV / AIF","ONI"); - this->commandMap.insertMulti("misc->TXT","ONI"); + this->commandMap.insertMulti("misc->DAT / SNDD ONI","WAV"); + this->commandMap.insertMulti("misc->DAT / SNDD ONI","AIF"); + this->commandMap.insertMulti("misc->DAT / SUBT ONI","TXT"); + this->commandMap.insertMulti("misc->WAV / AIF","SNDD ONI"); + this->commandMap.insertMulti("misc->TXT","SUBT ONI"); } -void MainWindow::on_cbFromGeneral_currentIndexChanged(const QString &arg1) +void MainWindow::on_cbFromXML_currentIndexChanged(const QString &arg1) { - updateComboBox(arg1, ui->cbToGeneral, "general"); + updateComboBox(arg1, ui->cbToXML); } + void MainWindow::on_cbFromTextures_currentIndexChanged(const QString &arg1) { //Options are only used for DAT/ONI -> Image @@ -843,58 +896,82 @@ void MainWindow::on_cbFromTextures_curre ui->gbTextures->setEnabled(true); } - updateComboBox(arg1, ui->cbToTextures, "textures"); + updateComboBox(arg1, ui->cbToTextures); } -void MainWindow::on_cbFromModels_currentIndexChanged(const QString &arg1) +void MainWindow::on_cbFromObjects_currentIndexChanged(const QString &arg1) { - - ui->cbCellShading->setEnabled(false); - ui->cbCellShading->setChecked(false); - ui->cbNormals->setEnabled(false); - ui->cbNormals->setChecked(false); ui->cbTexture->setEnabled(false); ui->cbTexture->setChecked(false); ui->cbWithAnimation->setEnabled(false); ui->cbWithAnimation->setChecked(false); - if(QString::compare(arg1,"OBJ",Qt::CaseSensitive)==0){ //case sensitive is faster - ui->cbTexture->setEnabled(true); + if(QString::compare(arg1,"M3GM ONI",Qt::CaseSensitive)==0){ //case sensitive is faster + ui->cbWithAnimation->setEnabled(true); } - else if(QString::compare(arg1,"DAE",Qt::CaseSensitive)==0){ - ui->cbCellShading->setEnabled(true); - ui->cbNormals->setEnabled(true); + else if(QString::compare(arg1,"OBJ",Qt::CaseSensitive)==0){ + ui->cbTexture->setEnabled(true); } - updateComboBox(arg1, ui->cbToModels, "models"); + updateComboBox(arg1, ui->cbToObjects); } -void MainWindow::on_cbFromAnimations_currentIndexChanged(const QString &arg1) +void MainWindow::on_cbFromCharacters_currentIndexChanged(const QString &arg1) { - ui->cbCamera->setEnabled(false); - ui->cbCamera->setChecked(false); - ui->cbGeometry->setEnabled(false); - ui->cbGeometry->setChecked(false); + ui->cbWithTRBS_ONCC->setEnabled(false); + ui->cbWithTRBS_ONCC->setChecked(false); + ui->cbCellShading->setEnabled(false); + ui->cbCellShading->setChecked(false); + ui->cbNormals->setEnabled(false); + ui->cbNormals->setChecked(false); - if(QString::compare(arg1,"ONI",Qt::CaseSensitive)==0){ //case sensitive is faster - ui->cbCamera->setEnabled(true); - ui->cbGeometry->setEnabled(true); + if(QString::compare(arg1,"TRAM ONI",Qt::CaseSensitive)==0){ //case sensitive is faster + ui->cbWithTRBS_ONCC->setEnabled(true); + } + else if(QString::compare(arg1,"TRBS DAE",Qt::CaseSensitive)==0){ + ui->cbNormals->setEnabled(true); + ui->cbCellShading->setEnabled(true); } - updateComboBox(arg1, ui->cbToAnimations, "animations"); + updateComboBox(arg1, ui->cbToCharacters); } void MainWindow::on_cbFromLevels_currentIndexChanged(const QString &arg1) { - updateComboBox(arg1, ui->cbToLevels, "levels"); + + ui->cbSpecificFilesLevels->setEnabled(false); + ui->cbSpecificFilesLevels->setChecked(false); + ui->cbDatLevels->setEnabled(false); + ui->cbDatLevels->setChecked(false); + ui->cbBnvLevels->setEnabled(false); + ui->cbBnvLevels->setChecked(false); + ui->cbAdditionalSourcesLevels->setEnabled(false); + ui->cbAdditionalSourcesLevels->setChecked(false); + ui->cbGridsLevels->setEnabled(false); + ui->cbGridsLevels->setChecked(false); + + if(arg1=="DAT"){ //case sensitive is faster + ui->cbSpecificFilesLevels->setEnabled(true); + } + else if(arg1=="ONI FILES"){ //case sensitive is faster + ui->cbDatLevels->setEnabled(true); + } + else if(arg1=="DAE"){ + ui->cbBnvLevels->setEnabled(true); + ui->cbAdditionalSourcesLevels->setEnabled(true); + } + + updateComboBox(arg1, ui->cbToLevels); } void MainWindow::on_cbFromMisc_currentIndexChanged(const QString &arg1) { - updateComboBox(arg1, ui->cbToMisc, "misc"); + updateComboBox(arg1, ui->cbToMisc); } -void MainWindow::updateComboBox(const QString &arg1, QComboBox *comboBox, const QString &identifier){ +void MainWindow::updateComboBox(const QString &arg1, QComboBox *comboBox){ + QString identifier=ui->tabWidget->tabText(ui->tabWidget->currentIndex()).toLower(); // get current tab title text (lower case) + comboBox->clear(); QStringList toUpdate=QStringList(); @@ -921,9 +998,9 @@ void MainWindow::on_actionMac_Windows_de ui->actionWindows->setChecked(false); } -void MainWindow::on_pbRemoveSourceGeneral_clicked() +void MainWindow::on_pbRemoveSourceXML_clicked() { - removeTableContents( ui->twSourcesGeneral); + removeTableContents( ui->twSourcesXML); } void MainWindow::on_pbRemoveSourceTextures_clicked() @@ -931,14 +1008,14 @@ void MainWindow::on_pbRemoveSourceTextur removeTableContents(ui->twSourcesTextures); } -void MainWindow::on_pbRemoveSourceModels_clicked() +void MainWindow::on_pbRemoveSourceObjects_clicked() { - removeTableContents(ui->twSourcesModels); + removeTableContents(ui->twSourcesObjects); } -void MainWindow::on_pbRemoveSourceAnimations_clicked() +void MainWindow::on_pbRemoveSourceCharacters_clicked() { - removeTableContents(ui->twSourcesAnimations); + removeTableContents(ui->twSourcesCharacters); } void MainWindow::on_pbRemoveSourceLevels_clicked() @@ -951,9 +1028,9 @@ void MainWindow::on_pbRemoveSourceMisc_c removeTableContents(ui->twSourcesMisc); } -void MainWindow::on_pbClearSourcesGeneral_clicked() +void MainWindow::on_pbClearSourcesXML_clicked() { - clearTableContents(ui->twSourcesGeneral); + clearTableContents(ui->twSourcesXML); } void MainWindow::on_pbClearSourcesTextures_clicked() @@ -961,14 +1038,14 @@ void MainWindow::on_pbClearSourcesTextur clearTableContents(ui->twSourcesTextures); } -void MainWindow::on_pbClearSourcesModels_clicked() +void MainWindow::on_pbClearSourcesObjects_clicked() { - clearTableContents(ui->twSourcesModels); + clearTableContents(ui->twSourcesObjects); } -void MainWindow::on_pbClearSourcesAnimations_clicked() +void MainWindow::on_pbClearSourcesCharacters_clicked() { - clearTableContents(ui->twSourcesAnimations); + clearTableContents(ui->twSourcesCharacters); } void MainWindow::on_pbClearSourcesLevels_clicked() @@ -984,12 +1061,24 @@ void MainWindow::on_pbClearSourcesMisc_c void MainWindow::removeTableContents(DropTableWidget *myTable){ int size = myTable->selectionModel()->selectedRows().size(); + QMessageBox::StandardButton defaultButton = QMessageBox::NoButton; // default button for clear asking question, only customizable in mac os + if(size==0){ Util::showPopUp("Select a row first."); return; } - if(Util::showQuestionPopUp(this,"Are you sure you want to delete the selected rows?")){ +#ifdef Q_OS_MAC + if(this->useYesAsDefaultWhenRemovingItems){ + defaultButton = QMessageBox::Yes; + } + else{ + defaultButton = QMessageBox::No; + } +#endif + + + if(Util::showQuestionPopUp(this,"Are you sure you want to delete the selected rows?",defaultButton)){ for(int i=0; iremoveRow(myTable->selectedItems().at(size-i-1)->row()); myTable->removeRow(myTable->selectionModel()->selectedRows().at(size-i-1).row()); @@ -999,12 +1088,24 @@ void MainWindow::removeTableContents(Dro } void MainWindow::clearTableContents(DropTableWidget *myTable){ + + QMessageBox::StandardButton defaultButton = QMessageBox::NoButton; // default button for clear asking question, only customizable in mac os + if(myTable->rowCount()==0){ Util::showPopUp("Nothing to clear."); return; } - if(Util::showQuestionPopUp(this,"Are you sure you want to clear the content?")){ +#ifdef Q_OS_MAC + if(this->useYesAsDefaultWhenRemovingItems){ + defaultButton = QMessageBox::Yes; + } + else{ + defaultButton = QMessageBox::No; + } +#endif + + if(Util::showQuestionPopUp(this,"Are you sure you want to clear the content?",defaultButton)){ myTable->clearContents(); myTable->setRowCount(0); } @@ -1028,70 +1129,17 @@ void MainWindow::closeEvent(QCloseEvent } } -void MainWindow::on_cbToGeneral_currentIndexChanged(const QString &arg1) -{ - - ui->cbDatGeneral->setEnabled(false); - ui->cbDatGeneral->setChecked(false); - ui->cbTRAMGeneral->setEnabled(false); - ui->cbTRAMGeneral->setChecked(false); - - if(QString::compare(ui->cbFromGeneral->currentText(),"ONI",Qt::CaseSensitive)==0){ - if(QString::compare(arg1,"DAT",Qt::CaseSensitive)==0){ - ui->cbDatGeneral->setEnabled(true); - } - else{ - ui->cbTRAMGeneral->setEnabled(true); - } - } - -} - -void MainWindow::on_cbToModels_currentIndexChanged(const QString &arg1) -{ - ui->cbWithAnimation->setEnabled(false); - ui->cbWithAnimation->setChecked(false); - - if(arg1=="DAE"){ - ui->cbWithAnimation->setEnabled(true); - } -} - void MainWindow::on_cbToLevels_currentIndexChanged(const QString &arg1) { - ui->cbDatLevels->setEnabled(false); - ui->cbDatLevels->setChecked(false); - ui->cbBnvLevels->setEnabled(false); - ui->cbBnvLevels->setChecked(false); - ui->cbAdditionalSourcesLevels->setEnabled(false); - ui->cbAdditionalSourcesLevels->setChecked(false); - ui->cbGridsLevels->setEnabled(false); - ui->cbGridsLevels->setChecked(false); - if(ui->cbFromLevels->currentText()=="MASTER XML" && arg1=="DAT"){ ui->cbDatLevels->setEnabled(true); } - else if(ui->cbFromLevels->currentText()=="DAE" && arg1=="ONI"){ - ui->cbBnvLevels->setEnabled(true); - ui->cbAdditionalSourcesLevels->setEnabled(true); + else if(ui->cbFromLevels->currentText()=="MASTER XML" && arg1=="ONI FILES"){ + ui->cbDatLevels->setEnabled(false); + ui->cbDatLevels->setChecked(false); } -} -void MainWindow::on_cbDatGeneral_toggled(bool checked) -{ - ui->leTargetDatGeneral->setEnabled(checked); -} - -void MainWindow::on_cbTRAMGeneral_toggled(bool checked) -{ - ui->leTRAMGeneral->setEnabled(checked); - if(checked){ - QString file=QFileDialog::getOpenFileName(this,"Choose the TRAM.oni file...","./" , "All Files (*.*)"); - if(!file.isEmpty()){ - ui->leTRAMGeneral->setText(file); - } - } } void MainWindow::on_cbDatLevels_toggled(bool checked) @@ -1132,9 +1180,15 @@ void MainWindow::on_cbAdditionalSourcesL } } +void MainWindow::on_cbWithTRBS_ONCC_toggled(bool checked) +{ + ui->leTRBS_ONCC->setEnabled(checked); +} + void MainWindow::on_actionCheck_OniSplit_version_triggered() { QProcess *myProcess = new QProcess(); + myProcess->setWorkingDirectory(this->AppDir); myProcess->start(GlobalVars::OniSplitExeName+" -version"); myProcess->waitForFinished(-1); QString result=myProcess->readAllStandardOutput(); @@ -1145,6 +1199,7 @@ void MainWindow::on_actionCheck_OniSplit void MainWindow::on_actionCheck_xmlTools_version_triggered() { QProcess *myProcess = new QProcess(); + myProcess->setWorkingDirectory(this->AppDir); myProcess->start(GlobalVars::XmlToolsExeName+" version"); myProcess->waitForFinished(-1); QString result=myProcess->readLine(); @@ -1154,19 +1209,24 @@ void MainWindow::on_actionCheck_xmlTools /** Update items loaded - **/ -void MainWindow::on_tabWidget_selected(const QString &arg1) +**/ +void MainWindow::on_tabWidget_currentChanged(int index) { - if(arg1.compare("General",Qt::CaseSensitive)==0){ //case sentive is faster - updateItemsLoaded(ui->twSourcesGeneral); + QString tabtext = ui->tabWidget->tabText(index); + + if(tabtext.compare("XML",Qt::CaseSensitive)==0){ //case sentive is faster + updateItemsLoaded(ui->twSourcesXML); } - else if(arg1.compare("Textures",Qt::CaseSensitive)==0){ + else if(tabtext.compare("Textures",Qt::CaseSensitive)==0){ updateItemsLoaded(ui->twSourcesTextures); } - else if(arg1.compare("Models",Qt::CaseSensitive)==0){ - updateItemsLoaded(ui->twSourcesModels); + else if(tabtext.compare("Characters",Qt::CaseSensitive)==0){ + updateItemsLoaded(ui->twSourcesCharacters); + } + else if(tabtext.compare("Objects",Qt::CaseSensitive)==0){ + updateItemsLoaded(ui->twSourcesObjects); } - else if(arg1.compare("Levels",Qt::CaseSensitive)==0){ + else if(tabtext.compare("Levels",Qt::CaseSensitive)==0){ updateItemsLoaded(ui->twSourcesLevels); } else{ @@ -1227,24 +1287,29 @@ void MainWindow::on_actionView_log_trigg Util::openLogFile(); } +void MainWindow::on_actionOpen_AE_folder_triggered() +{ + QDesktopServices::openUrl(QUrl("file:///"+this->AeLocation)); +} + QString MainWindow::getTypeConversion(DropTableWidget *myTable){ QString from,to; - if(myTable==ui->twSourcesGeneral){ - from=ui->cbFromGeneral->currentText(); - to=ui->cbToGeneral->currentText(); + if(myTable==ui->twSourcesXML){ + from=ui->cbFromXML->currentText(); + to=ui->cbToXML->currentText(); } else if(myTable==ui->twSourcesTextures){ from=ui->cbFromTextures->currentText(); to=ui->cbToTextures->currentText(); } - else if(myTable==ui->twSourcesModels){ - from=ui->cbFromModels->currentText(); - to=ui->cbToModels->currentText(); - } - else if(myTable==ui->twSourcesAnimations){ - from=ui->cbFromAnimations->currentText(); - to=ui->cbToAnimations->currentText(); + else if(myTable==ui->twSourcesObjects){ + from=ui->cbFromObjects->currentText(); + to=ui->cbToObjects->currentText(); + } + else if(myTable==ui->twSourcesCharacters){ + from=ui->cbFromCharacters->currentText(); + to=ui->cbToCharacters->currentText(); } else if(myTable==ui->twSourcesLevels){ from=ui->cbFromLevels->currentText(); @@ -1470,20 +1535,23 @@ void MainWindow::changeItemsOutput(DropT } QString MainWindow::getCommand(DropTableWidget* myTable, QString myOutputFolder, QString from, QString to , QString file){ - if(myTable==ui->twSourcesGeneral){ //So we only need to parse one command. - return fileParsingGeneral(myOutputFolder,from,to,file); + + QString tabTitle=ui->tabWidget->tabText(ui->tabWidget->currentIndex()).toLower(); // get current tab title + + if(myTable==ui->twSourcesXML){ //So we only need to parse one command. + return fileParsingXML(tabTitle, myOutputFolder,from,to,file); } else if(myTable==ui->twSourcesTextures){ - return fileParsingTextures(myOutputFolder,from,to,file); + return fileParsingTextures(tabTitle, myOutputFolder,from,to,file); } - else if(myTable==ui->twSourcesModels){ - return fileParsingModels(myOutputFolder,from,to,file); + else if(myTable==ui->twSourcesObjects){ + return fileParsingObjects(tabTitle, myOutputFolder,from,to,file); } - else if(myTable==ui->twSourcesAnimations){ - return fileParsingAnimations(myOutputFolder,from,to,file); + else if(myTable==ui->twSourcesCharacters){ + return fileParsingCharacters(tabTitle, myOutputFolder,from,to,file); } else if(myTable==ui->twSourcesLevels){ - return fileParsingLevels(myOutputFolder,from,to,file); + return fileParsingLevels(tabTitle, myOutputFolder,from,to,file); } else{ return fileParsingMisc(myOutputFolder,from,to,file); @@ -1495,11 +1563,11 @@ QString MainWindow::getCommand(DropTable This is OS indepented. It maintain size ratio over the Windows and Mac. **/ void MainWindow::setConverterButtonsSize(){ - int height=ui->pbConvertGeneral->sizeHint().height()*1.3; - ui->pbConvertGeneral->setMinimumHeight(height); + int height=ui->pbConvertXML->sizeHint().height()*1.3; + ui->pbConvertXML->setMinimumHeight(height); ui->pbConvertTextures->setMinimumHeight(height); - ui->pbConvertModels->setMinimumHeight(height); - ui->pbConvertAnimations->setMinimumHeight(height); + ui->pbConvertObjects->setMinimumHeight(height); + ui->pbConvertCharacters->setMinimumHeight(height); ui->pbConvertLevels->setMinimumHeight(height); ui->pbConvertMisc->setMinimumHeight(height); } @@ -1508,8 +1576,8 @@ void MainWindow::setConverterButtonsSize Gets application directory. In mac os gets the .app directory **/ QString MainWindow::getOSIndependentAppPath(){ -#ifdef Q_WS_MAC - QDir dir = QDir::current(); +#ifdef Q_OS_MAC + QDir dir = QDir(QCoreApplication::applicationDirPath()); if(dir.absolutePath().contains(".app")){ // include bundle, but we don't want it dir.cdUp(); dir.cdUp(); @@ -1532,17 +1600,23 @@ void MainWindow::connectSlots(){ //This signal is for thread that is working can show the result of a conversion connect(myConverter, SIGNAL(resultConversion(QString,int)), this, SLOT(TresultConversion(QString,int))); + //This signal is for thread that is working notify the gui thread that the conversion was aborted with sucess + connect(myConverter, SIGNAL(conversionAborted()), this, SLOT(TconversionAborted())); + + // This signal is to the user be able to terminate a conversion (OniSplit process in class myConverter will be terminated) + connect(this, SIGNAL(terminateCurrProcess()), myConverter, SLOT(terminateCurrProcess())); + //Drop signal for General table - connect(ui->twSourcesGeneral, SIGNAL(dropped(DropTableWidget*,QStringList)), this, SLOT(addFilesSource(DropTableWidget*,QStringList))); + connect(ui->twSourcesXML, SIGNAL(dropped(DropTableWidget*,QStringList)), this, SLOT(addFilesSource(DropTableWidget*,QStringList))); //Drop signal for Textures table connect(ui->twSourcesTextures, SIGNAL(dropped(DropTableWidget*,QStringList)), this, SLOT(addFilesSource(DropTableWidget*,QStringList))); - //Drop signal for Models table - connect(ui->twSourcesModels, SIGNAL(dropped(DropTableWidget*,QStringList)), this, SLOT(addFilesSource(DropTableWidget*,QStringList))); + //Drop signal for Objects table + connect(ui->twSourcesObjects, SIGNAL(dropped(DropTableWidget*,QStringList)), this, SLOT(addFilesSource(DropTableWidget*,QStringList))); - //Drop signal for Animations table - connect(ui->twSourcesAnimations, SIGNAL(dropped(DropTableWidget*,QStringList)), this, SLOT(addFilesSource(DropTableWidget*,QStringList))); + //Drop signal for Characters table + connect(ui->twSourcesCharacters, SIGNAL(dropped(DropTableWidget*,QStringList)), this, SLOT(addFilesSource(DropTableWidget*,QStringList))); //Drop signal for Levels table connect(ui->twSourcesLevels, SIGNAL(dropped(DropTableWidget*,QStringList)), this, SLOT(addFilesSource(DropTableWidget*,QStringList))); @@ -1551,16 +1625,16 @@ void MainWindow::connectSlots(){ connect(ui->twSourcesMisc, SIGNAL(dropped(DropTableWidget*,QStringList)), this, SLOT(addFilesSource(DropTableWidget*,QStringList))); //Context menu for General table - connect(ui->twSourcesGeneral, SIGNAL(dtContextMenu(DropTableWidget*,QContextMenuEvent*)), this, SLOT(dtContextMenu(DropTableWidget*,QContextMenuEvent*))); + connect(ui->twSourcesXML, SIGNAL(dtContextMenu(DropTableWidget*,QContextMenuEvent*)), this, SLOT(dtContextMenu(DropTableWidget*,QContextMenuEvent*))); //Context menu for Textures table connect(ui->twSourcesTextures, SIGNAL(dtContextMenu(DropTableWidget*,QContextMenuEvent*)), this, SLOT(dtContextMenu(DropTableWidget*,QContextMenuEvent*))); - //Context menu for Models table - connect(ui->twSourcesModels, SIGNAL(dtContextMenu(DropTableWidget*,QContextMenuEvent*)), this, SLOT(dtContextMenu(DropTableWidget*,QContextMenuEvent*))); + //Context menu for Objects table + connect(ui->twSourcesObjects, SIGNAL(dtContextMenu(DropTableWidget*,QContextMenuEvent*)), this, SLOT(dtContextMenu(DropTableWidget*,QContextMenuEvent*))); - //Context menu for Animations table - connect(ui->twSourcesAnimations, SIGNAL(dtContextMenu(DropTableWidget*,QContextMenuEvent*)), this, SLOT(dtContextMenu(DropTableWidget*,QContextMenuEvent*))); + //Context menu for Characters table + connect(ui->twSourcesCharacters, SIGNAL(dtContextMenu(DropTableWidget*,QContextMenuEvent*)), this, SLOT(dtContextMenu(DropTableWidget*,QContextMenuEvent*))); //Context menu for Levels table connect(ui->twSourcesLevels, SIGNAL(dtContextMenu(DropTableWidget*,QContextMenuEvent*)), this, SLOT(dtContextMenu(DropTableWidget*,QContextMenuEvent*))); @@ -1568,5 +1642,3 @@ void MainWindow::connectSlots(){ //Context menu for Misc table connect(ui->twSourcesMisc, SIGNAL(dtContextMenu(DropTableWidget*,QContextMenuEvent*)), this, SLOT(dtContextMenu(DropTableWidget*,QContextMenuEvent*))); } - -