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