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 55 of file atlasloader.cpp.

57 {
58  AtlasLoader rl = { name, &files };
59  return static_cast<AtlasResource*>(ResourceManager::get(
60  "atlas_" + name,
61  AtlasLoader::load, &rl));
62 }

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

◆ getEmptyAtlas()

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

Definition at line 56 of file emptyatlasloader.cpp.

58 {
59  EmptyAtlasLoader rl = { name, &files };
60  return ResourceManager::get("atlas_" + name, EmptyAtlasLoader::load, &rl);
61 }

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 65 of file imagesetloader.cpp.

68 {
69  ImageSetLoader rl = { imagePath, w, h };
70  const std::string str = std::string(
71  imagePath).append(
72  "[").append(toString(
73  w)).append(
74  "x").append(toString(
75  h)).append(
76  "]");
77  return static_cast<ImageSet*>(ResourceManager::get(str,
78  ImageSetLoader::load, &rl));
79 }

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 73 of file musicloader.cpp.

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

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 64 of file rescaledloader.cpp.

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

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

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

◆ getShader()

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

Definition at line 60 of file shaderloader.cpp.

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

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 64 of file shaderprogramloader.cpp.

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

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 70 of file soundloader.cpp.

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

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 57 of file spritedefloader.cpp.

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

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 67 of file subimageloader.cpp.

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

References ResourceManager::get(), AvatarDB::load(), Resource::mIdPath, 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 64 of file subimagesetloader.cpp.

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

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

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

◆ getWalkLayer()

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

Definition at line 57 of file walklayerloader.cpp.

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

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

◆ getXml()

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

Definition at line 55 of file xmlloader.cpp.

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

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

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

EmptyAtlasLoader::load
static Resource * load(const void *const v)
Definition: emptyatlasloader.cpp:41
ImageSetLoader::load
static Resource * load(const void *const v)
Definition: imagesetloader.cpp:45
Image
Definition: image.h:67
AtlasResource
Definition: atlasresource.h:32
XML::Document
Definition: libxml.h:52
Catch::toString
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
ImageSetLoader
Definition: imagesetloader.cpp:37
WalkLayerLoader::load
static Resource * load(const void *const v)
Definition: walklayerloader.cpp:43
SDLMusic
Definition: sdlmusic.h:38
strprintf
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
EmptyAtlasLoader
Definition: emptyatlasloader.cpp:34
x
x
Definition: graphics_calcImageRect.hpp:72
AtlasLoader
Definition: atlasloader.cpp:34
SpriteDef
Definition: spritedef.h:40
WalkLayer
Definition: walklayer.h:28
AtlasLoader::load
static Resource * load(const void *const v)
Definition: atlasloader.cpp:41
AvatarDB::load
void load()
Definition: avatardb.cpp:45
ResourceManager::get
Resource * get(const std::string &idPath, generator fun, const void *const data)
Definition: resourcemanager.cpp:427
WalkLayerLoader
Definition: walklayerloader.cpp:36
SoundEffect
Definition: soundeffect.h:38
ImageSet
Definition: imageset.h:37
y
y
Definition: graphics_calcImageRect.hpp:72
Resource::mIdPath
std::string mIdPath
Definition: resource.h:83