diff --git a/Nuake/src/Resource/FGD/ClassProperty.h b/Nuake/src/Resource/FGD/ClassProperty.h index 5810bfcf..fe57de87 100644 --- a/Nuake/src/Resource/FGD/ClassProperty.h +++ b/Nuake/src/Resource/FGD/ClassProperty.h @@ -1,5 +1,6 @@ #pragma once #include + enum class ClassPropertyType { String, Integer, diff --git a/Nuake/src/Resource/FGD/FGDFile.cpp b/Nuake/src/Resource/FGD/FGDFile.cpp index 57efceb2..b6bb059c 100644 --- a/Nuake/src/Resource/FGD/FGDFile.cpp +++ b/Nuake/src/Resource/FGD/FGDFile.cpp @@ -70,10 +70,30 @@ namespace Nuake { bool FGDFile::Export() { Ref project = Engine::GetProject(); - std::string path = project->TrenchbroomPath + "games/" + project->Name + "/" + project->Name + ".fgd"; + if (project->Name.empty()) + { + Logger::Log("Failed to create game configuration file: project name cannot be empty", "trenchbroom", CRITICAL); + return false; + } - FGDSerializer::BeginFGDFile(path); + // Create the games/PROJECT_NAME/ directories if they don't exist. + const std::string gamesDirectoryPath = project->TrenchbroomPath + "/../games/"; + if (!FileSystem::DirectoryExists(gamesDirectoryPath, true)) + { + FileSystem::MakeDirectory(gamesDirectoryPath, true); + } + + const std::string configDirectoryPath = gamesDirectoryPath + project->Name; + if (!FileSystem::DirectoryExists(configDirectoryPath, true)) + { + FileSystem::MakeDirectory(configDirectoryPath, true); + Logger::Log("Created game config directory: " + configDirectoryPath, "trenchbrrom"); + } + + // Write the file + const std::string filePath = configDirectoryPath + "/" + project->Name + ".fgd"; + FGDSerializer::BeginFGDFile(filePath); for (auto& b : BaseEntities) { diff --git a/Nuake/src/Resource/FGD/FGDFile.h b/Nuake/src/Resource/FGD/FGDFile.h index f60d18f0..0024931a 100644 --- a/Nuake/src/Resource/FGD/FGDFile.h +++ b/Nuake/src/Resource/FGD/FGDFile.h @@ -10,7 +10,8 @@ namespace Nuake { Brush, Point, Base, None }; - class FGDFile : ISerializable { + class FGDFile : ISerializable + { public: std::string Path;