X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FPartyLayout.cpp;h=bf8b3e8623d3d6d3987d6ba3075b264aa32d8a6d;hb=cc3d698b8c1ad09d7a3f9e3f28bc84e0ac1735ea;hp=e1fd33ffd0953c12083c63d1882a48fbae0cf873;hpb=95bfa881f3fa427b67d9ce21e6a10f80f7be5439;p=l2e.git diff --git a/src/battle/PartyLayout.cpp b/src/battle/PartyLayout.cpp index e1fd33f..bf8b3e8 100644 --- a/src/battle/PartyLayout.cpp +++ b/src/battle/PartyLayout.cpp @@ -1,15 +1,49 @@ -/* - * 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 PartyLayout::CalculatePosition(int index, int width, int height) const { + assert(index >= 0 && index < numPositions); + return Vector( + positions[index].X() * width / 255, + positions[index].Y() * height / 223 + ); +} + +void PartyLayout::CalculatePositions(int width, int height, vector > &dest) const { + dest.clear(); + dest.reserve(numPositions); + for (int i(0); i < numPositions; ++i) { + dest.push_back(Vector( + 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; +} + }