Merge remote-tracking branch 'origin/master' into project_setup_refactor

# Conflicts:
#	CMakeLists.txt
This commit is contained in:
Georg Hagen
2024-08-14 22:47:19 +02:00
61 changed files with 2489 additions and 96 deletions

View File

@@ -40,6 +40,11 @@ namespace OpenVulkano
}
}
std::string ResourceLoaderAppDirLinux::GetResourcePath(const std::string& resourceName)
{
return GetAppDir() + resourceName;
}
Array<char> ResourceLoaderAppDirLinux::GetResource(const std::string& resourceName)
{
return Utils::ReadFile(GetAppDir() + resourceName, true);

View File

@@ -13,6 +13,7 @@ namespace OpenVulkano
class ResourceLoaderAppDirLinux final : public ResourceLoader
{
public:
std::string GetResourcePath(const std::string& resourceName) override;
Array<char> GetResource(const std::string& resourceName) override;
};
}

View File

@@ -54,6 +54,30 @@ namespace OpenVulkano
}
return false;
}
std::string GetResourcePath(const std::string& resourceName) override
{
try
{
for (auto& loader: m_loaders)
{
auto res = loader->GetResourcePath(resourceName);
if (!res.empty())
{
return res;
}
}
}
catch (const std::exception& e)
{
Logger::FILESYS->error("Error trying to get resource path for '{}'! Error: {}", resourceName, e.what());
}
catch (...)
{
Logger::FILESYS->error("Unknown error trying to get resource path for '{}'!", resourceName);
}
return "";
}
};
ResourceLoader& ResourceLoader::GetInstance()

View File

@@ -15,7 +15,9 @@ namespace OpenVulkano
public:
virtual ~ResourceLoader() = default;
virtual Array<char> GetResource(const std::string& resourceName) = 0;
[[nodiscard]] virtual Array<char> GetResource(const std::string& resourceName) = 0;
[[nodiscard]] virtual std::string GetResourcePath(const std::string& resourceName) { return ""; }
static ResourceLoader& GetInstance();

View File

@@ -38,6 +38,11 @@ namespace OpenVulkano
}
}
std::string ResourceLoaderAppDirWindows::GetResourcePath(const std::string& resourceName)
{
return GetAppDir() + resourceName;
}
Array<char> ResourceLoaderAppDirWindows::GetResource(const std::string& resourceName)
{
return Utils::ReadFile(GetAppDir() + resourceName);

View File

@@ -13,6 +13,7 @@ namespace OpenVulkano
class ResourceLoaderAppDirWindows final : public ResourceLoader
{
public:
std::string GetResourcePath(const std::string& resourceName) override;
Array<char> GetResource(const std::string& resourceName) override;
};
}