]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/PartyLayout.cpp
moved map sprites to data file
[l2e.git] / src / battle / PartyLayout.cpp
index 6389327528bd77df1e4c233147b2d5ad51609d93..c2bb452eec6b7ae0f5edc2f07bc6efc0c1c5b77c 100644 (file)
@@ -7,6 +7,49 @@
 
 #include "PartyLayout.h"
 
+#include "../loader/TypeDescription.h"
+
+using geometry::Vector;
+using loader::FieldDescription;
+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;
+
+       int vectorId(TypeDescription::GetTypeId("Vector"));
+
+       TypeDescription &td(TypeDescription::CreateOrGet("PartyLayout"));
+       td.SetConstructor(&Construct);
+       td.SetSize(sizeof(PartyLayout));
+
+       td.AddField("positions", FieldDescription(((char *)&p.positions) - ((char *)&p), vectorId, true, true));
+}
+
+void PartyLayout::Construct(void *data) {
+       new (data) PartyLayout;
+}
+
 }