/
Material_Manager.hpp
52 lines (37 loc) · 1.26 KB
/
Material_Manager.hpp
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
#ifndef MATERIAL_MANAGER_CPP_
#define MATERIAL_MANAGER_CPP_
#include "ConstantExpressionVariable.hpp"
#include <vector>
#include <string>
#include <array>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <boost/filesystem.hpp>
#include <boost/range/iterator_range.hpp>
namespace fs = boost::filesystem;
namespace {
//各素材ファイルパス取得
std::vector<std::string> AllFilePath(const std::string& Path) {
std::vector<std::string> Container;
const fs::path path(Path);
for (const auto& p : boost::make_iterator_range(fs::recursive_directory_iterator(path), {})) {
if (!fs::is_directory(p.path()))
Container.emplace_back(std::move(Path + "/" + p.path().filename().string()));
}
return Container;
}
}
//各種素材読込テンプレート関数
template <typename T, typename Func>
std::vector<T> MaterialLoad(std::vector<T> Material, const std::string& Path, Func&& Loader) noexcept {
//サウンドデータの読み込み形式
DxLib::SetCreateSoundDataType(DX_SOUNDDATATYPE_MEMPRESS);
std::vector<std::string> Container = AllFilePath(Path);
for (auto&& c : Container)
Material.emplace_back(std::move(Loader(c.c_str())));
return Material;
}
//スクリプト読込関数
std::vector<std::string> ScriptRead(unsigned int EndFlag) noexcept;
#endif // MATERIAL_MANAGER_CPP_