ContentPackRuntime + refactor

This commit is contained in:
MihailRis
2024-02-08 20:53:12 +03:00
parent 54e6d49847
commit 241d15e349
22 changed files with 224 additions and 169 deletions
+26 -14
View File
@@ -8,16 +8,18 @@
class EnginePaths;
namespace fs = std::filesystem;
class contentpack_error : public std::runtime_error {
std::string packId;
std::filesystem::path folder;
fs::path folder;
public:
contentpack_error(std::string packId,
std::filesystem::path folder,
fs::path folder,
std::string message);
std::string getPackId() const;
std::filesystem::path getFolder() const;
fs::path getFolder() const;
};
struct ContentPack {
@@ -26,35 +28,45 @@ struct ContentPack {
std::string version = "0.0";
std::string creator = "";
std::string description = "no description";
std::filesystem::path folder;
fs::path folder;
std::vector<std::string> dependencies;
std::filesystem::path getContentFile() const;
fs::path getContentFile() const;
static const std::string PACKAGE_FILENAME;
static const std::string CONTENT_FILENAME;
static const std::filesystem::path BLOCKS_FOLDER;
static const std::filesystem::path ITEMS_FOLDER;
static const fs::path BLOCKS_FOLDER;
static const fs::path ITEMS_FOLDER;
static const std::vector<std::string> RESERVED_NAMES;
static bool is_pack(std::filesystem::path folder);
static ContentPack read(std::filesystem::path folder);
static bool is_pack(fs::path folder);
static ContentPack read(fs::path folder);
static void scan(std::filesystem::path folder,
static void scan(fs::path folder,
std::vector<ContentPack>& packs);
static void scan(EnginePaths* paths,
std::vector<ContentPack>& packs);
static std::vector<std::string> worldPacksList(std::filesystem::path folder);
static std::vector<std::string> worldPacksList(fs::path folder);
static std::filesystem::path findPack(
static fs::path findPack(
const EnginePaths* paths,
std::filesystem::path worldDir,
fs::path worldDir,
std::string name);
static void readPacks(const EnginePaths* paths,
std::vector<ContentPack>& packs,
const std::vector<std::string>& names,
std::filesystem::path worldDir);
fs::path worldDir);
};
class ContentPackRuntime {
ContentPack info;
public:
ContentPackRuntime(ContentPack info);
inline const std::string& getId() {
return info.id;
}
};
#endif // CONTENT_CONTENT_PACK_H_