-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtextures.cpp
More file actions
43 lines (38 loc) · 1.66 KB
/
Copy pathtextures.cpp
File metadata and controls
43 lines (38 loc) · 1.66 KB
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
#include <unordered_map>
#include <string>
#include "textures.h"
#include <iostream>
#include <SFML/Graphics.hpp>
using namespace std;
unordered_map<string, sf::Texture> TextureManager::UIElements;
void TextureManager::loadUIElements() {
//Optimization-> want to use constexpr, make a compile-time key lookup with a constexpr function
const std::unordered_map<std::string, std::string> filePaths = {
{"button_red", "images/button_red.png"},
{"button_green", "images/button_green.png"},
{"button_enter", "images/button_enter.png"},
{"button_home", "images/button_home.png"},
{"button_back", "images/button_back.png"},
{"button_settings", "images/button_settings.png"},
{"button_list", "images/button_list.png"},
{"button_add", "images/button_add.png"},
{"back_page_button", "images/back_page_button.png"},
{"next_page_button", "images/next_page_button.png"},
{"button_hazard", "images/button_hazard.png"},
{"button_trash", "images/trash_button.png"},
{"button_buy", "images/button_buy.png"},
{"button_post", "images/button_post.png"},
{"button_transfer", "images/button_transfer.png"},
{"logo_apple", "images/logo_apple.png"},
{"logo_samsung", "images/logo_samsung.png"},
};
for (const auto &[name, directory] : filePaths) {
if (UIElements[name].loadFromFile(directory)) {
cout << "Loaded Image -> " << name << endl;
}
}
cout << "All images and buttons loaded." << endl << endl;
}
sf::Texture& TextureManager::getUIElement(const string &name) {
return UIElements[name];
}