2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2008-2022 Blender Authors
|
2023-06-14 23:30:43 +10:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2012-12-18 00:51:25 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup freestyle
|
2012-12-18 00:51:25 +00:00
|
|
|
*/
|
2008-05-19 05:34:31 +00:00
|
|
|
|
|
|
|
|
#include "AppConfig.h"
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
2014-04-17 14:31:35 +09:00
|
|
|
#include "../system/FreestyleConfig.h"
|
2008-05-19 05:34:31 +00:00
|
|
|
#include "../system/StringUtils.h"
|
2012-12-18 00:51:25 +00:00
|
|
|
|
2008-05-19 05:34:31 +00:00
|
|
|
using namespace std;
|
|
|
|
|
|
2024-01-21 19:42:13 +01:00
|
|
|
#include "BKE_appdir.hh"
|
2008-09-29 15:50:50 +00:00
|
|
|
|
2020-11-07 18:17:12 +05:30
|
|
|
namespace Freestyle::Config {
|
2012-12-18 00:51:25 +00:00
|
|
|
|
2020-11-06 17:49:09 +01:00
|
|
|
Path *Path::_pInstance = nullptr;
|
2012-12-18 00:51:25 +00:00
|
|
|
Path::Path()
|
|
|
|
|
{
|
2008-09-09 18:03:44 +00:00
|
|
|
// get the root directory
|
2012-12-18 00:51:25 +00:00
|
|
|
// soc
|
2024-01-23 18:38:15 +01:00
|
|
|
const std::optional<std::string> path = BKE_appdir_folder_id(BLENDER_SYSTEM_SCRIPTS, nullptr);
|
|
|
|
|
setRootDir(path.value_or(BKE_appdir_program_dir()));
|
2008-05-25 17:34:21 +00:00
|
|
|
|
2008-09-09 18:03:44 +00:00
|
|
|
_pInstance = this;
|
|
|
|
|
}
|
2012-12-18 00:51:25 +00:00
|
|
|
|
|
|
|
|
void Path::setRootDir(const string &iRootDir)
|
|
|
|
|
{
|
2020-07-03 15:54:55 +02:00
|
|
|
_ProjectDir = iRootDir + string(DIR_SEP) + "freestyle";
|
2008-09-09 18:03:44 +00:00
|
|
|
_ModelsPath = "";
|
2020-07-09 13:29:48 +10:00
|
|
|
_PatternsPath = _ProjectDir + string(DIR_SEP) + "data" + string(DIR_SEP) + "textures" +
|
|
|
|
|
string(DIR_SEP) + "variation_patterns" + string(DIR_SEP);
|
|
|
|
|
_BrushesPath = _ProjectDir + string(DIR_SEP) + "data" + string(DIR_SEP) + "textures" +
|
|
|
|
|
string(DIR_SEP) + "brushes" + string(DIR_SEP);
|
|
|
|
|
_EnvMapDir = _ProjectDir + string(DIR_SEP) + "data" + string(DIR_SEP) + "env_map" +
|
|
|
|
|
string(DIR_SEP);
|
|
|
|
|
_MapsDir = _ProjectDir + string(DIR_SEP) + "data" + string(DIR_SEP) + "maps" + string(DIR_SEP);
|
2008-09-09 18:03:44 +00:00
|
|
|
}
|
2012-12-18 00:51:25 +00:00
|
|
|
|
|
|
|
|
void Path::setHomeDir(const string &iHomeDir)
|
|
|
|
|
{
|
2008-09-09 18:03:44 +00:00
|
|
|
_HomeDir = iHomeDir;
|
|
|
|
|
}
|
2012-12-18 00:51:25 +00:00
|
|
|
|
|
|
|
|
Path::~Path()
|
|
|
|
|
{
|
2020-11-06 17:49:09 +01:00
|
|
|
_pInstance = nullptr;
|
2008-09-09 18:03:44 +00:00
|
|
|
}
|
2012-12-18 00:51:25 +00:00
|
|
|
|
2013-03-07 23:17:23 +00:00
|
|
|
Path *Path::getInstance()
|
2012-12-18 00:51:25 +00:00
|
|
|
{
|
2008-09-09 18:03:44 +00:00
|
|
|
return _pInstance;
|
|
|
|
|
}
|
2012-12-18 00:51:25 +00:00
|
|
|
|
|
|
|
|
string Path::getEnvVar(const string &iEnvVarName)
|
|
|
|
|
{
|
2008-09-09 18:03:44 +00:00
|
|
|
string value;
|
2013-05-01 13:34:56 +00:00
|
|
|
if (!getenv(iEnvVarName.c_str())) {
|
|
|
|
|
cerr << "Warning: You may want to set the $" << iEnvVarName
|
2013-03-07 23:17:23 +00:00
|
|
|
<< " environment variable to use Freestyle." << endl
|
|
|
|
|
<< " Otherwise, the current directory will be used instead." << endl;
|
2008-09-09 18:03:44 +00:00
|
|
|
value = ".";
|
2012-12-18 00:51:25 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2013-05-01 13:34:56 +00:00
|
|
|
value = getenv(iEnvVarName.c_str());
|
2008-09-09 18:03:44 +00:00
|
|
|
}
|
|
|
|
|
return value;
|
|
|
|
|
}
|
2008-05-19 05:34:31 +00:00
|
|
|
|
2020-11-07 18:17:12 +05:30
|
|
|
} // namespace Freestyle::Config
|