4 * Created on: Aug 5, 2012
8 #include "PartyLayout.h"
10 #include "../loader/TypeDescription.h"
12 using geometry::Vector;
13 using loader::FieldDescription;
14 using loader::TypeDescription;
19 Vector<int> PartyLayout::CalculatePosition(int index, int width, int height) const {
20 assert(index >= 0 && index < numPositions);
22 positions[index].X() * width / 255,
23 positions[index].Y() * height / 223
27 void PartyLayout::CalculatePositions(int width, int height, vector<Vector<int> > &dest) const {
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
39 void PartyLayout::CreateTypeDescription() {
42 int vectorId(TypeDescription::GetTypeId("Vector"));
44 TypeDescription &td(TypeDescription::CreateOrGet("PartyLayout"));
45 td.SetConstructor(&Construct);
46 td.SetSize(sizeof(PartyLayout));
48 td.AddField("positions", FieldDescription(((char *)&p.positions) - ((char *)&p), vectorId, true, true));
51 void PartyLayout::Construct(void *data) {
52 new (data) PartyLayout;