Changeset 1047


Ignore:
Timestamp:
Sep 17, 2016, 12:51:26 AM (8 years ago)
Author:
s10k
Message:

Added Vago v1.0

Location:
Vago/trunk/Vago
Files:
6 added
43 edited

Legend:

Unmodified
Added
Removed
  • Vago/trunk/Vago/Vago.pro

    r1037 r1047  
    88QT       += network #network communication
    99QT       += script #for json parse
     10win32 {
     11QT       += winextras
     12}
     13CONFIG   += c++14
    1014
    11 INCLUDEPATH += $$[QT_INSTALL_HEADERS]/QtZlib
    12 INCLUDEPATH += ./libs
     15#INCLUDEPATH += ./libs
    1316INCLUDEPATH += ./packageWizard
    1417INCLUDEPATH += ./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/
     21INCLUDEPATH += ../Libs/zlib-1.2.8
     22LIBS += -LC:../Libs/zlib-1.2.8 -lz
     23INCLUDEPATH += ../Libs/quazip-0.7.2/quazip
     24LIBS += -L../Libs/quazip-0.7.2/quazip/release -lquazip
    1525
    1626macx {
     
    3646    converter.cpp \
    3747    about.cpp \
    38     libs/zipglobal.cpp \
    39     libs/zip.cpp \
    40     libs/unzip.cpp \
    4148    packageWizard/packagewizard.cpp \
    4249    packageWizard/packagepagefinal.cpp \
     
    4956    soundWizard/soundpagefinal.cpp \
    5057    soundWizard/soundwizard.cpp \
    51     xmlprocessor.cpp
     58    xmlprocessor.cpp \
     59    libs/pugixml/pugixml.cpp \
     60    utilvago.cpp
    5261
    5362HEADERS  += \
     
    6069    converter.h \
    6170    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 \
    6871    packageWizard/packagewizard.h \
    6972    packageWizard/packagepagefinal.h \
     
    7679    soundWizard/soundpagefinal.h \
    7780    soundWizard/soundwizard.h \
    78     xmlprocessor.h
     81    xmlprocessor.h \
     82    libs/pugixml/pugixml.hpp \
     83    utilvago.h
    7984
    80 FORMS    += mainwindow.ui \
     85FORMS    += \
     86    mainwindow.ui \
    8187    preferences.ui \
    8288    manualcommands.ui \
     
    9399RESOURCES += \
    94100    resources.qrc \
    95 
    96 CONFIG += c++11
  • Vago/trunk/Vago/about.cpp

    r1039 r1047  
    1414                         "<p style='font-size:small;'>"
    1515                         "Written by s10k<br /><br/>"
     16                         "Build Date " + __DATE__ + " " + __TIME__ + "<br /><br />"
    1617                         "Thanks to:<br/>"
    1718                         "Neo for OniSplit<br />"
     
    2728                         "Also thanks to: <br />"
    2829                         "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 />"
    3033                         "smashingmagazine for the folder icon :)<br />"
    3134                         "<center>"
  • Vago/trunk/Vago/about.h

    r811 r1047  
    44#include <QDialog>
    55
    6 #include "util.h"
     6#include "utilvago.h"
    77
    88namespace Ui {
  • Vago/trunk/Vago/converter.cpp

    r1035 r1047  
    88}
    99
     10#ifdef Q_OS_WIN
     11Converter::Converter(QString AppDir, Logger *myLogger, QStringList *myData, QWinTaskbarProgress *win7TaskBarProgress)
     12    : Converter(AppDir, myLogger, myData)
     13{
     14    this->win7TaskBarProgress = win7TaskBarProgress;
     15}
     16#endif
     17
    1018void Converter::run()
    1119{
     
    1624    int numErrors=0;
    1725
    18     this->myLogger->writeString("Setting working dir. to "+this->AppDir+".");
     26    this->myLogger->writeString("Setting working dir to "+this->AppDir+".");
    1927    myProcess->setWorkingDirectory(this->AppDir); // Set working directory (for work with AEI2/Mac OS)
    2028
     29#ifdef Q_OS_WIN
     30    if(this->win7TaskBarProgress){
     31        this->win7TaskBarProgress->reset();
     32        this->win7TaskBarProgress->show();
     33    }
     34#endif
     35
    2136    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
    2242        emit setupPB(this->myData->size());
    2343    }
    2444    else{
     45#ifdef Q_OS_WIN
     46        if(this->win7TaskBarProgress){
     47            this->win7TaskBarProgress->setRange(0,0);
     48        }
     49#endif
    2550        emit setupPB(0); //Intermitent bar, we don't have any estimation when the task is done
    2651    }
     
    3762
    3863            commandToExec=commands.mid(currentIndex,(nextIndex-currentIndex));
    39             this->myProcess->start(Util::getOniSplitExeName() +" "+commandToExec);
     64            this->myProcess->start(UtilVago::getOniSplitExeAbsolutePath() + " " + commandToExec);
    4065            this->myProcess->waitForFinished(-1);
    4166
    4267            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
    4375                delete this->myProcess; //delete object and make pointer invalid
    4476                this->myData->clear(); //clean list
    4577                emit conversionAborted();
     78
    4679                return;
    4780            }
     
    6295        }
    6396
     97#ifdef Q_OS_WIN
     98        if(this->win7TaskBarProgress){
     99            this->win7TaskBarProgress->setValue(win7TaskBarProgress->value()+1);
     100        }
     101#endif
     102
    64103        emit taskDone();
    65104    }
     105
     106#ifdef Q_OS_WIN
     107    if(this->win7TaskBarProgress){
     108        this->win7TaskBarProgress->hide();
     109    }
     110#endif
    66111
    67112    delete this->myProcess; //delete object and make pointer invalid
  • Vago/trunk/Vago/converter.h

    r897 r1047  
    44#include <QProgressBar>
    55#include <QThread>
     6#ifdef Q_OS_WIN
     7#include <QWinTaskbarProgress>
     8#endif
    69
    7 #include "logger.h"
     10#include "utilvago.h"
    811
    912class Converter : public QThread
     
    1215public:
    1316    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
    1421private:
    1522    QString AppDir;
     
    1825    QProcess *myProcess;
    1926    bool processHasKilled;
     27    #ifdef Q_OS_WIN
     28    QWinTaskbarProgress *win7TaskBarProgress = nullptr;
     29    #endif
    2030
    2131protected:
  • Vago/trunk/Vago/droptablewidget.h

    r998 r1047  
    55#include <QtWidgets>
    66
    7 #include "util.h"
     7#include "utilvago.h"
    88
    99
  • Vago/trunk/Vago/logger.cpp

    r803 r1047  
    11#include "logger.h"
    22
    3 Logger::Logger(QString appDir)
     3Logger::Logger(QString appDir, QString logFileName)
    44{
    5      myLogFile = new QFile(appDir+"/"+GlobalVars::AppLogName);
     5    myLogFile = std::make_unique<QFile>(appDir+"/"+logFileName);
    66
    7      if (!myLogFile->open(QIODevice::WriteOnly | QIODevice::Text)){ //open to write
    8            return;
    9      }
     7    if (!myLogFile->open(QIODevice::WriteOnly | QIODevice::Text)){ //open to write
     8        return;
     9    }
    1010
    11     logStream = new QTextStream (myLogFile);
     11    logStream = std::make_unique<QTextStream>(myLogFile.get());
    1212    //logStream->setCodec("UTF-8");
    1313}
    1414
    15  /**
     15/**
    1616  ** Mutex makes it thread safe. (not sure if needed although)
    1717  **/
     
    1919    mutex.lock();
    2020    *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";
    2222    *this->logStream << "--------------------------------------------\n";
    2323    this->logStream->flush();
     
    2929 **/
    3030void 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();
    3737}
    3838
    39 //deconstructor, will close the file automatically and free the resources...
    4039Logger::~Logger(){
    41     delete this->logStream;
    42     delete this->myLogFile; //the deconstructor of the file will close it automatically
     40
    4341}
  • Vago/trunk/Vago/logger.h

    r811 r1047  
    55#include <QMutex>
    66#include <QDateTime>
    7 
    8 #include "util.h"
     7#include <memory>
    98
    109class Logger
    1110{
    1211public:
    13     Logger(QString  appDir);
     12    Logger(QString  appDir, QString logFileName);
    1413    ~Logger();
    1514    void writeString(QString strToWrite);
    1615    void writeBytes(QByteArray arrToWrite);
    1716private:
    18     QFile *myLogFile;
    19     QTextStream *logStream;
     17    std::unique_ptr<QFile> myLogFile;
     18    std::unique_ptr<QTextStream> logStream;
    2019    QMutex mutex; //mutex for control writes to the logs
    2120};
  • Vago/trunk/Vago/main.cpp

    r1035 r1047  
    11#include <QtWidgets/QApplication>
    22#include "mainwindow.h"
     3
    34
    45int main(int argc, char *argv[])
     
    910    w.show();
    1011    a.setStyleSheet("QStatusBar::item { border: 0px; }"); //hide QLabels border in status bar //http://qt-project.org/forums/viewthread/18743
    11    
     12
    1213    return a.exec();
    1314}
  • Vago/trunk/Vago/mainwindow.cpp

    r1036 r1047  
    1010    ui->setupUi(this);
    1111
    12     this->myLogger = new Logger(Util::getAppPath()); //start logger
    13 
    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());
    1515    this->myLogger->writeString("True app dir: "+QDir::currentPath());
    1616
    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.");
    2121        exit(1);
    2222    }
    2323
    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.");
    2626        exit(1);
    2727    }
    2828
    29     this->vagoSettings = new QSettings(Util::getAppPath() + "/" + this->VagoSettingsName, QSettings::IniFormat);
     29    this->vagoSettings = new QSettings(UtilVago::getAppPath() + "/" + this->VagoSettingsName, QSettings::IniFormat);
    3030
    3131    //First Execution? Old configuration? Settings missed?
     
    3636    }
    3737    if(!this->vagoSettings->contains("Workspace")){
    38         this->vagoSettings->setValue("Workspace", Util::getAppPath()+"/VagoWorkspace");
     38        this->vagoSettings->setValue("Workspace", UtilVago::getAppPath()+"/VagoWorkspace");
    3939        iniChanged=true;
    4040    }
     
    4545
    4646        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.");
    4848            exit(1);
    4949        }
     
    7575        this->vagoSettings->setValue("ConfirmExit", false);
    7676        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        }
    7787    }
    7888#ifdef Q_OS_MAC
     
    118128    this->listToProccess = new QStringList;
    119129
    120     //Create a thread for do the conversion in background
    121     this->myConverter = new Converter(Util::getAppPath(),this->myLogger,this->listToProccess);
    122 
    123130    // User interface
    124131    ui->mainToolBar->addWidget(ui->tbAE); //add ae installer launch button
     
    132139    ui->mainToolBar->setLayoutDirection(Qt::RightToLeft);
    133140
    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
    135143
    136144#ifdef Q_OS_MAC
     
    144152    // resize(800,600); // Mac OS pcs should be able to render this resolution without any problem. It's also better
    145153    //// 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)");
    146160#else
    147     //resize(640,480); // windows stuff
     161    ui->pbConvert->setToolTip(ui->pbConvert->toolTip() + " (Ctrl + Enter)");
    148162#endif
    149 
    150     resize(this->startedWindowWidth,this->startedWindowHeight);
    151 
    152     connectSlots();
    153163
    154164    //Commands Mapping
     
    158168    updateItemsLoaded(ui->twSourcesXML);
    159169
    160     this->myLogger->writeString("Application started.");
     170    loadRecentProjects();
    161171}
    162172
     
    166176    this->myLogger->writeString("Application Exited.");
    167177}
     178
     179
     180void 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
    168205
    169206void MainWindow::on_actionExit_triggered()
     
    187224void MainWindow::on_actionSound_Wizard_triggered()
    188225{
    189     SoundWizard myWizard (Util::getAppPath(), this->workspaceWizardsLocation, this->myLogger, &this->commandMap);
     226    SoundWizard myWizard (UtilVago::getAppPath(), this->workspaceWizardsLocation, this->myLogger, &this->commandMap);
    190227    myWizard.exec();
    191228}
     
    283320    }
    284321    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());
    286323    }
    287324    result->deleteLater();
     
    436473        }
    437474
    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());
    456476
    457477        if(ui->cbEnvMap->isChecked()){
     
    635655}
    636656
    637 void MainWindow::addRowTable(DropTableWidget *myTable, QString fileName, QString fromTo, QString command){
     657void MainWindow::addRowTable(DropTableWidget *myTable, QString fileName, QString fromTo, QString command, bool isToDisabled){
    638658    //Get actual number rows
    639659    int twSize=myTable->rowCount();
     
    647667    QTableWidgetItem *newCommand = new QTableWidgetItem(command);
    648668
     669    if(isToDisabled){
     670        myTable->setDisableStyleWidgetItem(newFile);
     671        myTable->setDisableStyleWidgetItem(newConversion);
     672        myTable->setDisableStyleWidgetItem(newCommand);
     673    }
     674
    649675    myTable->setItem(twSize,0,newFile);
    650676    myTable->setItem(twSize,1,newConversion);
     
    654680}
    655681
    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){
     682void MainWindow::on_pbConvert_clicked()
     683{
     684    startConversion();
     685}
     686
     687void MainWindow::startConversion(){
     688
     689    DropTableWidget* currTable = getCurrentTableWidget();
    687690
    688691    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){
    691694            ready=true;
    692695            break;
     
    704707    }
    705708
    706     for(int i=0; i<myTable->rowCount(); i++){
     709    for(int i=0; i<currTable->rowCount(); i++){
    707710        //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());
    710713        }
    711714    }
     
    733736        QString sNumErrors=QString::number(numErrors);
    734737        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.");
    736739            showErrStatusMessage("Something gone wrong. Check log file ("+sNumErrors+" Errors).");
    737740        }
    738741        else{
    739             Util::showErrorLogPopUp(result);
     742            UtilVago::showErrorPopUpLogButton(result);
    740743            showErrStatusMessage("Something gone wrong. Check log file.");
    741744        }
     
    887890void MainWindow::on_cbFromTextures_currentIndexChanged(const QString &arg1)
    888891{
    889     //Options are only used for DAT/ONI -> Image
    890     if(QString::compare(arg1,"DAT / ONI",Qt::CaseSensitive)==0){ //case sensitive is faster
    891         ui->gbTextures->setEnabled(false);
    892     }
    893     else{
    894         ui->gbTextures->setEnabled(true);
    895     }
    896 
    897892    updateComboBox(arg1, ui->cbToTextures);
    898893}
     
    900895void MainWindow::on_cbFromObjects_currentIndexChanged(const QString &arg1)
    901896{
    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 faster
    908         ui->cbWithAnimation->setEnabled(true);
    909     }
    910     else if(QString::compare(arg1,"OBJ",Qt::CaseSensitive)==0){
    911         ui->cbTexture->setEnabled(true);
    912     }
    913 
    914897    updateComboBox(arg1, ui->cbToObjects);
    915898}
     
    917900void MainWindow::on_cbFromCharacters_currentIndexChanged(const QString &arg1)
    918901{
    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 faster
    927         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 
    934902    updateComboBox(arg1, ui->cbToCharacters);
    935903}
     
    937905void MainWindow::on_cbFromLevels_currentIndexChanged(const QString &arg1)
    938906{
    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 faster
    952         ui->cbSpecificFilesLevels->setEnabled(true);
    953     }
    954     else if(arg1=="ONI FILES"){ //case sensitive is faster
    955         ui->cbDatLevels->setEnabled(true);
    956     }
    957     else if(arg1=="DAE"){
    958         ui->cbBnvLevels->setEnabled(true);
    959         ui->cbAdditionalSourcesLevels->setEnabled(true);
    960     }
    961 
    962907    updateComboBox(arg1, ui->cbToLevels);
    963908}
     
    969914
    970915void 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)
    972997
    973998    comboBox->clear();
     
    11051130
    11061131    if(Util::showQuestionPopUp(this,"Are you sure you want to clear the content?",defaultButton)){
    1107         myTable->clearContents();
    1108         myTable->setRowCount(0);
     1132        clearTableNoPrompt(myTable);
    11091133    }
    11101134    updateItemsLoaded(myTable);
    11111135}
    11121136
     1137void MainWindow::clearTableNoPrompt(DropTableWidget *myTable){
     1138    myTable->clearContents();
     1139    myTable->setRowCount(0);
     1140}
    11131141
    11141142void MainWindow::on_actionPreferences_triggered()
     
    11861214void MainWindow::on_actionCheck_OniSplit_version_triggered()
    11871215{
    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());
    11951224}
    11961225
    11971226void MainWindow::on_actionCheck_xmlTools_version_triggered()
    11981227{
    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());
    12061235}
    12071236
     
    12091238  Update items loaded
    12101239**/
    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     }
     1240void MainWindow::on_tabWidget_currentChanged(int)
     1241{
     1242    updateItemsLoaded(getCurrentTableWidget());
    12331243}
    12341244
     
    12831293void MainWindow::on_actionView_log_triggered()
    12841294{
    1285     Util::openLogFile();
     1295    UtilVago::openLogFile();
    12861296}
    12871297
     
    12891299{
    12901300    QDesktopServices::openUrl(QUrl("file:///"+this->AeLocation));
     1301}
     1302
     1303void 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
     1316void 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
     1326void 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
     1337void MainWindow::on_actionProject1_triggered()
     1338{
     1339    loadProjectState(this->ui->actionProject1->text());
     1340}
     1341
     1342void MainWindow::on_actionProject2_triggered()
     1343{
     1344    loadProjectState(this->ui->actionProject2->text());
     1345}
     1346
     1347void MainWindow::on_actionProject3_triggered()
     1348{
     1349    loadProjectState(this->ui->actionProject3->text());
     1350}
     1351
     1352void MainWindow::on_actionProject4_triggered()
     1353{
     1354    loadProjectState(this->ui->actionProject4->text());
     1355}
     1356
     1357void MainWindow::on_actionProject5_triggered()
     1358{
     1359    loadProjectState(this->ui->actionProject5->text());
    12911360}
    12921361
     
    13401409    }
    13411410
    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());
    13541423    menu->addSeparator();
    1355     menu->addAction(moveUp);
    1356     menu->addAction(moveDown);
     1424    menu->addAction(moveUp.get());
     1425    menu->addAction(moveDown.get());
    13571426    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());
    13621431
    13631432
     
    13831452    QAction* selectedOption = menu->exec(event->globalPos());
    13841453
    1385     if(selectedOption==copy){
     1454    if(selectedOption==copy.get()){
    13861455        //Let's copy the contents to the clipboard
    13871456
     
    14061475        showSuccessStatusMessage(QString::number(size) + (size==1?" item ":" items ")+ "copied to the clipboard");
    14071476    }
    1408     else if(selectedOption==moveUp){
     1477    else if(selectedOption==moveUp.get()){
    14091478        qSort(selectedRows); //let's order the selections by the row number, so we know exactly how to swap it
    14101479        myTable->swapPositions(selectedRows,-1);
    14111480    }
    1412     else if(selectedOption==moveDown){
     1481    else if(selectedOption==moveDown.get()){
    14131482        qSort(selectedRows);
    14141483        myTable->swapPositions(selectedRows,+1);
    14151484    }
    1416     else if(selectedOption==changeOptions){
     1485    else if(selectedOption==changeOptions.get()){
    14171486        changeToCurrentSettings(selectedRows,myTable);
    14181487    }
    1419     else if(selectedOption==outWorkspace){
     1488    else if(selectedOption==outWorkspace.get()){
    14201489        changeItemsOutput(myTable,selectedRows,this->workspaceLocation);
    14211490    }
    1422     else if(selectedOption==outCurrOutput){
     1491    else if(selectedOption==outCurrOutput.get()){
    14231492        changeItemsOutput(myTable,selectedRows,this->outputFolder);
    14241493    }
    1425     else if(selectedOption==outOther){
     1494    else if(selectedOption==outOther.get()){
    14261495
    14271496        QString newDir=QFileDialog::getExistingDirectory(this,"Choose the folder for the output of the files selected...",this->AeLocation+"/GameDataFolder");
     
    14351504
    14361505    }
    1437     else if(selectedOption==edisable){
     1506    else if(selectedOption==edisable.get()){
    14381507
    14391508        int enabledCount=0, disabledCount=0;
     
    14731542        showSuccessStatusMessage(result);
    14741543    }
    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;
    14861544}
    14871545
     
    15581616}
    15591617
    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 
    15731618void MainWindow::connectSlots(){
    15741619
     
    16241669    connect(ui->twSourcesMisc, SIGNAL(dtContextMenu(DropTableWidget*,QContextMenuEvent*)), this, SLOT(dtContextMenu(DropTableWidget*,QContextMenuEvent*)));
    16251670}
     1671
     1672void 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
     1700void 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
     1788QRadioButton* 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
     1810QRadioButton* 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
     1833void 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
     1847DropTableWidget* MainWindow::getCurrentTableWidget(){
     1848
     1849    return getTableWidgetByTabName(ui->tabWidget->tabText(ui->tabWidget->currentIndex()));
     1850
     1851}
     1852
     1853DropTableWidget* 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
     1876QString MainWindow::getCurrentTabName(){
     1877    return ui->tabWidget->tabText(ui->tabWidget->currentIndex());
     1878}
     1879
     1880QString 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
     1903QList<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
     1913void 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
     1980void 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
     2064void 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
     2070void 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
     2087void 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
     2119void 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  
    22#define MAINWINDOW_H
    33
    4 #include "util.h"
     4#include "utilvago.h"
    55#include "preferences.h"
    66#include "manualcommands.h"
     
    1212
    1313#include <QMainWindow>
    14 #include <QSettings>
    1514#include <QMessageBox>
    1615#include <QProcess>
     
    3029#include <QScriptEngine>
    3130#include <QScriptValueIterator>
     31#include <QWinTaskbarProgress>
     32#include <QWinTaskbarButton>
     33
     34#include "libs/pugixml/pugixml.hpp"
    3235//#include <QDebug>
    3336
     
    3942{
    4043    Q_OBJECT
    41    
     44
    4245public:
    4346    explicit MainWindow(QWidget *parent = 0);
     
    4750protected:
    4851    void closeEvent(QCloseEvent *event);
    49    
     52
    5053private slots:
    5154    void on_actionExit_triggered();
     
    6770    void on_pbAddSourceXML_clicked();
    6871
    69     void on_pbConvertXML_clicked();
     72    void on_pbConvert_clicked();
    7073
    7174    void TsetupProgressBar(int max);
     
    105108    void on_pbAddSourceMisc_clicked();
    106109
    107     void on_pbConvertTextures_clicked();
    108 
    109     void on_pbConvertObjects_clicked();
    110 
    111     void on_pbConvertLevels_clicked();
    112 
    113     void on_pbConvertMisc_clicked();
    114 
    115110    void on_pbRemoveSourceObjects_clicked();
    116111
     
    155150    void on_cbFromCharacters_currentIndexChanged(const QString &arg1);
    156151
    157     void on_pbConvertCharacters_clicked();
    158 
    159152    void on_pbAddSourceCharacters_clicked();
    160153
     
    179172    void on_tbAbortConversion_clicked();
    180173
    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();
    182191
    183192private:
     
    188197    QString outputFolder; //Output folder
    189198    QString AeLocation; //Workspace location
     199    QString lastProjectFilePath;
    190200    int startedWindowWidth;
    191201    int startedWindowHeight;
     
    200210    QSettings *vagoSettings;
    201211    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};
    202222
    203223    void connectSlots();
     
    205225    void showSuccessStatusMessage(QString message);
    206226    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);
    208228    void clearTableContents(DropTableWidget *myTable);
     229    void clearTableNoPrompt(DropTableWidget *myTable);
    209230    void removeTableContents(DropTableWidget *myTable);
    210231    void updateComboBox(const QString &arg1, QComboBox *comboBox);
    211     void startConversion(DropTableWidget *myTable);
     232    void startConversion();
    212233    void updateItemsLoaded(DropTableWidget *currentTable);
    213234    void changeToCurrentSettings(QList<int> rows, DropTableWidget* myTable); //change some rows to the current settings
    214235    void changeItemsOutput(DropTableWidget* myTable, QList<int> rows, QString newOutput);
    215236    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);
    216247    QString getFileOutputFolder(QString fromTo, QString myOutputFolder="");
    217248    QString fileParsingXML(QString tabTitle, QString myOutputFolder, QString from, QString to , QString file);
     
    224255    QString getTypeConversion(DropTableWidget *myTable); //get the current type for a table
    225256    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();
    226264
    227265signals:
  • Vago/trunk/Vago/mainwindow.ui

    r898 r1047  
    284284         </layout>
    285285        </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>
    306286       </layout>
    307287      </widget>
     
    553533           </item>
    554534          </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>
    575535         </widget>
    576536        </item>
     
    758718         </widget>
    759719        </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>
    780720       </layout>
    781721      </widget>
     
    970910           </item>
    971911          </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>
    992912         </widget>
    993913        </item>
     
    12811201         </widget>
    12821202        </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>
    13031203       </layout>
    13041204      </widget>
     
    14271327         </widget>
    14281328        </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>
    14491329       </layout>
    14501330      </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>
    14511357     </widget>
    14521358    </item>
     
    14591365     <y>0</y>
    14601366     <width>800</width>
    1461      <height>22</height>
     1367     <height>20</height>
    14621368    </rect>
    14631369   </property>
     
    14661372     <string>File</string>
    14671373    </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>
    14681384    <addaction name="actionPreferences"/>
     1385    <addaction name="actionSave"/>
     1386    <addaction name="actionSave_Project"/>
     1387    <addaction name="actionLoad_Project"/>
     1388    <addaction name="menuRecent_Projects"/>
    14691389    <addaction name="separator"/>
    14701390    <addaction name="actionExit"/>
     
    16391559   </property>
    16401560  </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>
    16411618 </widget>
    16421619 <layoutdefault spacing="6" margin="11"/>
  • Vago/trunk/Vago/manualcommands.cpp

    r1035 r1047  
    1111    this->myProcess = new QProcess();
    1212    this->myProcess->setProcessChannelMode(QProcess::MergedChannels);
    13     this->myProcess->setWorkingDirectory(Util::getAppPath());
     13    this->myProcess->setWorkingDirectory(UtilVago::getAppPath());
    1414    ui->leManualCommand->installEventFilter(this);
    1515
     
    6262    }
    6363
    64     QString var = Util::getOniSplitExeName() +" "+ui->leManualCommand->text();
     64    QString var = UtilVago::getOniSplitExeAbsolutePath() +" "+ui->leManualCommand->text();
    6565
    66     this->myProcess->start(Util::getOniSplitExeName()+" "+ui->leManualCommand->text());
     66    this->myProcess->start(UtilVago::getOniSplitExeAbsolutePath()+" "+ui->leManualCommand->text());
    6767    this->myProcess->waitForFinished(120000); //wait 2 minutes at maximum
    6868    ui->ptOutput->appendPlainText("> "+command);
  • Vago/trunk/Vago/manualcommands.h

    r811 r1047  
    77#include <QScrollBar>
    88
    9 #include "util.h"
     9#include "utilvago.h"
    1010
    1111
  • Vago/trunk/Vago/packageWizard/packagepage2.cpp

    r1039 r1047  
    8282        bool necessaryToRedownload=false;
    8383
    84         QFile *file = new QFile(GlobalVars::VagoTemporaryDir+"/"+this->ZipCacheFile);
     84        QFile file(GlobalVars::VagoTemporaryDir+"/"+this->ZipCacheFile);
    8585
    86         if(!file->exists()){
     86        if(!file.exists()){
    8787            necessaryToRedownload=true; //File doesn't exist yet, necessary to download
    8888        }
    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)
    9090            necessaryToRedownload=true; //File already exists but already expired (+2 mins without update)
    9191        }
    92         delete file;
    9392
    9493        if(necessaryToRedownload){
     
    117116    if(result->error()==QNetworkReply::NoError){
    118117
    119         QFile *file = new QFile(GlobalVars::VagoTemporaryDir+"/"+this->ZipCacheFile);
     118        QFile file(GlobalVars::VagoTemporaryDir+"/"+this->ZipCacheFile);
    120119
    121120        // Create temp folder if it doesn't exist
     
    124123        }
    125124
    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.");
    130127            return;
    131128        }
    132         file->write(result->readAll());
    133         file->close();
     129        file.write(result->readAll());
     130        file.close();
    134131
    135132        //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        }
    148136
    149137        checkForPackagesInCache();
     
    151139    }
    152140    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());
    156142    }
    157143
     
    162148    QString packageNumber=ui->lePackageNumber->text();
    163149
    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.");
    169153        return;
    170154    }
    171155    //Read file cache to ram
    172     QString data=file->readAll();
     156    QString data=file.readAll();
    173157
    174158
     
    200184        Util::showPopUp("It seems that the package number " + packageNumber + " is not being used yet! :)");
    201185    }
    202 
    203     delete file;
    204186}
    205187
     
    208190    ui->lePackageNumber->setText(QString().setNum(index+1)+"XXXX");
    209191}
    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  
    22#define PACKAGEPAGE2_H
    33
    4 #include "util.h"
    5 #include "logger.h"
    6 #include "unzip.h"
     4#include "utilvago.h"
    75
    86#include <QWizardPage>
     
    1210#include <QScriptEngine>
    1311#include <QScriptValueIterator>
     12#include <JlCompress.h>
    1413
    1514namespace Ui {
     
    3938    static const QString CacheFile;
    4039    static const QString PackagesCacheUrl;
    41     void checkForUnzipError(UnZip::ErrorCode ec);
    4240    void checkForPackagesInCache();
    4341};
  • Vago/trunk/Vago/packageWizard/packagepagefinal.h

    r771 r1047  
    22#define PACKAGEPAGEFINAL_H
    33
    4 #include "util.h"
    5 #include "logger.h"
     4#include "utilvago.h"
    65
    76#include <QWizardPage>
  • Vago/trunk/Vago/packageWizard/packagewizard.cpp

    r1035 r1047  
    118118    }
    119119
    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.");
    125124        return;
    126125    }
    127126
    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";
    134133    if(!incompatiblePackages.isEmpty()){
    135         *modWriteStream << "IncompatibleWith -> "+incompatiblePackages+"\n";
     134        modWriteStream << "IncompatibleWith -> "+incompatiblePackages+"\n";
    136135    }
    137136    if(!dependentPackages.isEmpty()){
    138         *modWriteStream << "DependsOn -> "+dependentPackages+"\n";
     137        modWriteStream << "DependsOn -> "+dependentPackages+"\n";
    139138    }
    140139
    141140    if(bslExist){
    142141        if(bslReplace){
    143             *modWriteStream << "HasBsl -> Yes\n";
     142            modWriteStream << "HasBsl -> Yes\n";
    144143        }
    145144        else{
    146             *modWriteStream << "HasBsl -> Addon\n";
     145            modWriteStream << "HasBsl -> Addon\n";
    147146        }
    148147    }
    149148
    150149    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
    160157    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        }
    171161    }
    172162
     
    205195        }
    206196        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  
    77#include "packagepage4.h"
    88#include "packagepagefinal.h"
    9 #include "zip.h"
    109
    1110#include <QLabel>
     
    1615#include <QTextStream>
    1716#include <QSettings>
     17#include <JlCompress.h>
    1818
    1919class PackageWizard
     
    2626    void copyPackageFolders(const DropTableWidget *myTable, QString tableDir, QString modDir, bool &bslExist);
    2727    void createPackage(const QWizard &myWizard, PackagePage4 *page4);
    28     void checkForZipError(Zip::ErrorCode ec);
    2928
    3029    Logger *myLogger;
  • Vago/trunk/Vago/preferences.h

    r897 r1047  
    77#include <QMessageBox>
    88
    9 #include "util.h"
     9#include "utilvago.h"
    1010
    1111namespace Ui {
  • Vago/trunk/Vago/preferences.ui

    r999 r1047  
    88    <y>0</y>
    99    <width>493</width>
    10     <height>291</height>
     10    <height>258</height>
    1111   </rect>
    1212  </property>
  • Vago/trunk/Vago/readme.txt

    r1041 r1047  
    11Readme.txt
    22~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    3 Vago GUI v0.9c
     3Vago GUI v1.0
    44~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    55
     
    3939
    4040----------------------------------
     411.0, 17-09-2016
     42- Added feature to save and restore vago projects (plus load recent projects)
     43Projects 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----------------------------------
    41530.9c, 02-04-2016
    4254- Fixed ONI FILES to DAT - Add button does not let to select a folder
    43 
    4455- Some minor fixes in the AEI Mod Package Wizard
    4556----------------------------------
  • Vago/trunk/Vago/soundWizard/soundpagefinal.cpp

    r1035 r1047  
    1919    ui->lbComplete->setText("<html>The wizard is now complete. The sounds have been converted. "
    2020                            "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, "
    2222                            "otherwise click finish.</html>"); // Don't use rich text in qtdesigner because it generates platform dependent code
    2323
     
    148148
    149149    // 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);
    154152        return;
    155153    }
    156154
    157155    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);
    161157    }
    162158
     
    167163    QFile::setPermissions(grpFileLocation, QFile::ReadOwner | QFile::WriteOwner);
    168164
    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";
    185182
    186183    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";
    188185    }
    189186
     
    206203        QFile::copy(grpFileLocation, currGrpFileLocation);
    207204
    208         (*this->xmlCommands) << "replaceall -element:BaseTrack1 -value:"+currFileName+" -filename:"+currAmbFileLocation+" -nobackups" // process the xml
    209                              << "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";
    210207
    211208        myXmlProcessor->start();
     
    228225        QString sNumErrors=QString::number(numErrors);
    229226        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.");
    231228        }
    232229        else{
    233             Util::showErrorLogPopUp(result);
     230            UtilVago::showErrorPopUpLogButton(result);
    234231        }
    235232    }
  • Vago/trunk/Vago/util.cpp

    r1035 r1047  
    1111}
    1212
    13 QString insertQuotes(QString path){
    14     return "\""+path+"\"";
     13QString cutNameWithoutBackSlash(QString path){
     14    return cutName(path).remove('/');
     15}
     16
     17QString insertQuotes(const QString &currString){
     18    return "\""+currString+"\"";
    1519}
    1620
     
    1923}
    2024
    21 void showPopUp(QString message){
     25void showPopUp(const QString &message){
    2226    QMessageBox msgBox;
    2327    msgBox.setIcon(QMessageBox::Information);
     
    2630}
    2731
    28 void showRichPopUp(QString message){
     32void showRichPopUp(const QString &message){
    2933    QMessageBox msgBox;
    3034    msgBox.setTextFormat(Qt::RichText);
     
    3438}
    3539
    36 void showWarningPopUp(QString message){
     40void showWarningPopUp(const QString &message){
    3741    QMessageBox msgBox;
    3842    msgBox.setIcon(QMessageBox::Warning);
     
    4145}
    4246
    43 void showErrorPopUp(QString message){
     47void showErrorPopUp(const QString &message){
    4448    QMessageBox msgBox;
    4549    msgBox.setIcon(QMessageBox::Critical);
     
    4852}
    4953
    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){
     54void showRichErrorPopUp(const QString &message){
    6455    QMessageBox msgBox;
    6556    msgBox.setIcon(QMessageBox::Critical);
     
    140131}
    141132
    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
     134bool 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            }
    190161        }
    191162    }
     
    222193}
    223194
    224 void openLogFile(){
    225     QDesktopServices::openUrl(QUrl("file:///"+Util::getAppPath()+"/"+GlobalVars::AppLogName));
    226 }
    227 
    228195//Searches for the QString "toSearch" in the "myString" variable backward
    229196//Returns the index of the first match or -1 if not found
     
    277244}
    278245
    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  
    22#define UTIL_H
    33
     4#include <QtGlobal> // for debug macros
     5#ifdef QT_DEBUG
     6    #include <QDebug>
     7#endif
    48#include <QString>
    59#include <QMessageBox>
     
    1115#include <QCoreApplication>
    1216#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>
    4320
    4421/**
     
    4825QString normalizePath(QString path);
    4926QString cutName(QString path);
    50 QString insertQuotes(QString path);
     27QString cutNameWithoutBackSlash(QString path);
     28QString insertQuotes(const QString &currString);
    5129QString normalizeAndQuote(QString path);
    5230QString fullTrim(QString str);
    5331QString 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
     33inline const char* qStrToCstr(const QString &currentString){
     34    return currentString.toUtf8().constData();
     35}
     36
     37inline const char* boolToCstr(bool currentBoolean){
     38    return currentBoolean ? "true" : "false";
     39}
    6140
    6241QStringList multipleDirDialog(QString title);
     
    6948bool isStringInteger(QString myString);
    7049bool isStringDouble(QString myString);
    71 bool copyDir(QString from_dir, QString to_dir, bool replace_on_conflit);
     50bool copyDir(const QString &fromPath, QString toPath, const bool isRecursive = false);
    7251bool rmDir(const QString &dirPath);
    7352QRect 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();
     53void showPopUp(const QString &message);
     54void showRichPopUp(const QString &message);
     55void showWarningPopUp(const QString &message);
     56void showErrorPopUp(const QString &message);
     57void showRichErrorPopUp(const QString &message);
    8158}
    8259#endif // UTIL_H
  • Vago/trunk/Vago/xmlprocessor.cpp

    r1035 r1047  
    1010void XmlProcessor::run()
    1111{
    12     QProcess *myProcess = new QProcess();
     12    QProcess myProcess;
    1313    QString result = QString();
    1414    QString errorMessage = "";
    1515    int numErrors=0;
    1616
    17     myProcess->setWorkingDirectory(this->AppDir);
     17    myProcess.setWorkingDirectory(this->AppDir);
    1818
    1919    for(int i=0; i<this->commands->size(); i++){
    2020
    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();
    2424
    2525        if(!result.isEmpty()){
     
    3232    }
    3333
    34     delete myProcess; //delete object and make pointer invalid
    3534    this->commands->clear(); //clean list
    3635
  • Vago/trunk/Vago/xmlprocessor.h

    r815 r1047  
    44#include <QThread>
    55
    6 #include "logger.h"
    7 #include "util.h"
     6#include "utilvago.h"
    87
    98class XmlProcessor : public QThread
Note: See TracChangeset for help on using the changeset viewer.