summaryrefslogtreecommitdiff
path: root/include/SSVOpenHexagon/Global/AssetStorage.hpp
blob: 5444f354a18a2431817d8e81cac5cb3b3c9d22db (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) 2013-2020 Vittorio Romeo
// License: Academic Free License ("AFL") v. 3.0
// AFL License page: https://opensource.org/licenses/AFL-3.0

#pragma once

#include <string>
#include <memory>

namespace sf {

class SoundBuffer;
class Texture;
class Font;

} // namespace sf

namespace hg {

class AssetStorage
{
private:
    class AssetStorageImpl;

    std::unique_ptr<AssetStorageImpl> _impl;

    [[nodiscard]] const AssetStorageImpl& impl() const noexcept;
    [[nodiscard]] AssetStorageImpl& impl() noexcept;

public:
    explicit AssetStorage();
    ~AssetStorage();

    [[nodiscard]] bool loadTexture(
        const std::string& id, const std::string& path);

    [[nodiscard]] bool loadFont(const std::string& id, const std::string& path);

    [[nodiscard]] bool loadSoundBuffer(
        const std::string& id, const std::string& path);

    [[nodiscard]] sf::Texture* getTexture(const std::string& id) noexcept;
    [[nodiscard]] sf::Font* getFont(const std::string& id) noexcept;
    [[nodiscard]] sf::SoundBuffer* getSoundBuffer(
        const std::string& id) noexcept;

    [[nodiscard]] bool hasTexture(const std::string& id) noexcept;
    [[nodiscard]] bool hasFont(const std::string& id) noexcept;
    [[nodiscard]] bool hasSoundBuffer(const std::string& id) noexcept;
};

} // namespace hg