Changeset 155 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/structures/SimulationScript.java
- Timestamp:
- 11/20/2019 03:22:38 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/scriptbuilder/structures/SimulationScript.java
r145 r155 5 5 import java.io.File; 6 6 import java.io.FileWriter; 7 import java.io.IOException; 7 8 import java.util.ArrayList; 8 9 import java.util.List; … … 12 13 import scriptbuilder.structures.ScriptIncident.IncidentFocusedEvent; 13 14 import scriptbuilder.structures.ScriptIncident.SliceChangedEvent; 15 import scriptbuilder.structures.events.*; 14 16 import scriptbuilder.structures.units.Unit; 17 import java.nio.file.Path; 18 import java.nio.file.Paths; 19 import java.util.TreeMap; 15 20 16 21 /** … … 256 261 ex.printStackTrace(); 257 262 } 263 try 264 { 265 createAudioDirectory(Paths.get(f.getCanonicalPath()).getParent()); 266 } 267 catch(IOException ex) 268 { 269 System.err.println("there was a problem creating the audio directories."); 270 } 271 272 258 273 saved = true; 259 274 } 260 275 private void createAudioDirectory(Path path){ 276 File f = new File(path.toString()+"/audio"); 277 if(!f.exists()) 278 { 279 f.mkdir(); 280 //scan through to see what is already there and then make changes accordingly. 281 } 282 for(ScriptIncident i : incidents) 283 { 284 if(i!=null) 285 { 286 String name = ((Integer) i.number).toString(); 287 File incidentFolder = new File(path.toString()+"/audio/"+name); 288 if(incidentFolder.exists()) 289 { 290 //check to see if there are already files for the given incidents 291 //not sure how the ordering of the files should be. 292 //check to see if folder needs filling 293 }else 294 { 295 296 //create an incidentfolder since one does not already exist 297 incidentFolder.mkdir(); 298 int fileCount = 1; 299 for(TimeSlice slice : i.getSlices()) 300 { 301 for(I_ScriptEvent event : slice.events) 302 { 303 if(event.getScriptEventType().equals(ScriptEvent.ScriptEventType.CHP_RADIO_EVENT)) 304 { 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 326 } 327 } 328 } 329 330 } 331 } 332 333 334 } 335 336 337 } 261 338 @Override 262 339 public String toXML()
Note: See TracChangeset
for help on using the changeset viewer.
