git repos / blockattack-game

blame: source/code/sago/SagoDataHolder.hpp

normal view · raw

82da8a1c sago007 2015-12-19 18:00 1
/*
47fef8e8 sago007 2016-11-24 21:37 2
Copyright (c) 2015 Poul Sander
47fef8e8 sago007 2016-11-24 21:37 3
47fef8e8 sago007 2016-11-24 21:37 4
Permission is hereby granted, free of charge, to any person
47fef8e8 sago007 2016-11-24 21:37 5
obtaining a copy of this software and associated documentation files
47fef8e8 sago007 2016-11-24 21:37 6
(the "Software"), to deal in the Software without restriction,
47fef8e8 sago007 2016-11-24 21:37 7
including without limitation the rights to use, copy, modify, merge,
47fef8e8 sago007 2016-11-24 21:37 8
publish, distribute, sublicense, and/or sell copies of the Software,
47fef8e8 sago007 2016-11-24 21:37 9
and to permit persons to whom the Software is furnished to do so,
47fef8e8 sago007 2016-11-24 21:37 10
subject to the following conditions:
47fef8e8 sago007 2016-11-24 21:37 11
47fef8e8 sago007 2016-11-24 21:37 12
The above copyright notice and this permission notice shall be
47fef8e8 sago007 2016-11-24 21:37 13
included in all copies or substantial portions of the Software.
47fef8e8 sago007 2016-11-24 21:37 14
47fef8e8 sago007 2016-11-24 21:37 15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
47fef8e8 sago007 2016-11-24 21:37 16
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
47fef8e8 sago007 2016-11-24 21:37 17
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
47fef8e8 sago007 2016-11-24 21:37 18
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
47fef8e8 sago007 2016-11-24 21:37 19
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
47fef8e8 sago007 2016-11-24 21:37 20
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
47fef8e8 sago007 2016-11-24 21:37 21
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
47fef8e8 sago007 2016-11-24 21:37 22
SOFTWARE.
82da8a1c sago007 2015-12-19 18:00 23
*/
82da8a1c sago007 2015-12-19 18:00 24
82da8a1c sago007 2015-12-19 18:00 25
#include "SDL.h"
82da8a1c sago007 2015-12-19 18:00 26
#include <SDL_mixer.h>      //Used for sound & music
82da8a1c sago007 2015-12-19 18:00 27
#include <SDL_image.h>      //To load PNG images!
82da8a1c sago007 2015-12-19 18:00 28
#include <SDL_ttf.h>
82da8a1c sago007 2015-12-19 18:00 29
#include <physfs.h>         //Abstract file system. To use containers
82da8a1c sago007 2015-12-19 18:00 30
#include <string>
82da8a1c sago007 2015-12-19 18:00 31
82da8a1c sago007 2015-12-19 18:00 32
#ifndef TEXTUREHOLDER_HPP
82da8a1c sago007 2015-12-19 18:00 33
#define	TEXTUREHOLDER_HPP
82da8a1c sago007 2015-12-19 18:00 34
82da8a1c sago007 2015-12-19 18:00 35
namespace sago {
82da8a1c sago007 2015-12-19 18:00 36
82da8a1c sago007 2015-12-19 18:00 37
class SagoDataHolder {
82da8a1c sago007 2015-12-19 18:00 38
public:
82da8a1c sago007 2015-12-19 18:00 39
	SagoDataHolder(SDL_Renderer* renderer);
82da8a1c sago007 2015-12-19 18:00 40
	/**
82da8a1c sago007 2015-12-19 18:00 41
	 * Return a pointer to the given texture. The pointer is valid for the lifetime of SagoDataHolder object it was taken from.
47fef8e8 sago007 2016-11-24 21:37 42
	 * @param textureName Name of the texture
47fef8e8 sago007 2016-11-24 21:37 43
	 * @return  Pointer to the loaded texture
47fef8e8 sago007 2016-11-24 21:37 44
	 */
82da8a1c sago007 2015-12-19 18:00 45
	SDL_Texture* getTexturePtr(const std::string &textureName) const;
82da8a1c sago007 2015-12-19 18:00 46
	TTF_Font* getFontPtr(const std::string &fontName, int ptsize) const;
82da8a1c sago007 2015-12-19 18:00 47
	Mix_Music* getMusicPtr(const std::string &musicName) const;
82da8a1c sago007 2015-12-19 18:00 48
	Mix_Chunk* getSoundPtr(const std::string &soundName) const;
e297a2e8 sago007 2016-01-21 18:07 49
	void setVerbose(bool value);
82da8a1c sago007 2015-12-19 18:00 50
	virtual ~SagoDataHolder();
82da8a1c sago007 2015-12-19 18:00 51
private:
82da8a1c sago007 2015-12-19 18:00 52
	SagoDataHolder(const SagoDataHolder& base) = delete;
47fef8e8 sago007 2016-11-24 21:37 53
	SagoDataHolder& operator=(const SagoDataHolder& base) = delete;
82da8a1c sago007 2015-12-19 18:00 54
	struct SagoDataHolderData;
82da8a1c sago007 2015-12-19 18:00 55
	mutable SagoDataHolderData *data;
82da8a1c sago007 2015-12-19 18:00 56
};
82da8a1c sago007 2015-12-19 18:00 57
82da8a1c sago007 2015-12-19 18:00 58
} //namespace sago
82da8a1c sago007 2015-12-19 18:00 59
82da8a1c sago007 2015-12-19 18:00 60
#endif	/* TEXTUREHOLDER_HPP */
82da8a1c sago007 2015-12-19 18:00 61
1970-01-01 00:00 62