--- Vago/trunk/Vago/soundWizard/soundpagefinal.cpp 2016/03/24 22:28:41 1035
+++ Vago/trunk/Vago/soundWizard/soundpagefinal.cpp 2016/10/30 16:01:17 1059
@@ -18,7 +18,7 @@ SoundPageFinal::SoundPageFinal(QString A
ui->lbComplete->setText("The wizard is now complete. The sounds have been converted. "
"You can view all converted files clicking here.
"
- "
Click restart to create more sounds from the wizard beggining,"
+ "
Click restart to create more sounds from the wizard beggining, "
"otherwise click finish."); // Don't use rich text in qtdesigner because it generates platform dependent code
connectSlots();
@@ -45,8 +45,10 @@ void SoundPageFinal::startProcessing(){
// Sample files names
QString ambFile="OSBDsample_file.amb.xml";
QString grpFile="OSBDsample_file.grp.xml";
+ QString impFile="OSBDsample_file.imp.xml";
QString ambFileLocation=GlobalVars::VagoTemporaryDir+"/"+ambFile;
QString grpFileLocation=GlobalVars::VagoTemporaryDir+"/"+grpFile;
+ QString impFileLocation=GlobalVars::VagoTemporaryDir+"/"+impFile;
// Page 2 variables
QString outputFolder;
@@ -68,6 +70,18 @@ void SoundPageFinal::startProcessing(){
bool preventRepeat=false;
bool stereo22=false, mono22=false, mono44Pc=false;
+ // Page 5 variables
+ QString minVolumeDistanceImp, maxVolumeDistanceImp, minAngleImp,
+ maxAngleImp, minAttenuationImp, impactVelocityImp,
+ minOcclusionImp, priorityImp;
+ bool priorityLowImp = false, priorityNormalImp = false,
+ priorityHighImp = false, priorityHighestImp = false;
+
+ // Create temp folder if it doesn't exist
+ if(!QDir(GlobalVars::VagoTemporaryDir).exists()){
+ QDir().mkdir(GlobalVars::VagoTemporaryDir);
+ }
+
// Get data page 2
if(field("rbOther").toBool()){
outputFolder=field("leOtherLocation").toString();
@@ -76,8 +90,6 @@ void SoundPageFinal::startProcessing(){
outputFolder=this->soundsLocation;
}
- outputFolder = Util::insertQuotes(outputFolder); // for onisplit work correctly
-
// Get data page 3
priorityLow=field("rbPriorityLow").toBool();
@@ -144,47 +156,83 @@ void SoundPageFinal::startProcessing(){
else if(mono22){
numberChannels="1";
}
+
+ // Get data page 5
+ priorityLowImp=field("rbPriorityLowImp").toBool();
+ priorityNormalImp=field("rbPriorityNormalImp").toBool();
+ priorityHighImp=field("rbPriorityHighImp").toBool();
+ priorityHighestImp=field("rbPriorityHighestImp").toBool();
+
+ if(priorityNormalImp){
+ priorityImp="Normal";
+ }
+ else if(priorityLowImp){
+ priorityImp="Low";
+ }
+ else if(priorityHighImp){
+ priorityImp="High";
+ }
+ else if(priorityHighestImp){
+ priorityImp="Highest";
+ }
+
+ minVolumeDistanceImp=Util::normalizeDecimalSeparator(field("leMinVolumeDistanceImp").toString());
+ maxVolumeDistanceImp=Util::normalizeDecimalSeparator(field("leMaxVolumeDistanceImp").toString());
+ minAngleImp=Util::normalizeDecimalSeparator(field("leMinAngleImp").toString());
+ maxAngleImp=Util::normalizeDecimalSeparator(field("leMaxAngleImp").toString());
+ minAttenuationImp=Util::normalizeDecimalSeparator(field("leMinAttenuationImp").toString());
+ impactVelocityImp=Util::normalizeDecimalSeparator(field("leImpactVelocityImp").toString());
+ minOcclusionImp=Util::normalizeDecimalSeparator(field("leMinOcclusionImp").toString());
+
//######################################################### Starting xml processing
// Clean tmp dir
- if(!Util::rmDir(GlobalVars::VagoTemporaryDir)){
- QString message="Couldn't clean vago temp dir for complete sound wizard. Aborting.\n"+GlobalVars::VagoTemporaryDir;
- this->myLogger->writeString(message);
- Util::showErrorLogPopUp(message);
+ if(!Util::rmDir(GlobalVars::VagoTemporaryDir)){
+ UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "Couldn't clean vago temp dir for complete sound wizard. Aborting.\n"+GlobalVars::VagoTemporaryDir);
return;
}
if(!QDir(QDir::tempPath()).mkpath("VagoTemp")){
- QString message="Couldn't reconstruct vago temp dir for complete sound wizard. Aborting.\n"+GlobalVars::VagoTemporaryDir;
- this->myLogger->writeString(message);
- Util::showErrorLogPopUp(message);
+ UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "Couldn't reconstruct vago temp dir for complete sound wizard. Aborting.\n"+GlobalVars::VagoTemporaryDir);
}
// Copy sample xml files to tmp dir
QFile::copy(":/new/sampleFiles/"+ambFile , ambFileLocation);
QFile::copy(":/new/sampleFiles/"+grpFile , grpFileLocation);
+ QFile::copy(":/new/sampleFiles/"+impFile , impFileLocation);
QFile::setPermissions(ambFileLocation, QFile::ReadOwner | QFile::WriteOwner); //remove read only attribute that come from resources
QFile::setPermissions(grpFileLocation, QFile::ReadOwner | QFile::WriteOwner);
+ QFile::setPermissions(impFileLocation, QFile::ReadOwner | QFile::WriteOwner);
- (*this->xmlCommands) << "replaceall -element:Priority -value:"+priority+" -filename:"+ambFileLocation+" -nobackups"
- << "replaceall -element:Flags -value:"+flags.join(" ")+" -filename:"+ambFileLocation+" -nobackups"
- << "replaceall -element:SphereRadius -value:"+sphereRadious+" -filename:"+ambFileLocation+" -nobackups"
- << "replaceall -element:Treshold -value:"+treshold+" -filename:"+ambFileLocation+" -nobackups"
- << "replaceall -element:MinOcclusion -value:"+minOcclusion+" -filename:"+ambFileLocation+" -nobackups"
- << "replaceall -parelement:ElapsedTime -element:Min -value:"+minElapsedTime+" -filename:"+ambFileLocation+" -nobackups"
- << "replaceall -parelement:Distance -element:Max -value:"+maxVolumeDistance+" -filename:"+ambFileLocation+" -nobackups"
- << "replaceall -parelement:Distance -element:Min -value:"+minVolumeDistance+" -filename:"+ambFileLocation+" -nobackups"
- << "replaceall -parelement:SoundGroup -element:Volume -value:"+volume+" -filename:"+grpFileLocation+" -nobackups"
- << "replaceall -parelement:SoundGroup -element:Pitch -value:"+pitch+" -filename:"+grpFileLocation+" -nobackups"
- << "replaceall -parelement:SoundGroup -element:NumberOfChannels -value:"+numberChannels+" -filename:"+grpFileLocation+" -nobackups"
- << "replaceall -parelement:Volume -element:Min -value:"+minVolume+" -filename:"+grpFileLocation+" -nobackups"
- << "replaceall -parelement:Volume -element:Max -value:"+maxVolume+" -filename:"+grpFileLocation+" -nobackups"
- << "replaceall -parelement:Pitch -element:Min -value:"+minPitch+" -filename:"+grpFileLocation+" -nobackups"
- << "replaceall -parelement:Pitch -element:Max -value:"+maxPitch+" -filename:"+grpFileLocation+" -nobackups"
- << "replaceall -element:Weight -value:"+weight+" -filename:"+grpFileLocation+" -nobackups";
+ (*this->xmlCommands)
+ << "--replace-all-values -e Priority -n "+Util::insertQuotes(priority)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values -e Flags -n "+(flags.join(" ").isEmpty() ? "\" \"" : Util::insertQuotes(flags.join(" ")))+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values -e SphereRadius -n "+Util::insertQuotes(sphereRadious)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values -e Treshold -n "+Util::insertQuotes(treshold)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values -e MinOcclusion -n "+Util::insertQuotes(minOcclusion)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values --parent-element-name ElapsedTime -e Max -n "+Util::insertQuotes(maxElapsedTime)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values --parent-element-name ElapsedTime -e Min -n "+Util::insertQuotes(minElapsedTime)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values --parent-element-name Distance -e Max -n "+Util::insertQuotes(maxVolumeDistance)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values --parent-element-name Distance -e Min -n "+Util::insertQuotes(minVolumeDistance)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values --parent-element-name SoundGroup -e Volume -n "+Util::insertQuotes(volume)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values --parent-element-name SoundGroup -e Pitch -n "+Util::insertQuotes(pitch)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values --parent-element-name SoundGroup -e NumberOfChannels -n "+Util::insertQuotes(numberChannels)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values --parent-element-name Volume -e Min -n "+Util::insertQuotes(minVolume)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values --parent-element-name Volume -e Max -n "+Util::insertQuotes(maxVolume)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values --parent-element-name Pitch -e Min -n "+Util::insertQuotes(minPitch)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values --parent-element-name Pitch -e Max -n "+Util::insertQuotes(maxPitch)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values -e Weight -n "+Util::insertQuotes(weight)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values -e Priority -n "+Util::insertQuotes(priorityImp)+" -f "+Util::insertQuotes(impFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values --parent-element-name Distance -e Min -n "+Util::insertQuotes(minVolumeDistanceImp)+" -f "+Util::insertQuotes(impFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values --parent-element-name Distance -e Max -n "+Util::insertQuotes(maxVolumeDistanceImp)+" -f "+Util::insertQuotes(impFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values --parent-element-name Angle -e Min -n "+Util::insertQuotes(minAngleImp)+" -f "+Util::insertQuotes(impFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values --parent-element-name Angle -e Max -n "+Util::insertQuotes(maxAngleImp)+" -f "+Util::insertQuotes(impFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values -e MinAttenuation -n "+Util::insertQuotes(minAttenuationImp)+" -f "+Util::insertQuotes(impFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values -e ImpactVelocity -n "+Util::insertQuotes(impactVelocityImp)+" -f "+Util::insertQuotes(impFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values -e MinOcclusion -n "+Util::insertQuotes(minOcclusionImp)+" -f "+Util::insertQuotes(impFileLocation)+" --no-backups --no-verbose";
if(preventRepeat){
- (*this->xmlCommands) << "replaceall -parelement:SoundGroup -element:Flags -value:PreventRepeat -filename:"+grpFileLocation+" -nobackups";
+ (*this->xmlCommands) << "--replace-all-values --parent-element-name SoundGroup -e Flags -n PreventRepeat -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose";
}
myXmlProcessor->start();
@@ -193,33 +241,35 @@ void SoundPageFinal::startProcessing(){
QString currFileName;
QString currGrpFileLocation;
QString currAmbFileLocation;
+ QString currImpFileLocation;
for(int i=0; ipage2Table->rowCount(); i++){
- (*this->oniSplitCommands) << this->commandMap->value("xml->XML->ONI")+" "+outputFolder+" "+Util::insertQuotes(this->page2Table->item(i,1)->text()); // add location of sound file to convert
+ (*this->oniSplitCommands) << this->commandMap->value("xml->XML->ONI")+" "+Util::insertQuotes(outputFolder)+" "+Util::insertQuotes(this->page2Table->item(i,1)->text()); // add location of sound file to convert
currFileName=this->page2Table->item(i,0)->text(); // get current file name
- currAmbFileLocation = QString(ambFileLocation).replace("sample_file",currFileName); // get the new files, filenames
- currGrpFileLocation = QString(grpFileLocation).replace("sample_file",currFileName);
+ currAmbFileLocation = outputFolder + "/" + QString(ambFile).replace("sample_file",currFileName); // get the new files, filenames
+ currGrpFileLocation = outputFolder + "/" + QString(grpFile).replace("sample_file",currFileName);
+ currImpFileLocation = outputFolder + "/" + QString(impFile).replace("sample_file",currFileName);
QFile::copy(ambFileLocation, currAmbFileLocation); // make a copy of the sample files that will be the real files
QFile::copy(grpFileLocation, currGrpFileLocation);
+ QFile::copy(impFileLocation, currImpFileLocation);
- (*this->xmlCommands) << "replaceall -element:BaseTrack1 -value:"+currFileName+" -filename:"+currAmbFileLocation+" -nobackups" // process the xml
- << "replaceall -element:Sound -value:"+currFileName+" -filename:"+currGrpFileLocation+" -nobackups";
+ (*this->xmlCommands) << "--replace-all-values -e BaseTrack1 -n "+Util::insertQuotes(currFileName)+" -f "+Util::insertQuotes(currAmbFileLocation)+" --no-backups --no-verbose" // process the xml
+ << "--replace-all-values -e Sound -n "+Util::insertQuotes(currFileName)+" -f "+Util::insertQuotes(currGrpFileLocation)+" --no-backups --no-verbose"
+ << "--replace-all-values -e Group -n "+Util::insertQuotes(currFileName)+" -f "+Util::insertQuotes(currImpFileLocation)+" --no-backups --no-verbose";
myXmlProcessor->start();
myXmlProcessor->wait(); // Wait until all xml is edited
- }
- (*this->oniSplitCommands) << this->commandMap->value("xml->XML->ONI")+" "+outputFolder+" "+Util::insertQuotes(GlobalVars::VagoTemporaryDir+"/*.xml");
+ (*this->oniSplitCommands) << this->commandMap->value("xml->XML->ONI")+" "+Util::insertQuotes(outputFolder)+" "+Util::insertQuotes(currAmbFileLocation);
+ (*this->oniSplitCommands) << this->commandMap->value("xml->XML->ONI")+" "+Util::insertQuotes(outputFolder)+" "+Util::insertQuotes(currGrpFileLocation);
+ (*this->oniSplitCommands) << this->commandMap->value("xml->XML->ONI")+" "+Util::insertQuotes(outputFolder)+" "+Util::insertQuotes(currImpFileLocation);
+ }
this->myConverter->start(); // finally process the onisplit commands
this->myConverter->wait(); // wait for it to complete
-
- // Finally remove the sample files, since not needed anymore
- QFile(ambFileLocation).remove();
- QFile(grpFileLocation).remove();
}
void SoundPageFinal::catchXmlAndOSplitProcessingError(QString result, int numErrors){
@@ -227,10 +277,10 @@ void SoundPageFinal::catchXmlAndOSplitPr
if(numErrors!=0){
QString sNumErrors=QString::number(numErrors);
if(numErrors>1){
- Util::showErrorLogPopUp(result+"\n This is the last of "+sNumErrors+" Errors.");
+ UtilVago::showErrorPopUpLogButton(result+"\n This is the last of " + sNumErrors + " errors.");
}
else{
- Util::showErrorLogPopUp(result);
+ UtilVago::showErrorPopUpLogButton(result);
}
}
}