| 1 | #include "mainwindow.h" | 
 
 
 
 
 | 2 | #include "ui_mainwindow.h" | 
 
 
 
 
 | 3 |  | 
 
 
 
 
 | 4 | const QString MainWindow::VagoSettingsName = "settingsVago.ini"; | 
 
 
 
 
 | 5 |  | 
 
 
 
 
 | 6 | MainWindow::MainWindow(QWidget *parent) : | 
 
 
 
 
 | 7 | QMainWindow(parent), | 
 
 
 
 
 | 8 | ui(new Ui::MainWindow) | 
 
 
 
 
 | 9 | { | 
 
 
 
 
 | 10 | ui->setupUi(this); | 
 
 
 
 
 | 11 |  | 
 
 
 
 
 | 12 | this->setWindowTitle("Vago v"+GlobalVars::AppVersion); | 
 
 
 
 
 | 13 |  | 
 
 
 
 
 | 14 | // QTextCodec::setCodecForCStrings(QTextCodec::codecForLocale ()); | 
 
 
 
 
 | 15 |  | 
 
 
 
 
 | 16 | if(!QFile::exists(QDir::currentPath()+"/"+GlobalVars::OniSplitExeName)){ | 
 
 
 
 
 | 17 | 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."); | 
 
 
 
 
 | 18 | exit(1); | 
 
 
 
 
 | 19 | } | 
 
 
 
 
 | 20 |  | 
 
 
 
 
 | 21 | if(!QFile::exists(QDir::currentPath()+"/"+GlobalVars::XmlToolsExeName)){ | 
 
 
 
 
 | 22 | 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."); | 
 
 
 
 
 | 23 | exit(1); | 
 
 
 
 
 | 24 | } | 
 
 
 
 
 | 25 |  | 
 
 
 
 
 | 26 | this->vagoSettings = new QSettings(QDir::currentPath() + "/" + this->VagoSettingsName, QSettings::IniFormat); | 
 
 
 
 
 | 27 |  | 
 
 
 
 
 | 28 | //First Execution? Old configuration? Settings missed? | 
 
 
 
 
 | 29 | bool iniChanged=false; | 
 
 
 
 
 | 30 | if(!this->vagoSettings->contains("VagoVersion") || this->vagoSettings->value("VagoVersion")!=GlobalVars::AppVersion){ | 
 
 
 
 
 | 31 | this->vagoSettings->setValue("VagoVersion", GlobalVars::AppVersion); | 
 
 
 
 
 | 32 | iniChanged=true; | 
 
 
 
 
 | 33 | } | 
 
 
 
 
 | 34 | if(!this->vagoSettings->contains("Workspace")){ | 
 
 
 
 
 | 35 | this->vagoSettings->setValue("Workspace", QDir::currentPath()+"/VagoWorkspace"); | 
 
 
 
 
 | 36 | iniChanged=true; | 
 
 
 
 
 | 37 | } | 
 
 
 
 
 | 38 | if(!this->vagoSettings->contains("AeFolder")){ | 
 
 
 
 
 | 39 |  | 
 
 
 
 
 | 40 | Util::showPopUp("Seems it's the first time you are executing Vago. \n\nPlease input your Anniversary Edition (AE) Folder."); | 
 
 
 
 
 | 41 | QString aefolder=Util::normalizePath(QFileDialog::getExistingDirectory(this,"Choose Anniversary Edition (AE) folder...")); | 
 
 
 
 
 | 42 |  | 
 
 
 
 
 | 43 | if(aefolder.isEmpty()){ | 
 
 
 
 
 | 44 | Util::showErrorPopUp("AE folder is mandatory. Application will exit."); | 
 
 
 
 
 | 45 | exit(1); | 
 
 
 
 
 | 46 | } | 
 
 
 
 
 | 47 |  | 
 
 
 
 
 | 48 | if(!aefolder.endsWith("AE")){ | 
 
 
 
 
 | 49 | 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."); | 
 
 
 
 
 | 50 | } | 
 
 
 
 
 | 51 |  | 
 
 
 
 
 | 52 | this->vagoSettings->setValue("AeFolder", aefolder); | 
 
 
 
 
 | 53 | iniChanged=true; | 
 
 
 
 
 | 54 | } | 
 
 
 
 
 | 55 | if(!this->vagoSettings->contains("OniWindow")){ | 
 
 
 
 
 | 56 | this->vagoSettings->setValue("OniWindow", true); | 
 
 
 
 
 | 57 | iniChanged=true; | 
 
 
 
 
 | 58 | } | 
 
 
 
 
 | 59 | if(!this->vagoSettings->contains("SeparateInWorkspace")){ | 
 
 
 
 
 | 60 | this->vagoSettings->setValue("SeparateInWorkspace",true); | 
 
 
 
 
 | 61 | iniChanged=true; | 
 
 
 
 
 | 62 | } | 
 
 
 
 
 | 63 | if(!this->vagoSettings->contains("ConfirmExit")){ | 
 
 
 
 
 | 64 | this->vagoSettings->setValue("ConfirmExit", false); | 
 
 
 
 
 | 65 | iniChanged=true; | 
 
 
 
 
 | 66 | } | 
 
 
 
 
 | 67 |  | 
 
 
 
 
 | 68 | if(iniChanged){ | 
 
 
 
 
 | 69 | this->vagoSettings->sync(); | 
 
 
 
 
 | 70 | } | 
 
 
 
 
 | 71 | /// | 
 
 
 
 
 | 72 |  | 
 
 
 
 
 | 73 | this->workspaceLocation=this->vagoSettings->value("Workspace").toString(); | 
 
 
 
 
 | 74 | this->workspaceWizardsLocation=this->workspaceLocation+"/Wizards"; | 
 
 
 
 
 | 75 | this->AeLocation=this->vagoSettings->value("AeFolder").toString(); | 
 
 
 
 
 | 76 | this->outputFolder=this->workspaceLocation; | 
 
 
 
 
 | 77 |  | 
 
 
 
 
 | 78 | //Create our workspace if it doesn't exists yet | 
 
 
 
 
 | 79 | if(!QDir(this->workspaceLocation).exists()){ | 
 
 
 
 
 | 80 | QDir().mkdir(this->workspaceLocation); | 
 
 
 
 
 | 81 | } | 
 
 
 
 
 | 82 | this->itemsLoaded=new QLabel(this); | 
 
 
 
 
 | 83 | ui->statusBar->addWidget(this->itemsLoaded); | 
 
 
 
 
 | 84 | this->myBar = new QProgressBar(this); | 
 
 
 
 
 | 85 | this->myBar->setTextVisible(false); //hides text | 
 
 
 
 
 | 86 |  | 
 
 
 
 
 | 87 | this->myBar->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Fixed); | 
 
 
 
 
 | 88 | this->myBar->setMinimumWidth(150); | 
 
 
 
 
 | 89 | this->myBar->hide(); //hide while not being used | 
 
 
 
 
 | 90 |  | 
 
 
 
 
 | 91 | ui->statusBar->addPermanentWidget(myBar); //this adds automatically in right | 
 
 
 
 
 | 92 |  | 
 
 
 
 
 | 93 | this->myLogger = new Logger(); //start logger | 
 
 
 
 
 | 94 |  | 
 
 
 
 
 | 95 | //Initialize list pointers | 
 
 
 
 
 | 96 | this->listToProccess = new QStringList; | 
 
 
 
 
 | 97 |  | 
 
 
 
 
 | 98 | //Create a thread for do the conversion in background | 
 
 
 
 
 | 99 | this->myConverter = new Converter(this->myLogger,this->listToProccess); | 
 
 
 
 
 | 100 |  | 
 
 
 
 
 | 101 | ui->mainToolBar->addWidget(ui->tbAE); //add ae installer launch button | 
 
 
 
 
 | 102 | ui->mainToolBar->addWidget(ui->emptySpacerLabel); //trick, we can't add directly a space so we add an empty | 
 
 
 
 
 | 103 | ui->mainToolBar->addWidget(ui->tbOni); //add oni launch buttonlabel | 
 
 
 
 
 | 104 | ui->mainToolBar->addWidget(ui->emptySpacerLabel2); //same as before | 
 
 
 
 
 | 105 | ui->mainToolBar->addWidget(ui->tbCommand); //add option to manual onisplit commands | 
 
 
 
 
 | 106 | ui->mainToolBar->addWidget(ui->emptySpacerLabel3); //same as before | 
 
 
 
 
 | 107 | ui->mainToolBar->addWidget(ui->tbOpenFolder); //add option to open folder with files converted etc | 
 
 
 
 
 | 108 |  | 
 
 
 
 
 | 109 | ui->mainToolBar->setLayoutDirection(Qt::RightToLeft); | 
 
 
 
 
 | 110 |  | 
 
 
 
 
 | 111 | connectSlots(); | 
 
 
 
 
 | 112 |  | 
 
 
 
 
 | 113 | //Commands Mapping | 
 
 
 
 
 | 114 | this->commandMap = QHash<QString, QString>(); | 
 
 
 
 
 | 115 | mapCommands(); | 
 
 
 
 
 | 116 |  | 
 
 
 
 
 | 117 | updateItemsLoaded(ui->twSourcesGeneral); | 
 
 
 
 
 | 118 |  | 
 
 
 
 
 | 119 | this->myLogger->writeString("Application started."); | 
 
 
 
 
 | 120 | } | 
 
 
 
 
 | 121 |  | 
 
 
 
 
 | 122 | MainWindow::~MainWindow() | 
 
 
 
 
 | 123 | { | 
 
 
 
 
 | 124 | delete ui; | 
 
 
 
 
 | 125 | this->myLogger->writeString("Application Exited."); | 
 
 
 
 
 | 126 | } | 
 
 
 
 
 | 127 |  | 
 
 
 
 
 | 128 | void MainWindow::on_actionExit_triggered() | 
 
 
 
 
 | 129 | { | 
 
 
 
 
 | 130 | close(); | 
 
 
 
 
 | 131 | } | 
 
 
 
 
 | 132 |  | 
 
 
 
 
 | 133 | void MainWindow::on_actionAbout_triggered() | 
 
 
 
 
 | 134 | { | 
 
 
 
 
 | 135 | //Show preferences | 
 
 
 
 
 | 136 | About *aboutWindow = new About(this); | 
 
 
 
 
 | 137 | aboutWindow->show(); //it destroys itself when finished. | 
 
 
 
 
 | 138 | } | 
 
 
 
 
 | 139 |  | 
 
 
 
 
 | 140 | void MainWindow::on_actionAE_Package_Creator_triggered() | 
 
 
 
 
 | 141 | { | 
 
 
 
 
 | 142 | PackageWizard myWizard = PackageWizard(this->workspaceWizardsLocation, this->vagoSettings, this->myLogger); | 
 
 
 
 
 | 143 | myWizard.exec(); | 
 
 
 
 
 | 144 | } | 
 
 
 
 
 | 145 |  | 
 
 
 
 
 | 146 | void MainWindow::on_actionSound_Wizard_triggered() | 
 
 
 
 
 | 147 | { | 
 
 
 
 
 | 148 | SoundWizard myWizard (this->workspaceWizardsLocation, this->myLogger, &this->commandMap); | 
 
 
 
 
 | 149 | myWizard.exec(); | 
 
 
 
 
 | 150 | } | 
 
 
 
 
 | 151 |  | 
 
 
 
 
 | 152 | void MainWindow::on_tbOni_clicked() | 
 
 
 
 
 | 153 | { | 
 
 
 
 
 | 154 | QStringList arguments; | 
 
 
 
 
 | 155 |  | 
 
 
 
 
 | 156 | if(this->vagoSettings->value("OniWindow").toBool()){ //Run in a window? | 
 
 
 
 
 | 157 | arguments << "-noswitch"; | 
 
 
 
 
 | 158 | } | 
 
 
 
 
 | 159 | else{ | 
 
 
 
 
 | 160 | arguments << "-switch"; | 
 
 
 
 
 | 161 | } | 
 
 
 
 
 | 162 |  | 
 
 
 
 
 | 163 | arguments << " -debugfiles"; | 
 
 
 
 
 | 164 |  | 
 
 
 
 
 | 165 | if(!QProcess::startDetached(this->AeLocation+"/Oni.exe",arguments,this->AeLocation)){ | 
 
 
 
 
 | 166 | showErrStatusMessage("Oni could not be started!"); | 
 
 
 
 
 | 167 | } | 
 
 
 
 
 | 168 | } | 
 
 
 
 
 | 169 |  | 
 
 
 
 
 | 170 | void MainWindow::on_tbAE_clicked() | 
 
 
 
 
 | 171 | { | 
 
 
 
 
 | 172 | // If the app turn out someday to a native app use QProcess::startDetached instead... | 
 
 
 
 
 | 173 |  | 
 
 
 
 
 | 174 | if(!QDesktopServices::openUrl(this->AeLocation+"/AEInstaller/bin/AEInstaller2.jar")){ | 
 
 
 
 
 | 175 | showErrStatusMessage("Could not start AE Installer!"); | 
 
 
 
 
 | 176 | } | 
 
 
 
 
 | 177 | } | 
 
 
 
 
 | 178 |  | 
 
 
 
 
 | 179 | void MainWindow::on_tbOpenFolder_clicked() | 
 
 
 
 
 | 180 | { | 
 
 
 
 
 | 181 | QDesktopServices::openUrl(QUrl("file:///"+this->outputFolder)); | 
 
 
 
 
 | 182 | } | 
 
 
 
 
 | 183 |  | 
 
 
 
 
 | 184 | void MainWindow::on_cbEnvMap_toggled(bool checked) | 
 
 
 
 
 | 185 | { | 
 
 
 
 
 | 186 | ui->leEnvMapTexture->setEnabled(checked); | 
 
 
 
 
 | 187 | } | 
 
 
 
 
 | 188 |  | 
 
 
 
 
 | 189 | void MainWindow::on_cbTexture_toggled(bool checked) | 
 
 
 
 
 | 190 | { | 
 
 
 
 
 | 191 | ui->leTextureName->setEnabled(checked); | 
 
 
 
 
 | 192 | } | 
 
 
 
 
 | 193 |  | 
 
 
 
 
 | 194 | void MainWindow::on_cbWithAnimation_toggled(bool checked) | 
 
 
 
 
 | 195 | { | 
 
 
 
 
 | 196 | ui->leAnimationName->setEnabled(checked); | 
 
 
 
 
 | 197 | } | 
 
 
 
 
 | 198 |  | 
 
 
 
 
 | 199 | void MainWindow::on_cbCamera_toggled(bool checked) | 
 
 
 
 
 | 200 | { | 
 
 
 
 
 | 201 | if(checked){ | 
 
 
 
 
 | 202 | ui->cbGeometry->setChecked(false); | 
 
 
 
 
 | 203 | } | 
 
 
 
 
 | 204 | } | 
 
 
 
 
 | 205 |  | 
 
 
 
 
 | 206 | void MainWindow::on_cbGeometry_toggled(bool checked) | 
 
 
 
 
 | 207 | { | 
 
 
 
 
 | 208 | ui->leGeometryName->setEnabled(checked); | 
 
 
 
 
 | 209 | if(checked){ | 
 
 
 
 
 | 210 | ui->cbCamera->setChecked(false); | 
 
 
 
 
 | 211 | } | 
 
 
 
 
 | 212 | } | 
 
 
 
 
 | 213 |  | 
 
 
 
 
 | 214 | void MainWindow::on_actionCheck_For_Updates_triggered() | 
 
 
 
 
 | 215 | { | 
 
 
 
 
 | 216 |  | 
 
 
 
 
 | 217 | //let's check in the web if this version is the latest | 
 
 
 
 
 | 218 | QNetworkAccessManager *manager = new QNetworkAccessManager(this); | 
 
 
 
 
 | 219 | connect(manager, SIGNAL(finished(QNetworkReply*)), | 
 
 
 
 
 | 220 | this, SLOT(checkVagoLastVersion(QNetworkReply*))); | 
 
 
 
 
 | 221 |  | 
 
 
 
 
 | 222 | manager->get(QNetworkRequest(QUrl(GlobalVars::VagoCheckUpdatesUrl))); | 
 
 
 
 
 | 223 |  | 
 
 
 
 
 | 224 | } | 
 
 
 
 
 | 225 |  | 
 
 
 
 
 | 226 | void MainWindow::checkVagoLastVersion(QNetworkReply *result){ | 
 
 
 
 
 | 227 |  | 
 
 
 
 
 | 228 | if(result->error()==QNetworkReply::NoError){ | 
 
 
 
 
 | 229 | QScriptEngine engine; | 
 
 
 
 
 | 230 | QScriptValue sc = engine.evaluate("(" + QString(result->readAll()) + ")"); | 
 
 
 
 
 | 231 |  | 
 
 
 
 
 | 232 | // "field_version":{"und":[{"value":"0.6a","format":null,"safe_value":"0.6a"}]} //Note the use of [{}] which means it's a array of 1 element with one object inside (so the use of [0] bellow | 
 
 
 
 
 | 233 |  | 
 
 
 
 
 | 234 | QString newVersion = sc.property("field_version").toObject().property("und").toObject().property("0").toObject().property("value").toString(); | 
 
 
 
 
 | 235 |  | 
 
 
 
 
 | 236 | if(newVersion!=GlobalVars::AppVersion){ | 
 
 
 
 
 | 237 | Util::showRichPopUp("There's a new version of Vago! (v"+newVersion+")<br/><br/>"+ | 
 
 
 
 
 | 238 | "You can download it <a href='"+GlobalVars::VagoWebUrl+"'>here</a>."); | 
 
 
 
 
 | 239 | } | 
 
 
 
 
 | 240 | else{ | 
 
 
 
 
 | 241 | Util::showPopUp("You are using last version."); | 
 
 
 
 
 | 242 | } | 
 
 
 
 
 | 243 | } | 
 
 
 
 
 | 244 | else{ | 
 
 
 
 
 | 245 | Util::showErrorPopUp("An error occurred checking last version:\n\n"+result->errorString()); | 
 
 
 
 
 | 246 | } | 
 
 
 
 
 | 247 | result->deleteLater(); | 
 
 
 
 
 | 248 | } | 
 
 
 
 
 | 249 |  | 
 
 
 
 
 | 250 | void MainWindow::on_pbAddSourceGeneral_clicked() | 
 
 
 
 
 | 251 | { | 
 
 
 
 
 | 252 | if(QString::compare(ui->cbFromGeneral->currentText(),"ONI",Qt::CaseSensitive)==0 && QString::compare(ui->cbToGeneral->currentText(),"DAT",Qt::CaseSensitive)==0){ //CaseSensitive is faster) | 
 
 
 
 
 | 253 | addFilesSource(ui->twSourcesGeneral,Util::multipleDirDialog("Choose folders with ONIs...")); | 
 
 
 
 
 | 254 | } | 
 
 
 
 
 | 255 | else{ | 
 
 
 
 
 | 256 | addFilesSource( ui->twSourcesGeneral,QFileDialog::getOpenFileNames(this,"Choose the files...","./" , "All Files (*.*)")); | 
 
 
 
 
 | 257 | } | 
 
 
 
 
 | 258 | } | 
 
 
 
 
 | 259 |  | 
 
 
 
 
 | 260 | void MainWindow::on_pbAddSourceTextures_clicked() | 
 
 
 
 
 | 261 | { | 
 
 
 
 
 | 262 | addFilesSource( ui->twSourcesTextures, QFileDialog::getOpenFileNames(this,"Choose the files...","./" , "All Files (*.*)")); | 
 
 
 
 
 | 263 | } | 
 
 
 
 
 | 264 |  | 
 
 
 
 
 | 265 | void MainWindow::on_pbAddSourceModels_clicked() | 
 
 
 
 
 | 266 | { | 
 
 
 
 
 | 267 | addFilesSource( ui->twSourcesModels,QFileDialog::getOpenFileNames(this,"Choose the files...","./" , "All Files (*.*)")); | 
 
 
 
 
 | 268 | } | 
 
 
 
 
 | 269 |  | 
 
 
 
 
 | 270 | void MainWindow::on_pbAddSourceAnimations_clicked() | 
 
 
 
 
 | 271 | { | 
 
 
 
 
 | 272 | addFilesSource( ui->twSourcesAnimations,QFileDialog::getOpenFileNames(this,"Choose the files...","./" , "All Files (*.*)")); | 
 
 
 
 
 | 273 | } | 
 
 
 
 
 | 274 |  | 
 
 
 
 
 | 275 | void MainWindow::on_pbAddSourceLevels_clicked() | 
 
 
 
 
 | 276 | { | 
 
 
 
 
 | 277 | addFilesSource( ui->twSourcesLevels,QFileDialog::getOpenFileNames(this,"Choose the files...","./" , "All Files (*.*)")); | 
 
 
 
 
 | 278 | } | 
 
 
 
 
 | 279 |  | 
 
 
 
 
 | 280 | void MainWindow::on_pbAddSourceMisc_clicked() | 
 
 
 
 
 | 281 | { | 
 
 
 
 
 | 282 | addFilesSource( ui->twSourcesMisc,QFileDialog::getOpenFileNames(this,"Choose the files...","./" , "All Files (*.*)")); | 
 
 
 
 
 | 283 | } | 
 
 
 
 
 | 284 |  | 
 
 
 
 
 | 285 | QString MainWindow::getFileOutputFolder(QString fromTo, QString myOutputFolder){ | 
 
 
 
 
 | 286 |  | 
 
 
 
 
 | 287 | if(myOutputFolder==""){ //We may want to change to a non standart location with context menu | 
 
 
 
 
 | 288 | myOutputFolder=this->outputFolder; | 
 
 
 
 
 | 289 | } | 
 
 
 
 
 | 290 |  | 
 
 
 
 
 | 291 | if(this->vagoSettings->value("SeparateInWorkspace").toBool() && myOutputFolder==this->workspaceLocation){ | 
 
 
 
 
 | 292 | myOutputFolder+="/"+ui->tabWidget->tabText(ui->tabWidget->currentIndex()); | 
 
 
 
 
 | 293 | myOutputFolder+="/"+QString(fromTo).replace(" / ","_").replace(" > "," - "); | 
 
 
 
 
 | 294 | } | 
 
 
 
 
 | 295 | return Util::insertQuotes(myOutputFolder+"/"); | 
 
 
 
 
 | 296 | } | 
 
 
 
 
 | 297 |  | 
 
 
 
 
 | 298 | void MainWindow::addFilesSource(DropTableWidget *myTable, QStringList files){ | 
 
 
 
 
 | 299 |  | 
 
 
 
 
 | 300 | //Get Conversion pretended | 
 
 
 
 
 | 301 | QString from,to; | 
 
 
 
 
 | 302 |  | 
 
 
 
 
 | 303 | QString fromTo = getTypeConversion(myTable); | 
 
 
 
 
 | 304 |  | 
 
 
 
 
 | 305 | 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 | 
 
 
 
 
 | 306 | to = QString(fromTo).remove(0,fromTo.lastIndexOf("> ")+2); //+2 to start after "> " | 
 
 
 
 
 | 307 |  | 
 
 
 
 
 | 308 | //Pre-processing (check if the files/folders received are valid), e.g. check for ONI->DAT if are only given folders and not files | 
 
 
 
 
 | 309 | if(QString::compare(from,"ONI",Qt::CaseSensitive)==0 && QString::compare(to,"DAT",Qt::CaseSensitive)==0){ | 
 
 
 
 
 | 310 | //check if it's a folder | 
 
 
 
 
 | 311 | foreach(QString myFile, files){ | 
 
 
 
 
 | 312 | if(!QDir(myFile).exists()){ | 
 
 
 
 
 | 313 | showErrStatusMessage("Only folders are allowed for this operation."); | 
 
 
 
 
 | 314 | return; | 
 
 
 
 
 | 315 | } | 
 
 
 
 
 | 316 | } | 
 
 
 
 
 | 317 |  | 
 
 
 
 
 | 318 | } | 
 
 
 
 
 | 319 | else{ | 
 
 
 
 
 | 320 | foreach(QString myFile, files){ | 
 
 
 
 
 | 321 | //check if it's a file | 
 
 
 
 
 | 322 | if(QDir(myFile).exists()){ | 
 
 
 
 
 | 323 | showErrStatusMessage("Only files are allowed for this operation."); | 
 
 
 
 
 | 324 | return; | 
 
 
 
 
 | 325 | } | 
 
 
 
 
 | 326 | } | 
 
 
 
 
 | 327 | } | 
 
 
 
 
 | 328 |  | 
 
 
 
 
 | 329 | //Build command | 
 
 
 
 
 | 330 | QString command, lastFileName; | 
 
 
 
 
 | 331 |  | 
 
 
 
 
 | 332 | QString myOutputFolder=getFileOutputFolder(fromTo); | 
 
 
 
 
 | 333 |  | 
 
 
 
 
 | 334 | //if folder doesn't exist onisplit will create it for us :) | 
 
 
 
 
 | 335 | foreach(QString currentFile, files){ | 
 
 
 
 
 | 336 |  | 
 
 
 
 
 | 337 | currentFile=Util::normalizeAndQuote(currentFile); //insert quotes ("") in file | 
 
 
 
 
 | 338 |  | 
 
 
 
 
 | 339 | if(lastFileName.isEmpty()){ //Optimization: all commands are the same for each file, just replace the filename | 
 
 
 
 
 | 340 |  | 
 
 
 
 
 | 341 | command=getCommand(myTable,myOutputFolder,from,to,currentFile); | 
 
 
 
 
 | 342 |  | 
 
 
 
 
 | 343 | if(command.isEmpty()){ //something wrong was happening (not inputted a texture name?) | 
 
 
 
 
 | 344 | return; //stop adding files | 
 
 
 
 
 | 345 | } | 
 
 
 
 
 | 346 | currentFile=Util::cutName(currentFile); | 
 
 
 
 
 | 347 | }else{ //one parsing was already made just replace the filename by the old one in the command | 
 
 
 
 
 | 348 |  | 
 
 
 
 
 | 349 | currentFile=Util::cutName(currentFile); | 
 
 
 
 
 | 350 |  | 
 
 
 
 
 | 351 | command.replace(lastFileName,currentFile,Qt::CaseSensitive); //case sentive is faster | 
 
 
 
 
 | 352 | } | 
 
 
 
 
 | 353 |  | 
 
 
 
 
 | 354 | lastFileName=currentFile; | 
 
 
 
 
 | 355 |  | 
 
 
 
 
 | 356 | addRowTable(myTable,lastFileName,fromTo,command); | 
 
 
 
 
 | 357 | } | 
 
 
 
 
 | 358 | updateItemsLoaded(myTable); | 
 
 
 
 
 | 359 | } | 
 
 
 
 
 | 360 |  | 
 
 
 
 
 | 361 | QString MainWindow::fileParsingGeneral(QString myOutputFolder, QString from, QString to , QString file){ | 
 
 
 
 
 | 362 |  | 
 
 
 
 
 | 363 | QString command; | 
 
 
 
 
 | 364 |  | 
 
 
 
 
 | 365 | if(QString::compare(from,"ONI",Qt::CaseSensitive)==0 && QString::compare(to,"DAT",Qt::CaseSensitive)==0){ //CaseSensitive is faster | 
 
 
 
 
 | 366 |  | 
 
 
 
 
 | 367 | QString datName; | 
 
 
 
 
 | 368 |  | 
 
 
 
 
 | 369 | if(ui->cbDatGeneral->isChecked()){ | 
 
 
 
 
 | 370 | if(ui->leTargetDatGeneral->text().isEmpty()){ | 
 
 
 
 
 | 371 | showErrStatusMessage("Checkbox '"+ui->cbDatGeneral->text()+"' is selected. The name cannot be empty."); | 
 
 
 
 
 | 372 | return ""; | 
 
 
 
 
 | 373 | } | 
 
 
 
 
 | 374 | datName+=QString(myOutputFolder).insert(myOutputFolder.size()-1,ui->leTargetDatGeneral->text()); //set name inputted by user | 
 
 
 
 
 | 375 | if(!ui->leTargetDatGeneral->text().toUpper().endsWith(".DAT")){ | 
 
 
 
 
 | 376 | datName.insert(datName.size()-1,".dat"); //append extension if necessary (-1 to maintain final quote) | 
 
 
 
 
 | 377 | } | 
 
 
 
 
 | 378 | } | 
 
 
 
 
 | 379 | else{ | 
 
 
 
 
 | 380 | datName=QString(myOutputFolder).insert(myOutputFolder.size()-1,Util::cutName(file).remove("/")+".dat"); //if none iputted set the same name of input file | 
 
 
 
 
 | 381 | } | 
 
 
 
 
 | 382 |  | 
 
 
 
 
 | 383 | if(ui->actionWindows->isChecked()){ //is target plataform select windows? | 
 
 
 
 
 | 384 | return command=this->commandMap.value("general->"+from+"->"+to+"(PC)")+" "+ file + " "+datName; | 
 
 
 
 
 | 385 | } | 
 
 
 
 
 | 386 | else{ | 
 
 
 
 
 | 387 | return command=this->commandMap.value("general->"+from+"->"+to+"(demoPCMAC)")+" "+ file + " "+datName; | 
 
 
 
 
 | 388 | } | 
 
 
 
 
 | 389 | } | 
 
 
 
 
 | 390 | else if(QString::compare(from,"ONI",Qt::CaseSensitive)==0 && QString::compare(to,"XML",Qt::CaseSensitive)==0 && ui->cbTRAMGeneral->isChecked()){ | 
 
 
 
 
 | 391 | if(ui->leTRAMGeneral->text().isEmpty()){ | 
 
 
 
 
 | 392 | showErrStatusMessage("Checkbox '"+ui->cbTRAMGeneral->text()+"' is selected. The source cannot be empty."); | 
 
 
 
 
 | 393 | return ""; | 
 
 
 
 
 | 394 | } | 
 
 
 
 
 | 395 | return command=this->commandMap.value("general->"+from+"->"+to)+" "+myOutputFolder+" "+this->commandMap.value("general->"+ui->cbTRAMGeneral->text())+file + " "+ Util::normalizeAndQuote(ui->leTRAMGeneral->text()); | 
 
 
 
 
 | 396 | } | 
 
 
 
 
 | 397 | else{ | 
 
 
 
 
 | 398 | return command=this->commandMap.value("general->"+from+"->"+to)+" "+myOutputFolder+" "+file; | 
 
 
 
 
 | 399 | } | 
 
 
 
 
 | 400 |  | 
 
 
 
 
 | 401 | } | 
 
 
 
 
 | 402 |  | 
 
 
 
 
 | 403 | QString MainWindow::fileParsingTextures(QString myOutputFolder, QString from, QString to , QString file){ | 
 
 
 
 
 | 404 |  | 
 
 
 
 
 | 405 | QString command=this->commandMap.value("textures->"+from+"->"+to)+" "+myOutputFolder; | 
 
 
 
 
 | 406 |  | 
 
 
 
 
 | 407 | if(ui->gbTextures->isEnabled()){ //faster than compare strings (if is DAT/ONI) | 
 
 
 
 
 | 408 |  | 
 
 
 
 
 | 409 | if(ui->cbMipMapsTextures->isChecked()){ | 
 
 
 
 
 | 410 | command+=" "+this->commandMap.value("textures->"+ui->cbMipMapsTextures->text()); | 
 
 
 
 
 | 411 | } | 
 
 
 
 
 | 412 |  | 
 
 
 
 
 | 413 | if(ui->cbNoUwrap->isChecked()){ | 
 
 
 
 
 | 414 | command+=" "+this->commandMap.value("textures->"+ui->cbNoUwrap->text()); | 
 
 
 
 
 | 415 | } | 
 
 
 
 
 | 416 |  | 
 
 
 
 
 | 417 | if(ui->cbNoVwrap->isChecked()){ | 
 
 
 
 
 | 418 | command+=" "+this->commandMap.value("textures->"+ui->cbNoVwrap->text()); | 
 
 
 
 
 | 419 | } | 
 
 
 
 
 | 420 |  | 
 
 
 
 
 | 421 | if(ui->cbLarge->isChecked()){ | 
 
 
 
 
 | 422 | command+=" "+this->commandMap.value("textures->"+ui->cbLarge->text()); | 
 
 
 
 
 | 423 | } | 
 
 
 
 
 | 424 |  | 
 
 
 
 
 | 425 | if(ui->rbBGR32->isChecked()){ | 
 
 
 
 
 | 426 | command+=" "+this->commandMap.value("textures->"+ui->rbBGR32->text()); | 
 
 
 
 
 | 427 | } | 
 
 
 
 
 | 428 | else if(ui->rbBGRA32->isChecked()){ | 
 
 
 
 
 | 429 | command+=" "+this->commandMap.value("textures->"+ui->rbBGRA32->text()); | 
 
 
 
 
 | 430 | } | 
 
 
 
 
 | 431 | else if(ui->rbBGR555->isChecked()){ | 
 
 
 
 
 | 432 | command+=" "+this->commandMap.value("textures->"+ui->rbBGR555->text()); | 
 
 
 
 
 | 433 | } | 
 
 
 
 
 | 434 | else if(ui->rbBGRA5551->isChecked()){ | 
 
 
 
 
 | 435 | command+=" "+this->commandMap.value("textures->"+ui->rbBGRA5551->text()); | 
 
 
 
 
 | 436 | } | 
 
 
 
 
 | 437 | else if(ui->rbBGRA444->isChecked()){ | 
 
 
 
 
 | 438 | command+=" "+this->commandMap.value("textures->"+ui->rbBGRA444->text()); | 
 
 
 
 
 | 439 | } | 
 
 
 
 
 | 440 | else{ //dxt1 checked | 
 
 
 
 
 | 441 | command+=" "+this->commandMap.value("textures->"+ui->rbDxt1->text()); | 
 
 
 
 
 | 442 | } | 
 
 
 
 
 | 443 |  | 
 
 
 
 
 | 444 | if(ui->cbEnvMap->isChecked()){ | 
 
 
 
 
 | 445 | if(ui->leEnvMapTexture->text().isEmpty()){ | 
 
 
 
 
 | 446 | showErrStatusMessage("Checkbox '"+ui->cbEnvMap->text()+"' is selected. The name texture name cannot be empty."); | 
 
 
 
 
 | 447 | return ""; | 
 
 
 
 
 | 448 | } | 
 
 
 
 
 | 449 | command+=" "+this->commandMap.value("textures->"+ui->cbEnvMap->text()) + ui->leEnvMapTexture->text().remove(".oni",Qt::CaseInsensitive); | 
 
 
 
 
 | 450 | } | 
 
 
 
 
 | 451 | } | 
 
 
 
 
 | 452 |  | 
 
 
 
 
 | 453 | return command+=" "+file; //add source | 
 
 
 
 
 | 454 | } | 
 
 
 
 
 | 455 |  | 
 
 
 
 
 | 456 | QString MainWindow::fileParsingModels(QString myOutputFolder, QString from, QString to , QString file){ | 
 
 
 
 
 | 457 |  | 
 
 
 
 
 | 458 | QString command=this->commandMap.value("models->"+from+"->"+to)+" "+myOutputFolder; | 
 
 
 
 
 | 459 |  | 
 
 
 
 
 | 460 | //TODO: This can be optimized. When some are not enable others are. | 
 
 
 
 
 | 461 | if(ui->cbTexture->isChecked()){ | 
 
 
 
 
 | 462 | if(ui->leTextureName->text().isEmpty()){ | 
 
 
 
 
 | 463 | showErrStatusMessage("Checkbox '"+ui->cbTexture->text()+"' is selected. The name cannot be empty."); | 
 
 
 
 
 | 464 | return ""; | 
 
 
 
 
 | 465 | } | 
 
 
 
 
 | 466 | command+=" "+this->commandMap.value("models->"+ui->cbTexture->text()) + ui->leTextureName->text().remove(".oni",Qt::CaseInsensitive); | 
 
 
 
 
 | 467 | } | 
 
 
 
 
 | 468 |  | 
 
 
 
 
 | 469 | if(ui->cbCellShading->isChecked()){ | 
 
 
 
 
 | 470 | command+=" "+this->commandMap.value("models->"+ui->cbCellShading->text()); | 
 
 
 
 
 | 471 | } | 
 
 
 
 
 | 472 |  | 
 
 
 
 
 | 473 | if(ui->cbNormals->isChecked()){ | 
 
 
 
 
 | 474 | command+=" "+this->commandMap.value("models->"+ui->cbNormals->text()); | 
 
 
 
 
 | 475 | } | 
 
 
 
 
 | 476 |  | 
 
 
 
 
 | 477 | if(ui->cbWithAnimation->isEnabled()){ | 
 
 
 
 
 | 478 | if(ui->cbWithAnimation->isChecked()){ | 
 
 
 
 
 | 479 | command+=" "+this->commandMap.value("models->"+ui->cbWithAnimation->text())+ui->leAnimationName->text().remove(".oni",Qt::CaseInsensitive); | 
 
 
 
 
 | 480 | } | 
 
 
 
 
 | 481 | else{ | 
 
 
 
 
 | 482 | command+=" "+this->commandMap.value("models->No Animation"); | 
 
 
 
 
 | 483 | } | 
 
 
 
 
 | 484 | } | 
 
 
 
 
 | 485 |  | 
 
 
 
 
 | 486 |  | 
 
 
 
 
 | 487 | return command+=" "+file; //add source | 
 
 
 
 
 | 488 | } | 
 
 
 
 
 | 489 |  | 
 
 
 
 
 | 490 | QString MainWindow::fileParsingAnimations(QString myOutputFolder, QString from, QString to , QString file){ | 
 
 
 
 
 | 491 |  | 
 
 
 
 
 | 492 | QString command=this->commandMap.value("animations->"+from+"->"+to)+" "+myOutputFolder + " " + file ; | 
 
 
 
 
 | 493 |  | 
 
 
 
 
 | 494 | if(ui->cbCamera->isChecked()){ | 
 
 
 
 
 | 495 | command+=" "+this->commandMap.value("animations->"+ui->cbCamera->text()); | 
 
 
 
 
 | 496 | } | 
 
 
 
 
 | 497 | else if(ui->cbGeometry->isChecked()){ | 
 
 
 
 
 | 498 | if(ui->leGeometryName->text().isEmpty()){ | 
 
 
 
 
 | 499 | showErrStatusMessage("Checkbox '"+ui->cbGeometry->text()+"' is selected. The geometry file path cannot be empty."); | 
 
 
 
 
 | 500 | return ""; | 
 
 
 
 
 | 501 | } | 
 
 
 
 
 | 502 | command+=" "+this->commandMap.value("animations->"+ui->cbGeometry->text()) + (ui->leGeometryName->text().startsWith('"')?ui->leGeometryName->text():Util::insertQuotes(ui->leGeometryName->text())); | 
 
 
 
 
 | 503 | } | 
 
 
 
 
 | 504 |  | 
 
 
 
 
 | 505 | return command; | 
 
 
 
 
 | 506 | } | 
 
 
 
 
 | 507 |  | 
 
 
 
 
 | 508 | QString MainWindow::fileParsingLevels(QString myOutputFolder, QString from, QString to , QString file){ | 
 
 
 
 
 | 509 |  | 
 
 
 
 
 | 510 | QString datName, command; | 
 
 
 
 
 | 511 |  | 
 
 
 
 
 | 512 | command=this->commandMap.value("levels->"+from+"->"+to)+" "+myOutputFolder+" "+file; | 
 
 
 
 
 | 513 |  | 
 
 
 
 
 | 514 | if(from=="MASTER XML" && to=="DAT"){ | 
 
 
 
 
 | 515 | command+=GlobalVars::OniSplitProcSeparator; //insert mark so we know this action will take 2 commands | 
 
 
 
 
 | 516 |  | 
 
 
 
 
 | 517 | QString datName; | 
 
 
 
 
 | 518 | if(ui->cbDatLevels->isChecked()){ | 
 
 
 
 
 | 519 | if(ui->leTargetDatLevels->text().isEmpty()){ | 
 
 
 
 
 | 520 | showErrStatusMessage("Checkbox '"+ui->cbDatLevels->text()+"' is selected. The name cannot be empty."); | 
 
 
 
 
 | 521 | return ""; | 
 
 
 
 
 | 522 | } | 
 
 
 
 
 | 523 | datName+=QString(myOutputFolder).insert(myOutputFolder.size()-1,ui->leTargetDatLevels->text()); //set name inputted by user | 
 
 
 
 
 | 524 | if(!ui->leTargetDatLevels->text().toUpper().endsWith(".DAT")){ | 
 
 
 
 
 | 525 | datName.insert(datName.size()-1,".dat"); //append extension if necessary (-1 to maintain final quote) | 
 
 
 
 
 | 526 | } | 
 
 
 
 
 | 527 | } | 
 
 
 
 
 | 528 | else{ | 
 
 
 
 
 | 529 | 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 | 
 
 
 
 
 | 530 | } | 
 
 
 
 
 | 531 |  | 
 
 
 
 
 | 532 | if(ui->actionWindows->isChecked()){ //is target plataform select windows? | 
 
 
 
 
 | 533 | command+=this->commandMap.value("general->ONI->"+to+"(PC)")+" "+myOutputFolder+" "+datName; //add second command | 
 
 
 
 
 | 534 | } | 
 
 
 
 
 | 535 | else{ | 
 
 
 
 
 | 536 | command+=this->commandMap.value("general->ONI->"+to+"(demoPCMAC)")+" "+myOutputFolder+" "+datName; //add second command | 
 
 
 
 
 | 537 | } | 
 
 
 
 
 | 538 | } | 
 
 
 
 
 | 539 |  | 
 
 
 
 
 | 540 | if(ui->cbBnvLevels->isChecked()){ | 
 
 
 
 
 | 541 |  | 
 
 
 
 
 | 542 | if(ui->leBnvLevels->text().isEmpty()){ | 
 
 
 
 
 | 543 | showErrStatusMessage("Checkbox '"+ui->cbBnvLevels->text()+"' is selected. The BNV file cannot be empty."); | 
 
 
 
 
 | 544 | return ""; | 
 
 
 
 
 | 545 | } | 
 
 
 
 
 | 546 | command+=" "+Util::normalizeAndQuote(ui->leBnvLevels->text()); | 
 
 
 
 
 | 547 | } | 
 
 
 
 
 | 548 |  | 
 
 
 
 
 | 549 | if(ui->cbAdditionalSourcesLevels->isChecked()){ | 
 
 
 
 
 | 550 |  | 
 
 
 
 
 | 551 | if(ui->leAdditSourcesLevels->text().isEmpty()){ | 
 
 
 
 
 | 552 | showErrStatusMessage("Checkbox '"+ui->cbAdditionalSourcesLevels->text()+"' is selected. The source files cannot be empty."); | 
 
 
 
 
 | 553 | return ""; | 
 
 
 
 
 | 554 | } | 
 
 
 
 
 | 555 |  | 
 
 
 
 
 | 556 | QString additionalFiles=ui->leAdditSourcesLevels->text(); | 
 
 
 
 
 | 557 |  | 
 
 
 
 
 | 558 | int currentIndex=0, nextIndex=0; | 
 
 
 
 
 | 559 |  | 
 
 
 
 
 | 560 | //parse all files (separated by spaces) | 
 
 
 
 
 | 561 | while(true){ | 
 
 
 
 
 | 562 | nextIndex=additionalFiles.indexOf(" ",currentIndex+1); | 
 
 
 
 
 | 563 |  | 
 
 
 
 
 | 564 | command += " "+Util::normalizeAndQuote(additionalFiles.mid(currentIndex,(nextIndex-currentIndex))); | 
 
 
 
 
 | 565 |  | 
 
 
 
 
 | 566 | if(nextIndex==-1){ //we got to the end, stop parsing | 
 
 
 
 
 | 567 | break; | 
 
 
 
 
 | 568 | } | 
 
 
 
 
 | 569 | currentIndex=nextIndex+1; //update currentIndex +1 for start after the separator | 
 
 
 
 
 | 570 | } | 
 
 
 
 
 | 571 | } | 
 
 
 
 
 | 572 |  | 
 
 
 
 
 | 573 | if(ui->cbGridsLevels->isChecked()){ | 
 
 
 
 
 | 574 | command+=GlobalVars::OniSplitProcSeparator+this->commandMap.value("levels->"+ui->cbGridsLevels->text())+" "+Util::normalizeAndQuote(ui->leBnvLevels->text())+" "+file+" -out:"+myOutputFolder; | 
 
 
 
 
 | 575 | } | 
 
 
 
 
 | 576 |  | 
 
 
 
 
 | 577 | return command; | 
 
 
 
 
 | 578 | } | 
 
 
 
 
 | 579 |  | 
 
 
 
 
 | 580 | QString MainWindow::fileParsingMisc(QString myOutputFolder, QString from, QString to , QString file){ | 
 
 
 
 
 | 581 | return this->commandMap.value("misc->"+from+"->"+to)+" "+myOutputFolder+" "+file; | 
 
 
 
 
 | 582 | } | 
 
 
 
 
 | 583 |  | 
 
 
 
 
 | 584 | void MainWindow::addRowTable(DropTableWidget *myTable, QString fileName, QString fromTo, QString command){ | 
 
 
 
 
 | 585 | //Get actual number rows | 
 
 
 
 
 | 586 | int twSize=myTable->rowCount(); | 
 
 
 
 
 | 587 |  | 
 
 
 
 
 | 588 | //increase the rows for the new item | 
 
 
 
 
 | 589 | myTable->setRowCount(twSize+1); | 
 
 
 
 
 | 590 |  | 
 
 
 
 
 | 591 | //Add to table and list to | 
 
 
 
 
 | 592 | QTableWidgetItem *newFile = new QTableWidgetItem(fileName); | 
 
 
 
 
 | 593 | QTableWidgetItem *newConversion = new QTableWidgetItem(fromTo); | 
 
 
 
 
 | 594 | QTableWidgetItem *newCommand = new QTableWidgetItem(command); | 
 
 
 
 
 | 595 |  | 
 
 
 
 
 | 596 | myTable->setItem(twSize,0,newFile); | 
 
 
 
 
 | 597 | myTable->setItem(twSize,1,newConversion); | 
 
 
 
 
 | 598 | myTable->setItem(twSize,2,newCommand); | 
 
 
 
 
 | 599 |  | 
 
 
 
 
 | 600 | myTable->updateTableToolTips(twSize); //Update tool tips | 
 
 
 
 
 | 601 | } | 
 
 
 
 
 | 602 |  | 
 
 
 
 
 | 603 | void MainWindow::on_pbConvertGeneral_clicked() | 
 
 
 
 
 | 604 | { | 
 
 
 
 
 | 605 | startConversion(ui->twSourcesGeneral); | 
 
 
 
 
 | 606 | } | 
 
 
 
 
 | 607 |  | 
 
 
 
 
 | 608 | void MainWindow::on_pbConvertTextures_clicked() | 
 
 
 
 
 | 609 | { | 
 
 
 
 
 | 610 | startConversion(ui->twSourcesTextures); | 
 
 
 
 
 | 611 | } | 
 
 
 
 
 | 612 |  | 
 
 
 
 
 | 613 | void MainWindow::on_pbConvertModels_clicked() | 
 
 
 
 
 | 614 | { | 
 
 
 
 
 | 615 | startConversion(ui->twSourcesModels); | 
 
 
 
 
 | 616 | } | 
 
 
 
 
 | 617 |  | 
 
 
 
 
 | 618 | void MainWindow::on_pbConvertAnimations_clicked() | 
 
 
 
 
 | 619 | { | 
 
 
 
 
 | 620 | startConversion(ui->twSourcesAnimations); | 
 
 
 
 
 | 621 | } | 
 
 
 
 
 | 622 |  | 
 
 
 
 
 | 623 | void MainWindow::on_pbConvertLevels_clicked() | 
 
 
 
 
 | 624 | { | 
 
 
 
 
 | 625 | startConversion(ui->twSourcesLevels); | 
 
 
 
 
 | 626 | } | 
 
 
 
 
 | 627 |  | 
 
 
 
 
 | 628 | void MainWindow::on_pbConvertMisc_clicked() | 
 
 
 
 
 | 629 | { | 
 
 
 
 
 | 630 | startConversion(ui->twSourcesMisc); | 
 
 
 
 
 | 631 | } | 
 
 
 
 
 | 632 |  | 
 
 
 
 
 | 633 | void MainWindow::startConversion(DropTableWidget *myTable){ | 
 
 
 
 
 | 634 |  | 
 
 
 
 
 | 635 | bool ready=false; | 
 
 
 
 
 | 636 | for(int i=0; i<myTable->rowCount(); i++){ //There are items to process? | 
 
 
 
 
 | 637 | if(myTable->item(i,2)->background()!=myTable->disabledBackStyle){ | 
 
 
 
 
 | 638 | ready=true; | 
 
 
 
 
 | 639 | break; | 
 
 
 
 
 | 640 | } | 
 
 
 
 
 | 641 | } | 
 
 
 
 
 | 642 |  | 
 
 
 
 
 | 643 | if(!ready){ | 
 
 
 
 
 | 644 | showErrStatusMessage("Please add sources to convert first."); | 
 
 
 
 
 | 645 | return; | 
 
 
 
 
 | 646 | } | 
 
 
 
 
 | 647 |  | 
 
 
 
 
 | 648 | if(myBar->isVisible()){ | 
 
 
 
 
 | 649 | Util::showErrorPopUp("Another conversion is progress. Please wait until it finishes."); | 
 
 
 
 
 | 650 | return; | 
 
 
 
 
 | 651 | } | 
 
 
 
 
 | 652 |  | 
 
 
 
 
 | 653 | for(int i=0; i<myTable->rowCount(); i++){ | 
 
 
 
 
 | 654 | //Only process enabled items | 
 
 
 
 
 | 655 | if(myTable->item(i,2)->background()!=myTable->disabledBackStyle){ | 
 
 
 
 
 | 656 | this->listToProccess->append(myTable->item(i,2)->text()); | 
 
 
 
 
 | 657 | } | 
 
 
 
 
 | 658 | } | 
 
 
 
 
 | 659 |  | 
 
 
 
 
 | 660 | this->myConverter->start(); | 
 
 
 
 
 | 661 | } | 
 
 
 
 
 | 662 |  | 
 
 
 
 
 | 663 | void MainWindow::TsetupProgressBar(int max){ | 
 
 
 
 
 | 664 | this->myBar->setValue(0); | 
 
 
 
 
 | 665 | this->myBar->show(); | 
 
 
 
 
 | 666 | this->myBar->setMaximum(max); | 
 
 
 
 
 | 667 | } | 
 
 
 
 
 | 668 |  | 
 
 
 
 
 | 669 | void  MainWindow::TupdateProgressBar(){ | 
 
 
 
 
 | 670 | this->myBar->setValue(this->myBar->value()+1); //more one task done | 
 
 
 
 
 | 671 | } | 
 
 
 
 
 | 672 |  | 
 
 
 
 
 | 673 | void MainWindow::TresultConversion(QString result, int numErrors){ | 
 
 
 
 
 | 674 | QApplication::alert(this); //Show a notification if window is not active | 
 
 
 
 
 | 675 | this->myBar->hide(); | 
 
 
 
 
 | 676 |  | 
 
 
 
 
 | 677 | if(numErrors!=0){ | 
 
 
 
 
 | 678 | QString sNumErrors=QString::number(numErrors); | 
 
 
 
 
 | 679 | if(numErrors>1){ | 
 
 
 
 
 | 680 | Util::showErrorLogPopUp(result+"\n This is the last of "+sNumErrors+" Errors."); | 
 
 
 
 
 | 681 | showErrStatusMessage("Something gone wrong. Check log file ("+sNumErrors+" Errors)."); | 
 
 
 
 
 | 682 | } | 
 
 
 
 
 | 683 | else{ | 
 
 
 
 
 | 684 | Util::showErrorLogPopUp(result); | 
 
 
 
 
 | 685 | showErrStatusMessage("Something gone wrong. Check log file."); | 
 
 
 
 
 | 686 | } | 
 
 
 
 
 | 687 |  | 
 
 
 
 
 | 688 | } | 
 
 
 
 
 | 689 | else{ | 
 
 
 
 
 | 690 | showSuccessStatusMessage("Everything went well!"); | 
 
 
 
 
 | 691 | } | 
 
 
 
 
 | 692 | } | 
 
 
 
 
 | 693 |  | 
 
 
 
 
 | 694 | void MainWindow::showErrStatusMessage(QString message){ | 
 
 
 
 
 | 695 |  | 
 
 
 
 
 | 696 | QPalette myPalete = QPalette(); | 
 
 
 
 
 | 697 | myPalete.setColor( QPalette::WindowText, QColor(255,0,0)); | 
 
 
 
 
 | 698 | statusBar()->setPalette( myPalete ); | 
 
 
 
 
 | 699 | ui->statusBar->showMessage(message,10000); //display by 10 seconds | 
 
 
 
 
 | 700 |  | 
 
 
 
 
 | 701 | } | 
 
 
 
 
 | 702 |  | 
 
 
 
 
 | 703 | void MainWindow::showSuccessStatusMessage(QString message){ | 
 
 
 
 
 | 704 |  | 
 
 
 
 
 | 705 | QPalette myPalete = QPalette(); | 
 
 
 
 
 | 706 | myPalete.setColor( QPalette::WindowText, QColor(0,150,0)); | 
 
 
 
 
 | 707 | statusBar()->setPalette( myPalete ); | 
 
 
 
 
 | 708 | ui->statusBar->showMessage(message,10000); //display by 10 seconds | 
 
 
 
 
 | 709 |  | 
 
 
 
 
 | 710 | } | 
 
 
 
 
 | 711 |  | 
 
 
 
 
 | 712 | void MainWindow::mapCommands(){ | 
 
 
 
 
 | 713 | ////////////////////////////////////////////////////////////////////////General Commands | 
 
 
 
 
 | 714 | this->commandMap.insert("general->DAT->ONI","-export"); | 
 
 
 
 
 | 715 | //this->commandMap.insert("general->ONI->DAT","-import"); //Not used. | 
 
 
 
 
 | 716 | this->commandMap.insert("general->ONI->DAT(PC)","-import:nosep"); | 
 
 
 
 
 | 717 | this->commandMap.insert("general->ONI->DAT(demoPCMAC)","-import:sep"); | 
 
 
 
 
 | 718 | this->commandMap.insert("general->ONI->XML","-extract:xml"); | 
 
 
 
 
 | 719 | this->commandMap.insert("general->XML->ONI","-create"); | 
 
 
 
 
 | 720 | //######################General Options | 
 
 
 
 
 | 721 | this->commandMap.insert("general->"+ui->cbTRAMGeneral->text(),"-anim-body:"); | 
 
 
 
 
 | 722 | //Possible Combinations | 
 
 
 
 
 | 723 | this->commandMap.insertMulti("general->DAT","ONI"); | 
 
 
 
 
 | 724 | this->commandMap.insertMulti("general->ONI","DAT"); | 
 
 
 
 
 | 725 | this->commandMap.insertMulti("general->ONI","XML"); | 
 
 
 
 
 | 726 | this->commandMap.insertMulti("general->XML","ONI"); | 
 
 
 
 
 | 727 |  | 
 
 
 
 
 | 728 | ////////////////////////////////////////////////////////////////////////Textures Commands | 
 
 
 
 
 | 729 | this->commandMap.insert("textures->DAT / ONI->DDS","-extract:dds"); | 
 
 
 
 
 | 730 | this->commandMap.insert("textures->DAT / ONI->TGA","-extract:tga"); | 
 
 
 
 
 | 731 | this->commandMap.insert("textures->DAT / ONI->PNG","-extract:png"); | 
 
 
 
 
 | 732 | this->commandMap.insert("textures->DAT / ONI->JPG","-extract:jpg"); | 
 
 
 
 
 | 733 | this->commandMap.insert("textures->DDS / TGA / PNG / JPG->ONI","-create:txmp"); | 
 
 
 
 
 | 734 | //######################Textures Options | 
 
 
 
 
 | 735 | this->commandMap.insert("textures->"+ui->rbBGR32->text(),"-format:bgr32"); | 
 
 
 
 
 | 736 | this->commandMap.insert("textures->"+ui->rbBGRA32->text(),"-format:bgra32"); | 
 
 
 
 
 | 737 | this->commandMap.insert("textures->"+ui->rbBGR555->text(),"-format:bgr555"); | 
 
 
 
 
 | 738 | this->commandMap.insert("textures->"+ui->rbBGRA5551->text(),"-format:bgra5551"); | 
 
 
 
 
 | 739 | this->commandMap.insert("textures->"+ui->rbBGRA444->text(),"-format:bgra4444"); | 
 
 
 
 
 | 740 | this->commandMap.insert("textures->"+ui->rbDxt1->text(),"-format:dxt1"); | 
 
 
 
 
 | 741 | this->commandMap.insert("textures->"+ui->cbMipMapsTextures->text(),"-genmipmaps"); | 
 
 
 
 
 | 742 | this->commandMap.insert("textures->"+ui->cbNoUwrap->text(),"-nouwrap"); | 
 
 
 
 
 | 743 | this->commandMap.insert("textures->"+ui->cbNoVwrap->text(),"-novwrap"); | 
 
 
 
 
 | 744 | this->commandMap.insert("textures->"+ui->cbLarge->text(),"-large"); | 
 
 
 
 
 | 745 | this->commandMap.insert("textures->"+ui->cbEnvMap->text(),"-envmap:"); | 
 
 
 
 
 | 746 | //Possible Combinations | 
 
 
 
 
 | 747 | this->commandMap.insertMulti("textures->DAT / ONI","DDS"); | 
 
 
 
 
 | 748 | this->commandMap.insertMulti("textures->DAT / ONI","TGA"); | 
 
 
 
 
 | 749 | this->commandMap.insertMulti("textures->DAT / ONI","PNG"); | 
 
 
 
 
 | 750 | this->commandMap.insertMulti("textures->DAT / ONI","JPG"); | 
 
 
 
 
 | 751 | this->commandMap.insertMulti("textures->DDS / TGA / PNG / JPG","ONI"); | 
 
 
 
 
 | 752 |  | 
 
 
 
 
 | 753 | ////////////////////////////////////////////////////////////////////////Models Commands | 
 
 
 
 
 | 754 | this->commandMap.insert("models->ONI->OBJ","-extract:obj"); | 
 
 
 
 
 | 755 | this->commandMap.insert("models->ONI->DAE","-extract:dae -search "+Util::insertQuotes(this->AeLocation+"/GameDataFolder/level0_Final")); | 
 
 
 
 
 | 756 | this->commandMap.insert("models->OBJ->ONI","-create:m3gm"); | 
 
 
 
 
 | 757 | this->commandMap.insert("models->DAE->ONI","-create:trbs"); | 
 
 
 
 
 | 758 | //######################Models Options | 
 
 
 
 
 | 759 | this->commandMap.insert("models->"+ui->cbCellShading->text(),"-cel"); | 
 
 
 
 
 | 760 | this->commandMap.insert("models->"+ui->cbNormals->text(),"-normals"); | 
 
 
 
 
 | 761 | this->commandMap.insert("models->"+ui->cbTexture->text(),"-tex:"); | 
 
 
 
 
 | 762 | this->commandMap.insert("models->"+ui->cbWithAnimation->text(),"-anim:"); | 
 
 
 
 
 | 763 | this->commandMap.insert("models->No Animation","-noanim"); //No label with this name so can't be dynamic | 
 
 
 
 
 | 764 | //Possible Combinations | 
 
 
 
 
 | 765 | this->commandMap.insertMulti("models->ONI","OBJ"); | 
 
 
 
 
 | 766 | this->commandMap.insertMulti("models->ONI","DAE"); | 
 
 
 
 
 | 767 | this->commandMap.insertMulti("models->OBJ","ONI"); | 
 
 
 
 
 | 768 | this->commandMap.insertMulti("models->DAE","ONI"); | 
 
 
 
 
 | 769 |  | 
 
 
 
 
 | 770 | ////////////////////////////////////////////////////////////////////////Animations Commands | 
 
 
 
 
 | 771 | this->commandMap.insert("animations->ONI->DAE","-extract:dae"); | 
 
 
 
 
 | 772 | this->commandMap.insert("animations->FILM DAT->XML","film2xml"); | 
 
 
 
 
 | 773 | //######################Animations Options | 
 
 
 
 
 | 774 | this->commandMap.insert("animations->"+ui->cbCamera->text(),"-geom:camera"); | 
 
 
 
 
 | 775 | this->commandMap.insert("animations->"+ui->cbGeometry->text(),"-geom:"); | 
 
 
 
 
 | 776 | //Possible Combinations | 
 
 
 
 
 | 777 | this->commandMap.insertMulti("animations->ONI","DAE"); | 
 
 
 
 
 | 778 | this->commandMap.insertMulti("animations->DAE","ONI"); | 
 
 
 
 
 | 779 | this->commandMap.insertMulti("animations->FILM DAT","XML"); | 
 
 
 
 
 | 780 |  | 
 
 
 
 
 | 781 | ////////////////////////////////////////////////////////////////////////Levels Commands | 
 
 
 
 
 | 782 | this->commandMap.insert("levels->ONI->DAE","-extract:dae -search "+Util::insertQuotes(this->AeLocation+"/GameDataFolder/level0_Final")); | 
 
 
 
 
 | 783 | this->commandMap.insert("levels->DAE->ONI","-create:akev"); | 
 
 
 
 
 | 784 | this->commandMap.insert("levels->MASTER XML->DAT","-create:level"); | 
 
 
 
 
 | 785 | this->commandMap.insert("levels->MASTER XML->ONI FILES","-create:level"); | 
 
 
 
 
 | 786 | //######################Levels Options | 
 
 
 
 
 | 787 | this->commandMap.insert("levels->"+ui->cbGridsLevels->text(),"-grid:create"); | 
 
 
 
 
 | 788 | //Possible Combinations | 
 
 
 
 
 | 789 | this->commandMap.insertMulti("levels->ONI","DAE"); | 
 
 
 
 
 | 790 | this->commandMap.insertMulti("levels->DAE","ONI"); | 
 
 
 
 
 | 791 | this->commandMap.insertMulti("levels->MASTER XML","DAT"); | 
 
 
 
 
 | 792 | this->commandMap.insertMulti("levels->MASTER XML","ONI FILES"); | 
 
 
 
 
 | 793 |  | 
 
 
 
 
 | 794 | ////////////////////////////////////////////////////////////////////////Misc Commands | 
 
 
 
 
 | 795 | this->commandMap.insert("misc->DAT / ONI->WAV","-extract:wav"); | 
 
 
 
 
 | 796 | this->commandMap.insert("misc->DAT / ONI->AIF","-extract:aif"); | 
 
 
 
 
 | 797 | this->commandMap.insert("misc->DAT / ONI->TXT","-extract:txt"); | 
 
 
 
 
 | 798 | this->commandMap.insert("misc->WAV / AIF->ONI","-create"); | 
 
 
 
 
 | 799 | this->commandMap.insert("misc->TXT->ONI","-create:subt"); | 
 
 
 
 
 | 800 | //Possible Combinations | 
 
 
 
 
 | 801 | this->commandMap.insertMulti("misc->DAT / ONI","WAV"); | 
 
 
 
 
 | 802 | this->commandMap.insertMulti("misc->DAT / ONI","AIF"); | 
 
 
 
 
 | 803 | this->commandMap.insertMulti("misc->DAT / ONI","TXT"); | 
 
 
 
 
 | 804 | this->commandMap.insertMulti("misc->WAV / AIF","ONI"); | 
 
 
 
 
 | 805 | this->commandMap.insertMulti("misc->TXT","ONI"); | 
 
 
 
 
 | 806 |  | 
 
 
 
 
 | 807 | } | 
 
 
 
 
 | 808 |  | 
 
 
 
 
 | 809 | void MainWindow::on_cbFromGeneral_currentIndexChanged(const QString &arg1) | 
 
 
 
 
 | 810 | { | 
 
 
 
 
 | 811 | updateComboBox(arg1, ui->cbToGeneral, "general"); | 
 
 
 
 
 | 812 | } | 
 
 
 
 
 | 813 |  | 
 
 
 
 
 | 814 | void MainWindow::on_cbFromTextures_currentIndexChanged(const QString &arg1) | 
 
 
 
 
 | 815 | { | 
 
 
 
 
 | 816 | //Options are only used for DAT/ONI -> Image | 
 
 
 
 
 | 817 | if(QString::compare(arg1,"DAT / ONI",Qt::CaseSensitive)==0){ //case sensitive is faster | 
 
 
 
 
 | 818 | ui->gbTextures->setEnabled(false); | 
 
 
 
 
 | 819 | } | 
 
 
 
 
 | 820 | else{ | 
 
 
 
 
 | 821 | ui->gbTextures->setEnabled(true); | 
 
 
 
 
 | 822 | } | 
 
 
 
 
 | 823 |  | 
 
 
 
 
 | 824 | updateComboBox(arg1, ui->cbToTextures, "textures"); | 
 
 
 
 
 | 825 | } | 
 
 
 
 
 | 826 |  | 
 
 
 
 
 | 827 | void MainWindow::on_cbFromModels_currentIndexChanged(const QString &arg1) | 
 
 
 
 
 | 828 | { | 
 
 
 
 
 | 829 |  | 
 
 
 
 
 | 830 | ui->cbCellShading->setEnabled(false); | 
 
 
 
 
 | 831 | ui->cbCellShading->setChecked(false); | 
 
 
 
 
 | 832 | ui->cbNormals->setEnabled(false); | 
 
 
 
 
 | 833 | ui->cbNormals->setChecked(false); | 
 
 
 
 
 | 834 | ui->cbTexture->setEnabled(false); | 
 
 
 
 
 | 835 | ui->cbTexture->setChecked(false); | 
 
 
 
 
 | 836 | ui->cbWithAnimation->setEnabled(false); | 
 
 
 
 
 | 837 | ui->cbWithAnimation->setChecked(false); | 
 
 
 
 
 | 838 |  | 
 
 
 
 
 | 839 | if(QString::compare(arg1,"OBJ",Qt::CaseSensitive)==0){ //case sensitive is faster | 
 
 
 
 
 | 840 | ui->cbTexture->setEnabled(true); | 
 
 
 
 
 | 841 | } | 
 
 
 
 
 | 842 | else if(QString::compare(arg1,"DAE",Qt::CaseSensitive)==0){ | 
 
 
 
 
 | 843 | ui->cbCellShading->setEnabled(true); | 
 
 
 
 
 | 844 | ui->cbNormals->setEnabled(true); | 
 
 
 
 
 | 845 | } | 
 
 
 
 
 | 846 |  | 
 
 
 
 
 | 847 | updateComboBox(arg1, ui->cbToModels, "models"); | 
 
 
 
 
 | 848 | } | 
 
 
 
 
 | 849 |  | 
 
 
 
 
 | 850 | void MainWindow::on_cbFromAnimations_currentIndexChanged(const QString &arg1) | 
 
 
 
 
 | 851 | { | 
 
 
 
 
 | 852 | ui->cbCamera->setEnabled(false); | 
 
 
 
 
 | 853 | ui->cbCamera->setChecked(false); | 
 
 
 
 
 | 854 | ui->cbGeometry->setEnabled(false); | 
 
 
 
 
 | 855 | ui->cbGeometry->setChecked(false); | 
 
 
 
 
 | 856 |  | 
 
 
 
 
 | 857 | if(QString::compare(arg1,"ONI",Qt::CaseSensitive)==0){ //case sensitive is faster | 
 
 
 
 
 | 858 | ui->cbCamera->setEnabled(true); | 
 
 
 
 
 | 859 | ui->cbGeometry->setEnabled(true); | 
 
 
 
 
 | 860 | } | 
 
 
 
 
 | 861 |  | 
 
 
 
 
 | 862 | updateComboBox(arg1, ui->cbToAnimations, "animations"); | 
 
 
 
 
 | 863 | } | 
 
 
 
 
 | 864 |  | 
 
 
 
 
 | 865 | void MainWindow::on_cbFromLevels_currentIndexChanged(const QString &arg1) | 
 
 
 
 
 | 866 | { | 
 
 
 
 
 | 867 | updateComboBox(arg1, ui->cbToLevels, "levels"); | 
 
 
 
 
 | 868 | } | 
 
 
 
 
 | 869 |  | 
 
 
 
 
 | 870 | void MainWindow::on_cbFromMisc_currentIndexChanged(const QString &arg1) | 
 
 
 
 
 | 871 | { | 
 
 
 
 
 | 872 | updateComboBox(arg1, ui->cbToMisc, "misc"); | 
 
 
 
 
 | 873 | } | 
 
 
 
 
 | 874 |  | 
 
 
 
 
 | 875 | void MainWindow::updateComboBox(const QString &arg1, QComboBox *comboBox, const QString &identifier){ | 
 
 
 
 
 | 876 | comboBox->clear(); | 
 
 
 
 
 | 877 |  | 
 
 
 
 
 | 878 | QStringList toUpdate=QStringList(); | 
 
 
 
 
 | 879 |  | 
 
 
 
 
 | 880 | QStringList values=commandMap.values(identifier+"->"+arg1); | 
 
 
 
 
 | 881 |  | 
 
 
 
 
 | 882 | for (int i = values.size()-1; i >= 0; i--){ //By defaut MultiItems have the inversed order (http://qt-project.org/doc/qt-4.8/qhash.html#insertMulti) | 
 
 
 
 
 | 883 | toUpdate << values.at(i); | 
 
 
 
 
 | 884 | } | 
 
 
 
 
 | 885 |  | 
 
 
 
 
 | 886 | comboBox->addItems(toUpdate); | 
 
 
 
 
 | 887 | } | 
 
 
 
 
 | 888 |  | 
 
 
 
 
 | 889 |  | 
 
 
 
 
 | 890 | void MainWindow::on_actionWindows_triggered() | 
 
 
 
 
 | 891 | { | 
 
 
 
 
 | 892 | ui->actionWindows->setChecked(true); | 
 
 
 
 
 | 893 | ui->actionMac_Windows_demo->setChecked(false); | 
 
 
 
 
 | 894 | } | 
 
 
 
 
 | 895 |  | 
 
 
 
 
 | 896 | void MainWindow::on_actionMac_Windows_demo_triggered() | 
 
 
 
 
 | 897 | { | 
 
 
 
 
 | 898 | ui->actionMac_Windows_demo->setChecked(true); | 
 
 
 
 
 | 899 | ui->actionWindows->setChecked(false); | 
 
 
 
 
 | 900 | } | 
 
 
 
 
 | 901 |  | 
 
 
 
 
 | 902 | void MainWindow::on_pbRemoveSourceGeneral_clicked() | 
 
 
 
 
 | 903 | { | 
 
 
 
 
 | 904 | removeTableContents( ui->twSourcesGeneral); | 
 
 
 
 
 | 905 | } | 
 
 
 
 
 | 906 |  | 
 
 
 
 
 | 907 | void MainWindow::on_pbRemoveSourceTextures_clicked() | 
 
 
 
 
 | 908 | { | 
 
 
 
 
 | 909 | removeTableContents(ui->twSourcesTextures); | 
 
 
 
 
 | 910 | } | 
 
 
 
 
 | 911 |  | 
 
 
 
 
 | 912 | void MainWindow::on_pbRemoveSourceModels_clicked() | 
 
 
 
 
 | 913 | { | 
 
 
 
 
 | 914 | removeTableContents(ui->twSourcesModels); | 
 
 
 
 
 | 915 | } | 
 
 
 
 
 | 916 |  | 
 
 
 
 
 | 917 | void MainWindow::on_pbRemoveSourceAnimations_clicked() | 
 
 
 
 
 | 918 | { | 
 
 
 
 
 | 919 | removeTableContents(ui->twSourcesAnimations); | 
 
 
 
 
 | 920 | } | 
 
 
 
 
 | 921 |  | 
 
 
 
 
 | 922 | void MainWindow::on_pbRemoveSourceLevels_clicked() | 
 
 
 
 
 | 923 | { | 
 
 
 
 
 | 924 | removeTableContents(ui->twSourcesLevels); | 
 
 
 
 
 | 925 | } | 
 
 
 
 
 | 926 |  | 
 
 
 
 
 | 927 | void MainWindow::on_pbRemoveSourceMisc_clicked() | 
 
 
 
 
 | 928 | { | 
 
 
 
 
 | 929 | removeTableContents(ui->twSourcesMisc); | 
 
 
 
 
 | 930 | } | 
 
 
 
 
 | 931 |  | 
 
 
 
 
 | 932 | void MainWindow::on_pbClearSourcesGeneral_clicked() | 
 
 
 
 
 | 933 | { | 
 
 
 
 
 | 934 | clearTableContents(ui->twSourcesGeneral); | 
 
 
 
 
 | 935 | } | 
 
 
 
 
 | 936 |  | 
 
 
 
 
 | 937 | void MainWindow::on_pbClearSourcesTextures_clicked() | 
 
 
 
 
 | 938 | { | 
 
 
 
 
 | 939 | clearTableContents(ui->twSourcesTextures); | 
 
 
 
 
 | 940 | } | 
 
 
 
 
 | 941 |  | 
 
 
 
 
 | 942 | void MainWindow::on_pbClearSourcesModels_clicked() | 
 
 
 
 
 | 943 | { | 
 
 
 
 
 | 944 | clearTableContents(ui->twSourcesModels); | 
 
 
 
 
 | 945 | } | 
 
 
 
 
 | 946 |  | 
 
 
 
 
 | 947 | void MainWindow::on_pbClearSourcesAnimations_clicked() | 
 
 
 
 
 | 948 | { | 
 
 
 
 
 | 949 | clearTableContents(ui->twSourcesAnimations); | 
 
 
 
 
 | 950 | } | 
 
 
 
 
 | 951 |  | 
 
 
 
 
 | 952 | void MainWindow::on_pbClearSourcesLevels_clicked() | 
 
 
 
 
 | 953 | { | 
 
 
 
 
 | 954 | clearTableContents(ui->twSourcesLevels); | 
 
 
 
 
 | 955 | } | 
 
 
 
 
 | 956 |  | 
 
 
 
 
 | 957 | void MainWindow::on_pbClearSourcesMisc_clicked() | 
 
 
 
 
 | 958 | { | 
 
 
 
 
 | 959 | clearTableContents(ui->twSourcesMisc); | 
 
 
 
 
 | 960 | } | 
 
 
 
 
 | 961 |  | 
 
 
 
 
 | 962 | void MainWindow::removeTableContents(DropTableWidget *myTable){ | 
 
 
 
 
 | 963 | int size = myTable->selectionModel()->selectedRows().size(); | 
 
 
 
 
 | 964 |  | 
 
 
 
 
 | 965 | if(size==0){ | 
 
 
 
 
 | 966 | Util::showPopUp("Select a row first."); | 
 
 
 
 
 | 967 | return; | 
 
 
 
 
 | 968 | } | 
 
 
 
 
 | 969 |  | 
 
 
 
 
 | 970 | if(Util::showQuestionPopUp(this,"Are you sure you want to delete the selected rows?")){ | 
 
 
 
 
 | 971 | for(int i=0; i<size; i++){ | 
 
 
 
 
 | 972 | //myTable->removeRow(myTable->selectedItems().at(size-i-1)->row()); | 
 
 
 
 
 | 973 | myTable->removeRow(myTable->selectionModel()->selectedRows().at(size-i-1).row()); | 
 
 
 
 
 | 974 | } | 
 
 
 
 
 | 975 | updateItemsLoaded(myTable); | 
 
 
 
 
 | 976 | } | 
 
 
 
 
 | 977 | } | 
 
 
 
 
 | 978 |  | 
 
 
 
 
 | 979 | void MainWindow::clearTableContents(DropTableWidget *myTable){ | 
 
 
 
 
 | 980 | if(myTable->rowCount()==0){ | 
 
 
 
 
 | 981 | Util::showPopUp("Nothing to clear."); | 
 
 
 
 
 | 982 | return; | 
 
 
 
 
 | 983 | } | 
 
 
 
 
 | 984 |  | 
 
 
 
 
 | 985 | if(Util::showQuestionPopUp(this,"Are you sure you want to clear the content?")){ | 
 
 
 
 
 | 986 | myTable->clearContents(); | 
 
 
 
 
 | 987 | myTable->setRowCount(0); | 
 
 
 
 
 | 988 | } | 
 
 
 
 
 | 989 | updateItemsLoaded(myTable); | 
 
 
 
 
 | 990 | } | 
 
 
 
 
 | 991 |  | 
 
 
 
 
 | 992 |  | 
 
 
 
 
 | 993 | void MainWindow::on_actionPreferences_triggered() | 
 
 
 
 
 | 994 | { | 
 
 
 
 
 | 995 | //Show preferences | 
 
 
 
 
 | 996 | Preferences *preferencesWindow = new Preferences(this,this->vagoSettings); | 
 
 
 
 
 | 997 | preferencesWindow->exec(); //it destroys itself when finished. | 
 
 
 
 
 | 998 | } | 
 
 
 
 
 | 999 |  | 
 
 
 
 
 | 1000 |  | 
 
 
 
 
 | 1001 | void MainWindow::closeEvent(QCloseEvent *event){ | 
 
 
 
 
 | 1002 | if(this->vagoSettings->value("ConfirmExit").toBool()){ | 
 
 
 
 
 | 1003 | if(!Util::showQuestionPopUp(this,"Exit Vago?")){ | 
 
 
 
 
 | 1004 | event->ignore(); | 
 
 
 
 
 | 1005 | } | 
 
 
 
 
 | 1006 | } | 
 
 
 
 
 | 1007 | } | 
 
 
 
 
 | 1008 |  | 
 
 
 
 
 | 1009 | void MainWindow::on_cbToGeneral_currentIndexChanged(const QString &arg1) | 
 
 
 
 
 | 1010 | { | 
 
 
 
 
 | 1011 |  | 
 
 
 
 
 | 1012 | ui->cbDatGeneral->setEnabled(false); | 
 
 
 
 
 | 1013 | ui->cbDatGeneral->setChecked(false); | 
 
 
 
 
 | 1014 | ui->cbTRAMGeneral->setEnabled(false); | 
 
 
 
 
 | 1015 | ui->cbTRAMGeneral->setChecked(false); | 
 
 
 
 
 | 1016 |  | 
 
 
 
 
 | 1017 | if(QString::compare(ui->cbFromGeneral->currentText(),"ONI",Qt::CaseSensitive)==0){ | 
 
 
 
 
 | 1018 | if(QString::compare(arg1,"DAT",Qt::CaseSensitive)==0){ | 
 
 
 
 
 | 1019 | ui->cbDatGeneral->setEnabled(true); | 
 
 
 
 
 | 1020 | } | 
 
 
 
 
 | 1021 | else{ | 
 
 
 
 
 | 1022 | ui->cbTRAMGeneral->setEnabled(true); | 
 
 
 
 
 | 1023 | } | 
 
 
 
 
 | 1024 | } | 
 
 
 
 
 | 1025 |  | 
 
 
 
 
 | 1026 | } | 
 
 
 
 
 | 1027 |  | 
 
 
 
 
 | 1028 | void MainWindow::on_cbToModels_currentIndexChanged(const QString &arg1) | 
 
 
 
 
 | 1029 | { | 
 
 
 
 
 | 1030 | ui->cbWithAnimation->setEnabled(false); | 
 
 
 
 
 | 1031 | ui->cbWithAnimation->setChecked(false); | 
 
 
 
 
 | 1032 |  | 
 
 
 
 
 | 1033 | if(arg1=="DAE"){ | 
 
 
 
 
 | 1034 | ui->cbWithAnimation->setEnabled(true); | 
 
 
 
 
 | 1035 | } | 
 
 
 
 
 | 1036 | } | 
 
 
 
 
 | 1037 |  | 
 
 
 
 
 | 1038 | void MainWindow::on_cbToLevels_currentIndexChanged(const QString &arg1) | 
 
 
 
 
 | 1039 | { | 
 
 
 
 
 | 1040 |  | 
 
 
 
 
 | 1041 | ui->cbDatLevels->setEnabled(false); | 
 
 
 
 
 | 1042 | ui->cbDatLevels->setChecked(false); | 
 
 
 
 
 | 1043 | ui->cbBnvLevels->setEnabled(false); | 
 
 
 
 
 | 1044 | ui->cbBnvLevels->setChecked(false); | 
 
 
 
 
 | 1045 | ui->cbAdditionalSourcesLevels->setEnabled(false); | 
 
 
 
 
 | 1046 | ui->cbAdditionalSourcesLevels->setChecked(false); | 
 
 
 
 
 | 1047 | ui->cbGridsLevels->setEnabled(false); | 
 
 
 
 
 | 1048 | ui->cbGridsLevels->setChecked(false); | 
 
 
 
 
 | 1049 |  | 
 
 
 
 
 | 1050 | if(ui->cbFromLevels->currentText()=="MASTER XML" && arg1=="DAT"){ | 
 
 
 
 
 | 1051 | ui->cbDatLevels->setEnabled(true); | 
 
 
 
 
 | 1052 | } | 
 
 
 
 
 | 1053 | else if(ui->cbFromLevels->currentText()=="DAE" && arg1=="ONI"){ | 
 
 
 
 
 | 1054 | ui->cbBnvLevels->setEnabled(true); | 
 
 
 
 
 | 1055 | ui->cbAdditionalSourcesLevels->setEnabled(true); | 
 
 
 
 
 | 1056 | } | 
 
 
 
 
 | 1057 | } | 
 
 
 
 
 | 1058 |  | 
 
 
 
 
 | 1059 | void MainWindow::on_cbDatGeneral_toggled(bool checked) | 
 
 
 
 
 | 1060 | { | 
 
 
 
 
 | 1061 | ui->leTargetDatGeneral->setEnabled(checked); | 
 
 
 
 
 | 1062 | } | 
 
 
 
 
 | 1063 |  | 
 
 
 
 
 | 1064 | void MainWindow::on_cbTRAMGeneral_toggled(bool checked) | 
 
 
 
 
 | 1065 | { | 
 
 
 
 
 | 1066 | ui->leTRAMGeneral->setEnabled(checked); | 
 
 
 
 
 | 1067 | if(checked){ | 
 
 
 
 
 | 1068 | QString file=QFileDialog::getOpenFileName(this,"Choose the TRAM.oni file...","./" , "All Files (*.*)"); | 
 
 
 
 
 | 1069 | if(!file.isEmpty()){ | 
 
 
 
 
 | 1070 | ui->leTRAMGeneral->setText(file); | 
 
 
 
 
 | 1071 | } | 
 
 
 
 
 | 1072 | } | 
 
 
 
 
 | 1073 | } | 
 
 
 
 
 | 1074 |  | 
 
 
 
 
 | 1075 | void MainWindow::on_cbDatLevels_toggled(bool checked) | 
 
 
 
 
 | 1076 | { | 
 
 
 
 
 | 1077 | ui->leTargetDatLevels->setEnabled(checked); | 
 
 
 
 
 | 1078 | } | 
 
 
 
 
 | 1079 |  | 
 
 
 
 
 | 1080 | void MainWindow::on_cbBnvLevels_toggled(bool checked) | 
 
 
 
 
 | 1081 | { | 
 
 
 
 
 | 1082 | ui->leBnvLevels->setEnabled(checked); | 
 
 
 
 
 | 1083 | ui->cbGridsLevels->setEnabled(checked); | 
 
 
 
 
 | 1084 | ui->cbGridsLevels->setChecked(checked); | 
 
 
 
 
 | 1085 | if(checked){ | 
 
 
 
 
 | 1086 | QString file=QFileDialog::getOpenFileName(this,"Choose the BNV.dae file...","./" , "All Files (*.*)"); | 
 
 
 
 
 | 1087 | if(!file.isEmpty()){ | 
 
 
 
 
 | 1088 | ui->leBnvLevels->setText(file); | 
 
 
 
 
 | 1089 | } | 
 
 
 
 
 | 1090 | } | 
 
 
 
 
 | 1091 | } | 
 
 
 
 
 | 1092 |  | 
 
 
 
 
 | 1093 | void MainWindow::on_cbAdditionalSourcesLevels_toggled(bool checked) | 
 
 
 
 
 | 1094 | { | 
 
 
 
 
 | 1095 | ui->leAdditSourcesLevels->setEnabled(checked); | 
 
 
 
 
 | 1096 |  | 
 
 
 
 
 | 1097 | if(checked){ | 
 
 
 
 
 | 1098 | QStringList filesSelected=QFileDialog::getOpenFileNames(this,"Choose the additional .dae files...","./" , "All Files (*.*)"); | 
 
 
 
 
 | 1099 | QString filesJoined; | 
 
 
 
 
 | 1100 | int size=filesSelected.size(); | 
 
 
 
 
 | 1101 |  | 
 
 
 
 
 | 1102 | if(!filesSelected.isEmpty()){ | 
 
 
 
 
 | 1103 | for(int i=0; i<size-1; i++){ | 
 
 
 
 
 | 1104 | filesJoined+=filesSelected.at(i)+" "; | 
 
 
 
 
 | 1105 | } | 
 
 
 
 
 | 1106 | filesJoined+=filesSelected.at(size-1); //last doesn't have space after | 
 
 
 
 
 | 1107 | ui->leAdditSourcesLevels->setText(filesJoined); | 
 
 
 
 
 | 1108 | } | 
 
 
 
 
 | 1109 |  | 
 
 
 
 
 | 1110 | } | 
 
 
 
 
 | 1111 | } | 
 
 
 
 
 | 1112 |  | 
 
 
 
 
 | 1113 | void MainWindow::on_actionCheck_OniSplit_version_triggered() | 
 
 
 
 
 | 1114 | { | 
 
 
 
 
 | 1115 | QProcess *myProcess = new QProcess(); | 
 
 
 
 
 | 1116 | myProcess->start(GlobalVars::OniSplitExeName+" -version"); | 
 
 
 
 
 | 1117 | myProcess->waitForFinished(-1); | 
 
 
 
 
 | 1118 | QString result=myProcess->readAllStandardOutput(); | 
 
 
 
 
 | 1119 | delete myProcess; | 
 
 
 
 
 | 1120 | Util::showPopUp("This Vago version was built with base in OniSplit version "+GlobalVars::BuiltOniSplitVersion+"\n\nActual version is:\n"+result); | 
 
 
 
 
 | 1121 | } | 
 
 
 
 
 | 1122 |  | 
 
 
 
 
 | 1123 | void MainWindow::on_actionCheck_xmlTools_version_triggered() | 
 
 
 
 
 | 1124 | { | 
 
 
 
 
 | 1125 | QProcess *myProcess = new QProcess(); | 
 
 
 
 
 | 1126 | myProcess->start(GlobalVars::XmlToolsExeName+" version"); | 
 
 
 
 
 | 1127 | myProcess->waitForFinished(-1); | 
 
 
 
 
 | 1128 | QString result=myProcess->readLine(); | 
 
 
 
 
 | 1129 | delete myProcess; | 
 
 
 
 
 | 1130 | Util::showPopUp("This Vago version was built with base in xmlTools version "+GlobalVars::BuiltXmlToolsVersion+"\n\nActual version is:\n"+result); | 
 
 
 
 
 | 1131 | } | 
 
 
 
 
 | 1132 |  | 
 
 
 
 
 | 1133 | /** | 
 
 
 
 
 | 1134 | Update items loaded | 
 
 
 
 
 | 1135 | **/ | 
 
 
 
 
 | 1136 | void MainWindow::on_tabWidget_selected(const QString &arg1) | 
 
 
 
 
 | 1137 | { | 
 
 
 
 
 | 1138 | if(arg1.compare("General",Qt::CaseSensitive)==0){ //case sentive is faster | 
 
 
 
 
 | 1139 | updateItemsLoaded(ui->twSourcesGeneral); | 
 
 
 
 
 | 1140 | } | 
 
 
 
 
 | 1141 | else if(arg1.compare("Textures",Qt::CaseSensitive)==0){ | 
 
 
 
 
 | 1142 | updateItemsLoaded(ui->twSourcesTextures); | 
 
 
 
 
 | 1143 | } | 
 
 
 
 
 | 1144 | else if(arg1.compare("Models",Qt::CaseSensitive)==0){ | 
 
 
 
 
 | 1145 | updateItemsLoaded(ui->twSourcesModels); | 
 
 
 
 
 | 1146 | } | 
 
 
 
 
 | 1147 | else if(arg1.compare("Levels",Qt::CaseSensitive)==0){ | 
 
 
 
 
 | 1148 | updateItemsLoaded(ui->twSourcesLevels); | 
 
 
 
 
 | 1149 | } | 
 
 
 
 
 | 1150 | else{ | 
 
 
 
 
 | 1151 | updateItemsLoaded(ui->twSourcesMisc); | 
 
 
 
 
 | 1152 | } | 
 
 
 
 
 | 1153 | } | 
 
 
 
 
 | 1154 |  | 
 
 
 
 
 | 1155 | void MainWindow::updateItemsLoaded(DropTableWidget *currentTable){ | 
 
 
 
 
 | 1156 |  | 
 
 
 
 
 | 1157 | int numItems=currentTable->rowCount(); | 
 
 
 
 
 | 1158 |  | 
 
 
 
 
 | 1159 | this->itemsLoaded->setText(QString().setNum(numItems)+ (numItems==1?" item ":" items ") +"loaded"); | 
 
 
 
 
 | 1160 | } | 
 
 
 
 
 | 1161 |  | 
 
 
 
 
 | 1162 | void MainWindow::on_tbCommand_clicked() | 
 
 
 
 
 | 1163 | { | 
 
 
 
 
 | 1164 | //Show preferences | 
 
 
 
 
 | 1165 | ManualCommands *commandsWindow = new ManualCommands(this); | 
 
 
 
 
 | 1166 | commandsWindow->show(); //it destroys itself when finished. | 
 
 
 
 
 | 1167 | } | 
 
 
 
 
 | 1168 |  | 
 
 
 
 
 | 1169 | void MainWindow::on_actionWorkspace_triggered() | 
 
 
 
 
 | 1170 | { | 
 
 
 
 
 | 1171 | ui->actionWorkspace->setChecked(true); | 
 
 
 
 
 | 1172 | ui->actionOther->setChecked(false); | 
 
 
 
 
 | 1173 | this->outputFolder=this->workspaceLocation; | 
 
 
 
 
 | 1174 | ui->tbOpenFolder->setToolTip("Open Vago workspace"); | 
 
 
 
 
 | 1175 | showSuccessStatusMessage("Vago is now outputting the NEW items for Vago workspace."); | 
 
 
 
 
 | 1176 | } | 
 
 
 
 
 | 1177 |  | 
 
 
 
 
 | 1178 | void MainWindow::on_actionOther_triggered() | 
 
 
 
 
 | 1179 | { | 
 
 
 
 
 | 1180 | QString newDir=QFileDialog::getExistingDirectory(this,"Choose the folder for output NEW files directly...",this->AeLocation+"/GameDataFolder"); | 
 
 
 
 
 | 1181 | newDir=Util::normalizePath(newDir); | 
 
 
 
 
 | 1182 |  | 
 
 
 
 
 | 1183 | if(newDir.isEmpty()){ | 
 
 
 
 
 | 1184 | ui->actionOther->setChecked(false); | 
 
 
 
 
 | 1185 | return; //do nothing | 
 
 
 
 
 | 1186 | } | 
 
 
 
 
 | 1187 |  | 
 
 
 
 
 | 1188 | if(newDir==this->workspaceLocation){ | 
 
 
 
 
 | 1189 | on_actionWorkspace_triggered(); //set it to vago workspace | 
 
 
 
 
 | 1190 | return; | 
 
 
 
 
 | 1191 | } | 
 
 
 
 
 | 1192 |  | 
 
 
 
 
 | 1193 | ui->actionOther->setChecked(true); | 
 
 
 
 
 | 1194 | ui->actionWorkspace->setChecked(false); | 
 
 
 
 
 | 1195 |  | 
 
 
 
 
 | 1196 | this->outputFolder=newDir; | 
 
 
 
 
 | 1197 |  | 
 
 
 
 
 | 1198 | QString newDirName=Util::cutName(newDir); | 
 
 
 
 
 | 1199 | ui->tbOpenFolder->setToolTip("Open "+newDirName+" output folder"); | 
 
 
 
 
 | 1200 | showSuccessStatusMessage("Vago is now outputting the NEW items for "+newDirName+"."); | 
 
 
 
 
 | 1201 | } | 
 
 
 
 
 | 1202 |  | 
 
 
 
 
 | 1203 | void MainWindow::on_actionView_log_triggered() | 
 
 
 
 
 | 1204 | { | 
 
 
 
 
 | 1205 | Util::openLogFile(); | 
 
 
 
 
 | 1206 | } | 
 
 
 
 
 | 1207 |  | 
 
 
 
 
 | 1208 | QString MainWindow::getTypeConversion(DropTableWidget *myTable){ | 
 
 
 
 
 | 1209 | QString from,to; | 
 
 
 
 
 | 1210 |  | 
 
 
 
 
 | 1211 | if(myTable==ui->twSourcesGeneral){ | 
 
 
 
 
 | 1212 | from=ui->cbFromGeneral->currentText(); | 
 
 
 
 
 | 1213 | to=ui->cbToGeneral->currentText(); | 
 
 
 
 
 | 1214 | } | 
 
 
 
 
 | 1215 | else if(myTable==ui->twSourcesTextures){ | 
 
 
 
 
 | 1216 | from=ui->cbFromTextures->currentText(); | 
 
 
 
 
 | 1217 | to=ui->cbToTextures->currentText(); | 
 
 
 
 
 | 1218 | } | 
 
 
 
 
 | 1219 | else if(myTable==ui->twSourcesModels){ | 
 
 
 
 
 | 1220 | from=ui->cbFromModels->currentText(); | 
 
 
 
 
 | 1221 | to=ui->cbToModels->currentText(); | 
 
 
 
 
 | 1222 | } | 
 
 
 
 
 | 1223 | else if(myTable==ui->twSourcesAnimations){ | 
 
 
 
 
 | 1224 | from=ui->cbFromAnimations->currentText(); | 
 
 
 
 
 | 1225 | to=ui->cbToAnimations->currentText(); | 
 
 
 
 
 | 1226 | } | 
 
 
 
 
 | 1227 | else if(myTable==ui->twSourcesLevels){ | 
 
 
 
 
 | 1228 | from=ui->cbFromLevels->currentText(); | 
 
 
 
 
 | 1229 | to=ui->cbToLevels->currentText(); | 
 
 
 
 
 | 1230 | } | 
 
 
 
 
 | 1231 | else{ | 
 
 
 
 
 | 1232 | from=ui->cbFromMisc->currentText(); | 
 
 
 
 
 | 1233 | to=ui->cbToMisc->currentText(); | 
 
 
 
 
 | 1234 | } | 
 
 
 
 
 | 1235 |  | 
 
 
 
 
 | 1236 | return from + " > " + to; | 
 
 
 
 
 | 1237 | } | 
 
 
 
 
 | 1238 |  | 
 
 
 
 
 | 1239 | //Drop table widget context menu | 
 
 
 
 
 | 1240 | void MainWindow::dtContextMenu(DropTableWidget* myTable, QContextMenuEvent *event){ | 
 
 
 
 
 | 1241 | QModelIndex index = myTable->indexAt(event->pos()); | 
 
 
 
 
 | 1242 |  | 
 
 
 
 
 | 1243 | //item exists? | 
 
 
 
 
 | 1244 | if(!index.isValid()) | 
 
 
 
 
 | 1245 | return; | 
 
 
 
 
 | 1246 |  | 
 
 
 
 
 | 1247 | if(myTable->selectionModel()->selectedRows().size()==0){ //No multiple rows selected | 
 
 
 
 
 | 1248 | myTable->selectRow(myTable->itemAt(event->pos())->row()); //select all the row of the item clicked | 
 
 
 
 
 | 1249 | } | 
 
 
 
 
 | 1250 |  | 
 
 
 
 
 | 1251 | QList<int> selectedRows = QList<int>(); | 
 
 
 
 
 | 1252 |  | 
 
 
 
 
 | 1253 | foreach(QModelIndex rowItem, myTable->selectionModel()->selectedRows()){ | 
 
 
 
 
 | 1254 | selectedRows << rowItem.row(); | 
 
 
 
 
 | 1255 | } | 
 
 
 
 
 | 1256 |  | 
 
 
 
 
 | 1257 | QMenu *menu = new QMenu(); | 
 
 
 
 
 | 1258 | QAction *copy = new QAction("Copy",myTable); | 
 
 
 
 
 | 1259 | QAction *moveUp = new QAction("Move Up",myTable); | 
 
 
 
 
 | 1260 | QAction *moveDown = new QAction("Move Down",myTable); | 
 
 
 
 
 | 1261 | QAction *changeOptions = new QAction("Change To Current Options",myTable); | 
 
 
 
 
 | 1262 | QMenu *changeOutput = new QMenu("Change Output for:"); | 
 
 
 
 
 | 1263 | QAction *outWorkspace = new QAction("Workspace",myTable); | 
 
 
 
 
 | 1264 | QAction *outCurrOutput = new QAction("Current Output Folder",myTable); | 
 
 
 
 
 | 1265 | QAction *outOther = new QAction("Other...",myTable); | 
 
 
 
 
 | 1266 | QAction *edisable = new QAction("Enable/Disable",myTable); | 
 
 
 
 
 | 1267 |  | 
 
 
 
 
 | 1268 | menu->addAction(copy); | 
 
 
 
 
 | 1269 | menu->addSeparator(); | 
 
 
 
 
 | 1270 | menu->addAction(moveUp); | 
 
 
 
 
 | 1271 | menu->addAction(moveDown); | 
 
 
 
 
 | 1272 | menu->addSeparator(); | 
 
 
 
 
 | 1273 | menu->addAction(changeOptions); | 
 
 
 
 
 | 1274 | menu->addMenu(changeOutput); | 
 
 
 
 
 | 1275 | changeOutput->addActions(QList<QAction*>() << outWorkspace << outCurrOutput << outOther); | 
 
 
 
 
 | 1276 | menu->addAction(edisable); | 
 
 
 
 
 | 1277 |  | 
 
 
 
 
 | 1278 |  | 
 
 
 
 
 | 1279 | //if it's in the first row it can't be setted up | 
 
 
 
 
 | 1280 | if(selectedRows.at(0)==0){ | 
 
 
 
 
 | 1281 | moveUp->setEnabled(false); | 
 
 
 
 
 | 1282 | } | 
 
 
 
 
 | 1283 |  | 
 
 
 
 
 | 1284 | //if we are at bottom we can't go down | 
 
 
 
 
 | 1285 | if(selectedRows.at(selectedRows.size()-1)==myTable->rowCount()-1){ | 
 
 
 
 
 | 1286 | moveDown->setEnabled(false); | 
 
 
 
 
 | 1287 | } | 
 
 
 
 
 | 1288 |  | 
 
 
 
 
 | 1289 | //Can we change the settings? (the conversion must be the same) | 
 
 
 
 
 | 1290 | QString currentSettings = (getTypeConversion(myTable)); //call function at the mainWindow with a signal (different threads?) | 
 
 
 
 
 | 1291 | foreach(int row, selectedRows){ | 
 
 
 
 
 | 1292 | if( myTable->item(row,1)->text() != currentSettings){ //If we find out any of the selected items can't be convert disable operation | 
 
 
 
 
 | 1293 | changeOptions->setEnabled(false); | 
 
 
 
 
 | 1294 | break; | 
 
 
 
 
 | 1295 | } | 
 
 
 
 
 | 1296 | } | 
 
 
 
 
 | 1297 |  | 
 
 
 
 
 | 1298 | QAction* selectedOption = menu->exec(event->globalPos()); | 
 
 
 
 
 | 1299 |  | 
 
 
 
 
 | 1300 | if(selectedOption==copy){ | 
 
 
 
 
 | 1301 | //Let's copy the contents to the clipboard | 
 
 
 
 
 | 1302 |  | 
 
 
 
 
 | 1303 | QString toCopy; | 
 
 
 
 
 | 1304 |  | 
 
 
 
 
 | 1305 | int size=selectedRows.size(); | 
 
 
 
 
 | 1306 |  | 
 
 
 
 
 | 1307 | //Let's format it a bit... | 
 
 
 
 
 | 1308 | for(int i=0; i<size; i++){ | 
 
 
 
 
 | 1309 | for(int j=0; j<myTable->columnCount(); j++){ | 
 
 
 
 
 | 1310 | toCopy+=myTable->item(selectedRows.at(i),j)->text(); | 
 
 
 
 
 | 1311 | if(j!=myTable->columnCount()-1){ | 
 
 
 
 
 | 1312 | toCopy+="\t"; | 
 
 
 
 
 | 1313 | } | 
 
 
 
 
 | 1314 | } | 
 
 
 
 
 | 1315 | if(i!=size-1){ | 
 
 
 
 
 | 1316 | toCopy+="\n"; | 
 
 
 
 
 | 1317 | } | 
 
 
 
 
 | 1318 | } | 
 
 
 
 
 | 1319 |  | 
 
 
 
 
 | 1320 | QApplication::clipboard()->setText(toCopy); | 
 
 
 
 
 | 1321 | showSuccessStatusMessage(QString::number(size) + (size==1?" item ":" items ")+ "copied to the clipboard"); | 
 
 
 
 
 | 1322 | } | 
 
 
 
 
 | 1323 | else if(selectedOption==moveUp){ | 
 
 
 
 
 | 1324 | qSort(selectedRows); //let's order the selections by the row number, so we know exactly how to swap it | 
 
 
 
 
 | 1325 | myTable->swapPositions(selectedRows,-1); | 
 
 
 
 
 | 1326 | } | 
 
 
 
 
 | 1327 | else if(selectedOption==moveDown){ | 
 
 
 
 
 | 1328 | qSort(selectedRows); | 
 
 
 
 
 | 1329 | myTable->swapPositions(selectedRows,+1); | 
 
 
 
 
 | 1330 | } | 
 
 
 
 
 | 1331 | else if(selectedOption==changeOptions){ | 
 
 
 
 
 | 1332 | changeToCurrentSettings(selectedRows,myTable); | 
 
 
 
 
 | 1333 | } | 
 
 
 
 
 | 1334 | else if(selectedOption==outWorkspace){ | 
 
 
 
 
 | 1335 | changeItemsOutput(myTable,selectedRows,this->workspaceLocation); | 
 
 
 
 
 | 1336 | } | 
 
 
 
 
 | 1337 | else if(selectedOption==outCurrOutput){ | 
 
 
 
 
 | 1338 | changeItemsOutput(myTable,selectedRows,this->outputFolder); | 
 
 
 
 
 | 1339 | } | 
 
 
 
 
 | 1340 | else if(selectedOption==outOther){ | 
 
 
 
 
 | 1341 |  | 
 
 
 
 
 | 1342 | QString newDir=QFileDialog::getExistingDirectory(this,"Choose the folder for the output of the files selected...",this->AeLocation+"/GameDataFolder"); | 
 
 
 
 
 | 1343 | newDir=Util::normalizePath(newDir); | 
 
 
 
 
 | 1344 |  | 
 
 
 
 
 | 1345 | if(newDir.isEmpty()){ | 
 
 
 
 
 | 1346 | return; //do nothing | 
 
 
 
 
 | 1347 | } | 
 
 
 
 
 | 1348 |  | 
 
 
 
 
 | 1349 | changeItemsOutput(myTable,selectedRows,newDir); | 
 
 
 
 
 | 1350 |  | 
 
 
 
 
 | 1351 | } | 
 
 
 
 
 | 1352 | else if(selectedOption==edisable){ | 
 
 
 
 
 | 1353 |  | 
 
 
 
 
 | 1354 | int enabledCount=0, disabledCount=0; | 
 
 
 
 
 | 1355 |  | 
 
 
 
 
 | 1356 | for(int i=0; i<selectedRows.size(); i++){ | 
 
 
 
 
 | 1357 |  | 
 
 
 
 
 | 1358 | for(int j=0; j<myTable->columnCount(); j++){ | 
 
 
 
 
 | 1359 | QTableWidgetItem *currentItem=myTable->item(selectedRows.at(i),j); | 
 
 
 
 
 | 1360 |  | 
 
 
 
 
 | 1361 | if(currentItem->background()!=myTable->disabledBackStyle){ | 
 
 
 
 
 | 1362 | myTable->setDisableStyleWidgetItem(currentItem); | 
 
 
 
 
 | 1363 | if(j==0){ //Only count the row, not the columns | 
 
 
 
 
 | 1364 | disabledCount++; | 
 
 
 
 
 | 1365 | } | 
 
 
 
 
 | 1366 | } | 
 
 
 
 
 | 1367 | else{ //reset to initial state (enable) | 
 
 
 
 
 | 1368 | myTable->resetStyleWidgetItem(currentItem); | 
 
 
 
 
 | 1369 | if(j==0){ | 
 
 
 
 
 | 1370 | enabledCount++; | 
 
 
 
 
 | 1371 | } | 
 
 
 
 
 | 1372 | } | 
 
 
 
 
 | 1373 | } | 
 
 
 
 
 | 1374 | } | 
 
 
 
 
 | 1375 |  | 
 
 
 
 
 | 1376 | QString result; | 
 
 
 
 
 | 1377 |  | 
 
 
 
 
 | 1378 | if(enabledCount!=0){ | 
 
 
 
 
 | 1379 | result+=QString::number(enabledCount) + (enabledCount==1?" item ":" items ") + "Enabled"; | 
 
 
 
 
 | 1380 | } | 
 
 
 
 
 | 1381 | if(enabledCount!=0 && disabledCount!=0){ | 
 
 
 
 
 | 1382 | result+=" and "; | 
 
 
 
 
 | 1383 | } | 
 
 
 
 
 | 1384 | if(disabledCount!=0){ | 
 
 
 
 
 | 1385 | result+=QString::number(disabledCount) + (disabledCount==1?" item ":" items ") + "Disabled"; | 
 
 
 
 
 | 1386 | } | 
 
 
 
 
 | 1387 |  | 
 
 
 
 
 | 1388 | showSuccessStatusMessage(result); | 
 
 
 
 
 | 1389 | } | 
 
 
 
 
 | 1390 |  | 
 
 
 
 
 | 1391 | delete copy; | 
 
 
 
 
 | 1392 | delete moveUp; | 
 
 
 
 
 | 1393 | delete moveDown; | 
 
 
 
 
 | 1394 | delete changeOptions; | 
 
 
 
 
 | 1395 | delete outWorkspace; | 
 
 
 
 
 | 1396 | delete outCurrOutput; | 
 
 
 
 
 | 1397 | delete outOther; | 
 
 
 
 
 | 1398 | delete changeOutput; | 
 
 
 
 
 | 1399 | delete edisable; | 
 
 
 
 
 | 1400 | delete menu; | 
 
 
 
 
 | 1401 | } | 
 
 
 
 
 | 1402 |  | 
 
 
 
 
 | 1403 | void MainWindow::changeToCurrentSettings(QList<int> rows, DropTableWidget* myTable){ | 
 
 
 
 
 | 1404 | //construct a command for each one | 
 
 
 
 
 | 1405 | //Output a status message saying the number of changed files | 
 
 
 
 
 | 1406 | QString fromTo=getTypeConversion(myTable); | 
 
 
 
 
 | 1407 | QString 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 | 
 
 
 
 
 | 1408 | QString to = QString(fromTo).remove(0,fromTo.lastIndexOf("> ")+2); //+2 to start after "> " | 
 
 
 
 
 | 1409 |  | 
 
 
 
 
 | 1410 | QString command; | 
 
 
 
 
 | 1411 |  | 
 
 
 
 
 | 1412 | foreach(int row, rows){ | 
 
 
 
 
 | 1413 |  | 
 
 
 
 
 | 1414 | command=getCommand(myTable,getFileOutputFolder(fromTo,myTable->getOutputAbsolute(row)),from,to,myTable->getFileAbsolute(row)); | 
 
 
 
 
 | 1415 |  | 
 
 
 
 
 | 1416 | if(command.isEmpty()){ //something wrong was happening (not inputted a texture name?) | 
 
 
 
 
 | 1417 | return; //stop changing settings | 
 
 
 
 
 | 1418 | } | 
 
 
 
 
 | 1419 |  | 
 
 
 
 
 | 1420 | myTable->item(row,2)->setText(command); //update settings to the current row | 
 
 
 
 
 | 1421 | myTable->updateTableToolTips(row); | 
 
 
 
 
 | 1422 | } | 
 
 
 
 
 | 1423 |  | 
 
 
 
 
 | 1424 | showSuccessStatusMessage(QString::number(rows.size()) + (rows.size()==1?" item ":" items ")+ "changed to the current settings"); | 
 
 
 
 
 | 1425 | } | 
 
 
 
 
 | 1426 |  | 
 
 
 
 
 | 1427 | void MainWindow::changeItemsOutput(DropTableWidget* myTable, QList<int> rows, QString newOutput){ | 
 
 
 
 
 | 1428 |  | 
 
 
 
 
 | 1429 | QString command, currentAbsoluteFile, fromTo, from, to; | 
 
 
 
 
 | 1430 |  | 
 
 
 
 
 | 1431 | foreach(int row, rows){ //No optimization possible here, commands may be different | 
 
 
 
 
 | 1432 | fromTo=myTable->item(row,1)->text(); | 
 
 
 
 
 | 1433 | from = QString(fromTo).remove(fromTo.indexOf(" >"),fromTo.size()-1); //parse the string to get the from | 
 
 
 
 
 | 1434 | to = QString(fromTo).remove(0,fromTo.lastIndexOf("> ")+2); //+2 to start after "> " | 
 
 
 
 
 | 1435 |  | 
 
 
 
 
 | 1436 | currentAbsoluteFile=myTable->getFileAbsolute(row); | 
 
 
 
 
 | 1437 | command=getCommand(myTable,getFileOutputFolder(fromTo,newOutput),from,to,currentAbsoluteFile); | 
 
 
 
 
 | 1438 |  | 
 
 
 
 
 | 1439 | if(command.isEmpty()){ //something wrong was happening (not inputted a texture name?) | 
 
 
 
 
 | 1440 | return; //stop changing output | 
 
 
 
 
 | 1441 | } | 
 
 
 
 
 | 1442 |  | 
 
 
 
 
 | 1443 | myTable->item(row,2)->setText(command); //update command to the current row | 
 
 
 
 
 | 1444 | myTable->updateTableToolTips(row); | 
 
 
 
 
 | 1445 | } | 
 
 
 
 
 | 1446 |  | 
 
 
 
 
 | 1447 | showSuccessStatusMessage(QString::number(rows.size()) + (rows.size()==1?" item ":" items ")+ "changed the output to "+(newOutput!=this->workspaceLocation?Util::cutName(newOutput):"Vago workspace")); | 
 
 
 
 
 | 1448 | } | 
 
 
 
 
 | 1449 |  | 
 
 
 
 
 | 1450 | QString MainWindow::getCommand(DropTableWidget* myTable, QString myOutputFolder, QString from, QString to , QString file){ | 
 
 
 
 
 | 1451 | if(myTable==ui->twSourcesGeneral){ //So we only need to parse one command. | 
 
 
 
 
 | 1452 | return fileParsingGeneral(myOutputFolder,from,to,file); | 
 
 
 
 
 | 1453 | } | 
 
 
 
 
 | 1454 | else if(myTable==ui->twSourcesTextures){ | 
 
 
 
 
 | 1455 | return fileParsingTextures(myOutputFolder,from,to,file); | 
 
 
 
 
 | 1456 | } | 
 
 
 
 
 | 1457 | else if(myTable==ui->twSourcesModels){ | 
 
 
 
 
 | 1458 | return fileParsingModels(myOutputFolder,from,to,file); | 
 
 
 
 
 | 1459 | } | 
 
 
 
 
 | 1460 | else if(myTable==ui->twSourcesAnimations){ | 
 
 
 
 
 | 1461 | return fileParsingAnimations(myOutputFolder,from,to,file); | 
 
 
 
 
 | 1462 | } | 
 
 
 
 
 | 1463 | else if(myTable==ui->twSourcesLevels){ | 
 
 
 
 
 | 1464 | return fileParsingLevels(myOutputFolder,from,to,file); | 
 
 
 
 
 | 1465 | } | 
 
 
 
 
 | 1466 | else{ | 
 
 
 
 
 | 1467 | return fileParsingMisc(myOutputFolder,from,to,file); | 
 
 
 
 
 | 1468 | } | 
 
 
 
 
 | 1469 |  | 
 
 
 
 
 | 1470 | } | 
 
 
 
 
 | 1471 |  | 
 
 
 
 
 | 1472 | void MainWindow::connectSlots(){ | 
 
 
 
 
 | 1473 |  | 
 
 
 
 
 | 1474 | //This signal is for thread that is working setup the progress bar (make it visible and set it's min-max) | 
 
 
 
 
 | 1475 | connect(myConverter, SIGNAL(setupPB(int)), this, SLOT(TsetupProgressBar(int)), Qt::BlockingQueuedConnection); | 
 
 
 
 
 | 1476 |  | 
 
 
 
 
 | 1477 | //This signal is for thread that is working can update the progress bar of the gui | 
 
 
 
 
 | 1478 | connect(myConverter, SIGNAL(taskDone()), this, SLOT(TupdateProgressBar()),Qt::BlockingQueuedConnection); | 
 
 
 
 
 | 1479 |  | 
 
 
 
 
 | 1480 | //This signal is for thread that is working can show the result of a conversion | 
 
 
 
 
 | 1481 | connect(myConverter, SIGNAL(resultConversion(QString,int)), this, SLOT(TresultConversion(QString,int))); | 
 
 
 
 
 | 1482 |  | 
 
 
 
 
 | 1483 | //Drop signal for General table | 
 
 
 
 
 | 1484 | connect(ui->twSourcesGeneral, SIGNAL(dropped(DropTableWidget*,QStringList)), this, SLOT(addFilesSource(DropTableWidget*,QStringList))); | 
 
 
 
 
 | 1485 |  | 
 
 
 
 
 | 1486 | //Drop signal for Textures table | 
 
 
 
 
 | 1487 | connect(ui->twSourcesTextures, SIGNAL(dropped(DropTableWidget*,QStringList)), this, SLOT(addFilesSource(DropTableWidget*,QStringList))); | 
 
 
 
 
 | 1488 |  | 
 
 
 
 
 | 1489 | //Drop signal for Models table | 
 
 
 
 
 | 1490 | connect(ui->twSourcesModels, SIGNAL(dropped(DropTableWidget*,QStringList)), this, SLOT(addFilesSource(DropTableWidget*,QStringList))); | 
 
 
 
 
 | 1491 |  | 
 
 
 
 
 | 1492 | //Drop signal for Animations table | 
 
 
 
 
 | 1493 | connect(ui->twSourcesAnimations, SIGNAL(dropped(DropTableWidget*,QStringList)), this, SLOT(addFilesSource(DropTableWidget*,QStringList))); | 
 
 
 
 
 | 1494 |  | 
 
 
 
 
 | 1495 | //Drop signal for Levels table | 
 
 
 
 
 | 1496 | connect(ui->twSourcesLevels, SIGNAL(dropped(DropTableWidget*,QStringList)), this, SLOT(addFilesSource(DropTableWidget*,QStringList))); | 
 
 
 
 
 | 1497 |  | 
 
 
 
 
 | 1498 | //Drop signal for Misc table | 
 
 
 
 
 | 1499 | connect(ui->twSourcesMisc, SIGNAL(dropped(DropTableWidget*,QStringList)), this, SLOT(addFilesSource(DropTableWidget*,QStringList))); | 
 
 
 
 
 | 1500 |  | 
 
 
 
 
 | 1501 | //Context menu for General table | 
 
 
 
 
 | 1502 | connect(ui->twSourcesGeneral, SIGNAL(dtContextMenu(DropTableWidget*,QContextMenuEvent*)), this, SLOT(dtContextMenu(DropTableWidget*,QContextMenuEvent*))); | 
 
 
 
 
 | 1503 |  | 
 
 
 
 
 | 1504 | //Context menu for Textures table | 
 
 
 
 
 | 1505 | connect(ui->twSourcesTextures, SIGNAL(dtContextMenu(DropTableWidget*,QContextMenuEvent*)), this, SLOT(dtContextMenu(DropTableWidget*,QContextMenuEvent*))); | 
 
 
 
 
 | 1506 |  | 
 
 
 
 
 | 1507 | //Context menu for Models table | 
 
 
 
 
 | 1508 | connect(ui->twSourcesModels, SIGNAL(dtContextMenu(DropTableWidget*,QContextMenuEvent*)), this, SLOT(dtContextMenu(DropTableWidget*,QContextMenuEvent*))); | 
 
 
 
 
 | 1509 |  | 
 
 
 
 
 | 1510 | //Context menu for Animations table | 
 
 
 
 
 | 1511 | connect(ui->twSourcesAnimations, SIGNAL(dtContextMenu(DropTableWidget*,QContextMenuEvent*)), this, SLOT(dtContextMenu(DropTableWidget*,QContextMenuEvent*))); | 
 
 
 
 
 | 1512 |  | 
 
 
 
 
 | 1513 | //Context menu for Levels table | 
 
 
 
 
 | 1514 | connect(ui->twSourcesLevels, SIGNAL(dtContextMenu(DropTableWidget*,QContextMenuEvent*)), this, SLOT(dtContextMenu(DropTableWidget*,QContextMenuEvent*))); | 
 
 
 
 
 | 1515 |  | 
 
 
 
 
 | 1516 | //Context menu for Misc table | 
 
 
 
 
 | 1517 | connect(ui->twSourcesMisc, SIGNAL(dtContextMenu(DropTableWidget*,QContextMenuEvent*)), this, SLOT(dtContextMenu(DropTableWidget*,QContextMenuEvent*))); | 
 
 
 
 
 | 1518 | } | 
 
 
 
 
 | 1519 |  | 
 
 
 
 
 | 1520 |  |