xoreos  0.0.5
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Aurora::SSFFile Class Reference

Class to hold a sound set. More...

#include <ssffile.h>

Inheritance diagram for Aurora::SSFFile:
Inheritance graph
[legend]
Collaboration diagram for Aurora::SSFFile:
Collaboration graph
[legend]

Classes

struct  Sound
 A sound in the sound set. More...
 

Public Types

enum  Version { kVersion10_NWN, kVersion11_NWN2, kVersion11_KotOR }
 The different versions of SSF files that exists. More...
 

Public Member Functions

 SSFFile ()
 
 SSFFile (Common::SeekableReadStream &ssf)
 
 SSFFile (const Common::UString &ssf)
 
 ~SSFFile ()
 
size_t getSoundCount () const
 Return the number of sounds in this SSF file. More...
 
const Common::UStringgetSoundFile (size_t index) const
 Return the sound file to play for this sound. More...
 
uint32 getStrRef (size_t index) const
 Return the string reference of the text to display for this sound. More...
 
void getSound (size_t index, Common::UString &soundFile, uint32 &strRef) const
 Return both the sound file and the string reference for this sound. More...
 
void setSoundFile (size_t index, const Common::UString &soundFile)
 Set the sound file to play for this sound. More...
 
void setStrRef (size_t index, uint32 strRef)
 Set the string reference of the text to display for this sound. More...
 
void setSound (size_t index, const Common::UString &soundFile, uint32 strRef)
 Set both the sound file and the string reference for this sound. More...
 
Version determineVersionForGame (GameID game) const
 Determine the best version to save this SSF file in, for the specified game. More...
 
void writeSSF (Common::WriteStream &out, Version version) const
 Write the SSF into a stream, as the specified version. More...
 
bool writeSSF (const Common::UString &fileName, Version version) const
 Write the SSF into a file, as the specified version. More...
 
- Public Member Functions inherited from Aurora::AuroraFile
 AuroraFile ()
 
void clear ()
 
uint32 getID () const
 Return the file's ID. More...
 
uint32 getVersion () const
 Return the file's version. More...
 
bool isUTF16LE () const
 Were the ID and version encoded in little-endian UTF-16 in the file? More...
 

Private Types

typedef std::vector< SoundSoundSet
 

Private Member Functions

void load (Common::SeekableReadStream &ssf)
 
Version readSSFHeader (Common::SeekableReadStream &ssf, size_t &entryCount, size_t &offEntryTable)
 Read the header of an SSF file and determine the version. More...
 
void readEntries (Common::SeekableReadStream &ssf, Version version, size_t offset)
 Read the data entries, depending on the version. More...
 
void readEntriesNWN (Common::SeekableReadStream &ssf, size_t soundFileLen)
 Read the data entries of the NWN versions. More...
 
void readEntriesKotOR (Common::SeekableReadStream &ssf)
 Read the data entries of the KotOR version. More...
 
size_t getMaxSoundFileLen () const
 Return the maximum length of a sound filename in characters. More...
 
bool existNonASCIISoundFile () const
 Is there a sound filename with non-ASCII characters? More...
 
void checkVersionFeatures (Version version) const
 Make sure this SSF files fits the requirements for specified SSF version. More...
 
void writeNWN (Common::WriteStream &out) const
 Write this SSF into a stream as a V1.0 (NWN). More...
 
void writeNWN2 (Common::WriteStream &out) const
 Write this SSF into a stream as a V1.1 (NWN2). More...
 
void writeKotOR (Common::WriteStream &out) const
 Write this SSF into a stream as a V1.1 (KotOR/KotOR2). More...
 
void writeNWN (Common::WriteStream &out, size_t soundFileLen) const
 Write this SSF data into a stream as one of the versions for NWN. More...
 

Private Attributes

SoundSet _sounds
 

Additional Inherited Members

- Static Public Member Functions inherited from Aurora::AuroraFile
static void readHeader (Common::ReadStream &stream, uint32 &id, uint32 &version, bool &utf16le)
 Read the header out of a stream. More...
 
static void readHeader (Common::ReadStream &stream, uint32 &id, uint32 &version)
 Read the ID and version out of a stream. More...
 
static uint32 readHeaderID (Common::ReadStream &stream)
 Read the ID out of a stream. More...
 
- Protected Member Functions inherited from Aurora::AuroraFile
void readHeader (Common::ReadStream &stream)
 
- Static Protected Member Functions inherited from Aurora::AuroraFile
static uint32 convertUTF16LE (uint32 x1, uint32 x2)
 
- Protected Attributes inherited from Aurora::AuroraFile
uint32 _id
 The file's ID. More...
 
uint32 _version
 The file's version. More...
 
bool _utf16le
 The file's ID and version are in little-endian UTF-16. More...
 

Detailed Description

Class to hold a sound set.

A sound set contains a simple array of strings and sound resource names for common creature sounds, like fighting noises, being hurt, calling for medical help, etc.

Which index is used for which situation differs from game to game.

SSF files are used in these four games: Neverwinter Nights, Neverwinter Nights 2, Knights of the Old Republic and Knights of the Old Republic II.

Definition at line 55 of file ssffile.h.

Member Typedef Documentation

◆ SoundSet

typedef std::vector<Sound> Aurora::SSFFile::SoundSet
private

Definition at line 109 of file ssffile.h.

Member Enumeration Documentation

◆ Version

The different versions of SSF files that exists.

Enumerator
kVersion10_NWN 

SSF V1.0, as found in NWN and NWN2.

kVersion11_NWN2 

SSF V1.1, as found in NWN2.

kVersion11_KotOR 

SSF V1.1, as found in KotOR and KotOR.

Definition at line 58 of file ssffile.h.

Constructor & Destructor Documentation

◆ SSFFile() [1/3]

Aurora::SSFFile::SSFFile ( )

Definition at line 51 of file ssffile.cpp.

◆ SSFFile() [2/3]

Aurora::SSFFile::SSFFile ( Common::SeekableReadStream ssf)

Definition at line 54 of file ssffile.cpp.

References load().

Here is the call graph for this function:

◆ SSFFile() [3/3]

Aurora::SSFFile::SSFFile ( const Common::UString ssf)

Definition at line 58 of file ssffile.cpp.

References Common::UString::c_str(), Aurora::kFileTypeSSF, load(), and ResMan.

Here is the call graph for this function:

◆ ~SSFFile()

Aurora::SSFFile::~SSFFile ( )

Definition at line 66 of file ssffile.cpp.

Member Function Documentation

◆ checkVersionFeatures()

void Aurora::SSFFile::checkVersionFeatures ( Version  version) const
private

Make sure this SSF files fits the requirements for specified SSF version.

Definition at line 249 of file ssffile.cpp.

References _sounds, existNonASCIISoundFile(), getMaxSoundFileLen(), kVersion10_NWN, kVersion11_KotOR, kVersion11_NWN2, and UINT32_MAX.

Referenced by writeSSF().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ determineVersionForGame()

SSFFile::Version Aurora::SSFFile::determineVersionForGame ( GameID  game) const

Determine the best version to save this SSF file in, for the specified game.

Definition at line 278 of file ssffile.cpp.

References getMaxSoundFileLen(), Aurora::kGameIDKotOR, Aurora::kGameIDKotOR2, Aurora::kGameIDNWN, Aurora::kGameIDNWN2, kVersion10_NWN, kVersion11_KotOR, and kVersion11_NWN2.

Here is the call graph for this function:

◆ existNonASCIISoundFile()

bool Aurora::SSFFile::existNonASCIISoundFile ( ) const
private

Is there a sound filename with non-ASCII characters?

Definition at line 240 of file ssffile.cpp.

References _sounds, and Common::UString::isASCII().

Referenced by checkVersionFeatures().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getMaxSoundFileLen()

size_t Aurora::SSFFile::getMaxSoundFileLen ( ) const
private

Return the maximum length of a sound filename in characters.

Definition at line 232 of file ssffile.cpp.

References _sounds, and MAX().

Referenced by checkVersionFeatures(), and determineVersionForGame().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSound()

void Aurora::SSFFile::getSound ( size_t  index,
Common::UString soundFile,
uint32 strRef 
) const

Return both the sound file and the string reference for this sound.

Definition at line 189 of file ssffile.cpp.

References _sounds, Common::UString::clear(), and Aurora::kStrRefInvalid.

Here is the call graph for this function:

◆ getSoundCount()

size_t Aurora::SSFFile::getSoundCount ( ) const

Return the number of sounds in this SSF file.

Definition at line 169 of file ssffile.cpp.

References _sounds.

◆ getSoundFile()

const Common::UString & Aurora::SSFFile::getSoundFile ( size_t  index) const

Return the sound file to play for this sound.

Definition at line 173 of file ssffile.cpp.

References _sounds, and Aurora::kEmptyString.

Referenced by Engines::NWN::Dialog::playSound(), Engines::NWN2::Functions::playVoiceChat(), and Engines::NWN::Functions::playVoiceChat().

Here is the caller graph for this function:

◆ getStrRef()

uint32 Aurora::SSFFile::getStrRef ( size_t  index) const

Return the string reference of the text to display for this sound.

Definition at line 182 of file ssffile.cpp.

References _sounds, and Aurora::kStrRefInvalid.

◆ load()

void Aurora::SSFFile::load ( Common::SeekableReadStream ssf)
private

Definition at line 69 of file ssffile.cpp.

References _sounds, Common::StackException::add(), readEntries(), and readSSFHeader().

Referenced by SSFFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readEntries()

void Aurora::SSFFile::readEntries ( Common::SeekableReadStream ssf,
Version  version,
size_t  offset 
)
private

Read the data entries, depending on the version.

Definition at line 119 of file ssffile.cpp.

References kVersion10_NWN, kVersion11_KotOR, kVersion11_NWN2, readEntriesKotOR(), readEntriesNWN(), and Common::SeekableReadStream::seek().

Referenced by load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readEntriesKotOR()

void Aurora::SSFFile::readEntriesKotOR ( Common::SeekableReadStream ssf)
private

Read the data entries of the KotOR version.

Definition at line 162 of file ssffile.cpp.

References _sounds, and Common::ReadStream::readUint32LE().

Referenced by readEntries().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readEntriesNWN()

void Aurora::SSFFile::readEntriesNWN ( Common::SeekableReadStream ssf,
size_t  soundFileLen 
)
private

Read the data entries of the NWN versions.

Definition at line 140 of file ssffile.cpp.

References _sounds, Common::kEncodingASCII, Common::readStringFixed(), Common::ReadStream::readUint32LE(), and Common::SeekableReadStream::seek().

Referenced by readEntries().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readSSFHeader()

SSFFile::Version Aurora::SSFFile::readSSFHeader ( Common::SeekableReadStream ssf,
size_t &  entryCount,
size_t &  offEntryTable 
)
private

Read the header of an SSF file and determine the version.

Definition at line 84 of file ssffile.cpp.

References Aurora::AuroraFile::_id, Aurora::AuroraFile::_version, Common::debugTag(), kSSFID, Aurora::kVersion10, kVersion10_NWN, kVersion11, kVersion11_KotOR, kVersion11_NWN2, Aurora::AuroraFile::readHeader(), Common::ReadStream::readUint32LE(), Common::SeekableReadStream::size(), and UINT32_MAX.

Referenced by load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setSound()

void Aurora::SSFFile::setSound ( size_t  index,
const Common::UString soundFile,
uint32  strRef 
)

Set both the sound file and the string reference for this sound.

Definition at line 221 of file ssffile.cpp.

References _sounds, and UINT32_MAX.

◆ setSoundFile()

void Aurora::SSFFile::setSoundFile ( size_t  index,
const Common::UString soundFile 
)

Set the sound file to play for this sound.

Definition at line 201 of file ssffile.cpp.

References _sounds, and UINT32_MAX.

◆ setStrRef()

void Aurora::SSFFile::setStrRef ( size_t  index,
uint32  strRef 
)

Set the string reference of the text to display for this sound.

Definition at line 211 of file ssffile.cpp.

References _sounds, and UINT32_MAX.

◆ writeKotOR()

void Aurora::SSFFile::writeKotOR ( Common::WriteStream out) const
private

Write this SSF into a stream as a V1.1 (KotOR/KotOR2).

Definition at line 368 of file ssffile.cpp.

References _sounds, Common::WriteStream::writeString(), and Common::WriteStream::writeUint32LE().

Referenced by writeSSF().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeNWN() [1/2]

void Aurora::SSFFile::writeNWN ( Common::WriteStream out) const
private

Write this SSF into a stream as a V1.0 (NWN).

Definition at line 356 of file ssffile.cpp.

References Common::WriteStream::writeString().

Referenced by writeNWN2(), and writeSSF().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeNWN() [2/2]

void Aurora::SSFFile::writeNWN ( Common::WriteStream out,
size_t  soundFileLen 
) const
private

Write this SSF data into a stream as one of the versions for NWN.

Definition at line 328 of file ssffile.cpp.

References _sounds, Common::kEncodingASCII, Common::kSeekError, UINT32_MAX, Common::WriteStream::writeByte(), Common::writeStringFixed(), and Common::WriteStream::writeUint32LE().

Here is the call graph for this function:

◆ writeNWN2()

void Aurora::SSFFile::writeNWN2 ( Common::WriteStream out) const
private

Write this SSF into a stream as a V1.1 (NWN2).

Definition at line 362 of file ssffile.cpp.

References writeNWN(), and Common::WriteStream::writeString().

Referenced by writeSSF().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeSSF() [1/2]

void Aurora::SSFFile::writeSSF ( Common::WriteStream out,
Version  version 
) const

Write the SSF into a stream, as the specified version.

Definition at line 299 of file ssffile.cpp.

References checkVersionFeatures(), kVersion10_NWN, kVersion11_KotOR, kVersion11_NWN2, writeKotOR(), writeNWN(), and writeNWN2().

Referenced by writeSSF().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeSSF() [2/2]

bool Aurora::SSFFile::writeSSF ( const Common::UString fileName,
Version  version 
) const

Write the SSF into a file, as the specified version.

Definition at line 317 of file ssffile.cpp.

References Common::WriteFile::close(), Common::WriteFile::open(), and writeSSF().

Here is the call graph for this function:

Member Data Documentation

◆ _sounds

SoundSet Aurora::SSFFile::_sounds
private

The documentation for this class was generated from the following files: