Changeset 120 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/structures


Ignore:
Timestamp:
09/13/2017 12:39:31 PM (9 years ago)
Author:
bmcguffin
Message:

Altered addNewEvent() so that start times of events are now rounded to the nearest minute.

File:
1 edited

Legend:

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

    r119 r120  
    188188    public void addNewEvent(I_ScriptEvent ev, int start) 
    189189    { 
     190        int leftoverSeconds = start % 60; 
     191         
     192        //round start time to the nearest minute 
     193        if(leftoverSeconds != 0) 
     194        { 
     195            if(leftoverSeconds > 30) 
     196            { 
     197                start += (60 - leftoverSeconds); 
     198            } 
     199            else 
     200            { 
     201                start -= leftoverSeconds; 
     202            } 
     203        } 
     204         
    190205        //Check to see if there's already a timeslice here 
    191206        TimeSlice t = slices.get(start); 
Note: See TracChangeset for help on using the changeset viewer.