Changeset 169 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/structures/SimulationScript.java
- Timestamp:
- 12/18/2019 02:12:23 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/scriptbuilder/structures/SimulationScript.java
r158 r169 85 85 86 86 public boolean saved; 87 87 88 88 //TODO: Pretty much everything in this constructor is dummy data. 89 89 //Replace all of it. … … 273 273 saved = true; 274 274 } 275 276 /** 277 * Creates the proper audio directory using the I_AudioEvent types. 278 * @param path of audio directory root 279 */ 275 280 private void createAudioDirectory(Path path){ 276 281 File f = new File(path.toString()+"/audio"); … … 278 283 { 279 284 f.mkdir(); 280 //scan through to see what is already there and then make changes accordingly.285 //scan through to see what is already there and if there is no existing audio directory, create it. 281 286 } 282 287 for(ScriptIncident i : incidents) … … 286 291 String name = ((Integer) i.number).toString(); 287 292 File incidentFolder = new File(path.toString()+"/audio/"+name); 288 if( incidentFolder.exists())293 if(!incidentFolder.exists()) 289 294 { 290 //check to see if there are already files for the given incidents291 //not sure how the ordering of the files should be.292 //check to see if folder needs filling293 }else294 {295 296 295 //create an incidentfolder since one does not already exist 297 296 incidentFolder.mkdir(); 298 int fileCount = 1; 299 for(TimeSlice slice : i.getSlices()) 297 } 298 299 300 for(TimeSlice slice : i.getSlices()) 301 { 302 for(I_ScriptEvent event : slice.events) 300 303 { 301 for(I_ScriptEvent event : slice.events)304 if(event instanceof I_AudioEvent) 302 305 { 303 if(event.getScriptEventType().equals(ScriptEvent.ScriptEventType.CHP_RADIO_EVENT)) 306 //if the event is a chp radio event 307 //then add the dummy file to the subdirectory created 308 //CURRENTLY this ONLY is implemented for CHPRadioEvent, so it will need to be changed later. 309 CHPRadioEvent radioEvent = (CHPRadioEvent) event; 310 311 String output = radioEvent.toScriptFile(); 312 //optimally, this line should use the ID, but to account for files being read in, it needs to be the radiofile name 313 File newAudioScript = new File(path.toString()+"/audio/"+name+"/"+radioEvent.radioFile.replaceAll(".mp3","")+".txt"); 314 315 try 304 316 { 305 //if the event is a chp radio event 306 //then add the dummy file to the subdirectory created 307 CHPRadioEvent radioEvent = (CHPRadioEvent) event; 308 309 String output = radioEvent.toScriptFile(); 310 311 File newAudioScript = new File(path.toString()+"/audio/"+name+"/"+name+fileCount+".txt"); 312 313 fileCount++; 314 try 315 { 316 newAudioScript.createNewFile(); 317 BufferedWriter bw = new BufferedWriter(new FileWriter(newAudioScript)); 318 bw.write(output); 319 bw.flush(); 320 bw.close(); 321 }catch(Exception e) 322 { 323 System.err.println("there was a problem creating your text files"); 324 } 325 317 newAudioScript.createNewFile(); 318 BufferedWriter bw = new BufferedWriter(new FileWriter(newAudioScript)); 319 bw.write(output); 320 bw.flush(); 321 bw.close(); 322 }catch(Exception e) 323 { 324 System.err.println("there was a problem creating your text files"); 326 325 } 326 327 327 } 328 328 } 329 330 329 } 330 331 331 332 } 332 333
Note: See TracChangeset
for help on using the changeset viewer.
