From: Daniel Karbach Date: Sun, 9 Sep 2012 11:51:11 +0000 (+0200) Subject: added partial type description of Item X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=3c176f86a79039b2bd9cc59a0c072fe37ef601cc;p=l2e.git added partial type description of Item still missing a way to describe bit fields/flags --- diff --git a/src/common/Item.cpp b/src/common/Item.cpp index f14fd22..e695e8d 100644 --- a/src/common/Item.cpp +++ b/src/common/Item.cpp @@ -7,6 +7,11 @@ #include "Item.h" +#include "../loader/TypeDescription.h" + +using loader::FieldDescription; +using loader::TypeDescription; + namespace common { Item::Item() @@ -24,4 +29,26 @@ Item::Item() } + +void Item::CreateTypeDescription() { + Item i; + TypeDescription &td(TypeDescription::CreateOrGet("Item")); + + td.SetSize(sizeof(Item)); + + int animationId(TypeDescription::GetTypeId("Animation")); + int ikariId(TypeDescription::GetTypeId("Ikari")); + int numberId(TypeDescription::GetTypeId("Number")); + int spriteId(TypeDescription::GetTypeId("Sprite")); + int stringId(TypeDescription::GetTypeId("String")); + int targetsId(TypeDescription::GetTypeId("TargetingMode")); + + td.AddField("name", FieldDescription(((char *)&i.name) - ((char *)&i), stringId, true)); + td.AddField("menuicon", FieldDescription(((char *)&i.menuIcon) - ((char *)&i), spriteId, true)); + // TODO: implement flags/fields (e.g. for usability) + td.AddField("targets", FieldDescription(((char *)&i.targettingMode) - ((char *)&i), targetsId, false)); + td.AddField("ikari", FieldDescription(((char *)&i.ikari) - ((char *)&i), ikariId, true)); + td.AddField("attackanimation", FieldDescription(((char *)&i.attackAnimation) - ((char *)&i), animationId, true)); +} + } diff --git a/src/common/Item.h b/src/common/Item.h index 1d9d51c..5a7a453 100644 --- a/src/common/Item.h +++ b/src/common/Item.h @@ -88,6 +88,8 @@ public: void SetIkari(const Ikari *i) { ikari = i; } void SetAttackAnimation(graphics::Animation *a) { attackAnimation = a; } + static void CreateTypeDescription(); + private: enum Usability { USABILITY_MOST_USEFUL = 1,