xoreos  0.0.5
dlgfile.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef AURORA_DLGFILE_H
26 #define AURORA_DLGFILE_H
27 
28 #include <vector>
29 
30 #include <boost/noncopyable.hpp>
31 
32 #include "src/common/types.h"
33 #include "src/common/ustring.h"
34 
35 #include "src/aurora/types.h"
36 #include "src/aurora/locstring.h"
37 
38 namespace Common {
39  class SeekableReadStream;
40 }
41 
42 namespace Aurora {
43 
44 namespace NWScript {
45  class Object;
46 }
47 
48 // TODO: KotOR:
49 // - "ConversationType", "StuntList", "Skippable", "AmbientTrack",
50 // "AnimatedCut", ...
51 // - Sound resrefs in field "VO_ResRef"
52 // - Quest IDs in field "PlotIndex"
53 // - Camera: "CameraModel", "CameraAngle", "CameraID", "CamVidEffect", "FadeType"
54 // TODO: KotOR2:
55 // - "Emotion", "FacialAnim"
56 // - 2 scripts, with params:
57 // "Script{,2}"; "ActionParam[1-5]{,b}", "ActionParamStr{A,B}"
58 // - 2 active test scripts, with params and bool operators (not, and/or)
59 // "Active{,2}"; "Param[1-5]{,b}", "ParamStr{A,B}"
60 // "Not{,2}", "Logic"
61 
62 class DLGFile : boost::noncopyable {
63 public:
64  static const uint32 kEndLine = 0xFFFFFFFE;
65  static const uint32 kInvalidLine = 0xFFFFFFFF;
66 
67  struct Line {
69 
72 
75 
77 
80 
81  bool isEnd;
82  };
83 
84 
86  DLGFile(Common::SeekableReadStream *dlg, NWScript::Object *owner = 0, bool repairNWNPremium = false);
88  DLGFile(const Common::UString &dlg, NWScript::Object *owner = 0, bool repairNWNPremium = false);
89  ~DLGFile();
90 
92  bool getNoZoomIn() const;
93 
95  uint32 getDelayEntry() const;
97  uint32 getDelayReply() const;
98 
99  bool hasEnded() const;
100 
101  void startConversation();
102  void abortConversation();
103 
104  void pickReply(uint32 id);
105 
106  const Line *getCurrentEntry() const;
107  const std::vector<const Line *> &getCurrentReplies() const;
108 
110  const Line *getOneLiner() const;
111 
112 private:
114  struct Link {
117  };
118 
120  struct Entry {
121  bool isPC;
122 
124 
126 
127  std::vector<Link> replies;
128  };
129 
130 
132 
135 
138 
139  bool _noZoomIn;
140 
141  std::vector<Entry> _entriesNPC;
142  std::vector<Entry> _entriesPC;
143 
144  std::vector<Link> _entriesStart;
145 
146  std::vector<Entry>::iterator _currentEntry;
147  std::vector<const Line *> _currentReplies;
148 
149  bool _ended;
150 
151 
152  void load(const GFF3Struct &dlg);
153 
154  void readEntries(const GFF3List &list, std::vector<Entry> &entries, bool isPC);
155  void readLinks(const GFF3List &list, std::vector<Link> &links);
156 
157  void readEntry(const GFF3Struct &gff, Entry &entry);
158  void readLink(const GFF3Struct &gff, Link &link);
159 
160  bool evaluateEntries(const std::vector<Link> &entries,
161  std::vector<Entry>::iterator &active);
162  bool evaluateReplies(const std::vector<Link> &entries,
163  std::vector<const Line *> &active);
164 
165  bool runScript(const Common::UString &script) const;
166 };
167 
168 } // End of namespace Aurora
169 
170 #endif // AURORA_DLGFILE_H
void abortConversation()
Definition: dlgfile.cpp:100
uint32 getDelayReply() const
Return the number of seconds to wait before showing each reply.
Definition: dlgfile.cpp:77
void pickReply(uint32 id)
Definition: dlgfile.cpp:112
void readEntry(const GFF3Struct &gff, Entry &entry)
Definition: dlgfile.cpp:220
Definition: 2dafile.h:39
std::vector< Entry > _entriesNPC
NPC dialog lines ("entries").
Definition: dlgfile.h:141
DLGFile(Common::SeekableReadStream *dlg, NWScript::Object *owner=0, bool repairNWNPremium=false)
Take over this stream and read a DLG file out of it.
Definition: dlgfile.cpp:45
A class holding an UTF-8 string.
Definition: ustring.h:48
A localized string.
Definition: locstring.h:43
std::vector< const Line * > _currentReplies
The current replies.
Definition: dlgfile.h:147
void readLink(const GFF3Struct &gff, Link &link)
Definition: dlgfile.cpp:252
NWScript::Object * _owner
Definition: dlgfile.h:131
std::vector< Link > replies
Reply lines.
Definition: dlgfile.h:127
bool _noZoomIn
Starting the conversation does not zoom the camera onto the speaker.
Definition: dlgfile.h:139
bool hasEnded() const
Definition: dlgfile.cpp:81
bool evaluateEntries(const std::vector< Link > &entries, std::vector< Entry >::iterator &active)
Definition: dlgfile.cpp:257
Common::UString sound
ResRef of the sound to play while speaking this entry.
Definition: dlgfile.h:73
Common::UString voice
ResRef of the voice over for KotOR games.
Definition: dlgfile.h:74
const Line * getOneLiner() const
Return the first active non-branching entry.
Definition: dlgfile.cpp:151
bool getNoZoomIn() const
Does starting the conversation zoom in the camera onto the speaker or not?
Definition: dlgfile.cpp:69
Line line
The line&#39;s contents.
Definition: dlgfile.h:125
uint32 id
ID of this line (entry-local).
Definition: dlgfile.h:68
bool isPC
Is this a PC or NPC line?
Definition: dlgfile.h:121
void readEntries(const GFF3List &list, std::vector< Entry > &entries, bool isPC)
Definition: dlgfile.cpp:198
bool runScript(const Common::UString &script) const
Definition: dlgfile.cpp:293
uint32 _delayReply
Number of seconds to wait before showing each reply.
Definition: dlgfile.h:134
void load(const GFF3Struct &dlg)
Definition: dlgfile.cpp:165
Low-level type definitions to handle fixed width types portably.
Common::UString _convAbort
Script to run when the conversation was aborted.
Definition: dlgfile.h:136
uint32 questEntry
Entry ID to set the quest to.
Definition: dlgfile.h:79
Common::UString _convEnd
Script to run when the conversation ended normally.
Definition: dlgfile.h:137
std::vector< Entry > _entriesPC
PC dialog lines ("replies").
Definition: dlgfile.h:142
Common::UString quest
Quest name to modify when speaking this entry.
Definition: dlgfile.h:78
const std::vector< const Line * > & getCurrentReplies() const
Definition: dlgfile.cpp:147
Handling BioWare&#39;s localized strings.
std::vector< const GFF3Struct * > GFF3List
Definition: types.h:449
Unicode string handling.
A dialog entry.
Definition: dlgfile.h:120
Basic type definitions to handle files used in BioWare&#39;s Aurora engine.
static const uint32 kEndLine
Definition: dlgfile.h:64
bool isEnd
Are there no replies to this line?
Definition: dlgfile.h:81
bool _ended
Has the conversation ended?
Definition: dlgfile.h:149
A struct within a GFF3.
Definition: gff3file.h:164
uint32_t uint32
Definition: types.h:204
std::vector< Link > _entriesStart
NPC starting lines (greetings).
Definition: dlgfile.h:144
uint32 _delayEntry
Number of seconds to wait before showing each entry.
Definition: dlgfile.h:133
void readLinks(const GFF3List &list, std::vector< Link > &links)
Definition: dlgfile.cpp:212
uint32 getDelayEntry() const
Return the number of seconds to wait before showing each entry.
Definition: dlgfile.cpp:73
uint32 animation
Animation to play while speaking this entry.
Definition: dlgfile.h:76
Interface for a seekable & readable data stream.
Definition: readstream.h:265
static const uint32 kInvalidLine
Definition: dlgfile.h:65
void startConversation()
Definition: dlgfile.cpp:85
std::vector< Entry >::iterator _currentEntry
The current entry.
Definition: dlgfile.h:146
Common::UString speaker
Tag of the speaker, empty if default.
Definition: dlgfile.h:70
Common::UString script
Script to run when speaking this entry.
Definition: dlgfile.h:123
LocString text
The actual text of the entry.
Definition: dlgfile.h:71
const Line * getCurrentEntry() const
Definition: dlgfile.cpp:140
bool evaluateReplies(const std::vector< Link > &entries, std::vector< const Line *> &active)
Definition: dlgfile.cpp:275