Changeset 116 in tmcsimulator-scriptbuilder for trunk


Ignore:
Timestamp:
09/07/2017 01:44:00 PM (9 years ago)
Author:
bmcguffin
Message:

The first event added to any incident is automatically placed at time 0 relative to the start of the incident.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/scriptbuilder/structures/ScriptIncident.java

    r111 r116  
    188188    public void addNewEvent(I_ScriptEvent ev, int start) 
    189189    { 
    190         //Check to see if there's already a timeslice here 
    191         TimeSlice t = slices.get(start); 
    192         //If not, make one; then, add the event to it 
    193         if (t == null) 
    194         { 
    195             t = new TimeSlice(start, this); 
    196             t.addEvent(ev); 
    197             slices.put(start, t); 
    198         } 
     190        //The first event in the incident defines its start point, so it should 
     191        //be placed at time 0 
     192        if (start != 0 && slices.size() == 0) 
     193        { 
     194            addNewEvent(ev, 0); 
     195        } 
     196 
    199197        else 
    200198        { 
    201             t.addEvent(ev); 
    202         } 
    203         eventCount++; 
    204  
    205         //If this is the latest start time in the incident, update that number 
    206         if (start > latestStart) 
    207         { 
    208             latestStart = start; 
    209         } 
    210         //If this event is earlier than all previous events, or if there are  
    211         //no other events, the offset is equal to this event's start time 
    212         if (start < offset || eventCount == 1) 
    213         { 
    214             offset = start; 
    215             //System.out.println("Offset: " + offset); 
    216         } 
    217         updateLength(); 
     199            //Check to see if there's already a timeslice here 
     200            TimeSlice t = slices.get(start); 
     201            //If not, make one; then, add the event to it 
     202            if (t == null) 
     203            { 
     204                t = new TimeSlice(start, this); 
     205                t.addEvent(ev); 
     206                slices.put(start, t); 
     207            } 
     208            else 
     209            { 
     210                t.addEvent(ev); 
     211            } 
     212            eventCount++; 
     213 
     214            //If this is the latest start time in the incident, update that number 
     215            if (start > latestStart) 
     216            { 
     217                latestStart = start; 
     218            } 
     219            //If this event is earlier than all previous events, or if there are  
     220            //no other events, the offset is equal to this event's start time 
     221            if (start < offset || eventCount == 1) 
     222            { 
     223                offset = start; 
     224                //System.out.println("Offset: " + offset); 
     225            } 
     226            updateLength(); 
     227        } 
    218228    } 
    219229 
Note: See TracChangeset for help on using the changeset viewer.