78 count(0), line(0), reply(i) {
89 ConfigMan.getBool(
"largefonts") ?
"fnt_dialog_big16" :
"fnt_dialog16x16";
166 const float portraitX =
_x + 3.0f;
168 const float portraitZ =
_z - 10.0f;
170 _portrait->setPosition(portraitX, portraitY, portraitZ);
174 const float nameX = portraitX +
_portrait->getWidth() + 5.0f;
175 const float nameY = portraitY +
_portrait->getHeight() -
_name->getHeight();
177 _name->setPosition(nameX, nameY, portraitZ);
181 const float entryX = nameX;
182 float entryY = nameY - 4.0f;
188 (*e)->setPosition(entryX, entryY, portraitZ);
193 const float replyX =
_x + 5.0f;
194 float replyY = MIN<float>(entryY, portraitY) - 4.0f;
202 const float replyCountX = replyCountRight - r->count->getWidth();
204 r->count->setPosition(replyCountX, replyY, portraitZ);
207 const float replyLineX = replyCountRight;
210 r->line->setPosition(replyLineX, replyY, portraitZ);
276 const float maxWidth =
_width - 2.0f - 2.0f -
_portrait->getWidth() - 5.0f;
278 std::vector<Common::UString> lines;
281 for (std::vector<Common::UString>::iterator l = lines.begin(); l != lines.end(); ++l)
350 for (std::list<Reply>::const_iterator r =
_replies.begin(); r !=
_replies.end(); ++r) {
365 std::vector<Common::UString> lines;
367 std::list<Reply>::const_iterator reply = r->reply;
371 std::vector<Common::UString>::iterator line = lines.begin();
372 if (line == lines.end())
378 for (++line; line != lines.end(); ++line) {
394 float screenX, screenY;
395 CursorMan.toScreenCoordinates(x, y, screenX, screenY);
397 if (!
isIn(screenX, screenY)) {
402 std::list<ReplyLine>::iterator highlight;
404 if ((highlight->count && highlight->count->isIn(screenX, screenY)) ||
405 (highlight->line && highlight->line->isIn (screenX, screenY)))
441 for (std::list<ReplyLine>::iterator r =
_replyLines.begin();
444 if (r->reply->id !=
id)
467 for (std::list<ReplyLine>::iterator r =
_replyLines.begin();
470 if (r->reply->id !=
id)
474 r->count->setColor(1.0f, 1.0f, 1.0f, 1.0f);
476 r->line->setColor(1.0f, 1.0f, 1.0f, 1.0f);
492 glColor4f(0.0f, 0.0f, 0.0f, 0.5f);
497 glVertex2f(
_x ,
_y );
504 glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
513 glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
515 glVertex2f(
_x ,
_y );
518 glVertex2f(
_x ,
_y + 1.0f);
522 glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
526 glVertex2f(
_x ,
_y );
527 glVertex2f(
_x + 1.0f,
_y );
531 glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
539 glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
544 Module &module,
bool playHello) :
545 _conv(conv), _pc(&pc), _object(&obj), _module(&module) {
550 _dlg->startConversation();
566 return _dlg->hasEnded();
585 _dlg->abortConversation();
593 bool hasMove =
false;
595 for (std::list<Events::Event>::const_iterator e =
_eventQueue.begin();
622 if (event.button.button != SDL_BUTTON_LMASK)
625 _dlgBox->mouseClick(event.button.x, event.button.y);
630 if (event.key.keysym.sym == SDLK_ESCAPE) {
635 if (event.key.keysym.sym == SDLK_1)
637 else if (event.key.keysym.sym == SDLK_2)
639 else if (event.key.keysym.sym == SDLK_3)
641 else if (event.key.keysym.sym == SDLK_4)
643 else if (event.key.keysym.sym == SDLK_5)
645 else if (event.key.keysym.sym == SDLK_6)
647 else if (event.key.keysym.sym == SDLK_7)
649 else if (event.key.keysym.sym == SDLK_8)
651 else if (event.key.keysym.sym == SDLK_9)
653 else if (event.key.keysym.sym == SDLK_0)
664 _dlg->pickReply(picked);
665 if (
_dlg->hasEnded()) {
679 int newWidth,
int newHeight) {
681 const float x = -(newWidth / 2.0f) + 10.0f;
682 const float y = (newHeight / 2.0f) -
_dlgBox->getHeight() - 20.0f;
684 _dlgBox->setPosition(x, y, 0.0f);
705 _dlgBox->setName(
"[INVALID NPC]");
713 const std::vector<const Aurora::DLGFile::Line *> &replies =
_dlg->getCurrentReplies();
714 if (!replies.empty()) {
715 for (std::vector<const Aurora::DLGFile::Line *>::const_iterator r = replies.begin();
716 r != replies.end(); ++r) {
722 _dlgBox->addReply(text, (*r)->id);
751 if (sound.
empty() && greeting) {
const Common::UString & getPortrait() const
Return the object's portrait.
Common::ScopedPtr< Portrait > _portrait
The current speaker's portrait.
const Common::UString & getSoundFile(size_t index) const
Return the sound file to play for this sound.
virtual void show()
Show the object.
Handling BioWare's SSFs (sound set file).
void notifyResized(int oldWidth, int oldHeight, int newWidth, int newHeight)
static const uint32 kContinue
static const float kLightBlueR
The global graphics manager.
#define TalkMan
Shortcut for accessing the talk manager.
virtual void hide()
Hide the object.
float getWidth() const
Return the box's width.
static const float kDialogHeight
A class holding an UTF-8 string.
void setPortrait(const Common::UString &portrait)
Set the current speaker's portrait.
#define TextureMan
Shortcut for accessing the texture manager.
float _height
The box's height.
std::list< Reply >::const_iterator _pickedReply
The picked (clicked) reply.
uint32 _replyCount
The number of replies.
void setName(const Common::UString &name)
Set the current speaker's name.
void reset(PointerType o=0)
Resets the pointer with the new value.
double _distance
The distance of the object from the viewer.
The global config manager.
const Common::UString & getName() const
Return the object's name.
Reply(const Common::UString &r="", uint32 i=0xFFFFFFFF)
void addEvent(const Events::Event &event)
Add a single event for consideration into the event queue.
Class to hold a sound set.
static const float kLightBlueB
virtual float getLineSpacing() const
Return the size of space between lines.
The Aurora texture manager.
int processEventQueue()
Process the current event queue.
void hide()
Hide the dialog.
Common::ScopedPtr< Aurora::DLGFile > _dlg
The conversation file.
void setPosition(float x, float y, float z)
Set the box's position.
void pickReply(uint32 n)
Pick the reply number n.
float split(const Common::UString &line, std::vector< Common::UString > &lines, float maxWidth=0.0f, float maxHeight=0.0f, bool trim=true) const
void clearReplies()
Clear the PC replies.
void mouseMove()
The mouse was moved.
Basic Neverwinter Nights type definitions.
std::list< Reply > _replies
The PC replies.
uint32 getPickedID() const
Return the reply ID that was clicked.
void abort()
Abort the current conversation.
void playSound(bool greeting)
Play a conversation sound.
const Common::UString & getString(Language language, LanguageGender gender=kLanguageGenderCurrent) const
Get the string of that language.
GUIElement(GUIElementType type)
float _replyCountWidth
The max width of a reply number text.
Common::UString sound
ResRef of the sound to play while speaking this entry.
virtual void playAnimation(const Common::UString &animation="", bool restart=true, float length=0.0f, float speed=1.0f)
Play an object animation.
Common::UString _entry
The NPC entry.
Mouse button was pressed.
Keyboard key was pressed.
The context needed to run a Neverwinter Nights module.
static const uint32 kEndDialog
float _x
The box's X position.
void render(Graphics::RenderPass pass)
Render the object.
Common::ScopedPtr< Graphics::Aurora::Text > _name
The current speaker's name.
void stopAnimation()
Stop a conversation animation.
static UString format(const char *s,...) GCC_PRINTF(1
Print formatted data into an UString object, similar to sprintf().
void showEntry()
Show the entry.
Common::PtrList< Graphics::Aurora::Text > _entryLines
The NPC text lines.
Object * _object
The conversation's NPC.
#define ConfigMan
Shortcut for accessing the config manager.
void updateBox()
Update the box's contents.
void getPosition(float &x, float &y, float &z) const
Return the box's position.
Utility templates and functions.
A list of pointer to objects, with automatic deletion.
float _y
The box's Y position.
void setEntry(const Common::UString &entry)
Set the NPC entry.
static const float kDialogWidth
The global events manager.
Dialog(const Common::UString &conv, Creature &pc, Object &obj, Module &module, bool playHello=true)
void keyPressed(const Events::Event &event)
A keyboard key was pressed.
void calculateDistance()
Calculate the object's distance.
void hideReplies()
Hide the replies.
std::list< ReplyLine >::iterator _highlightedReply
The currently highlighted reply.
void playSound(const Common::UString &sound, bool pitchVariance=false)
Play an object sound.
bool empty() const
Is the string empty?
void mouseClick(int x, int y)
Notify the box that the mouse was clicked.
void mouseMove(int x, int y)
Notify the box that the mouse was moved.
#define CursorMan
Shortcut for accessing the cursor manager.
Module * _module
The module this dialog is in.
The Aurora cursor manager.
DialogBox(float width, float height)
void showReplies()
Show the replies.
The NWN ingame dialog panel.
An object in a Neverwinter Nights area.
void show()
Show the dialog.
void stopSound()
Stop the current object sound.
#define WindowMan
Shortcut for accessing the window manager.
static const float kLightBlueG
static const uint32 kEndLine
float _z
The box's Z position.
bool isVisible() const
Is the object visible?
void hideEntry()
Hide the entry.
Graphics::Aurora::FontHandle _font
The dialog font.
The global talk manager for Aurora strings.
A creature in a Neverwinter Nights area.
Common::ScopedPtr< DialogBox > _dlgBox
The actual dialog box.
void addReply(const Common::UString &reply, uint32 id)
Add a PC reply.
void mouseClick(const Events::Event &event)
The mouse was clicked.
void clear()
Clear the complete contents.
bool hasEnded() const
Has the conversation ended?
void setHighlight(const std::list< ReplyLine >::iterator &h)
Set the highlighted reply.
A portrait model and widget.
void clearEntry()
Clear the NPC entry.
bool isIn(float x, float y) const
Are the coordinates inside the box?
const Aurora::SSFFile * getSSF()
Return the object's sound set.
void finishReplies()
Finished adding PC replies.
void setPCSpeaker(Aurora::NWScript::Object *pc)
Set the PC currently speaking with this object.
Manager for tokens in Aurora engines text strings.
void playAnimation()
Play a conversation animation.
uint32 animation
Animation to play while speaking this entry.
float _width
The box's width.
Common::UString getCreatureTalkAnimationName(TalkAnimation animation)
Return the name (as found in the models) of a specific creature talk animation.
Handling BioWare's DLGs (dialog / conversation files).
virtual float getHeight() const =0
Return the height of a character.
void clear()
Clear the string's contents.
Object * getFirstObjectByTag(const Common::UString &tag) const
Return the first object with this tag.
static const uint32 kInvalidLine
#define TokenMan
Shortcut for accessing the token manager.
#define GfxMan
Shortcut for accessing the graphics manager.
Only render opaque parts.
std::list< ReplyLine > _replyLines
The PC text lines.
float getHeight() const
Return the box's height.
Common::UString speaker
Tag of the speaker, empty if default.
std::list< Events::Event > _eventQueue
The event queue.
#define FontMan
Shortcut for accessing the font manager.
LocString text
The actual text of the entry.
Object * getSpeaker()
Get the current speaker.