Changeset 167 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder
- Timestamp:
- 12/16/2019 03:55:46 PM (6 years ago)
- Location:
- trunk/src/scriptbuilder/structures
- Files:
-
- 5 edited
-
ScriptIncident.java (modified) (1 diff)
-
TimeSlice.java (modified) (2 diffs)
-
events/AudioEvent.java (modified) (2 diffs)
-
events/CHPRadioEvent.java (modified) (1 diff)
-
events/I_AudioEvent.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/scriptbuilder/structures/ScriptIncident.java
r164 r167 296 296 { 297 297 t = new TimeSlice(start, this); 298 //t.addEvent(ev);299 298 slices.put(start, t); 300 299 } 301 else 302 { 303 //t.addEvent(ev); 300 301 //checks if event to add is an I_AudioEvent and if the I_AudioEvent already has an AudioEvent to connect with it 302 if(ev instanceof I_AudioEvent && t.getCorrespondingAudioEvent((I_AudioEvent)ev)==null){ 303 304 AudioEvent audio = (AudioEvent) ScriptEvent.factoryByType(ScriptEventType.AUDIO_EVENT); 305 306 //checks to see if there is already a filename in the I_AudioEvent, if so, set the AudioEvent ID. This is because the ID is not stored within the Script itself. 307 if(!((I_AudioEvent) ev).getFileName().equals("")) 308 { 309 ((I_AudioEvent) ev).setID(((I_AudioEvent) ev).getFileName()); 310 } 311 // checks to see if the I_AudioEvent already has an ID or not, if not, set one based on the audioEventCount. 312 if(((I_AudioEvent) ev).getID().equals("")) 313 { 314 ((I_AudioEvent) ev).setID(number+Integer.toString(audioEventCount)); 315 audioEventCount++; 316 } 317 //sets AudioEvent id to id of I_AudioEvent 318 audio.id = ((I_AudioEvent) ev).getID(); 319 //sets I_AudioEvent filename to the AudioEvent id 320 ((I_AudioEvent) ev).setFileName(audio.id); 321 //sets the file path of the AudioEvent based on its internal id 322 audio.setAudioFilePathRelative(); 323 //adds AudioEvent to the timeslice 324 t.addEvent(audio); 325 304 326 } 305 327 t.addEvent(ev); 306 if(ev instanceof I_AudioEvent){307 //should make a path and a different filename fields for the file itself. Either that or deal with the string separation each time308 //needs a check for when we move I_AudioEvents in the incident, as to not make duplicate events.309 String fileName = number+"/"+number + "" + audioEventCount;310 AudioEvent audio = (AudioEvent) ScriptEvent.factoryByType(ScriptEventType.AUDIO_EVENT);311 ((I_AudioEvent) ev).setFileName(fileName);312 audio.setAudioFilePathRelative(fileName);313 314 t.addEvent(audio);315 audioEventCount++;316 }317 328 eventCount++; 318 329 -
trunk/src/scriptbuilder/structures/TimeSlice.java
r162 r167 320 320 } 321 321 } 322 //these two following functions should not be necessary. 322 323 /** 323 324 * this method removes an audioevent that corresponds to the input I_AudioEvent. NEEDS VERIFICATION 324 325 */ 325 326 public void removeCorrespondingAudioEvent(I_AudioEvent comparisonEvent){ 326 String id = comparisonEvent.get FileName().split("/")[1];327 String id = comparisonEvent.getID(); 327 328 for(I_ScriptEvent event : events) 328 329 { 329 330 if(event instanceof AudioEvent) 330 331 { 331 System.out.println("removed an audioevent \n" + ((AudioEvent)event).audioPath.split("/")[2].substring(0,((AudioEvent)event).audioPath.split("/")[2].length() - 4)); 332 System.out.println(id); 333 System.out.println(id.equals(((AudioEvent)event).audioPath.split("/")[2].substring(0,((AudioEvent)event).audioPath.split("/")[2].length() - 4))); 334 335 if(id.equals(((AudioEvent)event).audioPath.split("/")[2].substring(0,((AudioEvent)event).audioPath.split("/")[2].length() - 4))) 332 if(id.equals(((AudioEvent) event).id)) 336 333 { 337 334 System.out.println("the event was deleted"); … … 342 339 } 343 340 } 344 public AudioEvent getCorrespondingAudioEvent(I_AudioEvent compari osonEvent)345 { 346 String id = compari osonEvent.getFileName();341 public AudioEvent getCorrespondingAudioEvent(I_AudioEvent comparisonEvent) 342 { 343 String id = comparisonEvent.getID(); 347 344 AudioEvent retVal = null; 348 345 for(I_ScriptEvent event: events) 349 346 { 350 if(event instanceof AudioEvent && ((AudioEvent)event).audioPath.split("/")[2].equals(id))347 if(event instanceof AudioEvent && id.equals(((AudioEvent) event).id)) 351 348 { 352 349 retVal = (AudioEvent) event; -
trunk/src/scriptbuilder/structures/events/AudioEvent.java
r161 r167 44 44 45 45 /** 46 * File path for the audio file. 46 * File path for the audio file. Perhaps should only be generated on save? 47 47 */ 48 48 public String audioPath = ""; … … 64 64 audioPath = "audio/" + f + ".mp3"; 65 65 } 66 66 /** 67 * sets audio path relative to the working directory using the id value. 68 */ 67 69 public void setAudioFilePathRelative() 68 70 { -
trunk/src/scriptbuilder/structures/events/CHPRadioEvent.java
r161 r167 78 78 79 79 @Override 80 public void setID(String id) 81 { 82 this.id = id; 83 } 84 85 @Override 80 86 public void setFileName(String s) 81 87 { -
trunk/src/scriptbuilder/structures/events/I_AudioEvent.java
r159 r167 11 11 */ 12 12 public interface I_AudioEvent { 13 /**14 * allows for the AudioEvent type to return if it is an audio event. Could be replaced by just using instanceOf I think15 * @return16 */17 13 18 14 … … 21 17 String getID(); 22 18 19 void setID(String id); 20 23 21 void setFileName(String s); 24 22
Note: See TracChangeset
for help on using the changeset viewer.
