fix texture path adding order

This commit is contained in:
HJfod 2022-10-24 22:46:39 +03:00
parent 1d34bb138b
commit c7cc2d4563
3 changed files with 24 additions and 10 deletions
loader
include/Geode
src/load

View file

@ -186,6 +186,7 @@ namespace geode {
void updateResources();
void addTexturePath(ghc::filesystem::path const& path);
void removeTexturePath(ghc::filesystem::path const& path);
std::vector<ghc::filesystem::path> getTexturePaths() const;
/**
* Check if a mod with an ID is installed. Any

View file

@ -114,7 +114,7 @@ namespace geode::utils::ranges {
} else {
first = false;
}
res += Conv(p);
res += converter(p);
}
return res;
}

View file

@ -55,11 +55,20 @@ void Loader::updateResourcePaths() {
log::debug("Setting resource paths");
// reset search paths
CCFileUtils::get()->setSearchPaths({
"Resources",
(this->getGeodeDirectory() / GEODE_RESOURCE_DIRECTORY).string(),
(this->getGeodeDirectory() / GEODE_TEMP_DIRECTORY).string()
});
CCFileUtils::get()->removeAllPaths();
// add custom texture paths first (priority)
for (auto const& path : m_texturePaths) {
CCFileUtils::get()->addSearchPath(path.string().c_str());
}
// add own paths next
CCFileUtils::get()->addSearchPath(
(this->getGeodeDirectory() / GEODE_RESOURCE_DIRECTORY).string().c_str()
);
CCFileUtils::get()->addSearchPath(
(this->getGeodeDirectory() / GEODE_TEMP_DIRECTORY).string().c_str()
);
// add mods' search paths
for (auto const& [_, mod] : m_mods) {
@ -70,10 +79,8 @@ void Loader::updateResourcePaths() {
CCFileUtils::get()->addSearchPath(searchPath.string().c_str());
}
// add custom texture paths
for (auto const& path : m_texturePaths) {
CCFileUtils::get()->addSearchPath(path.string().c_str());
}
// add GD's search path
CCFileUtils::get()->addSearchPath("Resources");
}
void Loader::updateModResources(Mod* mod) {
@ -124,6 +131,8 @@ void Loader::updateResources() {
}
void Loader::addTexturePath(ghc::filesystem::path const& path) {
// remove path if it already exists
this->removeTexturePath(path);
m_texturePaths.push_back(path);
}
@ -131,6 +140,10 @@ void Loader::removeTexturePath(ghc::filesystem::path const& path) {
ranges::remove(m_texturePaths, path);
}
std::vector<ghc::filesystem::path> Loader::getTexturePaths() const {
return m_texturePaths;
}
size_t Loader::loadModsFromDirectory(
ghc::filesystem::path const& dir, bool recursive
) {