ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/s10k/Vago/mainwindow.cpp
(Generate patch)

Comparing:
Vago/trunk/Vago/mainwindow.cpp (file contents), Revision 1047 by s10k, Fri Sep 16 22:51:26 2016 UTC vs.
s10k/Vago/mainwindow.cpp (file contents), Revision 1093 by s10k, Sat Dec 30 13:57:32 2017 UTC

# Line 7 | Line 7 | MainWindow::MainWindow(QWidget *parent)
7      QMainWindow(parent),
8      ui(new Ui::MainWindow)
9   {
10 <    ui->setupUi(this);
10 >    // We use this appender because it is the native way to have \r\n in windows in plog library
11 >    // example: https://github.com/SergiusTheBest/plog/blob/master/samples/NativeEOL/Main.cpp
12 >    static plog::RollingFileAppender<plog::TxtFormatter, plog::NativeEOLConverter<>> fileAppender
13 >            (QSTR_TO_CSTR(Util::FileSystem::getAppPath() + "/" + GlobalVars::AppLogName), 1024*5 /* 5 Mb max log size */, 3);
14 >    plog::init(plog::info, &fileAppender);
15  
16 <    this->myLogger = new Logger(UtilVago::getAppPath(), GlobalVars::AppLogName); //start logger
16 >    ui->setupUi(this);
17  
18 <    this->myLogger->writeString("Detected AppDir: "+UtilVago::getAppPath());
19 <    this->myLogger->writeString("True app dir: "+QDir::currentPath());
18 >    LOG_INFO << "Detected AppDir: " + UtilVago::getAppPath();
19 >    LOG_INFO << "True app dir: "+QDir::currentPath();
20  
21      setVagoWindowTitle();
22  
23 <    if(!QFile::exists(UtilVago::getOniSplitExeAbsolutePath())){
24 <        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.");
23 >    if(!QFile::exists(UtilVago::getOniSplitExecutableAbsolutePath())){
24 >        UtilVago::showAndLogErrorPopUp("OniSplit not found. Please download it at "+GlobalVars::ModsDomain+" and put it the Vago's tools folder. \n\nProgram will now exit.");
25          exit(1);
26      }
27  
28 <    if(!QFile::exists(UtilVago::getXmlToolsExeAbsolutePath())){
29 <        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.");
28 >    if(!QFile::exists(UtilVago::getXmlToolsExecutableAbsolutePath())){
29 >        UtilVago::showAndLogErrorPopUp("XmlTools not found. Please download it at "+GlobalVars::ModsDomain+" and put it the Vago's tools folder. \n\nProgram will now exit.");
30          exit(1);
31      }
32  
# Line 40 | Line 44 | MainWindow::MainWindow(QWidget *parent)
44      }
45      if(!this->vagoSettings->contains("AeFolder")){
46  
47 <        Util::showPopUp("Seems it's the first time you are executing Vago. \n\nPlease input your Anniversary Edition (AE) Folder.");
48 <        QString aefolder=Util::normalizePath(QFileDialog::getExistingDirectory(this,"Choose Anniversary Edition (AE) folder..."));
47 >        Util::Dialogs::showInfo("Seems it's the first time you are executing Vago. \n\nPlease input your Anniversary Edition (AE) Folder.");
48 >        QString aefolder=Util::FileSystem::normalizePath(QFileDialog::getExistingDirectory(this,"Choose Anniversary Edition (AE) folder..."));
49  
50          if(aefolder.isEmpty()){
51 <            UtilVago::showAndLogErrorPopUp(this->myLogger, "AE folder is mandatory. Application will now exit.");
51 >            UtilVago::showAndLogErrorPopUp("AE folder is mandatory. Application will now exit.");
52              exit(1);
53          }
54  
55          if(!aefolder.endsWith("AE")){
56 <            Util::showWarningPopUp("Seems the folder you selected isn't called 'AE'. \n\nIf you run in any problems you can always change it in Vago preferences window.");
56 >            Util::Dialogs::showWarning("Seems the folder you selected isn't called 'AE'. \n\nIf you run in any problems you can always change it in Vago preferences window.");
57          }
58  
59          this->vagoSettings->setValue("AeFolder", aefolder);
# Line 71 | Line 75 | MainWindow::MainWindow(QWidget *parent)
75          this->vagoSettings->setValue("SeparateInWorkspace",true);
76          iniChanged=true;
77      }
78 <    if(!this->vagoSettings->contains("ConfirmExit")){
79 <        this->vagoSettings->setValue("ConfirmExit", false);
78 >    if(!this->vagoSettings->contains("AskSaveProject")){
79 >        this->vagoSettings->setValue("AskSaveProject", true);
80 >        iniChanged=true;
81 >    }
82 >    if(!this->vagoSettings->contains("AskToOpenLastProject")){
83 >        this->vagoSettings->setValue("AskToOpenLastProject", false);
84          iniChanged=true;
85      }
86      if(!this->vagoSettings->contains("LastProjectPath")){
# Line 124 | Line 132 | MainWindow::MainWindow(QWidget *parent)
132      ui->statusBar->addPermanentWidget(this->myBar); //this adds automatically in right
133      ui->statusBar->addPermanentWidget(ui->tbAbortConversion);
134  
127    //Initialize list pointers
128    this->listToProccess = new QStringList;
129
135      // User interface
136      ui->mainToolBar->addWidget(ui->tbAE); //add ae installer launch button
137      ui->mainToolBar->addWidget(ui->emptySpacerLabel); //trick, we can't add directly a space so we add an empty
# Line 134 | Line 139 | MainWindow::MainWindow(QWidget *parent)
139      ui->mainToolBar->addWidget(ui->emptySpacerLabel2); //same as before
140      ui->mainToolBar->addWidget(ui->tbCommand); //add option to manual onisplit commands
141      ui->mainToolBar->addWidget(ui->emptySpacerLabel3); //same as before
142 +    ui->mainToolBar->addWidget(ui->tbXmlToolsInterface); //add option to manual onisplit commands
143 +    ui->mainToolBar->addWidget(ui->emptySpacerLabel4); //same as before
144      ui->mainToolBar->addWidget(ui->tbOpenFolder); //add option to open folder with files converted etc
145  
146      ui->mainToolBar->setLayoutDirection(Qt::RightToLeft);
# Line 173 | Line 180 | MainWindow::MainWindow(QWidget *parent)
180   MainWindow::~MainWindow()
181   {
182      delete ui;
183 <    this->myLogger->writeString("Application Exited.");
183 >    LOG_INFO << "Application Exited.";
184   }
185  
186  
187   void MainWindow::showEvent(QShowEvent *e)
188   {
189 <    #ifdef Q_OS_WIN
189 >    // If we don't have a converter yet, application wasn't started.
190 >    if(!this->applicationIsFullyLoaded)
191 >    {
192 >        // Apparently Qt doesn't contains a slot to when the application was fully load (mainwindow). So we do our own implementation instead.
193 >        connect(this, SIGNAL(signalAppIsLoaded()), this, SLOT(applicationWasLoaded()), Qt::ConnectionType::QueuedConnection);
194 >        emit signalAppIsLoaded();
195 >    }
196 >
197 >    e->accept();
198 > }
199 >
200 > // Called only when the MainWindow was fully loaded and painted on the screen. This slot is only called once.
201 > void MainWindow::applicationWasLoaded(){
202 > #ifdef Q_OS_WIN
203      // QProgressBar only works after the windows was shown
204      // http://stackoverflow.com/questions/24840941/qwintaskbarprogress-wont-show (Kervala answer)
205  
# Line 190 | Line 210 | void MainWindow::showEvent(QShowEvent *e
210      this->win7TaskBarProgress = this->win7TaskBarButton->progress();
211  
212      //Create a thread for do the conversion in background
213 <    this->myConverter = new Converter(UtilVago::getAppPath(), this->myLogger, this->listToProccess, this->win7TaskBarProgress);
214 <    #else
215 <    this->myConverter = new Converter(UtilVago::getAppPath(), this->myLogger, this->listToProccess);
216 <    #endif
213 >    this->myConverter = new Converter(UtilVago::getAppPath(), &this->listToProccess, this->win7TaskBarProgress);
214 > #else
215 >    this->myConverter = new Converter(UtilVago::getAppPath(), &this->listToProccess);
216 > #endif
217  
218      connectSlots();
219  
220 <    this->myLogger->writeString("Application started.");
220 >    LOG_INFO << "Application started.";
221  
222 <    e->accept();
222 >    this->applicationIsFullyLoaded = true;
223 >
224 >    QString lastSavedProject = this->vagoSettings->value("RecentProject1").toString();
225 >
226 >    if(!lastSavedProject.isEmpty() && this->vagoSettings->value("AskToOpenLastProject").toBool()){
227 >        if(Util::Dialogs::showQuestion(this,"Do you want to load latest project?\n\nLatest project was '" + Util::FileSystem::cutNameWithoutBackSlash(lastSavedProject) + "'.")){
228 >            loadProjectState(lastSavedProject);
229 >        }
230 >    }
231   }
232  
233  
# Line 217 | Line 245 | void MainWindow::on_actionAbout_triggere
245  
246   void MainWindow::on_actionAE_Package_Creator_triggered()
247   {
248 <    PackageWizard myWizard = PackageWizard(this->workspaceWizardsLocation, this->vagoSettings, this->myLogger);
249 <    myWizard.exec();
248 >    // it deletes itself once closed
249 >    WizardFactory<PackageWizard>::startInstance(UtilVago::getAppPath(), this->workspaceWizardsLocation, this->vagoSettings);
250   }
251  
252   void MainWindow::on_actionSound_Wizard_triggered()
253   {
254 <    SoundWizard myWizard (UtilVago::getAppPath(), this->workspaceWizardsLocation, this->myLogger, &this->commandMap);
255 <    myWizard.exec();
254 >    // it deletes itself once closed
255 >    WizardFactory<SoundWizard>::startInstance(UtilVago::getAppPath(), this->workspaceWizardsLocation, this->vagoSettings, &this->commandMap);
256 > }
257 >
258 > void MainWindow::on_actionBackground_Image_Wizard_triggered()
259 > {
260 >    // it deletes itself once closed
261 >    WizardFactory<BGImageWizard>::startInstance(UtilVago::getAppPath(), this->workspaceWizardsLocation, this->vagoSettings);
262 > }
263 >
264 > void MainWindow::on_actionWindow_Messages_Wizard_triggered()
265 > {
266 >    // it deletes itself once closed
267 >    WizardFactory<WmWizard>::startInstance(UtilVago::getAppPath(), this->workspaceWizardsLocation, this->vagoSettings);
268   }
269  
270   void MainWindow::on_tbOni_clicked()
# Line 243 | Line 283 | void MainWindow::on_tbOni_clicked()
283      arguments << "-debugfiles";
284  
285      if(!QProcess::startDetached(this->AeLocation+"/"+GlobalVars::OniExe,arguments,this->AeLocation)){
286 <        showErrStatusMessage("Oni could not be started!");
286 >        Util::StatusBar::showError(ui->statusBar, "Oni could not be started!");
287      }
288   }
289  
# Line 252 | Line 292 | void MainWindow::on_tbAE_clicked()
292      // If the app turn out someday to a native app use QProcess::startDetached instead...
293  
294      if(!QDesktopServices::openUrl("file:///"+this->AeLocation+"/AEInstaller/bin/AEInstaller2.jar")){
295 <        showErrStatusMessage("Could not start AE Installer!");
295 >        Util::StatusBar::showError(ui->statusBar, "Could not start AE Installer!");
296      }
297   }
298  
# Line 261 | Line 301 | void MainWindow::on_tbOpenFolder_clicked
301      QDesktopServices::openUrl(QUrl("file:///"+this->outputFolder));
302   }
303  
304 +
305 + void MainWindow::on_tbXmlToolsInterface_clicked()
306 + {
307 +    //We pass no parent because we want to have an independent window for XmlToolsInterface,
308 +    //so we can minimize it or maximize indepently from the MainWindow
309 +    XmlToolsInterface *xmlToolsWindow = new XmlToolsInterface();
310 +    xmlToolsWindow->show(); //it destroys itself when finished.
311 + }
312 +
313   void MainWindow::on_tbAbortConversion_clicked()
314   {
315 <    if(Util::showQuestionPopUp(this,"Are you sure you want to abort the current conversion?")){
315 >    if(Util::Dialogs::showQuestion(this,"Are you sure you want to abort the current conversion?")){
316          emit terminateCurrProcess();
317      }
318   }
# Line 278 | Line 327 | void MainWindow::on_cbTexture_toggled(bo
327      ui->leTextureName->setEnabled(checked);
328   }
329  
330 < void MainWindow::on_cbWithAnimation_toggled(bool checked)
330 > void MainWindow::on_cbSpecificFilesLevels_toggled(bool checked)
331   {
332 <    ui->leAnimationName->setEnabled(checked);
332 >    ui->leSpecificFilesLevels->setEnabled(checked);
333   }
334  
335 < void MainWindow::on_cbSpecificFilesLevels_toggled(bool checked)
335 > void MainWindow::on_cbWithAnimation_toggled(bool checked)
336   {
337 <    ui->leSpecificFilesLevels->setEnabled(checked);
337 >    ui->leAnimationName->setEnabled(checked);
338   }
339  
340   void MainWindow::on_actionCheck_For_Updates_triggered()
# Line 311 | Line 360 | void MainWindow::checkVagoLastVersion(QN
360          QString newVersion = sc.property("field_version").toObject().property("und").toObject().property("0").toObject().property("value").toString();
361  
362          if(newVersion!=GlobalVars::AppVersion){
363 <            Util::showRichPopUp("There's a new version of Vago! (v"+newVersion+")<br/><br/>"+
364 <                                "You can download it <a href='"+GlobalVars::VagoWebUrl+"'>here</a>.");
363 >            Util::Dialogs::showRichInfo("There's a new version of Vago! (v"+newVersion+")<br/><br/>"+
364 >                                        "You can download it <a href='"+GlobalVars::VagoWebUrl+"'>here</a>.");
365          }
366          else{
367 <            Util::showPopUp("You are using last version.");
367 >            Util::Dialogs::showInfo("You are using last version.");
368          }
369      }
370      else{
371 <        UtilVago::showAndLogErrorPopUp(this->myLogger, "An error occurred checking last version:\n\n"+result->errorString());
371 >        UtilVago::showAndLogErrorPopUp("An error occurred checking last version:\n\n"+result->errorString());
372      }
373      result->deleteLater();
374   }
# Line 347 | Line 396 | void MainWindow::on_pbAddSourceCharacter
396   void MainWindow::on_pbAddSourceLevels_clicked()
397   {
398      if(QString::compare(ui->cbFromLevels->currentText(),"ONI FILES",Qt::CaseSensitive)==0 && QString::compare(ui->cbToLevels->currentText(),"DAT",Qt::CaseSensitive)==0){ //CaseSensitive is faster)
399 <        addFilesSource(ui->twSourcesLevels,Util::multipleDirDialog("Choose folders with ONIs..."));
399 >        addFilesSource(ui->twSourcesLevels,Util::Dialogs::multipleDirSelection("Choose folders with ONIs..."));
400      }
401      else{
402          addFilesSource(ui->twSourcesLevels,QFileDialog::getOpenFileNames(this,"Choose the files...","./" , "All Files (*.*)"));
# Line 369 | Line 418 | QString MainWindow::getFileOutputFolder(
418          myOutputFolder+="/"+ui->tabWidget->tabText(ui->tabWidget->currentIndex());
419          myOutputFolder+="/"+QString(fromTo).replace(" / ","_").replace(" > "," - ");
420      }
421 <    return Util::insertQuotes(myOutputFolder+"/");
421 >    return Util::String::insertQuotes(myOutputFolder+"/");
422   }
423  
424   void MainWindow::addFilesSource(DropTableWidget *myTable, QStringList files){
# Line 382 | Line 431 | void MainWindow::addFilesSource(DropTabl
431      from = QString(fromTo).remove(fromTo.indexOf(" >"),fromTo.size()-1); //parse the string to get the from, only 1 time parsed by each group of files = very fast
432      to = QString(fromTo).remove(0,fromTo.lastIndexOf("> ")+2); //+2 to start after "> "
433  
434 <    //Pre-processing (check if the files/folders received are valid), e.g. check for ONI->DAT if are only given folders and not files
434 >    //Pre-processing (check if the files/folders received are valid), e.g. check for ONI FILES->DAT if are only given folders and not files
435      if(from=="ONI FILES" && to=="DAT"){
436          //check if it's a folder
437 <        foreach(QString myFile, files){
437 >        for(const QString &myFile : files){
438              if(!QDir(myFile).exists()){
439 <                showErrStatusMessage("Only folders are allowed for this operation.");
439 >                Util::StatusBar::showError(ui->statusBar, "Only folders are allowed for this operation.");
440                  return;
441              }
442          }
443  
444      }
445      else{
446 <        foreach(QString myFile, files){
446 >        for(const QString &myFile : files){
447 >
448              //check if it's a file
449              if(QDir(myFile).exists()){
450 <                showErrStatusMessage("Only files are allowed for this operation.");
450 >                Util::StatusBar::showError(ui->statusBar, "Only files are allowed for this operation.");
451 >                return;
452 >            }
453 >
454 >            // Check if the given files have the expected extensions
455 >            QFileInfo fileInfo(myFile);
456 >
457 >            QStringList expectedExtensions;
458 >
459 >            bool extensionIsValid = false;
460 >
461 >            if(
462 >                    from == "DAT / TXMP ONI" ||
463 >                    from == "DAT / SNDD ONI" ||
464 >                    from == "DAT / SUBT ONI"
465 >                    ){
466 >                expectedExtensions << "DAT" << "ONI";
467 >            }
468 >            else if(from == "TGA / DDS / PNG / JPG"){
469 >                expectedExtensions << "TGA" << "DDS" << "PNG" << "JPG";
470 >            }
471 >            else if(
472 >                    from == "TRAM ONI" ||
473 >                    from == "TRBS / ONCC ONI" ||
474 >                    from == "M3GM ONI" ||
475 >                    from == "ONWC ONI" ||
476 >                    from == "OBAN ONI (cam)" ||
477 >                    from == "AKEV ONI"
478 >                    ){
479 >                expectedExtensions << "ONI";
480 >            }
481 >            else if(from == "TRBS XML" || from == "MASTER XML"){
482 >                expectedExtensions << "XML";
483 >            }
484 >            else if(from == "TRBS DAE"){
485 >                expectedExtensions << "DAE";
486 >            }
487 >            else if(from == "FILM DAT"){
488 >                expectedExtensions << "DAT";
489 >            }
490 >            else if(from == "WAV / AIF"){
491 >                expectedExtensions << "WAV" << "AIF";
492 >            }
493 >            else{
494 >                expectedExtensions << from;
495 >            }
496 >
497 >            for(const QString &currExpectedExtension : expectedExtensions){
498 >                if(fileInfo.suffix().toUpper() == currExpectedExtension){
499 >                    extensionIsValid = true;
500 >                    break;
501 >                }
502 >            }
503 >
504 >            if(!extensionIsValid){
505 >                QString errorMsg = "Can't add the file '" + fileInfo.fileName() + "'. It isn't a " + expectedExtensions.join(" or ") + " file.";
506 >                Util::Dialogs::showError(errorMsg);
507 >                Util::StatusBar::showError(ui->statusBar, errorMsg);
508                  return;
509              }
510          }
# Line 409 | Line 516 | void MainWindow::addFilesSource(DropTabl
516      QString myOutputFolder=getFileOutputFolder(fromTo);
517  
518      //if folder doesn't exist onisplit will create it for us :)
519 <    foreach(QString currentFile, files){
519 >    for(QString currentFile : files){
520  
521 <        currentFile=Util::normalizeAndQuote(currentFile); //insert quotes ("") in file
521 >        currentFile=Util::FileSystem::normalizeAndQuote(currentFile); //insert quotes ("") in file
522  
523          if(lastFileName.isEmpty()){ //Optimization: all commands are the same for each file, just replace the filename
524  
# Line 420 | Line 527 | void MainWindow::addFilesSource(DropTabl
527              if(command.isEmpty()){ //something wrong was happening (not inputted a texture name?)
528                  return; //stop adding files
529              }
530 <            currentFile=Util::cutName(currentFile);
530 >            currentFile=Util::FileSystem::cutName(currentFile);
531          }else{ //one parsing was already made just replace the filename by the old one in the command
532  
533 <            currentFile=Util::cutName(currentFile);
533 >            currentFile=Util::FileSystem::cutName(currentFile);
534  
535              command.replace(lastFileName,currentFile,Qt::CaseSensitive); //case sentive is faster
536          }
# Line 433 | Line 540 | void MainWindow::addFilesSource(DropTabl
540          addRowTable(myTable,lastFileName,fromTo,command);
541      }
542      updateItemsLoaded(myTable);
543 +    rowsWereChangedInDropTableWidget();
544   }
545  
546   QString MainWindow::fileParsingXML(QString tabTitle, QString myOutputFolder, QString from, QString to , QString file){
# Line 456 | Line 564 | QString MainWindow::fileParsingTextures(
564  
565      if(ui->gbTextures->isEnabled()){ //faster than compare strings (if is DAT/ONI)
566  
567 <        if(ui->cbMipMapsTextures->isChecked()){
567 >        if(ui->cbMipMapsTextures->isEnabled() && ui->cbMipMapsTextures->isChecked()){
568              command+=" "+this->commandMap.value(tabTitle+"->"+ui->cbMipMapsTextures->text());
569          }
570  
571 <        if(ui->cbNoUwrap->isChecked()){
571 >        if(ui->cbNoUwrap->isEnabled() && ui->cbNoUwrap->isChecked()){
572              command+=" "+this->commandMap.value(tabTitle+"->"+ui->cbNoUwrap->text());
573          }
574  
575 <        if(ui->cbNoVwrap->isChecked()){
575 >        if(ui->cbNoVwrap->isEnabled() && ui->cbNoVwrap->isChecked()){
576              command+=" "+this->commandMap.value(tabTitle+"->"+ui->cbNoVwrap->text());
577          }
578  
579 <        if(ui->cbLarge->isChecked()){
579 >        if(ui->cbLarge->isEnabled() && ui->cbLarge->isChecked()){
580              command+=" "+this->commandMap.value(tabTitle+"->"+ui->cbLarge->text());
581          }
582  
583          command+=" "+this->commandMap.value(tabTitle+"->"+getTextureRBCheckedTypeTexture()->text());
584  
585 <        if(ui->cbEnvMap->isChecked()){
585 >        if(ui->cbEnvMap->isEnabled() && ui->cbEnvMap->isChecked()){
586              if(ui->leEnvMapTexture->text().isEmpty()){
587 <                showErrStatusMessage("Checkbox '"+ui->cbEnvMap->text()+"' is selected. The name texture name cannot be empty.");
587 >                Util::StatusBar::showError(ui->statusBar, "Checkbox '"+ui->cbEnvMap->text()+"' is selected. The name texture name cannot be empty.");
588                  return "";
589              }
590              command+=" "+this->commandMap.value(tabTitle+"->"+ui->cbEnvMap->text()) + ui->leEnvMapTexture->text().remove(".oni",Qt::CaseInsensitive);
# Line 488 | Line 596 | QString MainWindow::fileParsingTextures(
596  
597   QString MainWindow::fileParsingCharacters(QString tabTitle, QString myOutputFolder, QString from, QString to , QString file){
598  
599 <    QString command=this->commandMap.value(tabTitle+"->"+from+"->"+to)+" "+myOutputFolder + " " + file ;
599 >    QString command=this->commandMap.value(tabTitle + "->" + from + "->" + to) + " " + myOutputFolder + " " + file ;
600  
601  
602 <    if(ui->cbCellShading->isChecked()){
603 <        command+=" "+this->commandMap.value(tabTitle+"->"+ui->cbCellShading->text());
602 >    if(ui->cbCellShading->isEnabled() && ui->cbCellShading->isChecked()){
603 >        command+=" "+this->commandMap.value(tabTitle + "->" + ui->cbCellShading->text());
604      }
605  
606 <    if(ui->cbNormals->isChecked()){
607 <        command+=" "+this->commandMap.value(tabTitle+"->"+ui->cbNormals->text());
606 >    if(ui->cbNormals->isEnabled() && ui->cbNormals->isChecked()){
607 >        command+=" "+this->commandMap.value(tabTitle + "->" + ui->cbNormals->text());
608      }
609  
610 <    if(ui->cbWithTRBS_ONCC->isChecked()){
610 >    if(ui->cbStandingPose->isEnabled() && ui->cbStandingPose->isChecked()){
611 >        command+=" "+this->commandMap.value(tabTitle + "->" + ui->cbStandingPose->text());
612 >    }
613 >
614 >    if(ui->cbWithTRBS_ONCC->isEnabled() && ui->cbWithTRBS_ONCC->isChecked()){
615          if(ui->leTRBS_ONCC->text().isEmpty()){
616 <            showErrStatusMessage("Checkbox '"+ui->cbWithTRBS_ONCC->text()+"' is selected. The name cannot be empty.");
616 >            Util::StatusBar::showError(ui->statusBar, "Checkbox '" + ui->cbWithTRBS_ONCC->text() + "' is selected. The name cannot be empty.");
617              return "";
618          }
619  
620 <        command+=" "+this->commandMap.value(tabTitle+"->"+ui->cbWithTRBS_ONCC->text())+Util::normalizeAndQuote(ui->leTRBS_ONCC->text());
620 >        command+= " " + this->commandMap.value(tabTitle + "->" + ui->cbWithTRBS_ONCC->text()) + Util::FileSystem::normalizeAndQuote(ui->leTRBS_ONCC->text());
621      }
622  
623      return command;
# Line 516 | Line 628 | QString MainWindow::fileParsingObjects(Q
628  
629      QString command=this->commandMap.value(tabTitle+"->"+from+"->"+to)+" "+myOutputFolder;
630  
631 <    //TODO: This can be optimized. When some are not enable others are.
520 <    if(ui->cbTexture->isChecked()){
631 >    if(ui->cbTexture->isEnabled() && ui->cbTexture->isChecked()){
632          if(ui->leTextureName->text().isEmpty()){
633 <            showErrStatusMessage("Checkbox '"+ui->cbTexture->text()+"' is selected. The file source cannot be empty.");
633 >            Util::StatusBar::showError(ui->statusBar, "Checkbox '"+ui->cbTexture->text()+"' is selected. The file source cannot be empty.");
634              return "";
635          }
636          command+=" "+this->commandMap.value(tabTitle+"->"+ui->cbTexture->text()) + ui->leTextureName->text();
637      }
638 <    else if(ui->cbWithAnimation->isChecked()){
638 >    else if(ui->cbWithAnimation->isEnabled() && ui->cbWithAnimation->isChecked()){
639          if(ui->leAnimationName->text().isEmpty()){
640 <            showErrStatusMessage("Checkbox '"+ui->cbWithAnimation->text()+"' is selected. The file source cannot be empty.");
640 >            Util::StatusBar::showError(ui->statusBar, "Checkbox '"+ui->cbWithAnimation->text()+"' is selected. The file source cannot be empty.");
641              return "";
642          }
643 <        command+=" "+Util::normalizeAndQuote(ui->leAnimationName->text()) + " " + this->commandMap.value(tabTitle+"->"+ui->cbWithAnimation->text()) + file;
643 >        command+=" "+Util::FileSystem::normalizeAndQuote(ui->leAnimationName->text()) + " " + this->commandMap.value(tabTitle+"->"+ui->cbWithAnimation->text()) + file;
644          return command;
645      }
646  
# Line 548 | Line 659 | QString MainWindow::fileParsingLevels(QS
659  
660          command=this->commandMap.value(tabTitle+"->"+from+"->"+to);
661  
662 <        if(ui->cbSpecificFilesLevels->isChecked()){
662 >        if(ui->cbSpecificFilesLevels->isEnabled() && ui->cbSpecificFilesLevels->isChecked()){
663  
664              if(ui->leSpecificFilesLevels->text().isEmpty()){
665 <                showErrStatusMessage("Checkbox '"+ui->cbSpecificFilesLevels->text()+"' is selected. The files pattern cannot be empty.");
665 >                Util::StatusBar::showError(ui->statusBar, "Checkbox '"+ui->cbSpecificFilesLevels->text()+"' is selected. The files pattern cannot be empty.");
666                  return "";
667              }
668  
# Line 559 | Line 670 | QString MainWindow::fileParsingLevels(QS
670          }
671  
672          if(from=="DAT" && to=="ONI FILES"){ // extract files to a subdir with the files name ex: level0_Final
673 <            command += " " + myOutputFolder.insert(myOutputFolder.size()-2,QString(Util::cutName(file)).replace(".dat","")) + " " + file;
673 >            command += " " + myOutputFolder.insert(myOutputFolder.size()-2,QString(Util::FileSystem::cutName(file)).replace(".dat","")) + " " + file;
674          }
675          else{
676              command+=" "+myOutputFolder+" "+file;
# Line 574 | Line 685 | QString MainWindow::fileParsingLevels(QS
685              command+=GlobalVars::OniSplitProcSeparator; //insert mark so we know this action will take 2 commands
686          }
687  
688 <        if(ui->cbDatLevels->isChecked()){
688 >        if(ui->cbDatLevels->isEnabled() && ui->cbDatLevels->isChecked()){
689              if(ui->leTargetDatLevels->text().isEmpty()){
690 <                showErrStatusMessage("Checkbox '"+ui->cbDatLevels->text()+"' is selected. The name cannot be empty.");
690 >                Util::StatusBar::showError(ui->statusBar, "Checkbox '"+ui->cbDatLevels->text()+"' is selected. The name cannot be empty.");
691                  return "";
692              }
693              datName+=QString(myOutputFolder).insert(myOutputFolder.size()-1,ui->leTargetDatLevels->text()); //set name inputted by user
# Line 586 | Line 697 | QString MainWindow::fileParsingLevels(QS
697          }
698          else{
699              if(from=="ONI FILES"){
700 <                datName=QString(myOutputFolder).insert(myOutputFolder.size()-1,Util::cutName(file).remove("/")+".dat"); //if none iputted set the same name of input file
700 >                datName=QString(myOutputFolder).insert(myOutputFolder.size()-1,Util::FileSystem::cutName(file).remove("/")+".dat"); //if none iputted set the same name of input file
701              }
702              else if(from=="MASTER XML"){
703 <                datName=QString(myOutputFolder).insert(myOutputFolder.size()-1,Util::cutName(file).remove("/").replace(".xml",".dat",Qt::CaseInsensitive)); //if none iputted set the same name of input file
703 >                datName=QString(myOutputFolder).insert(myOutputFolder.size()-1,Util::FileSystem::cutName(file).remove("/").replace(".xml",".dat",Qt::CaseInsensitive)); //if none iputted set the same name of input file
704              }
705          }
706          if(from=="ONI FILES"){
707 <            if(ui->actionWindows->isChecked()){ //is target plataform select windows?
707 >            if(ui->actionWindows->isEnabled() && ui->actionWindows->isChecked()){ //is target plataform select windows?
708                  return command=this->commandMap.value(tabTitle+"->"+from+"->"+to+"(PC)")+" "+ file + " "+datName;
709              }
710              else{
# Line 601 | Line 712 | QString MainWindow::fileParsingLevels(QS
712              }
713          }
714          else if(from=="MASTER XML"){
715 <            if(ui->actionWindows->isChecked()){ //is target plataform select windows?
715 >            if(ui->actionWindows->isEnabled() && ui->actionWindows->isChecked()){ //is target plataform select windows?
716                  command+=this->commandMap.value(tabTitle+"->ONI FILES->"+to+"(PC)")+" "+myOutputFolder+" "+datName; //add second command
717              }
718              else{
# Line 610 | Line 721 | QString MainWindow::fileParsingLevels(QS
721          }
722      }
723  
724 <    if(ui->cbBnvLevels->isChecked()){
724 >    if(ui->cbBnvLevels->isEnabled() && ui->cbBnvLevels->isChecked()){
725  
726 <        if(ui->leBnvLevels->text().isEmpty()){
727 <            showErrStatusMessage("Checkbox '"+ui->cbBnvLevels->text()+"' is selected. The BNV file cannot be empty.");
726 >        if(ui->leBnvLevels->isEnabled() && ui->leBnvLevels->text().isEmpty()){
727 >            Util::StatusBar::showError(ui->statusBar, "Checkbox '"+ui->cbBnvLevels->text()+"' is selected. The BNV file cannot be empty.");
728              return "";
729          }
730 <        command+=" "+Util::normalizeAndQuote(ui->leBnvLevels->text());
730 >        command+=" "+Util::FileSystem::normalizeAndQuote(ui->leBnvLevels->text());
731      }
732  
733 <    if(ui->cbAdditionalSourcesLevels->isChecked()){
733 >    if(ui->cbAdditionalSourcesLevels->isEnabled() && ui->cbAdditionalSourcesLevels->isChecked()){
734  
735          if(ui->leAdditSourcesLevels->text().isEmpty()){
736 <            showErrStatusMessage("Checkbox '"+ui->cbAdditionalSourcesLevels->text()+"' is selected. The source files cannot be empty.");
736 >            Util::StatusBar::showError(ui->statusBar, "Checkbox '"+ui->cbAdditionalSourcesLevels->text()+"' is selected. The source files cannot be empty.");
737              return "";
738          }
739  
# Line 634 | Line 745 | QString MainWindow::fileParsingLevels(QS
745          while(true){
746              nextIndex=additionalFiles.indexOf(";",currentIndex+1);
747  
748 <            command += " "+Util::normalizeAndQuote(additionalFiles.mid(currentIndex,(nextIndex-currentIndex)));
748 >            command += " "+Util::FileSystem::normalizeAndQuote(additionalFiles.mid(currentIndex,(nextIndex-currentIndex)));
749  
750              if(nextIndex==-1){ //we got to the end, stop parsing
751                  break;
# Line 643 | Line 754 | QString MainWindow::fileParsingLevels(QS
754          }
755      }
756  
757 <    if(ui->cbGridsLevels->isChecked()){
758 <        command+=GlobalVars::OniSplitProcSeparator+this->commandMap.value(tabTitle+"->"+ui->cbGridsLevels->text())+" "+Util::normalizeAndQuote(ui->leBnvLevels->text())+" "+file+" -out:"+myOutputFolder;
757 >    if(ui->cbGridsLevels->isEnabled() && ui->cbGridsLevels->isChecked()){
758 >        command+=GlobalVars::OniSplitProcSeparator+this->commandMap.value(tabTitle+"->"+ui->cbGridsLevels->text())+" "+Util::FileSystem::normalizeAndQuote(ui->leBnvLevels->text())+" "+file+" -out:"+myOutputFolder;
759      }
760  
761      return command;
# Line 697 | Line 808 | void MainWindow::startConversion(){
808      }
809  
810      if(!ready){
811 <        showErrStatusMessage("Please add sources to convert first.");
811 >        Util::StatusBar::showError(ui->statusBar, "Please add sources to convert first.");
812          return;
813      }
814  
815      if(this->myBar->isVisible()){
816 <        Util::showErrorPopUp("Another conversion is progress. Please wait until it finishes.");
816 >        Util::Dialogs::showError("Another conversion is progress. Please wait until it finishes.");
817          return;
818      }
819  
820      for(int i=0; i<currTable->rowCount(); i++){
821          //Only process enabled items
822          if(currTable->item(i,2)->background()!=currTable->disabledBackStyle){
823 <            this->listToProccess->append(currTable->item(i,2)->text());
823 >            this->listToProccess.append(currTable->item(i,2)->text());
824          }
825      }
826  
# Line 735 | Line 846 | void MainWindow::TresultConversion(QStri
846      if(numErrors!=0){
847          QString sNumErrors=QString::number(numErrors);
848          if(numErrors>1){
849 <            UtilVago::showErrorPopUpLogButton(result+"\n This is the last of "+sNumErrors+" Errors.");
850 <            showErrStatusMessage("Something gone wrong. Check log file ("+sNumErrors+" Errors).");
849 >            UtilVago::showErrorPopUpLogButton(result+"\n This is the last of "+sNumErrors+" errors.");
850 >            Util::StatusBar::showError(ui->statusBar, "Something gone wrong. Check log file ("+sNumErrors+" errors).");
851          }
852          else{
853              UtilVago::showErrorPopUpLogButton(result);
854 <            showErrStatusMessage("Something gone wrong. Check log file.");
854 >            Util::StatusBar::showError(ui->statusBar, "Something gone wrong. Check log file.");
855          }
745
856      }
857      else{
858 <        showSuccessStatusMessage("Everything went well!");
858 >        Util::StatusBar::showSuccess(ui->statusBar, "Everything went well!");
859      }
860   }
861  
# Line 753 | Line 863 | void MainWindow::TconversionAborted(){
863      this->myBar->hide();
864      ui->tbAbortConversion->hide();
865  
866 <    showErrStatusMessage("Conversion was aborted.");
757 < }
758 <
759 < void MainWindow::showErrStatusMessage(QString message){
760 <
761 <    QPalette myPalete = QPalette();
762 <    myPalete.setColor( QPalette::WindowText, QColor(255,0,0));
763 <    statusBar()->setPalette( myPalete );
764 <    ui->statusBar->showMessage(message,10000); //display by 10 seconds
765 <
766 < }
767 <
768 < void MainWindow::showSuccessStatusMessage(QString message){
769 <
770 <    QPalette myPalete = QPalette();
771 <    myPalete.setColor( QPalette::WindowText, QColor(0,150,0));
772 <    statusBar()->setPalette( myPalete );
773 <    ui->statusBar->showMessage(message,10000); //display by 10 seconds
774 <
866 >    Util::StatusBar::showError(ui->statusBar, "Conversion was aborted.");
867   }
868  
869   void MainWindow::mapCommands(){
# Line 820 | Line 912 | void MainWindow::mapCommands(){
912      this->commandMap.insert("characters->"+ui->cbWithTRBS_ONCC->text(),"-anim-body:");
913      this->commandMap.insert("characters->"+ui->cbCellShading->text(),"-cel");
914      this->commandMap.insert("characters->"+ui->cbNormals->text(),"-normals");
915 +    this->commandMap.insert("characters->"+ui->cbStandingPose->text(),"-noanim");
916      //Possible Combinations
917      this->commandMap.insertMulti("characters->TRAM ONI","XML / XML & DAE");
918      this->commandMap.insertMulti("characters->TRBS / ONCC ONI","DAE");
# Line 835 | Line 928 | void MainWindow::mapCommands(){
928      this->commandMap.insert("objects->ONWC ONI->DAE","-extract:dae");
929      this->commandMap.insert("objects->OBAN ONI (cam)->DAE","-extract:dae");
930      this->commandMap.insert("objects->OBJ->M3GM ONI","-create:m3gm");
931 <    //######################Characters Options
931 >    //######################Objects Options
932      this->commandMap.insert("objects->"+ui->cbTexture->text(),"-tex:");
933      this->commandMap.insert("objects->"+ui->cbWithAnimation->text(),"-geom:");
934      //Possible Combinations
# Line 922 | Line 1015 | void MainWindow::updateComboBox(const QS
1015      else if(comboBox == ui->cbToTextures){
1016          identifier = ui->tabWidget->tabText(TexturesTabIndex);
1017  
1018 <        //Options are only used for DAT/ONI -> Image
1019 <        if(QString::compare(arg1,"DAT / ONI",Qt::CaseSensitive)==0){ //case sensitive is faster
1018 >        //Options are only used for DAT/TXMP ONI -> Image
1019 >        if(QString::compare(arg1,"DAT / TXMP ONI",Qt::CaseSensitive)==0){ //case sensitive is faster
1020              ui->gbTextures->setEnabled(false);
1021          }
1022          else{
1023              ui->gbTextures->setEnabled(true);
1024 +            ui->leEnvMapTexture->setEnabled(ui->cbEnvMap->isChecked());
1025          }
1026      }
1027      else if(comboBox == ui->cbToCharacters){
1028          identifier = ui->tabWidget->tabText(CharactersTabIndex);
1029  
1030          ui->cbWithTRBS_ONCC->setEnabled(false);
937        ui->cbWithTRBS_ONCC->setChecked(false);
1031          ui->cbCellShading->setEnabled(false);
939        ui->cbCellShading->setChecked(false);
1032          ui->cbNormals->setEnabled(false);
1033 <        ui->cbNormals->setChecked(false);
1033 >        ui->cbStandingPose->setEnabled(false);
1034 >        ui->leTRBS_ONCC->setEnabled(false);
1035  
1036 +        //#error add drag and drop to Extract TRAM with TRBS/ONCC
1037          if(QString::compare(arg1,"TRAM ONI",Qt::CaseSensitive)==0){ //case sensitive is faster
1038              ui->cbWithTRBS_ONCC->setEnabled(true);
1039 +            ui->leTRBS_ONCC->setEnabled(ui->cbWithTRBS_ONCC->isChecked());
1040          }
1041          else if(QString::compare(arg1,"TRBS DAE",Qt::CaseSensitive)==0){
1042              ui->cbNormals->setEnabled(true);
1043              ui->cbCellShading->setEnabled(true);
1044          }
1045 +        else if(QString::compare(arg1,"TRBS / ONCC ONI",Qt::CaseSensitive)==0){
1046 +            ui->cbStandingPose->setEnabled(true);
1047 +        }
1048  
1049      }
1050      else if(comboBox == ui->cbToObjects){
1051          identifier = ui->tabWidget->tabText(ObjectsTabIndex);
1052  
1053          ui->cbTexture->setEnabled(false);
1054 <        ui->cbTexture->setChecked(false);
1054 >        ui->leTextureName->setEnabled(false);
1055          ui->cbWithAnimation->setEnabled(false);
1056 <        ui->cbWithAnimation->setChecked(false);
1056 >        ui->leAnimationName->setEnabled(false);
1057  
1058          if(QString::compare(arg1,"M3GM ONI",Qt::CaseSensitive)==0){ //case sensitive is faster
1059              ui->cbWithAnimation->setEnabled(true);
1060 +            ui->leAnimationName->setEnabled(ui->cbWithAnimation->isChecked());
1061          }
1062          else if(QString::compare(arg1,"OBJ",Qt::CaseSensitive)==0){
1063              ui->cbTexture->setEnabled(true);
1064 +            ui->leTextureName->setEnabled(ui->cbTexture->isChecked());
1065          }
1066      }
1067      else if(comboBox == ui->cbToLevels){
1068          identifier = ui->tabWidget->tabText(LevelsTabIndex);
1069  
1070          ui->cbSpecificFilesLevels->setEnabled(false);
1071 <        ui->cbSpecificFilesLevels->setChecked(false);
1071 >        ui->leSpecificFilesLevels->setEnabled(false);
1072          ui->cbDatLevels->setEnabled(false);
1073 <        ui->cbDatLevels->setChecked(false);
1073 >        ui->leTargetDatLevels->setEnabled(false);
1074          ui->cbBnvLevels->setEnabled(false);
1075 <        ui->cbBnvLevels->setChecked(false);
1075 >        ui->leBnvLevels->setEnabled(false);
1076          ui->cbAdditionalSourcesLevels->setEnabled(false);
1077 <        ui->cbAdditionalSourcesLevels->setChecked(false);
1077 >        ui->leAdditSourcesLevels->setEnabled(false);
1078          ui->cbGridsLevels->setEnabled(false);
979        ui->cbGridsLevels->setChecked(false);
1079  
1080          if(arg1=="DAT"){ //case sensitive is faster
1081              ui->cbSpecificFilesLevels->setEnabled(true);
1082 +            ui->leSpecificFilesLevels->setEnabled( ui->cbSpecificFilesLevels->isChecked());
1083          }
1084          else if(arg1=="ONI FILES"){ //case sensitive is faster
1085              ui->cbDatLevels->setEnabled(true);
1086 +            ui->leTargetDatLevels->setEnabled(ui->cbDatLevels->isChecked());
1087          }
1088          else if(arg1=="DAE"){
1089              ui->cbBnvLevels->setEnabled(true);
1090 +            ui->leBnvLevels->setEnabled(ui->cbBnvLevels->isChecked());
1091              ui->cbAdditionalSourcesLevels->setEnabled(true);
1092 +            ui->leAdditSourcesLevels->setEnabled(ui->cbAdditionalSourcesLevels->isChecked());
1093          }
1094      }
1095      else{ // Misc
# Line 1087 | Line 1190 | void MainWindow::removeTableContents(Dro
1190      QMessageBox::StandardButton defaultButton = QMessageBox::NoButton; // default button for clear asking question, only customizable in mac os
1191  
1192      if(size==0){
1193 <        Util::showPopUp("Select a row first.");
1193 >        Util::Dialogs::showInfo("Select a row first.");
1194          return;
1195      }
1196  
# Line 1101 | Line 1204 | void MainWindow::removeTableContents(Dro
1204   #endif
1205  
1206  
1207 <    if(Util::showQuestionPopUp(this,"Are you sure you want to delete the selected rows?",defaultButton)){
1207 >    if(Util::Dialogs::showQuestion(this,"Are you sure you want to delete the selected rows?",defaultButton)){
1208          for(int i=0; i<size; i++){
1209              //myTable->removeRow(myTable->selectedItems().at(size-i-1)->row());
1210              myTable->removeRow(myTable->selectionModel()->selectedRows().at(size-i-1).row());
1211          }
1212          updateItemsLoaded(myTable);
1213 +        rowsWereChangedInDropTableWidget();
1214      }
1215   }
1216  
# Line 1115 | Line 1219 | void MainWindow::clearTableContents(Drop
1219      QMessageBox::StandardButton defaultButton = QMessageBox::NoButton; // default button for clear asking question, only customizable in mac os
1220  
1221      if(myTable->rowCount()==0){
1222 <        Util::showPopUp("Nothing to clear.");
1222 >        Util::Dialogs::showInfo("Nothing to clear.");
1223          return;
1224      }
1225  
# Line 1128 | Line 1232 | void MainWindow::clearTableContents(Drop
1232      }
1233   #endif
1234  
1235 <    if(Util::showQuestionPopUp(this,"Are you sure you want to clear the content?",defaultButton)){
1235 >    if(Util::Dialogs::showQuestion(this,"Are you sure you want to clear the content?",defaultButton)){
1236          clearTableNoPrompt(myTable);
1237 +        updateItemsLoaded(myTable);
1238 +        rowsWereChangedInDropTableWidget();
1239      }
1240 <    updateItemsLoaded(myTable);
1240 >
1241   }
1242  
1243   void MainWindow::clearTableNoPrompt(DropTableWidget *myTable){
# Line 1148 | Line 1254 | void MainWindow::on_actionPreferences_tr
1254  
1255  
1256   void MainWindow::closeEvent(QCloseEvent *event){
1257 <    if(this->vagoSettings->value("ConfirmExit").toBool()){
1258 <        if(!Util::showQuestionPopUp(this,"Exit Vago?")){
1257 >    if(this->vagoSettings->value("AskSaveProject").toBool() && this->unsavedChangesExist){
1258 >        QMessageBox::StandardButton result = askToSaveCurrentProject();
1259 >        if(result == QMessageBox::StandardButton::Cancel){
1260              event->ignore();
1261 +            return;
1262          }
1263      }
1264 +
1265 +    // Exit application (this will also close all other windows which don't have parent, for instance ManualCommands)
1266 +    QApplication::quit();
1267 + }
1268 +
1269 + QMessageBox::StandardButton MainWindow::askToSaveCurrentProject(){
1270 +    QMessageBox::StandardButton result =
1271 +            Util::Dialogs::showQuestionWithCancel(this,"There are unsaved changes. Do you want to save the current project?", QMessageBox::StandardButton::Yes);
1272 +
1273 +    if(result == QMessageBox::StandardButton::Yes){
1274 +        on_actionSave_triggered();
1275 +    }
1276 +
1277 +    return result;
1278   }
1279  
1280   void MainWindow::on_cbToLevels_currentIndexChanged(const QString &arg1)
# Line 1178 | Line 1300 | void MainWindow::on_cbBnvLevels_toggled(
1300      ui->leBnvLevels->setEnabled(checked);
1301      ui->cbGridsLevels->setEnabled(checked);
1302      ui->cbGridsLevels->setChecked(checked);
1303 <    if(checked){
1303 >    if(checked && !projectIsLoading){
1304          QString file=QFileDialog::getOpenFileName(this,"Choose the BNV.dae file...","./" , "All Files (*.*)");
1305          if(!file.isEmpty()){
1306              ui->leBnvLevels->setText(file);
# Line 1190 | Line 1312 | void MainWindow::on_cbAdditionalSourcesL
1312   {
1313      ui->leAdditSourcesLevels->setEnabled(checked);
1314  
1315 <    if(checked){
1315 >    if(checked && !projectIsLoading){
1316          QStringList filesSelected=QFileDialog::getOpenFileNames(this,"Choose the additional .dae files...","./" , "All Files (*.*)");
1317          QString filesJoined;
1318          int size=filesSelected.size();
# Line 1215 | Line 1337 | void MainWindow::on_actionCheck_OniSplit
1337   {
1338      QProcess myProcess;
1339      myProcess.setWorkingDirectory(UtilVago::getAppPath());
1340 <    myProcess.start(UtilVago::getOniSplitExeAbsolutePath()+" -version");
1340 >    myProcess.start(UtilVago::getOniSplitExecutable()+" -version");
1341      myProcess.waitForFinished();
1342  
1343      QString result=myProcess.readAllStandardOutput();
1344  
1345 <    Util::showPopUp("This Vago version was built with base in OniSplit version "+GlobalVars::BuiltOniSplitVersion+"\n\nCurrent version is:\n"+result.trimmed());
1345 >    Util::Dialogs::showInfo("This Vago version was built with base in OniSplit version "+GlobalVars::BuiltOniSplitVersion+"\n\nCurrent version is:\n"+result.trimmed());
1346   }
1347  
1348   void MainWindow::on_actionCheck_xmlTools_version_triggered()
1349   {
1350      QProcess myProcess;
1351      myProcess.setWorkingDirectory(UtilVago::getAppPath());
1352 <    myProcess.start(UtilVago::getXmlToolsExeAbsolutePath()+" --version");
1352 >    myProcess.start(UtilVago::getXmlToolsExecutable()+" --version");
1353      myProcess.waitForFinished();
1354      QString result=myProcess.readLine();
1355  
1356 <    Util::showPopUp("This Vago version was built with base in XmlTools version "+GlobalVars::BuiltXmlToolsVersion+"\n\nCurrent version is:\n"+result.trimmed());
1356 >    Util::Dialogs::showInfo("This Vago version was built with base in XmlTools version "+GlobalVars::BuiltXmlToolsVersion+"\n\nCurrent version is:\n"+result.trimmed());
1357   }
1358  
1359   /**
# Line 1249 | Line 1371 | void MainWindow::updateItemsLoaded(DropT
1371      this->itemsLoaded->setText(QString().setNum(numItems)+ (numItems==1?" item ":" items ") +"loaded");
1372   }
1373  
1374 + void MainWindow::rowsWereChangedInDropTableWidget(){
1375 +    // We have changed rows, we have now unsaved changes.
1376 +    if(!this->unsavedChangesExist){
1377 +        this->unsavedChangesExist = true;
1378 +        setVagoWindowTitle();
1379 +    }
1380 + }
1381 +
1382   void MainWindow::on_tbCommand_clicked()
1383   {
1384 <    //Show preferences
1385 <    ManualCommands *commandsWindow = new ManualCommands(this);
1384 >    //We pass no parent because we want to have an independent window for ManualCommands,
1385 >    //so we can minimize it or maximize indepently from the MainWindow
1386 >    ManualCommands *commandsWindow = new ManualCommands();
1387      commandsWindow->show(); //it destroys itself when finished.
1388   }
1389  
# Line 1262 | Line 1393 | void MainWindow::on_actionWorkspace_trig
1393      ui->actionOther->setChecked(false);
1394      this->outputFolder=this->workspaceLocation;
1395      ui->tbOpenFolder->setToolTip("Open Vago workspace");
1396 <    showSuccessStatusMessage("Vago is now outputting the NEW items for Vago workspace.");
1396 >    Util::StatusBar::showSuccess(ui->statusBar, "Vago is now outputting the NEW items for Vago workspace.");
1397   }
1398  
1399   void MainWindow::on_actionOther_triggered()
1400   {
1401      QString newDir=QFileDialog::getExistingDirectory(this,"Choose the folder for output NEW files directly...",this->AeLocation+"/GameDataFolder");
1402 <    newDir=Util::normalizePath(newDir);
1402 >    newDir=Util::FileSystem::normalizePath(newDir);
1403  
1404      if(newDir.isEmpty()){
1405          ui->actionOther->setChecked(false);
# Line 1285 | Line 1416 | void MainWindow::on_actionOther_triggere
1416  
1417      this->outputFolder=newDir;
1418  
1419 <    QString newDirName=Util::cutName(newDir);
1419 >    QString newDirName=Util::FileSystem::cutName(newDir);
1420      ui->tbOpenFolder->setToolTip("Open "+newDirName+" output folder");
1421 <    showSuccessStatusMessage("Vago is now outputting the NEW items for "+newDirName+".");
1421 >    Util::StatusBar::showSuccess(ui->statusBar, "Vago is now outputting the NEW items for "+newDirName+".");
1422   }
1423  
1424   void MainWindow::on_actionView_log_triggered()
# Line 1313 | Line 1444 | void MainWindow::on_actionSave_Project_t
1444  
1445   }
1446  
1447 + // New Project
1448 + void MainWindow::on_actionNew_Project_triggered()
1449 + {
1450 +    if(this->vagoSettings->value("AskSaveProject").toBool() && this->unsavedChangesExist){
1451 +        QMessageBox::StandardButton result = askToSaveCurrentProject();
1452 +        if(result == QMessageBox::StandardButton::Cancel){
1453 +            return;
1454 +        }
1455 +    }
1456 +
1457 +    QList<DropTableWidget*> myTables = getAllTableWidgets();
1458 +
1459 +    for(DropTableWidget* const currTable : myTables){
1460 +        clearTableNoPrompt(currTable);
1461 +    }
1462 +
1463 +    this->lastProjectFilePath=""; // clear last project file path
1464 +    this->unsavedChangesExist = false;
1465 +
1466 +    setVagoWindowTitle(); // update vago title
1467 + }
1468 +
1469   void MainWindow::on_actionSave_triggered()
1470   {
1471      if(this->lastProjectFilePath.isEmpty()){
# Line 1404 | Line 1557 | void MainWindow::dtContextMenu(DropTable
1557  
1558      QList<int> selectedRows = QList<int>();
1559  
1560 <    foreach(QModelIndex rowItem, myTable->selectionModel()->selectedRows()){
1560 >    for(const QModelIndex &rowItem : myTable->selectionModel()->selectedRows()){
1561          selectedRows << rowItem.row();
1562      }
1563  
# Line 1442 | Line 1595 | void MainWindow::dtContextMenu(DropTable
1595  
1596      //Can we change the settings? (the conversion must be the same)
1597      QString currentSettings = (getTypeConversion(myTable)); //call function at the mainWindow with a signal (different threads?)
1598 <    foreach(int row, selectedRows){
1598 >    for(const int row : selectedRows){
1599          if( myTable->item(row,1)->text() != currentSettings){ //If we find out any of the selected items can't be convert disable operation
1600              changeOptions->setEnabled(false);
1601              break;
# Line 1472 | Line 1625 | void MainWindow::dtContextMenu(DropTable
1625          }
1626  
1627          QApplication::clipboard()->setText(toCopy);
1628 <        showSuccessStatusMessage(QString::number(size) + (size==1?" item ":" items ")+ "copied to the clipboard");
1628 >        Util::StatusBar::showSuccess(ui->statusBar, QString::number(size) + (size==1?" item ":" items ")+ "copied to the clipboard");
1629      }
1630      else if(selectedOption==moveUp.get()){
1631          qSort(selectedRows); //let's order the selections by the row number, so we know exactly how to swap it
1632          myTable->swapPositions(selectedRows,-1);
1633 +        rowsWereChangedInDropTableWidget();
1634      }
1635      else if(selectedOption==moveDown.get()){
1636          qSort(selectedRows);
1637          myTable->swapPositions(selectedRows,+1);
1638 +        rowsWereChangedInDropTableWidget();
1639      }
1640      else if(selectedOption==changeOptions.get()){
1641          changeToCurrentSettings(selectedRows,myTable);
# Line 1494 | Line 1649 | void MainWindow::dtContextMenu(DropTable
1649      else if(selectedOption==outOther.get()){
1650  
1651          QString newDir=QFileDialog::getExistingDirectory(this,"Choose the folder for the output of the files selected...",this->AeLocation+"/GameDataFolder");
1652 <        newDir=Util::normalizePath(newDir);
1652 >        newDir=Util::FileSystem::normalizePath(newDir);
1653  
1654          if(newDir.isEmpty()){
1655              return; //do nothing
# Line 1539 | Line 1694 | void MainWindow::dtContextMenu(DropTable
1694              result+=QString::number(disabledCount) + (disabledCount==1?" item ":" items ") + "Disabled";
1695          }
1696  
1697 <        showSuccessStatusMessage(result);
1697 >        rowsWereChangedInDropTableWidget();
1698 >        Util::StatusBar::showSuccess(ui->statusBar, result);
1699      }
1700   }
1701  
# Line 1552 | Line 1708 | void MainWindow::changeToCurrentSettings
1708  
1709      QString command;
1710  
1711 <    foreach(int row, rows){
1556 <
1711 >    for(int row : rows){
1712          command=getCommand(myTable,getFileOutputFolder(fromTo,myTable->getOutputAbsolute(row)),from,to,myTable->getFileAbsolute(row));
1713  
1714          if(command.isEmpty()){ //something wrong was happening (not inputted a texture name?)
# Line 1564 | Line 1719 | void MainWindow::changeToCurrentSettings
1719          myTable->updateTableToolTips(row);
1720      }
1721  
1722 <    showSuccessStatusMessage(QString::number(rows.size()) + (rows.size()==1?" item ":" items ")+ "changed to the current settings");
1722 >    rowsWereChangedInDropTableWidget();
1723 >    Util::StatusBar::showSuccess(ui->statusBar, QString::number(rows.size()) + (rows.size()==1?" item ":" items ")+ "changed to the current settings");
1724   }
1725  
1726   void MainWindow::changeItemsOutput(DropTableWidget* myTable, QList<int> rows, QString newOutput){
1727  
1728      QString command, currentAbsoluteFile, fromTo, from, to;
1729  
1730 <    foreach(int row, rows){ //No optimization possible here, commands may be different
1730 >    for(const int row : rows){ //No optimization possible here, commands may be different
1731          fromTo=myTable->item(row,1)->text();
1732          from = QString(fromTo).remove(fromTo.indexOf(" >"),fromTo.size()-1); //parse the string to get the from
1733          to = QString(fromTo).remove(0,fromTo.lastIndexOf("> ")+2); //+2 to start after "> "
# Line 1587 | Line 1743 | void MainWindow::changeItemsOutput(DropT
1743          myTable->updateTableToolTips(row);
1744      }
1745  
1746 <    showSuccessStatusMessage(QString::number(rows.size()) + (rows.size()==1?" item ":" items ")+ "changed the output to "+(newOutput!=this->workspaceLocation?Util::cutName(newOutput):"Vago workspace"));
1746 >    rowsWereChangedInDropTableWidget();
1747 >    Util::StatusBar::showSuccess(ui->statusBar, QString::number(rows.size()) + (rows.size()==1?" item ":" items ")+ "changed the output to "+(newOutput!=this->workspaceLocation?Util::FileSystem::cutName(newOutput):"Vago workspace"));
1748   }
1749  
1750   QString MainWindow::getCommand(DropTableWidget* myTable, QString myOutputFolder, QString from, QString to , QString file){
# Line 1671 | Line 1828 | void MainWindow::connectSlots(){
1828  
1829   void MainWindow::saveProjectState(const QString &filePath)
1830   {
1831 +    try{
1832 +        ProjectFileVago::saveProjectDataToFile(filePath, fetchCurrentProjectData());
1833  
1834 <    QList<DropTableWidget*> tableWidgets = getAllTableWidgets();
1834 >        this->vagoSettings->setValue("LastProjectPath",QFileInfo(filePath).absoluteDir().path());
1835  
1836 <    pugi::xml_document doc;
1836 >        this->lastProjectFilePath = filePath;
1837 >        this->unsavedChangesExist = false;
1838  
1839 <    pugi::xml_node rootNode = doc.append_child("VagoProject");
1680 <    rootNode.append_attribute("vagoVersion").set_value(GlobalVars::AppVersion.toUtf8().constData());
1839 >        addNewRecentProject(filePath);
1840  
1841 <    foreach(DropTableWidget* const &myTable, tableWidgets){
1683 <        saveProjectWidget(rootNode, myTable);
1684 <    }
1841 >        setVagoWindowTitle();
1842  
1843 <    if(!doc.save_file(filePath.toUtf8().constData(), PUGIXML_TEXT("\t"), pugi::format_default | pugi::format_write_bom, pugi::xml_encoding::encoding_utf8)){
1844 <        UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "An error ocurred while trying to save the project file. Please try another path.");
1845 <        return;
1843 >        Util::StatusBar::showSuccess(ui->statusBar, "Project saved sucessfully.");
1844 >    }
1845 >    catch(const std::exception& e){
1846 >        QString errorMessage = "An error ocurred while trying to save the project file. Please try another path.";
1847 >        UtilVago::showAndLogErrorPopUpLogButton(errorMessage);
1848 >        Util::StatusBar::showError(ui->statusBar, "Couldn't save project file.");
1849      }
1850 + }
1851  
1852 <    this->vagoSettings->setValue("LastProjectPath",QFileInfo(filePath).absoluteDir().path());
1852 > ProjectFileVago::ProjectData MainWindow::fetchCurrentProjectData(){
1853  
1854 <    this->lastProjectFilePath = filePath;
1854 >    ProjectFileVago::ProjectData currentProjectData;
1855  
1856 <    addNewRecentProject(filePath);
1856 >    auto fFetchTabGenericData =
1857 >            [](ProjectFileVago::ProjectTable &projectTable,
1858 >            const QComboBox * const cbFrom,
1859 >            const QComboBox * const cbTo,
1860 >            DropTableWidget const * const table) ->void{
1861  
1862 <    setVagoWindowTitle();
1863 < }
1862 >        projectTable.from = cbFrom->currentText();
1863 >        projectTable.to = cbTo->currentText();
1864  
1865 < void MainWindow::saveProjectWidget(pugi::xml_node &rootNode, DropTableWidget* table)
1701 < {
1702 <    QString from;
1703 <    QString to;
1704 <    QString tabName = getTabNameByTableWidget(table);
1705 <
1706 <    pugi::xml_node currentNodeTable = rootNode.append_child("tempName");
1707 <    pugi::xml_node options;
1708 <
1709 <    if(table==ui->twSourcesXML){ //So we only need to parse one command.
1710 <        from = ui->cbFromXML->currentText().toUtf8().constData();
1711 <        to = ui->cbToXML->currentText().toUtf8().constData();
1712 <    }
1713 <    else if(table==ui->twSourcesTextures){
1714 <        from = ui->cbFromTextures->currentText().toUtf8().constData();
1715 <        to = ui->cbToTextures->currentText().toUtf8().constData();
1716 <        options = currentNodeTable.append_child("Options");
1717 <        options.append_attribute("type").set_value(Util::qStrToCstr(getTextureRBCheckedTypeTexture()->text()));
1718 <        options.append_attribute("genMipMaps").set_value(Util::boolToCstr(ui->cbMipMapsTextures->isChecked()));
1719 <        options.append_attribute("noUwrap").set_value(Util::boolToCstr(ui->cbNoUwrap->isChecked()));
1720 <        options.append_attribute("noVwrap").set_value(Util::boolToCstr(ui->cbNoVwrap->isChecked()));
1721 <        options.append_attribute("large").set_value(Util::boolToCstr(ui->cbLarge->isChecked()));
1722 <        options.append_attribute("envMap").set_value(Util::boolToCstr(ui->cbEnvMap->isChecked()));
1723 <        options.append_attribute("envMapValue").set_value(Util::qStrToCstr(ui->leEnvMapTexture->text()));
1724 <    }
1725 <    else if(table==ui->twSourcesCharacters){
1726 <        from = ui->cbFromCharacters->currentText().toUtf8().constData();
1727 <        to = ui->cbToCharacters->currentText().toUtf8().constData();
1728 <        options = currentNodeTable.append_child("Options");
1729 <        options.append_attribute("cellShading").set_value(Util::boolToCstr(ui->cbCellShading->isChecked()));
1730 <        options.append_attribute("normals").set_value(Util::boolToCstr(ui->cbNormals->isChecked()));
1731 <        options.append_attribute("extractTRBSONCC").set_value(Util::boolToCstr(ui->cbWithTRBS_ONCC->isChecked()));
1732 <        options.append_attribute("extractTRBSONCCValue").set_value(Util::qStrToCstr(ui->leTRBS_ONCC->text()));
1733 <    }
1734 <    else if(table==ui->twSourcesObjects){
1735 <        from = ui->cbFromObjects->currentText().toUtf8().constData();
1736 <        to = ui->cbToObjects->currentText().toUtf8().constData();
1737 <        options = currentNodeTable.append_child("Options");
1738 <        options.append_attribute("texture").set_value(Util::boolToCstr(ui->cbTexture->isChecked()));
1739 <        options.append_attribute("textureValue").set_value(Util::qStrToCstr(ui->leTextureName->text()));
1740 <        options.append_attribute("withAnimation").set_value(Util::boolToCstr(ui->cbWithAnimation->isChecked()));
1741 <        options.append_attribute("withAnimationValue").set_value(Util::qStrToCstr(ui->leAnimationName->text()));
1742 <    }
1743 <    else if(table==ui->twSourcesLevels){
1744 <        from = ui->cbFromLevels->currentText().toUtf8().constData();
1745 <        to = ui->cbToLevels->currentText().toUtf8().constData();
1746 <        options = currentNodeTable.append_child("Options");
1747 <        options.append_attribute("extractWithFiles").set_value(Util::boolToCstr(ui->cbSpecificFilesLevels->isChecked()));
1748 <        options.append_attribute("extractWithFilesValue").set_value(Util::qStrToCstr(ui->leSpecificFilesLevels->text()));
1749 <        options.append_attribute("datFilename").set_value(Util::boolToCstr(ui->cbDatLevels->isChecked()));
1750 <        options.append_attribute("datFilenameValue").set_value(Util::qStrToCstr(ui->leTargetDatLevels->text()));
1751 <        options.append_attribute("bnvSource").set_value(Util::boolToCstr(ui->cbBnvLevels->isChecked()));
1752 <        options.append_attribute("bnvSourceValue").set_value(Util::qStrToCstr(ui->leBnvLevels->text()));
1753 <        options.append_attribute("generateGrids").set_value(Util::boolToCstr(ui->cbGridsLevels->isChecked()));
1754 <        options.append_attribute("additionalSources").set_value(Util::boolToCstr(ui->cbAdditionalSourcesLevels->isChecked()));
1755 <        options.append_attribute("additionalSourcesValue").set_value(Util::qStrToCstr(ui->leAdditSourcesLevels->text()));
1756 <    }
1757 <    else{
1758 <        from = ui->cbFromMisc->currentText().toUtf8().constData();
1759 <        to = ui->cbToMisc->currentText().toUtf8().constData();
1760 <    }
1761 <
1762 <    currentNodeTable.set_name(tabName.toUtf8().constData());
1865 >        for(int i=0; i<table->rowCount(); i++){
1866  
1867 <    currentNodeTable.append_attribute("from").set_value(from.toUtf8().constData());
1765 <    currentNodeTable.append_attribute("to").set_value(to.toUtf8().constData());
1867 >            ProjectFileVago::ProjectTableRow currentRow;
1868  
1869 +            currentRow.fileFolder = table->item(i,0)->text();
1870 +            currentRow.fromTo = table->item(i,1)->text();
1871 +            currentRow.command= table->item(i,2)->text();
1872  
1873 <    for(int i=0; i<table->rowCount(); i++){
1874 <
1875 <        QString currFileFolder = table->item(i,0)->text();
1771 <        QString currFromTo = table->item(i,1)->text();
1772 <        QString currCommand = table->item(i,2)->text();
1873 >            if(table->item(i,2)->background()==table->disabledBackStyle){
1874 >                currentRow.isDisabled = true;
1875 >            }
1876  
1877 <        pugi::xml_node currentRow = currentNodeTable.append_child("Row");
1877 >            projectTable.rows.append(currentRow);
1878 >        }
1879 >    };
1880  
1881 +    // XML tab
1882 +    fFetchTabGenericData(currentProjectData.xmlTable, ui->cbFromXML, ui->cbToXML, ui->twSourcesXML);
1883  
1884 <        currentRow.append_attribute("fileFolder").set_value(Util::qStrToCstr(currFileFolder));
1885 <        currentRow.append_attribute("fromTo").set_value(Util::qStrToCstr(currFromTo));
1886 <        currentRow.append_attribute("command").set_value(Util::qStrToCstr(currCommand));
1884 >    // Textures tab
1885 >    fFetchTabGenericData(currentProjectData.texturesTable, ui->cbFromTextures, ui->cbToTextures, ui->twSourcesTextures);
1886 >    currentProjectData.texturesTable.rbTexturesType = getTextureRBCheckedTypeTexture()->text();
1887 >    currentProjectData.texturesTable.cbGenMipMaps = ui->cbMipMapsTextures->isChecked();
1888 >    currentProjectData.texturesTable.cbNoUwrap = ui->cbNoUwrap->isChecked();
1889 >    currentProjectData.texturesTable.cbNoVwrap = ui->cbNoVwrap->isChecked();
1890 >    currentProjectData.texturesTable.cbLarge = ui->cbLarge->isChecked();
1891 >    currentProjectData.texturesTable.cbEnvMap = ui->cbEnvMap->isChecked();
1892 >    currentProjectData.texturesTable.leEnvMapTexture = ui->leEnvMapTexture->text();
1893 >
1894 >    // Characters tab
1895 >    fFetchTabGenericData(currentProjectData.charactersTable, ui->cbFromCharacters, ui->cbToCharacters, ui->twSourcesCharacters);
1896 >    currentProjectData.charactersTable.cbCellShading = ui->cbCellShading->isChecked();
1897 >    currentProjectData.charactersTable.cbNormals = ui->cbNormals->isChecked();
1898 >    currentProjectData.charactersTable.cbStandingPose = ui->cbStandingPose->isChecked();
1899 >    currentProjectData.charactersTable.cbWithTRBS_ONCC = ui->cbWithTRBS_ONCC->isChecked();
1900 >    currentProjectData.charactersTable.leTRBS_ONCC = ui->leTRBS_ONCC->text();
1901 >
1902 >    // Objects tab
1903 >    fFetchTabGenericData(currentProjectData.objectsTable, ui->cbFromObjects, ui->cbToObjects, ui->twSourcesObjects);
1904 >    currentProjectData.objectsTable.cbTexture = ui->cbTexture->isChecked();
1905 >    currentProjectData.objectsTable.leTextureName = ui->leTextureName->text();
1906 >    currentProjectData.objectsTable.cbWithAnimation = ui->cbWithAnimation->isChecked();
1907 >    currentProjectData.objectsTable.leAnimationName = ui->leAnimationName->text();
1908 >
1909 >    // Levels tab
1910 >    fFetchTabGenericData(currentProjectData.levelsTable, ui->cbFromLevels, ui->cbToLevels, ui->twSourcesLevels);
1911 >    currentProjectData.levelsTable.cbSpecificFilesLevels = ui->cbSpecificFilesLevels->isChecked();
1912 >    currentProjectData.levelsTable.leSpecificFilesLevels = ui->leSpecificFilesLevels->text();
1913 >    currentProjectData.levelsTable.cbDatLevels = ui->cbDatLevels->isChecked();
1914 >    currentProjectData.levelsTable.leTargetDatLevels = ui->leTargetDatLevels->text();
1915 >    currentProjectData.levelsTable.cbBnvLevels = ui->cbBnvLevels->isChecked();
1916 >    currentProjectData.levelsTable.leBnvLevels = ui->leBnvLevels->text();
1917 >    currentProjectData.levelsTable.cbGridsLevels = ui->cbGridsLevels->isChecked();
1918 >    currentProjectData.levelsTable.cbAdditionalSourcesLevels = ui->cbAdditionalSourcesLevels->isChecked();
1919 >    currentProjectData.levelsTable.leAdditSourcesLevels = ui->leAdditSourcesLevels->text();
1920  
1921 <        if(table->item(i,2)->background()==table->disabledBackStyle){
1922 <            currentRow.append_attribute("disabled").set_value(true);
1783 <        }
1921 >    // Misc tab
1922 >    fFetchTabGenericData(currentProjectData.miscTable, ui->cbFromMisc, ui->cbToMisc, ui->twSourcesMisc);
1923  
1924 <    }
1924 >    return currentProjectData;
1925   }
1926  
1927   QRadioButton* MainWindow::getTextureRBCheckedTypeTexture()
# Line 1838 | Line 1977 | void MainWindow::setVagoWindowTitle(){
1977          vagoTitle += "Untitled";
1978      }
1979      else{
1980 <        vagoTitle += Util::cutNameWithoutBackSlash(this->lastProjectFilePath);
1980 >        vagoTitle += Util::FileSystem::cutNameWithoutBackSlash(this->lastProjectFilePath);
1981 >    }
1982 >
1983 >    if(this->unsavedChangesExist){
1984 >        vagoTitle += "*";
1985      }
1986  
1987      setWindowTitle(vagoTitle);
# Line 1913 | Line 2056 | QList<DropTableWidget*> MainWindow::getA
2056   void MainWindow::loadProjectState(const QString &filePath)
2057   {
2058  
2059 <    QString statusError = "Couldn't load project.";
2060 <
2061 <    pugi::xml_document doc;
2062 <
2063 <    pugi::xml_parse_result result = doc.load_file(Util::qStrToCstr(filePath));
2064 <
2065 <    if(result.status!=pugi::status_ok){
2066 <        UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "An error ocurred while loading project file.\n" + QString(result.description()));
2067 <        showErrStatusMessage(statusError);
2068 <        return;
2069 <    }
2070 <
2071 <
2072 <    if(QString(doc.root().first_child().name()) != "VagoProject"){
2073 <        UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, QString(doc.root().name()) + "The file opened is not a valid VagoProject file. Load aborted.");
2074 <        showErrStatusMessage(statusError);
2075 <        return;
2076 <    }
2077 <
2078 <    QString projVagoVersion;
2079 <
2080 <    try{
2081 <        projVagoVersion = QString(doc.select_node("/VagoProject/@vagoVersion").attribute().value());
2082 <    }
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);
2059 >    auto fLoadTabGenericData =
2060 >            [this]( // we are capturing this only to call the addRowTable function...
2061 >                const ProjectFileVago::ProjectTable &tableData,
2062 >                DropTableWidget * const table,
2063 >                QComboBox * const cbFrom,
2064 >                QComboBox * const cbTo) -> void{
2065 >
2066 >        cbFrom->setCurrentText(tableData.from);
2067 >        cbTo->setCurrentText(tableData.to);
2068 >
2069 >        // Add rows
2070 >        for(const ProjectFileVago::ProjectTableRow &currentRow : tableData.rows){
2071 >            addRowTable(table,currentRow.fileFolder,currentRow.fromTo,currentRow.command, currentRow.isDisabled);
2072 >        }
2073 >
2074 >    };
2075 >
2076 >    this->projectIsLoading = true;
2077 >
2078 >    if(this->vagoSettings->value("AskSaveProject").toBool() && this->unsavedChangesExist){
2079 >        QMessageBox::StandardButton result = askToSaveCurrentProject();
2080 >        if(result == QMessageBox::StandardButton::Cancel){
2081 >            this->projectIsLoading = false;
2082 >            return;
2083          }
2084      }
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    }
2085  
2086 <    this->vagoSettings->setValue("LastProjectPath",QFileInfo(filePath).absoluteDir().path());
2086 >    try{
2087 >        ProjectFileVago::ProjectData projectData = ProjectFileVago::readProjectDataFromFile(filePath);
2088  
2089 <    this->lastProjectFilePath = filePath;
2089 >        // XML tab
2090 >        fLoadTabGenericData(projectData.xmlTable, ui->twSourcesXML, ui->cbFromXML, ui->cbToXML);
2091  
2092 <    addNewRecentProject(filePath);
2092 >        // Textures tab
2093 >        fLoadTabGenericData(projectData.texturesTable, ui->twSourcesTextures, ui->cbFromTextures, ui->cbToTextures);
2094 >        getTextureRBTypeTextureByName(projectData.texturesTable.rbTexturesType)->setChecked(true);
2095 >        ui->cbMipMapsTextures->setChecked(projectData.texturesTable.cbGenMipMaps);
2096 >        ui->cbNoUwrap->setChecked(projectData.texturesTable.cbNoUwrap);
2097 >        ui->cbNoVwrap->setChecked(projectData.texturesTable.cbNoVwrap);
2098 >        ui->cbLarge->setChecked(projectData.texturesTable.cbLarge);
2099 >        ui->cbEnvMap->setChecked(projectData.texturesTable.cbEnvMap);
2100 >        ui->leEnvMapTexture->setText(projectData.texturesTable.leEnvMapTexture);
2101 >
2102 >        // Characters tab
2103 >        fLoadTabGenericData(projectData.charactersTable, ui->twSourcesCharacters, ui->cbFromCharacters, ui->cbToCharacters);
2104 >
2105 >        ui->cbCellShading->setChecked(projectData.charactersTable.cbCellShading);
2106 >        ui->cbNormals->setChecked(projectData.charactersTable.cbNormals);
2107 >        ui->cbStandingPose->setChecked(projectData.charactersTable.cbStandingPose);
2108 >        ui->cbWithTRBS_ONCC->setChecked(projectData.charactersTable.cbWithTRBS_ONCC);
2109 >        ui->leTRBS_ONCC->setText(projectData.charactersTable.leTRBS_ONCC);
2110 >
2111 >        // Objects tab
2112 >        fLoadTabGenericData(projectData.objectsTable, ui->twSourcesObjects, ui->cbFromObjects, ui->cbToObjects);
2113 >
2114 >        ui->cbTexture->setChecked(projectData.objectsTable.cbTexture);
2115 >        ui->leTextureName->setText(projectData.objectsTable.leTextureName);
2116 >        ui->cbWithAnimation->setChecked(projectData.objectsTable.cbWithAnimation);
2117 >        ui->leAnimationName->setText(projectData.objectsTable.leAnimationName);
2118 >
2119 >        // Levels tab
2120 >        fLoadTabGenericData(projectData.levelsTable, ui->twSourcesLevels, ui->cbFromLevels, ui->cbToLevels);
2121 >
2122 >        ui->cbSpecificFilesLevels->setChecked(projectData.levelsTable.cbSpecificFilesLevels);
2123 >        ui->leSpecificFilesLevels->setText(projectData.levelsTable.leSpecificFilesLevels);
2124 >        ui->cbDatLevels->setChecked(projectData.levelsTable.cbDatLevels);
2125 >        ui->leTargetDatLevels->setText(projectData.levelsTable.leTargetDatLevels);
2126 >        ui->cbBnvLevels->setChecked(projectData.levelsTable.cbBnvLevels);
2127 >        ui->leBnvLevels->setText(projectData.levelsTable.leBnvLevels);
2128 >        ui->cbGridsLevels->setChecked(projectData.levelsTable.cbGridsLevels);
2129 >        ui->cbAdditionalSourcesLevels->setChecked(projectData.levelsTable.cbAdditionalSourcesLevels);
2130 >        ui->leAdditSourcesLevels->setText(projectData.levelsTable.leAdditSourcesLevels);
2131 >
2132 >        // Misc tab
2133 >        fLoadTabGenericData(projectData.miscTable, ui->twSourcesMisc, ui->cbFromMisc, ui->cbToMisc);
2134 >
2135 >        this->vagoSettings->setValue("LastProjectPath",QFileInfo(filePath).absoluteDir().path());
2136 >
2137 >        this->lastProjectFilePath = filePath;
2138 >        this->unsavedChangesExist = false;
2139  
2140 <    setVagoWindowTitle();
2140 >        addNewRecentProject(filePath);
2141  
2142 <    showSuccessStatusMessage("Project loaded sucessfully.");
1977 < }
2142 >        setVagoWindowTitle();
2143  
2144 +        this->projectIsLoading = false;
2145  
2146 < void MainWindow::loadProjectWidget(pugi::xml_document &doc, DropTableWidget* table)
1981 < {
1982 <    QString tabName = getTabNameByTableWidget(table);
1983 <    QString from (doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/@from")).attribute().value());
1984 <    QString to (doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/@to")).attribute().value());
1985 <
1986 <    if(table==ui->twSourcesXML){
1987 <        ui->cbFromXML->setCurrentText(from);
1988 <        on_cbFromXML_currentIndexChanged(from);
1989 <        ui->cbToXML->setCurrentText(to);
1990 <    }
1991 <    else if(table==ui->twSourcesTextures){
1992 <        //ui->cbFromTextures->setCurrentText(from);
1993 <        on_cbFromTextures_currentIndexChanged(from);
1994 <        ui->cbToTextures->setCurrentText(to);
1995 <
1996 <        getTextureRBTypeTextureByName((doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@type")).attribute().value()))->setChecked(true);
1997 <        ui->cbMipMapsTextures->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@genMipMaps")).attribute().as_bool());
1998 <        ui->cbNoUwrap->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@noUwrap")).attribute().as_bool());
1999 <        ui->cbNoVwrap->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@noVwrap")).attribute().as_bool());
2000 <        ui->cbLarge->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@large")).attribute().as_bool());
2001 <        ui->cbEnvMap->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@envMap")).attribute().as_bool());
2002 <        ui->leEnvMapTexture->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@envMapValue")).attribute().value()));
2003 <    }
2004 <    else if(table==ui->twSourcesCharacters){
2005 <        ui->cbFromCharacters->setCurrentText(from);
2006 <        on_cbFromCharacters_currentIndexChanged(from);
2007 <        ui->cbToCharacters->setCurrentText(to);
2008 <
2009 <
2010 <        ui->cbCellShading->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@cellShading")).attribute().as_bool());
2011 <        ui->cbNormals->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@normals")).attribute().as_bool());
2012 <        ui->cbWithTRBS_ONCC->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@extractTRBSONCC")).attribute().as_bool());
2013 <        ui->leTRBS_ONCC->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@extractTRBSONCCValue")).attribute().value()));
2014 <    }
2015 <    else if(table==ui->twSourcesObjects){
2016 <        ui->cbFromObjects->setCurrentText(from);
2017 <        on_cbFromObjects_currentIndexChanged(from);
2018 <        ui->cbToObjects->setCurrentText(to);
2019 <
2020 <        ui->cbTexture->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@texture")).attribute().as_bool());
2021 <        ui->leTextureName->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@textureValue")).attribute().value()));
2022 <        ui->cbWithAnimation->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@withAnimation")).attribute().as_bool());
2023 <        ui->leAnimationName->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@withAnimationValue")).attribute().value()));
2024 <    }
2025 <    else if(table==ui->twSourcesLevels){
2026 <        ui->cbFromLevels->setCurrentText(from);
2027 <        on_cbFromLevels_currentIndexChanged(from);
2028 <        ui->cbToLevels->setCurrentText(to);
2029 <
2030 <        ui->cbSpecificFilesLevels->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@extractWithFiles")).attribute().as_bool());
2031 <        ui->leSpecificFilesLevels->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@extractWithFilesValue")).attribute().value()));
2032 <        ui->cbDatLevels->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@datFilename")).attribute().as_bool());
2033 <        ui->leTargetDatLevels->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@datFilenameValue")).attribute().value()));
2034 <        ui->cbBnvLevels->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@bnvSource")).attribute().as_bool());
2035 <        ui->leBnvLevels->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@bnvSourceValue")).attribute().value()));
2036 <        ui->cbGridsLevels->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@generateGrids")).attribute().as_bool());
2037 <        ui->cbAdditionalSourcesLevels->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@additionalSources")).attribute().as_bool());
2038 <        ui->leAdditSourcesLevels->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@bnvSource")).attribute().value()));
2146 >        Util::StatusBar::showSuccess(ui->statusBar, "Project loaded sucessfully.");
2147      }
2148 <    else{
2149 <        ui->cbFromMisc->setCurrentText(from);
2150 <        on_cbFromMisc_currentIndexChanged(from);
2151 <        ui->cbToMisc->setCurrentText(to);
2148 >    catch(const std::exception& e){
2149 >        this->projectIsLoading = false;
2150 >        QString errorMessage = "Couldn't load the Vago project. Error: " + QString(e.what());
2151 >        LOG_ERROR << errorMessage;
2152 >        Util::Dialogs::showError(errorMessage);
2153 >        Util::StatusBar::showError(ui->statusBar, "Couldn't load project.");
2154      }
2155  
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    }
2156   }
2157  
2158   void MainWindow::saveRecentProjects(){

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)