refactor(resource-manager): minor style changes and comments

This commit is contained in:
2025-04-28 13:43:57 -04:00
parent d3a5e4615b
commit d678c4bc33

View File

@@ -39,11 +39,11 @@ ResourceManager::ResourceManager() {
m_dataDir = m_config.get<std::string>("Data:Dir", defaultDataDir); m_dataDir = m_config.get<std::string>("Data:Dir", defaultDataDir);
// -- Get the index file path using filesytem to make it a system safe path // -- Get the index file path using filesytem to make it a system safe path
std::string indexFilePath = m_dataDir + "/index.yaml"; std::string indexFilePath = m_dataDir + "/index.yaml";
std::filesystem::path indexFile(indexFilePath); // TODO Add checks to make sure data dir exists and index.yaml exists
const std::filesystem::path indexFile(indexFilePath);
m_resourceConfig.loadConfig(indexFile.string()); m_resourceConfig.loadConfig(indexFile.string());
std::vector<std::string> assets = m_resourceConfig.keys(); for (const auto key : m_resourceConfig.keys() ) {
for (auto key : assets ) {
load(key); load(key);
} }
} }
@@ -69,14 +69,15 @@ bool ResourceManager::loadResource(std::string& name) {
} }
bool ResourceManager::load(const std::string& name) { bool ResourceManager::load(const std::string& name) {
// TODO : make this path system more system agnostic
const std::string resourcePath = m_dataDir + "/" + m_resourceConfig.get<std::string>(name); const std::string resourcePath = m_dataDir + "/" + m_resourceConfig.get<std::string>(name);
std::filesystem::path resourceFile(resourcePath); const std::filesystem::path resourceFile(resourcePath);
if (!std::filesystem::exists(resourceFile)) { if (!std::filesystem::exists(resourceFile)) {
LOG_ERROR(m_logger, "Resource file not found: {}", resourceFile.string()); LOG_ERROR(m_logger, "Resource file not found: {}", resourceFile.string());
return false; return false;
} }
LOG_INFO(m_logger, "Loading resource: {}", resourceFile.string()); LOG_INFO(m_logger, "Loading resource: {}", resourceFile.string());
if (m_resources.find(name) != m_resources.end()) { if (m_resources.contains(name)) {
LOG_INFO(m_logger, "Resource already loaded: {}", name); LOG_INFO(m_logger, "Resource already loaded: {}", name);
return true; return true;
} }