xoreos
0.0.5
|
Class to hold a sound set. More...
#include <ssffile.h>
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::UString & | getSoundFile (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< Sound > | SoundSet |
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... | |
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.
|
private |
Aurora::SSFFile::SSFFile | ( | ) |
Definition at line 51 of file ssffile.cpp.
Aurora::SSFFile::SSFFile | ( | Common::SeekableReadStream & | ssf | ) |
Definition at line 54 of file ssffile.cpp.
References load().
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.
Aurora::SSFFile::~SSFFile | ( | ) |
Definition at line 66 of file ssffile.cpp.
|
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().
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.
|
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().
|
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().
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.
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.
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().
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.
|
private |
Definition at line 69 of file ssffile.cpp.
References _sounds, Common::StackException::add(), readEntries(), and readSSFHeader().
Referenced by SSFFile().
|
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().
|
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().
|
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().
|
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().
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.
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.
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.
|
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().
|
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().
|
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().
|
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().
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().
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().
|
private |
Definition at line 111 of file ssffile.h.
Referenced by checkVersionFeatures(), existNonASCIISoundFile(), getMaxSoundFileLen(), getSound(), getSoundCount(), getSoundFile(), getStrRef(), load(), readEntriesKotOR(), readEntriesNWN(), setSound(), setSoundFile(), setStrRef(), writeKotOR(), and writeNWN().