2016-05-17 03:04:11 +12:00
|
|
|
#pragma once
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
#ifndef STUDIOPALETTE_INCLUDED
|
|
|
|
#define STUDIOPALETTE_INCLUDED
|
|
|
|
|
|
|
|
#include "tpalette.h"
|
|
|
|
//#include "tfilepath.h"
|
|
|
|
|
|
|
|
#undef DVAPI
|
|
|
|
#undef DVVAR
|
|
|
|
#ifdef TOONZLIB_EXPORTS
|
|
|
|
#define DVAPI DV_EXPORT_API
|
|
|
|
#define DVVAR DV_EXPORT_VAR
|
|
|
|
#else
|
|
|
|
#define DVAPI DV_IMPORT_API
|
|
|
|
#define DVVAR DV_IMPORT_VAR
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class TPalette;
|
|
|
|
class TImage;
|
|
|
|
class TColorStyle;
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
class DVAPI StudioPalette { // singleton; methods can throw exceptions
|
2016-03-19 06:57:51 +13:00
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
class Listener {
|
|
|
|
public:
|
|
|
|
virtual void onStudioPaletteTreeChange() {}
|
|
|
|
virtual void onStudioPaletteMove(const TFilePath &dstPath,
|
|
|
|
const TFilePath &srcPath) {}
|
|
|
|
virtual void onStudioPaletteChange(const TFilePath &palette) {}
|
|
|
|
virtual ~Listener() {}
|
|
|
|
};
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
class Palette { // serve per il drag&drop
|
|
|
|
TFilePath m_palettePath;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
public:
|
|
|
|
Palette(const TFilePath &path) : m_palettePath(path) {}
|
|
|
|
const TFilePath &getPath() const { return m_palettePath; }
|
|
|
|
};
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
static StudioPalette *instance();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
~StudioPalette();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TPalette *getPalette(const TFilePath &path, bool loadRefImg = false);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
int getChildren(std::vector<TFilePath> &fps, const TFilePath &folderPath);
|
|
|
|
int getChildCount(const TFilePath &folderPath);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool isFolder(const TFilePath &path);
|
|
|
|
bool isPalette(const TFilePath &path);
|
|
|
|
bool isReadOnly(const TFilePath &path);
|
|
|
|
bool isLevelPalette(const TFilePath &path);
|
|
|
|
bool hasGlobalName(const TFilePath &path);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// ritorna il nome del folder creato
|
|
|
|
TFilePath createFolder(const TFilePath &parentFolderPath);
|
|
|
|
void createFolder(const TFilePath &parentFolderPath, std::wstring name);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// ritorna il nome della palette creata;
|
|
|
|
// se paletteName != "" prova ad assegnare quel nome. Se esiste gia'
|
|
|
|
// aggiunge un suffisso
|
|
|
|
TFilePath createPalette(const TFilePath &folderPath,
|
|
|
|
std::string paletteName = "");
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// DOESN'T get ownership
|
|
|
|
void setPalette(const TFilePath &palettePath, const TPalette *palette,
|
|
|
|
bool notifyPaletteChanged);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void deletePalette(const TFilePath &palettePath);
|
|
|
|
void deleteFolder(const TFilePath &folderPath);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TFilePath importPalette(const TFilePath &dstFolder, const TFilePath &srcPath);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void movePalette(const TFilePath &dstPath, const TFilePath &srcPath);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TFilePath getLevelPalettesRoot();
|
|
|
|
TFilePath getProjectPalettesRoot();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// TFilePath getRefImage(const TFilePath palettePath);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool updateLinkedColors(TPalette *palette);
|
|
|
|
void setStylesGlobalNames(TPalette *palette);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TFilePath getPalettePath(std::wstring paletteId);
|
|
|
|
TPalette *getPalette(std::wstring paletteId);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TColorStyle *getStyle(std::wstring styleId);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// se lo stile ha un nome globale restituisce il nome della studio palette e
|
|
|
|
// l'indice
|
|
|
|
// dello stile linkato
|
|
|
|
// (altrimenti restituisce (TFilePath(),-1))
|
|
|
|
std::pair<TFilePath, int> getSourceStyle(TColorStyle *cs);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void addListener(Listener *listener);
|
|
|
|
void removeListener(Listener *listener);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void notifyTreeChange();
|
|
|
|
void notifyMove(const TFilePath &dstPath, const TFilePath &srcPath);
|
|
|
|
void notifyPaletteChange(const TFilePath &name);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// bruttacchietto.
|
|
|
|
static bool isEnabled() { return m_enabled; };
|
|
|
|
static void enable(bool enabled);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void save(const TFilePath &path, TPalette *palette);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
private:
|
2016-06-15 18:43:10 +12:00
|
|
|
StudioPalette();
|
|
|
|
TFilePath m_root;
|
|
|
|
std::map<std::wstring, TFilePath> m_table;
|
|
|
|
std::vector<Listener *> m_listeners;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TPalette *load(const TFilePath &path);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
static bool m_enabled;
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|