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
Shinya Kitaoka 3bfa54
TXshSoundTextLevel::TXshSoundTextLevel(std::wstring name)
Shinya Kitaoka 120a6e
    : TXshLevel(m_classCode, name), m_framesText() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TXshSoundTextLevel::~TXshSoundTextLevel() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TXshSoundTextLevel *TXshSoundTextLevel::clone() const {
Shinya Kitaoka 120a6e
  TXshSoundTextLevel *sound = new TXshSoundTextLevel(m_name);
Shinya Kitaoka 120a6e
  return sound;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TXshSoundTextLevel::setFrameText(int frameIndex, QString text) {
Jeremy Bullock 52a220
  while (frameIndex >= m_framesText.size()) {
Jeremy Bullock 52a220
    m_framesText.append(QString(" "));
Jeremy Bullock 52a220
  }
Shinya Kitaoka 120a6e
  m_framesText.replace(frameIndex, text);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
QString TXshSoundTextLevel::getFrameText(int frameIndex) const {
Shinya Kitaoka 120a6e
  if (frameIndex >= m_framesText.size()) return QString();
Shinya Kitaoka 120a6e
  return m_framesText[frameIndex];
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TXshSoundTextLevel::loadData(TIStream &is) {
Shinya Kitaoka 120a6e
  is >> m_name;
Shinya Kitaoka 120a6e
  setName(m_name);
Shinya Kitaoka 120a6e
  std::string tagName;
Shinya Kitaoka 120a6e
  int type = UNKNOWN_XSHLEVEL;
Shinya Kitaoka 120a6e
  while (is.matchTag(tagName)) {
Shinya Kitaoka 120a6e
    if (tagName == "type") {
Shinya Kitaoka 120a6e
      std::string v;
Shinya Kitaoka 120a6e
      is >> v;
Shinya Kitaoka 120a6e
      if (v == "textSound") type = SND_TXT_XSHLEVEL;
Shinya Kitaoka 120a6e
      is.matchEndTag();
Shinya Kitaoka 120a6e
    } else if (tagName == "frame") {
shun_iwasawa 53cbe2
      std::wstring text;
Shinya Kitaoka 120a6e
      is >> text;
shun_iwasawa 53cbe2
      m_framesText.push_back(QString::fromStdWString(text));
Shinya Kitaoka 120a6e
      is.matchEndTag();
Shinya Kitaoka 120a6e
    } else
Shinya Kitaoka 120a6e
      throw TException("unexpected tag " + tagName);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  setType(type);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TXshSoundTextLevel::saveData(TOStream &os) {
Shinya Kitaoka 120a6e
  os << m_name;
Shinya Kitaoka 120a6e
  int i;
Shinya Kitaoka 120a6e
  for (i = 0; i < m_framesText.size(); i++) {
Shinya Kitaoka 120a6e
    os.openChild("frame");
Shinya Kitaoka 120a6e
    os << m_framesText[i];
Shinya Kitaoka 120a6e
    os.closeChild();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  os.child("type") << L"textSound";
Toshihiro Shimizu 890ddd
}