Warning: Can't use blame annotator:
svn blame failed on trunk/src/scriptbuilder/structures/events/CHPRadioEvent.java: ("Can't find a temporary directory: Internal error", 20014)

source: tmcsimulator-scriptbuilder/trunk/src/scriptbuilder/structures/events/CHPRadioEvent.java @ 155

Revision 155, 2.3 KB checked in by sdanthin, 6 years ago (diff)

units.xml moved to Incidents folder

RevLine 
1/*
2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
5 */
6package scriptbuilder.structures.events;
7
8import java.util.ArrayList;
9import scriptbuilder.structures.ELEMENT;
10import scriptbuilder.structures.I_XML_Writable;
11import scriptbuilder.structures.ScriptEvent;
12import scriptbuilder.structures.XMLWriter;
13
14/**
15 * Data model for a CHP radio event. A CHP radio transmission has a
16 * conversation, with dialog between a field unit and a dispatch center. It also
17 * has an audio file which has that conversation acted out.
18 *
19 * @author Bryan McGuffin
20 */
21public class CHPRadioEvent extends ScriptEvent implements I_XML_Writable
22{
23
24    /**
25     * Constructor.
26     */
27    public CHPRadioEvent()
28    {
29        super(ScriptEventType.CHP_RADIO_EVENT);
30    }
31
32    /**
33     * List of the lines of dialog in this event.
34     */
35    public ArrayList<String> lines = new ArrayList<String>();
36
37    /**
38     * List of the corresponding roles for each line of dialog.
39     */
40    public ArrayList<String> roles = new ArrayList<String>();
41
42    /**
43     * Path for the audio file to be played during this event.
44     */
45    public String radioFile = "";
46
47    /**
48     * Returns the contents of the CHPRadioEvent to make recording easier.
49     * @return a string with the script to be said
50     */
51    public String toScriptFile()
52    {
53        String fileContents = "";
54        for(int lineIndex=0;lineIndex<lines.size();lineIndex++)
55        {
56            fileContents += roles.get(lineIndex) + " " + lines.get(lineIndex) + "\n";
57        }
58        return fileContents;
59    }
60   
61    @Override
62    public String toXML()
63    {
64        String output = XMLWriter.openTag(ELEMENT.CHP_RADIO.tag + " RadioFile=\"" + radioFile + "\"");
65        output += XMLWriter.openTag(ELEMENT.DIALOG.tag);
66
67        for (int i = 0; i < lines.size(); i++)
68        {
69            output += XMLWriter.openTag(ELEMENT.LINE.tag + " Role=\"" + roles.get(i) + "\"");
70            output += lines.get(i);
71            output += XMLWriter.closeTag(ELEMENT.LINE.tag);
72        }
73
74        output += XMLWriter.closeTag(ELEMENT.DIALOG.tag);
75        output += XMLWriter.closeTag(ELEMENT.CHP_RADIO.tag);
76
77        return output;
78    }
79}
Note: See TracBrowser for help on using the repository browser.