Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "toonz/toonzfolders.h"
Toshihiro Shimizu 890ddd
#include "tsystem.h"
Toshihiro Shimizu 890ddd
#include "tenv.h"
Toshihiro Shimizu 890ddd
//#include "appmainshell.h"
Toshihiro Shimizu 890ddd
#include "tconvert.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
using namespace TEnv;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TFilePath ToonzFolder::getModulesDir()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return getProfileFolder() + "layouts";
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TFilePathSet ToonzFolder::getProjectsFolders()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TFilePathSet fps = getSystemVarPathSetValue(getSystemVarPrefix() + "PROJECTS");
Toshihiro Shimizu 890ddd
	if (fps.empty())
Toshihiro Shimizu 890ddd
		fps.push_back(TEnv::getStuffDir() + "Projects");
Toshihiro Shimizu 890ddd
	return fps;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TFilePath ToonzFolder::getFirstProjectsFolder()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TFilePathSet fps = getProjectsFolders();
Toshihiro Shimizu 890ddd
	if (fps.empty())
Toshihiro Shimizu 890ddd
		return TFilePath();
Toshihiro Shimizu 890ddd
	else
Toshihiro Shimizu 890ddd
		return *fps.begin();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TFilePath ToonzFolder::getLibraryFolder()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TFilePath fp = getSystemVarPathValue(getSystemVarPrefix() + "LIBRARY");
Toshihiro Shimizu 890ddd
	if (fp == TFilePath())
Toshihiro Shimizu 890ddd
		fp = getFirstProjectsFolder() + "library";
Toshihiro Shimizu 890ddd
	return fp;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TFilePath ToonzFolder::getStudioPaletteFolder()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TFilePath fp = getSystemVarPathValue(getSystemVarPrefix() + "STUDIOPALETTE");
Toshihiro Shimizu 890ddd
	if (fp == TFilePath())
Toshihiro Shimizu 890ddd
		fp = getFirstProjectsFolder() + "studiopalette";
Toshihiro Shimizu 890ddd
	return fp;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TFilePath ToonzFolder::getFxPresetFolder()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TFilePath fp = getSystemVarPathValue(getSystemVarPrefix() + "FXPRESETS");
Toshihiro Shimizu 890ddd
	if (fp == TFilePath())
Toshihiro Shimizu 890ddd
		fp = getFirstProjectsFolder() + "fxs";
Toshihiro Shimizu 890ddd
	return fp;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TFilePath ToonzFolder::getCacheRootFolder()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TFilePath fp = getSystemVarPathValue(getSystemVarPrefix() + "CACHEROOT");
Toshihiro Shimizu 890ddd
	if (fp == TFilePath())
Toshihiro Shimizu 890ddd
		fp = getStuffDir() + "cache";
Toshihiro Shimizu 890ddd
	return fp;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TFilePath ToonzFolder::getProfileFolder()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TFilePath fp = getSystemVarPathValue(getSystemVarPrefix() + "PROFILES");
Toshihiro Shimizu 890ddd
	if (fp == TFilePath())
Toshihiro Shimizu 890ddd
		fp = getStuffDir() + "profiles";
Toshihiro Shimizu 890ddd
	return fp;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TFilePath ToonzFolder::getReslistPath(bool forCleanup)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return getFirstProjectsFolder() + (forCleanup ? "cleanupreslist.txt" : "reslist.txt");
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TFilePath ToonzFolder::getTemplateModuleDir()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return getModulesDir() + getModuleName();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TFilePath ToonzFolder::getMyModuleDir()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TFilePath fp(getTemplateModuleDir());
Toshihiro Shimizu 890ddd
	return fp.withName(fp.getWideName() + L"." + TSystem::getUserName().toStdWString());
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TFilePath ToonzFolder::getModuleFile(TFilePath filename)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TFilePath fp = getMyModuleDir() + filename;
Toshihiro Shimizu 890ddd
	if (TFileStatus(fp).doesExist())
Toshihiro Shimizu 890ddd
		return fp;
Toshihiro Shimizu 890ddd
	fp = getTemplateModuleDir() + filename;
Toshihiro Shimizu 890ddd
	return fp;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 3bfa54
TFilePath ToonzFolder::getModuleFile(std::string fn)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return ToonzFolder::getModuleFile(TFilePath(fn));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//===================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
FolderListenerManager::FolderListenerManager()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
FolderListenerManager::~FolderListenerManager()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
FolderListenerManager *FolderListenerManager::instance()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	static FolderListenerManager _instance;
Toshihiro Shimizu 890ddd
	return &_instance;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FolderListenerManager::notifyFolderChanged(const TFilePath &path)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	for (std::set<listener *="">::iterator i = m_listeners.begin(); i != m_listeners.end(); ++i)</listener>
Toshihiro Shimizu 890ddd
		(*i)->onFolderChanged(path);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FolderListenerManager::addListener(Listener *listener)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_listeners.insert(listener);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FolderListenerManager::removeListener(Listener *listener)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_listeners.erase(listener);
Toshihiro Shimizu 890ddd
}