Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

Dialog Class Reference

Inheritance diagram for Dialog:

Inheritance graph
[legend]
Collaboration diagram for Dialog:

Collaboration graph
[legend]

Detailed Description

Dialog with sound and subtitle.

Dialog is const class only sound is lazy loaded.

Definition at line 14 of file Dialog.h.

Public Member Functions

 Dialog (const std::string &lang, const std::string &soundfile, const std::string &subtitle)
 Create new dialog.
virtual ~Dialog ()
bool isSpeechless () const
int talk (int volume, int loops=0) const
 Run dialog.
virtual void runSubtitle (const StringTool::t_args &args) const
 Override this method to run subtitles.
std::string getLang () const
std::string getSubtitle () const
std::string getFormatedSubtitle (const StringTool::t_args &args) const
 Replace 1, 2, .
int getMinTime () const
 Minimal time according subtitle length.
bool equalSound (const Mix_Chunk *other) const

Static Public Attributes

static const std::string DEFAULT_LANG = "en"


Constructor & Destructor Documentation

Dialog::Dialog const std::string &  lang,
const std::string &  soundfile,
const std::string &  subtitle
 

Create new dialog.

Both sound file and subtitles are optional.

Definition at line 23 of file Dialog.cpp.

00025     : m_soundfile(soundfile), m_lang(lang), m_subtitle(subtitle)
00026 {
00027     m_sound = NULL;
00028 }

Dialog::~Dialog  )  [virtual]
 

Definition at line 30 of file Dialog.cpp.

00031 {
00032     if (m_sound) {
00033         Mix_FreeChunk(m_sound);
00034     }
00035 }


Member Function Documentation

bool Dialog::equalSound const Mix_Chunk *  other  )  const [inline]
 

Definition at line 35 of file Dialog.h.

00036         { return m_sound == other; }

std::string Dialog::getFormatedSubtitle const StringTool::t_args args  )  const
 

Replace 1, 2, .

.. with the arguments. NOTE: 0 is not expanded

Definition at line 72 of file Dialog.cpp.

00073 {
00074     std::string buffer = m_subtitle;
00075     for (unsigned int i = 1; i < args.size(); ++i) {
00076         StringTool::replace(buffer,
00077                 "%" + StringTool::toString(i), args[i]);
00078     }
00079     return buffer;
00080 }

std::string Dialog::getLang  )  const [inline]
 

Definition at line 30 of file Dialog.h.

00030 { return m_lang; }

int Dialog::getMinTime  )  const
 

Minimal time according subtitle length.

Returns:
minimal number of cycles for talk

Definition at line 87 of file Dialog.cpp.

00088 {
00089     return min(180, m_subtitle.size());
00090 }

std::string Dialog::getSubtitle  )  const [inline]
 

Definition at line 31 of file Dialog.h.

00031 { return m_subtitle; }

bool Dialog::isSpeechless  )  const [inline]
 

Definition at line 27 of file Dialog.h.

00027 { return m_soundfile.empty(); }

void Dialog::runSubtitle const StringTool::t_args args  )  const [virtual]
 

Override this method to run subtitles.

Reimplemented in FishDialog.

Definition at line 61 of file Dialog.cpp.

00062 {
00063     LOG_INFO(ExInfo("subtitle")
00064             .addInfo("content", getFormatedSubtitle(args)));
00065 }

int Dialog::talk int  volume,
int  loops = 0
const
 

Run dialog.

Do lazy loading of sound.

Parameters:
volume sound volume
loops numer of loops. 0=play once, 1=play twice, -1=play infinite
Returns:
channel number where the sound is played or -1

Definition at line 46 of file Dialog.cpp.

00047 {
00048     if (NULL == m_sound && !m_soundfile.empty()) {
00049         Path soundPath = Path::dataReadPath(m_soundfile);
00050         m_sound = ResSoundPack::loadSound(soundPath);
00051     }
00052 
00053     int channel = SoundAgent::agent()->playSound(m_sound, volume, loops);
00054     return channel;
00055 }


Field Documentation

const std::string Dialog::DEFAULT_LANG = "en" [static]
 

Definition at line 17 of file Dialog.cpp.


The documentation for this class was generated from the following files:
Generated on Wed Jun 1 09:54:52 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2