-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcstreamwriter.cpp
158 lines (124 loc) · 4.44 KB
/
cstreamwriter.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#include "cstreamwriter.h"
CStreamWriter::CStreamWriter(QFile* file)
{
this->file = file;
tabCount = 0;
stream = new QTextStream(file);
}
void CStreamWriter::writeEndl()
{
*stream << endl;
}
void CStreamWriter::writeInclude(QString file)
{
*stream << "#include \"" << file << "\"" << endl;
}
void CStreamWriter::writeNode(Node* n, QString prefix, int index, bool comma)
{
*stream << "\t{ " << prefix << "_path_" << index << ", " << n->getAreaId() << ", " << n->getUnk0()
<< ", " << n->getUnk1() << ", " << n->getIconId() << ", " << n->getSettings() << ", {0, 0, 0} }";
if (comma)
*stream << ",";
*stream << endl;
}
void CStreamWriter::writeNodes(QList<Node*>* nodes, QString prefix)
{
writePaths(nodes, prefix);
*stream << "node " << prefix << "_nodes[] =" << endl << "{" << endl;
for (int i = 0; i < nodes->length(); i++)
{
Node* n = nodes->at(i);
bool comma = (i != (nodes->length()-1));
writeNode(n, prefix, i, comma);
}
*stream << "};" << endl;
}
void CStreamWriter::writePaths(QList<Node *> *nodes, QString prefix)
{
for (int i = 0; i < nodes->length(); i++)
{
Node* n = nodes->at(i);
*stream << "path " << prefix << "_path_" << i << "[] =" << endl << "{" << endl;
for (int j = 0; j < n->pathList()->count(); j++)
{
Path* p = n->pathList()->at(j);
*stream << "\t{" << p->endingNodeId << ", " << p->animationId << ", " << p->settings << ", 0}," << endl;
}
*stream << "\t{255, 0, 0, 0}" << endl << "};" << endl << endl;
}
}
void CStreamWriter::writeVisibleNode(Node* n, bool comma)
{
*stream << "\t{ "
<< "{" << n->getUnlock(0) << ", " << n->getUnlock(1) << ", " << n->getUnlock(2) << ", " << n->getUnlock(3) << "}, "
<< "{" << n->getUnlockSecret(0) << ", " << n->getUnlockSecret(1) << ", " << n->getUnlockSecret(2) << ", " << n->getUnlockSecret(3) << "}, "
<< n->getCameraScroll() << ", "
<< n->getCameraScrollSecret() << ", "
<< n->getx() << ", "
<< n->gety() << ", "
<< n->getz()
<< " }";
if (comma)
*stream << ",";
*stream << endl;
}
void CStreamWriter::writeVisibleNodes(QList<Node*>* nodes, QString prefix)
{
*stream << "visibleNode " << prefix << "_visibleNodes[] =" << endl << "{" << endl;
for (int i = 0; i < nodes->length(); i++)
{
Node* n = nodes->at(i);
bool comma = (i != (nodes->length()-1));
writeVisibleNode(n, comma);
}
*stream << "};" << endl;
}
void CStreamWriter::writePathBehavior(PathBehavior* p, bool comma)
{
*stream << "\t{" << p->getAnimationId() << ", " << p->getStarCoinCost() << ", " << p->getSettings() << ", 0}";
if (comma)
*stream << ",";
*stream << endl;
}
void CStreamWriter::writePathBehaviors(QList<PathBehavior*>* paths, QString prefix)
{
*stream << "pathBehavior " << prefix << "_pathBehaviors[] =" << endl << "{" << endl;
for (int i = 0; i < paths->length(); i++)
{
PathBehavior* p = paths->at(i);
bool comma = (i != (paths->length()-1));
writePathBehavior(p, comma);
}
*stream << "};" << endl;
}
void CStreamWriter::writeMapObject(MapObject* mapObject)
{
*stream << "\t{ " << mapObject->getNodeId() << ", {0, 0, 0}, " << mapObject->getx()*0x1000 << ", " << mapObject->gety()*0x1000 << ", " << mapObject->getz()*0x1000 << " }," << endl;
}
void CStreamWriter::writeMapObjects(QList<MapObject*>* mapObjects, quint8 type, QString prefix)
{
QString typeName;
if (type == 1)
typeName = "towersCastles";
else if (type == 2)
typeName = "mushroomHouses";
else
typeName = "starCoinSigns";
*stream << "mapObject " << prefix << "_" << typeName << "[] =" << endl << "{" << endl;
for (int i = 0; i < mapObjects->length(); i++)
{
MapObject* o = mapObjects->at(i);
writeMapObject(o);
}
if (type == 0)
*stream << "\t{ 0x00, {0x00, 0x00, 0x00}, 0, 0, 0 }" << endl;
else
*stream << "\t{ 0xFF, {0xFF, 0xFF, 0xFF}, 0, 0, 0 }" << endl;
*stream << "};" << endl;
}
void CStreamWriter::writeSprites(Map* map, QString prefix)
{
*stream << "sprites " << prefix << "_sprites =" << endl << "{" << endl;
*stream << "\t" << map->sprite1StartNode << ", " << map->sprite1Type << ", " << map->sprite2StartNode << ", " << map->sprite2Type << endl;
*stream << "};" << endl;
}