- Timestamp:
- Sep 17, 2016, 12:51:26 AM (8 years ago)
- Location:
- Vago/trunk/Vago
- Files:
-
- 6 added
- 43 edited
Legend:
- Unmodified
- Added
- Removed
-
Vago/trunk/Vago/Vago.pro
r1037 r1047 8 8 QT += network #network communication 9 9 QT += script #for json parse 10 win32 { 11 QT += winextras 12 } 13 CONFIG += c++14 10 14 11 INCLUDEPATH += $$[QT_INSTALL_HEADERS]/QtZlib 12 INCLUDEPATH += ./libs 15 #INCLUDEPATH += ./libs 13 16 INCLUDEPATH += ./packageWizard 14 17 INCLUDEPATH += ./soundWizard 18 19 # Used this great tutorial to build zlib and quazip: 20 # http://www.antonioborondo.com/2014/10/22/zipping-and-unzipping-files-with-qt/ 21 INCLUDEPATH += ../Libs/zlib-1.2.8 22 LIBS += -LC:../Libs/zlib-1.2.8 -lz 23 INCLUDEPATH += ../Libs/quazip-0.7.2/quazip 24 LIBS += -L../Libs/quazip-0.7.2/quazip/release -lquazip 15 25 16 26 macx { … … 36 46 converter.cpp \ 37 47 about.cpp \ 38 libs/zipglobal.cpp \39 libs/zip.cpp \40 libs/unzip.cpp \41 48 packageWizard/packagewizard.cpp \ 42 49 packageWizard/packagepagefinal.cpp \ … … 49 56 soundWizard/soundpagefinal.cpp \ 50 57 soundWizard/soundwizard.cpp \ 51 xmlprocessor.cpp 58 xmlprocessor.cpp \ 59 libs/pugixml/pugixml.cpp \ 60 utilvago.cpp 52 61 53 62 HEADERS += \ … … 60 69 converter.h \ 61 70 about.h \ 62 libs/zipglobal.h \63 libs/zipentry_p.h \64 libs/zip_p.h \65 libs/zip.h \66 libs/unzip_p.h \67 libs/unzip.h \68 71 packageWizard/packagewizard.h \ 69 72 packageWizard/packagepagefinal.h \ … … 76 79 soundWizard/soundpagefinal.h \ 77 80 soundWizard/soundwizard.h \ 78 xmlprocessor.h 81 xmlprocessor.h \ 82 libs/pugixml/pugixml.hpp \ 83 utilvago.h 79 84 80 FORMS += mainwindow.ui \ 85 FORMS += \ 86 mainwindow.ui \ 81 87 preferences.ui \ 82 88 manualcommands.ui \ … … 93 99 RESOURCES += \ 94 100 resources.qrc \ 95 96 CONFIG += c++11 -
Vago/trunk/Vago/about.cpp
r1039 r1047 14 14 "<p style='font-size:small;'>" 15 15 "Written by s10k<br /><br/>" 16 "Build Date " + __DATE__ + " " + __TIME__ + "<br /><br />" 16 17 "Thanks to:<br/>" 17 18 "Neo for OniSplit<br />" … … 27 28 "Also thanks to: <br />" 28 29 "StackOverflow Community<br />" 29 "Fabrizio Angius for PKZIP 2.0 for zip handling<br />" 30 "Sergey A. Tachenov for the QuaZIP library<br />" 31 "Antonio Borondo for the documentation how to setup QuaZIP<br />" 32 "Arseny Kapoulkine (and contributors)for pugixml library<br />" 30 33 "smashingmagazine for the folder icon :)<br />" 31 34 "<center>" -
Vago/trunk/Vago/about.h
r811 r1047 4 4 #include <QDialog> 5 5 6 #include "util .h"6 #include "utilvago.h" 7 7 8 8 namespace Ui { -
Vago/trunk/Vago/converter.cpp
r1035 r1047 8 8 } 9 9 10 #ifdef Q_OS_WIN 11 Converter::Converter(QString AppDir, Logger *myLogger, QStringList *myData, QWinTaskbarProgress *win7TaskBarProgress) 12 : Converter(AppDir, myLogger, myData) 13 { 14 this->win7TaskBarProgress = win7TaskBarProgress; 15 } 16 #endif 17 10 18 void Converter::run() 11 19 { … … 16 24 int numErrors=0; 17 25 18 this->myLogger->writeString("Setting working dir .to "+this->AppDir+".");26 this->myLogger->writeString("Setting working dir to "+this->AppDir+"."); 19 27 myProcess->setWorkingDirectory(this->AppDir); // Set working directory (for work with AEI2/Mac OS) 20 28 29 #ifdef Q_OS_WIN 30 if(this->win7TaskBarProgress){ 31 this->win7TaskBarProgress->reset(); 32 this->win7TaskBarProgress->show(); 33 } 34 #endif 35 21 36 if(this->myData->size()!=1){ 37 #ifdef Q_OS_WIN 38 if(this->win7TaskBarProgress){ 39 this->win7TaskBarProgress->setRange(0,this->myData->size()); 40 } 41 #endif 22 42 emit setupPB(this->myData->size()); 23 43 } 24 44 else{ 45 #ifdef Q_OS_WIN 46 if(this->win7TaskBarProgress){ 47 this->win7TaskBarProgress->setRange(0,0); 48 } 49 #endif 25 50 emit setupPB(0); //Intermitent bar, we don't have any estimation when the task is done 26 51 } … … 37 62 38 63 commandToExec=commands.mid(currentIndex,(nextIndex-currentIndex)); 39 this->myProcess->start(Util ::getOniSplitExeName() +" "+commandToExec);64 this->myProcess->start(UtilVago::getOniSplitExeAbsolutePath() + " " + commandToExec); 40 65 this->myProcess->waitForFinished(-1); 41 66 42 67 if(this->processHasKilled){ // If the process has killed there's no need to proceed with reading output or process more commands 68 69 #ifdef Q_OS_WIN 70 if(this->win7TaskBarProgress){ 71 this->win7TaskBarProgress->hide(); 72 } 73 #endif 74 43 75 delete this->myProcess; //delete object and make pointer invalid 44 76 this->myData->clear(); //clean list 45 77 emit conversionAborted(); 78 46 79 return; 47 80 } … … 62 95 } 63 96 97 #ifdef Q_OS_WIN 98 if(this->win7TaskBarProgress){ 99 this->win7TaskBarProgress->setValue(win7TaskBarProgress->value()+1); 100 } 101 #endif 102 64 103 emit taskDone(); 65 104 } 105 106 #ifdef Q_OS_WIN 107 if(this->win7TaskBarProgress){ 108 this->win7TaskBarProgress->hide(); 109 } 110 #endif 66 111 67 112 delete this->myProcess; //delete object and make pointer invalid -
Vago/trunk/Vago/converter.h
r897 r1047 4 4 #include <QProgressBar> 5 5 #include <QThread> 6 #ifdef Q_OS_WIN 7 #include <QWinTaskbarProgress> 8 #endif 6 9 7 #include " logger.h"10 #include "utilvago.h" 8 11 9 12 class Converter : public QThread … … 12 15 public: 13 16 Converter(QString AppDir, Logger *myLogger, QStringList *myData); 17 18 #ifdef Q_OS_WIN 19 Converter(QString AppDir, Logger *myLogger, QStringList *myData, QWinTaskbarProgress *win7TaskBarProgress); 20 #endif 14 21 private: 15 22 QString AppDir; … … 18 25 QProcess *myProcess; 19 26 bool processHasKilled; 27 #ifdef Q_OS_WIN 28 QWinTaskbarProgress *win7TaskBarProgress = nullptr; 29 #endif 20 30 21 31 protected: -
Vago/trunk/Vago/droptablewidget.h
r998 r1047 5 5 #include <QtWidgets> 6 6 7 #include "util .h"7 #include "utilvago.h" 8 8 9 9 -
Vago/trunk/Vago/logger.cpp
r803 r1047 1 1 #include "logger.h" 2 2 3 Logger::Logger(QString appDir )3 Logger::Logger(QString appDir, QString logFileName) 4 4 { 5 myLogFile = new QFile(appDir+"/"+GlobalVars::AppLogName);5 myLogFile = std::make_unique<QFile>(appDir+"/"+logFileName); 6 6 7 8 9 7 if (!myLogFile->open(QIODevice::WriteOnly | QIODevice::Text)){ //open to write 8 return; 9 } 10 10 11 logStream = new QTextStream (myLogFile);11 logStream = std::make_unique<QTextStream>(myLogFile.get()); 12 12 //logStream->setCodec("UTF-8"); 13 13 } 14 14 15 15 /** 16 16 ** Mutex makes it thread safe. (not sure if needed although) 17 17 **/ … … 19 19 mutex.lock(); 20 20 *this->logStream << "--------------------------------------------"; 21 *this->logStream << "\nEvent Start: " << QDateTime::currentDateTime().toString( ) << "\n" << strToWrite << "\nEvent End.\n";21 *this->logStream << "\nEvent Start: " << QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss") << "\n" << strToWrite << "\nEvent End.\n"; 22 22 *this->logStream << "--------------------------------------------\n"; 23 23 this->logStream->flush(); … … 29 29 **/ 30 30 void Logger::writeBytes(QByteArray arrToWrite){ 31 mutex.lock();32 *this->logStream << "--------------------------------------------";33 *this->logStream << "\nEvent Start: " << QDateTime::currentDateTime().toString() << "\n" << arrToWrite << "\nEvent End.\n";34 *this->logStream << "--------------------------------------------";35 this->logStream->flush();36 mutex.unlock();31 mutex.lock(); 32 *this->logStream << "--------------------------------------------"; 33 *this->logStream << "\nEvent Start: " << QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss") << "\n" << arrToWrite << "\nEvent End.\n"; 34 *this->logStream << "--------------------------------------------"; 35 this->logStream->flush(); 36 mutex.unlock(); 37 37 } 38 38 39 //deconstructor, will close the file automatically and free the resources...40 39 Logger::~Logger(){ 41 delete this->logStream; 42 delete this->myLogFile; //the deconstructor of the file will close it automatically 40 43 41 } -
Vago/trunk/Vago/logger.h
r811 r1047 5 5 #include <QMutex> 6 6 #include <QDateTime> 7 8 #include "util.h" 7 #include <memory> 9 8 10 9 class Logger 11 10 { 12 11 public: 13 Logger(QString appDir );12 Logger(QString appDir, QString logFileName); 14 13 ~Logger(); 15 14 void writeString(QString strToWrite); 16 15 void writeBytes(QByteArray arrToWrite); 17 16 private: 18 QFile *myLogFile;19 QTextStream *logStream;17 std::unique_ptr<QFile> myLogFile; 18 std::unique_ptr<QTextStream> logStream; 20 19 QMutex mutex; //mutex for control writes to the logs 21 20 }; -
Vago/trunk/Vago/main.cpp
r1035 r1047 1 1 #include <QtWidgets/QApplication> 2 2 #include "mainwindow.h" 3 3 4 4 5 int main(int argc, char *argv[]) … … 9 10 w.show(); 10 11 a.setStyleSheet("QStatusBar::item { border: 0px; }"); //hide QLabels border in status bar //http://qt-project.org/forums/viewthread/18743 11 12 12 13 return a.exec(); 13 14 } -
Vago/trunk/Vago/mainwindow.cpp
r1036 r1047 10 10 ui->setupUi(this); 11 11 12 this->myLogger = new Logger(Util ::getAppPath()); //start logger13 14 this->myLogger->writeString("Detected AppDir: "+Util ::getAppPath());12 this->myLogger = new Logger(UtilVago::getAppPath(), GlobalVars::AppLogName); //start logger 13 14 this->myLogger->writeString("Detected AppDir: "+UtilVago::getAppPath()); 15 15 this->myLogger->writeString("True app dir: "+QDir::currentPath()); 16 16 17 this->setWindowTitle("Vago v"+GlobalVars::AppVersion);18 19 if(!QFile::exists(Util ::getAppPath()+"/"+GlobalVars::OniSplitString)){20 Util ::showErrorPopUp("OniSplit not found. Please download it at "+GlobalVars::ModsDomain+" and put it in the same folder of Vago. \n\nProgram will now exit.");17 setVagoWindowTitle(); 18 19 if(!QFile::exists(UtilVago::getOniSplitExeAbsolutePath())){ 20 UtilVago::showAndLogErrorPopUp(this->myLogger, "OniSplit not found. Please download it at "+GlobalVars::ModsDomain+" and put it the Vago's tools folder. \n\nProgram will now exit."); 21 21 exit(1); 22 22 } 23 23 24 if(!QFile::exists(Util ::getAppPath()+"/"+GlobalVars::XmlToolsString)){25 Util ::showErrorPopUp("xmlTools not found. Please download it at "+GlobalVars::ModsDomain+" and put it in the same folder of Vago. \n\nProgram will now exit.");24 if(!QFile::exists(UtilVago::getXmlToolsExeAbsolutePath())){ 25 UtilVago::showAndLogErrorPopUp(this->myLogger, "XmlTools not found. Please download it at "+GlobalVars::ModsDomain+" and put it the Vago's tools folder. \n\nProgram will now exit."); 26 26 exit(1); 27 27 } 28 28 29 this->vagoSettings = new QSettings(Util ::getAppPath() + "/" + this->VagoSettingsName, QSettings::IniFormat);29 this->vagoSettings = new QSettings(UtilVago::getAppPath() + "/" + this->VagoSettingsName, QSettings::IniFormat); 30 30 31 31 //First Execution? Old configuration? Settings missed? … … 36 36 } 37 37 if(!this->vagoSettings->contains("Workspace")){ 38 this->vagoSettings->setValue("Workspace", Util ::getAppPath()+"/VagoWorkspace");38 this->vagoSettings->setValue("Workspace", UtilVago::getAppPath()+"/VagoWorkspace"); 39 39 iniChanged=true; 40 40 } … … 45 45 46 46 if(aefolder.isEmpty()){ 47 Util ::showErrorPopUp("AE folder is mandatory. Application will now exit.");47 UtilVago::showAndLogErrorPopUp(this->myLogger, "AE folder is mandatory. Application will now exit."); 48 48 exit(1); 49 49 } … … 75 75 this->vagoSettings->setValue("ConfirmExit", false); 76 76 iniChanged=true; 77 } 78 if(!this->vagoSettings->contains("LastProjectPath")){ 79 this->vagoSettings->setValue("LastProjectPath", this->vagoSettings->value("Workspace")); 80 iniChanged=true; 81 } 82 for(int i=0; i<this->recentProjectsMaxSize; i++){ 83 if(!this->vagoSettings->contains("RecentProject" + QString::number(i+1))){ 84 this->vagoSettings->setValue("RecentProject" + QString::number(i+1), ""); 85 iniChanged=true; 86 } 77 87 } 78 88 #ifdef Q_OS_MAC … … 118 128 this->listToProccess = new QStringList; 119 129 120 //Create a thread for do the conversion in background121 this->myConverter = new Converter(Util::getAppPath(),this->myLogger,this->listToProccess);122 123 130 // User interface 124 131 ui->mainToolBar->addWidget(ui->tbAE); //add ae installer launch button … … 132 139 ui->mainToolBar->setLayoutDirection(Qt::RightToLeft); 133 140 134 setConverterButtonsSize(); 141 ui->pbConvert->setMinimumHeight(ui->pbConvert->sizeHint().height()*1.5); // This is OS indepented. It maintain size ratio over the Windows and Mac. 142 135 143 136 144 #ifdef Q_OS_MAC … … 144 152 // resize(800,600); // Mac OS pcs should be able to render this resolution without any problem. It's also better 145 153 //// because the components on mac use more space 154 #endif 155 156 resize(this->startedWindowWidth,this->startedWindowHeight); 157 158 #ifdef Q_OS_MAC 159 ui->pbConvert->setToolTip(ui->pbConvert->toolTip() + " (⌘ + Enter)"); 146 160 #else 147 //resize(640,480); // windows stuff161 ui->pbConvert->setToolTip(ui->pbConvert->toolTip() + " (Ctrl + Enter)"); 148 162 #endif 149 150 resize(this->startedWindowWidth,this->startedWindowHeight);151 152 connectSlots();153 163 154 164 //Commands Mapping … … 158 168 updateItemsLoaded(ui->twSourcesXML); 159 169 160 this->myLogger->writeString("Application started.");170 loadRecentProjects(); 161 171 } 162 172 … … 166 176 this->myLogger->writeString("Application Exited."); 167 177 } 178 179 180 void MainWindow::showEvent(QShowEvent *e) 181 { 182 #ifdef Q_OS_WIN 183 // QProgressBar only works after the windows was shown 184 // http://stackoverflow.com/questions/24840941/qwintaskbarprogress-wont-show (Kervala answer) 185 186 this->win7TaskBarButton = new QWinTaskbarButton(); 187 188 this->win7TaskBarButton->setWindow(this->windowHandle()); 189 190 this->win7TaskBarProgress = this->win7TaskBarButton->progress(); 191 192 //Create a thread for do the conversion in background 193 this->myConverter = new Converter(UtilVago::getAppPath(), this->myLogger, this->listToProccess, this->win7TaskBarProgress); 194 #else 195 this->myConverter = new Converter(UtilVago::getAppPath(), this->myLogger, this->listToProccess); 196 #endif 197 198 connectSlots(); 199 200 this->myLogger->writeString("Application started."); 201 202 e->accept(); 203 } 204 168 205 169 206 void MainWindow::on_actionExit_triggered() … … 187 224 void MainWindow::on_actionSound_Wizard_triggered() 188 225 { 189 SoundWizard myWizard (Util ::getAppPath(), this->workspaceWizardsLocation, this->myLogger, &this->commandMap);226 SoundWizard myWizard (UtilVago::getAppPath(), this->workspaceWizardsLocation, this->myLogger, &this->commandMap); 190 227 myWizard.exec(); 191 228 } … … 283 320 } 284 321 else{ 285 Util ::showErrorPopUp("An error occurred checking last version:\n\n"+result->errorString());322 UtilVago::showAndLogErrorPopUp(this->myLogger, "An error occurred checking last version:\n\n"+result->errorString()); 286 323 } 287 324 result->deleteLater(); … … 436 473 } 437 474 438 if(ui->rbBGR32->isChecked()){ 439 command+=" "+this->commandMap.value(tabTitle+"->"+ui->rbBGR32->text()); 440 } 441 else if(ui->rbBGRA32->isChecked()){ 442 command+=" "+this->commandMap.value(tabTitle+"->"+ui->rbBGRA32->text()); 443 } 444 else if(ui->rbBGR555->isChecked()){ 445 command+=" "+this->commandMap.value(tabTitle+"->"+ui->rbBGR555->text()); 446 } 447 else if(ui->rbBGRA5551->isChecked()){ 448 command+=" "+this->commandMap.value(tabTitle+"->"+ui->rbBGRA5551->text()); 449 } 450 else if(ui->rbBGRA444->isChecked()){ 451 command+=" "+this->commandMap.value(tabTitle+"->"+ui->rbBGRA444->text()); 452 } 453 else{ //dxt1 checked 454 command+=" "+this->commandMap.value(tabTitle+"->"+ui->rbDxt1->text()); 455 } 475 command+=" "+this->commandMap.value(tabTitle+"->"+getTextureRBCheckedTypeTexture()->text()); 456 476 457 477 if(ui->cbEnvMap->isChecked()){ … … 635 655 } 636 656 637 void MainWindow::addRowTable(DropTableWidget *myTable, QString fileName, QString fromTo, QString command ){657 void MainWindow::addRowTable(DropTableWidget *myTable, QString fileName, QString fromTo, QString command, bool isToDisabled){ 638 658 //Get actual number rows 639 659 int twSize=myTable->rowCount(); … … 647 667 QTableWidgetItem *newCommand = new QTableWidgetItem(command); 648 668 669 if(isToDisabled){ 670 myTable->setDisableStyleWidgetItem(newFile); 671 myTable->setDisableStyleWidgetItem(newConversion); 672 myTable->setDisableStyleWidgetItem(newCommand); 673 } 674 649 675 myTable->setItem(twSize,0,newFile); 650 676 myTable->setItem(twSize,1,newConversion); … … 654 680 } 655 681 656 void MainWindow::on_pbConvertXML_clicked() 657 { 658 startConversion(ui->twSourcesXML); 659 } 660 661 void MainWindow::on_pbConvertTextures_clicked() 662 { 663 startConversion(ui->twSourcesTextures); 664 } 665 666 void MainWindow::on_pbConvertObjects_clicked() 667 { 668 startConversion(ui->twSourcesObjects); 669 } 670 671 void MainWindow::on_pbConvertCharacters_clicked() 672 { 673 startConversion(ui->twSourcesCharacters); 674 } 675 676 void MainWindow::on_pbConvertLevels_clicked() 677 { 678 startConversion(ui->twSourcesLevels); 679 } 680 681 void MainWindow::on_pbConvertMisc_clicked() 682 { 683 startConversion(ui->twSourcesMisc); 684 } 685 686 void MainWindow::startConversion(DropTableWidget *myTable){ 682 void MainWindow::on_pbConvert_clicked() 683 { 684 startConversion(); 685 } 686 687 void MainWindow::startConversion(){ 688 689 DropTableWidget* currTable = getCurrentTableWidget(); 687 690 688 691 bool ready=false; 689 for(int i=0; i< myTable->rowCount(); i++){ //There are items to process?690 if( myTable->item(i,2)->background()!=myTable->disabledBackStyle){692 for(int i=0; i<currTable->rowCount(); i++){ //There are items to process? 693 if(currTable->item(i,2)->background()!=currTable->disabledBackStyle){ 691 694 ready=true; 692 695 break; … … 704 707 } 705 708 706 for(int i=0; i< myTable->rowCount(); i++){709 for(int i=0; i<currTable->rowCount(); i++){ 707 710 //Only process enabled items 708 if( myTable->item(i,2)->background()!=myTable->disabledBackStyle){709 this->listToProccess->append( myTable->item(i,2)->text());711 if(currTable->item(i,2)->background()!=currTable->disabledBackStyle){ 712 this->listToProccess->append(currTable->item(i,2)->text()); 710 713 } 711 714 } … … 733 736 QString sNumErrors=QString::number(numErrors); 734 737 if(numErrors>1){ 735 Util ::showErrorLogPopUp(result+"\n This is the last of "+sNumErrors+" Errors.");738 UtilVago::showErrorPopUpLogButton(result+"\n This is the last of "+sNumErrors+" Errors."); 736 739 showErrStatusMessage("Something gone wrong. Check log file ("+sNumErrors+" Errors)."); 737 740 } 738 741 else{ 739 Util ::showErrorLogPopUp(result);742 UtilVago::showErrorPopUpLogButton(result); 740 743 showErrStatusMessage("Something gone wrong. Check log file."); 741 744 } … … 887 890 void MainWindow::on_cbFromTextures_currentIndexChanged(const QString &arg1) 888 891 { 889 //Options are only used for DAT/ONI -> Image890 if(QString::compare(arg1,"DAT / ONI",Qt::CaseSensitive)==0){ //case sensitive is faster891 ui->gbTextures->setEnabled(false);892 }893 else{894 ui->gbTextures->setEnabled(true);895 }896 897 892 updateComboBox(arg1, ui->cbToTextures); 898 893 } … … 900 895 void MainWindow::on_cbFromObjects_currentIndexChanged(const QString &arg1) 901 896 { 902 ui->cbTexture->setEnabled(false);903 ui->cbTexture->setChecked(false);904 ui->cbWithAnimation->setEnabled(false);905 ui->cbWithAnimation->setChecked(false);906 907 if(QString::compare(arg1,"M3GM ONI",Qt::CaseSensitive)==0){ //case sensitive is faster908 ui->cbWithAnimation->setEnabled(true);909 }910 else if(QString::compare(arg1,"OBJ",Qt::CaseSensitive)==0){911 ui->cbTexture->setEnabled(true);912 }913 914 897 updateComboBox(arg1, ui->cbToObjects); 915 898 } … … 917 900 void MainWindow::on_cbFromCharacters_currentIndexChanged(const QString &arg1) 918 901 { 919 ui->cbWithTRBS_ONCC->setEnabled(false);920 ui->cbWithTRBS_ONCC->setChecked(false);921 ui->cbCellShading->setEnabled(false);922 ui->cbCellShading->setChecked(false);923 ui->cbNormals->setEnabled(false);924 ui->cbNormals->setChecked(false);925 926 if(QString::compare(arg1,"TRAM ONI",Qt::CaseSensitive)==0){ //case sensitive is faster927 ui->cbWithTRBS_ONCC->setEnabled(true);928 }929 else if(QString::compare(arg1,"TRBS DAE",Qt::CaseSensitive)==0){930 ui->cbNormals->setEnabled(true);931 ui->cbCellShading->setEnabled(true);932 }933 934 902 updateComboBox(arg1, ui->cbToCharacters); 935 903 } … … 937 905 void MainWindow::on_cbFromLevels_currentIndexChanged(const QString &arg1) 938 906 { 939 940 ui->cbSpecificFilesLevels->setEnabled(false);941 ui->cbSpecificFilesLevels->setChecked(false);942 ui->cbDatLevels->setEnabled(false);943 ui->cbDatLevels->setChecked(false);944 ui->cbBnvLevels->setEnabled(false);945 ui->cbBnvLevels->setChecked(false);946 ui->cbAdditionalSourcesLevels->setEnabled(false);947 ui->cbAdditionalSourcesLevels->setChecked(false);948 ui->cbGridsLevels->setEnabled(false);949 ui->cbGridsLevels->setChecked(false);950 951 if(arg1=="DAT"){ //case sensitive is faster952 ui->cbSpecificFilesLevels->setEnabled(true);953 }954 else if(arg1=="ONI FILES"){ //case sensitive is faster955 ui->cbDatLevels->setEnabled(true);956 }957 else if(arg1=="DAE"){958 ui->cbBnvLevels->setEnabled(true);959 ui->cbAdditionalSourcesLevels->setEnabled(true);960 }961 962 907 updateComboBox(arg1, ui->cbToLevels); 963 908 } … … 969 914 970 915 void MainWindow::updateComboBox(const QString &arg1, QComboBox *comboBox){ 971 QString identifier=ui->tabWidget->tabText(ui->tabWidget->currentIndex()).toLower(); // get current tab title text (lower case) 916 917 QString identifier; 918 919 if(comboBox == ui->cbToXML){ 920 identifier = ui->tabWidget->tabText(XMLTabIndex); 921 } 922 else if(comboBox == ui->cbToTextures){ 923 identifier = ui->tabWidget->tabText(TexturesTabIndex); 924 925 //Options are only used for DAT/ONI -> Image 926 if(QString::compare(arg1,"DAT / ONI",Qt::CaseSensitive)==0){ //case sensitive is faster 927 ui->gbTextures->setEnabled(false); 928 } 929 else{ 930 ui->gbTextures->setEnabled(true); 931 } 932 } 933 else if(comboBox == ui->cbToCharacters){ 934 identifier = ui->tabWidget->tabText(CharactersTabIndex); 935 936 ui->cbWithTRBS_ONCC->setEnabled(false); 937 ui->cbWithTRBS_ONCC->setChecked(false); 938 ui->cbCellShading->setEnabled(false); 939 ui->cbCellShading->setChecked(false); 940 ui->cbNormals->setEnabled(false); 941 ui->cbNormals->setChecked(false); 942 943 if(QString::compare(arg1,"TRAM ONI",Qt::CaseSensitive)==0){ //case sensitive is faster 944 ui->cbWithTRBS_ONCC->setEnabled(true); 945 } 946 else if(QString::compare(arg1,"TRBS DAE",Qt::CaseSensitive)==0){ 947 ui->cbNormals->setEnabled(true); 948 ui->cbCellShading->setEnabled(true); 949 } 950 951 } 952 else if(comboBox == ui->cbToObjects){ 953 identifier = ui->tabWidget->tabText(ObjectsTabIndex); 954 955 ui->cbTexture->setEnabled(false); 956 ui->cbTexture->setChecked(false); 957 ui->cbWithAnimation->setEnabled(false); 958 ui->cbWithAnimation->setChecked(false); 959 960 if(QString::compare(arg1,"M3GM ONI",Qt::CaseSensitive)==0){ //case sensitive is faster 961 ui->cbWithAnimation->setEnabled(true); 962 } 963 else if(QString::compare(arg1,"OBJ",Qt::CaseSensitive)==0){ 964 ui->cbTexture->setEnabled(true); 965 } 966 } 967 else if(comboBox == ui->cbToLevels){ 968 identifier = ui->tabWidget->tabText(LevelsTabIndex); 969 970 ui->cbSpecificFilesLevels->setEnabled(false); 971 ui->cbSpecificFilesLevels->setChecked(false); 972 ui->cbDatLevels->setEnabled(false); 973 ui->cbDatLevels->setChecked(false); 974 ui->cbBnvLevels->setEnabled(false); 975 ui->cbBnvLevels->setChecked(false); 976 ui->cbAdditionalSourcesLevels->setEnabled(false); 977 ui->cbAdditionalSourcesLevels->setChecked(false); 978 ui->cbGridsLevels->setEnabled(false); 979 ui->cbGridsLevels->setChecked(false); 980 981 if(arg1=="DAT"){ //case sensitive is faster 982 ui->cbSpecificFilesLevels->setEnabled(true); 983 } 984 else if(arg1=="ONI FILES"){ //case sensitive is faster 985 ui->cbDatLevels->setEnabled(true); 986 } 987 else if(arg1=="DAE"){ 988 ui->cbBnvLevels->setEnabled(true); 989 ui->cbAdditionalSourcesLevels->setEnabled(true); 990 } 991 } 992 else{ // Misc 993 identifier = ui->tabWidget->tabText(MiscTabIndex); 994 } 995 996 identifier = identifier.toLower(); // get current tab title text (lower case) 972 997 973 998 comboBox->clear(); … … 1105 1130 1106 1131 if(Util::showQuestionPopUp(this,"Are you sure you want to clear the content?",defaultButton)){ 1107 myTable->clearContents(); 1108 myTable->setRowCount(0); 1132 clearTableNoPrompt(myTable); 1109 1133 } 1110 1134 updateItemsLoaded(myTable); 1111 1135 } 1112 1136 1137 void MainWindow::clearTableNoPrompt(DropTableWidget *myTable){ 1138 myTable->clearContents(); 1139 myTable->setRowCount(0); 1140 } 1113 1141 1114 1142 void MainWindow::on_actionPreferences_triggered() … … 1186 1214 void MainWindow::on_actionCheck_OniSplit_version_triggered() 1187 1215 { 1188 QProcess *myProcess = new QProcess(); 1189 myProcess->setWorkingDirectory(Util::getAppPath()); 1190 myProcess->start(Util::getOniSplitExeName()+" -version"); 1191 myProcess->waitForFinished(-1); 1192 QString result=myProcess->readAllStandardOutput(); 1193 delete myProcess; 1194 Util::showPopUp("This Vago version was built with base in OniSplit version "+GlobalVars::BuiltOniSplitVersion+"\n\nActual version is:\n"+result); 1216 QProcess myProcess; 1217 myProcess.setWorkingDirectory(UtilVago::getAppPath()); 1218 myProcess.start(UtilVago::getOniSplitExeAbsolutePath()+" -version"); 1219 myProcess.waitForFinished(); 1220 1221 QString result=myProcess.readAllStandardOutput(); 1222 1223 Util::showPopUp("This Vago version was built with base in OniSplit version "+GlobalVars::BuiltOniSplitVersion+"\n\nCurrent version is:\n"+result.trimmed()); 1195 1224 } 1196 1225 1197 1226 void MainWindow::on_actionCheck_xmlTools_version_triggered() 1198 1227 { 1199 QProcess *myProcess = new QProcess();1200 myProcess ->setWorkingDirectory(Util::getAppPath());1201 myProcess ->start(Util::getXmlToolsExeName()+"version");1202 myProcess ->waitForFinished(-1);1203 QString result=myProcess ->readLine();1204 delete myProcess; 1205 Util::showPopUp("This Vago version was built with base in xmlTools version "+GlobalVars::BuiltXmlToolsVersion+"\n\nActual version is:\n"+result);1228 QProcess myProcess; 1229 myProcess.setWorkingDirectory(UtilVago::getAppPath()); 1230 myProcess.start(UtilVago::getXmlToolsExeAbsolutePath()+" --version"); 1231 myProcess.waitForFinished(); 1232 QString result=myProcess.readLine(); 1233 1234 Util::showPopUp("This Vago version was built with base in XmlTools version "+GlobalVars::BuiltXmlToolsVersion+"\n\nCurrent version is:\n"+result.trimmed()); 1206 1235 } 1207 1236 … … 1209 1238 Update items loaded 1210 1239 **/ 1211 void MainWindow::on_tabWidget_currentChanged(int index) 1212 { 1213 QString tabtext = ui->tabWidget->tabText(index); 1214 1215 if(tabtext.compare("XML",Qt::CaseSensitive)==0){ //case sentive is faster 1216 updateItemsLoaded(ui->twSourcesXML); 1217 } 1218 else if(tabtext.compare("Textures",Qt::CaseSensitive)==0){ 1219 updateItemsLoaded(ui->twSourcesTextures); 1220 } 1221 else if(tabtext.compare("Characters",Qt::CaseSensitive)==0){ 1222 updateItemsLoaded(ui->twSourcesCharacters); 1223 } 1224 else if(tabtext.compare("Objects",Qt::CaseSensitive)==0){ 1225 updateItemsLoaded(ui->twSourcesObjects); 1226 } 1227 else if(tabtext.compare("Levels",Qt::CaseSensitive)==0){ 1228 updateItemsLoaded(ui->twSourcesLevels); 1229 } 1230 else{ 1231 updateItemsLoaded(ui->twSourcesMisc); 1232 } 1240 void MainWindow::on_tabWidget_currentChanged(int) 1241 { 1242 updateItemsLoaded(getCurrentTableWidget()); 1233 1243 } 1234 1244 … … 1283 1293 void MainWindow::on_actionView_log_triggered() 1284 1294 { 1285 Util ::openLogFile();1295 UtilVago::openLogFile(); 1286 1296 } 1287 1297 … … 1289 1299 { 1290 1300 QDesktopServices::openUrl(QUrl("file:///"+this->AeLocation)); 1301 } 1302 1303 void MainWindow::on_actionSave_Project_triggered() 1304 { 1305 1306 QString filePath = QFileDialog::getSaveFileName(this, tr("Save File"), 1307 this->vagoSettings->value("LastProjectPath").toString(), 1308 tr("Vago project files (*.vgp)")); 1309 1310 if(!filePath.isEmpty()){ 1311 saveProjectState(filePath); 1312 } 1313 1314 } 1315 1316 void MainWindow::on_actionSave_triggered() 1317 { 1318 if(this->lastProjectFilePath.isEmpty()){ 1319 on_actionSave_Project_triggered(); 1320 return; 1321 } 1322 1323 saveProjectState(this->lastProjectFilePath); 1324 } 1325 1326 void MainWindow::on_actionLoad_Project_triggered() 1327 { 1328 1329 QString filePath = QFileDialog::getOpenFileName(this, tr("Load File"), 1330 this->vagoSettings->value("LastProjectPath").toString(), 1331 tr("Vago project files (*.vgp)")); 1332 if(!filePath.isEmpty()){ 1333 loadProjectState(filePath); 1334 } 1335 } 1336 1337 void MainWindow::on_actionProject1_triggered() 1338 { 1339 loadProjectState(this->ui->actionProject1->text()); 1340 } 1341 1342 void MainWindow::on_actionProject2_triggered() 1343 { 1344 loadProjectState(this->ui->actionProject2->text()); 1345 } 1346 1347 void MainWindow::on_actionProject3_triggered() 1348 { 1349 loadProjectState(this->ui->actionProject3->text()); 1350 } 1351 1352 void MainWindow::on_actionProject4_triggered() 1353 { 1354 loadProjectState(this->ui->actionProject4->text()); 1355 } 1356 1357 void MainWindow::on_actionProject5_triggered() 1358 { 1359 loadProjectState(this->ui->actionProject5->text()); 1291 1360 } 1292 1361 … … 1340 1409 } 1341 1410 1342 QMenu *menu = new QMenu();1343 QAction *copy = new QAction("Copy",myTable);1344 QAction *moveUp = new QAction("Move Up",myTable);1345 QAction *moveDown = new QAction("Move Down",myTable);1346 QAction *changeOptions = new QAction("Change To Current Options",myTable);1347 QMenu *changeOutput = new QMenu("Change Output for:");1348 QAction *outWorkspace = new QAction("Workspace",myTable);1349 QAction *outCurrOutput = new QAction("Current Output Folder",myTable);1350 QAction *outOther = new QAction("Other...",myTable);1351 QAction *edisable = new QAction("Enable/Disable",myTable);1352 1353 menu->addAction(copy );1411 std::unique_ptr<QMenu> menu = std::make_unique<QMenu>(); 1412 std::unique_ptr<QAction> copy = std::make_unique<QAction>("Copy",myTable); 1413 std::unique_ptr<QAction> moveUp = std::make_unique<QAction>("Move Up",myTable); 1414 std::unique_ptr<QAction> moveDown = std::make_unique<QAction>("Move Down",myTable); 1415 std::unique_ptr<QAction> changeOptions = std::make_unique<QAction>("Change To Current Options",myTable); 1416 std::unique_ptr<QMenu> changeOutput = std::make_unique<QMenu>("Change Output for:"); 1417 std::unique_ptr<QAction> outWorkspace = std::make_unique<QAction>("Workspace",myTable); 1418 std::unique_ptr<QAction> outCurrOutput = std::make_unique<QAction>("Current Output Folder",myTable); 1419 std::unique_ptr<QAction> outOther = std::make_unique<QAction>("Other...",myTable); 1420 std::unique_ptr<QAction> edisable = std::make_unique<QAction>("Enable/Disable",myTable); 1421 1422 menu->addAction(copy.get()); 1354 1423 menu->addSeparator(); 1355 menu->addAction(moveUp );1356 menu->addAction(moveDown );1424 menu->addAction(moveUp.get()); 1425 menu->addAction(moveDown.get()); 1357 1426 menu->addSeparator(); 1358 menu->addAction(changeOptions );1359 menu->addMenu(changeOutput );1360 changeOutput->addActions(QList<QAction*>() << outWorkspace << outCurrOutput << outOther);1361 menu->addAction(edisable );1427 menu->addAction(changeOptions.get()); 1428 menu->addMenu(changeOutput.get()); 1429 changeOutput->addActions(QList<QAction*>() << outWorkspace.get() << outCurrOutput.get() << outOther.get()); 1430 menu->addAction(edisable.get()); 1362 1431 1363 1432 … … 1383 1452 QAction* selectedOption = menu->exec(event->globalPos()); 1384 1453 1385 if(selectedOption==copy ){1454 if(selectedOption==copy.get()){ 1386 1455 //Let's copy the contents to the clipboard 1387 1456 … … 1406 1475 showSuccessStatusMessage(QString::number(size) + (size==1?" item ":" items ")+ "copied to the clipboard"); 1407 1476 } 1408 else if(selectedOption==moveUp ){1477 else if(selectedOption==moveUp.get()){ 1409 1478 qSort(selectedRows); //let's order the selections by the row number, so we know exactly how to swap it 1410 1479 myTable->swapPositions(selectedRows,-1); 1411 1480 } 1412 else if(selectedOption==moveDown ){1481 else if(selectedOption==moveDown.get()){ 1413 1482 qSort(selectedRows); 1414 1483 myTable->swapPositions(selectedRows,+1); 1415 1484 } 1416 else if(selectedOption==changeOptions ){1485 else if(selectedOption==changeOptions.get()){ 1417 1486 changeToCurrentSettings(selectedRows,myTable); 1418 1487 } 1419 else if(selectedOption==outWorkspace ){1488 else if(selectedOption==outWorkspace.get()){ 1420 1489 changeItemsOutput(myTable,selectedRows,this->workspaceLocation); 1421 1490 } 1422 else if(selectedOption==outCurrOutput ){1491 else if(selectedOption==outCurrOutput.get()){ 1423 1492 changeItemsOutput(myTable,selectedRows,this->outputFolder); 1424 1493 } 1425 else if(selectedOption==outOther ){1494 else if(selectedOption==outOther.get()){ 1426 1495 1427 1496 QString newDir=QFileDialog::getExistingDirectory(this,"Choose the folder for the output of the files selected...",this->AeLocation+"/GameDataFolder"); … … 1435 1504 1436 1505 } 1437 else if(selectedOption==edisable ){1506 else if(selectedOption==edisable.get()){ 1438 1507 1439 1508 int enabledCount=0, disabledCount=0; … … 1473 1542 showSuccessStatusMessage(result); 1474 1543 } 1475 1476 delete copy;1477 delete moveUp;1478 delete moveDown;1479 delete changeOptions;1480 delete outWorkspace;1481 delete outCurrOutput;1482 delete outOther;1483 delete changeOutput;1484 delete edisable;1485 delete menu;1486 1544 } 1487 1545 … … 1558 1616 } 1559 1617 1560 /**1561 This is OS indepented. It maintain size ratio over the Windows and Mac.1562 **/1563 void MainWindow::setConverterButtonsSize(){1564 int height=ui->pbConvertXML->sizeHint().height()*1.3;1565 ui->pbConvertXML->setMinimumHeight(height);1566 ui->pbConvertTextures->setMinimumHeight(height);1567 ui->pbConvertObjects->setMinimumHeight(height);1568 ui->pbConvertCharacters->setMinimumHeight(height);1569 ui->pbConvertLevels->setMinimumHeight(height);1570 ui->pbConvertMisc->setMinimumHeight(height);1571 }1572 1573 1618 void MainWindow::connectSlots(){ 1574 1619 … … 1624 1669 connect(ui->twSourcesMisc, SIGNAL(dtContextMenu(DropTableWidget*,QContextMenuEvent*)), this, SLOT(dtContextMenu(DropTableWidget*,QContextMenuEvent*))); 1625 1670 } 1671 1672 void MainWindow::saveProjectState(const QString &filePath) 1673 { 1674 1675 QList<DropTableWidget*> tableWidgets = getAllTableWidgets(); 1676 1677 pugi::xml_document doc; 1678 1679 pugi::xml_node rootNode = doc.append_child("VagoProject"); 1680 rootNode.append_attribute("vagoVersion").set_value(GlobalVars::AppVersion.toUtf8().constData()); 1681 1682 foreach(DropTableWidget* const &myTable, tableWidgets){ 1683 saveProjectWidget(rootNode, myTable); 1684 } 1685 1686 if(!doc.save_file(filePath.toUtf8().constData(), PUGIXML_TEXT("\t"), pugi::format_default | pugi::format_write_bom, pugi::xml_encoding::encoding_utf8)){ 1687 UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "An error ocurred while trying to save the project file. Please try another path."); 1688 return; 1689 } 1690 1691 this->vagoSettings->setValue("LastProjectPath",QFileInfo(filePath).absoluteDir().path()); 1692 1693 this->lastProjectFilePath = filePath; 1694 1695 addNewRecentProject(filePath); 1696 1697 setVagoWindowTitle(); 1698 } 1699 1700 void MainWindow::saveProjectWidget(pugi::xml_node &rootNode, DropTableWidget* table) 1701 { 1702 QString from; 1703 QString to; 1704 QString tabName = getTabNameByTableWidget(table); 1705 1706 pugi::xml_node currentNodeTable = rootNode.append_child("tempName"); 1707 pugi::xml_node options; 1708 1709 if(table==ui->twSourcesXML){ //So we only need to parse one command. 1710 from = ui->cbFromXML->currentText().toUtf8().constData(); 1711 to = ui->cbToXML->currentText().toUtf8().constData(); 1712 } 1713 else if(table==ui->twSourcesTextures){ 1714 from = ui->cbFromTextures->currentText().toUtf8().constData(); 1715 to = ui->cbToTextures->currentText().toUtf8().constData(); 1716 options = currentNodeTable.append_child("Options"); 1717 options.append_attribute("type").set_value(Util::qStrToCstr(getTextureRBCheckedTypeTexture()->text())); 1718 options.append_attribute("genMipMaps").set_value(Util::boolToCstr(ui->cbMipMapsTextures->isChecked())); 1719 options.append_attribute("noUwrap").set_value(Util::boolToCstr(ui->cbNoUwrap->isChecked())); 1720 options.append_attribute("noVwrap").set_value(Util::boolToCstr(ui->cbNoVwrap->isChecked())); 1721 options.append_attribute("large").set_value(Util::boolToCstr(ui->cbLarge->isChecked())); 1722 options.append_attribute("envMap").set_value(Util::boolToCstr(ui->cbEnvMap->isChecked())); 1723 options.append_attribute("envMapValue").set_value(Util::qStrToCstr(ui->leEnvMapTexture->text())); 1724 } 1725 else if(table==ui->twSourcesCharacters){ 1726 from = ui->cbFromCharacters->currentText().toUtf8().constData(); 1727 to = ui->cbToCharacters->currentText().toUtf8().constData(); 1728 options = currentNodeTable.append_child("Options"); 1729 options.append_attribute("cellShading").set_value(Util::boolToCstr(ui->cbCellShading->isChecked())); 1730 options.append_attribute("normals").set_value(Util::boolToCstr(ui->cbNormals->isChecked())); 1731 options.append_attribute("extractTRBSONCC").set_value(Util::boolToCstr(ui->cbWithTRBS_ONCC->isChecked())); 1732 options.append_attribute("extractTRBSONCCValue").set_value(Util::qStrToCstr(ui->leTRBS_ONCC->text())); 1733 } 1734 else if(table==ui->twSourcesObjects){ 1735 from = ui->cbFromObjects->currentText().toUtf8().constData(); 1736 to = ui->cbToObjects->currentText().toUtf8().constData(); 1737 options = currentNodeTable.append_child("Options"); 1738 options.append_attribute("texture").set_value(Util::boolToCstr(ui->cbTexture->isChecked())); 1739 options.append_attribute("textureValue").set_value(Util::qStrToCstr(ui->leTextureName->text())); 1740 options.append_attribute("withAnimation").set_value(Util::boolToCstr(ui->cbWithAnimation->isChecked())); 1741 options.append_attribute("withAnimationValue").set_value(Util::qStrToCstr(ui->leAnimationName->text())); 1742 } 1743 else if(table==ui->twSourcesLevels){ 1744 from = ui->cbFromLevels->currentText().toUtf8().constData(); 1745 to = ui->cbToLevels->currentText().toUtf8().constData(); 1746 options = currentNodeTable.append_child("Options"); 1747 options.append_attribute("extractWithFiles").set_value(Util::boolToCstr(ui->cbSpecificFilesLevels->isChecked())); 1748 options.append_attribute("extractWithFilesValue").set_value(Util::qStrToCstr(ui->leSpecificFilesLevels->text())); 1749 options.append_attribute("datFilename").set_value(Util::boolToCstr(ui->cbDatLevels->isChecked())); 1750 options.append_attribute("datFilenameValue").set_value(Util::qStrToCstr(ui->leTargetDatLevels->text())); 1751 options.append_attribute("bnvSource").set_value(Util::boolToCstr(ui->cbBnvLevels->isChecked())); 1752 options.append_attribute("bnvSourceValue").set_value(Util::qStrToCstr(ui->leBnvLevels->text())); 1753 options.append_attribute("generateGrids").set_value(Util::boolToCstr(ui->cbGridsLevels->isChecked())); 1754 options.append_attribute("additionalSources").set_value(Util::boolToCstr(ui->cbAdditionalSourcesLevels->isChecked())); 1755 options.append_attribute("additionalSourcesValue").set_value(Util::qStrToCstr(ui->leAdditSourcesLevels->text())); 1756 } 1757 else{ 1758 from = ui->cbFromMisc->currentText().toUtf8().constData(); 1759 to = ui->cbToMisc->currentText().toUtf8().constData(); 1760 } 1761 1762 currentNodeTable.set_name(tabName.toUtf8().constData()); 1763 1764 currentNodeTable.append_attribute("from").set_value(from.toUtf8().constData()); 1765 currentNodeTable.append_attribute("to").set_value(to.toUtf8().constData()); 1766 1767 1768 for(int i=0; i<table->rowCount(); i++){ 1769 1770 QString currFileFolder = table->item(i,0)->text(); 1771 QString currFromTo = table->item(i,1)->text(); 1772 QString currCommand = table->item(i,2)->text(); 1773 1774 pugi::xml_node currentRow = currentNodeTable.append_child("Row"); 1775 1776 1777 currentRow.append_attribute("fileFolder").set_value(Util::qStrToCstr(currFileFolder)); 1778 currentRow.append_attribute("fromTo").set_value(Util::qStrToCstr(currFromTo)); 1779 currentRow.append_attribute("command").set_value(Util::qStrToCstr(currCommand)); 1780 1781 if(table->item(i,2)->background()==table->disabledBackStyle){ 1782 currentRow.append_attribute("disabled").set_value(true); 1783 } 1784 1785 } 1786 } 1787 1788 QRadioButton* MainWindow::getTextureRBCheckedTypeTexture() 1789 { 1790 if(ui->rbBGR32->isChecked()){ 1791 return ui->rbBGR32; 1792 } 1793 else if(ui->rbBGRA32->isChecked()){ 1794 return ui->rbBGRA32; 1795 } 1796 else if(ui->rbBGR555->isChecked()){ 1797 return ui->rbBGR555; 1798 } 1799 else if(ui->rbBGRA5551->isChecked()){ 1800 return ui->rbBGRA5551; 1801 } 1802 else if(ui->rbBGRA444->isChecked()){ 1803 return ui->rbBGRA444; 1804 } 1805 else{ //dxt1 checked 1806 return ui->rbDxt1; 1807 } 1808 } 1809 1810 QRadioButton* MainWindow::getTextureRBTypeTextureByName(const QString &texType) 1811 { 1812 if(QString::compare(texType,ui->rbBGR32->text(),Qt::CaseSensitive)==0){ 1813 return ui->rbBGR32; 1814 } 1815 else if(QString::compare(texType,ui->rbBGRA32->text(),Qt::CaseSensitive)==0){ 1816 return ui->rbBGRA32; 1817 } 1818 else if(QString::compare(texType, ui->rbBGR555->text(),Qt::CaseSensitive)==0){ 1819 return ui->rbBGR555; 1820 } 1821 else if(QString::compare(texType,ui->rbBGRA5551->text(),Qt::CaseSensitive)==0){ 1822 return ui->rbBGRA5551; 1823 } 1824 else if(QString::compare(texType,ui->rbBGRA444->text(),Qt::CaseSensitive)==0){ 1825 return ui->rbBGRA444; 1826 } 1827 else{ //dxt1 1828 return ui->rbDxt1; 1829 } 1830 1831 } 1832 1833 void MainWindow::setVagoWindowTitle(){ 1834 1835 QString vagoTitle = "Vago v"+GlobalVars::AppVersion + " - "; 1836 1837 if(this->lastProjectFilePath.isEmpty()){ 1838 vagoTitle += "Untitled"; 1839 } 1840 else{ 1841 vagoTitle += Util::cutNameWithoutBackSlash(this->lastProjectFilePath); 1842 } 1843 1844 setWindowTitle(vagoTitle); 1845 } 1846 1847 DropTableWidget* MainWindow::getCurrentTableWidget(){ 1848 1849 return getTableWidgetByTabName(ui->tabWidget->tabText(ui->tabWidget->currentIndex())); 1850 1851 } 1852 1853 DropTableWidget* MainWindow::getTableWidgetByTabName(const QString &tabName){ 1854 1855 if(tabName.compare("XML",Qt::CaseSensitive)==0){ //case sentive is faster 1856 return ui->twSourcesXML; 1857 } 1858 else if(tabName.compare("Textures",Qt::CaseSensitive)==0){ 1859 return ui->twSourcesTextures; 1860 } 1861 else if(tabName.compare("Characters",Qt::CaseSensitive)==0){ 1862 return ui->twSourcesCharacters; 1863 } 1864 else if(tabName.compare("Objects",Qt::CaseSensitive)==0){ 1865 return ui->twSourcesObjects; 1866 } 1867 else if(tabName.compare("Levels",Qt::CaseSensitive)==0){ 1868 return ui->twSourcesLevels; 1869 } 1870 else{ 1871 return ui->twSourcesMisc; 1872 } 1873 1874 } 1875 1876 QString MainWindow::getCurrentTabName(){ 1877 return ui->tabWidget->tabText(ui->tabWidget->currentIndex()); 1878 } 1879 1880 QString MainWindow::getTabNameByTableWidget(DropTableWidget* table){ 1881 1882 if(table == ui->twSourcesXML){ 1883 return ui->tabWidget->tabText(XMLTabIndex); 1884 } 1885 else if(table == ui->twSourcesTextures){ 1886 return ui->tabWidget->tabText(TexturesTabIndex); 1887 } 1888 else if(table == ui->twSourcesCharacters){ 1889 return ui->tabWidget->tabText(CharactersTabIndex); 1890 } 1891 else if(table == ui->twSourcesObjects){ 1892 return ui->tabWidget->tabText(ObjectsTabIndex); 1893 } 1894 else if(table == ui->twSourcesLevels){ 1895 return ui->tabWidget->tabText(LevelsTabIndex); 1896 } 1897 else{ 1898 return ui->tabWidget->tabText(MiscTabIndex); 1899 } 1900 1901 } 1902 1903 QList<DropTableWidget*> MainWindow::getAllTableWidgets() 1904 { 1905 QList<DropTableWidget*> tableWidgets; 1906 1907 tableWidgets << ui->twSourcesXML << ui->twSourcesTextures << ui->twSourcesCharacters 1908 << ui->twSourcesObjects << ui->twSourcesLevels << ui->twSourcesMisc; 1909 1910 return tableWidgets; 1911 } 1912 1913 void MainWindow::loadProjectState(const QString &filePath) 1914 { 1915 1916 QString statusError = "Couldn't load project."; 1917 1918 pugi::xml_document doc; 1919 1920 pugi::xml_parse_result result = doc.load_file(Util::qStrToCstr(filePath)); 1921 1922 if(result.status!=pugi::status_ok){ 1923 UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "An error ocurred while loading project file.\n" + QString(result.description())); 1924 showErrStatusMessage(statusError); 1925 return; 1926 } 1927 1928 1929 if(QString(doc.root().first_child().name()) != "VagoProject"){ 1930 UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, QString(doc.root().name()) + "The file opened is not a valid VagoProject file. Load aborted."); 1931 showErrStatusMessage(statusError); 1932 return; 1933 } 1934 1935 QString projVagoVersion; 1936 1937 try{ 1938 projVagoVersion = QString(doc.select_node("/VagoProject/@vagoVersion").attribute().value()); 1939 } 1940 catch (const pugi::xpath_exception& e) 1941 { 1942 UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "Couldn't find the vagoVersion of the current project. Load aborted.\n" + QString(e.what())); 1943 showErrStatusMessage(statusError); 1944 return; 1945 } 1946 1947 if(!projVagoVersion.startsWith(GlobalVars::LastCompatibleVersion)){ 1948 UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "The project that you are trying to load seems it is not compatible with your Vago Version. Please update Vago and try again."); 1949 showErrStatusMessage(statusError); 1950 return; 1951 } 1952 1953 // After the initial validations begin loading the project data 1954 1955 QList<DropTableWidget*> tableWidgets = getAllTableWidgets(); 1956 1957 try{ 1958 foreach(DropTableWidget* const &myTable, tableWidgets){ 1959 loadProjectWidget(doc, myTable); 1960 } 1961 } 1962 catch(const std::exception& e){ 1963 UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "Couldn't load the vago project. Error: " + QString(e.what())); 1964 showErrStatusMessage(statusError); 1965 return; 1966 } 1967 1968 this->vagoSettings->setValue("LastProjectPath",QFileInfo(filePath).absoluteDir().path()); 1969 1970 this->lastProjectFilePath = filePath; 1971 1972 addNewRecentProject(filePath); 1973 1974 setVagoWindowTitle(); 1975 1976 showSuccessStatusMessage("Project loaded sucessfully."); 1977 } 1978 1979 1980 void MainWindow::loadProjectWidget(pugi::xml_document &doc, DropTableWidget* table) 1981 { 1982 QString tabName = getTabNameByTableWidget(table); 1983 QString from (doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/@from")).attribute().value()); 1984 QString to (doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/@to")).attribute().value()); 1985 1986 if(table==ui->twSourcesXML){ 1987 ui->cbFromXML->setCurrentText(from); 1988 on_cbFromXML_currentIndexChanged(from); 1989 ui->cbToXML->setCurrentText(to); 1990 } 1991 else if(table==ui->twSourcesTextures){ 1992 //ui->cbFromTextures->setCurrentText(from); 1993 on_cbFromTextures_currentIndexChanged(from); 1994 ui->cbToTextures->setCurrentText(to); 1995 1996 getTextureRBTypeTextureByName((doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@type")).attribute().value()))->setChecked(true); 1997 ui->cbMipMapsTextures->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@genMipMaps")).attribute().as_bool()); 1998 ui->cbNoUwrap->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@noUwrap")).attribute().as_bool()); 1999 ui->cbNoVwrap->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@noVwrap")).attribute().as_bool()); 2000 ui->cbLarge->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@large")).attribute().as_bool()); 2001 ui->cbEnvMap->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@envMap")).attribute().as_bool()); 2002 ui->leEnvMapTexture->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@envMapValue")).attribute().value())); 2003 } 2004 else if(table==ui->twSourcesCharacters){ 2005 ui->cbFromCharacters->setCurrentText(from); 2006 on_cbFromCharacters_currentIndexChanged(from); 2007 ui->cbToCharacters->setCurrentText(to); 2008 2009 2010 ui->cbCellShading->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@cellShading")).attribute().as_bool()); 2011 ui->cbNormals->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@normals")).attribute().as_bool()); 2012 ui->cbWithTRBS_ONCC->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@extractTRBSONCC")).attribute().as_bool()); 2013 ui->leTRBS_ONCC->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@extractTRBSONCCValue")).attribute().value())); 2014 } 2015 else if(table==ui->twSourcesObjects){ 2016 ui->cbFromObjects->setCurrentText(from); 2017 on_cbFromObjects_currentIndexChanged(from); 2018 ui->cbToObjects->setCurrentText(to); 2019 2020 ui->cbTexture->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@texture")).attribute().as_bool()); 2021 ui->leTextureName->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@textureValue")).attribute().value())); 2022 ui->cbWithAnimation->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@withAnimation")).attribute().as_bool()); 2023 ui->leAnimationName->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@withAnimationValue")).attribute().value())); 2024 } 2025 else if(table==ui->twSourcesLevels){ 2026 ui->cbFromLevels->setCurrentText(from); 2027 on_cbFromLevels_currentIndexChanged(from); 2028 ui->cbToLevels->setCurrentText(to); 2029 2030 ui->cbSpecificFilesLevels->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@extractWithFiles")).attribute().as_bool()); 2031 ui->leSpecificFilesLevels->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@extractWithFilesValue")).attribute().value())); 2032 ui->cbDatLevels->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@datFilename")).attribute().as_bool()); 2033 ui->leTargetDatLevels->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@datFilenameValue")).attribute().value())); 2034 ui->cbBnvLevels->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@bnvSource")).attribute().as_bool()); 2035 ui->leBnvLevels->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@bnvSourceValue")).attribute().value())); 2036 ui->cbGridsLevels->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@generateGrids")).attribute().as_bool()); 2037 ui->cbAdditionalSourcesLevels->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@additionalSources")).attribute().as_bool()); 2038 ui->leAdditSourcesLevels->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@bnvSource")).attribute().value())); 2039 } 2040 else{ 2041 ui->cbFromMisc->setCurrentText(from); 2042 on_cbFromMisc_currentIndexChanged(from); 2043 ui->cbToMisc->setCurrentText(to); 2044 } 2045 2046 // Clean previous rows 2047 clearTableNoPrompt(table); 2048 2049 for(const pugi::xpath_node &xPathNode : doc.select_nodes(Util::qStrToCstr("/VagoProject/"+tabName+"/Row"))){ 2050 pugi::xml_node currNode = xPathNode.node(); 2051 2052 QString currFileFolder = currNode.attribute("fileFolder").value(); 2053 QString currFromTo = currNode.attribute("fromTo").value(); 2054 QString currCommand = currNode.attribute("command").value(); 2055 2056 bool isToDisable = false; 2057 pugi::xml_attribute disabledAttr = currNode.attribute("disabled"); 2058 isToDisable = disabledAttr.empty() ? false : disabledAttr.as_bool(); 2059 2060 addRowTable(table,currFileFolder,currFromTo,currCommand, isToDisable); 2061 } 2062 } 2063 2064 void MainWindow::saveRecentProjects(){ 2065 for(int i=0; i<this->recentProjectsList.size(); i++){ 2066 this->vagoSettings->setValue("RecentProject" + QString::number(i+1), recentProjectsList[i]); 2067 } 2068 } 2069 2070 void MainWindow::loadRecentProjects(){ 2071 for(int i=0; i<this->recentProjectsMaxSize; i++){ 2072 2073 QString currProj = this->vagoSettings->value("RecentProject" + QString::number(i+1)).toString(); 2074 2075 if(!currProj.isEmpty()){ 2076 recentProjectsList.append(currProj); 2077 } 2078 else{ 2079 break; 2080 } 2081 } 2082 2083 reloadRecentProjectsMenu(); 2084 2085 } 2086 2087 void MainWindow::addNewRecentProject(const QString &filePath){ 2088 2089 // If the new project is equal to the last one simply ignore 2090 if(filePath == this->vagoSettings->value("RecentProject1").toString()){ 2091 return; 2092 } 2093 2094 // If the item already exists in our list remove it, so it can go to the top again 2095 for(auto it = this->recentProjectsList.begin(); it != this->recentProjectsList.end();){ 2096 if(*it == filePath){ 2097 it = this->recentProjectsList.erase(it); 2098 } 2099 else{ 2100 it++; 2101 } 2102 } 2103 2104 // if we gonna overflow our list, remove the older item to reserve space to the new one 2105 if(this->recentProjectsList.size()==this->recentProjectsMaxSize){ 2106 this->recentProjectsList.removeLast(); 2107 } 2108 2109 this->vagoSettings->setValue("LastProjectPath",QFileInfo(filePath).absoluteDir().path()); 2110 2111 // add new recent file 2112 this->recentProjectsList.prepend(filePath); 2113 2114 reloadRecentProjectsMenu(); 2115 2116 saveRecentProjects(); 2117 } 2118 2119 void MainWindow::reloadRecentProjectsMenu(){ 2120 2121 ui->menuRecent_Projects->setEnabled(false); 2122 ui->actionProject1->setVisible(false); 2123 ui->actionProject2->setVisible(false); 2124 ui->actionProject3->setVisible(false); 2125 ui->actionProject4->setVisible(false); 2126 ui->actionProject5->setVisible(false); 2127 2128 { 2129 QList<QString>::const_iterator it; 2130 int i; 2131 for(it = recentProjectsList.cbegin(), i=0; it != recentProjectsList.cend(); it++, i++){ 2132 2133 QAction* currAction = nullptr; 2134 2135 switch (i){ 2136 case 0: 2137 currAction = ui->actionProject1; 2138 break; 2139 case 1: 2140 currAction = ui->actionProject2; 2141 break; 2142 case 2: 2143 currAction = ui->actionProject3; 2144 break; 2145 case 3: 2146 currAction = ui->actionProject4; 2147 break; 2148 case 4: 2149 currAction = ui->actionProject5; 2150 break; 2151 } 2152 2153 if(currAction){ 2154 ui->menuRecent_Projects->setEnabled(true); 2155 currAction->setText(*it); 2156 currAction->setVisible(true); 2157 } 2158 } 2159 } 2160 2161 } -
Vago/trunk/Vago/mainwindow.h
r1035 r1047 2 2 #define MAINWINDOW_H 3 3 4 #include "util .h"4 #include "utilvago.h" 5 5 #include "preferences.h" 6 6 #include "manualcommands.h" … … 12 12 13 13 #include <QMainWindow> 14 #include <QSettings>15 14 #include <QMessageBox> 16 15 #include <QProcess> … … 30 29 #include <QScriptEngine> 31 30 #include <QScriptValueIterator> 31 #include <QWinTaskbarProgress> 32 #include <QWinTaskbarButton> 33 34 #include "libs/pugixml/pugixml.hpp" 32 35 //#include <QDebug> 33 36 … … 39 42 { 40 43 Q_OBJECT 41 44 42 45 public: 43 46 explicit MainWindow(QWidget *parent = 0); … … 47 50 protected: 48 51 void closeEvent(QCloseEvent *event); 49 52 50 53 private slots: 51 54 void on_actionExit_triggered(); … … 67 70 void on_pbAddSourceXML_clicked(); 68 71 69 void on_pbConvert XML_clicked();72 void on_pbConvert_clicked(); 70 73 71 74 void TsetupProgressBar(int max); … … 105 108 void on_pbAddSourceMisc_clicked(); 106 109 107 void on_pbConvertTextures_clicked();108 109 void on_pbConvertObjects_clicked();110 111 void on_pbConvertLevels_clicked();112 113 void on_pbConvertMisc_clicked();114 115 110 void on_pbRemoveSourceObjects_clicked(); 116 111 … … 155 150 void on_cbFromCharacters_currentIndexChanged(const QString &arg1); 156 151 157 void on_pbConvertCharacters_clicked();158 159 152 void on_pbAddSourceCharacters_clicked(); 160 153 … … 179 172 void on_tbAbortConversion_clicked(); 180 173 181 void on_tabWidget_currentChanged(int index); 174 void on_tabWidget_currentChanged(int); 175 176 void on_actionSave_Project_triggered(); 177 178 void on_actionSave_triggered(); 179 180 void on_actionLoad_Project_triggered(); 181 182 void on_actionProject1_triggered(); 183 184 void on_actionProject2_triggered(); 185 186 void on_actionProject3_triggered(); 187 188 void on_actionProject4_triggered(); 189 190 void on_actionProject5_triggered(); 182 191 183 192 private: … … 188 197 QString outputFolder; //Output folder 189 198 QString AeLocation; //Workspace location 199 QString lastProjectFilePath; 190 200 int startedWindowWidth; 191 201 int startedWindowHeight; … … 200 210 QSettings *vagoSettings; 201 211 static const QString VagoSettingsName; 212 static constexpr int recentProjectsMaxSize=5; 213 QList<QString> recentProjectsList; 214 #ifdef Q_OS_WIN 215 // These are deleted automatically by the window (since button is attached to it) 216 QWinTaskbarProgress *win7TaskBarProgress; 217 QWinTaskbarButton *win7TaskBarButton; 218 #endif 219 220 // anonymous enum 221 enum {XMLTabIndex, TexturesTabIndex, CharactersTabIndex, ObjectsTabIndex, LevelsTabIndex, MiscTabIndex}; 202 222 203 223 void connectSlots(); … … 205 225 void showSuccessStatusMessage(QString message); 206 226 void mapCommands(); 207 void addRowTable(DropTableWidget *myTable, QString file, QString fromTo, QString command);227 void addRowTable(DropTableWidget *myTable, QString file, QString fromTo, QString command, bool isToDisabled=false); 208 228 void clearTableContents(DropTableWidget *myTable); 229 void clearTableNoPrompt(DropTableWidget *myTable); 209 230 void removeTableContents(DropTableWidget *myTable); 210 231 void updateComboBox(const QString &arg1, QComboBox *comboBox); 211 void startConversion( DropTableWidget *myTable);232 void startConversion(); 212 233 void updateItemsLoaded(DropTableWidget *currentTable); 213 234 void changeToCurrentSettings(QList<int> rows, DropTableWidget* myTable); //change some rows to the current settings 214 235 void changeItemsOutput(DropTableWidget* myTable, QList<int> rows, QString newOutput); 215 236 void setConverterButtonsSize(); 237 void saveProjectState(const QString &filePath); 238 void saveProjectWidget(pugi::xml_node &rootNode, DropTableWidget* table); 239 void loadProjectState(const QString &filePath); 240 void setVagoWindowTitle(); 241 void loadProjectWidget(pugi::xml_document &doc, DropTableWidget* table); 242 void saveRecentProjects(); 243 void loadRecentProjects(); 244 void addNewRecentProject(const QString &filePath); 245 void reloadRecentProjectsMenu(); 246 void showEvent(QShowEvent *e); 216 247 QString getFileOutputFolder(QString fromTo, QString myOutputFolder=""); 217 248 QString fileParsingXML(QString tabTitle, QString myOutputFolder, QString from, QString to , QString file); … … 224 255 QString getTypeConversion(DropTableWidget *myTable); //get the current type for a table 225 256 QString getOSIndependentAppPath(); 257 QString getTabNameByTableWidget(DropTableWidget* table); 258 QString getCurrentTabName(); 259 QRadioButton* getTextureRBCheckedTypeTexture(); 260 QRadioButton *getTextureRBTypeTextureByName(const QString &texType); 261 DropTableWidget *getCurrentTableWidget(); 262 DropTableWidget* getTableWidgetByTabName(const QString &tabName); 263 QList<DropTableWidget*> getAllTableWidgets(); 226 264 227 265 signals: -
Vago/trunk/Vago/mainwindow.ui
r898 r1047 284 284 </layout> 285 285 </item> 286 <item>287 <widget class="Line" name="line_3">288 <property name="orientation">289 <enum>Qt::Horizontal</enum>290 </property>291 </widget>292 </item>293 <item>294 <widget class="QPushButton" name="pbConvertXML">295 <property name="minimumSize">296 <size>297 <width>0</width>298 <height>30</height>299 </size>300 </property>301 <property name="text">302 <string>Convert</string>303 </property>304 </widget>305 </item>306 286 </layout> 307 287 </widget> … … 553 533 </item> 554 534 </layout> 555 </widget>556 </item>557 <item>558 <widget class="Line" name="line_8">559 <property name="orientation">560 <enum>Qt::Horizontal</enum>561 </property>562 </widget>563 </item>564 <item>565 <widget class="QPushButton" name="pbConvertTextures">566 <property name="minimumSize">567 <size>568 <width>0</width>569 <height>30</height>570 </size>571 </property>572 <property name="text">573 <string>Convert</string>574 </property>575 535 </widget> 576 536 </item> … … 758 718 </widget> 759 719 </item> 760 <item>761 <widget class="Line" name="line_15">762 <property name="orientation">763 <enum>Qt::Horizontal</enum>764 </property>765 </widget>766 </item>767 <item>768 <widget class="QPushButton" name="pbConvertCharacters">769 <property name="minimumSize">770 <size>771 <width>0</width>772 <height>30</height>773 </size>774 </property>775 <property name="text">776 <string>Convert</string>777 </property>778 </widget>779 </item>780 720 </layout> 781 721 </widget> … … 970 910 </item> 971 911 </layout> 972 </widget>973 </item>974 <item>975 <widget class="Line" name="line_9">976 <property name="orientation">977 <enum>Qt::Horizontal</enum>978 </property>979 </widget>980 </item>981 <item>982 <widget class="QPushButton" name="pbConvertObjects">983 <property name="minimumSize">984 <size>985 <width>0</width>986 <height>30</height>987 </size>988 </property>989 <property name="text">990 <string>Convert</string>991 </property>992 912 </widget> 993 913 </item> … … 1281 1201 </widget> 1282 1202 </item> 1283 <item>1284 <widget class="Line" name="line_10">1285 <property name="orientation">1286 <enum>Qt::Horizontal</enum>1287 </property>1288 </widget>1289 </item>1290 <item>1291 <widget class="QPushButton" name="pbConvertLevels">1292 <property name="minimumSize">1293 <size>1294 <width>0</width>1295 <height>30</height>1296 </size>1297 </property>1298 <property name="text">1299 <string>Convert</string>1300 </property>1301 </widget>1302 </item>1303 1203 </layout> 1304 1204 </widget> … … 1427 1327 </widget> 1428 1328 </item> 1429 <item>1430 <widget class="Line" name="line_7">1431 <property name="orientation">1432 <enum>Qt::Horizontal</enum>1433 </property>1434 </widget>1435 </item>1436 <item>1437 <widget class="QPushButton" name="pbConvertMisc">1438 <property name="minimumSize">1439 <size>1440 <width>0</width>1441 <height>30</height>1442 </size>1443 </property>1444 <property name="text">1445 <string>Convert</string>1446 </property>1447 </widget>1448 </item>1449 1329 </layout> 1450 1330 </widget> 1331 </widget> 1332 </item> 1333 <item> 1334 <widget class="Line" name="line_3"> 1335 <property name="orientation"> 1336 <enum>Qt::Horizontal</enum> 1337 </property> 1338 </widget> 1339 </item> 1340 <item> 1341 <widget class="QPushButton" name="pbConvert"> 1342 <property name="minimumSize"> 1343 <size> 1344 <width>0</width> 1345 <height>30</height> 1346 </size> 1347 </property> 1348 <property name="toolTip"> 1349 <string>Convert the sources above</string> 1350 </property> 1351 <property name="text"> 1352 <string>Convert</string> 1353 </property> 1354 <property name="shortcut"> 1355 <string>Ctrl+Return</string> 1356 </property> 1451 1357 </widget> 1452 1358 </item> … … 1459 1365 <y>0</y> 1460 1366 <width>800</width> 1461 <height>2 2</height>1367 <height>20</height> 1462 1368 </rect> 1463 1369 </property> … … 1466 1372 <string>File</string> 1467 1373 </property> 1374 <widget class="QMenu" name="menuRecent_Projects"> 1375 <property name="title"> 1376 <string>Recent Projects</string> 1377 </property> 1378 <addaction name="actionProject1"/> 1379 <addaction name="actionProject2"/> 1380 <addaction name="actionProject3"/> 1381 <addaction name="actionProject4"/> 1382 <addaction name="actionProject5"/> 1383 </widget> 1468 1384 <addaction name="actionPreferences"/> 1385 <addaction name="actionSave"/> 1386 <addaction name="actionSave_Project"/> 1387 <addaction name="actionLoad_Project"/> 1388 <addaction name="menuRecent_Projects"/> 1469 1389 <addaction name="separator"/> 1470 1390 <addaction name="actionExit"/> … … 1639 1559 </property> 1640 1560 </action> 1561 <action name="actionSave_Project"> 1562 <property name="text"> 1563 <string>Save Project As...</string> 1564 </property> 1565 </action> 1566 <action name="actionLoad_Project"> 1567 <property name="text"> 1568 <string>Load Project...</string> 1569 </property> 1570 <property name="iconText"> 1571 <string>Load Project...</string> 1572 </property> 1573 <property name="toolTip"> 1574 <string>Load Project...</string> 1575 </property> 1576 </action> 1577 <action name="actionSave"> 1578 <property name="enabled"> 1579 <bool>true</bool> 1580 </property> 1581 <property name="text"> 1582 <string>Save</string> 1583 </property> 1584 <property name="shortcut"> 1585 <string>Ctrl+S</string> 1586 </property> 1587 </action> 1588 <action name="actionPlaceholder1"> 1589 <property name="text"> 1590 <string>Placeholder1</string> 1591 </property> 1592 </action> 1593 <action name="actionProject1"> 1594 <property name="text"> 1595 <string>Project1</string> 1596 </property> 1597 </action> 1598 <action name="actionProject2"> 1599 <property name="text"> 1600 <string>Project2</string> 1601 </property> 1602 </action> 1603 <action name="actionProject3"> 1604 <property name="text"> 1605 <string>Project3</string> 1606 </property> 1607 </action> 1608 <action name="actionProject4"> 1609 <property name="text"> 1610 <string>Project4</string> 1611 </property> 1612 </action> 1613 <action name="actionProject5"> 1614 <property name="text"> 1615 <string>Project5</string> 1616 </property> 1617 </action> 1641 1618 </widget> 1642 1619 <layoutdefault spacing="6" margin="11"/> -
Vago/trunk/Vago/manualcommands.cpp
r1035 r1047 11 11 this->myProcess = new QProcess(); 12 12 this->myProcess->setProcessChannelMode(QProcess::MergedChannels); 13 this->myProcess->setWorkingDirectory(Util ::getAppPath());13 this->myProcess->setWorkingDirectory(UtilVago::getAppPath()); 14 14 ui->leManualCommand->installEventFilter(this); 15 15 … … 62 62 } 63 63 64 QString var = Util ::getOniSplitExeName() +" "+ui->leManualCommand->text();64 QString var = UtilVago::getOniSplitExeAbsolutePath() +" "+ui->leManualCommand->text(); 65 65 66 this->myProcess->start(Util ::getOniSplitExeName()+" "+ui->leManualCommand->text());66 this->myProcess->start(UtilVago::getOniSplitExeAbsolutePath()+" "+ui->leManualCommand->text()); 67 67 this->myProcess->waitForFinished(120000); //wait 2 minutes at maximum 68 68 ui->ptOutput->appendPlainText("> "+command); -
Vago/trunk/Vago/manualcommands.h
r811 r1047 7 7 #include <QScrollBar> 8 8 9 #include "util .h"9 #include "utilvago.h" 10 10 11 11 -
Vago/trunk/Vago/packageWizard/packagepage2.cpp
r1039 r1047 82 82 bool necessaryToRedownload=false; 83 83 84 QFile *file = new QFile(GlobalVars::VagoTemporaryDir+"/"+this->ZipCacheFile);84 QFile file(GlobalVars::VagoTemporaryDir+"/"+this->ZipCacheFile); 85 85 86 if(!file ->exists()){86 if(!file.exists()){ 87 87 necessaryToRedownload=true; //File doesn't exist yet, necessary to download 88 88 } 89 else if (QDateTime::currentDateTime().toTime_t()-QFileInfo( *file).lastModified().toTime_t() > 150){ //checks between 2 minutes (give more 30 seconds due to zip extraction)89 else if (QDateTime::currentDateTime().toTime_t()-QFileInfo(file).lastModified().toTime_t() > 150){ //checks between 2 minutes (give more 30 seconds due to zip extraction) 90 90 necessaryToRedownload=true; //File already exists but already expired (+2 mins without update) 91 91 } 92 delete file;93 92 94 93 if(necessaryToRedownload){ … … 117 116 if(result->error()==QNetworkReply::NoError){ 118 117 119 QFile *file = new QFile(GlobalVars::VagoTemporaryDir+"/"+this->ZipCacheFile);118 QFile file(GlobalVars::VagoTemporaryDir+"/"+this->ZipCacheFile); 120 119 121 120 // Create temp folder if it doesn't exist … … 124 123 } 125 124 126 if(!file->open(QIODevice::WriteOnly)){ 127 const QString error="Error fetching package data: creating cache file."; 128 this->myLogger->writeString(error); 129 Util::showErrorPopUp(error); 125 if(!file.open(QIODevice::WriteOnly)){ 126 UtilVago::showAndLogErrorPopUp(this->myLogger, "Error fetching package data: creating cache file."); 130 127 return; 131 128 } 132 file ->write(result->readAll());133 file ->close();129 file.write(result->readAll()); 130 file.close(); 134 131 135 132 //Let's extract the cache data 136 UnZip uz; 137 UnZip::ErrorCode ec = uz.openArchive(GlobalVars::VagoTemporaryDir+"/"+this->ZipCacheFile); 138 checkForUnzipError(ec); 139 140 //Extract the cache files 141 ec = uz.extractAll(GlobalVars::VagoTemporaryDir); 142 checkForUnzipError(ec); 143 144 //Close zip archive 145 uz.closeArchive(); 146 147 delete file; 133 if(JlCompress::extractFile(GlobalVars::VagoTemporaryDir+"/"+this->ZipCacheFile, "/"+this->CacheFile ,GlobalVars::VagoTemporaryDir+"/"+this->CacheFile).isEmpty()){ 134 UtilVago::showAndLogErrorPopUp(this->myLogger, "An error occurred while unzipping the package data."); 135 } 148 136 149 137 checkForPackagesInCache(); … … 151 139 } 152 140 else{ 153 const QString error="An error occurred checking number availability:\n\n"+result->errorString(); 154 this->myLogger->writeString(error); 155 Util::showErrorLogPopUp(error); 141 UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "An error occurred checking number availability:\n\n"+result->errorString()); 156 142 } 157 143 … … 162 148 QString packageNumber=ui->lePackageNumber->text(); 163 149 164 QFile *file = new QFile(GlobalVars::VagoTemporaryDir+"/"+this->CacheFile); //let's read the chache unzipped 165 if(!file->open(QIODevice::ReadOnly)){ 166 const QString error="Error reading downloaded package cache data."; 167 this->myLogger->writeString(error); 168 Util::showErrorPopUp(error); 150 QFile file(GlobalVars::VagoTemporaryDir+"/"+this->CacheFile); //let's read the chache unzipped 151 if(!file.open(QIODevice::ReadOnly)){ 152 UtilVago::showAndLogErrorPopUp(this->myLogger, "Error reading downloaded package cache data."); 169 153 return; 170 154 } 171 155 //Read file cache to ram 172 QString data=file ->readAll();156 QString data=file.readAll(); 173 157 174 158 … … 200 184 Util::showPopUp("It seems that the package number " + packageNumber + " is not being used yet! :)"); 201 185 } 202 203 delete file;204 186 } 205 187 … … 208 190 ui->lePackageNumber->setText(QString().setNum(index+1)+"XXXX"); 209 191 } 210 211 void PackagePage2::checkForUnzipError(UnZip::ErrorCode ec){212 if (ec != UnZip::Ok){213 const QString error="Error found while unzipping the package data. Error number = "+QString::number(ec);214 Util::showErrorPopUp(error);215 this->myLogger->writeString(error);216 }217 } -
Vago/trunk/Vago/packageWizard/packagepage2.h
r811 r1047 2 2 #define PACKAGEPAGE2_H 3 3 4 #include "util.h" 5 #include "logger.h" 6 #include "unzip.h" 4 #include "utilvago.h" 7 5 8 6 #include <QWizardPage> … … 12 10 #include <QScriptEngine> 13 11 #include <QScriptValueIterator> 12 #include <JlCompress.h> 14 13 15 14 namespace Ui { … … 39 38 static const QString CacheFile; 40 39 static const QString PackagesCacheUrl; 41 void checkForUnzipError(UnZip::ErrorCode ec);42 40 void checkForPackagesInCache(); 43 41 }; -
Vago/trunk/Vago/packageWizard/packagepagefinal.h
r771 r1047 2 2 #define PACKAGEPAGEFINAL_H 3 3 4 #include "util.h" 5 #include "logger.h" 4 #include "utilvago.h" 6 5 7 6 #include <QWizardPage> -
Vago/trunk/Vago/packageWizard/packagewizard.cpp
r1035 r1047 118 118 } 119 119 120 QFile *modInfo = new QFile(modDir+"Mod_Info.cfg"); 121 122 if (!modInfo->open(QIODevice::WriteOnly | QIODevice::Text)){ //open to write 123 Util::showErrorPopUp("Couldn't create Mod_Info.cfg file."); 124 myLogger->writeString("Couldn't create Mod_Info.cfg file when creating AE Package."); 120 QFile modInfo(modDir+"Mod_Info.cfg"); 121 122 if (!modInfo.open(QIODevice::WriteOnly | QIODevice::Text)){ //open to write 123 UtilVago::showAndLogErrorPopUp(this->myLogger, "Couldn't create Mod_Info.cfg file when creating AE Package."); 125 124 return; 126 125 } 127 126 128 QTextStream *modWriteStream = new QTextStream (modInfo);129 *modWriteStream << "AEInstallVersion -> "+aeVersion+"\n";130 *modWriteStream << "NameOfMod -> "+modName+"\n";131 *modWriteStream << "ModVersion -> "+version+"\n";132 *modWriteStream << "Creator -> "+authors+"\n";133 *modWriteStream << "Readme -> "+description.replace("\n"," \\n ")+"\n";127 QTextStream modWriteStream(&modInfo); 128 modWriteStream << "AEInstallVersion -> "+aeVersion+"\n"; 129 modWriteStream << "NameOfMod -> "+modName+"\n"; 130 modWriteStream << "ModVersion -> "+version+"\n"; 131 modWriteStream << "Creator -> "+authors+"\n"; 132 modWriteStream << "Readme -> "+description.replace("\n"," \\n ")+"\n"; 134 133 if(!incompatiblePackages.isEmpty()){ 135 *modWriteStream << "IncompatibleWith -> "+incompatiblePackages+"\n";134 modWriteStream << "IncompatibleWith -> "+incompatiblePackages+"\n"; 136 135 } 137 136 if(!dependentPackages.isEmpty()){ 138 *modWriteStream << "DependsOn -> "+dependentPackages+"\n";137 modWriteStream << "DependsOn -> "+dependentPackages+"\n"; 139 138 } 140 139 141 140 if(bslExist){ 142 141 if(bslReplace){ 143 *modWriteStream << "HasBsl -> Yes\n";142 modWriteStream << "HasBsl -> Yes\n"; 144 143 } 145 144 else{ 146 *modWriteStream << "HasBsl -> Addon\n";145 modWriteStream << "HasBsl -> Addon\n"; 147 146 } 148 147 } 149 148 150 149 if(!unlockLevels.isEmpty()){ 151 *modWriteStream << "UnlockLevel -> "+unlockLevels+"\n"; 152 } 153 154 *modWriteStream << "Vago -> "+GlobalVars::AppVersion; 155 156 delete modWriteStream; //it auto closes the files/streams 157 delete modInfo; 158 159 //Create zipped package using PKZIP 2.0 (http://osdab.42cows.org/snippets/zip.php?mode=advanced) 150 modWriteStream << "UnlockLevel -> "+unlockLevels+"\n"; 151 } 152 153 modWriteStream << "Vago -> "+GlobalVars::AppVersion; 154 155 modInfo.close(); 156 160 157 if(createZip){ 161 Zip uz; 162 163 Zip::ErrorCode ec = uz.createArchive(this->packagesLocation+"/"+packageName+".zip"); 164 checkForZipError(ec); 165 166 ec=uz.addDirectory(modDir); 167 checkForZipError(ec); 168 169 ec = uz.closeArchive(); 170 checkForZipError(ec); 158 if(!JlCompress::compressDir(this->packagesLocation+"/"+packageName+".zip", modDir)){ 159 UtilVago::showAndLogErrorPopUp(this->myLogger, "An error occurred while zipping the package."); 160 } 171 161 } 172 162 … … 205 195 } 206 196 QDir().mkpath(path); //create path if doesn't exist 207 if(!Util::copyDir(sourceFolder,path+Util::cutName(sourceFolder),false)){//copy contents (creates dest destination automatically if not exists yet) 208 QString errorString="An error occurred while copying the folder/files to the package folder: \n" 209 "Copying from "+sourceFolder+"\n to "+path+Util::cutName(sourceFolder); 210 Util::showErrorLogPopUp(errorString); 211 this->myLogger->writeString(errorString); 212 } 213 } 214 } 215 216 /** 217 Convenience function for checking for zipping errors 218 */ 219 void PackageWizard::checkForZipError(Zip::ErrorCode ec){ 220 if (ec != Zip::Ok){ 221 const QString error="Error found while zipping the package. Error number = "+QString::number(ec); 222 Util::showErrorPopUp(error); 223 this->myLogger->writeString(error); 224 } 225 } 197 if(!Util::copyDir(sourceFolder,path,false)){//copy contents (creates dest destination automatically if not exists yet) 198 199 UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "An error occurred while copying the folder/files to the package folder: \n" 200 "Copying from "+sourceFolder+"\n to "+path); 201 } 202 } 203 } -
Vago/trunk/Vago/packageWizard/packagewizard.h
r811 r1047 7 7 #include "packagepage4.h" 8 8 #include "packagepagefinal.h" 9 #include "zip.h"10 9 11 10 #include <QLabel> … … 16 15 #include <QTextStream> 17 16 #include <QSettings> 17 #include <JlCompress.h> 18 18 19 19 class PackageWizard … … 26 26 void copyPackageFolders(const DropTableWidget *myTable, QString tableDir, QString modDir, bool &bslExist); 27 27 void createPackage(const QWizard &myWizard, PackagePage4 *page4); 28 void checkForZipError(Zip::ErrorCode ec);29 28 30 29 Logger *myLogger; -
Vago/trunk/Vago/preferences.h
r897 r1047 7 7 #include <QMessageBox> 8 8 9 #include "util .h"9 #include "utilvago.h" 10 10 11 11 namespace Ui { -
Vago/trunk/Vago/preferences.ui
r999 r1047 8 8 <y>0</y> 9 9 <width>493</width> 10 <height>2 91</height>10 <height>258</height> 11 11 </rect> 12 12 </property> -
Vago/trunk/Vago/readme.txt
r1041 r1047 1 1 Readme.txt 2 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3 Vago GUI v 0.9c3 Vago GUI v1.0 4 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 5 … … 39 39 40 40 ---------------------------------- 41 1.0, 17-09-2016 42 - Added feature to save and restore vago projects (plus load recent projects) 43 Projects are in XML format and are read with the pugixml library 44 - Added keyboard shortchut to the convert button 45 - Some code refactoring and started using C++14 46 - Fixed zip support for anniversary edition packages, switched to the zip library QuaZIP 47 - Fixed the anniversary edition packages creation on Windows {windows-change} 48 - Added extra logging 49 - Added Windows 7 and above conversions progress in taskbar {windows-change} 50 - Upgraded XmlTools from 0.8d to 2.0b 51 - Fixed libpng warning: iCCP: known incorrect sRGB profile 52 ---------------------------------- 41 53 0.9c, 02-04-2016 42 54 - Fixed ONI FILES to DAT - Add button does not let to select a folder 43 44 55 - Some minor fixes in the AEI Mod Package Wizard 45 56 ---------------------------------- -
Vago/trunk/Vago/soundWizard/soundpagefinal.cpp
r1035 r1047 19 19 ui->lbComplete->setText("<html>The wizard is now complete. The sounds have been converted. " 20 20 "You can view all converted files clicking <a href=' '>here.</a><br />" 21 "<br />Click restart to create more sounds from the wizard beggining, "21 "<br />Click restart to create more sounds from the wizard beggining, " 22 22 "otherwise click finish.</html>"); // Don't use rich text in qtdesigner because it generates platform dependent code 23 23 … … 148 148 149 149 // Clean tmp dir 150 if(!Util::rmDir(GlobalVars::VagoTemporaryDir)){ 151 QString message="Couldn't clean vago temp dir for complete sound wizard. Aborting.\n"+GlobalVars::VagoTemporaryDir; 152 this->myLogger->writeString(message); 153 Util::showErrorLogPopUp(message); 150 if(!Util::rmDir(GlobalVars::VagoTemporaryDir)){ 151 UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "Couldn't clean vago temp dir for complete sound wizard. Aborting.\n"+GlobalVars::VagoTemporaryDir); 154 152 return; 155 153 } 156 154 157 155 if(!QDir(QDir::tempPath()).mkpath("VagoTemp")){ 158 QString message="Couldn't reconstruct vago temp dir for complete sound wizard. Aborting.\n"+GlobalVars::VagoTemporaryDir; 159 this->myLogger->writeString(message); 160 Util::showErrorLogPopUp(message); 156 UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "Couldn't reconstruct vago temp dir for complete sound wizard. Aborting.\n"+GlobalVars::VagoTemporaryDir); 161 157 } 162 158 … … 167 163 QFile::setPermissions(grpFileLocation, QFile::ReadOwner | QFile::WriteOwner); 168 164 169 (*this->xmlCommands) << "replaceall -element:Priority -value:"+priority+" -filename:"+ambFileLocation+" -nobackups" 170 << "replaceall -element:Flags -value:"+flags.join(" ")+" -filename:"+ambFileLocation+" -nobackups" 171 << "replaceall -element:SphereRadius -value:"+sphereRadious+" -filename:"+ambFileLocation+" -nobackups" 172 << "replaceall -element:Treshold -value:"+treshold+" -filename:"+ambFileLocation+" -nobackups" 173 << "replaceall -element:MinOcclusion -value:"+minOcclusion+" -filename:"+ambFileLocation+" -nobackups" 174 << "replaceall -parelement:ElapsedTime -element:Min -value:"+minElapsedTime+" -filename:"+ambFileLocation+" -nobackups" 175 << "replaceall -parelement:Distance -element:Max -value:"+maxVolumeDistance+" -filename:"+ambFileLocation+" -nobackups" 176 << "replaceall -parelement:Distance -element:Min -value:"+minVolumeDistance+" -filename:"+ambFileLocation+" -nobackups" 177 << "replaceall -parelement:SoundGroup -element:Volume -value:"+volume+" -filename:"+grpFileLocation+" -nobackups" 178 << "replaceall -parelement:SoundGroup -element:Pitch -value:"+pitch+" -filename:"+grpFileLocation+" -nobackups" 179 << "replaceall -parelement:SoundGroup -element:NumberOfChannels -value:"+numberChannels+" -filename:"+grpFileLocation+" -nobackups" 180 << "replaceall -parelement:Volume -element:Min -value:"+minVolume+" -filename:"+grpFileLocation+" -nobackups" 181 << "replaceall -parelement:Volume -element:Max -value:"+maxVolume+" -filename:"+grpFileLocation+" -nobackups" 182 << "replaceall -parelement:Pitch -element:Min -value:"+minPitch+" -filename:"+grpFileLocation+" -nobackups" 183 << "replaceall -parelement:Pitch -element:Max -value:"+maxPitch+" -filename:"+grpFileLocation+" -nobackups" 184 << "replaceall -element:Weight -value:"+weight+" -filename:"+grpFileLocation+" -nobackups"; 165 (*this->xmlCommands) 166 << "--replace-all-values -e Priority -n "+Util::insertQuotes(priority)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose" 167 << "--replace-all-values -e Flags -n "+(flags.join(" ").isEmpty() ? "\" \"" : Util::insertQuotes(flags.join(" ")))+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose" 168 << "--replace-all-values -e SphereRadius -n "+Util::insertQuotes(sphereRadious)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose" 169 << "--replace-all-values -e Treshold -n "+Util::insertQuotes(treshold)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose" 170 << "--replace-all-values -e MinOcclusion -n "+Util::insertQuotes(minOcclusion)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose" 171 << "--replace-all-values --parent-element-name ElapsedTime -e Min -n "+Util::insertQuotes(minElapsedTime)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose" 172 << "--replace-all-values --parent-element-name Distance -e Max -n "+Util::insertQuotes(maxVolumeDistance)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose" 173 << "--replace-all-values --parent-element-name Distance -e Min -n "+Util::insertQuotes(minVolumeDistance)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose" 174 << "--replace-all-values --parent-element-name SoundGroup -e Volume -n "+Util::insertQuotes(volume)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose" 175 << "--replace-all-values --parent-element-name SoundGroup -e Pitch -n "+Util::insertQuotes(pitch)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose" 176 << "--replace-all-values --parent-element-name SoundGroup -e NumberOfChannels -n "+Util::insertQuotes(numberChannels)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose" 177 << "--replace-all-values --parent-element-name Volume -e Min -n "+Util::insertQuotes(minVolume)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose" 178 << "--replace-all-values --parent-element-name Volume -e Max -n "+Util::insertQuotes(maxVolume)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose" 179 << "--replace-all-values --parent-element-name Pitch -e Min -n "+Util::insertQuotes(minPitch)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose" 180 << "--replace-all-values --parent-element-name Pitch -e Max -n "+Util::insertQuotes(maxPitch)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose" 181 << "--replace-all-values -e Weight -n "+Util::insertQuotes(weight)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"; 185 182 186 183 if(preventRepeat){ 187 (*this->xmlCommands) << " replaceall -parelement:SoundGroup -element:Flags -value:PreventRepeat -filename:"+grpFileLocation+" -nobackups";184 (*this->xmlCommands) << "--replace-all-values --parent-element-name SoundGroup -e Flags -n PreventRepeat -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"; 188 185 } 189 186 … … 206 203 QFile::copy(grpFileLocation, currGrpFileLocation); 207 204 208 (*this->xmlCommands) << " replaceall -element:BaseTrack1 -value:"+currFileName+" -filename:"+currAmbFileLocation+" -nobackups" // process the xml209 << " replaceall -element:Sound -value:"+currFileName+" -filename:"+currGrpFileLocation+" -nobackups";205 (*this->xmlCommands) << "--replace-all-values -e BaseTrack1 -n "+Util::insertQuotes(currFileName)+" -f "+Util::insertQuotes(currAmbFileLocation)+" --no-backups --no-verbose" // process the xml 206 << "--replace-all-values -e Sound -n "+Util::insertQuotes(currFileName)+" -f "+Util::insertQuotes(currGrpFileLocation)+" --no-backups --no-verbose"; 210 207 211 208 myXmlProcessor->start(); … … 228 225 QString sNumErrors=QString::number(numErrors); 229 226 if(numErrors>1){ 230 Util ::showErrorLogPopUp(result+"\n This is the last of "+sNumErrors+" Errors.");227 UtilVago::showErrorPopUpLogButton(result+"\n This is the last of " + sNumErrors + " Errors."); 231 228 } 232 229 else{ 233 Util ::showErrorLogPopUp(result);230 UtilVago::showErrorPopUpLogButton(result); 234 231 } 235 232 } -
Vago/trunk/Vago/util.cpp
r1035 r1047 11 11 } 12 12 13 QString insertQuotes(QString path){ 14 return "\""+path+"\""; 13 QString cutNameWithoutBackSlash(QString path){ 14 return cutName(path).remove('/'); 15 } 16 17 QString insertQuotes(const QString &currString){ 18 return "\""+currString+"\""; 15 19 } 16 20 … … 19 23 } 20 24 21 void showPopUp( QStringmessage){25 void showPopUp(const QString &message){ 22 26 QMessageBox msgBox; 23 27 msgBox.setIcon(QMessageBox::Information); … … 26 30 } 27 31 28 void showRichPopUp( QStringmessage){32 void showRichPopUp(const QString &message){ 29 33 QMessageBox msgBox; 30 34 msgBox.setTextFormat(Qt::RichText); … … 34 38 } 35 39 36 void showWarningPopUp( QStringmessage){40 void showWarningPopUp(const QString &message){ 37 41 QMessageBox msgBox; 38 42 msgBox.setIcon(QMessageBox::Warning); … … 41 45 } 42 46 43 void showErrorPopUp( QStringmessage){47 void showErrorPopUp(const QString &message){ 44 48 QMessageBox msgBox; 45 49 msgBox.setIcon(QMessageBox::Critical); … … 48 52 } 49 53 50 //Same of above but allow open log file (doesn't right in log file!!) 51 void showErrorLogPopUp(QString message){ 52 QMessageBox msgBox; 53 msgBox.setIcon(QMessageBox::Critical); 54 msgBox.setText(message); 55 QPushButton *viewb = msgBox.addButton("View log", QMessageBox::ActionRole); 56 msgBox.setStandardButtons(QMessageBox::Close); 57 msgBox.exec(); 58 if(msgBox.clickedButton() == (QAbstractButton*) viewb){ 59 openLogFile(); 60 } 61 } 62 63 void showRichErrorPopUp(QString message){ 54 void showRichErrorPopUp(const QString &message){ 64 55 QMessageBox msgBox; 65 56 msgBox.setIcon(QMessageBox::Critical); … … 140 131 } 141 132 142 // from here: https://gzeki.com/blog/view/Recursive_copy_files_from_one_directory_to_another_in_C++_(Qt_5) 143 bool copyDir(QString from_dir, QString to_dir, bool replace_on_conflit) 144 { 145 QDir dir; 146 dir.setPath(from_dir); 147 148 from_dir += QDir::separator(); 149 to_dir += QDir::separator(); 150 151 foreach (QString copy_file, dir.entryList(QDir::Files)) 152 { 153 QString from = from_dir + copy_file; 154 QString to = to_dir + copy_file; 155 156 if (QFile::exists(to)) 157 { 158 if (replace_on_conflit) 159 { 160 if (QFile::remove(to) == false) 161 { 162 return false; 163 } 164 } 165 else 166 { 167 continue; 168 } 169 } 170 171 if (QFile::copy(from, to) == false) 172 { 173 return false; 174 } 175 } 176 177 foreach (QString copy_dir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) 178 { 179 QString from = from_dir + copy_dir; 180 QString to = to_dir + copy_dir; 181 182 if (dir.mkpath(to) == false) 183 { 184 return false; 185 } 186 187 if (copyDir(from, to, replace_on_conflit) == false) 188 { 189 return false; 133 // Created from scratch 134 bool copyDir(const QString &fromPath, QString toPath, const bool isRecursive){ 135 QDir fromDir(fromPath); 136 QDir toDir(toPath); 137 138 if(!toDir.mkdir(fromDir.dirName())){ // create the folder in the destination 139 return false; 140 } 141 142 // Update toPath to include the folder from "fromPath" 143 toPath = toPath + "/" + fromDir.dirName(); 144 toDir = QDir(toPath); 145 146 for(const QFileInfo &currFileInfo : fromDir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)){ 147 148 if(currFileInfo.isFile()){ 149 150 QFile destFile(toPath + "/" + currFileInfo.fileName()); 151 152 if(!QFile::copy(currFileInfo.absoluteFilePath(),toPath + "/" + currFileInfo.fileName())){ 153 return false; 154 } 155 } 156 else if(isRecursive && currFileInfo.isDir() && currFileInfo.absoluteFilePath() != fromDir.absolutePath()){ 157 158 if(!copyDir(currFileInfo.absoluteFilePath(), toPath, isRecursive)){ 159 return false; 160 } 190 161 } 191 162 } … … 222 193 } 223 194 224 void openLogFile(){225 QDesktopServices::openUrl(QUrl("file:///"+Util::getAppPath()+"/"+GlobalVars::AppLogName));226 }227 228 195 //Searches for the QString "toSearch" in the "myString" variable backward 229 196 //Returns the index of the first match or -1 if not found … … 277 244 } 278 245 279 /** 280 Gets application directory. In mac os gets the .app directory 281 **/ 282 QString getOSIndependentAppPath(){ 283 #ifdef Q_OS_MAC 284 QDir dir = QDir(QCoreApplication::applicationDirPath()); 285 if(dir.absolutePath().contains(".app")){ // include bundle, but we don't want it 286 dir.cdUp(); 287 dir.cdUp(); 288 dir.cdUp(); 289 } 290 return dir.absolutePath(); 291 #else 292 return QDir::currentPath(); 293 #endif 294 } 295 296 QString getAppPath(){ 297 return getOSIndependentAppPath(); 298 } 299 300 QString getOniSplitExeName(){ 301 302 #ifdef Q_OS_MAC 303 return getMonoExecutablePath() + " " + GlobalVars::OniSplitString; 304 #elif 305 return GlobalVars::OniSplitString; 306 #endif 307 } 308 309 QString getXmlToolsExeName(){ 310 311 #ifdef Q_OS_MAC 312 return getMonoExecutablePath() + " " + GlobalVars::XmlToolsString; 313 #elif 314 return GlobalVars::XmlToolsString; 315 #endif 316 } 317 318 #ifdef Q_OS_MAC 319 QString getMonoExecutablePath(){ 320 321 // Only way that I found to get mono working in 10.11 322 QString possibleMonoDir = "/usr/local/bin/mono"; 323 QFileInfo checkFile(possibleMonoDir); 324 325 if (checkFile.exists() && checkFile.isFile()) { 326 return possibleMonoDir; 327 } else { 328 return "mono"; 329 } 330 331 } 332 #endif 333 334 } 246 } -
Vago/trunk/Vago/util.h
r1038 r1047 2 2 #define UTIL_H 3 3 4 #include <QtGlobal> // for debug macros 5 #ifdef QT_DEBUG 6 #include <QDebug> 7 #endif 4 8 #include <QString> 5 9 #include <QMessageBox> … … 11 15 #include <QCoreApplication> 12 16 #include <QDesktopWidget> 13 14 namespace GlobalVars{ 15 16 const QString AppVersion="0.9c"; 17 const QString OniSplitString="OniSplit.exe"; 18 const QString XmlToolsString="xmlTools.exe"; 19 20 #ifdef Q_OS_WIN 21 const QString OniExe="Oni.exe"; 22 #else 23 const QString OniExe="Oni.app/Contents/MacOS/Oni"; 24 #endif 25 26 const QString AppLogName="logVago.txt"; 27 const QString BuiltOniSplitVersion="0.9.96.0"; 28 const QString BuiltXmlToolsVersion="0.8d"; 29 const QString ModsDomain="mods.oni2.net"; 30 #ifdef Q_OS_WIN 31 const QString VagoNode = "247"; 32 #else 33 const QString VagoNode = "277"; 34 #endif 35 const QString VagoCheckUpdatesUrl="http://"+ModsDomain+"/?q=api/node/"+VagoNode+".json"; 36 const QString VagoWebUrl="http://"+ModsDomain+"/node/"+VagoNode; 37 const QString VagoTemporaryDir=QDir::tempPath()+"/VagoTemp"; 38 const QString HelpDir="help"; 39 const int DefaultWindowWidth=800; 40 const int DefaultWindowHeight=600; 41 const char OniSplitProcSeparator=';'; 42 } 17 #include <QSettings> 18 #include <QXmlStreamReader> 19 #include <memory> 43 20 44 21 /** … … 48 25 QString normalizePath(QString path); 49 26 QString cutName(QString path); 50 QString insertQuotes(QString path); 27 QString cutNameWithoutBackSlash(QString path); 28 QString insertQuotes(const QString &currString); 51 29 QString normalizeAndQuote(QString path); 52 30 QString fullTrim(QString str); 53 31 QString normalizeDecimalSeparator(QString value); 54 QString getOSIndependentAppPath(); 55 QString getAppPath(); 56 QString getOniSplitExeName(); 57 QString getXmlToolsExeName(); 58 #ifdef Q_OS_MAC 59 QString getMonoExecutablePath(); 60 #endif 32 33 inline const char* qStrToCstr(const QString ¤tString){ 34 return currentString.toUtf8().constData(); 35 } 36 37 inline const char* boolToCstr(bool currentBoolean){ 38 return currentBoolean ? "true" : "false"; 39 } 61 40 62 41 QStringList multipleDirDialog(QString title); … … 69 48 bool isStringInteger(QString myString); 70 49 bool isStringDouble(QString myString); 71 bool copyDir( QString from_dir, QString to_dir, bool replace_on_conflit);50 bool copyDir(const QString &fromPath, QString toPath, const bool isRecursive = false); 72 51 bool rmDir(const QString &dirPath); 73 52 QRect getScreenResolution(); 74 void showPopUp(QString message); 75 void showRichPopUp(QString message); 76 void showWarningPopUp(QString message); 77 void showErrorPopUp(QString message); 78 void showErrorLogPopUp(QString message); 79 void showRichErrorPopUp(QString message); 80 void openLogFile(); 53 void showPopUp(const QString &message); 54 void showRichPopUp(const QString &message); 55 void showWarningPopUp(const QString &message); 56 void showErrorPopUp(const QString &message); 57 void showRichErrorPopUp(const QString &message); 81 58 } 82 59 #endif // UTIL_H -
Vago/trunk/Vago/xmlprocessor.cpp
r1035 r1047 10 10 void XmlProcessor::run() 11 11 { 12 QProcess *myProcess = new QProcess();12 QProcess myProcess; 13 13 QString result = QString(); 14 14 QString errorMessage = ""; 15 15 int numErrors=0; 16 16 17 myProcess ->setWorkingDirectory(this->AppDir);17 myProcess.setWorkingDirectory(this->AppDir); 18 18 19 19 for(int i=0; i<this->commands->size(); i++){ 20 20 21 myProcess ->start(Util::getXmlToolsExeName() +" "+this->commands->at(i));22 myProcess ->waitForFinished(-1);23 result=myProcess ->readAllStandardError();21 myProcess.start(UtilVago::getXmlToolsExeAbsolutePath() +" "+this->commands->at(i)); 22 myProcess.waitForFinished(-1); 23 result=myProcess.readAllStandardError(); 24 24 25 25 if(!result.isEmpty()){ … … 32 32 } 33 33 34 delete myProcess; //delete object and make pointer invalid35 34 this->commands->clear(); //clean list 36 35 -
Vago/trunk/Vago/xmlprocessor.h
r815 r1047 4 4 #include <QThread> 5 5 6 #include "logger.h" 7 #include "util.h" 6 #include "utilvago.h" 8 7 9 8 class XmlProcessor : public QThread
Note:
See TracChangeset
for help on using the changeset viewer.