nested folder support + refuse to load incompatibly sized textures + general cleanups

This commit is contained in:
Khangaroo 2019-08-16 22:34:22 -04:00 committed by James Rowe
parent 8a98310a16
commit ae4aaf2fc1
8 changed files with 141 additions and 57 deletions

View file

@ -4,6 +4,7 @@
#pragma once
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
@ -16,6 +17,12 @@ struct CustomTexInfo {
std::vector<u8> tex;
};
// This is to avoid parsing the filename multiple times
struct CustomTexPathInfo {
std::string path;
u64 hash;
};
// TODO: think of a better name for this class...
class CustomTexCache {
public:
@ -29,8 +36,16 @@ public:
const CustomTexInfo& LookupTexture(u64 hash) const;
void CacheTexture(u64 hash, const std::vector<u8>& tex, u32 width, u32 height);
void AddTexturePath(u64 hash, const std::string& path);
void FindCustomTextures();
void PreloadTextures();
bool CustomTextureExists(u64 hash) const;
const CustomTexPathInfo& LookupTexturePathInfo(u64 hash) const;
bool IsTexturePathMapEmpty() const;
private:
std::unordered_set<u64> dumped_textures;
std::unordered_map<u64, CustomTexInfo> custom_textures;
std::unordered_map<u64, CustomTexPathInfo> custom_texture_paths;
};
} // namespace Core