-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlevels.cpp
More file actions
37 lines (31 loc) · 922 Bytes
/
levels.cpp
File metadata and controls
37 lines (31 loc) · 922 Bytes
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
#include "levels.h"
LevelsManager::LevelsManager() : nLevels(0)
{
cfg = SingletonConfig::config();
}
int LevelsManager::Initialize()
{
lLib = new Json::Value;
std::ifstream file((*cfg)["Levels"]["List"].asCString(), std::ifstream::in);
file >> *lLib;
file.close();
return 0;
}
void LevelsManager::PreLoadLevels()
{
for (Json::ValueIterator it1 = lLib->begin(); it1 != lLib->end(); it1++) {
for (Json::ValueIterator it2 = it1->begin(); it2 != it1->end(); it2++) {
nLevels++;
}
}
levels = new LevelsMap(nLevels);
LevelData * load;
for (Json::ValueIterator it1 = lLib->begin(); it1 != lLib->end(); it1++) {
for (Json::ValueIterator it2 = it1->begin(); it2 != it1->end(); it2++) {
load = new LevelData;
load->Initialize(it2->asCString());
levels->emplace((*load->json)["Name"].asCString(), load);
}
}
std::cout << "Loaded " << nLevels << " levels.\n";
}