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


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

Fixed a bug which caused an event to be destroyed if it was the only event in its incident and the user attempted to change its start time. (See  http://git.tokomak.net:8888/ticket/20 for more details.)

File:
1 edited

Legend:

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

    r117 r119  
    208208            latestStart = start; 
    209209        } 
    210             //If this event is earlier than all previous events, or if there are  
     210        //If this event is earlier than all previous events, or if there are  
    211211        //no other events, the offset is equal to this event's start time 
    212212        if (start < offset || eventCount == 1) 
     
    392392        if (seconds == offset) 
    393393        { 
    394             offset = slices.firstKey(); 
     394            if (slices.size() > 0) 
     395            { 
     396                offset = slices.firstKey(); 
     397            } 
     398            else 
     399            { 
     400                offset = 0; 
     401            } 
    395402        } 
    396403        this.updateLength(); 
    397404        script.update(); 
    398405    } 
     406 
     407    /** 
     408     * Shifts the start time of a given event in this incident. The first event 
     409     * in the incident cannot be shifted. 
     410     * 
     411     * @param evt the event to be relocated 
     412     * @param oldTime the current start time of the event 
     413     * @param newTime the destination start time of the event 
     414     * @return true if the event is shifted over properly 
     415     * @pre the event in question exists 
     416     * @pre oldTime != newTime 
     417     */ 
     418    public boolean changeEventStart(I_ScriptEvent evt, int oldTime, int newTime) 
     419    { 
     420        if (!(oldTime == 0 && newTime > oldTime)) 
     421        { 
     422            this.slices.get(oldTime).events.remove(evt); 
     423            this.addNewEvent(evt, newTime); 
     424            return true; 
     425        } 
     426        return false; 
     427    } 
    399428} 
Note: See TracChangeset for help on using the changeset viewer.