-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActions.cpp
137 lines (135 loc) · 2.64 KB
/
Actions.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include "Common.h"
void Extension::ReturnToRoot()
{
cur = root;
}
void Extension::EnterSubnode(const TCHAR *Name)
{
CreateSubnode(Name);
cur = cur->nm[Name];
}
void Extension::GotoNodeByID(int ID)
{
if(SDNode::Nodes.find(ID) != SDNode::Nodes.end())
{
cur = SDNode::Nodes.find(ID)->second;
}
}
void Extension::CreateSubnode(const TCHAR *Name)
{
if(cur->nm.find(Name) == cur->nm.end())
{
cur->nm[Name] = new SDNode();
}
}
void Extension::AddNodeByID(int ID, const TCHAR *Name)
{
if(SDNode::Nodes.find(ID) != SDNode::Nodes.end())
{
cur->nm[Name] = SDNode::Nodes.find(ID)->second;
}
}
void Extension::SetInt(const TCHAR *Name, int Value)
{
cur->im[Name] = Value;
}
void Extension::SetFloat(const TCHAR *Name, float Value)
{
cur->fm[Name] = Value;
}
void Extension::SetString(const TCHAR *Name, const TCHAR *String)
{
cur->sm[Name] = String;
}
void Extension::IterateNodes()
{
SDNode::Nodes_t::const_iterator it = SDNode::Nodes.begin();
for(Nit = ⁢ it != SDNode::Nodes.end(); ++it)
{
Runtime.GenerateEvent(TOnNode);
}
Nit = 0;
}
void Extension::IterateSubnodes()
{
SDNode *c = cur;
SDNode::nmt::iterator it = c->nm.begin();
nit.push_back(&it);
for(; it != c->nm.end(); ++it)
{
Runtime.GenerateEvent(TOnSubnode);
}
nit.pop_back();
}
void Extension::IterateInts()
{
SDNode *c = cur;
SDNode::imt::iterator it = c->im.begin();
for(iit = ⁢ it != c->im.end(); ++it)
{
Runtime.GenerateEvent(TOnInt);
}
iit = 0;
}
void Extension::IterateFloats()
{
SDNode *c = cur;
SDNode::fmt::iterator it = c->fm.begin();
for(fit = ⁢ it != c->fm.end(); ++it)
{
Runtime.GenerateEvent(TOnFloat);
}
fit = 0;
}
void Extension::IterateStrings()
{
SDNode *c = cur;
SDNode::smt::iterator it = c->sm.begin();
for(sit = ⁢ it != c->sm.end(); ++it)
{
Runtime.GenerateEvent(TOnString);
}
sit = 0;
}
void Extension::RemoveSubnode(const TCHAR *Name)
{
cur->nm.erase(Name);
}
void Extension::RemoveNodeByID(int ID)
{
if(ID == 0) return;
if(ID == cur->ID) ReturnToRoot();
for(std::map<int, SDNode *>::const_iterator it = SDNode::Nodes.begin(); it != SDNode::Nodes.end(); ++it)
{
for(SDNode::nmt::iterator jt = it->second->nm.begin(); jt != it->second->nm.end();)
{
if(jt->second->ID == ID)
{
jt = it->second->nm.erase(jt);
}
else ++jt;
}
}
delete SDNode::Nodes.find(ID)->second;
}
void Extension::RemoveInt(const TCHAR *Name)
{
cur->im.erase(Name);
}
void Extension::RemoveFloat(const TCHAR *Name)
{
cur->fm.erase(Name);
}
void Extension::RemoveString(const TCHAR *Name)
{
cur->sm.erase(Name);
}
void Extension::ClearAll()
{
while(SDNode::Nodes.size())
{
delete SDNode::Nodes.begin()->second;
}
root = new SDNode();
cur = root;
}