Changeset 117 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/structures/ScriptIncident.java


Ignore:
Timestamp:
09/07/2017 02:08:40 PM (9 years ago)
Author:
bmcguffin
Message:

Redesigned the method by which the first event in an event is added to relative time 00:00:00.

Added a second timestamp panel to the incident editor screen, which displays absolute script time in red. The original timestamp panel displays time relative to the start of the incident, in black.

File:
1 edited

Legend:

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

    r116 r117  
    188188    public void addNewEvent(I_ScriptEvent ev, int start) 
    189189    { 
    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  
     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        } 
    197199        else 
    198200        { 
    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             } 
     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        } 
    219210            //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         } 
     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(); 
    228218    } 
    229219 
Note: See TracChangeset for help on using the changeset viewer.