|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshpalettelevel.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshleveltypes.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/toonzscene.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tconvert.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tstream.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfilepath_io.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tsystem.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
DEFINE_CLASS_CODE(TXshPaletteLevel, 52)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
PERSIST_IDENTIFIER(TXshPaletteLevel, "paletteLevel")
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
// TXshPaletteLevel
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TXshPaletteLevel::TXshPaletteLevel(wstring name)
|
|
Toshihiro Shimizu |
890ddd |
: TXshLevel(m_classCode, name), m_palette(0)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_type = PLT_XSHLEVEL;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TXshPaletteLevel::~TXshPaletteLevel()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPalette *TXshPaletteLevel::getPalette() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_palette;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TXshPaletteLevel::setPalette(TPalette *palette)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_palette != palette) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_palette)
|
|
Toshihiro Shimizu |
890ddd |
m_palette->release();
|
|
Toshihiro Shimizu |
890ddd |
m_palette = palette;
|
|
Toshihiro Shimizu |
890ddd |
if (m_palette)
|
|
Toshihiro Shimizu |
890ddd |
m_palette->addRef();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TXshPaletteLevel::setPath(const TFilePath &path)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_path = path;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TXshPaletteLevel::loadData(TIStream &is)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
string tagName;
|
|
Toshihiro Shimizu |
890ddd |
while (is.matchTag(tagName)) {
|
|
Toshihiro Shimizu |
890ddd |
if (tagName == "name") {
|
|
Toshihiro Shimizu |
890ddd |
wstring name;
|
|
Toshihiro Shimizu |
890ddd |
is >> name;
|
|
Toshihiro Shimizu |
890ddd |
setName(name);
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "path") {
|
|
Toshihiro Shimizu |
890ddd |
is >> m_path;
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
throw TException("TXshPaletteLevel, unknown tag: " + tagName);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
is.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TXshPaletteLevel::saveData(TOStream &os)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
os.child("path") << m_path;
|
|
Toshihiro Shimizu |
890ddd |
os.child("name") << getName();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TXshPaletteLevel::load()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFilePath path = getScene()->decodeFilePath(m_path);
|
|
Toshihiro Shimizu |
890ddd |
if (TSystem::doesExistFileOrLevel(path)) {
|
|
Toshihiro Shimizu |
890ddd |
TFileStatus fs(path);
|
|
Toshihiro Shimizu |
890ddd |
TPersist *p = 0;
|
|
Toshihiro Shimizu |
890ddd |
TIStream is(path);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (is && fs.doesExist()) {
|
|
Toshihiro Shimizu |
890ddd |
is >> p;
|
|
Toshihiro Shimizu |
890ddd |
TPalette *palette = dynamic_cast<tpalette *="">(p);</tpalette>
|
|
Toshihiro Shimizu |
890ddd |
palette->setPaletteName(path.getWideName());
|
|
Toshihiro Shimizu |
890ddd |
setPalette(palette);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
assert(m_palette);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TXshPaletteLevel::save()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFilePath path = getScene()->decodeFilePath(m_path);
|
|
Toshihiro Shimizu |
890ddd |
if (TSystem::doesExistFileOrLevel(path) && m_palette) {
|
|
Toshihiro Shimizu |
890ddd |
TOStream os(path);
|
|
Toshihiro Shimizu |
890ddd |
os << m_palette;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int TXshPaletteLevel::getFrameCount() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|