Changeset 168 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/structures/ScriptIncident.java
- Timestamp:
- 12/18/2019 02:11:14 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/scriptbuilder/structures/ScriptIncident.java
r167 r168 263 263 } 264 264 /** 265 * Adds an event to the correct timeslice when imported from an XML file. 266 * @param ev Event to be added to the timeslice. 267 * @param start Time when event needs to be added. 268 */ 269 public void addNewEventFromXML(I_ScriptEvent ev, int start) 270 { 271 TimeSlice t = slices.get(start); 272 if(t==null) 273 { 274 t = new TimeSlice(start,this); 275 slices.put(start,t); 276 } 277 t.addEvent(ev); 278 eventCount++; 279 280 //If this is the latest start time in the incident, update that number 281 if (start > latestStart) 282 { 283 latestStart = start; 284 } 285 //If this event is earlier than all previous events, or if there are 286 //no other events, the offset is equal to this event's start time 287 if (start < offset || eventCount == 1) 288 { 289 offset = start; 290 //System.out.println("Offset: " + offset); 291 } 292 updateLength(); 293 294 } 295 /** 265 296 * Add a new script event to this incident. 266 297 * … … 271 302 public void addNewEvent(I_ScriptEvent ev, int start) 272 303 { 273 /* 274 int leftoverSeconds = start % 60; 275 276 //round start time to the nearest minute 277 if(leftoverSeconds != 0) 278 { 279 if(leftoverSeconds > 30) 280 { 281 start += (60 - leftoverSeconds); 282 } 283 else 284 { 285 start -= leftoverSeconds; 286 } 287 } 288 */ 304 289 305 290 306 //Check to see if there's already a timeslice here … … 300 316 301 317 //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); 318 if(ev instanceof I_AudioEvent){ 319 305 320 306 321 //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 322 if(!((I_AudioEvent) ev).getFileName().equals("")) 308 323 { 309 ((I_AudioEvent) ev).setID(((I_AudioEvent) ev).getFileName() );324 ((I_AudioEvent) ev).setID(((I_AudioEvent) ev).getFileName().replaceAll(".mp3","")); 310 325 } 311 326 // checks to see if the I_AudioEvent already has an ID or not, if not, set one based on the audioEventCount. … … 315 330 audioEventCount++; 316 331 } 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); 332 if(t.getCorrespondingAudioEvent((I_AudioEvent)ev)==null) 333 { 334 AudioEvent audio = (AudioEvent) ScriptEvent.factoryByType(ScriptEventType.AUDIO_EVENT); 335 336 //sets AudioEvent id to id of I_AudioEvent 337 audio.id = ((I_AudioEvent) ev).getID(); 338 //sets I_AudioEvent filename to the AudioEvent id 339 ((I_AudioEvent) ev).setFileName(audio.id+ ".mp3"); 340 //sets the file path of the AudioEvent based on its internal id 341 audio.setAudioFilePathRelative(); 342 //adds AudioEvent to the timeslice 343 t.addEvent(audio); 344 } 345 325 346 326 347 }
Note: See TracChangeset
for help on using the changeset viewer.
