]> git.localhorst.tv Git - l2e.git/blob - src/battle/PartyLayout.cpp
converted pseudo-fields into real ones
[l2e.git] / src / battle / PartyLayout.cpp
1 /*
2  * PartyLayout.cpp
3  *
4  *  Created on: Aug 5, 2012
5  *      Author: holy
6  */
7
8 #include "PartyLayout.h"
9
10 #include "../loader/TypeDescription.h"
11
12 using geometry::Vector;
13 using loader::FieldDescription;
14 using loader::TypeDescription;
15 using std::vector;
16
17 namespace battle {
18
19 Vector<int> PartyLayout::CalculatePosition(int index, int width, int height) const {
20         assert(index >= 0 && index < numPositions);
21         return Vector<int>(
22                         positions[index].X() * width / 255,
23                         positions[index].Y() * height / 223
24                         );
25 }
26
27 void PartyLayout::CalculatePositions(int width, int height, vector<Vector<int> > &dest) const {
28         dest.clear();
29         dest.reserve(numPositions);
30         for (int i(0); i < numPositions; ++i) {
31                 dest.push_back(Vector<int>(
32                                 positions[i].X() * width / 255,
33                                 positions[i].Y() * height / 223
34                                 ));
35         }
36 }
37
38
39 void PartyLayout::CreateTypeDescription() {
40         PartyLayout p;
41
42         int vectorId(TypeDescription::GetTypeId("Vector"));
43
44         TypeDescription &td(TypeDescription::CreateOrGet("PartyLayout"));
45         td.SetSize(sizeof(PartyLayout));
46
47         td.AddField("positions", FieldDescription(((char *)&p.positions) - ((char *)&p), vectorId, true, true));
48 }
49
50 }