]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/PartyLayout.cpp
removed stupid file headers that eclipse put in
[l2e.git] / src / battle / PartyLayout.cpp
index 6389327528bd77df1e4c233147b2d5ad51609d93..bf8b3e8623d3d6d3987d6ba3075b264aa32d8a6d 100644 (file)
@@ -1,12 +1,49 @@
-/*
- * PartyLayout.cpp
- *
- *  Created on: Aug 5, 2012
- *      Author: holy
- */
-
 #include "PartyLayout.h"
 
+#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;
+}
+
 }