-
Notifications
You must be signed in to change notification settings - Fork 20
/
nx.cpp
78 lines (78 loc) · 3.49 KB
/
nx.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
67
68
69
70
71
72
73
74
75
76
77
78
//////////////////////////////////////////////////////////////////////////////
// NoLifeNx - Part of the NoLifeStory project //
// Copyright © 2013 Peter Atashian //
// //
// This program is free software: you can redistribute it and/or modify //
// it under the terms of the GNU Affero General Public License as //
// published by the Free Software Foundation, either version 3 of the //
// License, or (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU Affero General Public License for more details. //
// //
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
//////////////////////////////////////////////////////////////////////////////
#include "nx.hpp"
#include "file.hpp"
#include "node.hpp"
#include <fstream>
#include <vector>
#include <memory>
#include <stdexcept>
namespace nl {
namespace nx {
std::vector<std::unique_ptr<file>> files;
bool exists(std::string name) {
return std::ifstream(name).is_open();
}
node add_file(std::string name) {
if (!exists(name))
return {};
files.emplace_back(new file(name));
return *files.back();
}
node base, character, effect, etc, item, map, mob, morph, npc, quest, reactor, skill, sound, string, tamingmob, ui;
void load_all() {
if (exists("Base.nx")) {
base = add_file("Base.nx");
character = add_file("Character.nx");
effect = add_file("Effect.nx");
etc = add_file("Etc.nx");
item = add_file("Item.nx");
map = add_file("Map.nx");
mob = add_file("Mob.nx");
morph = add_file("Morph.nx");
npc = add_file("Npc.nx");
quest = add_file("Quest.nx");
reactor = add_file("Reactor.nx");
skill = add_file("Skill.nx");
sound = add_file("Sound.nx");
string = add_file("String.nx");
tamingmob = add_file("TamingMob.nx");
ui = add_file("UI.nx");
} else if (exists("Data.nx")) {
base = add_file("Data.nx");
character = base["Character"];
effect = base["Effect"];
etc = base["Etc"];
item = base["Item"];
map = base["Map"];
mob = base["Mob"];
morph = base["Morph"];
npc = base["Npc"];
quest = base["Quest"];
reactor = base["Reactor"];
skill = base["Skill"];
sound = base["Sound"];
string = base["String"];
tamingmob = base["TamingMob"];
ui = base["UI"];
} else {
throw std::runtime_error("Failed to locate nx files.");
}
}
}
}