/** * Triangles * Copyright (C) 2016 POSITIVE MENTAL ATTITUDE * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "Assets.hpp" #include "Utility.hpp" Assets::~Assets() { textures.clear(); sounds.clear(); fonts.clear(); } sf::Texture& Assets::loadTexture(std::string file) { if(!textures.count(file)) { sf::Texture texture; if(!texture.loadFromFile(file)) Echo::out(Echo::Error, "Unable to load texture file: ", file, "\nExpect a segfault!"); texture.setSmooth(true); textures.emplace(file, texture); } return textures.at(file); } sf::SoundBuffer& Assets::loadSound(std::string file) { if(!sounds.count(file)) { sf::SoundBuffer sound; if(!sound.loadFromFile(file)) Echo::out(Echo::Error, "Unable to load sound file: ", file, "\nExpect a segfault!"); sound.loadFromFile(file); sounds.emplace(file, sound); } return sounds.at(file); } sf::Font& Assets::loadFont(std::string file) { if(!fonts.count(file)) { sf::Font font; if(!font.loadFromFile(file)) Echo::out(Echo::Error, "Unable to load font file: ", file, "\nExpect a segfault!"); fonts.emplace(file, font); } return fonts.at(file); }