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 @ 161

Revision 161, 2.6 KB checked in by sdanthin, 6 years ago (diff)

AudioEvent?.java CHPRadioEvent.java added corresponding functions to match interface and began implementing an ID system.

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, I_AudioEvent
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     * ID
49     */
50    public String id = "";
51   
52   
53    /**
54     * Returns the contents of the CHPRadioEvent to make recording easier.
55     * @return a string with the script to be said
56     */
57    public String toScriptFile()
58    {
59        String fileContents = "";
60        for(int lineIndex=0;lineIndex<lines.size();lineIndex++)
61        {
62            fileContents += roles.get(lineIndex) + " " + lines.get(lineIndex) + "\n";
63        }
64        return fileContents;
65    }
66   
67    @Override
68    public String getFileName()
69    {
70        return radioFile;
71    }
72   
73    @Override
74    public String getID()
75    {
76        return id;
77    }
78   
79    @Override
80    public void setFileName(String s)
81    {
82        radioFile = s;
83    }
84   
85    @Override
86    public String toXML()
87    {
88        String output = XMLWriter.openTag(ELEMENT.CHP_RADIO.tag + " RadioFile=\"" + radioFile + "\"");
89        output += XMLWriter.openTag(ELEMENT.DIALOG.tag);
90
91        for (int i = 0; i < lines.size(); i++)
92        {
93            output += XMLWriter.openTag(ELEMENT.LINE.tag + " Role=\"" + roles.get(i) + "\"");
94            output += lines.get(i);
95            output += XMLWriter.closeTag(ELEMENT.LINE.tag);
96        }
97
98        output += XMLWriter.closeTag(ELEMENT.DIALOG.tag);
99        output += XMLWriter.closeTag(ELEMENT.CHP_RADIO.tag);
100
101        return output;
102    }
103}
Note: See TracBrowser for help on using the repository browser.