8#include "Engine/Files/AssetPath.h"
9#include "Engine/Files/GeneratedAssetManifest.h"
11#ifndef GAME_FOLDER_NAME
12#error "GAME_FOLDER_NAME must be defined by CMake"
40 for (
size_t i = 0; i < N; ++i) {
41 path_[i] = literal[i];
50 [[nodiscard]]
constexpr std::string_view
view()
const {
return {
path_.data(),
length_}; }
56 [[nodiscard]] std::filesystem::path
fsPath()
const
58 return std::filesystem::path(
view());
65 [[nodiscard]] std::string
string()
const
67 return std::string(
view());
74 [[nodiscard]]
constexpr const char*
c_str()
const
83 operator std::filesystem::path()
const {
return fsPath(); }
92 [[nodiscard]]
constexpr auto operator/(
const char (&other)[M])
const
94 constexpr size_t leftChars = N - 1;
95 constexpr size_t rightChars = M - 1;
96 constexpr size_t resultChars = leftChars + 1 + rightChars;
100 for (
size_t i = 0; i <
length_; ++i) {
104 result.
path_[out++] =
'/';
106 for (
size_t i = 0; i < rightChars; ++i) {
107 result.
path_[out++] = other[i];
109 result.
path_[out] =
'\0';
119 std::filesystem::path
operator/(
const std::filesystem::path & other )
const
129 std::filesystem::path
operator/(std::string_view other)
const
157 return stream << path.
view();
168 return Assets::GeneratedAssetManifest::contains(path.
view());
202 return ConstexprPath(
"assets/" GAME_FOLDER_NAME
"/Data/geometry/" );
211 return ConstexprPath(
"assets/" GAME_FOLDER_NAME
"/Data/sounds/" );
220 return ConstexprPath(
"assets/" GAME_FOLDER_NAME
"/Data/textures/" );
291#define CREATE_ASSET_PATH( assetPath ) \
294 constexpr auto verifiedAssetPath = ( assetPath ); \
296 ::Engine::Core::assetExists( verifiedAssetPath ), \
297 "Asset path is not present in GeneratedAssetManifest" \
299 return verifiedAssetPath; \
308#define CREATE_MESH_ASSET_PATH( assetPath, objectName ) \
311 constexpr auto path = CREATE_ASSET_PATH( assetPath ); \
312 Asset::MeshPath meshAsset( path.fsPath(), objectName ); \
Fixed-size path string that supports constexpr path composition.
constexpr const char * c_str() const
Gets a null-terminated character pointer.
std::filesystem::path operator/(std::string_view other) const
Appends a runtime string-view path segment.
std::array< char, N > path_
constexpr ConstexprPath(const char(&literal)[N])
Creates a constexpr path from a string literal.
constexpr std::string_view view() const
Gets this path as a string view.
std::string string() const
Converts this path to a string.
friend class ConstexprPath
constexpr auto operator/(const char(&other)[M]) const
Appends a string literal path segment.
std::filesystem::path fsPath() const
Converts this path to a filesystem path.
constexpr ConstexprPath()=default
Creates an empty constexpr path.
std::filesystem::path operator/(const std::filesystem::path &other) const
Appends a runtime filesystem path segment.
Centralized accessors for project and asset paths.
static constexpr auto engineFonts()
Path to font assets.
static constexpr auto engineTextures()
Path to engine textures.
static constexpr auto gameGeometry()
Path to game geometry assets.
static bool doesExrFileExist(const std::filesystem::path &path)
Checks if the specified filepath exists at the given path and if the file is an exr file.
static bool doesFileOfTypeExist(const std::filesystem::path &path, const std::string &extension)
Checks if the specified filepath exists and if the file at the path is of a file type.
static std::string getEngineRoot()
Gets the engine root directory at runtime.
static bool doesGltfFileExist(const std::filesystem::path &path)
Checks if the specified filepath exists at the given path and is a gltf file.
static constexpr auto gameTextures()
Path to game texture assets.
static constexpr auto engineGeometry()
Path to engine geometry assets.
static constexpr auto gameAudio()
Path to game Audio assets.
static constexpr auto engineShaders()
Path to engine shaders.
static bool doesFileExist(const std::filesystem::path &path)
Checks if a file at a filepath exists.
static constexpr auto engineSounds()
Path to engine audio files.
static constexpr std::string getProjectRoot()
Gets the root location of the whole game. This is.
consteval bool assetExists(const ConstexprPath< N > &path)
Checks whether a constexpr asset path exists in the generated manifest.
ConstexprPath(const char(&)[N]) -> ConstexprPath< N >
Deduces a ConstexprPath size from a string literal.
std::ostream & operator<<(std::ostream &stream, const ConstexprPath< N > &path)
Writes a constexpr path to an output stream.