| 9 |
|
{ |
| 10 |
|
ui->setupUi(this); |
| 11 |
|
|
| 12 |
< |
this->myLogger = new Logger(Util::getAppPath()); //start logger |
| 12 |
> |
this->myLogger = new Logger(UtilVago::getAppPath(), GlobalVars::AppLogName); //start logger |
| 13 |
|
|
| 14 |
< |
this->myLogger->writeString("Detected AppDir: "+Util::getAppPath()); |
| 14 |
> |
this->myLogger->writeString("Detected AppDir: "+UtilVago::getAppPath()); |
| 15 |
|
this->myLogger->writeString("True app dir: "+QDir::currentPath()); |
| 16 |
|
|
| 17 |
< |
this->setWindowTitle("Vago v"+GlobalVars::AppVersion); |
| 17 |
> |
setVagoWindowTitle(); |
| 18 |
|
|
| 19 |
< |
if(!QFile::exists(Util::getAppPath()+"/"+GlobalVars::OniSplitString)){ |
| 20 |
< |
Util::showErrorPopUp("OniSplit not found. Please download it at "+GlobalVars::ModsDomain+" and put it in the same folder of Vago. \n\nProgram will now exit."); |
| 19 |
> |
if(!QFile::exists(UtilVago::getOniSplitExecutableAbsolutePath())){ |
| 20 |
> |
UtilVago::showAndLogErrorPopUp(this->myLogger, "OniSplit not found. Please download it at "+GlobalVars::ModsDomain+" and put it the Vago's tools folder. \n\nProgram will now exit."); |
| 21 |
|
exit(1); |
| 22 |
|
} |
| 23 |
|
|
| 24 |
< |
if(!QFile::exists(Util::getAppPath()+"/"+GlobalVars::XmlToolsString)){ |
| 25 |
< |
Util::showErrorPopUp("xmlTools not found. Please download it at "+GlobalVars::ModsDomain+" and put it in the same folder of Vago. \n\nProgram will now exit."); |
| 24 |
> |
if(!QFile::exists(UtilVago::getXmlToolsExecutableAbsolutePath())){ |
| 25 |
> |
UtilVago::showAndLogErrorPopUp(this->myLogger, "XmlTools not found. Please download it at "+GlobalVars::ModsDomain+" and put it the Vago's tools folder. \n\nProgram will now exit."); |
| 26 |
|
exit(1); |
| 27 |
|
} |
| 28 |
|
|
| 29 |
< |
this->vagoSettings = new QSettings(Util::getAppPath() + "/" + this->VagoSettingsName, QSettings::IniFormat); |
| 29 |
> |
this->vagoSettings = new QSettings(UtilVago::getAppPath() + "/" + this->VagoSettingsName, QSettings::IniFormat); |
| 30 |
|
|
| 31 |
|
//First Execution? Old configuration? Settings missed? |
| 32 |
|
bool iniChanged=false; |
| 35 |
|
iniChanged=true; |
| 36 |
|
} |
| 37 |
|
if(!this->vagoSettings->contains("Workspace")){ |
| 38 |
< |
this->vagoSettings->setValue("Workspace", Util::getAppPath()+"/VagoWorkspace"); |
| 38 |
> |
this->vagoSettings->setValue("Workspace", UtilVago::getAppPath()+"/VagoWorkspace"); |
| 39 |
|
iniChanged=true; |
| 40 |
|
} |
| 41 |
|
if(!this->vagoSettings->contains("AeFolder")){ |
| 44 |
|
QString aefolder=Util::normalizePath(QFileDialog::getExistingDirectory(this,"Choose Anniversary Edition (AE) folder...")); |
| 45 |
|
|
| 46 |
|
if(aefolder.isEmpty()){ |
| 47 |
< |
Util::showErrorPopUp("AE folder is mandatory. Application will now exit."); |
| 47 |
> |
UtilVago::showAndLogErrorPopUp(this->myLogger, "AE folder is mandatory. Application will now exit."); |
| 48 |
|
exit(1); |
| 49 |
|
} |
| 50 |
|
|
| 71 |
|
this->vagoSettings->setValue("SeparateInWorkspace",true); |
| 72 |
|
iniChanged=true; |
| 73 |
|
} |
| 74 |
< |
if(!this->vagoSettings->contains("ConfirmExit")){ |
| 75 |
< |
this->vagoSettings->setValue("ConfirmExit", false); |
| 74 |
> |
if(!this->vagoSettings->contains("AskSaveProject")){ |
| 75 |
> |
this->vagoSettings->setValue("AskSaveProject", true); |
| 76 |
|
iniChanged=true; |
| 77 |
|
} |
| 78 |
+ |
if(!this->vagoSettings->contains("AskToOpenLastProject")){ |
| 79 |
+ |
this->vagoSettings->setValue("AskToOpenLastProject", false); |
| 80 |
+ |
iniChanged=true; |
| 81 |
+ |
} |
| 82 |
+ |
if(!this->vagoSettings->contains("LastProjectPath")){ |
| 83 |
+ |
this->vagoSettings->setValue("LastProjectPath", this->vagoSettings->value("Workspace")); |
| 84 |
+ |
iniChanged=true; |
| 85 |
+ |
} |
| 86 |
+ |
for(int i=0; i<this->recentProjectsMaxSize; i++){ |
| 87 |
+ |
if(!this->vagoSettings->contains("RecentProject" + QString::number(i+1))){ |
| 88 |
+ |
this->vagoSettings->setValue("RecentProject" + QString::number(i+1), ""); |
| 89 |
+ |
iniChanged=true; |
| 90 |
+ |
} |
| 91 |
+ |
} |
| 92 |
|
#ifdef Q_OS_MAC |
| 93 |
|
if(!this->vagoSettings->contains("useYesAsDefaultWhenRemovingItems")){ |
| 94 |
|
this->vagoSettings->setValue("useYesAsDefaultWhenRemovingItems", false); |
| 128 |
|
ui->statusBar->addPermanentWidget(this->myBar); //this adds automatically in right |
| 129 |
|
ui->statusBar->addPermanentWidget(ui->tbAbortConversion); |
| 130 |
|
|
| 117 |
– |
//Initialize list pointers |
| 118 |
– |
this->listToProccess = new QStringList; |
| 119 |
– |
|
| 120 |
– |
//Create a thread for do the conversion in background |
| 121 |
– |
this->myConverter = new Converter(Util::getAppPath(),this->myLogger,this->listToProccess); |
| 122 |
– |
|
| 131 |
|
// User interface |
| 132 |
|
ui->mainToolBar->addWidget(ui->tbAE); //add ae installer launch button |
| 133 |
|
ui->mainToolBar->addWidget(ui->emptySpacerLabel); //trick, we can't add directly a space so we add an empty |
| 135 |
|
ui->mainToolBar->addWidget(ui->emptySpacerLabel2); //same as before |
| 136 |
|
ui->mainToolBar->addWidget(ui->tbCommand); //add option to manual onisplit commands |
| 137 |
|
ui->mainToolBar->addWidget(ui->emptySpacerLabel3); //same as before |
| 138 |
+ |
ui->mainToolBar->addWidget(ui->tbXmlToolsInterface); //add option to manual onisplit commands |
| 139 |
+ |
ui->mainToolBar->addWidget(ui->emptySpacerLabel4); //same as before |
| 140 |
|
ui->mainToolBar->addWidget(ui->tbOpenFolder); //add option to open folder with files converted etc |
| 141 |
|
|
| 142 |
|
ui->mainToolBar->setLayoutDirection(Qt::RightToLeft); |
| 143 |
|
|
| 144 |
< |
setConverterButtonsSize(); |
| 144 |
> |
ui->pbConvert->setMinimumHeight(ui->pbConvert->sizeHint().height()*1.5); // This is OS indepented. It maintain size ratio over the Windows and Mac. |
| 145 |
> |
|
| 146 |
|
|
| 147 |
|
#ifdef Q_OS_MAC |
| 148 |
|
// setUnifiedTitleAndToolBarOnMac(true); // Qt suggests to use it on mac | http://www.slideshare.net/qtbynokia/how-to-make-your-qt-app-look-native // align on left doesn't work if active |
| 154 |
|
ui->actionMac_Windows_demo->setChecked(true); |
| 155 |
|
// resize(800,600); // Mac OS pcs should be able to render this resolution without any problem. It's also better |
| 156 |
|
//// because the components on mac use more space |
| 146 |
– |
#else |
| 147 |
– |
//resize(640,480); // windows stuff |
| 157 |
|
#endif |
| 158 |
|
|
| 159 |
|
resize(this->startedWindowWidth,this->startedWindowHeight); |
| 160 |
|
|
| 161 |
< |
connectSlots(); |
| 161 |
> |
#ifdef Q_OS_MAC |
| 162 |
> |
ui->pbConvert->setToolTip(ui->pbConvert->toolTip() + " (⌘ + Enter)"); |
| 163 |
> |
#else |
| 164 |
> |
ui->pbConvert->setToolTip(ui->pbConvert->toolTip() + " (Ctrl + Enter)"); |
| 165 |
> |
#endif |
| 166 |
|
|
| 167 |
|
//Commands Mapping |
| 168 |
|
this->commandMap = QHash<QString, QString>(); |
| 170 |
|
|
| 171 |
|
updateItemsLoaded(ui->twSourcesXML); |
| 172 |
|
|
| 173 |
< |
this->myLogger->writeString("Application started."); |
| 173 |
> |
loadRecentProjects(); |
| 174 |
|
} |
| 175 |
|
|
| 176 |
|
MainWindow::~MainWindow() |
| 179 |
|
this->myLogger->writeString("Application Exited."); |
| 180 |
|
} |
| 181 |
|
|
| 182 |
+ |
|
| 183 |
+ |
void MainWindow::showEvent(QShowEvent *e) |
| 184 |
+ |
{ |
| 185 |
+ |
// If we don't have a converter yet, application wasn't started. |
| 186 |
+ |
if(!this->applicationIsFullyLoaded) |
| 187 |
+ |
{ |
| 188 |
+ |
// Apparently Qt doesn't contains a slot to when the application was fully load (mainwindow). So we do our own implementation instead. |
| 189 |
+ |
connect(this, SIGNAL(signalAppIsLoaded()), this, SLOT(applicationWasLoaded()), Qt::ConnectionType::QueuedConnection); |
| 190 |
+ |
emit signalAppIsLoaded(); |
| 191 |
+ |
} |
| 192 |
+ |
|
| 193 |
+ |
e->accept(); |
| 194 |
+ |
} |
| 195 |
+ |
|
| 196 |
+ |
// Called only when the MainWindow was fully loaded and painted on the screen. This slot is only called once. |
| 197 |
+ |
void MainWindow::applicationWasLoaded(){ |
| 198 |
+ |
#ifdef Q_OS_WIN |
| 199 |
+ |
// QProgressBar only works after the windows was shown |
| 200 |
+ |
// http://stackoverflow.com/questions/24840941/qwintaskbarprogress-wont-show (Kervala answer) |
| 201 |
+ |
|
| 202 |
+ |
this->win7TaskBarButton = new QWinTaskbarButton(); |
| 203 |
+ |
|
| 204 |
+ |
this->win7TaskBarButton->setWindow(this->windowHandle()); |
| 205 |
+ |
|
| 206 |
+ |
this->win7TaskBarProgress = this->win7TaskBarButton->progress(); |
| 207 |
+ |
|
| 208 |
+ |
//Create a thread for do the conversion in background |
| 209 |
+ |
this->myConverter = new Converter(UtilVago::getAppPath(), this->myLogger, &this->listToProccess, this->win7TaskBarProgress); |
| 210 |
+ |
#else |
| 211 |
+ |
this->myConverter = new Converter(UtilVago::getAppPath(), this->myLogger, &this->listToProccess); |
| 212 |
+ |
#endif |
| 213 |
+ |
|
| 214 |
+ |
connectSlots(); |
| 215 |
+ |
|
| 216 |
+ |
this->myLogger->writeString("Application started."); |
| 217 |
+ |
|
| 218 |
+ |
this->applicationIsFullyLoaded = true; |
| 219 |
+ |
|
| 220 |
+ |
QString lastSavedProject = this->vagoSettings->value("RecentProject1").toString(); |
| 221 |
+ |
|
| 222 |
+ |
if(!lastSavedProject.isEmpty() && this->vagoSettings->value("AskToOpenLastProject").toBool()){ |
| 223 |
+ |
if(Util::showQuestionPopUp(this,"Do you want to load latest project?\n\nLatest project was '" + Util::cutNameWithoutBackSlash(lastSavedProject) + "'.")){ |
| 224 |
+ |
loadProjectState(lastSavedProject); |
| 225 |
+ |
} |
| 226 |
+ |
} |
| 227 |
+ |
} |
| 228 |
+ |
|
| 229 |
+ |
|
| 230 |
|
void MainWindow::on_actionExit_triggered() |
| 231 |
|
{ |
| 232 |
|
close(); |
| 247 |
|
|
| 248 |
|
void MainWindow::on_actionSound_Wizard_triggered() |
| 249 |
|
{ |
| 250 |
< |
SoundWizard myWizard (Util::getAppPath(), this->workspaceWizardsLocation, this->myLogger, &this->commandMap); |
| 250 |
> |
SoundWizard myWizard (UtilVago::getAppPath(), this->workspaceWizardsLocation, this->myLogger, &this->commandMap); |
| 251 |
> |
myWizard.exec(); |
| 252 |
> |
} |
| 253 |
> |
|
| 254 |
> |
void MainWindow::on_actionBackground_Image_Wizard_triggered() |
| 255 |
> |
{ |
| 256 |
> |
BGImageWizard myWizard (UtilVago::getAppPath(), this->workspaceWizardsLocation, this->vagoSettings, this->myLogger); |
| 257 |
|
myWizard.exec(); |
| 258 |
|
} |
| 259 |
|
|
| 291 |
|
QDesktopServices::openUrl(QUrl("file:///"+this->outputFolder)); |
| 292 |
|
} |
| 293 |
|
|
| 294 |
+ |
|
| 295 |
+ |
void MainWindow::on_tbXmlToolsInterface_clicked() |
| 296 |
+ |
{ |
| 297 |
+ |
//We pass no parent because we want to have an independent window for XmlToolsInterface, |
| 298 |
+ |
//so we can minimize it or maximize indepently from the MainWindow |
| 299 |
+ |
XmlToolsInterface *xmlToolsWindow = new XmlToolsInterface(this->myLogger); |
| 300 |
+ |
xmlToolsWindow->show(); //it destroys itself when finished. |
| 301 |
+ |
} |
| 302 |
+ |
|
| 303 |
|
void MainWindow::on_tbAbortConversion_clicked() |
| 304 |
|
{ |
| 305 |
|
if(Util::showQuestionPopUp(this,"Are you sure you want to abort the current conversion?")){ |
| 358 |
|
} |
| 359 |
|
} |
| 360 |
|
else{ |
| 361 |
< |
Util::showErrorPopUp("An error occurred checking last version:\n\n"+result->errorString()); |
| 361 |
> |
UtilVago::showAndLogErrorPopUp(this->myLogger, "An error occurred checking last version:\n\n"+result->errorString()); |
| 362 |
|
} |
| 363 |
|
result->deleteLater(); |
| 364 |
|
} |
| 472 |
|
addRowTable(myTable,lastFileName,fromTo,command); |
| 473 |
|
} |
| 474 |
|
updateItemsLoaded(myTable); |
| 475 |
+ |
rowsWereChangedInDropTableWidget(); |
| 476 |
|
} |
| 477 |
|
|
| 478 |
|
QString MainWindow::fileParsingXML(QString tabTitle, QString myOutputFolder, QString from, QString to , QString file){ |
| 512 |
|
command+=" "+this->commandMap.value(tabTitle+"->"+ui->cbLarge->text()); |
| 513 |
|
} |
| 514 |
|
|
| 515 |
< |
if(ui->rbBGR32->isChecked()){ |
| 439 |
< |
command+=" "+this->commandMap.value(tabTitle+"->"+ui->rbBGR32->text()); |
| 440 |
< |
} |
| 441 |
< |
else if(ui->rbBGRA32->isChecked()){ |
| 442 |
< |
command+=" "+this->commandMap.value(tabTitle+"->"+ui->rbBGRA32->text()); |
| 443 |
< |
} |
| 444 |
< |
else if(ui->rbBGR555->isChecked()){ |
| 445 |
< |
command+=" "+this->commandMap.value(tabTitle+"->"+ui->rbBGR555->text()); |
| 446 |
< |
} |
| 447 |
< |
else if(ui->rbBGRA5551->isChecked()){ |
| 448 |
< |
command+=" "+this->commandMap.value(tabTitle+"->"+ui->rbBGRA5551->text()); |
| 449 |
< |
} |
| 450 |
< |
else if(ui->rbBGRA444->isChecked()){ |
| 451 |
< |
command+=" "+this->commandMap.value(tabTitle+"->"+ui->rbBGRA444->text()); |
| 452 |
< |
} |
| 453 |
< |
else{ //dxt1 checked |
| 454 |
< |
command+=" "+this->commandMap.value(tabTitle+"->"+ui->rbDxt1->text()); |
| 455 |
< |
} |
| 515 |
> |
command+=" "+this->commandMap.value(tabTitle+"->"+getTextureRBCheckedTypeTexture()->text()); |
| 516 |
|
|
| 517 |
|
if(ui->cbEnvMap->isChecked()){ |
| 518 |
|
if(ui->leEnvMapTexture->text().isEmpty()){ |
| 694 |
|
return this->commandMap.value("misc->"+from+"->"+to)+" "+myOutputFolder+" "+file; |
| 695 |
|
} |
| 696 |
|
|
| 697 |
< |
void MainWindow::addRowTable(DropTableWidget *myTable, QString fileName, QString fromTo, QString command){ |
| 697 |
> |
void MainWindow::addRowTable(DropTableWidget *myTable, QString fileName, QString fromTo, QString command, bool isToDisabled){ |
| 698 |
|
//Get actual number rows |
| 699 |
|
int twSize=myTable->rowCount(); |
| 700 |
|
|
| 706 |
|
QTableWidgetItem *newConversion = new QTableWidgetItem(fromTo); |
| 707 |
|
QTableWidgetItem *newCommand = new QTableWidgetItem(command); |
| 708 |
|
|
| 709 |
+ |
if(isToDisabled){ |
| 710 |
+ |
myTable->setDisableStyleWidgetItem(newFile); |
| 711 |
+ |
myTable->setDisableStyleWidgetItem(newConversion); |
| 712 |
+ |
myTable->setDisableStyleWidgetItem(newCommand); |
| 713 |
+ |
} |
| 714 |
+ |
|
| 715 |
|
myTable->setItem(twSize,0,newFile); |
| 716 |
|
myTable->setItem(twSize,1,newConversion); |
| 717 |
|
myTable->setItem(twSize,2,newCommand); |
| 719 |
|
myTable->updateTableToolTips(twSize); //Update tool tips |
| 720 |
|
} |
| 721 |
|
|
| 722 |
< |
void MainWindow::on_pbConvertXML_clicked() |
| 722 |
> |
void MainWindow::on_pbConvert_clicked() |
| 723 |
|
{ |
| 724 |
< |
startConversion(ui->twSourcesXML); |
| 724 |
> |
startConversion(); |
| 725 |
|
} |
| 726 |
|
|
| 727 |
< |
void MainWindow::on_pbConvertTextures_clicked() |
| 662 |
< |
{ |
| 663 |
< |
startConversion(ui->twSourcesTextures); |
| 664 |
< |
} |
| 727 |
> |
void MainWindow::startConversion(){ |
| 728 |
|
|
| 729 |
< |
void MainWindow::on_pbConvertObjects_clicked() |
| 667 |
< |
{ |
| 668 |
< |
startConversion(ui->twSourcesObjects); |
| 669 |
< |
} |
| 670 |
< |
|
| 671 |
< |
void MainWindow::on_pbConvertCharacters_clicked() |
| 672 |
< |
{ |
| 673 |
< |
startConversion(ui->twSourcesCharacters); |
| 674 |
< |
} |
| 675 |
< |
|
| 676 |
< |
void MainWindow::on_pbConvertLevels_clicked() |
| 677 |
< |
{ |
| 678 |
< |
startConversion(ui->twSourcesLevels); |
| 679 |
< |
} |
| 680 |
< |
|
| 681 |
< |
void MainWindow::on_pbConvertMisc_clicked() |
| 682 |
< |
{ |
| 683 |
< |
startConversion(ui->twSourcesMisc); |
| 684 |
< |
} |
| 685 |
< |
|
| 686 |
< |
void MainWindow::startConversion(DropTableWidget *myTable){ |
| 729 |
> |
DropTableWidget* currTable = getCurrentTableWidget(); |
| 730 |
|
|
| 731 |
|
bool ready=false; |
| 732 |
< |
for(int i=0; i<myTable->rowCount(); i++){ //There are items to process? |
| 733 |
< |
if(myTable->item(i,2)->background()!=myTable->disabledBackStyle){ |
| 732 |
> |
for(int i=0; i<currTable->rowCount(); i++){ //There are items to process? |
| 733 |
> |
if(currTable->item(i,2)->background()!=currTable->disabledBackStyle){ |
| 734 |
|
ready=true; |
| 735 |
|
break; |
| 736 |
|
} |
| 746 |
|
return; |
| 747 |
|
} |
| 748 |
|
|
| 749 |
< |
for(int i=0; i<myTable->rowCount(); i++){ |
| 749 |
> |
for(int i=0; i<currTable->rowCount(); i++){ |
| 750 |
|
//Only process enabled items |
| 751 |
< |
if(myTable->item(i,2)->background()!=myTable->disabledBackStyle){ |
| 752 |
< |
this->listToProccess->append(myTable->item(i,2)->text()); |
| 751 |
> |
if(currTable->item(i,2)->background()!=currTable->disabledBackStyle){ |
| 752 |
> |
this->listToProccess.append(currTable->item(i,2)->text()); |
| 753 |
|
} |
| 754 |
|
} |
| 755 |
|
|
| 775 |
|
if(numErrors!=0){ |
| 776 |
|
QString sNumErrors=QString::number(numErrors); |
| 777 |
|
if(numErrors>1){ |
| 778 |
< |
Util::showErrorLogPopUp(result+"\n This is the last of "+sNumErrors+" Errors."); |
| 779 |
< |
showErrStatusMessage("Something gone wrong. Check log file ("+sNumErrors+" Errors)."); |
| 778 |
> |
UtilVago::showErrorPopUpLogButton(result+"\n This is the last of "+sNumErrors+" errors."); |
| 779 |
> |
showErrStatusMessage("Something gone wrong. Check log file ("+sNumErrors+" errors)."); |
| 780 |
|
} |
| 781 |
|
else{ |
| 782 |
< |
Util::showErrorLogPopUp(result); |
| 782 |
> |
UtilVago::showErrorPopUpLogButton(result); |
| 783 |
|
showErrStatusMessage("Something gone wrong. Check log file."); |
| 784 |
|
} |
| 742 |
– |
|
| 785 |
|
} |
| 786 |
|
else{ |
| 787 |
|
showSuccessStatusMessage("Everything went well!"); |
| 928 |
|
|
| 929 |
|
void MainWindow::on_cbFromTextures_currentIndexChanged(const QString &arg1) |
| 930 |
|
{ |
| 889 |
– |
//Options are only used for DAT/ONI -> Image |
| 890 |
– |
if(QString::compare(arg1,"DAT / ONI",Qt::CaseSensitive)==0){ //case sensitive is faster |
| 891 |
– |
ui->gbTextures->setEnabled(false); |
| 892 |
– |
} |
| 893 |
– |
else{ |
| 894 |
– |
ui->gbTextures->setEnabled(true); |
| 895 |
– |
} |
| 896 |
– |
|
| 931 |
|
updateComboBox(arg1, ui->cbToTextures); |
| 932 |
|
} |
| 933 |
|
|
| 934 |
|
void MainWindow::on_cbFromObjects_currentIndexChanged(const QString &arg1) |
| 935 |
|
{ |
| 902 |
– |
ui->cbTexture->setEnabled(false); |
| 903 |
– |
ui->cbTexture->setChecked(false); |
| 904 |
– |
ui->cbWithAnimation->setEnabled(false); |
| 905 |
– |
ui->cbWithAnimation->setChecked(false); |
| 906 |
– |
|
| 907 |
– |
if(QString::compare(arg1,"M3GM ONI",Qt::CaseSensitive)==0){ //case sensitive is faster |
| 908 |
– |
ui->cbWithAnimation->setEnabled(true); |
| 909 |
– |
} |
| 910 |
– |
else if(QString::compare(arg1,"OBJ",Qt::CaseSensitive)==0){ |
| 911 |
– |
ui->cbTexture->setEnabled(true); |
| 912 |
– |
} |
| 913 |
– |
|
| 936 |
|
updateComboBox(arg1, ui->cbToObjects); |
| 937 |
|
} |
| 938 |
|
|
| 939 |
|
void MainWindow::on_cbFromCharacters_currentIndexChanged(const QString &arg1) |
| 940 |
|
{ |
| 919 |
– |
ui->cbWithTRBS_ONCC->setEnabled(false); |
| 920 |
– |
ui->cbWithTRBS_ONCC->setChecked(false); |
| 921 |
– |
ui->cbCellShading->setEnabled(false); |
| 922 |
– |
ui->cbCellShading->setChecked(false); |
| 923 |
– |
ui->cbNormals->setEnabled(false); |
| 924 |
– |
ui->cbNormals->setChecked(false); |
| 925 |
– |
|
| 926 |
– |
if(QString::compare(arg1,"TRAM ONI",Qt::CaseSensitive)==0){ //case sensitive is faster |
| 927 |
– |
ui->cbWithTRBS_ONCC->setEnabled(true); |
| 928 |
– |
} |
| 929 |
– |
else if(QString::compare(arg1,"TRBS DAE",Qt::CaseSensitive)==0){ |
| 930 |
– |
ui->cbNormals->setEnabled(true); |
| 931 |
– |
ui->cbCellShading->setEnabled(true); |
| 932 |
– |
} |
| 933 |
– |
|
| 941 |
|
updateComboBox(arg1, ui->cbToCharacters); |
| 942 |
|
} |
| 943 |
|
|
| 944 |
|
void MainWindow::on_cbFromLevels_currentIndexChanged(const QString &arg1) |
| 945 |
|
{ |
| 939 |
– |
|
| 940 |
– |
ui->cbSpecificFilesLevels->setEnabled(false); |
| 941 |
– |
ui->cbSpecificFilesLevels->setChecked(false); |
| 942 |
– |
ui->cbDatLevels->setEnabled(false); |
| 943 |
– |
ui->cbDatLevels->setChecked(false); |
| 944 |
– |
ui->cbBnvLevels->setEnabled(false); |
| 945 |
– |
ui->cbBnvLevels->setChecked(false); |
| 946 |
– |
ui->cbAdditionalSourcesLevels->setEnabled(false); |
| 947 |
– |
ui->cbAdditionalSourcesLevels->setChecked(false); |
| 948 |
– |
ui->cbGridsLevels->setEnabled(false); |
| 949 |
– |
ui->cbGridsLevels->setChecked(false); |
| 950 |
– |
|
| 951 |
– |
if(arg1=="DAT"){ //case sensitive is faster |
| 952 |
– |
ui->cbSpecificFilesLevels->setEnabled(true); |
| 953 |
– |
} |
| 954 |
– |
else if(arg1=="ONI FILES"){ //case sensitive is faster |
| 955 |
– |
ui->cbDatLevels->setEnabled(true); |
| 956 |
– |
} |
| 957 |
– |
else if(arg1=="DAE"){ |
| 958 |
– |
ui->cbBnvLevels->setEnabled(true); |
| 959 |
– |
ui->cbAdditionalSourcesLevels->setEnabled(true); |
| 960 |
– |
} |
| 961 |
– |
|
| 946 |
|
updateComboBox(arg1, ui->cbToLevels); |
| 947 |
|
} |
| 948 |
|
|
| 952 |
|
} |
| 953 |
|
|
| 954 |
|
void MainWindow::updateComboBox(const QString &arg1, QComboBox *comboBox){ |
| 955 |
< |
QString identifier=ui->tabWidget->tabText(ui->tabWidget->currentIndex()).toLower(); // get current tab title text (lower case) |
| 955 |
> |
|
| 956 |
> |
QString identifier; |
| 957 |
> |
|
| 958 |
> |
if(comboBox == ui->cbToXML){ |
| 959 |
> |
identifier = ui->tabWidget->tabText(XMLTabIndex); |
| 960 |
> |
} |
| 961 |
> |
else if(comboBox == ui->cbToTextures){ |
| 962 |
> |
identifier = ui->tabWidget->tabText(TexturesTabIndex); |
| 963 |
> |
|
| 964 |
> |
//Options are only used for DAT/ONI -> Image |
| 965 |
> |
if(QString::compare(arg1,"DAT / ONI",Qt::CaseSensitive)==0){ //case sensitive is faster |
| 966 |
> |
ui->gbTextures->setEnabled(false); |
| 967 |
> |
} |
| 968 |
> |
else{ |
| 969 |
> |
ui->gbTextures->setEnabled(true); |
| 970 |
> |
} |
| 971 |
> |
} |
| 972 |
> |
else if(comboBox == ui->cbToCharacters){ |
| 973 |
> |
identifier = ui->tabWidget->tabText(CharactersTabIndex); |
| 974 |
> |
|
| 975 |
> |
ui->cbWithTRBS_ONCC->setEnabled(false); |
| 976 |
> |
ui->cbWithTRBS_ONCC->setChecked(false); |
| 977 |
> |
ui->cbCellShading->setEnabled(false); |
| 978 |
> |
ui->cbCellShading->setChecked(false); |
| 979 |
> |
ui->cbNormals->setEnabled(false); |
| 980 |
> |
ui->cbNormals->setChecked(false); |
| 981 |
> |
|
| 982 |
> |
if(QString::compare(arg1,"TRAM ONI",Qt::CaseSensitive)==0){ //case sensitive is faster |
| 983 |
> |
ui->cbWithTRBS_ONCC->setEnabled(true); |
| 984 |
> |
} |
| 985 |
> |
else if(QString::compare(arg1,"TRBS DAE",Qt::CaseSensitive)==0){ |
| 986 |
> |
ui->cbNormals->setEnabled(true); |
| 987 |
> |
ui->cbCellShading->setEnabled(true); |
| 988 |
> |
} |
| 989 |
> |
|
| 990 |
> |
} |
| 991 |
> |
else if(comboBox == ui->cbToObjects){ |
| 992 |
> |
identifier = ui->tabWidget->tabText(ObjectsTabIndex); |
| 993 |
> |
|
| 994 |
> |
ui->cbTexture->setEnabled(false); |
| 995 |
> |
ui->cbTexture->setChecked(false); |
| 996 |
> |
ui->cbWithAnimation->setEnabled(false); |
| 997 |
> |
ui->cbWithAnimation->setChecked(false); |
| 998 |
> |
|
| 999 |
> |
if(QString::compare(arg1,"M3GM ONI",Qt::CaseSensitive)==0){ //case sensitive is faster |
| 1000 |
> |
ui->cbWithAnimation->setEnabled(true); |
| 1001 |
> |
} |
| 1002 |
> |
else if(QString::compare(arg1,"OBJ",Qt::CaseSensitive)==0){ |
| 1003 |
> |
ui->cbTexture->setEnabled(true); |
| 1004 |
> |
} |
| 1005 |
> |
} |
| 1006 |
> |
else if(comboBox == ui->cbToLevels){ |
| 1007 |
> |
identifier = ui->tabWidget->tabText(LevelsTabIndex); |
| 1008 |
> |
|
| 1009 |
> |
ui->cbSpecificFilesLevels->setEnabled(false); |
| 1010 |
> |
ui->cbSpecificFilesLevels->setChecked(false); |
| 1011 |
> |
ui->cbDatLevels->setEnabled(false); |
| 1012 |
> |
ui->cbDatLevels->setChecked(false); |
| 1013 |
> |
ui->cbBnvLevels->setEnabled(false); |
| 1014 |
> |
ui->cbBnvLevels->setChecked(false); |
| 1015 |
> |
ui->cbAdditionalSourcesLevels->setEnabled(false); |
| 1016 |
> |
ui->cbAdditionalSourcesLevels->setChecked(false); |
| 1017 |
> |
ui->cbGridsLevels->setEnabled(false); |
| 1018 |
> |
ui->cbGridsLevels->setChecked(false); |
| 1019 |
> |
|
| 1020 |
> |
if(arg1=="DAT"){ //case sensitive is faster |
| 1021 |
> |
ui->cbSpecificFilesLevels->setEnabled(true); |
| 1022 |
> |
} |
| 1023 |
> |
else if(arg1=="ONI FILES"){ //case sensitive is faster |
| 1024 |
> |
ui->cbDatLevels->setEnabled(true); |
| 1025 |
> |
} |
| 1026 |
> |
else if(arg1=="DAE"){ |
| 1027 |
> |
ui->cbBnvLevels->setEnabled(true); |
| 1028 |
> |
ui->cbAdditionalSourcesLevels->setEnabled(true); |
| 1029 |
> |
} |
| 1030 |
> |
} |
| 1031 |
> |
else{ // Misc |
| 1032 |
> |
identifier = ui->tabWidget->tabText(MiscTabIndex); |
| 1033 |
> |
} |
| 1034 |
> |
|
| 1035 |
> |
identifier = identifier.toLower(); // get current tab title text (lower case) |
| 1036 |
|
|
| 1037 |
|
comboBox->clear(); |
| 1038 |
|
|
| 1146 |
|
myTable->removeRow(myTable->selectionModel()->selectedRows().at(size-i-1).row()); |
| 1147 |
|
} |
| 1148 |
|
updateItemsLoaded(myTable); |
| 1149 |
+ |
rowsWereChangedInDropTableWidget(); |
| 1150 |
|
} |
| 1151 |
|
} |
| 1152 |
|
|
| 1169 |
|
#endif |
| 1170 |
|
|
| 1171 |
|
if(Util::showQuestionPopUp(this,"Are you sure you want to clear the content?",defaultButton)){ |
| 1172 |
< |
myTable->clearContents(); |
| 1173 |
< |
myTable->setRowCount(0); |
| 1172 |
> |
clearTableNoPrompt(myTable); |
| 1173 |
> |
updateItemsLoaded(myTable); |
| 1174 |
> |
rowsWereChangedInDropTableWidget(); |
| 1175 |
|
} |
| 1176 |
< |
updateItemsLoaded(myTable); |
| 1176 |
> |
|
| 1177 |
|
} |
| 1178 |
|
|
| 1179 |
+ |
void MainWindow::clearTableNoPrompt(DropTableWidget *myTable){ |
| 1180 |
+ |
myTable->clearContents(); |
| 1181 |
+ |
myTable->setRowCount(0); |
| 1182 |
+ |
} |
| 1183 |
|
|
| 1184 |
|
void MainWindow::on_actionPreferences_triggered() |
| 1185 |
|
{ |
| 1190 |
|
|
| 1191 |
|
|
| 1192 |
|
void MainWindow::closeEvent(QCloseEvent *event){ |
| 1193 |
< |
if(this->vagoSettings->value("ConfirmExit").toBool()){ |
| 1194 |
< |
if(!Util::showQuestionPopUp(this,"Exit Vago?")){ |
| 1193 |
> |
if(this->vagoSettings->value("AskSaveProject").toBool() && this->unsavedChangesExist){ |
| 1194 |
> |
QMessageBox::StandardButton result = askToSaveCurrentProject(); |
| 1195 |
> |
if(result == QMessageBox::StandardButton::Cancel){ |
| 1196 |
|
event->ignore(); |
| 1197 |
+ |
return; |
| 1198 |
|
} |
| 1199 |
|
} |
| 1200 |
+ |
|
| 1201 |
+ |
// Exit application (this will also close all other windows which don't have parent, for instance ManualCommands) |
| 1202 |
+ |
QApplication::quit(); |
| 1203 |
+ |
} |
| 1204 |
+ |
|
| 1205 |
+ |
QMessageBox::StandardButton MainWindow::askToSaveCurrentProject(){ |
| 1206 |
+ |
QMessageBox::StandardButton result = |
| 1207 |
+ |
Util::showQuestionPopUpWithCancel(this,"There are unsaved changes. Do you want to save the current project?", QMessageBox::StandardButton::Yes); |
| 1208 |
+ |
|
| 1209 |
+ |
if(result == QMessageBox::StandardButton::Yes){ |
| 1210 |
+ |
on_actionSave_triggered(); |
| 1211 |
+ |
} |
| 1212 |
+ |
|
| 1213 |
+ |
return result; |
| 1214 |
|
} |
| 1215 |
|
|
| 1216 |
|
void MainWindow::on_cbToLevels_currentIndexChanged(const QString &arg1) |
| 1236 |
|
ui->leBnvLevels->setEnabled(checked); |
| 1237 |
|
ui->cbGridsLevels->setEnabled(checked); |
| 1238 |
|
ui->cbGridsLevels->setChecked(checked); |
| 1239 |
< |
if(checked){ |
| 1239 |
> |
if(checked && !projectIsLoading){ |
| 1240 |
|
QString file=QFileDialog::getOpenFileName(this,"Choose the BNV.dae file...","./" , "All Files (*.*)"); |
| 1241 |
|
if(!file.isEmpty()){ |
| 1242 |
|
ui->leBnvLevels->setText(file); |
| 1248 |
|
{ |
| 1249 |
|
ui->leAdditSourcesLevels->setEnabled(checked); |
| 1250 |
|
|
| 1251 |
< |
if(checked){ |
| 1251 |
> |
if(checked && !projectIsLoading){ |
| 1252 |
|
QStringList filesSelected=QFileDialog::getOpenFileNames(this,"Choose the additional .dae files...","./" , "All Files (*.*)"); |
| 1253 |
|
QString filesJoined; |
| 1254 |
|
int size=filesSelected.size(); |
| 1271 |
|
|
| 1272 |
|
void MainWindow::on_actionCheck_OniSplit_version_triggered() |
| 1273 |
|
{ |
| 1274 |
< |
QProcess *myProcess = new QProcess(); |
| 1275 |
< |
myProcess->setWorkingDirectory(Util::getAppPath()); |
| 1276 |
< |
myProcess->start(Util::getOniSplitExeName()+" -version"); |
| 1277 |
< |
myProcess->waitForFinished(-1); |
| 1278 |
< |
QString result=myProcess->readAllStandardOutput(); |
| 1279 |
< |
delete myProcess; |
| 1280 |
< |
Util::showPopUp("This Vago version was built with base in OniSplit version "+GlobalVars::BuiltOniSplitVersion+"\n\nActual version is:\n"+result); |
| 1274 |
> |
QProcess myProcess; |
| 1275 |
> |
myProcess.setWorkingDirectory(UtilVago::getAppPath()); |
| 1276 |
> |
myProcess.start(UtilVago::getOniSplitExecutable()+" -version"); |
| 1277 |
> |
myProcess.waitForFinished(); |
| 1278 |
> |
|
| 1279 |
> |
QString result=myProcess.readAllStandardOutput(); |
| 1280 |
> |
|
| 1281 |
> |
Util::showPopUp("This Vago version was built with base in OniSplit version "+GlobalVars::BuiltOniSplitVersion+"\n\nCurrent version is:\n"+result.trimmed()); |
| 1282 |
|
} |
| 1283 |
|
|
| 1284 |
|
void MainWindow::on_actionCheck_xmlTools_version_triggered() |
| 1285 |
|
{ |
| 1286 |
< |
QProcess *myProcess = new QProcess(); |
| 1287 |
< |
myProcess->setWorkingDirectory(Util::getAppPath()); |
| 1288 |
< |
myProcess->start(Util::getXmlToolsExeName()+" version"); |
| 1289 |
< |
myProcess->waitForFinished(-1); |
| 1290 |
< |
QString result=myProcess->readLine(); |
| 1291 |
< |
delete myProcess; |
| 1292 |
< |
Util::showPopUp("This Vago version was built with base in xmlTools version "+GlobalVars::BuiltXmlToolsVersion+"\n\nActual version is:\n"+result); |
| 1286 |
> |
QProcess myProcess; |
| 1287 |
> |
myProcess.setWorkingDirectory(UtilVago::getAppPath()); |
| 1288 |
> |
myProcess.start(UtilVago::getXmlToolsExecutable()+" --version"); |
| 1289 |
> |
myProcess.waitForFinished(); |
| 1290 |
> |
QString result=myProcess.readLine(); |
| 1291 |
> |
|
| 1292 |
> |
Util::showPopUp("This Vago version was built with base in XmlTools version "+GlobalVars::BuiltXmlToolsVersion+"\n\nCurrent version is:\n"+result.trimmed()); |
| 1293 |
|
} |
| 1294 |
|
|
| 1295 |
|
/** |
| 1296 |
|
Update items loaded |
| 1297 |
|
**/ |
| 1298 |
< |
void MainWindow::on_tabWidget_currentChanged(int index) |
| 1298 |
> |
void MainWindow::on_tabWidget_currentChanged(int) |
| 1299 |
|
{ |
| 1300 |
< |
QString tabtext = ui->tabWidget->tabText(index); |
| 1214 |
< |
|
| 1215 |
< |
if(tabtext.compare("XML",Qt::CaseSensitive)==0){ //case sentive is faster |
| 1216 |
< |
updateItemsLoaded(ui->twSourcesXML); |
| 1217 |
< |
} |
| 1218 |
< |
else if(tabtext.compare("Textures",Qt::CaseSensitive)==0){ |
| 1219 |
< |
updateItemsLoaded(ui->twSourcesTextures); |
| 1220 |
< |
} |
| 1221 |
< |
else if(tabtext.compare("Characters",Qt::CaseSensitive)==0){ |
| 1222 |
< |
updateItemsLoaded(ui->twSourcesCharacters); |
| 1223 |
< |
} |
| 1224 |
< |
else if(tabtext.compare("Objects",Qt::CaseSensitive)==0){ |
| 1225 |
< |
updateItemsLoaded(ui->twSourcesObjects); |
| 1226 |
< |
} |
| 1227 |
< |
else if(tabtext.compare("Levels",Qt::CaseSensitive)==0){ |
| 1228 |
< |
updateItemsLoaded(ui->twSourcesLevels); |
| 1229 |
< |
} |
| 1230 |
< |
else{ |
| 1231 |
< |
updateItemsLoaded(ui->twSourcesMisc); |
| 1232 |
< |
} |
| 1300 |
> |
updateItemsLoaded(getCurrentTableWidget()); |
| 1301 |
|
} |
| 1302 |
|
|
| 1303 |
|
void MainWindow::updateItemsLoaded(DropTableWidget *currentTable){ |
| 1307 |
|
this->itemsLoaded->setText(QString().setNum(numItems)+ (numItems==1?" item ":" items ") +"loaded"); |
| 1308 |
|
} |
| 1309 |
|
|
| 1310 |
+ |
void MainWindow::rowsWereChangedInDropTableWidget(){ |
| 1311 |
+ |
// We have changed rows, we have now unsaved changes. |
| 1312 |
+ |
if(!this->unsavedChangesExist){ |
| 1313 |
+ |
this->unsavedChangesExist = true; |
| 1314 |
+ |
setVagoWindowTitle(); |
| 1315 |
+ |
} |
| 1316 |
+ |
} |
| 1317 |
+ |
|
| 1318 |
|
void MainWindow::on_tbCommand_clicked() |
| 1319 |
|
{ |
| 1320 |
< |
//Show preferences |
| 1321 |
< |
ManualCommands *commandsWindow = new ManualCommands(this); |
| 1320 |
> |
//We pass no parent because we want to have an independent window for ManualCommands, |
| 1321 |
> |
//so we can minimize it or maximize indepently from the MainWindow |
| 1322 |
> |
ManualCommands *commandsWindow = new ManualCommands(); |
| 1323 |
|
commandsWindow->show(); //it destroys itself when finished. |
| 1324 |
|
} |
| 1325 |
|
|
| 1359 |
|
|
| 1360 |
|
void MainWindow::on_actionView_log_triggered() |
| 1361 |
|
{ |
| 1362 |
< |
Util::openLogFile(); |
| 1362 |
> |
UtilVago::openLogFile(); |
| 1363 |
|
} |
| 1364 |
|
|
| 1365 |
|
void MainWindow::on_actionOpen_AE_folder_triggered() |
| 1367 |
|
QDesktopServices::openUrl(QUrl("file:///"+this->AeLocation)); |
| 1368 |
|
} |
| 1369 |
|
|
| 1370 |
+ |
void MainWindow::on_actionSave_Project_triggered() |
| 1371 |
+ |
{ |
| 1372 |
+ |
|
| 1373 |
+ |
QString filePath = QFileDialog::getSaveFileName(this, tr("Save File"), |
| 1374 |
+ |
this->vagoSettings->value("LastProjectPath").toString(), |
| 1375 |
+ |
tr("Vago project files (*.vgp)")); |
| 1376 |
+ |
|
| 1377 |
+ |
if(!filePath.isEmpty()){ |
| 1378 |
+ |
saveProjectState(filePath); |
| 1379 |
+ |
} |
| 1380 |
+ |
|
| 1381 |
+ |
} |
| 1382 |
+ |
|
| 1383 |
+ |
// New Project |
| 1384 |
+ |
void MainWindow::on_actionNew_Project_triggered() |
| 1385 |
+ |
{ |
| 1386 |
+ |
if(this->vagoSettings->value("AskSaveProject").toBool() && this->unsavedChangesExist){ |
| 1387 |
+ |
QMessageBox::StandardButton result = askToSaveCurrentProject(); |
| 1388 |
+ |
if(result == QMessageBox::StandardButton::Cancel){ |
| 1389 |
+ |
return; |
| 1390 |
+ |
} |
| 1391 |
+ |
} |
| 1392 |
+ |
|
| 1393 |
+ |
QList<DropTableWidget*> myTables = getAllTableWidgets(); |
| 1394 |
+ |
|
| 1395 |
+ |
for(DropTableWidget* const currTable : myTables){ |
| 1396 |
+ |
clearTableNoPrompt(currTable); |
| 1397 |
+ |
} |
| 1398 |
+ |
|
| 1399 |
+ |
this->lastProjectFilePath=""; // clear last project file path |
| 1400 |
+ |
this->unsavedChangesExist = false; |
| 1401 |
+ |
|
| 1402 |
+ |
setVagoWindowTitle(); // update vago title |
| 1403 |
+ |
} |
| 1404 |
+ |
|
| 1405 |
+ |
void MainWindow::on_actionSave_triggered() |
| 1406 |
+ |
{ |
| 1407 |
+ |
if(this->lastProjectFilePath.isEmpty()){ |
| 1408 |
+ |
on_actionSave_Project_triggered(); |
| 1409 |
+ |
return; |
| 1410 |
+ |
} |
| 1411 |
+ |
|
| 1412 |
+ |
saveProjectState(this->lastProjectFilePath); |
| 1413 |
+ |
} |
| 1414 |
+ |
|
| 1415 |
+ |
void MainWindow::on_actionLoad_Project_triggered() |
| 1416 |
+ |
{ |
| 1417 |
+ |
|
| 1418 |
+ |
QString filePath = QFileDialog::getOpenFileName(this, tr("Load File"), |
| 1419 |
+ |
this->vagoSettings->value("LastProjectPath").toString(), |
| 1420 |
+ |
tr("Vago project files (*.vgp)")); |
| 1421 |
+ |
if(!filePath.isEmpty()){ |
| 1422 |
+ |
loadProjectState(filePath); |
| 1423 |
+ |
} |
| 1424 |
+ |
} |
| 1425 |
+ |
|
| 1426 |
+ |
void MainWindow::on_actionProject1_triggered() |
| 1427 |
+ |
{ |
| 1428 |
+ |
loadProjectState(this->ui->actionProject1->text()); |
| 1429 |
+ |
} |
| 1430 |
+ |
|
| 1431 |
+ |
void MainWindow::on_actionProject2_triggered() |
| 1432 |
+ |
{ |
| 1433 |
+ |
loadProjectState(this->ui->actionProject2->text()); |
| 1434 |
+ |
} |
| 1435 |
+ |
|
| 1436 |
+ |
void MainWindow::on_actionProject3_triggered() |
| 1437 |
+ |
{ |
| 1438 |
+ |
loadProjectState(this->ui->actionProject3->text()); |
| 1439 |
+ |
} |
| 1440 |
+ |
|
| 1441 |
+ |
void MainWindow::on_actionProject4_triggered() |
| 1442 |
+ |
{ |
| 1443 |
+ |
loadProjectState(this->ui->actionProject4->text()); |
| 1444 |
+ |
} |
| 1445 |
+ |
|
| 1446 |
+ |
void MainWindow::on_actionProject5_triggered() |
| 1447 |
+ |
{ |
| 1448 |
+ |
loadProjectState(this->ui->actionProject5->text()); |
| 1449 |
+ |
} |
| 1450 |
+ |
|
| 1451 |
|
QString MainWindow::getTypeConversion(DropTableWidget *myTable){ |
| 1452 |
|
QString from,to; |
| 1453 |
|
|
| 1497 |
|
selectedRows << rowItem.row(); |
| 1498 |
|
} |
| 1499 |
|
|
| 1500 |
< |
QMenu *menu = new QMenu(); |
| 1501 |
< |
QAction *copy = new QAction("Copy",myTable); |
| 1502 |
< |
QAction *moveUp = new QAction("Move Up",myTable); |
| 1503 |
< |
QAction *moveDown = new QAction("Move Down",myTable); |
| 1504 |
< |
QAction *changeOptions = new QAction("Change To Current Options",myTable); |
| 1505 |
< |
QMenu *changeOutput = new QMenu("Change Output for:"); |
| 1506 |
< |
QAction *outWorkspace = new QAction("Workspace",myTable); |
| 1507 |
< |
QAction *outCurrOutput = new QAction("Current Output Folder",myTable); |
| 1508 |
< |
QAction *outOther = new QAction("Other...",myTable); |
| 1509 |
< |
QAction *edisable = new QAction("Enable/Disable",myTable); |
| 1500 |
> |
std::unique_ptr<QMenu> menu = std::make_unique<QMenu>(); |
| 1501 |
> |
std::unique_ptr<QAction> copy = std::make_unique<QAction>("Copy",myTable); |
| 1502 |
> |
std::unique_ptr<QAction> moveUp = std::make_unique<QAction>("Move Up",myTable); |
| 1503 |
> |
std::unique_ptr<QAction> moveDown = std::make_unique<QAction>("Move Down",myTable); |
| 1504 |
> |
std::unique_ptr<QAction> changeOptions = std::make_unique<QAction>("Change To Current Options",myTable); |
| 1505 |
> |
std::unique_ptr<QMenu> changeOutput = std::make_unique<QMenu>("Change Output for:"); |
| 1506 |
> |
std::unique_ptr<QAction> outWorkspace = std::make_unique<QAction>("Workspace",myTable); |
| 1507 |
> |
std::unique_ptr<QAction> outCurrOutput = std::make_unique<QAction>("Current Output Folder",myTable); |
| 1508 |
> |
std::unique_ptr<QAction> outOther = std::make_unique<QAction>("Other...",myTable); |
| 1509 |
> |
std::unique_ptr<QAction> edisable = std::make_unique<QAction>("Enable/Disable",myTable); |
| 1510 |
|
|
| 1511 |
< |
menu->addAction(copy); |
| 1511 |
> |
menu->addAction(copy.get()); |
| 1512 |
|
menu->addSeparator(); |
| 1513 |
< |
menu->addAction(moveUp); |
| 1514 |
< |
menu->addAction(moveDown); |
| 1513 |
> |
menu->addAction(moveUp.get()); |
| 1514 |
> |
menu->addAction(moveDown.get()); |
| 1515 |
|
menu->addSeparator(); |
| 1516 |
< |
menu->addAction(changeOptions); |
| 1517 |
< |
menu->addMenu(changeOutput); |
| 1518 |
< |
changeOutput->addActions(QList<QAction*>() << outWorkspace << outCurrOutput << outOther); |
| 1519 |
< |
menu->addAction(edisable); |
| 1516 |
> |
menu->addAction(changeOptions.get()); |
| 1517 |
> |
menu->addMenu(changeOutput.get()); |
| 1518 |
> |
changeOutput->addActions(QList<QAction*>() << outWorkspace.get() << outCurrOutput.get() << outOther.get()); |
| 1519 |
> |
menu->addAction(edisable.get()); |
| 1520 |
|
|
| 1521 |
|
|
| 1522 |
|
//if it's in the first row it can't be setted up |
| 1540 |
|
|
| 1541 |
|
QAction* selectedOption = menu->exec(event->globalPos()); |
| 1542 |
|
|
| 1543 |
< |
if(selectedOption==copy){ |
| 1543 |
> |
if(selectedOption==copy.get()){ |
| 1544 |
|
//Let's copy the contents to the clipboard |
| 1545 |
|
|
| 1546 |
|
QString toCopy; |
| 1563 |
|
QApplication::clipboard()->setText(toCopy); |
| 1564 |
|
showSuccessStatusMessage(QString::number(size) + (size==1?" item ":" items ")+ "copied to the clipboard"); |
| 1565 |
|
} |
| 1566 |
< |
else if(selectedOption==moveUp){ |
| 1566 |
> |
else if(selectedOption==moveUp.get()){ |
| 1567 |
|
qSort(selectedRows); //let's order the selections by the row number, so we know exactly how to swap it |
| 1568 |
|
myTable->swapPositions(selectedRows,-1); |
| 1569 |
+ |
rowsWereChangedInDropTableWidget(); |
| 1570 |
|
} |
| 1571 |
< |
else if(selectedOption==moveDown){ |
| 1571 |
> |
else if(selectedOption==moveDown.get()){ |
| 1572 |
|
qSort(selectedRows); |
| 1573 |
|
myTable->swapPositions(selectedRows,+1); |
| 1574 |
+ |
rowsWereChangedInDropTableWidget(); |
| 1575 |
|
} |
| 1576 |
< |
else if(selectedOption==changeOptions){ |
| 1576 |
> |
else if(selectedOption==changeOptions.get()){ |
| 1577 |
|
changeToCurrentSettings(selectedRows,myTable); |
| 1578 |
|
} |
| 1579 |
< |
else if(selectedOption==outWorkspace){ |
| 1579 |
> |
else if(selectedOption==outWorkspace.get()){ |
| 1580 |
|
changeItemsOutput(myTable,selectedRows,this->workspaceLocation); |
| 1581 |
|
} |
| 1582 |
< |
else if(selectedOption==outCurrOutput){ |
| 1582 |
> |
else if(selectedOption==outCurrOutput.get()){ |
| 1583 |
|
changeItemsOutput(myTable,selectedRows,this->outputFolder); |
| 1584 |
|
} |
| 1585 |
< |
else if(selectedOption==outOther){ |
| 1585 |
> |
else if(selectedOption==outOther.get()){ |
| 1586 |
|
|
| 1587 |
|
QString newDir=QFileDialog::getExistingDirectory(this,"Choose the folder for the output of the files selected...",this->AeLocation+"/GameDataFolder"); |
| 1588 |
|
newDir=Util::normalizePath(newDir); |
| 1594 |
|
changeItemsOutput(myTable,selectedRows,newDir); |
| 1595 |
|
|
| 1596 |
|
} |
| 1597 |
< |
else if(selectedOption==edisable){ |
| 1597 |
> |
else if(selectedOption==edisable.get()){ |
| 1598 |
|
|
| 1599 |
|
int enabledCount=0, disabledCount=0; |
| 1600 |
|
|
| 1630 |
|
result+=QString::number(disabledCount) + (disabledCount==1?" item ":" items ") + "Disabled"; |
| 1631 |
|
} |
| 1632 |
|
|
| 1633 |
+ |
rowsWereChangedInDropTableWidget(); |
| 1634 |
|
showSuccessStatusMessage(result); |
| 1635 |
|
} |
| 1475 |
– |
|
| 1476 |
– |
delete copy; |
| 1477 |
– |
delete moveUp; |
| 1478 |
– |
delete moveDown; |
| 1479 |
– |
delete changeOptions; |
| 1480 |
– |
delete outWorkspace; |
| 1481 |
– |
delete outCurrOutput; |
| 1482 |
– |
delete outOther; |
| 1483 |
– |
delete changeOutput; |
| 1484 |
– |
delete edisable; |
| 1485 |
– |
delete menu; |
| 1636 |
|
} |
| 1637 |
|
|
| 1638 |
|
void MainWindow::changeToCurrentSettings(QList<int> rows, DropTableWidget* myTable){ |
| 1656 |
|
myTable->updateTableToolTips(row); |
| 1657 |
|
} |
| 1658 |
|
|
| 1659 |
+ |
rowsWereChangedInDropTableWidget(); |
| 1660 |
|
showSuccessStatusMessage(QString::number(rows.size()) + (rows.size()==1?" item ":" items ")+ "changed to the current settings"); |
| 1661 |
|
} |
| 1662 |
|
|
| 1680 |
|
myTable->updateTableToolTips(row); |
| 1681 |
|
} |
| 1682 |
|
|
| 1683 |
+ |
rowsWereChangedInDropTableWidget(); |
| 1684 |
|
showSuccessStatusMessage(QString::number(rows.size()) + (rows.size()==1?" item ":" items ")+ "changed the output to "+(newOutput!=this->workspaceLocation?Util::cutName(newOutput):"Vago workspace")); |
| 1685 |
|
} |
| 1686 |
|
|
| 1709 |
|
|
| 1710 |
|
} |
| 1711 |
|
|
| 1560 |
– |
/** |
| 1561 |
– |
This is OS indepented. It maintain size ratio over the Windows and Mac. |
| 1562 |
– |
**/ |
| 1563 |
– |
void MainWindow::setConverterButtonsSize(){ |
| 1564 |
– |
int height=ui->pbConvertXML->sizeHint().height()*1.3; |
| 1565 |
– |
ui->pbConvertXML->setMinimumHeight(height); |
| 1566 |
– |
ui->pbConvertTextures->setMinimumHeight(height); |
| 1567 |
– |
ui->pbConvertObjects->setMinimumHeight(height); |
| 1568 |
– |
ui->pbConvertCharacters->setMinimumHeight(height); |
| 1569 |
– |
ui->pbConvertLevels->setMinimumHeight(height); |
| 1570 |
– |
ui->pbConvertMisc->setMinimumHeight(height); |
| 1571 |
– |
} |
| 1572 |
– |
|
| 1712 |
|
void MainWindow::connectSlots(){ |
| 1713 |
|
|
| 1714 |
|
//This signal is for thread that is working setup the progress bar (make it visible and set it's min-max) |
| 1762 |
|
//Context menu for Misc table |
| 1763 |
|
connect(ui->twSourcesMisc, SIGNAL(dtContextMenu(DropTableWidget*,QContextMenuEvent*)), this, SLOT(dtContextMenu(DropTableWidget*,QContextMenuEvent*))); |
| 1764 |
|
} |
| 1765 |
+ |
|
| 1766 |
+ |
void MainWindow::saveProjectState(const QString &filePath) |
| 1767 |
+ |
{ |
| 1768 |
+ |
|
| 1769 |
+ |
QList<DropTableWidget*> tableWidgets = getAllTableWidgets(); |
| 1770 |
+ |
|
| 1771 |
+ |
pugi::xml_document doc; |
| 1772 |
+ |
|
| 1773 |
+ |
pugi::xml_node rootNode = doc.append_child("VagoProject"); |
| 1774 |
+ |
rootNode.append_attribute("vagoVersion").set_value(GlobalVars::LastCompatibleVersion.toUtf8().constData()); |
| 1775 |
+ |
|
| 1776 |
+ |
foreach(DropTableWidget* const &myTable, tableWidgets){ |
| 1777 |
+ |
saveProjectWidget(rootNode, myTable); |
| 1778 |
+ |
} |
| 1779 |
+ |
|
| 1780 |
+ |
if(!doc.save_file(filePath.toUtf8().constData(), PUGIXML_TEXT("\t"), pugi::format_default | pugi::format_write_bom, pugi::xml_encoding::encoding_utf8)){ |
| 1781 |
+ |
UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "An error ocurred while trying to save the project file. Please try another path."); |
| 1782 |
+ |
return; |
| 1783 |
+ |
} |
| 1784 |
+ |
|
| 1785 |
+ |
this->vagoSettings->setValue("LastProjectPath",QFileInfo(filePath).absoluteDir().path()); |
| 1786 |
+ |
|
| 1787 |
+ |
this->lastProjectFilePath = filePath; |
| 1788 |
+ |
this->unsavedChangesExist = false; |
| 1789 |
+ |
|
| 1790 |
+ |
addNewRecentProject(filePath); |
| 1791 |
+ |
|
| 1792 |
+ |
setVagoWindowTitle(); |
| 1793 |
+ |
|
| 1794 |
+ |
showSuccessStatusMessage("Project saved sucessfully."); |
| 1795 |
+ |
} |
| 1796 |
+ |
|
| 1797 |
+ |
void MainWindow::saveProjectWidget(pugi::xml_node &rootNode, DropTableWidget* table) |
| 1798 |
+ |
{ |
| 1799 |
+ |
QString from; |
| 1800 |
+ |
QString to; |
| 1801 |
+ |
QString tabName = getTabNameByTableWidget(table); |
| 1802 |
+ |
|
| 1803 |
+ |
pugi::xml_node currentNodeTable = rootNode.append_child("tempName"); |
| 1804 |
+ |
pugi::xml_node options; |
| 1805 |
+ |
|
| 1806 |
+ |
if(table==ui->twSourcesXML){ //So we only need to parse one command. |
| 1807 |
+ |
from = ui->cbFromXML->currentText().toUtf8().constData(); |
| 1808 |
+ |
to = ui->cbToXML->currentText().toUtf8().constData(); |
| 1809 |
+ |
} |
| 1810 |
+ |
else if(table==ui->twSourcesTextures){ |
| 1811 |
+ |
from = ui->cbFromTextures->currentText().toUtf8().constData(); |
| 1812 |
+ |
to = ui->cbToTextures->currentText().toUtf8().constData(); |
| 1813 |
+ |
options = currentNodeTable.append_child("Options"); |
| 1814 |
+ |
options.append_attribute("type").set_value(Util::qStrToCstr(getTextureRBCheckedTypeTexture()->text())); |
| 1815 |
+ |
options.append_attribute("genMipMaps").set_value(Util::boolToCstr(ui->cbMipMapsTextures->isChecked())); |
| 1816 |
+ |
options.append_attribute("noUwrap").set_value(Util::boolToCstr(ui->cbNoUwrap->isChecked())); |
| 1817 |
+ |
options.append_attribute("noVwrap").set_value(Util::boolToCstr(ui->cbNoVwrap->isChecked())); |
| 1818 |
+ |
options.append_attribute("large").set_value(Util::boolToCstr(ui->cbLarge->isChecked())); |
| 1819 |
+ |
options.append_attribute("envMap").set_value(Util::boolToCstr(ui->cbEnvMap->isChecked())); |
| 1820 |
+ |
options.append_attribute("envMapValue").set_value(Util::qStrToCstr(ui->leEnvMapTexture->text())); |
| 1821 |
+ |
} |
| 1822 |
+ |
else if(table==ui->twSourcesCharacters){ |
| 1823 |
+ |
from = ui->cbFromCharacters->currentText().toUtf8().constData(); |
| 1824 |
+ |
to = ui->cbToCharacters->currentText().toUtf8().constData(); |
| 1825 |
+ |
options = currentNodeTable.append_child("Options"); |
| 1826 |
+ |
options.append_attribute("cellShading").set_value(Util::boolToCstr(ui->cbCellShading->isChecked())); |
| 1827 |
+ |
options.append_attribute("normals").set_value(Util::boolToCstr(ui->cbNormals->isChecked())); |
| 1828 |
+ |
options.append_attribute("extractTRBSONCC").set_value(Util::boolToCstr(ui->cbWithTRBS_ONCC->isChecked())); |
| 1829 |
+ |
options.append_attribute("extractTRBSONCCValue").set_value(Util::qStrToCstr(ui->leTRBS_ONCC->text())); |
| 1830 |
+ |
} |
| 1831 |
+ |
else if(table==ui->twSourcesObjects){ |
| 1832 |
+ |
from = ui->cbFromObjects->currentText().toUtf8().constData(); |
| 1833 |
+ |
to = ui->cbToObjects->currentText().toUtf8().constData(); |
| 1834 |
+ |
options = currentNodeTable.append_child("Options"); |
| 1835 |
+ |
options.append_attribute("texture").set_value(Util::boolToCstr(ui->cbTexture->isChecked())); |
| 1836 |
+ |
options.append_attribute("textureValue").set_value(Util::qStrToCstr(ui->leTextureName->text())); |
| 1837 |
+ |
options.append_attribute("withAnimation").set_value(Util::boolToCstr(ui->cbWithAnimation->isChecked())); |
| 1838 |
+ |
options.append_attribute("withAnimationValue").set_value(Util::qStrToCstr(ui->leAnimationName->text())); |
| 1839 |
+ |
} |
| 1840 |
+ |
else if(table==ui->twSourcesLevels){ |
| 1841 |
+ |
from = ui->cbFromLevels->currentText().toUtf8().constData(); |
| 1842 |
+ |
to = ui->cbToLevels->currentText().toUtf8().constData(); |
| 1843 |
+ |
options = currentNodeTable.append_child("Options"); |
| 1844 |
+ |
options.append_attribute("extractWithFiles").set_value(Util::boolToCstr(ui->cbSpecificFilesLevels->isChecked())); |
| 1845 |
+ |
options.append_attribute("extractWithFilesValue").set_value(Util::qStrToCstr(ui->leSpecificFilesLevels->text())); |
| 1846 |
+ |
options.append_attribute("datFilename").set_value(Util::boolToCstr(ui->cbDatLevels->isChecked())); |
| 1847 |
+ |
options.append_attribute("datFilenameValue").set_value(Util::qStrToCstr(ui->leTargetDatLevels->text())); |
| 1848 |
+ |
options.append_attribute("bnvSource").set_value(Util::boolToCstr(ui->cbBnvLevels->isChecked())); |
| 1849 |
+ |
options.append_attribute("bnvSourceValue").set_value(Util::qStrToCstr(ui->leBnvLevels->text())); |
| 1850 |
+ |
options.append_attribute("generateGrids").set_value(Util::boolToCstr(ui->cbGridsLevels->isChecked())); |
| 1851 |
+ |
options.append_attribute("additionalSources").set_value(Util::boolToCstr(ui->cbAdditionalSourcesLevels->isChecked())); |
| 1852 |
+ |
options.append_attribute("additionalSourcesValue").set_value(Util::qStrToCstr(ui->leAdditSourcesLevels->text())); |
| 1853 |
+ |
} |
| 1854 |
+ |
else{ |
| 1855 |
+ |
from = ui->cbFromMisc->currentText().toUtf8().constData(); |
| 1856 |
+ |
to = ui->cbToMisc->currentText().toUtf8().constData(); |
| 1857 |
+ |
} |
| 1858 |
+ |
|
| 1859 |
+ |
currentNodeTable.set_name(tabName.toUtf8().constData()); |
| 1860 |
+ |
|
| 1861 |
+ |
currentNodeTable.append_attribute("from").set_value(from.toUtf8().constData()); |
| 1862 |
+ |
currentNodeTable.append_attribute("to").set_value(to.toUtf8().constData()); |
| 1863 |
+ |
|
| 1864 |
+ |
|
| 1865 |
+ |
for(int i=0; i<table->rowCount(); i++){ |
| 1866 |
+ |
|
| 1867 |
+ |
QString currFileFolder = table->item(i,0)->text(); |
| 1868 |
+ |
QString currFromTo = table->item(i,1)->text(); |
| 1869 |
+ |
QString currCommand = table->item(i,2)->text(); |
| 1870 |
+ |
|
| 1871 |
+ |
pugi::xml_node currentRow = currentNodeTable.append_child("Row"); |
| 1872 |
+ |
|
| 1873 |
+ |
|
| 1874 |
+ |
currentRow.append_attribute("fileFolder").set_value(Util::qStrToCstr(currFileFolder)); |
| 1875 |
+ |
currentRow.append_attribute("fromTo").set_value(Util::qStrToCstr(currFromTo)); |
| 1876 |
+ |
currentRow.append_attribute("command").set_value(Util::qStrToCstr(currCommand)); |
| 1877 |
+ |
|
| 1878 |
+ |
if(table->item(i,2)->background()==table->disabledBackStyle){ |
| 1879 |
+ |
currentRow.append_attribute("disabled").set_value(true); |
| 1880 |
+ |
} |
| 1881 |
+ |
|
| 1882 |
+ |
} |
| 1883 |
+ |
} |
| 1884 |
+ |
|
| 1885 |
+ |
QRadioButton* MainWindow::getTextureRBCheckedTypeTexture() |
| 1886 |
+ |
{ |
| 1887 |
+ |
if(ui->rbBGR32->isChecked()){ |
| 1888 |
+ |
return ui->rbBGR32; |
| 1889 |
+ |
} |
| 1890 |
+ |
else if(ui->rbBGRA32->isChecked()){ |
| 1891 |
+ |
return ui->rbBGRA32; |
| 1892 |
+ |
} |
| 1893 |
+ |
else if(ui->rbBGR555->isChecked()){ |
| 1894 |
+ |
return ui->rbBGR555; |
| 1895 |
+ |
} |
| 1896 |
+ |
else if(ui->rbBGRA5551->isChecked()){ |
| 1897 |
+ |
return ui->rbBGRA5551; |
| 1898 |
+ |
} |
| 1899 |
+ |
else if(ui->rbBGRA444->isChecked()){ |
| 1900 |
+ |
return ui->rbBGRA444; |
| 1901 |
+ |
} |
| 1902 |
+ |
else{ //dxt1 checked |
| 1903 |
+ |
return ui->rbDxt1; |
| 1904 |
+ |
} |
| 1905 |
+ |
} |
| 1906 |
+ |
|
| 1907 |
+ |
QRadioButton* MainWindow::getTextureRBTypeTextureByName(const QString &texType) |
| 1908 |
+ |
{ |
| 1909 |
+ |
if(QString::compare(texType,ui->rbBGR32->text(),Qt::CaseSensitive)==0){ |
| 1910 |
+ |
return ui->rbBGR32; |
| 1911 |
+ |
} |
| 1912 |
+ |
else if(QString::compare(texType,ui->rbBGRA32->text(),Qt::CaseSensitive)==0){ |
| 1913 |
+ |
return ui->rbBGRA32; |
| 1914 |
+ |
} |
| 1915 |
+ |
else if(QString::compare(texType, ui->rbBGR555->text(),Qt::CaseSensitive)==0){ |
| 1916 |
+ |
return ui->rbBGR555; |
| 1917 |
+ |
} |
| 1918 |
+ |
else if(QString::compare(texType,ui->rbBGRA5551->text(),Qt::CaseSensitive)==0){ |
| 1919 |
+ |
return ui->rbBGRA5551; |
| 1920 |
+ |
} |
| 1921 |
+ |
else if(QString::compare(texType,ui->rbBGRA444->text(),Qt::CaseSensitive)==0){ |
| 1922 |
+ |
return ui->rbBGRA444; |
| 1923 |
+ |
} |
| 1924 |
+ |
else{ //dxt1 |
| 1925 |
+ |
return ui->rbDxt1; |
| 1926 |
+ |
} |
| 1927 |
+ |
|
| 1928 |
+ |
} |
| 1929 |
+ |
|
| 1930 |
+ |
void MainWindow::setVagoWindowTitle(){ |
| 1931 |
+ |
|
| 1932 |
+ |
QString vagoTitle = "Vago v"+GlobalVars::AppVersion + " - "; |
| 1933 |
+ |
|
| 1934 |
+ |
if(this->lastProjectFilePath.isEmpty()){ |
| 1935 |
+ |
vagoTitle += "Untitled"; |
| 1936 |
+ |
} |
| 1937 |
+ |
else{ |
| 1938 |
+ |
vagoTitle += Util::cutNameWithoutBackSlash(this->lastProjectFilePath); |
| 1939 |
+ |
} |
| 1940 |
+ |
|
| 1941 |
+ |
if(this->unsavedChangesExist){ |
| 1942 |
+ |
vagoTitle += "*"; |
| 1943 |
+ |
} |
| 1944 |
+ |
|
| 1945 |
+ |
setWindowTitle(vagoTitle); |
| 1946 |
+ |
} |
| 1947 |
+ |
|
| 1948 |
+ |
DropTableWidget* MainWindow::getCurrentTableWidget(){ |
| 1949 |
+ |
|
| 1950 |
+ |
return getTableWidgetByTabName(ui->tabWidget->tabText(ui->tabWidget->currentIndex())); |
| 1951 |
+ |
|
| 1952 |
+ |
} |
| 1953 |
+ |
|
| 1954 |
+ |
DropTableWidget* MainWindow::getTableWidgetByTabName(const QString &tabName){ |
| 1955 |
+ |
|
| 1956 |
+ |
if(tabName.compare("XML",Qt::CaseSensitive)==0){ //case sentive is faster |
| 1957 |
+ |
return ui->twSourcesXML; |
| 1958 |
+ |
} |
| 1959 |
+ |
else if(tabName.compare("Textures",Qt::CaseSensitive)==0){ |
| 1960 |
+ |
return ui->twSourcesTextures; |
| 1961 |
+ |
} |
| 1962 |
+ |
else if(tabName.compare("Characters",Qt::CaseSensitive)==0){ |
| 1963 |
+ |
return ui->twSourcesCharacters; |
| 1964 |
+ |
} |
| 1965 |
+ |
else if(tabName.compare("Objects",Qt::CaseSensitive)==0){ |
| 1966 |
+ |
return ui->twSourcesObjects; |
| 1967 |
+ |
} |
| 1968 |
+ |
else if(tabName.compare("Levels",Qt::CaseSensitive)==0){ |
| 1969 |
+ |
return ui->twSourcesLevels; |
| 1970 |
+ |
} |
| 1971 |
+ |
else{ |
| 1972 |
+ |
return ui->twSourcesMisc; |
| 1973 |
+ |
} |
| 1974 |
+ |
|
| 1975 |
+ |
} |
| 1976 |
+ |
|
| 1977 |
+ |
QString MainWindow::getCurrentTabName(){ |
| 1978 |
+ |
return ui->tabWidget->tabText(ui->tabWidget->currentIndex()); |
| 1979 |
+ |
} |
| 1980 |
+ |
|
| 1981 |
+ |
QString MainWindow::getTabNameByTableWidget(DropTableWidget* table){ |
| 1982 |
+ |
|
| 1983 |
+ |
if(table == ui->twSourcesXML){ |
| 1984 |
+ |
return ui->tabWidget->tabText(XMLTabIndex); |
| 1985 |
+ |
} |
| 1986 |
+ |
else if(table == ui->twSourcesTextures){ |
| 1987 |
+ |
return ui->tabWidget->tabText(TexturesTabIndex); |
| 1988 |
+ |
} |
| 1989 |
+ |
else if(table == ui->twSourcesCharacters){ |
| 1990 |
+ |
return ui->tabWidget->tabText(CharactersTabIndex); |
| 1991 |
+ |
} |
| 1992 |
+ |
else if(table == ui->twSourcesObjects){ |
| 1993 |
+ |
return ui->tabWidget->tabText(ObjectsTabIndex); |
| 1994 |
+ |
} |
| 1995 |
+ |
else if(table == ui->twSourcesLevels){ |
| 1996 |
+ |
return ui->tabWidget->tabText(LevelsTabIndex); |
| 1997 |
+ |
} |
| 1998 |
+ |
else{ |
| 1999 |
+ |
return ui->tabWidget->tabText(MiscTabIndex); |
| 2000 |
+ |
} |
| 2001 |
+ |
|
| 2002 |
+ |
} |
| 2003 |
+ |
|
| 2004 |
+ |
QList<DropTableWidget*> MainWindow::getAllTableWidgets() |
| 2005 |
+ |
{ |
| 2006 |
+ |
QList<DropTableWidget*> tableWidgets; |
| 2007 |
+ |
|
| 2008 |
+ |
tableWidgets << ui->twSourcesXML << ui->twSourcesTextures << ui->twSourcesCharacters |
| 2009 |
+ |
<< ui->twSourcesObjects << ui->twSourcesLevels << ui->twSourcesMisc; |
| 2010 |
+ |
|
| 2011 |
+ |
return tableWidgets; |
| 2012 |
+ |
} |
| 2013 |
+ |
|
| 2014 |
+ |
void MainWindow::loadProjectState(const QString &filePath) |
| 2015 |
+ |
{ |
| 2016 |
+ |
|
| 2017 |
+ |
this->projectIsLoading = true; |
| 2018 |
+ |
|
| 2019 |
+ |
if(this->vagoSettings->value("AskSaveProject").toBool() && this->unsavedChangesExist){ |
| 2020 |
+ |
QMessageBox::StandardButton result = askToSaveCurrentProject(); |
| 2021 |
+ |
if(result == QMessageBox::StandardButton::Cancel){ |
| 2022 |
+ |
this->projectIsLoading = false; |
| 2023 |
+ |
return; |
| 2024 |
+ |
} |
| 2025 |
+ |
} |
| 2026 |
+ |
|
| 2027 |
+ |
QString statusError = "Couldn't load project."; |
| 2028 |
+ |
|
| 2029 |
+ |
pugi::xml_document doc; |
| 2030 |
+ |
|
| 2031 |
+ |
pugi::xml_parse_result result = doc.load_file(Util::qStrToCstr(filePath)); |
| 2032 |
+ |
|
| 2033 |
+ |
if(result.status!=pugi::status_ok){ |
| 2034 |
+ |
UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "An error ocurred while loading project file.\n" + QString(result.description())); |
| 2035 |
+ |
showErrStatusMessage(statusError); |
| 2036 |
+ |
this->projectIsLoading = false; |
| 2037 |
+ |
return; |
| 2038 |
+ |
} |
| 2039 |
+ |
|
| 2040 |
+ |
|
| 2041 |
+ |
if(QString(doc.root().first_child().name()) != "VagoProject"){ |
| 2042 |
+ |
UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, QString(doc.root().name()) + "The file opened is not a valid VagoProject file. Load aborted."); |
| 2043 |
+ |
showErrStatusMessage(statusError); |
| 2044 |
+ |
this->projectIsLoading = false; |
| 2045 |
+ |
return; |
| 2046 |
+ |
} |
| 2047 |
+ |
|
| 2048 |
+ |
QString projVagoVersion; |
| 2049 |
+ |
|
| 2050 |
+ |
try{ |
| 2051 |
+ |
projVagoVersion = QString(doc.select_node("/VagoProject/@vagoVersion").attribute().value()); |
| 2052 |
+ |
} |
| 2053 |
+ |
catch (const pugi::xpath_exception& e) |
| 2054 |
+ |
{ |
| 2055 |
+ |
UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "Couldn't find the vagoVersion of the current project. Load aborted.\n" + QString(e.what())); |
| 2056 |
+ |
showErrStatusMessage(statusError); |
| 2057 |
+ |
this->projectIsLoading = false; |
| 2058 |
+ |
return; |
| 2059 |
+ |
} |
| 2060 |
+ |
|
| 2061 |
+ |
if(!projVagoVersion.startsWith(GlobalVars::LastCompatibleVersion)){ |
| 2062 |
+ |
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."); |
| 2063 |
+ |
showErrStatusMessage(statusError); |
| 2064 |
+ |
this->projectIsLoading = false; |
| 2065 |
+ |
return; |
| 2066 |
+ |
} |
| 2067 |
+ |
|
| 2068 |
+ |
// After the initial validations begin loading the project data |
| 2069 |
+ |
|
| 2070 |
+ |
QList<DropTableWidget*> tableWidgets = getAllTableWidgets(); |
| 2071 |
+ |
|
| 2072 |
+ |
try{ |
| 2073 |
+ |
foreach(DropTableWidget* const &myTable, tableWidgets){ |
| 2074 |
+ |
loadProjectWidget(doc, myTable); |
| 2075 |
+ |
} |
| 2076 |
+ |
} |
| 2077 |
+ |
catch(const std::exception& e){ |
| 2078 |
+ |
UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "Couldn't load the vago project. Error: " + QString(e.what())); |
| 2079 |
+ |
showErrStatusMessage(statusError); |
| 2080 |
+ |
this->projectIsLoading = false; |
| 2081 |
+ |
return; |
| 2082 |
+ |
} |
| 2083 |
+ |
|
| 2084 |
+ |
this->vagoSettings->setValue("LastProjectPath",QFileInfo(filePath).absoluteDir().path()); |
| 2085 |
+ |
|
| 2086 |
+ |
this->lastProjectFilePath = filePath; |
| 2087 |
+ |
this->unsavedChangesExist = false; |
| 2088 |
+ |
|
| 2089 |
+ |
addNewRecentProject(filePath); |
| 2090 |
+ |
|
| 2091 |
+ |
setVagoWindowTitle(); |
| 2092 |
+ |
|
| 2093 |
+ |
this->projectIsLoading = false; |
| 2094 |
+ |
|
| 2095 |
+ |
showSuccessStatusMessage("Project loaded sucessfully."); |
| 2096 |
+ |
} |
| 2097 |
+ |
|
| 2098 |
+ |
|
| 2099 |
+ |
void MainWindow::loadProjectWidget(pugi::xml_document &doc, DropTableWidget* table) |
| 2100 |
+ |
{ |
| 2101 |
+ |
QString tabName = getTabNameByTableWidget(table); |
| 2102 |
+ |
QString from (doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/@from")).attribute().value()); |
| 2103 |
+ |
QString to (doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/@to")).attribute().value()); |
| 2104 |
+ |
|
| 2105 |
+ |
if(table==ui->twSourcesXML){ |
| 2106 |
+ |
ui->cbFromXML->setCurrentText(from); |
| 2107 |
+ |
on_cbFromXML_currentIndexChanged(from); |
| 2108 |
+ |
ui->cbToXML->setCurrentText(to); |
| 2109 |
+ |
} |
| 2110 |
+ |
else if(table==ui->twSourcesTextures){ |
| 2111 |
+ |
//ui->cbFromTextures->setCurrentText(from); |
| 2112 |
+ |
on_cbFromTextures_currentIndexChanged(from); |
| 2113 |
+ |
ui->cbToTextures->setCurrentText(to); |
| 2114 |
+ |
|
| 2115 |
+ |
getTextureRBTypeTextureByName((doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@type")).attribute().value()))->setChecked(true); |
| 2116 |
+ |
ui->cbMipMapsTextures->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@genMipMaps")).attribute().as_bool()); |
| 2117 |
+ |
ui->cbNoUwrap->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@noUwrap")).attribute().as_bool()); |
| 2118 |
+ |
ui->cbNoVwrap->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@noVwrap")).attribute().as_bool()); |
| 2119 |
+ |
ui->cbLarge->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@large")).attribute().as_bool()); |
| 2120 |
+ |
ui->cbEnvMap->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@envMap")).attribute().as_bool()); |
| 2121 |
+ |
ui->leEnvMapTexture->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@envMapValue")).attribute().value())); |
| 2122 |
+ |
} |
| 2123 |
+ |
else if(table==ui->twSourcesCharacters){ |
| 2124 |
+ |
ui->cbFromCharacters->setCurrentText(from); |
| 2125 |
+ |
on_cbFromCharacters_currentIndexChanged(from); |
| 2126 |
+ |
ui->cbToCharacters->setCurrentText(to); |
| 2127 |
+ |
|
| 2128 |
+ |
|
| 2129 |
+ |
ui->cbCellShading->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@cellShading")).attribute().as_bool()); |
| 2130 |
+ |
ui->cbNormals->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@normals")).attribute().as_bool()); |
| 2131 |
+ |
ui->cbWithTRBS_ONCC->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@extractTRBSONCC")).attribute().as_bool()); |
| 2132 |
+ |
ui->leTRBS_ONCC->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@extractTRBSONCCValue")).attribute().value())); |
| 2133 |
+ |
} |
| 2134 |
+ |
else if(table==ui->twSourcesObjects){ |
| 2135 |
+ |
ui->cbFromObjects->setCurrentText(from); |
| 2136 |
+ |
on_cbFromObjects_currentIndexChanged(from); |
| 2137 |
+ |
ui->cbToObjects->setCurrentText(to); |
| 2138 |
+ |
|
| 2139 |
+ |
ui->cbTexture->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@texture")).attribute().as_bool()); |
| 2140 |
+ |
ui->leTextureName->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@textureValue")).attribute().value())); |
| 2141 |
+ |
ui->cbWithAnimation->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@withAnimation")).attribute().as_bool()); |
| 2142 |
+ |
ui->leAnimationName->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@withAnimationValue")).attribute().value())); |
| 2143 |
+ |
} |
| 2144 |
+ |
else if(table==ui->twSourcesLevels){ |
| 2145 |
+ |
ui->cbFromLevels->setCurrentText(from); |
| 2146 |
+ |
on_cbFromLevels_currentIndexChanged(from); |
| 2147 |
+ |
ui->cbToLevels->setCurrentText(to); |
| 2148 |
+ |
|
| 2149 |
+ |
ui->cbSpecificFilesLevels->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@extractWithFiles")).attribute().as_bool()); |
| 2150 |
+ |
ui->leSpecificFilesLevels->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@extractWithFilesValue")).attribute().value())); |
| 2151 |
+ |
ui->cbDatLevels->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@datFilename")).attribute().as_bool()); |
| 2152 |
+ |
ui->leTargetDatLevels->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@datFilenameValue")).attribute().value())); |
| 2153 |
+ |
ui->cbBnvLevels->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@bnvSource")).attribute().as_bool()); |
| 2154 |
+ |
ui->leBnvLevels->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@bnvSourceValue")).attribute().value())); |
| 2155 |
+ |
ui->cbGridsLevels->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@generateGrids")).attribute().as_bool()); |
| 2156 |
+ |
ui->cbAdditionalSourcesLevels->setChecked(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@additionalSources")).attribute().as_bool()); |
| 2157 |
+ |
ui->leAdditSourcesLevels->setText(QString(doc.select_node(Util::qStrToCstr("/VagoProject/"+tabName+"/Options/@additionalSourcesValue")).attribute().value())); |
| 2158 |
+ |
} |
| 2159 |
+ |
else{ |
| 2160 |
+ |
ui->cbFromMisc->setCurrentText(from); |
| 2161 |
+ |
on_cbFromMisc_currentIndexChanged(from); |
| 2162 |
+ |
ui->cbToMisc->setCurrentText(to); |
| 2163 |
+ |
} |
| 2164 |
+ |
|
| 2165 |
+ |
// Clean previous rows |
| 2166 |
+ |
clearTableNoPrompt(table); |
| 2167 |
+ |
|
| 2168 |
+ |
for(const pugi::xpath_node &xPathNode : doc.select_nodes(Util::qStrToCstr("/VagoProject/"+tabName+"/Row"))){ |
| 2169 |
+ |
pugi::xml_node currNode = xPathNode.node(); |
| 2170 |
+ |
|
| 2171 |
+ |
QString currFileFolder = currNode.attribute("fileFolder").value(); |
| 2172 |
+ |
QString currFromTo = currNode.attribute("fromTo").value(); |
| 2173 |
+ |
QString currCommand = currNode.attribute("command").value(); |
| 2174 |
+ |
|
| 2175 |
+ |
bool isToDisable = false; |
| 2176 |
+ |
pugi::xml_attribute disabledAttr = currNode.attribute("disabled"); |
| 2177 |
+ |
isToDisable = disabledAttr.empty() ? false : disabledAttr.as_bool(); |
| 2178 |
+ |
|
| 2179 |
+ |
addRowTable(table,currFileFolder,currFromTo,currCommand, isToDisable); |
| 2180 |
+ |
} |
| 2181 |
+ |
} |
| 2182 |
+ |
|
| 2183 |
+ |
void MainWindow::saveRecentProjects(){ |
| 2184 |
+ |
for(int i=0; i<this->recentProjectsList.size(); i++){ |
| 2185 |
+ |
this->vagoSettings->setValue("RecentProject" + QString::number(i+1), recentProjectsList[i]); |
| 2186 |
+ |
} |
| 2187 |
+ |
} |
| 2188 |
+ |
|
| 2189 |
+ |
void MainWindow::loadRecentProjects(){ |
| 2190 |
+ |
for(int i=0; i<this->recentProjectsMaxSize; i++){ |
| 2191 |
+ |
|
| 2192 |
+ |
QString currProj = this->vagoSettings->value("RecentProject" + QString::number(i+1)).toString(); |
| 2193 |
+ |
|
| 2194 |
+ |
if(!currProj.isEmpty()){ |
| 2195 |
+ |
recentProjectsList.append(currProj); |
| 2196 |
+ |
} |
| 2197 |
+ |
else{ |
| 2198 |
+ |
break; |
| 2199 |
+ |
} |
| 2200 |
+ |
} |
| 2201 |
+ |
|
| 2202 |
+ |
reloadRecentProjectsMenu(); |
| 2203 |
+ |
|
| 2204 |
+ |
} |
| 2205 |
+ |
|
| 2206 |
+ |
void MainWindow::addNewRecentProject(const QString &filePath){ |
| 2207 |
+ |
|
| 2208 |
+ |
// If the new project is equal to the last one simply ignore |
| 2209 |
+ |
if(filePath == this->vagoSettings->value("RecentProject1").toString()){ |
| 2210 |
+ |
return; |
| 2211 |
+ |
} |
| 2212 |
+ |
|
| 2213 |
+ |
// If the item already exists in our list remove it, so it can go to the top again |
| 2214 |
+ |
for(auto it = this->recentProjectsList.begin(); it != this->recentProjectsList.end();){ |
| 2215 |
+ |
if(*it == filePath){ |
| 2216 |
+ |
it = this->recentProjectsList.erase(it); |
| 2217 |
+ |
} |
| 2218 |
+ |
else{ |
| 2219 |
+ |
it++; |
| 2220 |
+ |
} |
| 2221 |
+ |
} |
| 2222 |
+ |
|
| 2223 |
+ |
// if we gonna overflow our list, remove the older item to reserve space to the new one |
| 2224 |
+ |
if(this->recentProjectsList.size()==this->recentProjectsMaxSize){ |
| 2225 |
+ |
this->recentProjectsList.removeLast(); |
| 2226 |
+ |
} |
| 2227 |
+ |
|
| 2228 |
+ |
this->vagoSettings->setValue("LastProjectPath",QFileInfo(filePath).absoluteDir().path()); |
| 2229 |
+ |
|
| 2230 |
+ |
// add new recent file |
| 2231 |
+ |
this->recentProjectsList.prepend(filePath); |
| 2232 |
+ |
|
| 2233 |
+ |
reloadRecentProjectsMenu(); |
| 2234 |
+ |
|
| 2235 |
+ |
saveRecentProjects(); |
| 2236 |
+ |
} |
| 2237 |
+ |
|
| 2238 |
+ |
void MainWindow::reloadRecentProjectsMenu(){ |
| 2239 |
+ |
|
| 2240 |
+ |
ui->menuRecent_Projects->setEnabled(false); |
| 2241 |
+ |
ui->actionProject1->setVisible(false); |
| 2242 |
+ |
ui->actionProject2->setVisible(false); |
| 2243 |
+ |
ui->actionProject3->setVisible(false); |
| 2244 |
+ |
ui->actionProject4->setVisible(false); |
| 2245 |
+ |
ui->actionProject5->setVisible(false); |
| 2246 |
+ |
|
| 2247 |
+ |
{ |
| 2248 |
+ |
QList<QString>::const_iterator it; |
| 2249 |
+ |
int i; |
| 2250 |
+ |
for(it = recentProjectsList.cbegin(), i=0; it != recentProjectsList.cend(); it++, i++){ |
| 2251 |
+ |
|
| 2252 |
+ |
QAction* currAction = nullptr; |
| 2253 |
+ |
|
| 2254 |
+ |
switch (i){ |
| 2255 |
+ |
case 0: |
| 2256 |
+ |
currAction = ui->actionProject1; |
| 2257 |
+ |
break; |
| 2258 |
+ |
case 1: |
| 2259 |
+ |
currAction = ui->actionProject2; |
| 2260 |
+ |
break; |
| 2261 |
+ |
case 2: |
| 2262 |
+ |
currAction = ui->actionProject3; |
| 2263 |
+ |
break; |
| 2264 |
+ |
case 3: |
| 2265 |
+ |
currAction = ui->actionProject4; |
| 2266 |
+ |
break; |
| 2267 |
+ |
case 4: |
| 2268 |
+ |
currAction = ui->actionProject5; |
| 2269 |
+ |
break; |
| 2270 |
+ |
} |
| 2271 |
+ |
|
| 2272 |
+ |
if(currAction){ |
| 2273 |
+ |
ui->menuRecent_Projects->setEnabled(true); |
| 2274 |
+ |
currAction->setText(*it); |
| 2275 |
+ |
currAction->setVisible(true); |
| 2276 |
+ |
} |
| 2277 |
+ |
} |
| 2278 |
+ |
} |
| 2279 |
+ |
|
| 2280 |
+ |
} |