ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/s10k/Vago/soundWizard/soundpagefinal.cpp
(Generate patch)

Comparing Vago/trunk/Vago/soundWizard/soundpagefinal.cpp (file contents):
Revision 771 by s10k, Sun Mar 31 19:02:16 2013 UTC vs.
Revision 1054 by s10k, Wed Oct 12 21:35:13 2016 UTC

# Line 1 | Line 1
1   #include "soundpagefinal.h"
2   #include "ui_soundpagefinal.h"
3  
4 < SoundPageFinal::SoundPageFinal(QString soundsLocation, DropTableWidget *page2Table, Logger *myLogger, QHash<QString, QString> *commandMap, QWidget *parent) :
4 > SoundPageFinal::SoundPageFinal(QString AppDir, QString soundsLocation, DropTableWidget *page2Table, Logger *myLogger, QHash<QString, QString> *commandMap, QWidget *parent) :
5      QWizardPage(parent),
6      ui(new Ui::soundpagefinal)
7   {
# Line 13 | Line 13 | SoundPageFinal::SoundPageFinal(QString s
13  
14      this->xmlCommands = new QStringList();
15      this->oniSplitCommands = new QStringList();
16 <    this->myXmlProcessor = new XmlProcessor(this->myLogger,this->xmlCommands);
17 <    this->myConverter = new Converter(this->myLogger,this->oniSplitCommands);
16 >    this->myXmlProcessor = new XmlProcessor(AppDir, this->myLogger,this->xmlCommands);
17 >    this->myConverter = new Converter(AppDir, this->myLogger,this->oniSplitCommands);
18 >
19 >    ui->lbComplete->setText("<html>The wizard is now complete. The sounds have been converted. "
20 >                            "You can view all converted files clicking <a href=' '>here.</a><br />"
21 >                            "<br />Click restart to create more sounds from the wizard beggining, "
22 >                            "otherwise click finish.</html>"); // Don't use rich text in qtdesigner because it generates platform dependent code
23  
24      connectSlots();
25   }
# Line 40 | Line 45 | void SoundPageFinal::startProcessing(){
45      // Sample files names
46      QString ambFile="OSBDsample_file.amb.xml";
47      QString grpFile="OSBDsample_file.grp.xml";
48 +    QString impFile="OSBDsample_file.imp.xml";
49      QString ambFileLocation=GlobalVars::VagoTemporaryDir+"/"+ambFile;
50      QString grpFileLocation=GlobalVars::VagoTemporaryDir+"/"+grpFile;
51 +    QString impFileLocation=GlobalVars::VagoTemporaryDir+"/"+impFile;
52  
53      // Page 2 variables
54      QString outputFolder;
# Line 63 | Line 70 | void SoundPageFinal::startProcessing(){
70      bool preventRepeat=false;
71      bool stereo22=false, mono22=false, mono44Pc=false;
72  
73 +    // Page 5 variables
74 +    QString minVolumeDistanceImp, maxVolumeDistanceImp, minAngleImp,
75 +            maxAngleImp, minAttenuationImp, impactVelocityImp,
76 +            minOcclusionImp, priorityImp;
77 +    bool priorityLowImp = false, priorityNormalImp = false,
78 +            priorityHighImp = false, priorityHighestImp = false;
79 +
80      // Get data page 2
81      if(field("rbOther").toBool()){
82          outputFolder=field("leOtherLocation").toString();
# Line 71 | Line 85 | void SoundPageFinal::startProcessing(){
85          outputFolder=this->soundsLocation;
86      }
87  
74    outputFolder = Util::insertQuotes(outputFolder); // for onisplit work correctly
75
88      // Get data page 3
89  
90      priorityLow=field("rbPriorityLow").toBool();
# Line 139 | Line 151 | void SoundPageFinal::startProcessing(){
151      else if(mono22){
152          numberChannels="1";
153      }
154 +
155 +    // Get data page 5
156 +    priorityLowImp=field("rbPriorityLowImp").toBool();
157 +    priorityNormalImp=field("rbPriorityNormalImp").toBool();
158 +    priorityHighImp=field("rbPriorityHighImp").toBool();
159 +    priorityHighestImp=field("rbPriorityHighestImp").toBool();
160 +
161 +    if(priorityNormalImp){
162 +        priorityImp="Normal";
163 +    }
164 +    else if(priorityLowImp){
165 +        priorityImp="Low";
166 +    }
167 +    else if(priorityHighImp){
168 +        priorityImp="High";
169 +    }
170 +    else if(priorityHighestImp){
171 +        priorityImp="Highest";
172 +    }
173 +
174 +    minVolumeDistanceImp=Util::normalizeDecimalSeparator(field("leMinVolumeDistanceImp").toString());
175 +    maxVolumeDistanceImp=Util::normalizeDecimalSeparator(field("leMaxVolumeDistanceImp").toString());
176 +    minAngleImp=Util::normalizeDecimalSeparator(field("leMinAngleImp").toString());
177 +    maxAngleImp=Util::normalizeDecimalSeparator(field("leMaxAngleImp").toString());
178 +    minAttenuationImp=Util::normalizeDecimalSeparator(field("leMinAttenuationImp").toString());
179 +    impactVelocityImp=Util::normalizeDecimalSeparator(field("leImpactVelocityImp").toString());
180 +    minOcclusionImp=Util::normalizeDecimalSeparator(field("leMinOcclusionImp").toString());
181 +
182      //######################################################### Starting xml processing
183  
184      // Clean tmp dir
185 <    if(!Util::rmDir(GlobalVars::VagoTemporaryDir)){
186 <        QString message="Couldn't clean vago temp dir for complete sound wizard. Aborting.\n"+GlobalVars::VagoTemporaryDir;
147 <        this->myLogger->writeString(message);
148 <        Util::showErrorLogPopUp(message);
185 >    if(!Util::rmDir(GlobalVars::VagoTemporaryDir)){        
186 >        UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "Couldn't clean vago temp dir for complete sound wizard. Aborting.\n"+GlobalVars::VagoTemporaryDir);
187          return;
188      }
189  
190      if(!QDir(QDir::tempPath()).mkpath("VagoTemp")){
191 <        QString message="Couldn't reconstruct vago temp dir for complete sound wizard. Aborting.\n"+GlobalVars::VagoTemporaryDir;
154 <        this->myLogger->writeString(message);
155 <        Util::showErrorLogPopUp(message);
191 >        UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "Couldn't reconstruct vago temp dir for complete sound wizard. Aborting.\n"+GlobalVars::VagoTemporaryDir);
192      }
193  
194      // Copy sample xml files to tmp dir
195      QFile::copy(":/new/sampleFiles/"+ambFile , ambFileLocation);
196      QFile::copy(":/new/sampleFiles/"+grpFile , grpFileLocation);
197 +    QFile::copy(":/new/sampleFiles/"+impFile , impFileLocation);
198      QFile::setPermissions(ambFileLocation, QFile::ReadOwner | QFile::WriteOwner); //remove read only attribute that come from resources
199      QFile::setPermissions(grpFileLocation, QFile::ReadOwner | QFile::WriteOwner);
200 +    QFile::setPermissions(impFileLocation, QFile::ReadOwner | QFile::WriteOwner);
201  
202 <    (*this->xmlCommands) << "replaceall -element:Priority -value:"+priority+" -filename:"+ambFileLocation+" -nobackups"
203 <                         << "replaceall -element:Flags -value:"+flags.join(" ")+" -filename:"+ambFileLocation+" -nobackups"
204 <                         << "replaceall -element:SphereRadius -value:"+sphereRadious+" -filename:"+ambFileLocation+" -nobackups"
205 <                         << "replaceall -element:Treshold -value:"+treshold+" -filename:"+ambFileLocation+" -nobackups"
206 <                         << "replaceall -element:MinOcclusion -value:"+minOcclusion+" -filename:"+ambFileLocation+" -nobackups"
207 <                         << "replaceall -parelement:ElapsedTime -element:Min -value:"+minElapsedTime+" -filename:"+ambFileLocation+" -nobackups"
208 <                         << "replaceall -parelement:Distance -element:Max -value:"+maxVolumeDistance+" -filename:"+ambFileLocation+" -nobackups"
209 <                         << "replaceall -parelement:Distance -element:Min -value:"+minVolumeDistance+" -filename:"+ambFileLocation+" -nobackups"
210 <                         << "replaceall -parelement:SoundGroup -element:Volume -value:"+volume+" -filename:"+grpFileLocation+" -nobackups"
211 <                         << "replaceall -parelement:SoundGroup -element:Pitch -value:"+pitch+" -filename:"+grpFileLocation+" -nobackups"
212 <                         << "replaceall -parelement:SoundGroup -element:NumberOfChannels -value:"+numberChannels+" -filename:"+grpFileLocation+" -nobackups"
213 <                         << "replaceall -parelement:Volume -element:Min -value:"+minVolume+" -filename:"+grpFileLocation+" -nobackups"
214 <                         << "replaceall -parelement:Volume -element:Max -value:"+maxVolume+" -filename:"+grpFileLocation+" -nobackups"
215 <                         << "replaceall -parelement:Pitch -element:Min -value:"+minPitch+" -filename:"+grpFileLocation+" -nobackups"
216 <                         << "replaceall -parelement:Pitch -element:Max -value:"+maxPitch+" -filename:"+grpFileLocation+" -nobackups"
217 <                         << "replaceall -element:Weight -value:"+weight+" -filename:"+grpFileLocation+" -nobackups";
202 >    (*this->xmlCommands)
203 >     << "--replace-all-values -e Priority -n "+Util::insertQuotes(priority)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
204 >     << "--replace-all-values -e Flags -n "+(flags.join(" ").isEmpty() ? "\" \"" : Util::insertQuotes(flags.join(" ")))+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
205 >     << "--replace-all-values -e SphereRadius -n "+Util::insertQuotes(sphereRadious)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
206 >     << "--replace-all-values -e Treshold -n "+Util::insertQuotes(treshold)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
207 >     << "--replace-all-values -e MinOcclusion -n "+Util::insertQuotes(minOcclusion)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
208 >     << "--replace-all-values --parent-element-name ElapsedTime -e  Max -n "+Util::insertQuotes(maxElapsedTime)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
209 >     << "--replace-all-values --parent-element-name ElapsedTime -e  Min -n "+Util::insertQuotes(minElapsedTime)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
210 >     << "--replace-all-values --parent-element-name Distance -e  Max -n "+Util::insertQuotes(maxVolumeDistance)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
211 >     << "--replace-all-values --parent-element-name Distance -e  Min -n "+Util::insertQuotes(minVolumeDistance)+" -f "+Util::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
212 >     << "--replace-all-values --parent-element-name SoundGroup -e  Volume -n "+Util::insertQuotes(volume)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"
213 >     << "--replace-all-values --parent-element-name SoundGroup -e  Pitch -n "+Util::insertQuotes(pitch)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"
214 >     << "--replace-all-values --parent-element-name SoundGroup -e  NumberOfChannels -n "+Util::insertQuotes(numberChannels)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"
215 >     << "--replace-all-values --parent-element-name Volume -e  Min -n "+Util::insertQuotes(minVolume)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"
216 >     << "--replace-all-values --parent-element-name Volume -e  Max -n "+Util::insertQuotes(maxVolume)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"
217 >     << "--replace-all-values --parent-element-name Pitch -e  Min -n "+Util::insertQuotes(minPitch)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"
218 >     << "--replace-all-values --parent-element-name Pitch -e  Max -n "+Util::insertQuotes(maxPitch)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"
219 >     << "--replace-all-values -e  Weight -n "+Util::insertQuotes(weight)+" -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"
220 >     << "--replace-all-values -e  Priority -n "+Util::insertQuotes(priorityImp)+" -f "+Util::insertQuotes(impFileLocation)+" --no-backups --no-verbose"
221 >     << "--replace-all-values --parent-element-name Distance -e  Min -n "+Util::insertQuotes(minVolumeDistanceImp)+" -f "+Util::insertQuotes(impFileLocation)+" --no-backups --no-verbose"
222 >     << "--replace-all-values --parent-element-name Distance -e  Max -n "+Util::insertQuotes(maxVolumeDistanceImp)+" -f "+Util::insertQuotes(impFileLocation)+" --no-backups --no-verbose"
223 >     << "--replace-all-values --parent-element-name Angle -e  Min -n "+Util::insertQuotes(minAngleImp)+" -f "+Util::insertQuotes(impFileLocation)+" --no-backups --no-verbose"
224 >     << "--replace-all-values --parent-element-name Angle -e  Max -n "+Util::insertQuotes(maxAngleImp)+" -f "+Util::insertQuotes(impFileLocation)+" --no-backups --no-verbose"
225 >     << "--replace-all-values -e  MinAttenuation -n "+Util::insertQuotes(minAttenuationImp)+" -f "+Util::insertQuotes(impFileLocation)+" --no-backups --no-verbose"
226 >     << "--replace-all-values -e  ImpactVelocity -n "+Util::insertQuotes(impactVelocityImp)+" -f "+Util::insertQuotes(impFileLocation)+" --no-backups --no-verbose"
227 >     << "--replace-all-values -e  MinOcclusion -n "+Util::insertQuotes(minOcclusionImp)+" -f "+Util::insertQuotes(impFileLocation)+" --no-backups --no-verbose";
228  
229      if(preventRepeat){
230 <        (*this->xmlCommands) << "replaceall -parelement:SoundGroup -element:Flags -value:PreventRepeat -filename:"+grpFileLocation+" -nobackups";
230 >        (*this->xmlCommands) << "--replace-all-values --parent-element-name SoundGroup -e Flags -n PreventRepeat -f "+Util::insertQuotes(grpFileLocation)+" --no-backups --no-verbose";
231      }
232  
233      myXmlProcessor->start();
# Line 188 | Line 236 | void SoundPageFinal::startProcessing(){
236      QString currFileName;
237      QString currGrpFileLocation;
238      QString currAmbFileLocation;
239 +    QString currImpFileLocation;
240  
241      for(int i=0; i<this->page2Table->rowCount(); i++){
242  
243 <        (*this->oniSplitCommands) << this->commandMap->value("general->XML->ONI")+" "+outputFolder+" "+Util::insertQuotes(this->page2Table->item(i,1)->text()); // add location of sound file to convert
243 >        (*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
244  
245          currFileName=this->page2Table->item(i,0)->text(); // get current file name
246 <        currAmbFileLocation = QString(ambFileLocation).replace("sample_file",currFileName); // get the new files, filenames
247 <        currGrpFileLocation = QString(grpFileLocation).replace("sample_file",currFileName);
246 >        currAmbFileLocation = outputFolder + "/" + QString(ambFile).replace("sample_file",currFileName); // get the new files, filenames
247 >        currGrpFileLocation = outputFolder + "/" + QString(grpFile).replace("sample_file",currFileName);
248 >        currImpFileLocation = outputFolder + "/" + QString(impFile).replace("sample_file",currFileName);
249  
250          QFile::copy(ambFileLocation, currAmbFileLocation); // make a copy of the sample files that will be the real files
251          QFile::copy(grpFileLocation, currGrpFileLocation);
252 +        QFile::copy(impFileLocation, currImpFileLocation);
253  
254 <        (*this->xmlCommands) << "replaceall -element:BaseTrack1 -value:"+currFileName+" -filename:"+currAmbFileLocation+" -nobackups" // process the xml
255 <                             << "replaceall -element:Sound -value:"+currFileName+" -filename:"+currGrpFileLocation+" -nobackups";
254 >        (*this->xmlCommands) << "--replace-all-values -e BaseTrack1 -n "+Util::insertQuotes(currFileName)+" -f "+Util::insertQuotes(currAmbFileLocation)+" --no-backups --no-verbose" // process the xml
255 >                             << "--replace-all-values -e Sound -n "+Util::insertQuotes(currFileName)+" -f "+Util::insertQuotes(currGrpFileLocation)+" --no-backups --no-verbose"
256 >                             << "--replace-all-values -e Group -n "+Util::insertQuotes(currFileName)+" -f "+Util::insertQuotes(currImpFileLocation)+" --no-backups --no-verbose";
257  
258          myXmlProcessor->start();
259          myXmlProcessor->wait(); // Wait until all xml is edited
208    }
260  
261 <    (*this->oniSplitCommands) << this->commandMap->value("general->XML->ONI")+" "+outputFolder+" "+Util::insertQuotes(GlobalVars::VagoTemporaryDir+"/*.xml");
261 >        (*this->oniSplitCommands) << this->commandMap->value("xml->XML->ONI")+" "+Util::insertQuotes(outputFolder)+" "+Util::insertQuotes(currAmbFileLocation);
262 >        (*this->oniSplitCommands) << this->commandMap->value("xml->XML->ONI")+" "+Util::insertQuotes(outputFolder)+" "+Util::insertQuotes(currGrpFileLocation);
263 >        (*this->oniSplitCommands) << this->commandMap->value("xml->XML->ONI")+" "+Util::insertQuotes(outputFolder)+" "+Util::insertQuotes(currImpFileLocation);
264 >    }
265  
266      this->myConverter->start(); // finally process the onisplit commands
267      this->myConverter->wait(); // wait for it to complete
214
215    // Finally remove the sample files, since not needed anymore
216    QFile(ambFileLocation).remove();
217    QFile(grpFileLocation).remove();
268   }
269  
270   void SoundPageFinal::catchXmlAndOSplitProcessingError(QString result, int numErrors){
# Line 222 | Line 272 | void SoundPageFinal::catchXmlAndOSplitPr
272      if(numErrors!=0){
273          QString sNumErrors=QString::number(numErrors);
274          if(numErrors>1){
275 <            Util::showErrorLogPopUp(result+"\n This is the last of "+sNumErrors+" Errors.");
275 >            UtilVago::showErrorPopUpLogButton(result+"\n This is the last of " + sNumErrors + " errors.");
276          }
277          else{
278 <            Util::showErrorLogPopUp(result);
278 >            UtilVago::showErrorPopUpLogButton(result);
279          }
280      }
281   }

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)