Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "toonz/txshsoundtextlevel.h"
Toshihiro Shimizu 890ddd
#include "toonz/txshleveltypes.h"
Toshihiro Shimizu 890ddd
#include "tstream.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
DEFINE_CLASS_CODE(TXshSoundTextLevel, 54)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
PERSIST_IDENTIFIER(TXshSoundTextLevel, "soundTextLevel")
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TXshSoundTextLevel::TXshSoundTextLevel(wstring name)
Toshihiro Shimizu 890ddd
	: TXshLevel(m_classCode, name), m_framesText()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TXshSoundTextLevel::~TXshSoundTextLevel()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TXshSoundTextLevel *TXshSoundTextLevel::clone() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TXshSoundTextLevel *sound = new TXshSoundTextLevel(m_name);
Toshihiro Shimizu 890ddd
	return sound;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TXshSoundTextLevel::setFrameText(int frameIndex, QString text)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	while (frameIndex >= m_framesText.size())
Toshihiro Shimizu 890ddd
		m_framesText.append(QString());
Toshihiro Shimizu 890ddd
	m_framesText.replace(frameIndex, text);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
QString TXshSoundTextLevel::getFrameText(int frameIndex) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (frameIndex >= m_framesText.size())
Toshihiro Shimizu 890ddd
		return QString();
Toshihiro Shimizu 890ddd
	return m_framesText[frameIndex];
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TXshSoundTextLevel::loadData(TIStream &is)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	is >> m_name;
Toshihiro Shimizu 890ddd
	setName(m_name);
Toshihiro Shimizu 890ddd
	string tagName;
Toshihiro Shimizu 890ddd
	int type = UNKNOWN_XSHLEVEL;
Toshihiro Shimizu 890ddd
	while (is.matchTag(tagName)) {
Toshihiro Shimizu 890ddd
		if (tagName == "type") {
Toshihiro Shimizu 890ddd
			string v;
Toshihiro Shimizu 890ddd
			is >> v;
Toshihiro Shimizu 890ddd
			if (v == "textSound")
Toshihiro Shimizu 890ddd
				type = SND_TXT_XSHLEVEL;
Toshihiro Shimizu 890ddd
			is.matchEndTag();
Toshihiro Shimizu 890ddd
		} else if (tagName == "frame") {
Toshihiro Shimizu 890ddd
			QString text;
Toshihiro Shimizu 890ddd
			is >> text;
Toshihiro Shimizu 890ddd
			m_framesText.push_back(text);
Toshihiro Shimizu 890ddd
			is.matchEndTag();
Toshihiro Shimizu 890ddd
		} else
Toshihiro Shimizu 890ddd
			throw TException("unexpected tag " + tagName);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	setType(type);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TXshSoundTextLevel::saveData(TOStream &os)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	os << m_name;
Toshihiro Shimizu 890ddd
	int i;
Toshihiro Shimizu 890ddd
	for (i = 0; i < m_framesText.size(); i++) {
Toshihiro Shimizu 890ddd
		os.openChild("frame");
Toshihiro Shimizu 890ddd
		os << m_framesText[i];
Toshihiro Shimizu 890ddd
		os.closeChild();
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	os.child("type") << L"textSound";
Toshihiro Shimizu 890ddd
}