xoreos  0.0.5
object.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 ENGINES_NWN_OBJECT_H
26 #define ENGINES_NWN_OBJECT_H
27 
28 #include <list>
29 
30 #include "src/common/types.h"
31 #include "src/common/scopedptr.h"
32 #include "src/common/ustring.h"
33 
35 
36 #include "src/sound/types.h"
37 
38 #include "src/engines/nwn/types.h"
40 
42 
44 
45 namespace Aurora {
46  class SSFFile;
47 
48  namespace NWScript {
49  class Object;
50  }
51 }
52 
53 namespace Engines {
54 
55 namespace NWN {
56 
57 class Area;
58 
60 public:
62  virtual ~Object();
63 
65  ObjectType getType() const;
66 
67  // Basic visuals
68 
69  virtual void loadModel();
70  virtual void unloadModel();
71 
72  virtual void show();
73  virtual void hide();
74 
76  const std::list<uint32> &getIDs() const;
77 
78  // Basic properties
79 
81  const Common::UString &getName() const;
83  const Common::UString &getDescription() const;
85  const Common::UString &getPortrait() const;
86 
88  const Common::UString &getConversation() const;
89 
91  const Aurora::SSFFile *getSSF();
92 
93  // Interactive properties
94 
95  bool isStatic() const;
96  bool isUsable() const;
97 
98  bool isClickable() const;
99 
100  // Object/Object interactions
101 
106 
108  Area *getArea() const;
110  virtual void setArea(Area *);
111 
112  // Positioning
113 
115  virtual void getPosition(float &x, float &y, float &z) const;
117  virtual void getOrientation(float &x, float &y, float &z, float &angle) const;
118 
120  virtual void setPosition(float x, float y, float z);
122  virtual void setOrientation(float x, float y, float z, float angle);
123 
125  Location getLocation() const;
126 
127  // Object/Cursor interactions
128 
129  virtual void enter();
130  virtual void leave();
131 
133  virtual void highlight(bool enabled);
134 
136  virtual bool click(Object *triggerer = 0);
137 
138  // Object (text) talking
139 
141  virtual void speakString(const Common::UString &string, uint32 volume);
142 
144  void speakOneLiner(Common::UString conv, Object *tokenTarget = 0);
145 
146  // Sound
147 
149  void stopSound();
151  void playSound(const Common::UString &sound, bool pitchVariance = false);
152 
153  // Animation
154 
156  virtual void playAnimation(const Common::UString &animation = "", bool restart = true,
157  float length = 0.0f, float speed = 1.0f);
159  virtual void playAnimation(Animation animation, bool restart = true,
160  float length = 0.0f, float speed = 1.0f);
161 
162 protected:
164 
167 
169 
171 
174 
175  bool _static;
176  bool _usable;
177 
178  std::list<uint32> _ids;
179 
181 
183 
184  float _position[3];
185  float _orientation[4];
186 
188 
190 
191 
193  void loadSSF();
195  bool beginConversation(Object *triggerer);
196 
198  virtual bool createTooltip(Tooltip::Type type);
199 
201  bool createFeedbackTooltip();
203  bool createSpeechTooltip(const Common::UString &line);
204 
206  void destroyTooltip();
207 
209  bool showFeedbackTooltip();
211  bool showSpeechTooltip(const Common::UString &line);
213  void hideTooltip();
214 };
215 
216 } // End of namespace NWN
217 
218 } // End of namespace Engines
219 
220 #endif // ENGINES_NWN_OBJECT_H
const Common::UString & getPortrait() const
Return the object&#39;s portrait.
Definition: object.cpp:98
virtual void unloadModel()
Unload the object&#39;s model(s).
Definition: object.cpp:80
void destroyTooltip()
Destroy all tooltips on this object.
Definition: object.cpp:308
bool showSpeechTooltip(const Common::UString &line)
Create and show a tooltip with a line the object speaks.
Definition: object.cpp:325
virtual void getOrientation(float &x, float &y, float &z, float &angle) const
Return the object&#39;s orientation.
Definition: object.cpp:162
virtual bool createTooltip(Tooltip::Type type)
Create an empty tooltip.
Definition: object.cpp:284
bool isUsable() const
Can the object be used by the PC?
Definition: object.cpp:116
bool beginConversation(Object *triggerer)
Begin a conversation between the triggerer and this object.
Definition: object.cpp:260
bool createFeedbackTooltip()
Create a tooltip with the name and/or portrait of the object.
Definition: object.cpp:288
A class holding an UTF-8 string.
Definition: ustring.h:48
const Common::UString & getConversation() const
Return the object&#39;s default conversation (DLG).
Definition: object.cpp:102
bool isClickable() const
Can the player click the object?
Definition: object.cpp:120
virtual void setOrientation(float x, float y, float z, float angle)
Set the object&#39;s orientation.
Definition: object.cpp:176
const Common::UString & getName() const
Return the object&#39;s name.
Definition: object.cpp:90
Class to hold a sound set.
Definition: ssffile.h:55
Common::UString _name
The object&#39;s display name.
Definition: object.h:165
Location getLocation() const
Create a Location out of the object&#39;s area, position and orientation.
Definition: object.cpp:144
Aurora::NWScript::Object * _pcSpeaker
The current PC speaking with the object.
Definition: object.h:180
Area * getArea() const
Return the area this object is currently in.
Definition: object.cpp:136
Basic Neverwinter Nights type definitions.
Basic sound types.
virtual bool click(Object *triggerer=0)
The object was clicked.
Definition: object.cpp:256
const Common::UString & getDescription() const
Return the object&#39;s description.
Definition: object.cpp:94
An area in Neverwinter Nights, holding all objects and room tiles within, as well as general area pro...
Definition: area.h:63
A tooltip.
bool isStatic() const
Is the object static (not manipulable at all)?
Definition: object.cpp:112
virtual void speakString(const Common::UString &string, uint32 volume)
Speak the specified string.
Definition: object.cpp:210
A simple scoped smart pointer template.
virtual void enter()
The cursor entered the object.
Definition: object.cpp:183
virtual void playAnimation(const Common::UString &animation="", bool restart=true, float length=0.0f, float speed=1.0f)
Play an object animation.
Definition: object.cpp:274
std::list< uint32 > _ids
The object&#39;s model IDs.
Definition: object.h:178
virtual void getPosition(float &x, float &y, float &z) const
Return the object&#39;s position within its area.
Definition: object.cpp:156
float _orientation[4]
The object&#39;s orientation.
Definition: object.h:185
virtual ~Object()
Definition: object.cpp:68
Common::ScopedPtr< Tooltip > _tooltip
The tooltip displayed over the object.
Definition: object.h:189
virtual void setPosition(float x, float y, float z)
Set the object&#39;s position within its area.
Definition: object.cpp:170
Common::UString _description
The object&#39;s description.
Definition: object.h:166
Area * _area
The area the object is currently in.
Definition: object.h:182
bool showFeedbackTooltip()
Create and show a tooltip with the name and/or portrait of the object.
Definition: object.cpp:314
Aurora::NWScript::Object * getPCSpeaker() const
Return the PC currently speaking with this object.
Definition: object.cpp:128
bool _static
Is the object static?
Definition: object.h:175
void playSound(const Common::UString &sound, bool pitchVariance=false)
Play an object sound.
Definition: object.cpp:248
Low-level type definitions to handle fixed width types portably.
bool createSpeechTooltip(const Common::UString &line)
Create a tooltip with a line the object should speak.
Definition: object.cpp:298
virtual void setArea(Area *)
Set the area this object is currently in.
Definition: object.cpp:140
ObjectType _type
The object&#39;s type.
Definition: object.h:163
void speakOneLiner(Common::UString conv, Object *tokenTarget=0)
Speak an one-liner from the specified conversation file.
Definition: object.cpp:215
ObjectType
Object type, matches the bitfield in nwscript.nss.
Definition: types.h:36
Unicode string handling.
Common::UString _portrait
The object&#39;s portrait.
Definition: object.h:168
void stopSound()
Stop the current object sound.
Definition: object.cpp:244
uint32 _soundSet
The object&#39;s sound set, as an index into soundset.2da.
Definition: object.h:172
An NWScript object.
virtual void leave()
The cursor left the object.
Definition: object.cpp:186
virtual void loadModel()
Load the object&#39;s model(s).
Definition: object.cpp:77
A handle to a sound channel.
Definition: types.h:35
uint32_t uint32
Definition: types.h:204
virtual void highlight(bool enabled)
(Un)Highlight the object.
Definition: object.cpp:189
bool _usable
Is the object usable?
Definition: object.h:176
virtual void show()
Show the object&#39;s model(s).
Definition: object.cpp:84
A location within a Neverwinter Nights area.
Common::ScopedPtr< Aurora::SSFFile > _ssf
The object&#39;s sound set.
Definition: object.h:173
const Aurora::SSFFile * getSSF()
Return the object&#39;s sound set.
Definition: object.cpp:106
void setPCSpeaker(Aurora::NWScript::Object *pc)
Set the PC currently speaking with this object.
Definition: object.cpp:132
An object containing scripts.
Sound::ChannelHandle _sound
The currently playing object sound.
Definition: object.h:187
float _position[3]
The object&#39;s position.
Definition: object.h:184
ObjectType getType() const
Return the exact type of the object.
Definition: object.cpp:73
Common::UString _conversation
The object&#39;s default conversation.
Definition: object.h:170
void loadSSF()
Load the object&#39;s sound set.
Definition: object.cpp:192
void hideTooltip()
Hide the tooltip again.
Definition: object.cpp:337
virtual void hide()
Hide the object&#39;s model(s).
Definition: object.cpp:87
const std::list< uint32 > & getIDs() const
Return the object&#39;s model IDs.
Definition: object.cpp:124