ManaPlus
Functions
Loader Namespace Reference

Functions

AtlasResourcegetAtlas (const std::string &name, const StringVect &files)
 
ResourcegetEmptyAtlas (const std::string &name, const StringVect &files)
 
ImagegetImage (const std::string &idPath)
 
ImageSetgetImageSet (const std::string &imagePath, const int w, const int h)
 
SDLMusicgetMusic (const std::string &idPath)
 
ImagegetRescaled (const Image *const image, const int width, const int height)
 
ResourcegetShader (const unsigned int type, const std::string &name)
 
ResourcegetShaderProgram (const std::string &vertex, const std::string &fragment, const bool isNewShader)
 
SoundEffectgetSoundEffect (const std::string &idPath)
 
SpriteDefgetSprite (const std::string &path, const int variant)
 
ImagegetSubImage (Image *const parent, const int x, const int y, const int width, const int height)
 
ImageSetgetSubImageSet (Image *const parent, const int width, const int height)
 
WalkLayergetWalkLayer (const std::string &name, Map *const map)
 
XML::DocumentgetXml (const std::string &idPath, const UseVirtFs useResman, const SkipError skipError)
 

Function Documentation

◆ getAtlas()

AtlasResource * Loader::getAtlas ( const std::string &  name,
const StringVect files 
)

Definition at line 56 of file atlasloader.cpp.

58 {
59  AtlasLoader rl = { name, &files };
60  return static_cast<AtlasResource*>(ResourceManager::get(
61  "atlas_" + name,
62  AtlasLoader::load, &rl));
63 }
Resource * get(const std::string &idPath, generator fun, const void *const data)
static Resource * load(const void *const v)
Definition: atlasloader.cpp:42

References ResourceManager::get(), and AtlasLoader::load().

◆ getEmptyAtlas()

Resource * Loader::getEmptyAtlas ( const std::string &  name,
const StringVect files 
)

Definition at line 57 of file emptyatlasloader.cpp.

59 {
60  EmptyAtlasLoader rl = { name, &files };
61  return ResourceManager::get("atlas_" + name, EmptyAtlasLoader::load, &rl);
62 }
static Resource * load(const void *const v)

References ResourceManager::get(), and EmptyAtlasLoader::load().

Referenced by MapReader::loadEmptyAtlas().

◆ getImage()

Image * Loader::getImage ( const std::string &  idPath)

◆ getImageSet()

ImageSet * Loader::getImageSet ( const std::string &  imagePath,
const int  w,
const int  h 
)

Creates a image set based on the image referenced by the given path and the supplied sprite sizes

Definition at line 66 of file imagesetloader.cpp.

69 {
70  ImageSetLoader rl = { imagePath, w, h };
71  const std::string str = std::string(
72  imagePath).append(
73  "[").append(toString(
74  w)).append(
75  "x").append(toString(
76  h)).append(
77  "]");
78  return static_cast<ImageSet*>(ResourceManager::get(str,
79  ImageSetLoader::load, &rl));
80 }
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
static Resource * load(const void *const v)

References ResourceManager::get(), ImageSetLoader::load(), and Catch::toString().

Referenced by BrowserBox::BrowserBox(), ParticleEmitter::getImageSet(), Theme::getImageSetFromTheme(), SimpleAnimation::initializeAnimation(), SpriteDef::loadImageSet(), and StaticBrowserBox::StaticBrowserBox().

◆ getMusic()

SDLMusic * Loader::getMusic ( const std::string &  idPath)

Convenience wrapper around ResourceManager::get for loading songs.

Definition at line 74 of file musicloader.cpp.

75 {
76  ResourceLoader rl = { idPath };
77  return static_cast<SDLMusic*>(ResourceManager::get(
78  "music_" + idPath, ResourceLoader::load, &rl));
79 }

References ResourceManager::get(), and AvatarDB::load().

Referenced by loadMusic().

◆ getRescaled()

Image * Loader::getRescaled ( const Image *const  image,
const int  width,
const int  height 
)

Definition at line 65 of file rescaledloader.cpp.

68 {
69  if (image == nullptr)
70  return nullptr;
71 
72  const std::string idPath = image->mIdPath + strprintf(
73  "_rescaled%dx%d", width, height);
74  const RescaledLoader rl = { image, width, height };
75  return static_cast<Image *>(
77 }
std::string strprintf(const char *const format,...)

References ResourceManager::get(), AvatarDB::load(), and strprintf().

Referenced by AmbientLayer::AmbientLayer(), and Desktop::setBestFittingWallpaper().

◆ getShader()

Resource * Loader::getShader ( const unsigned int  type,
const std::string &  name 
)

Definition at line 61 of file shaderloader.cpp.

63 {
64  ShaderLoader rl = { name, type };
65  return ResourceManager::get("shader_" + name, ShaderLoader::load, &rl);
66 }

References ResourceManager::get(), and AvatarDB::load().

Referenced by ShadersManager::createProgram().

◆ getShaderProgram()

Resource * Loader::getShaderProgram ( const std::string &  vertex,
const std::string &  fragment,
const bool  isNewShader 
)

Definition at line 65 of file shaderprogramloader.cpp.

68 {
69  ShaderProgramLoader rl = { vertex, fragment, isNewShader };
70  return ResourceManager::get("program_" + vertex + " + " + fragment,
72 }

References ResourceManager::get(), and AvatarDB::load().

◆ getSoundEffect()

SoundEffect * Loader::getSoundEffect ( const std::string &  idPath)

Convenience wrapper around ResourceManager::get for loading samples.

Definition at line 71 of file soundloader.cpp.

72 {
73  ResourceLoader rl = { idPath };
74  return static_cast<SoundEffect*>(ResourceManager::get(
75  "sound_" + idPath, ResourceLoader::load, &rl));
76 }

References ResourceManager::get(), and AvatarDB::load().

Referenced by SoundManager::playGuiSfx(), and SoundManager::playSfx().

◆ getSprite()

SpriteDef * Loader::getSprite ( const std::string &  path,
const int  variant 
)

Creates a sprite definition based on a given path and the supplied variant.

Definition at line 58 of file spritedefloader.cpp.

60 {
61  SpriteDefLoader rl = { path, variant};
62  const std::string str = std::string(
63  "sprite_").append(
64  path).append(
65  "[").append(toString(
66  variant).append(
67  "]"));
68  return static_cast<SpriteDef*>(ResourceManager::get(str,
69  SpriteDefLoader::load, &rl));
70 }

References ResourceManager::get(), AvatarDB::load(), and Catch::toString().

Referenced by AnimationDelayLoad::load(), and AnimatedSprite::load().

◆ getSubImage()

Image * Loader::getSubImage ( Image *const  parent,
const int  x,
const int  y,
const int  width,
const int  height 
)

Definition at line 68 of file subimageloader.cpp.

73 {
74  if (parent == nullptr)
75  return nullptr;
76 
77  const SubImageLoader rl = { parent, x, y, width, height};
78 
79  const std::string str = std::string(parent->mIdPath).append(
80  ",[").append(
81  toString(x)).append(
82  ",").append(
83  toString(y)).append(
84  ",").append(
85  toString(width)).append(
86  "x").append(
87  toString(height)).append(
88  "]");
89  return static_cast<Image*>(ResourceManager::get(str,
90  SubImageLoader::load, &rl));
91 }

References ResourceManager::get(), AvatarDB::load(), Catch::toString(), x, and y.

Referenced by ParticleEmitter::getImageSet(), SkinHelper::loadList(), and ParticleEmitter::ParticleEmitter().

◆ getSubImageSet()

ImageSet * Loader::getSubImageSet ( Image *const  parent,
const int  width,
const int  height 
)

Definition at line 65 of file subimagesetloader.cpp.

68 {
69  if (parent == nullptr)
70  return nullptr;
71 
72  const SubImageSetLoader rl = { parent, width, height };
73  std::string str = std::string(
74  parent->mIdPath).append(
75  ", set[").append(toString(
76  width)).append(
77  "x").append(toString(
78  height)).append(
79  "]");
80  return static_cast<ImageSet*>(ResourceManager::get(str,
82 }

References ResourceManager::get(), AvatarDB::load(), and Catch::toString().

Referenced by ParticleEmitter::getImageSet(), and Theme::getImageSetFromThemeXml().

◆ getWalkLayer()

WalkLayer * Loader::getWalkLayer ( const std::string &  name,
Map *const  map 
)

Definition at line 58 of file walklayerloader.cpp.

60 {
61  WalkLayerLoader rl = {name, map};
62  return static_cast<WalkLayer*>(ResourceManager::get("walklayer_" + name,
63  WalkLayerLoader::load, &rl));
64 }
static Resource * load(const void *const v)

References ResourceManager::get(), and WalkLayerLoader::load().

◆ getXml()

XML::Document * Loader::getXml ( const std::string &  idPath,
const UseVirtFs  useResman,
const SkipError  skipError 
)

Definition at line 56 of file xmlloader.cpp.

59 {
60  ResourceLoader rl = { idPath, useResman, skipError };
61  return static_cast<XML::Document*>(ResourceManager::get(
62  "xml_" + idPath, ResourceLoader::load, &rl));
63 }

References ResourceManager::get(), and AvatarDB::load().

Referenced by Particle::addEffect(), ParticleEngine::addEffect(), SpriteDef::includeSprite(), SpriteDef::load(), Theme::loadColors(), Theme::loadInfo(), and Theme::readSkin().