aboutsummaryrefslogtreecommitdiff
path: root/include/ResourceCache.hpp
blob: ab7a921341548dff92f205d53ed4b09fe70680ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#pragma once

#include <SFML/Graphics/Font.hpp>
#include <SFML/Graphics/Texture.hpp>
#include <SFML/Graphics/Shader.hpp>
#include <dchat/Cache.hpp>
#include <string>
#include <stdexcept>

namespace dchat
{
    class FailedToLoadResourceException : public std::runtime_error
    {
    public:
        FailedToLoadResourceException(const std::string &errMsg) : std::runtime_error(errMsg) {}
    };
    
    class ResourceCache
    {
    public:
        // Throws FailedToLoadResourceException on failure
        static const sf::Font* getFont(const std::string &filepath);
        
        // Throws FailedToLoadResourceException on failure
        static sf::Texture* getTexture(const std::string &filepath);
        
        static sf::Shader* getShader(const std::string &filepath, sf::Shader::Type shaderType);

        static Cache* getCache();
    };
}