xoreos  0.0.5
waypoint.cpp
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 #include "src/common/util.h"
26 #include "src/common/maths.h"
27 
28 #include "src/aurora/gff3file.h"
29 #include "src/aurora/gdafile.h"
30 
33 
34 namespace Engines {
35 
36 namespace DragonAge2 {
37 
39  load(waypoint);
40 }
41 
43 }
44 
46  return _group;
47 }
48 
49 bool Waypoint::hasMapNote() const {
50  return _hasMapNote;
51 }
52 
54  return _enabledMapNote;
55 }
56 
57 void Waypoint::enableMapNote(bool enabled) {
58  _enabledMapNote = enabled;
59 }
60 
62  return _mapNote;
63 }
64 
66  return _icon;
67 }
68 
69 void Waypoint::load(const Aurora::GFF3Struct &waypoint) {
70  // Tag
71  _tag = waypoint.getString("Tag");
72 
73  // Group
74  _group = waypoint.getSint("Group", -1);
75 
76  // Map Note
77  _hasMapNote = waypoint.getBool("HasMapNote");
78  _enabledMapNote = waypoint.getBool("MapNoteEnabled");
79 
80  waypoint.getLocString("MapNote", _mapNote);
81 
82  // Type
83  _type = (uint32) ((int32) waypoint.getSint("MapNoteType", -1));
84 
85  // Position
86  const float position[3] = {
87  (float) waypoint.getDouble("XPosition"),
88  (float) waypoint.getDouble("YPosition"),
89  (float) waypoint.getDouble("ZPosition")
90  };
91 
92  setPosition(position[0], position[1], position[2]);
93 
94  // Orientation
95  const float orientation[4] = {
96  (float) waypoint.getDouble("XOrientation"),
97  (float) waypoint.getDouble("YOrientation"),
98  (float) waypoint.getDouble("ZOrientation"),
99  (float) Common::rad2deg(acos(waypoint.getDouble("WOrientation")) * 2.0)
100  };
101 
102  setOrientation(orientation[0], orientation[1], orientation[2], orientation[3]);
103 
105 
106  // Icon
107  _icon = gda.getString(_type, "Icon");
108 
109  // Variables and script
110  readVarTable(waypoint);
111  readScript(waypoint);
112  enableEvents(true);
113 }
114 
115 } // End of namespace DragonAge2
116 
117 } // End of namespace Engines
int64 getSint(const Common::UString &field, int64 def=0) const
Definition: gff3file.cpp:473
Handling version V3.2/V3.3 of BioWare&#39;s GFFs (generic file format).
Handling BioWare&#39;s GDAs (2DAs, two-dimensional array, within V4.0 GFFs).
bool getBool(const Common::UString &field, bool def=false) const
Definition: gff3file.cpp:510
uint32 _type
Index into the Waypoints MGDA.
Definition: waypoint.h:74
bool getLocString(const Common::UString &field, LocString &str) const
Definition: gff3file.cpp:614
A class holding an UTF-8 string.
Definition: ustring.h:48
A localized string.
Definition: locstring.h:43
virtual void setOrientation(float x, float y, float z, float angle)
Set the object&#39;s orientation.
Definition: object.cpp:140
bool enabledMapNote() const
Is the map note enabled?
Definition: waypoint.cpp:53
virtual void setPosition(float x, float y, float z)
Set the object&#39;s position within its area.
Definition: object.cpp:134
Mathematical helpers.
void enableEvents(bool enabled)
Enable/Disable the handling of all events.
Definition: container.cpp:75
Dragon Age II utility functions.
const Aurora::GDAFile & getMGDA(uint32 id)
Definition: util.cpp:36
int32 getGroup() const
Return the ID of the group this waypoint belongs to.
Definition: waypoint.cpp:45
const Common::UString & getIcon() const
Return the icon representing the waypoint on the map.
Definition: waypoint.cpp:65
int32 _group
The ID of the group this waypoint belongs to.
Definition: waypoint.h:65
Common::UString _icon
The icon to show in the mini map for this waypoint.
Definition: waypoint.h:77
Utility templates and functions.
bool _hasMapNote
Does this waypoint have a map note?
Definition: waypoint.h:67
A waypoint in a Dragon Age II area.
Waypoint(const Aurora::GFF3Struct &waypoint)
Load from a waypoint instance.
Definition: waypoint.cpp:38
double getDouble(const Common::UString &field, double def=0.0) const
Definition: gff3file.cpp:514
const Aurora::LocString & getMapNote() const
Return the waypoint&#39;s map note text.
Definition: waypoint.cpp:61
Common::UString getString(size_t row, uint32 columnHash, const Common::UString &def="") const
Definition: gdafile.cpp:165
bool hasMapNote() const
Does this waypoint have a map note?
Definition: waypoint.cpp:49
A struct within a GFF3.
Definition: gff3file.h:164
uint32_t uint32
Definition: types.h:204
Common::UString _tag
Definition: object.h:56
bool _enabledMapNote
Is this waypoint&#39;s map note enabled?
Definition: waypoint.h:68
Common::UString getString(const Common::UString &field, const Common::UString &def="") const
Definition: gff3file.cpp:527
static float rad2deg(float rad)
Definition: maths.h:93
void enableMapNote(bool enabled)
Enable/Disable the waypoint&#39;s map note.
Definition: waypoint.cpp:57
void load(const Aurora::GFF3Struct &waypoint)
Definition: waypoint.cpp:69
void readVarTable(const Aurora::GFF3List &varTable)
Aurora::LocString _mapNote
The waypoint&#39;s map note text.
Definition: waypoint.h:71
Class to hold the GFF&#39;d two-dimensional array of a GDA file.
Definition: gdafile.h:62
int32_t int32
Definition: types.h:203
void readScript(const Aurora::GFF3Struct &gff)
Definition: container.cpp:86