Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzCore includes
Toshihiro Shimizu 890ddd
#include "tconvert.h"
Toshihiro Shimizu 890ddd
#include "tstream.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzLib includes
Toshihiro Shimizu 890ddd
#include "toonz/txshsimplelevel.h"
Toshihiro Shimizu 890ddd
#include "toonz/toonzscene.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "toonz/levelset.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
namespace {
Toshihiro Shimizu 890ddd
const TFilePath defaultRootFolder("Cast");
Toshihiro Shimizu 890ddd
const TFilePath defaultSoundRootFolder("Audio");
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// TLevelSet
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TLevelSet::TLevelSet() : m_defaultFolder(defaultRootFolder) {
Shinya Kitaoka 120a6e
  m_folders.push_back(defaultRootFolder);
Shinya Kitaoka 120a6e
  m_folders.push_back(defaultSoundRootFolder);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TLevelSet::~TLevelSet() { clear(); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TLevelSet::clear() {
Shinya Kitaoka 120a6e
  for (std::vector<txshlevel *="">::iterator it = m_levels.begin();</txshlevel>
Shinya Kitaoka 120a6e
       it != m_levels.end(); ++it) {
Shinya Kitaoka 120a6e
    TXshLevel *level = *it;
Shinya Kitaoka 120a6e
    if (level->getSimpleLevel()) level->getSimpleLevel()->clearFrames();
Shinya Kitaoka 120a6e
    (*it)->release();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  m_levelTable.clear();
Shinya Kitaoka 120a6e
  m_levels.clear();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_folderTable.clear();
Shinya Kitaoka 120a6e
  m_folders.clear();
Shinya Kitaoka 120a6e
  m_folders.push_back(defaultRootFolder);
Shinya Kitaoka 120a6e
  m_folders.push_back(defaultSoundRootFolder);
Shinya Kitaoka 120a6e
  m_defaultFolder = defaultRootFolder;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TLevelSet::removeLevel(TXshLevel *level, bool deleteIt) {
Shinya Kitaoka 120a6e
  // if(level->getSimpleLevel())
Shinya Kitaoka 120a6e
  //  level->getSimpleLevel()->clearFrames();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_levels.erase(std::remove(m_levels.begin(), m_levels.end(), level),
Shinya Kitaoka 120a6e
                 m_levels.end());
Shinya Kitaoka 120a6e
  m_levelTable.erase(level->getName());
Shinya Kitaoka 120a6e
  if (deleteIt) level->release();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_folderTable.erase(level);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
bool TLevelSet::renameLevel(TXshLevel *level, const std::wstring &newName) {
Shinya Kitaoka 120a6e
  if (level->getName() == newName) return true;
Shinya Kitaoka 120a6e
  if (m_levelTable.count(newName) > 0) return false;
Shinya Kitaoka 120a6e
  m_levelTable.erase(level->getName());
Shinya Kitaoka 120a6e
  level->setName(newName);
Shinya Kitaoka 120a6e
  m_levelTable[newName] = level;
Shinya Kitaoka 120a6e
  return true;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
int TLevelSet::getLevelCount() const { return m_levels.size(); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TXshLevel *TLevelSet::getLevel(int index) const {
Shinya Kitaoka 120a6e
  assert(0 <= index && index < getLevelCount());
Shinya Kitaoka 120a6e
  return m_levels[index];
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TXshLevel *TLevelSet::getLevel(const std::wstring &levelName) const {
Shinya Kitaoka 120a6e
  std::map<std::wstring, *="" txshlevel="">::const_iterator it;</std::wstring,>
Shinya Kitaoka 120a6e
  it = m_levelTable.find(levelName);
Shinya Kitaoka 120a6e
  if (it == m_levelTable.end())
Shinya Kitaoka 120a6e
    return 0;
Shinya Kitaoka 120a6e
  else
Shinya Kitaoka 120a6e
    return it->second;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TXshLevel *TLevelSet::getLevel(const ToonzScene &scene,
Shinya Kitaoka 120a6e
                               const TFilePath &levelPath) const {
Shinya Kitaoka 120a6e
  const TFilePath &decodedPath = scene.decodeFilePath(levelPath);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int l, lCount = getLevelCount();
Shinya Kitaoka 120a6e
  for (l = 0; l != lCount; ++l) {
Shinya Kitaoka 120a6e
    TXshLevel *level = getLevel(l);
Shinya Kitaoka 120a6e
    if (decodedPath == scene.decodeFilePath(level->getPath())) return level;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  return 0;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
bool TLevelSet::hasLevel(const std::wstring &levelName) const {
Shinya Kitaoka 120a6e
  std::vector<txshlevel *="">::const_iterator it = m_levels.begin();</txshlevel>
Shinya Kitaoka 120a6e
  for (auto const level : m_levels) {
Shinya Kitaoka 120a6e
    if (levelName == level->getName()) return true;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  return false;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
bool TLevelSet::hasLevel(const ToonzScene &scene,
Shinya Kitaoka 120a6e
                         const TFilePath &levelPath) const {
Shinya Kitaoka 120a6e
  return getLevel(scene, levelPath);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TLevelSet::listLevels(std::vector<txshlevel *=""> &levels) const {</txshlevel>
Shinya Kitaoka 120a6e
  levels = m_levels;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
bool TLevelSet::insertLevel(TXshLevel *xl) {
Shinya Kitaoka 120a6e
  std::map<std::wstring, *="" txshlevel="">::const_iterator it;</std::wstring,>
Shinya Kitaoka 120a6e
  it = m_levelTable.find(xl->getName());
Shinya Kitaoka 120a6e
  if (it != m_levelTable.end() && it->second == xl)
Shinya Kitaoka 120a6e
    return it->second == xl;
Shinya Kitaoka 120a6e
  else {
Shinya Kitaoka 120a6e
    xl->addRef();
Shinya Kitaoka 120a6e
    m_levelTable[xl->getName()] = xl;
Shinya Kitaoka 120a6e
    m_levels.push_back(xl);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    TFilePath folder =
Shinya Kitaoka 120a6e
        (xl->getSoundLevel()) ? defaultSoundRootFolder : m_defaultFolder;
Shinya Kitaoka 120a6e
    m_folderTable[xl] = folder;
Shinya Kitaoka 120a6e
    assert(std::find(m_folders.begin(), m_folders.end(), folder) !=
Shinya Kitaoka 120a6e
           m_folders.end());
Shinya Kitaoka 120a6e
    return true;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TLevelSet::setDefaultFolder(TFilePath folder) {
Shinya Kitaoka 120a6e
  assert(std::find(m_folders.begin(), m_folders.end(), folder) !=
Shinya Kitaoka 120a6e
         m_folders.end());
Shinya Kitaoka 120a6e
  m_defaultFolder = folder;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TFilePath TLevelSet::getFolder(TXshLevel *xl) const {
Shinya Kitaoka 120a6e
  std::map<txshlevel *,="" tfilepath="">::const_iterator it;</txshlevel>
Shinya Kitaoka 120a6e
  it = m_folderTable.find(xl);
Shinya Kitaoka 120a6e
  assert(it != m_folderTable.end());
Shinya Kitaoka 120a6e
  return it->second;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TFilePath TLevelSet::renameFolder(const TFilePath &folder,
Shinya Kitaoka 120a6e
                                  const std::wstring &newName) {
Shinya Kitaoka 120a6e
  // Impedisco la creazione di folder con nome "" che creano problemi
Shinya Kitaoka 120a6e
  // (praticamente Ecome se avessero infinite sottocartelle)
Shinya Kitaoka 120a6e
  if (newName == L"") return folder;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TFilePath folder2 = folder.withName(newName);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  for (int i = 0; i < (int)m_folders.size(); i++) {
Shinya Kitaoka 120a6e
    if (folder == m_folders[i])
Shinya Kitaoka 120a6e
      m_folders[i] = folder2;
Shinya Kitaoka 120a6e
    else if (folder.isAncestorOf(m_folders[i]))
Shinya Kitaoka 120a6e
      m_folders[i] = folder2 + (m_folders[i] - folder);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  if (m_defaultFolder == folder) m_defaultFolder = folder2;
Shinya Kitaoka 120a6e
  std::map<txshlevel *,="" tfilepath="">::iterator it;</txshlevel>
Shinya Kitaoka 120a6e
  for (it = m_folderTable.begin(); it != m_folderTable.end(); ++it) {
Shinya Kitaoka 120a6e
    if (folder == it->second)
Shinya Kitaoka 120a6e
      it->second = folder2;
Shinya Kitaoka 120a6e
    else if (folder.isAncestorOf(it->second))
Shinya Kitaoka 120a6e
      it->second = folder2 + (it->second - folder);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  return folder2;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TFilePath TLevelSet::createFolder(const TFilePath &parentFolder,
Shinya Kitaoka 120a6e
                                  const std::wstring &newName) {
Shinya Kitaoka 120a6e
  TFilePath child = parentFolder + newName;
Shinya Kitaoka 120a6e
  if (std::find(m_folders.begin(), m_folders.end(), child) == m_folders.end())
Shinya Kitaoka 120a6e
    m_folders.push_back(child);
Shinya Kitaoka 120a6e
  return child;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TLevelSet::removeFolder(const TFilePath &folder) {
Shinya Kitaoka 120a6e
  if (folder == m_defaultFolder) return;
Shinya Kitaoka 120a6e
  std::vector<tfilepath> folders;</tfilepath>
Shinya Kitaoka 120a6e
  for (int i = 0; i < (int)m_folders.size(); i++)
Shinya Kitaoka 120a6e
    if (!folder.isAncestorOf(m_folders[i])) folders.push_back(m_folders[i]);
Shinya Kitaoka 120a6e
  folders.swap(m_folders);
Shinya Kitaoka 120a6e
  std::map<txshlevel *,="" tfilepath="">::iterator it;</txshlevel>
Shinya Kitaoka 120a6e
  for (it = m_folderTable.begin(); it != m_folderTable.end(); ++it) {
Shinya Kitaoka 120a6e
    if (folder.isAncestorOf(it->second)) it->second = m_defaultFolder;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TLevelSet::listLevels(std::vector<txshlevel *=""> &levels,</txshlevel>
Shinya Kitaoka 120a6e
                           const TFilePath &folder) const {
Shinya Kitaoka 120a6e
  std::map<txshlevel *,="" tfilepath="">::const_iterator it;</txshlevel>
Shinya Kitaoka 120a6e
  for (it = m_folderTable.begin(); it != m_folderTable.end(); ++it)
Shinya Kitaoka 120a6e
    if (folder == it->second) levels.push_back(it->first);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TLevelSet::listFolders(std::vector<tfilepath> &folders,</tfilepath>
Shinya Kitaoka 120a6e
                            const TFilePath &folder) const {
Shinya Kitaoka 120a6e
  for (int i = 0; i < (int)m_folders.size(); i++)
Shinya Kitaoka 120a6e
    if (m_folders[i].getParentDir() == folder) folders.push_back(m_folders[i]);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TLevelSet::moveLevelToFolder(const TFilePath &fp, TXshLevel *level) {
Shinya Kitaoka 120a6e
  TFilePath folder(fp);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (folder == TFilePath()) folder = m_defaultFolder;
Shinya Kitaoka 120a6e
  if (std::find(m_folders.begin(), m_folders.end(), folder) ==
Shinya Kitaoka 120a6e
      m_folders.end()) {
Shinya Kitaoka 120a6e
    assert(0);
Shinya Kitaoka 120a6e
    return;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  std::map<txshlevel *,="" tfilepath="">::iterator it;</txshlevel>
Shinya Kitaoka 120a6e
  it = m_folderTable.find(level);
Shinya Kitaoka 120a6e
  assert(it != m_folderTable.end());
Shinya Kitaoka 120a6e
  if (it == m_folderTable.end()) return;
Shinya Kitaoka 120a6e
  it->second = folder;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TLevelSet::saveFolder(TOStream &os, TFilePath folder) {
Shinya Kitaoka 120a6e
  std::map<std::string, std::string=""> attr;</std::string,>
Shinya Kitaoka 120a6e
  attr["name"]                                   = folder.getName();
Shinya Kitaoka 120a6e
  if (folder == getDefaultFolder()) attr["type"] = "default";
Shinya Kitaoka 120a6e
  os.openChild("folder", attr);
Shinya Kitaoka 120a6e
  std::vector<tfilepath> folders;</tfilepath>
Shinya Kitaoka 120a6e
  listFolders(folders, folder);
Shinya Kitaoka 120a6e
  if (!folders.empty()) {
Shinya Kitaoka 120a6e
    for (int i = 0; i < (int)folders.size(); i++) saveFolder(os, folders[i]);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  std::vector<txshlevel *=""> levels;</txshlevel>
Shinya Kitaoka 120a6e
  listLevels(levels, folder);
Shinya Kitaoka 120a6e
  if (!levels.empty()) {
Shinya Kitaoka 120a6e
    os.openChild("levels");
Shinya Kitaoka 120a6e
    for (int i = 0; i < (int)levels.size(); i++)
Shinya Kitaoka 120a6e
      if (m_saveSet.empty() || m_saveSet.count(levels[i]) > 0) os << levels[i];
Shinya Kitaoka 120a6e
    os.closeChild();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  os.closeChild();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TLevelSet::loadFolder(TIStream &is, TFilePath folder) {
Shinya Kitaoka 120a6e
  std::string s;
Shinya Kitaoka 120a6e
  is.getTagParam("type", s);
Shinya Kitaoka 120a6e
  if (s == "default") setDefaultFolder(folder);
Shinya Kitaoka 120a6e
  while (!is.eos()) {
Shinya Kitaoka 120a6e
    std::string tagName;
Shinya Kitaoka 120a6e
    is.matchTag(tagName);
Shinya Kitaoka 120a6e
    if (tagName == "levels") {
Shinya Kitaoka 120a6e
      while (!is.eos()) {
Shinya Kitaoka 120a6e
        TPersist *p = 0;
Shinya Kitaoka 120a6e
        is >> p;
Shinya Kitaoka 120a6e
        TXshLevel *xshLevel = dynamic_cast<txshlevel *="">(p);</txshlevel>
Shinya Kitaoka 120a6e
        if (xshLevel && !xshLevel->getChildLevel())
Shinya Kitaoka 120a6e
          moveLevelToFolder(folder, xshLevel);
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
    } else if (tagName == "folder") {
Shinya Kitaoka 120a6e
      is.getTagParam("name", s);
Shinya Kitaoka 120a6e
      TFilePath child = createFolder(folder, ::to_wstring(s));
Shinya Kitaoka 120a6e
      loadFolder(is, child);
Shinya Kitaoka 120a6e
    } else
Shinya Kitaoka 120a6e
      throw TException("expected <levels> or <folder>");</folder></levels>
Shinya Kitaoka 120a6e
    is.closeChild();
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TLevelSet::loadData(TIStream &is) {
Shinya Kitaoka 120a6e
  int folderCount = 1;
Shinya Kitaoka 120a6e
  while (!is.eos()) {
Shinya Kitaoka 120a6e
    std::string tagName;
Shinya Kitaoka 120a6e
    if (is.matchTag(tagName)) {
Shinya Kitaoka 120a6e
      if (tagName == "levels") {
Shinya Kitaoka 120a6e
        while (!is.eos()) {
Shinya Kitaoka 120a6e
          TPersist *p = 0;
Shinya Kitaoka 120a6e
          is >> p;
Shinya Kitaoka 120a6e
          TXshLevel *xshLevel = dynamic_cast<txshlevel *="">(p);</txshlevel>
Shinya Kitaoka 120a6e
          if (xshLevel) {
Shinya Kitaoka 120a6e
            insertLevel(xshLevel);
Shinya Kitaoka 120a6e
          }
Shinya Kitaoka 120a6e
        }
Shinya Kitaoka 120a6e
      } else if (tagName == "folder") {
Shinya Kitaoka 120a6e
        std::string name = ::to_string(defaultRootFolder.getWideString());
Shinya Kitaoka 120a6e
        is.getTagParam("name", name);
Shinya Kitaoka 120a6e
        TFilePath folder(name);
Shinya Kitaoka 120a6e
        if (folderCount == 1)
Shinya Kitaoka 120a6e
          m_defaultFolder = m_folders[0] = folder;
Shinya Kitaoka 120a6e
        else if (name != defaultSoundRootFolder.getName())
Shinya Kitaoka 120a6e
          m_folders.push_back(folder);
Shinya Kitaoka 120a6e
        folderCount++;
Shinya Kitaoka 120a6e
        loadFolder(is, folder);
Shinya Kitaoka 120a6e
      } else
Shinya Kitaoka 120a6e
        throw TException("expected <levels> or <folder>");</folder></levels>
Shinya Kitaoka 120a6e
      is.closeChild();
Shinya Kitaoka 120a6e
    } else
Shinya Kitaoka 120a6e
      throw TException("expected tag");
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TLevelSet::saveData(TOStream &os) {
Shinya Kitaoka 120a6e
  os.openChild("levels");
Shinya Kitaoka 120a6e
  int i;
Shinya Kitaoka 120a6e
  for (i = 0; i < getLevelCount(); i++) {
Shinya Kitaoka 120a6e
    TXshLevel *level = getLevel(i);
Shinya Kitaoka 120a6e
    if (m_saveSet.empty() || m_saveSet.count(level) > 0) os << level;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  os.closeChild();
Shinya Kitaoka 120a6e
  std::vector<tfilepath> folders;</tfilepath>
Shinya Kitaoka 120a6e
  listFolders(folders, TFilePath());
Shinya Kitaoka 120a6e
  assert(!folders.empty());
Shinya Kitaoka 120a6e
  for (i = 0; i < (int)folders.size(); i++) saveFolder(os, folders[i]);
Toshihiro Shimizu 890ddd
}