refactor: add ContentControl class

This commit is contained in:
MihailRis
2025-04-02 15:01:24 +03:00
parent 7262119f5b
commit 331734792d
21 changed files with 324 additions and 246 deletions
+3 -7
View File
@@ -247,8 +247,8 @@ std::tuple<std::string, std::string> EnginePaths::parsePath(std::string_view pat
return {prefix, filename};
}
ResPaths::ResPaths(io::path mainRoot, std::vector<PathsRoot> roots)
: mainRoot(std::move(mainRoot)), roots(std::move(roots)) {
ResPaths::ResPaths(std::vector<PathsRoot> roots)
: roots(std::move(roots)) {
}
io::path ResPaths::find(const std::string& filename) const {
@@ -259,7 +259,7 @@ io::path ResPaths::find(const std::string& filename) const {
return file;
}
}
return mainRoot / filename;
return io::path("res:") / filename;
}
std::string ResPaths::findRaw(const std::string& filename) const {
@@ -356,7 +356,3 @@ std::vector<io::path> ResPaths::collectRoots() {
}
return collected;
}
const io::path& ResPaths::getMainRoot() const {
return mainRoot;
}
+25 -25
View File
@@ -19,8 +19,33 @@ struct PathsRoot {
}
};
class ResPaths {
public:
ResPaths() = default;
ResPaths(std::vector<PathsRoot> roots);
io::path find(const std::string& filename) const;
std::string findRaw(const std::string& filename) const;
std::vector<io::path> listdir(const std::string& folder) const;
std::vector<std::string> listdirRaw(const std::string& folder) const;
/// @brief Read all found list versions from all packs and combine into a
/// single list. Invalid versions will be skipped with logging a warning
/// @param file *.json file path relative to entry point
dv::value readCombinedList(const std::string& file) const;
dv::value readCombinedObject(const std::string& file, bool deep=false) const;
std::vector<io::path> collectRoots();
private:
std::vector<PathsRoot> roots;
};
class EnginePaths {
public:
ResPaths resPaths;
void prepare();
void setUserFilesFolder(std::filesystem::path folder);
@@ -65,28 +90,3 @@ private:
void cleanup();
};
class ResPaths {
public:
ResPaths(io::path mainRoot, std::vector<PathsRoot> roots);
io::path find(const std::string& filename) const;
std::string findRaw(const std::string& filename) const;
std::vector<io::path> listdir(const std::string& folder) const;
std::vector<std::string> listdirRaw(const std::string& folder) const;
/// @brief Read all found list versions from all packs and combine into a
/// single list. Invalid versions will be skipped with logging a warning
/// @param file *.json file path relative to entry point
dv::value readCombinedList(const std::string& file) const;
dv::value readCombinedObject(const std::string& file, bool deep=false) const;
std::vector<io::path> collectRoots();
const io::path& getMainRoot() const;
private:
io::path mainRoot;
std::vector<PathsRoot> roots;
};