Packs management update WIP
This commit is contained in:
+23
-23
@@ -6,32 +6,17 @@
|
||||
#include "../graphics/Font.h"
|
||||
|
||||
Assets::~Assets() {
|
||||
for (auto& iter : shaders){
|
||||
delete iter.second;
|
||||
}
|
||||
|
||||
for (auto& iter : textures){
|
||||
delete iter.second;
|
||||
}
|
||||
|
||||
for (auto& iter : fonts){
|
||||
delete iter.second;
|
||||
}
|
||||
|
||||
for (auto& iter : atlases) {
|
||||
delete iter.second;
|
||||
}
|
||||
}
|
||||
|
||||
Texture* Assets::getTexture(std::string name) const {
|
||||
auto found = textures.find(name);
|
||||
if (found == textures.end())
|
||||
return nullptr;
|
||||
return found->second;
|
||||
return found->second.get();
|
||||
}
|
||||
|
||||
void Assets::store(Texture* texture, std::string name){
|
||||
textures[name] = texture;
|
||||
textures[name].reset(texture);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,11 +24,11 @@ Shader* Assets::getShader(std::string name) const{
|
||||
auto found = shaders.find(name);
|
||||
if (found == shaders.end())
|
||||
return nullptr;
|
||||
return found->second;
|
||||
return found->second.get();
|
||||
}
|
||||
|
||||
void Assets::store(Shader* shader, std::string name){
|
||||
shaders[name] = shader;
|
||||
shaders[name].reset(shader);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,20 +36,35 @@ Font* Assets::getFont(std::string name) const {
|
||||
auto found = fonts.find(name);
|
||||
if (found == fonts.end())
|
||||
return nullptr;
|
||||
return found->second;
|
||||
return found->second.get();
|
||||
}
|
||||
|
||||
void Assets::store(Font* font, std::string name){
|
||||
fonts[name] = font;
|
||||
fonts[name].reset(font);
|
||||
}
|
||||
|
||||
Atlas* Assets::getAtlas(std::string name) const {
|
||||
auto found = atlases.find(name);
|
||||
if (found == atlases.end())
|
||||
return nullptr;
|
||||
return found->second;
|
||||
return found->second.get();
|
||||
}
|
||||
|
||||
void Assets::store(Atlas* atlas, std::string name){
|
||||
atlases[name] = atlas;
|
||||
atlases[name].reset(atlas);
|
||||
}
|
||||
|
||||
void Assets::extend(const Assets& assets) {
|
||||
for (auto entry : assets.textures) {
|
||||
textures[entry.first] = entry.second;
|
||||
}
|
||||
for (auto entry : assets.shaders) {
|
||||
shaders[entry.first] = entry.second;
|
||||
}
|
||||
for (auto entry : assets.fonts) {
|
||||
fonts[entry.first] = entry.second;
|
||||
}
|
||||
for (auto entry : assets.atlases) {
|
||||
atlases[entry.first] = entry.second;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user