asset::AssetLoader

More...

#include <AssetLoader.hpp>

Public Functions

Name

~AssetLoader() =default

template <class... Args> void

LoadTexture(const std::string & key, const std::filesystem::path & path, std::string_view next, Args... args) load an SFML asset and add it to the map

void

LoadTexture(const std::string & key, std::vector< std::string > paths)

template <class... Args> void

LoadBGM(const std::string & key, const std::filesystem::path & path, std::string_view next, Args... args) Load a background music and add it to the map.

void

LoadBGM(const std::string & key, std::vector< std::string > paths)

template <class... Args> void

LoadSFX(const std::string & key, const std::filesystem::path & path, std::string_view next, Args... args) Load a sound effect and add it to the map.

void

LoadSFX(const std::string & key, std::vector< std::string > paths)

template <class... Args> void

LoadFont(const std::string & key, const std::filesystem::path & path, std::string_view next, Args... args) load a font and add it to the map

void

LoadFont(const std::string & key, std::vector< std::string > paths)

void

loadKeybind(const std::string & action, const std::string & key)

std::filesystem::path

smartPath(std::vector< std::string > paths) create a smartpath from a vector of string

sf::Texture &

GetTexture(const std::string & key) Get an Asset object from the map.

sf::Music &

GetBGM(const std::string & key) Get a background music object from the map.

sf::Sound &

GetSFX(const std::string & key) Get a sound effect object from the map.

sf::Font &

GetFont(const std::string & key) Get a font object from the mapb.

sf::Keyboard::Key &

GetKeybind(const std::string & key)

void

LoadIniFile(const std::filesystem::path & path) Load a .ini file with boost loading assets into the map.

std::filesystem::path

smartPath(std::filesystem::path path)

template <class... Args> std::filesystem::path

smartPath(std::filesystem::path path, std::string_view next, Args... args)

Detailed Description

class asset::AssetLoader;

This class loads all the assets neened by the game and stores them in a map Basic operatations on assets are supported An asset is either a texture, a sound or a font

Public Functions Documentation

function ~AssetLoader

~AssetLoader() =default

Destroy the AssetLoader object

function LoadTexture

template <class... Args>
static inline void LoadTexture(
    const std::string & key,
    const std::filesystem::path & path,
    std::string_view next,
    Args... args
)

load an SFML asset and add it to the map

Parameters:

  • key the key to load the asset

  • path first segment of the path of the asset

  • next next segment of the path of the asset

  • args other segments of the path

function LoadTexture

static inline void LoadTexture(
    const std::string & key,
    std::vector< std::string > paths
)

function LoadBGM

template <class... Args>
static inline void LoadBGM(
    const std::string & key,
    const std::filesystem::path & path,
    std::string_view next,
    Args... args
)

Load a background music and add it to the map.

Parameters:

  • key the key to load the asset

  • path first segment of the path of the asset

  • next next segment of the path of the asset

  • args other segments of the path

Template Parameters:

  • Args Path segments

function LoadBGM

static inline void LoadBGM(
    const std::string & key,
    std::vector< std::string > paths
)

function LoadSFX

template <class... Args>
static inline void LoadSFX(
    const std::string & key,
    const std::filesystem::path & path,
    std::string_view next,
    Args... args
)

Load a sound effect and add it to the map.

Parameters:

  • key the key to load the asset

  • path first segment of the path of the asset

  • next next segment of the path of the asset

  • args other segments of the path

Template Parameters:

  • Args Path segments

function LoadSFX

static inline void LoadSFX(
    const std::string & key,
    std::vector< std::string > paths
)

function LoadFont

template <class... Args>
static inline void LoadFont(
    const std::string & key,
    const std::filesystem::path & path,
    std::string_view next,
    Args... args
)

load a font and add it to the map

Parameters:

  • key the key to load the font

  • path first segment of the path of the font

  • next next segment of the path of the font

  • args other segments of the path

function LoadFont

static inline void LoadFont(
    const std::string & key,
    std::vector< std::string > paths
)

function loadKeybind

static inline void loadKeybind(
    const std::string & action,
    const std::string & key
)

function smartPath

static inline std::filesystem::path smartPath(
    std::vector< std::string > paths
)

create a smartpath from a vector of string

function GetTexture

static inline sf::Texture & GetTexture(
    const std::string & key
)

Get an Asset object from the map.

Parameters:

  • key of the asset to get

Return: sf::Texture& the texture

function GetBGM

static inline sf::Music & GetBGM(
    const std::string & key
)

Get a background music object from the map.

Parameters:

  • key of the asset to get

Return: sf::Music& the music

function GetSFX

static inline sf::Sound & GetSFX(
    const std::string & key
)

Get a sound effect object from the map.

Parameters:

  • key of the asset to get

Return: sf::Sound& the sound effect

function GetFont

static inline sf::Font & GetFont(
    const std::string & key
)

Get a font object from the mapb.

Parameters:

  • key of the asset to get

Return: sf::Font& the font

function GetKeybind

static inline sf::Keyboard::Key & GetKeybind(
    const std::string & key
)

function LoadIniFile

static inline void LoadIniFile(
    const std::filesystem::path & path
)

Load a .ini file with boost loading assets into the map.

function getInstance

static AssetLoader & getInstance()

the instance of the AssetLoader object

function smartPath

static inline std::filesystem::path smartPath(
    std::filesystem::path path
)

function smartPath

template <class... Args>
static inline std::filesystem::path smartPath(
    std::filesystem::path path,
    std::string_view next,
    Args... args
)

function display_key_from_map

static inline void display_key_from_map()

Updated on 2022-11-13 at 17:21:37 +0100

Last updated