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::getOniSplitExecutableAbsolutePath())){ |
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."); |
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::getXmlToolsExecutableAbsolutePath())){ |
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."); |
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 |
|
|
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); |
180 |
|
MainWindow::~MainWindow() |
181 |
|
{ |
182 |
|
delete ui; |
183 |
< |
this->myLogger->writeString("Application Exited."); |
183 |
> |
LOG_INFO << "Application Exited."; |
184 |
|
} |
185 |
|
|
186 |
|
|
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); |
213 |
> |
this->myConverter = new Converter(UtilVago::getAppPath(), &this->listToProccess, this->win7TaskBarProgress); |
214 |
|
#else |
215 |
< |
this->myConverter = new Converter(UtilVago::getAppPath(), this->myLogger, &this->listToProccess); |
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 |
|
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::showQuestionPopUp(this,"Do you want to load latest project?\n\nLatest project was '" + Util::cutNameWithoutBackSlash(lastSavedProject) + "'.")){ |
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 |
|
} |
246 |
|
void MainWindow::on_actionAE_Package_Creator_triggered() |
247 |
|
{ |
248 |
|
// it deletes itself once closed |
249 |
< |
WizardFactory<PackageWizard>::startInstance(UtilVago::getAppPath(), this->workspaceWizardsLocation, this->vagoSettings, this->myLogger); |
249 |
> |
WizardFactory<PackageWizard>::startInstance(UtilVago::getAppPath(), this->workspaceWizardsLocation, this->vagoSettings); |
250 |
|
} |
251 |
|
|
252 |
|
void MainWindow::on_actionSound_Wizard_triggered() |
253 |
|
{ |
254 |
|
// it deletes itself once closed |
255 |
< |
WizardFactory<SoundWizard>::startInstance(UtilVago::getAppPath(), this->workspaceWizardsLocation, this->vagoSettings, this->myLogger, &this->commandMap); |
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, this->myLogger); |
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, this->myLogger); |
267 |
> |
WizardFactory<WmWizard>::startInstance(UtilVago::getAppPath(), this->workspaceWizardsLocation, this->vagoSettings); |
268 |
|
} |
269 |
|
|
270 |
|
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 |
|
|
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 |
|
|
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(this->myLogger); |
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 |
|
} |
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() |
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 |
|
} |
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 (*.*)")); |
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){ |
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 |
|
} |
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 |
|
|
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 |
|
} |
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); |
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->isEnabled() && ui->cbNormals->isChecked()){ |
607 |
> |
command+=" "+this->commandMap.value(tabTitle + "->" + ui->cbNormals->text()); |
608 |
|
} |
609 |
|
|
610 |
< |
if(ui->cbNormals->isChecked()){ |
611 |
< |
command+=" "+this->commandMap.value(tabTitle+"->"+ui->cbNormals->text()); |
610 |
> |
if(ui->cbStandingPose->isEnabled() && ui->cbStandingPose->isChecked()){ |
611 |
> |
command+=" "+this->commandMap.value(tabTitle + "->" + ui->cbStandingPose->text()); |
612 |
|
} |
613 |
|
|
614 |
< |
if(ui->cbWithTRBS_ONCC->isChecked()){ |
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; |
628 |
|
|
629 |
|
QString command=this->commandMap.value(tabTitle+"->"+from+"->"+to)+" "+myOutputFolder; |
630 |
|
|
631 |
< |
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 |
|
|
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 |
|
|
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; |
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 |
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{ |
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{ |
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 |
|
|
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; |
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; |
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 |
|
|
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)."); |
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 |
|
} |
856 |
|
} |
857 |
|
else{ |
858 |
< |
showSuccessStatusMessage("Everything went well!"); |
858 |
> |
Util::StatusBar::showSuccess(ui->statusBar, "Everything went well!"); |
859 |
|
} |
860 |
|
} |
861 |
|
|
863 |
|
this->myBar->hide(); |
864 |
|
ui->tbAbortConversion->hide(); |
865 |
|
|
866 |
< |
showErrStatusMessage("Conversion was aborted."); |
801 |
< |
} |
802 |
< |
|
803 |
< |
void MainWindow::showErrStatusMessage(QString message){ |
804 |
< |
|
805 |
< |
QPalette myPalete = QPalette(); |
806 |
< |
myPalete.setColor( QPalette::WindowText, QColor(255,0,0)); |
807 |
< |
statusBar()->setPalette( myPalete ); |
808 |
< |
ui->statusBar->showMessage(message,10000); //display by 10 seconds |
809 |
< |
|
810 |
< |
} |
811 |
< |
|
812 |
< |
void MainWindow::showSuccessStatusMessage(QString message){ |
813 |
< |
|
814 |
< |
QPalette myPalete = QPalette(); |
815 |
< |
myPalete.setColor( QPalette::WindowText, QColor(0,150,0)); |
816 |
< |
statusBar()->setPalette( myPalete ); |
817 |
< |
ui->statusBar->showMessage(message,10000); //display by 10 seconds |
818 |
< |
|
866 |
> |
Util::StatusBar::showError(ui->statusBar, "Conversion was aborted."); |
867 |
|
} |
868 |
|
|
869 |
|
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"); |
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 |
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); |
981 |
– |
ui->cbWithTRBS_ONCC->setChecked(false); |
1031 |
|
ui->cbCellShading->setEnabled(false); |
983 |
– |
ui->cbCellShading->setChecked(false); |
1032 |
|
ui->cbNormals->setEnabled(false); |
1033 |
< |
ui->cbNormals->setChecked(false); |
1034 |
< |
//#error add drag and drop to Extract TRAM with TRBS/ONCC |
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); |
1023 |
– |
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 |
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 |
|
|
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()); |
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 |
|
|
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(); |
1268 |
|
|
1269 |
|
QMessageBox::StandardButton MainWindow::askToSaveCurrentProject(){ |
1270 |
|
QMessageBox::StandardButton result = |
1271 |
< |
Util::showQuestionPopUpWithCancel(this,"There are unsaved changes. Do you want to save the current project?", QMessageBox::StandardButton::Yes); |
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(); |
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() |
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 |
|
/** |
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); |
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() |
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 |
|
|
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; |
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 |
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 |
1695 |
|
} |
1696 |
|
|
1697 |
|
rowsWereChangedInDropTableWidget(); |
1698 |
< |
showSuccessStatusMessage(result); |
1698 |
> |
Util::StatusBar::showSuccess(ui->statusBar, result); |
1699 |
|
} |
1700 |
|
} |
1701 |
|
|
1708 |
|
|
1709 |
|
QString command; |
1710 |
|
|
1711 |
< |
foreach(int row, rows){ |
1653 |
< |
|
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?) |
1720 |
|
} |
1721 |
|
|
1722 |
|
rowsWereChangedInDropTableWidget(); |
1723 |
< |
showSuccessStatusMessage(QString::number(rows.size()) + (rows.size()==1?" item ":" items ")+ "changed to the current settings"); |
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 "> " |
1744 |
|
} |
1745 |
|
|
1746 |
|
rowsWereChangedInDropTableWidget(); |
1747 |
< |
showSuccessStatusMessage(QString::number(rows.size()) + (rows.size()==1?" item ":" items ")+ "changed the output to "+(newOutput!=this->workspaceLocation?Util::cutName(newOutput):"Vago workspace")); |
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){ |
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"); |
1779 |
< |
rootNode.append_attribute("vagoVersion").set_value(GlobalVars::LastCompatibleVersion.toUtf8().constData()); |
1839 |
> |
addNewRecentProject(filePath); |
1840 |
|
|
1841 |
< |
foreach(DropTableWidget* const &myTable, tableWidgets){ |
1782 |
< |
saveProjectWidget(rootNode, myTable); |
1783 |
< |
} |
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)){ |
1786 |
< |
UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "An error ocurred while trying to save the project file. Please try another path."); |
1787 |
< |
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; |
1793 |
< |
this->unsavedChangesExist = false; |
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(); |
1862 |
> |
projectTable.from = cbFrom->currentText(); |
1863 |
> |
projectTable.to = cbTo->currentText(); |
1864 |
|
|
1865 |
< |
showSuccessStatusMessage("Project saved sucessfully."); |
1800 |
< |
} |
1865 |
> |
for(int i=0; i<table->rowCount(); i++){ |
1866 |
|
|
1867 |
< |
void MainWindow::saveProjectWidget(pugi::xml_node &rootNode, DropTableWidget* table) |
1803 |
< |
{ |
1804 |
< |
QString from; |
1805 |
< |
QString to; |
1806 |
< |
QString tabName = getTabNameByTableWidget(table); |
1807 |
< |
|
1808 |
< |
pugi::xml_node currentNodeTable = rootNode.append_child("tempName"); |
1809 |
< |
pugi::xml_node options; |
1810 |
< |
|
1811 |
< |
if(table==ui->twSourcesXML){ //So we only need to parse one command. |
1812 |
< |
from = ui->cbFromXML->currentText().toUtf8().constData(); |
1813 |
< |
to = ui->cbToXML->currentText().toUtf8().constData(); |
1814 |
< |
} |
1815 |
< |
else if(table==ui->twSourcesTextures){ |
1816 |
< |
from = ui->cbFromTextures->currentText().toUtf8().constData(); |
1817 |
< |
to = ui->cbToTextures->currentText().toUtf8().constData(); |
1818 |
< |
options = currentNodeTable.append_child("Options"); |
1819 |
< |
options.append_attribute("type").set_value(Util::qStrToCstr(getTextureRBCheckedTypeTexture()->text())); |
1820 |
< |
options.append_attribute("genMipMaps").set_value(Util::boolToCstr(ui->cbMipMapsTextures->isChecked())); |
1821 |
< |
options.append_attribute("noUwrap").set_value(Util::boolToCstr(ui->cbNoUwrap->isChecked())); |
1822 |
< |
options.append_attribute("noVwrap").set_value(Util::boolToCstr(ui->cbNoVwrap->isChecked())); |
1823 |
< |
options.append_attribute("large").set_value(Util::boolToCstr(ui->cbLarge->isChecked())); |
1824 |
< |
options.append_attribute("envMap").set_value(Util::boolToCstr(ui->cbEnvMap->isChecked())); |
1825 |
< |
options.append_attribute("envMapValue").set_value(Util::qStrToCstr(ui->leEnvMapTexture->text())); |
1826 |
< |
} |
1827 |
< |
else if(table==ui->twSourcesCharacters){ |
1828 |
< |
from = ui->cbFromCharacters->currentText().toUtf8().constData(); |
1829 |
< |
to = ui->cbToCharacters->currentText().toUtf8().constData(); |
1830 |
< |
options = currentNodeTable.append_child("Options"); |
1831 |
< |
options.append_attribute("cellShading").set_value(Util::boolToCstr(ui->cbCellShading->isChecked())); |
1832 |
< |
options.append_attribute("normals").set_value(Util::boolToCstr(ui->cbNormals->isChecked())); |
1833 |
< |
options.append_attribute("extractTRBSONCC").set_value(Util::boolToCstr(ui->cbWithTRBS_ONCC->isChecked())); |
1834 |
< |
options.append_attribute("extractTRBSONCCValue").set_value(Util::qStrToCstr(ui->leTRBS_ONCC->text())); |
1835 |
< |
} |
1836 |
< |
else if(table==ui->twSourcesObjects){ |
1837 |
< |
from = ui->cbFromObjects->currentText().toUtf8().constData(); |
1838 |
< |
to = ui->cbToObjects->currentText().toUtf8().constData(); |
1839 |
< |
options = currentNodeTable.append_child("Options"); |
1840 |
< |
options.append_attribute("texture").set_value(Util::boolToCstr(ui->cbTexture->isChecked())); |
1841 |
< |
options.append_attribute("textureValue").set_value(Util::qStrToCstr(ui->leTextureName->text())); |
1842 |
< |
options.append_attribute("withAnimation").set_value(Util::boolToCstr(ui->cbWithAnimation->isChecked())); |
1843 |
< |
options.append_attribute("withAnimationValue").set_value(Util::qStrToCstr(ui->leAnimationName->text())); |
1844 |
< |
} |
1845 |
< |
else if(table==ui->twSourcesLevels){ |
1846 |
< |
from = ui->cbFromLevels->currentText().toUtf8().constData(); |
1847 |
< |
to = ui->cbToLevels->currentText().toUtf8().constData(); |
1848 |
< |
options = currentNodeTable.append_child("Options"); |
1849 |
< |
options.append_attribute("extractWithFiles").set_value(Util::boolToCstr(ui->cbSpecificFilesLevels->isChecked())); |
1850 |
< |
options.append_attribute("extractWithFilesValue").set_value(Util::qStrToCstr(ui->leSpecificFilesLevels->text())); |
1851 |
< |
options.append_attribute("datFilename").set_value(Util::boolToCstr(ui->cbDatLevels->isChecked())); |
1852 |
< |
options.append_attribute("datFilenameValue").set_value(Util::qStrToCstr(ui->leTargetDatLevels->text())); |
1853 |
< |
options.append_attribute("bnvSource").set_value(Util::boolToCstr(ui->cbBnvLevels->isChecked())); |
1854 |
< |
options.append_attribute("bnvSourceValue").set_value(Util::qStrToCstr(ui->leBnvLevels->text())); |
1855 |
< |
options.append_attribute("generateGrids").set_value(Util::boolToCstr(ui->cbGridsLevels->isChecked())); |
1856 |
< |
options.append_attribute("additionalSources").set_value(Util::boolToCstr(ui->cbAdditionalSourcesLevels->isChecked())); |
1857 |
< |
options.append_attribute("additionalSourcesValue").set_value(Util::qStrToCstr(ui->leAdditSourcesLevels->text())); |
1858 |
< |
} |
1859 |
< |
else{ |
1860 |
< |
from = ui->cbFromMisc->currentText().toUtf8().constData(); |
1861 |
< |
to = ui->cbToMisc->currentText().toUtf8().constData(); |
1862 |
< |
} |
1863 |
< |
|
1864 |
< |
currentNodeTable.set_name(tabName.toUtf8().constData()); |
1867 |
> |
ProjectFileVago::ProjectTableRow currentRow; |
1868 |
|
|
1869 |
< |
currentNodeTable.append_attribute("from").set_value(from.toUtf8().constData()); |
1870 |
< |
currentNodeTable.append_attribute("to").set_value(to.toUtf8().constData()); |
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 |
+ |
if(table->item(i,2)->background()==table->disabledBackStyle){ |
1874 |
+ |
currentRow.isDisabled = true; |
1875 |
+ |
} |
1876 |
|
|
1877 |
< |
for(int i=0; i<table->rowCount(); i++){ |
1878 |
< |
|
1879 |
< |
QString currFileFolder = table->item(i,0)->text(); |
1873 |
< |
QString currFromTo = table->item(i,1)->text(); |
1874 |
< |
QString currCommand = table->item(i,2)->text(); |
1875 |
< |
|
1876 |
< |
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); |
1885 |
< |
} |
1921 |
> |
// Misc tab |
1922 |
> |
fFetchTabGenericData(currentProjectData.miscTable, ui->cbFromMisc, ui->cbToMisc, ui->twSourcesMisc); |
1923 |
|
|
1924 |
< |
} |
1924 |
> |
return currentProjectData; |
1925 |
|
} |
1926 |
|
|
1927 |
|
QRadioButton* MainWindow::getTextureRBCheckedTypeTexture() |
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){ |
2056 |
|
void MainWindow::loadProjectState(const QString &filePath) |
2057 |
|
{ |
2058 |
|
|
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 ¤tRow : 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){ |
2083 |
|
} |
2084 |
|
} |
2085 |
|
|
2086 |
< |
QString statusError = "Couldn't load project."; |
2086 |
> |
try{ |
2087 |
> |
ProjectFileVago::ProjectData projectData = ProjectFileVago::readProjectDataFromFile(filePath); |
2088 |
|
|
2089 |
< |
pugi::xml_document doc; |
2089 |
> |
// XML tab |
2090 |
> |
fLoadTabGenericData(projectData.xmlTable, ui->twSourcesXML, ui->cbFromXML, ui->cbToXML); |
2091 |
|
|
2092 |
< |
pugi::xml_parse_result result = doc.load_file(Util::qStrToCstr(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 |
< |
if(result.status!=pugi::status_ok){ |
2039 |
< |
UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "An error ocurred while loading project file.\n" + QString(result.description())); |
2040 |
< |
showErrStatusMessage(statusError); |
2041 |
< |
this->projectIsLoading = false; |
2042 |
< |
return; |
2043 |
< |
} |
2135 |
> |
this->vagoSettings->setValue("LastProjectPath",QFileInfo(filePath).absoluteDir().path()); |
2136 |
|
|
2137 |
+ |
this->lastProjectFilePath = filePath; |
2138 |
+ |
this->unsavedChangesExist = false; |
2139 |
|
|
2140 |
< |
if(QString(doc.root().first_child().name()) != "VagoProject"){ |
2047 |
< |
UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, QString(doc.root().name()) + "The file opened is not a valid VagoProject file. Load aborted."); |
2048 |
< |
showErrStatusMessage(statusError); |
2049 |
< |
this->projectIsLoading = false; |
2050 |
< |
return; |
2051 |
< |
} |
2140 |
> |
addNewRecentProject(filePath); |
2141 |
|
|
2142 |
< |
QString projVagoVersion; |
2142 |
> |
setVagoWindowTitle(); |
2143 |
|
|
2055 |
– |
try{ |
2056 |
– |
projVagoVersion = QString(doc.select_node("/VagoProject/@vagoVersion").attribute().value()); |
2057 |
– |
} |
2058 |
– |
catch (const pugi::xpath_exception& e) |
2059 |
– |
{ |
2060 |
– |
UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "Couldn't find the vagoVersion of the current project. Load aborted.\n" + QString(e.what())); |
2061 |
– |
showErrStatusMessage(statusError); |
2144 |
|
this->projectIsLoading = false; |
2063 |
– |
return; |
2064 |
– |
} |
2145 |
|
|
2146 |
< |
if(!projVagoVersion.startsWith(GlobalVars::LastCompatibleVersion)){ |
2067 |
< |
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."); |
2068 |
< |
showErrStatusMessage(statusError); |
2069 |
< |
this->projectIsLoading = false; |
2070 |
< |
return; |
2071 |
< |
} |
2072 |
< |
|
2073 |
< |
// After the initial validations begin loading the project data |
2074 |
< |
|
2075 |
< |
QList<DropTableWidget*> tableWidgets = getAllTableWidgets(); |
2076 |
< |
|
2077 |
< |
try{ |
2078 |
< |
foreach(DropTableWidget* const &myTable, tableWidgets){ |
2079 |
< |
loadProjectWidget(doc, myTable); |
2080 |
< |
} |
2146 |
> |
Util::StatusBar::showSuccess(ui->statusBar, "Project loaded sucessfully."); |
2147 |
|
} |
2148 |
|
catch(const std::exception& e){ |
2083 |
– |
UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "Couldn't load the vago project. Error: " + QString(e.what())); |
2084 |
– |
showErrStatusMessage(statusError); |
2149 |
|
this->projectIsLoading = false; |
2150 |
< |
return; |
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 |
|
|
2089 |
– |
this->vagoSettings->setValue("LastProjectPath",QFileInfo(filePath).absoluteDir().path()); |
2090 |
– |
|
2091 |
– |
this->lastProjectFilePath = filePath; |
2092 |
– |
this->unsavedChangesExist = false; |
2093 |
– |
|
2094 |
– |
addNewRecentProject(filePath); |
2095 |
– |
|
2096 |
– |
setVagoWindowTitle(); |
2097 |
– |
|
2098 |
– |
this->projectIsLoading = false; |
2099 |
– |
|
2100 |
– |
showSuccessStatusMessage("Project loaded sucessfully."); |
2101 |
– |
} |
2102 |
– |
|
2103 |
– |
|
2104 |
– |
void MainWindow::loadProjectWidget(pugi::xml_document &doc, DropTableWidget* table) |
2105 |
– |
{ |
2106 |
– |
QString tabName = getTabNameByTableWidget(table); |
2107 |
– |
QString from (doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/@from")).attribute().value()); |
2108 |
– |
QString to (doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/@to")).attribute().value()); |
2109 |
– |
|
2110 |
– |
if(table==ui->twSourcesXML){ |
2111 |
– |
ui->cbFromXML->setCurrentText(from); |
2112 |
– |
on_cbFromXML_currentIndexChanged(from); |
2113 |
– |
ui->cbToXML->setCurrentText(to); |
2114 |
– |
} |
2115 |
– |
else if(table==ui->twSourcesTextures){ |
2116 |
– |
//ui->cbFromTextures->setCurrentText(from); |
2117 |
– |
on_cbFromTextures_currentIndexChanged(from); |
2118 |
– |
ui->cbToTextures->setCurrentText(to); |
2119 |
– |
|
2120 |
– |
getTextureRBTypeTextureByName((doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@type")).attribute().value()))->setChecked(true); |
2121 |
– |
ui->cbMipMapsTextures->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@genMipMaps")).attribute().as_bool()); |
2122 |
– |
ui->cbNoUwrap->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@noUwrap")).attribute().as_bool()); |
2123 |
– |
ui->cbNoVwrap->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@noVwrap")).attribute().as_bool()); |
2124 |
– |
ui->cbLarge->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@large")).attribute().as_bool()); |
2125 |
– |
ui->cbEnvMap->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@envMap")).attribute().as_bool()); |
2126 |
– |
ui->leEnvMapTexture->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@envMapValue")).attribute().value())); |
2127 |
– |
} |
2128 |
– |
else if(table==ui->twSourcesCharacters){ |
2129 |
– |
ui->cbFromCharacters->setCurrentText(from); |
2130 |
– |
on_cbFromCharacters_currentIndexChanged(from); |
2131 |
– |
ui->cbToCharacters->setCurrentText(to); |
2132 |
– |
|
2133 |
– |
|
2134 |
– |
ui->cbCellShading->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@cellShading")).attribute().as_bool()); |
2135 |
– |
ui->cbNormals->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@normals")).attribute().as_bool()); |
2136 |
– |
ui->cbWithTRBS_ONCC->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@extractTRBSONCC")).attribute().as_bool()); |
2137 |
– |
ui->leTRBS_ONCC->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@extractTRBSONCCValue")).attribute().value())); |
2138 |
– |
} |
2139 |
– |
else if(table==ui->twSourcesObjects){ |
2140 |
– |
ui->cbFromObjects->setCurrentText(from); |
2141 |
– |
on_cbFromObjects_currentIndexChanged(from); |
2142 |
– |
ui->cbToObjects->setCurrentText(to); |
2143 |
– |
|
2144 |
– |
ui->cbTexture->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@texture")).attribute().as_bool()); |
2145 |
– |
ui->leTextureName->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@textureValue")).attribute().value())); |
2146 |
– |
ui->cbWithAnimation->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@withAnimation")).attribute().as_bool()); |
2147 |
– |
ui->leAnimationName->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@withAnimationValue")).attribute().value())); |
2148 |
– |
} |
2149 |
– |
else if(table==ui->twSourcesLevels){ |
2150 |
– |
ui->cbFromLevels->setCurrentText(from); |
2151 |
– |
on_cbFromLevels_currentIndexChanged(from); |
2152 |
– |
ui->cbToLevels->setCurrentText(to); |
2153 |
– |
|
2154 |
– |
ui->cbSpecificFilesLevels->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@extractWithFiles")).attribute().as_bool()); |
2155 |
– |
ui->leSpecificFilesLevels->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@extractWithFilesValue")).attribute().value())); |
2156 |
– |
ui->cbDatLevels->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@datFilename")).attribute().as_bool()); |
2157 |
– |
ui->leTargetDatLevels->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@datFilenameValue")).attribute().value())); |
2158 |
– |
ui->cbBnvLevels->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@bnvSource")).attribute().as_bool()); |
2159 |
– |
ui->leBnvLevels->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@bnvSourceValue")).attribute().value())); |
2160 |
– |
ui->cbGridsLevels->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@generateGrids")).attribute().as_bool()); |
2161 |
– |
ui->cbAdditionalSourcesLevels->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@additionalSources")).attribute().as_bool()); |
2162 |
– |
ui->leAdditSourcesLevels->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@additionalSourcesValue")).attribute().value())); |
2163 |
– |
} |
2164 |
– |
else{ |
2165 |
– |
ui->cbFromMisc->setCurrentText(from); |
2166 |
– |
on_cbFromMisc_currentIndexChanged(from); |
2167 |
– |
ui->cbToMisc->setCurrentText(to); |
2168 |
– |
} |
2169 |
– |
|
2170 |
– |
// Clean previous rows |
2171 |
– |
clearTableNoPrompt(table); |
2172 |
– |
|
2173 |
– |
for(const pugi::xpath_node &xPathNode : doc.select_nodes(Util::qStrToCstr("/VagoProject/"+tabName+"/Row"))){ |
2174 |
– |
pugi::xml_node currNode = xPathNode.node(); |
2175 |
– |
|
2176 |
– |
QString currFileFolder = currNode.attribute("fileFolder").value(); |
2177 |
– |
QString currFromTo = currNode.attribute("fromTo").value(); |
2178 |
– |
QString currCommand = currNode.attribute("command").value(); |
2179 |
– |
|
2180 |
– |
bool isToDisable = false; |
2181 |
– |
pugi::xml_attribute disabledAttr = currNode.attribute("disabled"); |
2182 |
– |
isToDisable = disabledAttr.empty() ? false : disabledAttr.as_bool(); |
2183 |
– |
|
2184 |
– |
addRowTable(table,currFileFolder,currFromTo,currCommand, isToDisable); |
2185 |
– |
} |
2156 |
|
} |
2157 |
|
|
2158 |
|
void MainWindow::saveRecentProjects(){ |