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.
s10k/Vago/soundWizard/soundpagefinal.cpp (file contents), Revision 1093 by s10k, Sat Dec 30 13:57:32 2017 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, QHash<QString, QString> *commandMap, QWidget *parent) :
5      QWizardPage(parent),
6      ui(new Ui::soundpagefinal)
7   {
8      ui->setupUi(this);
9      this->soundsLocation=soundsLocation;
10      this->page2Table=page2Table;
11    this->myLogger=myLogger;
11      this->commandMap=commandMap;
12  
13      this->xmlCommands = new QStringList();
14      this->oniSplitCommands = new QStringList();
15 <    this->myXmlProcessor = new XmlProcessor(this->myLogger,this->xmlCommands);
16 <    this->myConverter = new Converter(this->myLogger,this->oniSplitCommands);
15 >    this->myXmlProcessor = new XmlProcessor(AppDir, this->xmlCommands);
16 >    this->myConverter = new Converter(AppDir,this->oniSplitCommands);
17 >
18 >    ui->lbComplete->setText("<html>The wizard is now complete. The sounds have been converted. "
19 >                            "You can view all converted files clicking <a href=' '>here.</a><br />"
20 >                            "<br />Click restart to create more sounds from the wizard beggining, "
21 >                            "otherwise click finish.</html>"); // Don't use rich text in qtdesigner because it generates platform dependent code
22  
23      connectSlots();
24   }
# Line 40 | Line 44 | void SoundPageFinal::startProcessing(){
44      // Sample files names
45      QString ambFile="OSBDsample_file.amb.xml";
46      QString grpFile="OSBDsample_file.grp.xml";
47 +    QString impFile="OSBDsample_file.imp.xml";
48      QString ambFileLocation=GlobalVars::VagoTemporaryDir+"/"+ambFile;
49      QString grpFileLocation=GlobalVars::VagoTemporaryDir+"/"+grpFile;
50 +    QString impFileLocation=GlobalVars::VagoTemporaryDir+"/"+impFile;
51  
52      // Page 2 variables
53      QString outputFolder;
# Line 63 | Line 69 | void SoundPageFinal::startProcessing(){
69      bool preventRepeat=false;
70      bool stereo22=false, mono22=false, mono44Pc=false;
71  
72 +    // Page 5 variables
73 +    QString minVolumeDistanceImp, maxVolumeDistanceImp, minAngleImp,
74 +            maxAngleImp, minAttenuationImp, impactVelocityImp,
75 +            minOcclusionImp, priorityImp;
76 +    bool priorityLowImp = false, priorityNormalImp = false,
77 +            priorityHighImp = false, priorityHighestImp = false;
78 +
79 +    // Create temp folder if it doesn't exist
80 +    if(!QDir(GlobalVars::VagoTemporaryDir).exists()){
81 +        QDir().mkdir(GlobalVars::VagoTemporaryDir);
82 +    }
83 +
84      // Get data page 2
85      if(field("rbOther").toBool()){
86          outputFolder=field("leOtherLocation").toString();
# Line 71 | Line 89 | void SoundPageFinal::startProcessing(){
89          outputFolder=this->soundsLocation;
90      }
91  
74    outputFolder = Util::insertQuotes(outputFolder); // for onisplit work correctly
75
92      // Get data page 3
93  
94      priorityLow=field("rbPriorityLow").toBool();
95      priorityNormal=field("rbPriorityNormal").toBool();
96      priorityHigh=field("rbPriorityHigh").toBool();
97      priorityHighest=field("rbPriorityHighest").toBool();
98 +    interruptOnStop=field("cbInterruptOnStop").toBool();
99 +    playOnce=field("cbPlayOnce").toBool();
100 +    canPan=field("cbCanPan").toBool();
101  
102      if(priorityNormal){
103          priority="Normal";
# Line 105 | Line 124 | void SoundPageFinal::startProcessing(){
124          flags << "CanPan";
125      }
126  
127 <    interruptOnStop=field("cbInterruptOnStop").toBool();
128 <    playOnce=field("cbPlayOnce").toBool();
129 <    canPan=field("cbCanPan").toBool();
130 <
131 <    sphereRadious=Util::normalizeDecimalSeparator(field("leSphereRadious").toString());
132 <    minElapsedTime=Util::normalizeDecimalSeparator(field("leMinElapsedTime").toString());
133 <    maxElapsedTime=Util::normalizeDecimalSeparator(field("leMaxElapsedTime").toString());
115 <    minVolumeDistance=Util::normalizeDecimalSeparator(field("leMinVolumeDistance").toString());
116 <    maxVolumeDistance=Util::normalizeDecimalSeparator(field("leMaxVolumeDistance").toString());
117 <    minOcclusion=Util::normalizeDecimalSeparator(field("leMinOcclusion").toString());
118 <    treshold=Util::normalizeDecimalSeparator(field("leTreshold").toString());
127 >    sphereRadious=Util::String::normalizeDecimalSeparator(field("leSphereRadious").toString());
128 >    minElapsedTime=Util::String::normalizeDecimalSeparator(field("leMinElapsedTime").toString());
129 >    maxElapsedTime=Util::String::normalizeDecimalSeparator(field("leMaxElapsedTime").toString());
130 >    minVolumeDistance=Util::String::normalizeDecimalSeparator(field("leMinVolumeDistance").toString());
131 >    maxVolumeDistance=Util::String::normalizeDecimalSeparator(field("leMaxVolumeDistance").toString());
132 >    minOcclusion=Util::String::normalizeDecimalSeparator(field("leMinOcclusion").toString());
133 >    treshold=Util::String::normalizeDecimalSeparator(field("leTreshold").toString());
134  
135      // Get data page 4
136  
137 <    volume=Util::normalizeDecimalSeparator(field("leVolume").toString());
138 <    minVolume=Util::normalizeDecimalSeparator(field("leMinVolume").toString());
139 <    maxVolume=Util::normalizeDecimalSeparator(field("leMaxVolume").toString());
140 <    pitch=Util::normalizeDecimalSeparator(field("lePitch").toString());
141 <    minPitch=Util::normalizeDecimalSeparator(field("leMinPitch").toString());
142 <    maxPitch=Util::normalizeDecimalSeparator(field("leMaxPitch").toString());
143 <    weight=Util::normalizeDecimalSeparator(field("leWeight").toString());
137 >    volume=Util::String::normalizeDecimalSeparator(field("leVolume").toString());
138 >    minVolume=Util::String::normalizeDecimalSeparator(field("leMinVolume").toString());
139 >    maxVolume=Util::String::normalizeDecimalSeparator(field("leMaxVolume").toString());
140 >    pitch=Util::String::normalizeDecimalSeparator(field("lePitch").toString());
141 >    minPitch=Util::String::normalizeDecimalSeparator(field("leMinPitch").toString());
142 >    maxPitch=Util::String::normalizeDecimalSeparator(field("leMaxPitch").toString());
143 >    weight=Util::String::normalizeDecimalSeparator(field("leWeight").toString());
144  
145      preventRepeat=field("cbPreventRepeat").toBool();
146  
# Line 139 | Line 154 | void SoundPageFinal::startProcessing(){
154      else if(mono22){
155          numberChannels="1";
156      }
157 +
158 +    // Get data page 5
159 +    priorityLowImp=field("rbPriorityLowImp").toBool();
160 +    priorityNormalImp=field("rbPriorityNormalImp").toBool();
161 +    priorityHighImp=field("rbPriorityHighImp").toBool();
162 +    priorityHighestImp=field("rbPriorityHighestImp").toBool();
163 +
164 +    if(priorityNormalImp){
165 +        priorityImp="Normal";
166 +    }
167 +    else if(priorityLowImp){
168 +        priorityImp="Low";
169 +    }
170 +    else if(priorityHighImp){
171 +        priorityImp="High";
172 +    }
173 +    else if(priorityHighestImp){
174 +        priorityImp="Highest";
175 +    }
176 +
177 +    minVolumeDistanceImp=Util::String::normalizeDecimalSeparator(field("leMinVolumeDistanceImp").toString());
178 +    maxVolumeDistanceImp=Util::String::normalizeDecimalSeparator(field("leMaxVolumeDistanceImp").toString());
179 +    minAngleImp=Util::String::normalizeDecimalSeparator(field("leMinAngleImp").toString());
180 +    maxAngleImp=Util::String::normalizeDecimalSeparator(field("leMaxAngleImp").toString());
181 +    minAttenuationImp=Util::String::normalizeDecimalSeparator(field("leMinAttenuationImp").toString());
182 +    impactVelocityImp=Util::String::normalizeDecimalSeparator(field("leImpactVelocityImp").toString());
183 +    minOcclusionImp=Util::String::normalizeDecimalSeparator(field("leMinOcclusionImp").toString());
184 +
185      //######################################################### Starting xml processing
186  
187      // Clean tmp dir
188 <    if(!Util::rmDir(GlobalVars::VagoTemporaryDir)){
189 <        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);
188 >    if(!Util::FileSystem::rmDir(GlobalVars::VagoTemporaryDir)){
189 >        UtilVago::showAndLogErrorPopUpLogButton("Couldn't clean vago temp dir for complete sound wizard. Aborting.\n"+GlobalVars::VagoTemporaryDir);
190          return;
191      }
192  
193      if(!QDir(QDir::tempPath()).mkpath("VagoTemp")){
194 <        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);
194 >        UtilVago::showAndLogErrorPopUpLogButton("Couldn't reconstruct vago temp dir for complete sound wizard. Aborting.\n"+GlobalVars::VagoTemporaryDir);
195      }
196  
197      // Copy sample xml files to tmp dir
198      QFile::copy(":/new/sampleFiles/"+ambFile , ambFileLocation);
199      QFile::copy(":/new/sampleFiles/"+grpFile , grpFileLocation);
200 +    QFile::copy(":/new/sampleFiles/"+impFile , impFileLocation);
201      QFile::setPermissions(ambFileLocation, QFile::ReadOwner | QFile::WriteOwner); //remove read only attribute that come from resources
202      QFile::setPermissions(grpFileLocation, QFile::ReadOwner | QFile::WriteOwner);
203 +    QFile::setPermissions(impFileLocation, QFile::ReadOwner | QFile::WriteOwner);
204  
205 <    (*this->xmlCommands) << "replaceall -element:Priority -value:"+priority+" -filename:"+ambFileLocation+" -nobackups"
206 <                         << "replaceall -element:Flags -value:"+flags.join(" ")+" -filename:"+ambFileLocation+" -nobackups"
207 <                         << "replaceall -element:SphereRadius -value:"+sphereRadious+" -filename:"+ambFileLocation+" -nobackups"
208 <                         << "replaceall -element:Treshold -value:"+treshold+" -filename:"+ambFileLocation+" -nobackups"
209 <                         << "replaceall -element:MinOcclusion -value:"+minOcclusion+" -filename:"+ambFileLocation+" -nobackups"
210 <                         << "replaceall -parelement:ElapsedTime -element:Min -value:"+minElapsedTime+" -filename:"+ambFileLocation+" -nobackups"
211 <                         << "replaceall -parelement:Distance -element:Max -value:"+maxVolumeDistance+" -filename:"+ambFileLocation+" -nobackups"
212 <                         << "replaceall -parelement:Distance -element:Min -value:"+minVolumeDistance+" -filename:"+ambFileLocation+" -nobackups"
213 <                         << "replaceall -parelement:SoundGroup -element:Volume -value:"+volume+" -filename:"+grpFileLocation+" -nobackups"
214 <                         << "replaceall -parelement:SoundGroup -element:Pitch -value:"+pitch+" -filename:"+grpFileLocation+" -nobackups"
215 <                         << "replaceall -parelement:SoundGroup -element:NumberOfChannels -value:"+numberChannels+" -filename:"+grpFileLocation+" -nobackups"
216 <                         << "replaceall -parelement:Volume -element:Min -value:"+minVolume+" -filename:"+grpFileLocation+" -nobackups"
217 <                         << "replaceall -parelement:Volume -element:Max -value:"+maxVolume+" -filename:"+grpFileLocation+" -nobackups"
218 <                         << "replaceall -parelement:Pitch -element:Min -value:"+minPitch+" -filename:"+grpFileLocation+" -nobackups"
219 <                         << "replaceall -parelement:Pitch -element:Max -value:"+maxPitch+" -filename:"+grpFileLocation+" -nobackups"
220 <                         << "replaceall -element:Weight -value:"+weight+" -filename:"+grpFileLocation+" -nobackups";
205 >    (*this->xmlCommands)
206 >     << "--replace-all-values -e Priority -n "+Util::String::insertQuotes(priority)+" -f "+Util::String::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
207 >     << "--replace-all-values -e Flags -n "+(flags.join(" ").isEmpty() ? Util::String::insertQuotes("") : Util::String::insertQuotes(flags.join(" ")))+" -f "+Util::String::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
208 >     << "--replace-all-values -e SphereRadius -n "+Util::String::insertQuotes(sphereRadious)+" -f "+Util::String::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
209 >     << "--replace-all-values -e Treshold -n "+Util::String::insertQuotes(treshold)+" -f "+Util::String::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
210 >     << "--replace-all-values -e MinOcclusion -n "+Util::String::insertQuotes(minOcclusion)+" -f "+Util::String::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
211 >     << "--replace-all-values --parent-element-name ElapsedTime -e  Max -n "+Util::String::insertQuotes(maxElapsedTime)+" -f "+Util::String::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
212 >     << "--replace-all-values --parent-element-name ElapsedTime -e  Min -n "+Util::String::insertQuotes(minElapsedTime)+" -f "+Util::String::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
213 >     << "--replace-all-values --parent-element-name Distance -e  Max -n "+Util::String::insertQuotes(maxVolumeDistance)+" -f "+Util::String::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
214 >     << "--replace-all-values --parent-element-name Distance -e  Min -n "+Util::String::insertQuotes(minVolumeDistance)+" -f "+Util::String::insertQuotes(ambFileLocation)+" --no-backups --no-verbose"
215 >     << "--replace-all-values --parent-element-name SoundGroup -e  Volume -n "+Util::String::insertQuotes(volume)+" -f "+Util::String::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"
216 >     << "--replace-all-values --parent-element-name SoundGroup -e  Pitch -n "+Util::String::insertQuotes(pitch)+" -f "+Util::String::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"
217 >     << "--replace-all-values --parent-element-name SoundGroup -e  NumberOfChannels -n "+Util::String::insertQuotes(numberChannels)+" -f "+Util::String::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"
218 >     << "--replace-all-values --parent-element-name Volume -e  Min -n "+Util::String::insertQuotes(minVolume)+" -f "+Util::String::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"
219 >     << "--replace-all-values --parent-element-name Volume -e  Max -n "+Util::String::insertQuotes(maxVolume)+" -f "+Util::String::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"
220 >     << "--replace-all-values --parent-element-name Pitch -e  Min -n "+Util::String::insertQuotes(minPitch)+" -f "+Util::String::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"
221 >     << "--replace-all-values --parent-element-name Pitch -e  Max -n "+Util::String::insertQuotes(maxPitch)+" -f "+Util::String::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"
222 >     << "--replace-all-values -e  Weight -n "+Util::String::insertQuotes(weight)+" -f "+Util::String::insertQuotes(grpFileLocation)+" --no-backups --no-verbose"
223 >     << "--replace-all-values -e  Priority -n "+Util::String::insertQuotes(priorityImp)+" -f "+Util::String::insertQuotes(impFileLocation)+" --no-backups --no-verbose"
224 >     << "--replace-all-values --parent-element-name Distance -e  Min -n "+Util::String::insertQuotes(minVolumeDistanceImp)+" -f "+Util::String::insertQuotes(impFileLocation)+" --no-backups --no-verbose"
225 >     << "--replace-all-values --parent-element-name Distance -e  Max -n "+Util::String::insertQuotes(maxVolumeDistanceImp)+" -f "+Util::String::insertQuotes(impFileLocation)+" --no-backups --no-verbose"
226 >     << "--replace-all-values --parent-element-name Angle -e  Min -n "+Util::String::insertQuotes(minAngleImp)+" -f "+Util::String::insertQuotes(impFileLocation)+" --no-backups --no-verbose"
227 >     << "--replace-all-values --parent-element-name Angle -e  Max -n "+Util::String::insertQuotes(maxAngleImp)+" -f "+Util::String::insertQuotes(impFileLocation)+" --no-backups --no-verbose"
228 >     << "--replace-all-values -e  MinAttenuation -n "+Util::String::insertQuotes(minAttenuationImp)+" -f "+Util::String::insertQuotes(impFileLocation)+" --no-backups --no-verbose"
229 >     << "--replace-all-values -e  ImpactVelocity -n "+Util::String::insertQuotes(impactVelocityImp)+" -f "+Util::String::insertQuotes(impFileLocation)+" --no-backups --no-verbose"
230 >     << "--replace-all-values -e  MinOcclusion -n "+Util::String::insertQuotes(minOcclusionImp)+" -f "+Util::String::insertQuotes(impFileLocation)+" --no-backups --no-verbose";
231  
232      if(preventRepeat){
233 <        (*this->xmlCommands) << "replaceall -parelement:SoundGroup -element:Flags -value:PreventRepeat -filename:"+grpFileLocation+" -nobackups";
233 >        (*this->xmlCommands) << "--replace-all-values --parent-element-name SoundGroup -e Flags -n PreventRepeat -f "+Util::String::insertQuotes(grpFileLocation)+" --no-backups --no-verbose";
234      }
235  
236      myXmlProcessor->start();
# Line 188 | Line 239 | void SoundPageFinal::startProcessing(){
239      QString currFileName;
240      QString currGrpFileLocation;
241      QString currAmbFileLocation;
242 +    QString currImpFileLocation;
243  
244      for(int i=0; i<this->page2Table->rowCount(); i++){
245  
246 <        (*this->oniSplitCommands) << this->commandMap->value("general->XML->ONI")+" "+outputFolder+" "+Util::insertQuotes(this->page2Table->item(i,1)->text()); // add location of sound file to convert
246 >        (*this->oniSplitCommands) << this->commandMap->value("xml->XML->ONI")+" "+Util::String::insertQuotes(outputFolder)+" "+Util::String::insertQuotes(this->page2Table->item(i,1)->text()); // add location of sound file to convert
247  
248          currFileName=this->page2Table->item(i,0)->text(); // get current file name
249 <        currAmbFileLocation = QString(ambFileLocation).replace("sample_file",currFileName); // get the new files, filenames
250 <        currGrpFileLocation = QString(grpFileLocation).replace("sample_file",currFileName);
249 >        currAmbFileLocation = outputFolder + "/" + QString(ambFile).replace("sample_file",currFileName); // get the new files, filenames
250 >        currGrpFileLocation = outputFolder + "/" + QString(grpFile).replace("sample_file",currFileName);
251 >        currImpFileLocation = outputFolder + "/" + QString(impFile).replace("sample_file",currFileName);
252  
253          QFile::copy(ambFileLocation, currAmbFileLocation); // make a copy of the sample files that will be the real files
254          QFile::copy(grpFileLocation, currGrpFileLocation);
255 +        QFile::copy(impFileLocation, currImpFileLocation);
256  
257 <        (*this->xmlCommands) << "replaceall -element:BaseTrack1 -value:"+currFileName+" -filename:"+currAmbFileLocation+" -nobackups" // process the xml
258 <                             << "replaceall -element:Sound -value:"+currFileName+" -filename:"+currGrpFileLocation+" -nobackups";
257 >        (*this->xmlCommands) << "--replace-all-values -e BaseTrack1 -n "+Util::String::insertQuotes(currFileName)+" -f "+Util::String::insertQuotes(currAmbFileLocation)+" --no-backups --no-verbose" // process the xml
258 >                             << "--replace-all-values -e Sound -n "+Util::String::insertQuotes(currFileName)+" -f "+Util::String::insertQuotes(currGrpFileLocation)+" --no-backups --no-verbose"
259 >                             << "--replace-all-values -e Group -n "+Util::String::insertQuotes(currFileName)+" -f "+Util::String::insertQuotes(currImpFileLocation)+" --no-backups --no-verbose";
260  
261          myXmlProcessor->start();
262          myXmlProcessor->wait(); // Wait until all xml is edited
208    }
263  
264 <    (*this->oniSplitCommands) << this->commandMap->value("general->XML->ONI")+" "+outputFolder+" "+Util::insertQuotes(GlobalVars::VagoTemporaryDir+"/*.xml");
264 >        (*this->oniSplitCommands) << this->commandMap->value("xml->XML->ONI")+" "+Util::String::insertQuotes(outputFolder)+" "+Util::String::insertQuotes(currAmbFileLocation);
265 >        (*this->oniSplitCommands) << this->commandMap->value("xml->XML->ONI")+" "+Util::String::insertQuotes(outputFolder)+" "+Util::String::insertQuotes(currGrpFileLocation);
266 >        (*this->oniSplitCommands) << this->commandMap->value("xml->XML->ONI")+" "+Util::String::insertQuotes(outputFolder)+" "+Util::String::insertQuotes(currImpFileLocation);
267 >    }
268  
269      this->myConverter->start(); // finally process the onisplit commands
270      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();
271   }
272  
273   void SoundPageFinal::catchXmlAndOSplitProcessingError(QString result, int numErrors){
# Line 222 | Line 275 | void SoundPageFinal::catchXmlAndOSplitPr
275      if(numErrors!=0){
276          QString sNumErrors=QString::number(numErrors);
277          if(numErrors>1){
278 <            Util::showErrorLogPopUp(result+"\n This is the last of "+sNumErrors+" Errors.");
278 >            UtilVago::showErrorPopUpLogButton(result+"\n This is the last of " + sNumErrors + " errors.");
279          }
280          else{
281 <            Util::showErrorLogPopUp(result);
281 >            UtilVago::showErrorPopUpLogButton(result);
282          }
283      }
284   }

Diff Legend

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