-
Notifications
You must be signed in to change notification settings - Fork 0
/
Resources.cpp
66 lines (52 loc) · 1.8 KB
/
Resources.cpp
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "stdafx.h"
#include "Resources.h"
Resources* Resources::instance_ = 0;
Resources* Resources::Instance()
{
if(instance_ == 0)
instance_ = new Resources;
return instance_;
}
Resources::Resources()
{
//load fonts
sf::Font arial;
arial.loadFromFile("resources/fonts/arial.ttf");
fontBank.insert(std::pair<std::string, sf::Font>("Arial", arial));
////load textures
//sf::Texture scrub1;
//scrub1.loadFromFile("images/scrub1.png");
//textureBank.insert(std::pair<std::string, sf::Texture>("Scrub1", scrub1));
//sf::Texture boss1;
//boss1.loadFromFile("images/boss1.png");
//textureBank.insert(std::pair<std::string, sf::Texture>("Boss1", boss1));
////load sounds
//sf::SoundBuffer intoScrub;
//intoScrub.loadFromFile("sounds/sfxr/intobattle.wav");
//sbBank.insert(std::pair<std::string, sf::SoundBuffer>("IntoScrub", intoScrub));
//sf::SoundBuffer intoBoss;
//intoBoss.loadFromFile("sounds/sfxr/intobattle2.wav");
//sbBank.insert(std::pair<std::string, sf::SoundBuffer>("IntoBoss", intoBoss));
//insert dummy variables to give default load conditions
fontBank.insert(std::pair<std::string, sf::Font>("zzzzzzz", sf::Font()));
textureBank.insert(std::pair<std::string, sf::Texture>("zzzzzz", sf::Texture()));
sbBank.insert(std::pair<std::string, sf::SoundBuffer>("zzzzzzz", sf::SoundBuffer()));
}
const sf::Font& Resources::FontBank(sf::String name)
{
if(fontBank.find(name)==fontBank.end())
return sf::Font();
return instance_->fontBank.at(name);
}
const sf::Texture& Resources::TextureBank(sf::String name)
{
if(textureBank.find(name)==textureBank.end())
return sf::Texture();
return instance_->textureBank.at(name);
}
const sf::SoundBuffer& Resources::SoundBank(const std::string name)
{
if(sbBank.find(name)==sbBank.end())
return sf::SoundBuffer();
return instance_->sbBank.at(name);
}