4 * Created on: Aug 5, 2012
8 #include "PartyLayout.h"
10 #include "../loader/Interpreter.h"
11 #include "../loader/TypeDescription.h"
13 using geometry::Vector;
14 using loader::FieldDescription;
15 using loader::Interpreter;
16 using loader::TypeDescription;
21 Vector<int> PartyLayout::CalculatePosition(int index, int width, int height) const {
22 assert(index >= 0 && index < numPositions);
24 positions[index].X() * width / 255,
25 positions[index].Y() * height / 223
29 void PartyLayout::CalculatePositions(int width, int height, vector<Vector<int> > &dest) const {
31 dest.reserve(numPositions);
32 for (int i(0); i < numPositions; ++i) {
33 dest.push_back(Vector<int>(
34 positions[i].X() * width / 255,
35 positions[i].Y() * height / 223
41 void PartyLayout::CreateTypeDescription() {
44 TypeDescription &td(TypeDescription::Create(TYPE_ID, "PartyLayout"));
45 td.SetDescription("Positions of party members");
46 td.SetConstructor(&Construct);
47 td.SetSize(sizeof(PartyLayout));
49 td.AddField("positions", FieldDescription(((char *)&p.positions) - ((char *)&p), Interpreter::VECTOR_ID).SetReferenced().SetAggregate().SetDescription("the members' positions"));
52 void PartyLayout::Construct(void *data) {
53 new (data) PartyLayout;