-/*
- * PartyLayout.cpp
- *
- * Created on: Aug 5, 2012
- * Author: holy
- */
-
#include "PartyLayout.h"
-using geometry::Point;
+#include "../loader/Interpreter.h"
+#include "../loader/TypeDescription.h"
+
+using geometry::Vector;
+using loader::FieldDescription;
+using loader::Interpreter;
+using loader::TypeDescription;
using std::vector;
namespace battle {
+Vector<int> PartyLayout::CalculatePosition(int index, int width, int height) const {
+ assert(index >= 0 && index < numPositions);
+ return Vector<int>(
+ positions[index].X() * width / 255,
+ positions[index].Y() * height / 223
+ );
+}
+
+void PartyLayout::CalculatePositions(int width, int height, vector<Vector<int> > &dest) const {
+ dest.clear();
+ dest.reserve(numPositions);
+ for (int i(0); i < numPositions; ++i) {
+ dest.push_back(Vector<int>(
+ positions[i].X() * width / 255,
+ positions[i].Y() * height / 223
+ ));
+ }
+}
+
+
+void PartyLayout::CreateTypeDescription() {
+ PartyLayout p;
+
+ TypeDescription &td(TypeDescription::Create(TYPE_ID, "PartyLayout"));
+ td.SetDescription("Positions of party members");
+ td.SetConstructor(&Construct);
+ td.SetSize(sizeof(PartyLayout));
+
+ td.AddField("positions", FieldDescription(((char *)&p.positions) - ((char *)&p), Interpreter::VECTOR_ID).SetReferenced().SetAggregate().SetDescription("the members' positions"));
+}
+
+void PartyLayout::Construct(void *data) {
+ new (data) PartyLayout;
+}
+
}