Changeset 30 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/structures/TimeSlice.java
- Timestamp:
- 08/02/2017 12:48:06 PM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/scriptbuilder/structures/TimeSlice.java (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/scriptbuilder/structures/TimeSlice.java
r21 r30 8 8 import java.util.TimeZone; 9 9 import scriptbuilder.gui.ScriptBuilderGuiConstants; 10 import scriptbuilder.structures.events.*; 10 11 import scriptbuilder.structures.events.I_ScriptEvent; 11 12 … … 194 195 195 196 /** 196 * Converts the contents of this timeslice to a correctly 197 * formatted<ScriptEvent> XML element.197 * Converts the contents of this timeslice to a correctly formatted 198 * <ScriptEvent> XML element. 198 199 * 199 200 * @return XML conversion of this timeslice. … … 202 203 public String toXML() 203 204 { 205 ArrayList<I_ScriptEvent> eventsCopy = new ArrayList<I_ScriptEvent>(); 206 207 for (I_ScriptEvent e : events) 208 { 209 eventsCopy.add(e); 210 } 211 204 212 System.out.println("Seconds:: " + seconds); 205 213 String output = openTag(ELEMENT.SCRIPT_EVENT.tag); … … 212 220 output += thisIncident.name + closeTag(ELEMENT.INCIDENT.tag); 213 221 214 for (I_ScriptEvent ev : events) 222 output += openTag(ELEMENT.CAD_DATA.tag); 223 if (containsCADIncidentEvent()) 224 { 225 output += openTag(ELEMENT.CAD_INCIDENT_EVENT.tag); 226 for (I_ScriptEvent ev : eventsCopy) 227 { 228 if (ev instanceof I_XML_Writable && isCADIncidentEvent(ev)) 229 { 230 I_XML_Writable ex = (I_XML_Writable) ev; 231 output += ex.toXML(); 232 eventsCopy.remove(ev); 233 } 234 } 235 output += closeTag(ELEMENT.CAD_INCIDENT_EVENT.tag); 236 } 237 output += closeTag(ELEMENT.CAD_DATA.tag); 238 239 for (I_ScriptEvent ev : eventsCopy) 215 240 { 216 241 if (ev instanceof I_XML_Writable) … … 242 267 return "<" + s + "/>\n"; 243 268 } 269 270 private boolean containsCADIncidentEvent() 271 { 272 for (I_ScriptEvent ev : events) 273 { 274 if (isCADIncidentEvent(ev)) 275 { 276 return true; 277 } 278 } 279 return false; 280 } 281 282 private boolean isCADIncidentEvent(I_ScriptEvent ev) 283 { 284 return ev instanceof AudioEvent || ev instanceof UnitEvent 285 || ev instanceof ParamicsEvent || ev instanceof TowEvent 286 || ev instanceof WitnessEvent; 287 } 244 288 }
Note: See TracChangeset
for help on using the changeset viewer.
