|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/fullcolorpalette.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tscenehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/toonzscene.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tsystem.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tstream.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tpalette.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//FullColorPalette
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//==================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FullColorPalette::FullColorPalette()
|
|
Toshihiro Shimizu |
890ddd |
: m_fullcolorPalettePath("+palettes\\Raster_Drawing_Palette.tpl"), m_palette(0)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FullColorPalette *FullColorPalette::instance()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
static FullColorPalette _instance;
|
|
Toshihiro Shimizu |
890ddd |
return &_instance;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FullColorPalette::~FullColorPalette()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
clear();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FullColorPalette::clear()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_palette)
|
|
Toshihiro Shimizu |
890ddd |
m_palette->release();
|
|
Toshihiro Shimizu |
890ddd |
m_palette = 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPalette *FullColorPalette::getPalette(ToonzScene *scene)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_palette)
|
|
Toshihiro Shimizu |
890ddd |
return m_palette;
|
|
Toshihiro Shimizu |
890ddd |
m_palette = new TPalette();
|
|
Toshihiro Shimizu |
890ddd |
m_palette->addRef();
|
|
Toshihiro Shimizu |
890ddd |
TFilePath fullPath = scene->decodeFilePath(m_fullcolorPalettePath);
|
|
Toshihiro Shimizu |
890ddd |
if (!TSystem::doesExistFileOrLevel(fullPath)) {
|
|
Toshihiro Shimizu |
890ddd |
//Per I francesi che hanno il nome vecchio della paletta
|
|
Toshihiro Shimizu |
890ddd |
//Verra' caricata la vecchia ma salvata col nome nuovo!
|
|
Toshihiro Shimizu |
890ddd |
TFilePath app("+palettes\\fullcolorPalette.tpl");
|
|
Toshihiro Shimizu |
890ddd |
fullPath = scene->decodeFilePath(app);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (TSystem::doesExistFileOrLevel(fullPath)) {
|
|
Toshihiro Shimizu |
890ddd |
TPalette *app = new TPalette();
|
|
Toshihiro Shimizu |
890ddd |
TIStream is(fullPath);
|
|
Toshihiro Shimizu |
890ddd |
is >> app;
|
|
Toshihiro Shimizu |
890ddd |
m_palette->assign(app);
|
|
Toshihiro Shimizu |
890ddd |
delete app;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
m_palette->setPaletteName(L"Raster Drawing Palette");
|
|
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 FullColorPalette::savePalette(ToonzScene *scene)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_palette || !m_palette->getDirtyFlag())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFilePath fullPath = scene->decodeFilePath(m_fullcolorPalettePath);
|
|
Toshihiro Shimizu |
890ddd |
if (TSystem::touchParentDir(fullPath)) {
|
|
Toshihiro Shimizu |
890ddd |
if (TSystem::doesExistFileOrLevel(fullPath))
|
|
Toshihiro Shimizu |
890ddd |
TSystem::removeFileOrLevel(fullPath);
|
|
Toshihiro Shimizu |
890ddd |
TOStream os(fullPath);
|
|
Toshihiro Shimizu |
890ddd |
os << m_palette;
|
|
Toshihiro Shimizu |
890ddd |
m_palette->setDirtyFlag(false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|