feat(editor): persist graphics settings and shadow overrides
This commit is contained in:
@@ -16,10 +16,29 @@ struct ProjectDescriptor {
|
||||
std::string startupScene;
|
||||
};
|
||||
|
||||
struct GraphicsSettingsDescriptor {
|
||||
std::string renderPipelineAssetAssembly;
|
||||
std::string renderPipelineAssetNamespace;
|
||||
std::string renderPipelineAssetClass;
|
||||
|
||||
bool HasRenderPipelineAsset() const {
|
||||
return !renderPipelineAssetAssembly.empty() &&
|
||||
!renderPipelineAssetClass.empty();
|
||||
}
|
||||
};
|
||||
|
||||
inline fs::path GetProjectFilePath(const std::string& projectRoot) {
|
||||
return fs::path(projectRoot) / "Project.xcproject";
|
||||
}
|
||||
|
||||
inline fs::path GetProjectSettingsDirectory(const std::string& projectRoot) {
|
||||
return fs::path(projectRoot) / "ProjectSettings";
|
||||
}
|
||||
|
||||
inline fs::path GetGraphicsSettingsFilePath(const std::string& projectRoot) {
|
||||
return GetProjectSettingsDirectory(projectRoot) / "GraphicsSettings.asset";
|
||||
}
|
||||
|
||||
inline std::string GetProjectName(const std::string& projectRoot) {
|
||||
const fs::path rootPath(projectRoot);
|
||||
const fs::path folderName = rootPath.filename().empty() ? rootPath.parent_path().filename() : rootPath.filename();
|
||||
@@ -79,6 +98,59 @@ inline std::optional<ProjectDescriptor> LoadProjectDescriptor(const std::string&
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
inline bool SaveProjectGraphicsSettings(
|
||||
const std::string& projectRoot,
|
||||
const GraphicsSettingsDescriptor& descriptor) {
|
||||
std::error_code ec;
|
||||
fs::create_directories(GetProjectSettingsDirectory(projectRoot), ec);
|
||||
|
||||
std::ofstream output(
|
||||
GetGraphicsSettingsFilePath(projectRoot),
|
||||
std::ios::out | std::ios::trunc);
|
||||
if (!output.is_open()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
output << "version=1\n";
|
||||
output << "render_pipeline_asset_assembly="
|
||||
<< descriptor.renderPipelineAssetAssembly << "\n";
|
||||
output << "render_pipeline_asset_namespace="
|
||||
<< descriptor.renderPipelineAssetNamespace << "\n";
|
||||
output << "render_pipeline_asset_class="
|
||||
<< descriptor.renderPipelineAssetClass << "\n";
|
||||
return output.good();
|
||||
}
|
||||
|
||||
inline std::optional<GraphicsSettingsDescriptor> LoadProjectGraphicsSettings(
|
||||
const std::string& projectRoot) {
|
||||
std::ifstream input(GetGraphicsSettingsFilePath(projectRoot));
|
||||
if (!input.is_open()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
GraphicsSettingsDescriptor descriptor;
|
||||
|
||||
std::string line;
|
||||
while (std::getline(input, line)) {
|
||||
const size_t equalsPos = line.find('=');
|
||||
if (equalsPos == std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const std::string key = Trim(line.substr(0, equalsPos));
|
||||
const std::string value = Trim(line.substr(equalsPos + 1));
|
||||
if (key == "render_pipeline_asset_assembly") {
|
||||
descriptor.renderPipelineAssetAssembly = value;
|
||||
} else if (key == "render_pipeline_asset_namespace") {
|
||||
descriptor.renderPipelineAssetNamespace = value;
|
||||
} else if (key == "render_pipeline_asset_class") {
|
||||
descriptor.renderPipelineAssetClass = value;
|
||||
}
|
||||
}
|
||||
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
inline std::string MakeProjectRelativePath(const std::string& projectRoot, const std::string& fullPath) {
|
||||
if (projectRoot.empty() || fullPath.empty()) {
|
||||
return {};
|
||||
|
||||
Reference in New Issue
Block a user