xoreos  0.0.5
dialog.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 // TODO: Make dialog boxes resizeable and/or repositionable?
26 // TODO: Actually, in the original, the dialog boxes do resize themselves up to a point...
27 
28 #include "src/common/util.h"
29 #include "src/common/configman.h"
30 
31 #include "src/aurora/talkman.h"
32 #include "src/aurora/ssffile.h"
33 #include "src/aurora/dlgfile.h"
34 
35 #include "src/events/events.h"
36 
37 #include "src/graphics/graphics.h"
38 #include "src/graphics/font.h"
39 
44 
46 
47 #include "src/engines/nwn/types.h"
48 #include "src/engines/nwn/object.h"
50 #include "src/engines/nwn/module.h"
51 
53 
55 
56 static const float kDialogWidth = 350.0f;
57 static const float kDialogHeight = 254.0f;
58 
59 static const float kLightBlueR = 101.0f / 255.0f;
60 static const float kLightBlueG = 176.0f / 255.0f;
61 static const float kLightBlueB = 252.0f / 255.0f;
62 
63 static const uint32 kContinue = 1741;
64 static const uint32 kEndDialog = 1742;
65 
66 namespace Engines {
67 
68 namespace NWN {
69 
70 DialogBox::Reply::Reply(const Common::UString &r, uint32 i) : reply(r), id(i) {
71 }
72 
73 
74 DialogBox::ReplyLine::ReplyLine() : count(0), line(0) {
75 }
76 
77 DialogBox::ReplyLine::ReplyLine(std::list<Reply>::const_iterator &i) :
78  count(0), line(0), reply(i) {
79 
80 }
81 
82 
83 DialogBox::DialogBox(float width, float height) :
85  _width(width), _height(height),
86  _x(0.0f), _y(0.0f), _z(0.0f), _replyCount(0), _replyCountWidth(0.0f) {
87 
88  const Common::UString fontName =
89  ConfigMan.getBool("largefonts") ? "fnt_dialog_big16" : "fnt_dialog16x16";
90  _font = FontMan.get(fontName);
91 
93 
94  _name.reset(new Graphics::Aurora::Text(FontMan.get("fnt_galahad14"), " ",
96 
98  _pickedReply = _replies.end();
99 }
100 
102  clearReplies();
103  clearEntry();
104 }
105 
107  GfxMan.lockFrame();
108 
109  _portrait->show();
110  _name->show();
111 
112  showEntry();
113  showReplies();
114 
116 
117  GfxMan.unlockFrame();
118 }
119 
121  GfxMan.lockFrame();
122 
123  hideReplies();
124  hideEntry();
125 
126  _name->hide();
127  _portrait->hide();
128 
130 
131  GfxMan.unlockFrame();
132 }
133 
134 bool DialogBox::isIn(float x, float y) const {
135  if ((x < _x) || (x > (_x + _width)))
136  return false;
137  if ((y < _y) || (y > (_y + _height)))
138  return false;
139 
140  return true;
141 }
142 
143 float DialogBox::getWidth() const {
144  return _width;
145 }
146 
147 float DialogBox::getHeight() const {
148  return _height;
149 }
150 
151 void DialogBox::getPosition(float &x, float &y, float &z) const {
152  x = _x;
153  y = _y;
154  z = _z;
155 }
156 
157 void DialogBox::setPosition(float x, float y, float z) {
158  GfxMan.lockFrame();
159 
160  _x = x;
161  _y = y;
162  _z = z;
163 
164  // Portrait
165 
166  const float portraitX = _x + 3.0f;
167  const float portraitY = _y + _height - _portrait->getHeight() - 3.0f;
168  const float portraitZ = _z - 10.0f;
169 
170  _portrait->setPosition(portraitX, portraitY, portraitZ);
171 
172  // Name
173 
174  const float nameX = portraitX + _portrait->getWidth() + 5.0f;
175  const float nameY = portraitY + _portrait->getHeight() - _name->getHeight();
176 
177  _name->setPosition(nameX, nameY, portraitZ);
178 
179  // NPC Entry
180 
181  const float entryX = nameX;
182  float entryY = nameY - 4.0f;
183 
185  e != _entryLines.end(); ++e) {
186  entryY -= _font.getFont().getHeight() + _font.getFont().getLineSpacing();
187 
188  (*e)->setPosition(entryX, entryY, portraitZ);
189  }
190 
191  // PC Replies
192 
193  const float replyX = _x + 5.0f;
194  float replyY = MIN<float>(entryY, portraitY) - 4.0f;
195 
196  const float replyCountRight = replyX + _replyCountWidth;
197 
198  for (std::list<ReplyLine>::iterator r = _replyLines.begin(); r != _replyLines.end(); ++r) {
199  replyY -= _font.getFont().getHeight() + _font.getFont().getLineSpacing();
200 
201  if (r->count) {
202  const float replyCountX = replyCountRight - r->count->getWidth();
203 
204  r->count->setPosition(replyCountX, replyY, portraitZ);
205  }
206 
207  const float replyLineX = replyCountRight;
208 
209  if (r->line)
210  r->line->setPosition(replyLineX, replyY, portraitZ);
211  }
212 
213  resort();
214 
215  GfxMan.unlockFrame();
216 }
217 
219  clearReplies();
220  clearEntry();
221 
222  setPortrait("");
223  setName("");
224 }
225 
227  _portrait->setPortrait(portrait);
228 }
229 
231  // TODO: DialogBox::setName(): Check whether the name overflows the box
232 
233  _name->set(name);
234 }
235 
238  e != _entryLines.end(); ++e)
239  (*e)->show();
240 }
241 
244  e != _entryLines.end(); ++e)
245  (*e)->hide();
246 }
247 
249  if (_entry.empty() && _entryLines.empty())
250  return;
251 
252  GfxMan.lockFrame();
253 
254  hideEntry();
255 
256  _entryLines.clear();
257  _entry.clear();
258 
259  GfxMan.unlockFrame();
260 }
261 
263  GfxMan.lockFrame();
264 
265  clearEntry();
266 
267  if (entry.empty()) {
268  GfxMan.unlockFrame();
269  return;
270  }
271 
272  _entry = TokenMan.parse(entry);
273 
274  // TODO: Check entry length, scrollbars
275 
276  const float maxWidth = _width - 2.0f - 2.0f - _portrait->getWidth() - 5.0f;
277 
278  std::vector<Common::UString> lines;
279  _font.getFont().split(_entry, lines, maxWidth);
280 
281  for (std::vector<Common::UString>::iterator l = lines.begin(); l != lines.end(); ++l)
282  _entryLines.push_back(new Graphics::Aurora::Text(_font, *l));
283 
284  setPosition(_x, _y, _z);
285 
286  if (isVisible())
287  showEntry();
288 
289  GfxMan.unlockFrame();
290 }
291 
293  for (std::list<ReplyLine>::iterator r = _replyLines.begin(); r != _replyLines.end(); ++r) {
294  if (r->count)
295  r->count->show();
296 
297  if (r->line)
298  r->line->show();
299  }
300 }
301 
303  for (std::list<ReplyLine>::iterator r = _replyLines.begin(); r != _replyLines.end(); ++r) {
304  if (r->count)
305  r->count->hide();
306 
307  if (r->line)
308  r->line->hide();
309  }
310 }
311 
313  hideReplies();
314 
315  setHighlight(_replyLines.end());
316  _pickedReply = _replies.end();
317 
318  for (std::list<ReplyLine>::iterator r = _replyLines.begin(); r != _replyLines.end(); ++r) {
319  delete r->count;
320  delete r->line;
321  }
322 
323  _replyLines.clear();
324  _replies.clear();
325 
326  _replyCount = 0;
327  _replyCountWidth = 0.0f;
328 }
329 
331  _replies.push_back(Reply(reply, id));
332 }
333 
335  // Clear the current reply lines
336 
337  for (std::list<ReplyLine>::iterator r = _replyLines.begin(); r != _replyLines.end(); ++r) {
338  delete r->count;
339  delete r->line;
340  }
341 
342  _replyLines.clear();
343 
344 
345  _replyCount = 0;
346  _replyCountWidth = 0.0f;
347 
348  // Create the reply number texts
349 
350  for (std::list<Reply>::const_iterator r = _replies.begin(); r != _replies.end(); ++r) {
351  _replyLines.push_back(ReplyLine(r));
352 
353  _replyLines.back().count =
356 
357  _replyCountWidth = MAX(_replyCountWidth, _replyLines.back().count->getWidth());
358  }
359 
360  // Create the reply line texts
361 
362  const float maxWidth = _width - 6.0f - _replyCountWidth;
363 
364  for (std::list<ReplyLine>::iterator r = _replyLines.begin(); r != _replyLines.end(); ++r) {
365  std::vector<Common::UString> lines;
366 
367  std::list<Reply>::const_iterator reply = r->reply;
368 
369  _font.getFont().split(TokenMan.parse(reply->reply), lines, maxWidth);
370 
371  std::vector<Common::UString>::iterator line = lines.begin();
372  if (line == lines.end())
373  continue;
374 
375  r->line = new Graphics::Aurora::Text(_font, *line,
377 
378  for (++line; line != lines.end(); ++line) {
379  r = _replyLines.insert(++r, ReplyLine(reply));
380 
381  r->line = new Graphics::Aurora::Text(_font, *line,
383  }
384 
385  }
386 
387  setPosition(_x, _y, _z);
388 
389  if (isVisible())
390  showReplies();
391 }
392 
393 void DialogBox::mouseMove(int x, int y) {
394  float screenX, screenY;
395  CursorMan.toScreenCoordinates(x, y, screenX, screenY);
396 
397  if (!isIn(screenX, screenY)) {
398  setHighlight(_replyLines.end());
399  return;
400  }
401 
402  std::list<ReplyLine>::iterator highlight;
403  for (highlight = _replyLines.begin(); highlight != _replyLines.end(); ++highlight)
404  if ((highlight->count && highlight->count->isIn(screenX, screenY)) ||
405  (highlight->line && highlight->line->isIn (screenX, screenY)))
406  break;
407 
408  setHighlight(highlight);
409 }
410 
411 void DialogBox::mouseClick(int x, int y) {
412  mouseMove(x, y);
413 
414  if (_highlightedReply == _replyLines.end())
415  _pickedReply = _replies.end();
416  else
418 }
419 
421  if (n >= _replyCount) {
422  _pickedReply = _replies.end();
423  return;
424  }
425 
426  _pickedReply = _replies.begin();
427  std::advance(_pickedReply, n);
428 }
429 
431  if (_pickedReply == _replies.end())
433 
434  return _pickedReply->id;
435 }
436 
437 void DialogBox::setHighlight(const std::list<ReplyLine>::iterator &h) {
438  if (_highlightedReply != _replyLines.end()) {
439  uint32 id = _highlightedReply->reply->id;
440 
441  for (std::list<ReplyLine>::iterator r = _replyLines.begin();
442  r != _replyLines.end(); ++r) {
443 
444  if (r->reply->id != id)
445  continue;
446 
447  if (r->count)
448  r->count->setColor(kLightBlueR, kLightBlueG, kLightBlueB, 1.0f);
449  if (r->line)
450  r->line->setColor(kLightBlueR, kLightBlueG, kLightBlueB, 1.0f);
451  }
452 
453  }
454 
455  _highlightedReply = h;
456 
457  if (_highlightedReply != _replyLines.end()) {
458  if (_highlightedReply->count)
459  _highlightedReply->count->setColor(1.0f, 1.0f, 1.0f, 1.0f);
460  if (_highlightedReply->line)
461  _highlightedReply->line->setColor(1.0f, 1.0f, 1.0f, 1.0f);
462  }
463 
464  if (_highlightedReply != _replyLines.end()) {
465  uint32 id = _highlightedReply->reply->id;
466 
467  for (std::list<ReplyLine>::iterator r = _replyLines.begin();
468  r != _replyLines.end(); ++r) {
469 
470  if (r->reply->id != id)
471  continue;
472 
473  if (r->count)
474  r->count->setColor(1.0f, 1.0f, 1.0f, 1.0f);
475  if (r->line)
476  r->line->setColor(1.0f, 1.0f, 1.0f, 1.0f);
477  }
478 
479  }
480 
481 }
482 
484  _distance = _z;
485 }
486 
489  return;
490 
491  TextureMan.reset();
492  glColor4f(0.0f, 0.0f, 0.0f, 0.5f);
493 
494 
495  // Backdrop
496  glBegin(GL_QUADS);
497  glVertex2f(_x , _y );
498  glVertex2f(_x + _width, _y );
499  glVertex2f(_x + _width, _y + _height);
500  glVertex2f(_x , _y + _height);
501  glEnd();
502 
503  // Top edge
504  glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
505  glBegin(GL_QUADS);
506  glVertex2f(_x , _y + _height - 1.0f);
507  glVertex2f(_x + _width, _y + _height - 1.0f);
508  glVertex2f(_x + _width, _y + _height );
509  glVertex2f(_x , _y + _height );
510  glEnd();
511 
512  // Bottom edge
513  glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
514  glBegin(GL_QUADS);
515  glVertex2f(_x , _y );
516  glVertex2f(_x + _width, _y );
517  glVertex2f(_x + _width, _y + 1.0f);
518  glVertex2f(_x , _y + 1.0f);
519  glEnd();
520 
521  // Left edge
522  glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
523  glBegin(GL_QUADS);
524  glVertex2f(_x + 1.0f, _y + _height);
525  glVertex2f(_x , _y + _height);
526  glVertex2f(_x , _y );
527  glVertex2f(_x + 1.0f, _y );
528  glEnd();
529 
530  // Right edge
531  glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
532  glBegin(GL_QUADS);
533  glVertex2f(_x + _width , _y + _height);
534  glVertex2f(_x + _width - 1.0f, _y + _height);
535  glVertex2f(_x + _width - 1.0f, _y );
536  glVertex2f(_x + _width , _y );
537  glEnd();
538 
539  glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
540 }
541 
542 
544  Module &module, bool playHello) :
545  _conv(conv), _pc(&pc), _object(&obj), _module(&module) {
546 
547  _object->setPCSpeaker(&pc);
548 
549  _dlg.reset(new Aurora::DLGFile(conv, _object, true));
550  _dlg->startConversation();
551 
553 
554  updateBox();
555  playSound(playHello);
556  playAnimation();
557 
558  notifyResized(0, 0, WindowMan.getWindowWidth(), WindowMan.getWindowHeight());
559 }
560 
562  abort();
563 }
564 
565 bool Dialog::hasEnded() const {
566  return _dlg->hasEnded();
567 }
568 
569 void Dialog::show() {
570  _dlgBox->show();
571 }
572 
573 void Dialog::hide() {
574  _dlgBox->hide();
575 }
576 
578  stopAnimation();
579 
580  hide();
581 
582  _object->setPCSpeaker(0);
583  _object->stopSound();
584 
585  _dlg->abortConversation();
586 }
587 
588 void Dialog::addEvent(const Events::Event &event) {
589  _eventQueue.push_back(event);
590 }
591 
593  bool hasMove = false;
594 
595  for (std::list<Events::Event>::const_iterator e = _eventQueue.begin();
596  e != _eventQueue.end(); ++e) {
597 
598  if (e->type == Events::kEventMouseMove)
599  hasMove = true;
600  else if (e->type == Events::kEventKeyDown)
601  keyPressed(*e);
602  else if (e->type == Events::kEventMouseDown)
603  mouseClick(*e);
604  }
605 
606  _eventQueue.clear();
607 
608  if (hasMove)
609  mouseMove();
610 
611  return hasEnded() ? 1 : 0;
612 }
613 
615  int x, y;
616  CursorMan.getPosition(x, y);
617 
618  _dlgBox->mouseMove(x, y);
619 }
620 
621 void Dialog::mouseClick(const Events::Event &event) {
622  if (event.button.button != SDL_BUTTON_LMASK)
623  return;
624 
625  _dlgBox->mouseClick(event.button.x, event.button.y);
626  checkPicked();
627 }
628 
629 void Dialog::keyPressed(const Events::Event &event) {
630  if (event.key.keysym.sym == SDLK_ESCAPE) {
631  abort();
632  return;
633  }
634 
635  if (event.key.keysym.sym == SDLK_1)
636  _dlgBox->pickReply(0);
637  else if (event.key.keysym.sym == SDLK_2)
638  _dlgBox->pickReply(1);
639  else if (event.key.keysym.sym == SDLK_3)
640  _dlgBox->pickReply(2);
641  else if (event.key.keysym.sym == SDLK_4)
642  _dlgBox->pickReply(3);
643  else if (event.key.keysym.sym == SDLK_5)
644  _dlgBox->pickReply(4);
645  else if (event.key.keysym.sym == SDLK_6)
646  _dlgBox->pickReply(5);
647  else if (event.key.keysym.sym == SDLK_7)
648  _dlgBox->pickReply(6);
649  else if (event.key.keysym.sym == SDLK_8)
650  _dlgBox->pickReply(7);
651  else if (event.key.keysym.sym == SDLK_9)
652  _dlgBox->pickReply(8);
653  else if (event.key.keysym.sym == SDLK_0)
654  _dlgBox->pickReply(9);
655 
656  checkPicked();
657 }
658 
660  uint32 picked = _dlgBox->getPickedID();
661  if (picked == Aurora::DLGFile::kInvalidLine)
662  return;
663 
664  _dlg->pickReply(picked);
665  if (_dlg->hasEnded()) {
666  stopAnimation();
667  return;
668  }
669 
670  updateBox();
671  playSound(false);
672  playAnimation();
673 
674  // Update the highlighted reply
675  mouseMove();
676 }
677 
678 void Dialog::notifyResized(int UNUSED(oldWidth), int UNUSED(oldHeight),
679  int newWidth, int newHeight) {
680 
681  const float x = -(newWidth / 2.0f) + 10.0f;
682  const float y = (newHeight / 2.0f) - _dlgBox->getHeight() - 20.0f;
683 
684  _dlgBox->setPosition(x, y, 0.0f);
685 }
686 
688  GfxMan.lockFrame();
689 
690  _dlgBox->clear();
691 
692  // Entry
693 
694 
695  const Aurora::DLGFile::Line *entry = _dlg->getCurrentEntry();
696  if (entry) {
697  // Name and portrait
698 
699  Object *speaker = getSpeaker();
700 
701  if (speaker) {
702  _dlgBox->setPortrait(speaker->getPortrait());
703  _dlgBox->setName(speaker->getName());
704  } else
705  _dlgBox->setName("[INVALID NPC]");
706 
707  // Text
708  _dlgBox->setEntry(entry->text.getString());
709  }
710 
711  // Replies
712 
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) {
717 
718  Common::UString text = (*r)->text.getString();
719  if (text.empty())
720  text = TalkMan.getString((*r)->isEnd ? kEndDialog : kContinue);
721 
722  _dlgBox->addReply(text, (*r)->id);
723  }
724  } else
725  _dlgBox->addReply(TalkMan.getString(kEndDialog), Aurora::DLGFile::kEndLine);
726 
727  _dlgBox->finishReplies();
728 
729  GfxMan.unlockFrame();
730 }
731 
733  const Aurora::DLGFile::Line *entry = _dlg->getCurrentEntry();
734  if (!entry)
735  return 0;
736 
737  if (!entry->speaker.empty())
738  return dynamic_cast<Object *>(_module->getFirstObjectByTag(entry->speaker));
739 
740  return _object;
741 }
742 
743 void Dialog::playSound(bool greeting) {
744  const Aurora::DLGFile::Line *entry = _dlg->getCurrentEntry();
745  if (!entry)
746  return;
747 
748  Common::UString sound = entry->sound;
749 
750  bool isSSF = false;
751  if (sound.empty() && greeting) {
752  const Aurora::SSFFile *ssf = _object->getSSF();
753 
754  if (ssf) {
755  isSSF = true;
756 
757  sound = ssf->getSoundFile(kSSFHello);
758  }
759  }
760 
761  _object->playSound(sound, isSSF);
762 }
763 
764 struct TalkAnim {
766  const char *name;
767 };
768 
770  Object *speaker = getSpeaker();
771  if (!speaker)
772  return;
773 
774  const Aurora::DLGFile::Line *entry = _dlg->getCurrentEntry();
775  if (!entry) {
776  stopAnimation();
777  return;
778  }
779 
780  speaker->playAnimation(getCreatureTalkAnimationName((TalkAnimation) entry->animation), false, -1.0f);
781 }
782 
784  Object *speaker = getSpeaker();
785  if (!speaker)
786  return;
787 
788  speaker->playAnimation();
789 }
790 
791 } // End of namespace NWN
792 
793 } // End of namespace Engines
const Common::UString & getPortrait() const
Return the object&#39;s portrait.
Definition: object.cpp:98
Common::ScopedPtr< Portrait > _portrait
The current speaker&#39;s portrait.
Definition: dialog.h:156
const Common::UString & getSoundFile(size_t index) const
Return the sound file to play for this sound.
Definition: ssffile.cpp:173
virtual void show()
Show the object.
Definition: renderable.cpp:114
Handling BioWare&#39;s SSFs (sound set file).
void notifyResized(int oldWidth, int oldHeight, int newWidth, int newHeight)
Definition: dialog.cpp:678
static const uint32 kContinue
Definition: dialog.cpp:63
static const float kLightBlueR
Definition: dialog.cpp:59
The global graphics manager.
#define TalkMan
Shortcut for accessing the talk manager.
Definition: talkman.h:111
virtual void hide()
Hide the object.
Definition: renderable.cpp:123
float getWidth() const
Return the box&#39;s width.
Definition: dialog.cpp:143
static const float kDialogHeight
Definition: dialog.cpp:57
A class holding an UTF-8 string.
Definition: ustring.h:48
void setPortrait(const Common::UString &portrait)
Set the current speaker&#39;s portrait.
Definition: dialog.cpp:226
#define TextureMan
Shortcut for accessing the texture manager.
Definition: textureman.h:127
float _height
The box&#39;s height.
Definition: dialog.h:149
std::list< Reply >::const_iterator _pickedReply
The picked (clicked) reply.
Definition: dialog.h:173
uint32 _replyCount
The number of replies.
Definition: dialog.h:169
void setName(const Common::UString &name)
Set the current speaker&#39;s name.
Definition: dialog.cpp:230
void reset(PointerType o=0)
Resets the pointer with the new value.
Definition: scopedptr.h:87
double _distance
The distance of the object from the viewer.
Definition: renderable.h:101
The global config manager.
const Common::UString & getName() const
Return the object&#39;s name.
Definition: object.cpp:90
Reply(const Common::UString &r="", uint32 i=0xFFFFFFFF)
Definition: dialog.cpp:70
void addEvent(const Events::Event &event)
Add a single event for consideration into the event queue.
Definition: dialog.cpp:588
Class to hold a sound set.
Definition: ssffile.h:55
static const float kLightBlueB
Definition: dialog.cpp:61
virtual float getLineSpacing() const
Return the size of space between lines.
Definition: font.cpp:39
The Aurora texture manager.
int processEventQueue()
Process the current event queue.
Definition: dialog.cpp:592
void hide()
Hide the dialog.
Definition: dialog.cpp:573
A text object.
Common::ScopedPtr< Aurora::DLGFile > _dlg
The conversation file.
Definition: dialog.h:221
void setPosition(float x, float y, float z)
Set the box&#39;s position.
Definition: dialog.cpp:157
void pickReply(uint32 n)
Pick the reply number n.
Definition: dialog.cpp:420
float split(const Common::UString &line, std::vector< Common::UString > &lines, float maxWidth=0.0f, float maxHeight=0.0f, bool trim=true) const
Definition: font.cpp:69
void clearReplies()
Clear the PC replies.
Definition: dialog.cpp:312
void mouseMove()
The mouse was moved.
Definition: dialog.cpp:614
Basic Neverwinter Nights type definitions.
std::list< Reply > _replies
The PC replies.
Definition: dialog.h:164
uint32 getPickedID() const
Return the reply ID that was clicked.
Definition: dialog.cpp:430
void abort()
Abort the current conversation.
Definition: dialog.cpp:577
void playSound(bool greeting)
Play a conversation sound.
Definition: dialog.cpp:743
const Common::UString & getString(Language language, LanguageGender gender=kLanguageGenderCurrent) const
Get the string of that language.
Definition: locstring.cpp:82
GUIElement(GUIElementType type)
Definition: guielement.h:41
The Aurora font manager.
Mouse was moved.
Definition: types.h:48
float _replyCountWidth
The max width of a reply number text.
Definition: dialog.h:170
Common::UString sound
ResRef of the sound to play while speaking this entry.
Definition: dlgfile.h:73
SDL_Event Event
Definition: types.h:42
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
Common::UString _entry
The NPC entry.
Definition: dialog.h:163
Mouse button was pressed.
Definition: types.h:49
Keyboard key was pressed.
Definition: types.h:46
The context needed to run a Neverwinter Nights module.
static const uint32 kEndDialog
Definition: dialog.cpp:64
float _x
The box&#39;s X position.
Definition: dialog.h:151
void render(Graphics::RenderPass pass)
Render the object.
Definition: dialog.cpp:487
A text object.
Definition: text.h:42
Common::ScopedPtr< Graphics::Aurora::Text > _name
The current speaker&#39;s name.
Definition: dialog.h:158
RenderPass
Definition: types.h:97
void stopAnimation()
Stop a conversation animation.
Definition: dialog.cpp:783
static UString format(const char *s,...) GCC_PRINTF(1
Print formatted data into an UString object, similar to sprintf().
Definition: ustring.cpp:718
void showEntry()
Show the entry.
Definition: dialog.cpp:236
Common::PtrList< Graphics::Aurora::Text > _entryLines
The NPC text lines.
Definition: dialog.h:166
Object * _object
The conversation&#39;s NPC.
Definition: dialog.h:215
void show()
Show the box.
Definition: dialog.cpp:106
#define ConfigMan
Shortcut for accessing the config manager.
Definition: configman.h:176
#define UNUSED(x)
Definition: system.h:170
void updateBox()
Update the box&#39;s contents.
Definition: dialog.cpp:687
void getPosition(float &x, float &y, float &z) const
Return the box&#39;s position.
Definition: dialog.cpp:151
Utility templates and functions.
A list of pointer to objects, with automatic deletion.
Definition: ptrlist.h:41
float _y
The box&#39;s Y position.
Definition: dialog.h:152
void setEntry(const Common::UString &entry)
Set the NPC entry.
Definition: dialog.cpp:262
static const float kDialogWidth
Definition: dialog.cpp:56
The global events manager.
Dialog(const Common::UString &conv, Creature &pc, Object &obj, Module &module, bool playHello=true)
Definition: dialog.cpp:543
void keyPressed(const Events::Event &event)
A keyboard key was pressed.
Definition: dialog.cpp:629
void calculateDistance()
Calculate the object&#39;s distance.
Definition: dialog.cpp:483
void hideReplies()
Hide the replies.
Definition: dialog.cpp:302
std::list< ReplyLine >::iterator _highlightedReply
The currently highlighted reply.
Definition: dialog.h:172
void playSound(const Common::UString &sound, bool pitchVariance=false)
Play an object sound.
Definition: object.cpp:248
bool empty() const
Is the string empty?
Definition: ustring.cpp:245
void mouseClick(int x, int y)
Notify the box that the mouse was clicked.
Definition: dialog.cpp:411
void mouseMove(int x, int y)
Notify the box that the mouse was moved.
Definition: dialog.cpp:393
#define CursorMan
Shortcut for accessing the cursor manager.
Definition: cursorman.h:129
Module * _module
The module this dialog is in.
Definition: dialog.h:217
The Aurora cursor manager.
DialogBox(float width, float height)
Definition: dialog.cpp:83
void showReplies()
Show the replies.
Definition: dialog.cpp:292
const char * name
Definition: dialog.cpp:766
The NWN ingame dialog panel.
An object in a Neverwinter Nights area.
void show()
Show the dialog.
Definition: dialog.cpp:569
void stopSound()
Stop the current object sound.
Definition: object.cpp:244
#define WindowMan
Shortcut for accessing the window manager.
Definition: windowman.h:137
static const float kLightBlueG
Definition: dialog.cpp:60
static const uint32 kEndLine
Definition: dlgfile.h:64
float _z
The box&#39;s Z position.
Definition: dialog.h:153
A NWN portrait model.
Definition: portrait.h:47
void clear()
Definition: ptrlist.h:47
bool isVisible() const
Is the object visible?
Definition: renderable.cpp:106
void hideEntry()
Hide the entry.
Definition: dialog.cpp:242
Graphics::Aurora::FontHandle _font
The dialog font.
Definition: dialog.h:161
TalkAnimation id
Definition: dialog.cpp:765
uint32_t uint32
Definition: types.h:204
The global talk manager for Aurora strings.
A creature in a Neverwinter Nights area.
Common::ScopedPtr< DialogBox > _dlgBox
The actual dialog box.
Definition: dialog.h:219
void addReply(const Common::UString &reply, uint32 id)
Add a PC reply.
Definition: dialog.cpp:330
void mouseClick(const Events::Event &event)
The mouse was clicked.
Definition: dialog.cpp:621
void clear()
Clear the complete contents.
Definition: dialog.cpp:218
bool hasEnded() const
Has the conversation ended?
Definition: dialog.cpp:565
void setHighlight(const std::list< ReplyLine >::iterator &h)
Set the highlighted reply.
Definition: dialog.cpp:437
A portrait model and widget.
void clearEntry()
Clear the NPC entry.
Definition: dialog.cpp:248
bool isIn(float x, float y) const
Are the coordinates inside the box?
Definition: dialog.cpp:134
const Aurora::SSFFile * getSSF()
Return the object&#39;s sound set.
Definition: object.cpp:106
A line of a PC reply.
Definition: dialog.h:138
#define pass
Definition: fft.cpp:257
void finishReplies()
Finished adding PC replies.
Definition: dialog.cpp:334
void setPCSpeaker(Aurora::NWScript::Object *pc)
Set the PC currently speaking with this object.
Definition: object.cpp:132
void hide()
Hide the box.
Definition: dialog.cpp:120
Manager for tokens in Aurora engines text strings.
void playAnimation()
Play a conversation animation.
Definition: dialog.cpp:769
uint32 animation
Animation to play while speaking this entry.
Definition: dlgfile.h:76
float _width
The box&#39;s width.
Definition: dialog.h:148
Common::UString getCreatureTalkAnimationName(TalkAnimation animation)
Return the name (as found in the models) of a specific creature talk animation.
Definition: types.cpp:120
T MAX(T a, T b)
Definition: util.h:71
Handling BioWare&#39;s DLGs (dialog / conversation files).
virtual float getHeight() const =0
Return the height of a character.
void clear()
Clear the string&#39;s contents.
Definition: ustring.cpp:236
Object * getFirstObjectByTag(const Common::UString &tag) const
Return the first object with this tag.
static const uint32 kInvalidLine
Definition: dlgfile.h:65
#define TokenMan
Shortcut for accessing the token manager.
Definition: tokenman.h:63
A font.
#define GfxMan
Shortcut for accessing the graphics manager.
Definition: graphics.h:299
Only render opaque parts.
Definition: types.h:98
std::list< ReplyLine > _replyLines
The PC text lines.
Definition: dialog.h:167
float getHeight() const
Return the box&#39;s height.
Definition: dialog.cpp:147
Common::UString speaker
Tag of the speaker, empty if default.
Definition: dlgfile.h:70
std::list< Events::Event > _eventQueue
The event queue.
Definition: dialog.h:223
#define FontMan
Shortcut for accessing the font manager.
Definition: fontman.h:105
LocString text
The actual text of the entry.
Definition: dlgfile.h:71
Object * getSpeaker()
Get the current speaker.
Definition: dialog.cpp:732