From: Daniel Karbach Date: Mon, 8 Oct 2012 21:46:34 +0000 (+0200) Subject: added textual type/field descriptions and wiki mode X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=4bc70f5311dcbcca4e6b9e852bbcb19602f50eeb;p=l2e.git added textual type/field descriptions and wiki mode the data types part of the loader source wiki page (http://luke.redirectme.net/redmine/projects/l2e/wiki/LoaderSource) can now be generated by passing -S as an argument. --- diff --git a/src/app/Arguments.cpp b/src/app/Arguments.cpp index 80e5aa0..fa8c851 100644 --- a/src/app/Arguments.cpp +++ b/src/app/Arguments.cpp @@ -14,7 +14,7 @@ namespace app { Arguments::Arguments() : outfile(0) -, dump(false) { +, runlevel(PLAY) { } @@ -25,7 +25,7 @@ void Arguments::Read(int argc, char **argv) { if (arg[0] == '-') { switch (arg[1]) { case 'd': - dump = true; + runlevel = DUMP; break; case 'o': if (i + 1 >= argc) { @@ -33,6 +33,16 @@ void Arguments::Read(int argc, char **argv) { } ++i; outfile = argv[i]; + runlevel = WRITE; + break; + case 'B': + runlevel = BATTLE; + break; + case 'M': + runlevel = MAP; + break; + case 'S': + runlevel = SOURCE_WIKI; break; default: throw std::runtime_error(std::string("unknown option ") + arg[1]); @@ -44,14 +54,4 @@ void Arguments::Read(int argc, char **argv) { } } -Arguments::RunLevel Arguments::DetectRunLevel() const { - if (dump) { - return DUMP; - } else if (outfile) { - return WRITE; - } else { - return PLAY; - } -} - } diff --git a/src/app/Arguments.h b/src/app/Arguments.h index 1a81649..7c51b7f 100644 --- a/src/app/Arguments.h +++ b/src/app/Arguments.h @@ -23,12 +23,17 @@ public: DUMP, PLAY, WRITE, + + // temporary modes + BATTLE, + MAP, + SOURCE_WIKI, }; public: void Read(int argc, char **argv); - RunLevel DetectRunLevel() const; + RunLevel GetRunLevel() const { return runlevel; } const std::vector &Infiles() const { return infiles; } @@ -38,7 +43,7 @@ public: private: std::vector infiles; const char *outfile; - bool dump; + RunLevel runlevel; }; diff --git a/src/battle/Monster.cpp b/src/battle/Monster.cpp index 7cb4185..498a8c6 100644 --- a/src/battle/Monster.cpp +++ b/src/battle/Monster.cpp @@ -62,22 +62,23 @@ void Monster::CreateTypeDescription() { int stringId(TypeDescription::GetTypeId("String")); TypeDescription &td(TypeDescription::CreateOrGet("Monster")); + td.SetDescription("All data of a monster."); td.SetConstructor(&Construct); td.SetSize(sizeof(Monster)); - td.AddField("name", FieldDescription(((char *)&m.name) - ((char *)&m), stringId, true)); - td.AddField("sprite", FieldDescription(((char *)&m.sprite) - ((char *)&m), spriteId, true)); - td.AddField("level", FieldDescription(((char *)&m.level) - ((char *)&m), numberId, false)); + td.AddField("name", FieldDescription(((char *)&m.name) - ((char *)&m), stringId).SetReferenced()); + td.AddField("sprite", FieldDescription(((char *)&m.sprite) - ((char *)&m), spriteId).SetReferenced()); + td.AddField("level", FieldDescription(((char *)&m.level) - ((char *)&m), numberId)); - td.AddField("maxHealth", FieldDescription(((char *)&m.maxHealth) - ((char *)&m), numberId, false)); - td.AddField("health", FieldDescription(((char *)&m.health) - ((char *)&m), numberId, false)); - td.AddField("maxMana", FieldDescription(((char *)&m.maxMana) - ((char *)&m), numberId, false)); - td.AddField("mana", FieldDescription(((char *)&m.mana) - ((char *)&m), numberId, false)); - td.AddField("stats", FieldDescription(((char *)&m.stats) - ((char *)&m), statsId, false)); + td.AddField("maxHealth", FieldDescription(((char *)&m.maxHealth) - ((char *)&m), numberId)); + td.AddField("health", FieldDescription(((char *)&m.health) - ((char *)&m), numberId)); + td.AddField("maxMana", FieldDescription(((char *)&m.maxMana) - ((char *)&m), numberId)); + td.AddField("mana", FieldDescription(((char *)&m.mana) - ((char *)&m), numberId)); + td.AddField("stats", FieldDescription(((char *)&m.stats) - ((char *)&m), statsId)); - td.AddField("attackAnimation", FieldDescription(((char *)&m.attackAnimation) - ((char *)&m), animationId, true)); - td.AddField("spellAnimation", FieldDescription(((char *)&m.spellAnimation) - ((char *)&m), animationId, true)); - td.AddField("meleeAnimation", FieldDescription(((char *)&m.meleeAnimation) - ((char *)&m), animationId, true)); + td.AddField("attackAnimation", FieldDescription(((char *)&m.attackAnimation) - ((char *)&m), animationId).SetReferenced()); + td.AddField("spellAnimation", FieldDescription(((char *)&m.spellAnimation) - ((char *)&m), animationId).SetReferenced()); + td.AddField("meleeAnimation", FieldDescription(((char *)&m.meleeAnimation) - ((char *)&m), animationId).SetReferenced()); } void Monster::Construct(void *data) { diff --git a/src/battle/PartyLayout.cpp b/src/battle/PartyLayout.cpp index c2bb452..27d587e 100644 --- a/src/battle/PartyLayout.cpp +++ b/src/battle/PartyLayout.cpp @@ -42,10 +42,11 @@ void PartyLayout::CreateTypeDescription() { int vectorId(TypeDescription::GetTypeId("Vector")); TypeDescription &td(TypeDescription::CreateOrGet("PartyLayout")); + td.SetDescription("Positions of party members"); td.SetConstructor(&Construct); td.SetSize(sizeof(PartyLayout)); - td.AddField("positions", FieldDescription(((char *)&p.positions) - ((char *)&p), vectorId, true, true)); + td.AddField("positions", FieldDescription(((char *)&p.positions) - ((char *)&p), vectorId).SetReferenced().SetAggregate().SetDescription("the members' positions")); } void PartyLayout::Construct(void *data) { diff --git a/src/battle/Resources.cpp b/src/battle/Resources.cpp index 6c46946..bb0c0ad 100644 --- a/src/battle/Resources.cpp +++ b/src/battle/Resources.cpp @@ -98,72 +98,72 @@ void Resources::CreateTypeDescription() { td.SetConstructor(&Construct); td.SetSize(sizeof(Resources)); - td.AddField("swapCursor", FieldDescription(((char *)&r.swapCursor) - ((char *)&r), spriteId, true)); - td.AddField("moveIcons", FieldDescription(((char *)&r.moveIcons) - ((char *)&r), spriteId, true)); - td.AddField("attackIcons", FieldDescription(((char *)&r.attackIcons) - ((char *)&r), spriteId, true)); - td.AddField("attackChoiceIcons", FieldDescription(((char *)&r.attackChoiceIcons) - ((char *)&r), spriteId, true)); + td.AddField("swapCursor", FieldDescription(((char *)&r.swapCursor) - ((char *)&r), spriteId).SetReferenced().SetDescription("the cursor sprite for swapping heroes")); + td.AddField("moveIcons", FieldDescription(((char *)&r.moveIcons) - ((char *)&r), spriteId).SetReferenced().SetDescription("the icons of the move selection menu")); + td.AddField("attackIcons", FieldDescription(((char *)&r.attackIcons) - ((char *)&r), spriteId).SetReferenced().SetDescription("the icons of the attack selection menu")); + td.AddField("attackChoiceIcons", FieldDescription(((char *)&r.attackChoiceIcons) - ((char *)&r), spriteId).SetReferenced().SetDescription("the icons showing the hero's attack choice in the respective tag")); - td.AddField("titleFrame", FieldDescription(((char *)&r.titleFrame) - ((char *)&r), frameId, true)); - td.AddField("titleFont", FieldDescription(((char *)&r.titleFont) - ((char *)&r), fontId, true)); + td.AddField("titleFrame", FieldDescription(((char *)&r.titleFrame) - ((char *)&r), frameId).SetReferenced().SetDescription("frame for title headings (spell names, status information, etc.)")); + td.AddField("titleFont", FieldDescription(((char *)&r.titleFont) - ((char *)&r), fontId).SetReferenced().SetDescription("the font for title headings")); - td.AddField("heroTagFrame", FieldDescription(((char *)&r.heroTagFrame) - ((char *)&r), frameId, true)); - td.AddField("activeHeroTagFrame", FieldDescription(((char *)&r.activeHeroTagFrame) - ((char *)&r), frameId, true)); - td.AddField("smallHeroTagFrame", FieldDescription(((char *)&r.smallHeroTagFrame) - ((char *)&r), frameId, true)); - td.AddField("lastSmallHeroTagFrame", FieldDescription(((char *)&r.lastSmallHeroTagFrame) - ((char *)&r), frameId, true)); + td.AddField("heroTagFrame", FieldDescription(((char *)&r.heroTagFrame) - ((char *)&r), frameId).SetReferenced().SetDescription("frame for hero tags")); + td.AddField("activeHeroTagFrame", FieldDescription(((char *)&r.activeHeroTagFrame) - ((char *)&r), frameId).SetReferenced().SetDescription("frame for the active hero's tag")); + td.AddField("smallHeroTagFrame", FieldDescription(((char *)&r.smallHeroTagFrame) - ((char *)&r), frameId).SetReferenced().SetDescription("frame for small hero tags (during attack animation)")); + td.AddField("lastSmallHeroTagFrame", FieldDescription(((char *)&r.lastSmallHeroTagFrame) - ((char *)&r), frameId).SetReferenced().SetDescription("frame for the last small hero tag")); - td.AddField("heroTagFont", FieldDescription(((char *)&r.heroTagFont) - ((char *)&r), fontId, true)); - td.AddField("heroTagLabels", FieldDescription(((char *)&r.heroTagLabels) - ((char *)&r), spriteId, true)); + td.AddField("heroTagFont", FieldDescription(((char *)&r.heroTagFont) - ((char *)&r), fontId).SetReferenced().SetDescription("font for hero tags (hero names)")); + td.AddField("heroTagLabels", FieldDescription(((char *)&r.heroTagLabels) - ((char *)&r), spriteId).SetReferenced().SetDescription("labels on the hero tag (hp/mp/ip/lvl/move)")); - td.AddField("healthGauge", FieldDescription(((char *)&r.healthGauge) - ((char *)&r), gaugeId, true)); - td.AddField("manaGauge", FieldDescription(((char *)&r.manaGauge) - ((char *)&r), gaugeId, true)); - td.AddField("ikariGauge", FieldDescription(((char *)&r.ikariGauge) - ((char *)&r), gaugeId, true)); + td.AddField("healthGauge", FieldDescription(((char *)&r.healthGauge) - ((char *)&r), gaugeId).SetReferenced().SetDescription("health gauge")); + td.AddField("manaGauge", FieldDescription(((char *)&r.manaGauge) - ((char *)&r), gaugeId).SetReferenced().SetDescription("mana gauge")); + td.AddField("ikariGauge", FieldDescription(((char *)&r.ikariGauge) - ((char *)&r), gaugeId).SetReferenced().SetDescription("ikari gauge")); - td.AddField("selectFrame", FieldDescription(((char *)&r.selectFrame) - ((char *)&r), frameId, true)); + td.AddField("selectFrame", FieldDescription(((char *)&r.selectFrame) - ((char *)&r), frameId).SetReferenced().SetDescription("frame for spell, item, and ikari menus")); - td.AddField("normalFont", FieldDescription(((char *)&r.normalFont) - ((char *)&r), fontId, true)); - td.AddField("disabledFont", FieldDescription(((char *)&r.disabledFont) - ((char *)&r), fontId, true)); + td.AddField("normalFont", FieldDescription(((char *)&r.normalFont) - ((char *)&r), fontId).SetReferenced().SetDescription("font for menus")); + td.AddField("disabledFont", FieldDescription(((char *)&r.disabledFont) - ((char *)&r), fontId).SetReferenced().SetDescription("font for disabled entries in menus")); - td.AddField("menuCursor", FieldDescription(((char *)&r.menuCursor) - ((char *)&r), spriteId, true)); - td.AddField("weaponTargetCursor", FieldDescription(((char *)&r.weaponTargetCursor) - ((char *)&r), spriteId, true)); - td.AddField("magicTargetCursor", FieldDescription(((char *)&r.magicTargetCursor) - ((char *)&r), spriteId, true)); - td.AddField("itemTargetCursor", FieldDescription(((char *)&r.itemTargetCursor) - ((char *)&r), spriteId, true)); + td.AddField("menuCursor", FieldDescription(((char *)&r.menuCursor) - ((char *)&r), spriteId).SetReferenced().SetDescription("selection indicator for menus")); + td.AddField("weaponTargetCursor", FieldDescription(((char *)&r.weaponTargetCursor) - ((char *)&r), spriteId).SetReferenced().SetDescription("cursor for selectiong attack targets")); + td.AddField("magicTargetCursor", FieldDescription(((char *)&r.magicTargetCursor) - ((char *)&r), spriteId).SetReferenced().SetDescription("cursor for selectiong spell targets")); + td.AddField("itemTargetCursor", FieldDescription(((char *)&r.itemTargetCursor) - ((char *)&r), spriteId).SetReferenced().SetDescription("cursor for selectiong item targets")); - td.AddField("spellMenuHeadline", FieldDescription(((char *)&r.spellMenuHeadline) - ((char *)&r), stringId, true)); - td.AddField("spellMenuProperties", FieldDescription(((char *)&r.spellMenuProperties) - ((char *)&r), menuPropertiesId, true)); + td.AddField("spellMenuHeadline", FieldDescription(((char *)&r.spellMenuHeadline) - ((char *)&r), stringId).SetReferenced().SetDescription("headline of the spell menu")); + td.AddField("spellMenuProperties", FieldDescription(((char *)&r.spellMenuProperties) - ((char *)&r), menuPropertiesId).SetReferenced().SetDescription("properties of the spell menu")); - td.AddField("itemMenuHeadline", FieldDescription(((char *)&r.itemMenuHeadline) - ((char *)&r), stringId, true)); - td.AddField("itemMenuProperties", FieldDescription(((char *)&r.itemMenuProperties) - ((char *)&r), menuPropertiesId, true)); + td.AddField("itemMenuHeadline", FieldDescription(((char *)&r.itemMenuHeadline) - ((char *)&r), stringId).SetReferenced().SetDescription("headline of the item menu")); + td.AddField("itemMenuProperties", FieldDescription(((char *)&r.itemMenuProperties) - ((char *)&r), menuPropertiesId).SetReferenced().SetDescription("properties of the item menu")); - td.AddField("ikariMenuHeadline", FieldDescription(((char *)&r.ikariMenuHeadline) - ((char *)&r), stringId, true)); - td.AddField("ikariMenuProperties", FieldDescription(((char *)&r.ikariMenuProperties) - ((char *)&r), menuPropertiesId, true)); - td.AddField("noEquipmentText", FieldDescription(((char *)&r.noEquipmentText) - ((char *)&r), stringId, true)); + td.AddField("ikariMenuHeadline", FieldDescription(((char *)&r.ikariMenuHeadline) - ((char *)&r), stringId).SetReferenced().SetDescription("headline of the ikari menu")); + td.AddField("ikariMenuProperties", FieldDescription(((char *)&r.ikariMenuProperties) - ((char *)&r), menuPropertiesId).SetReferenced().SetDescription("properties of the ikari menu")); + td.AddField("noEquipmentText", FieldDescription(((char *)&r.noEquipmentText) - ((char *)&r), stringId).SetReferenced().SetDescription("text to show for missing equipment")); - td.AddField("escapeText", FieldDescription(((char *)&r.escapeText) - ((char *)&r), stringId, true)); + td.AddField("escapeText", FieldDescription(((char *)&r.escapeText) - ((char *)&r), stringId).SetReferenced().SetDescription("displayed when the party escapes")); - td.AddField("numberAnimationPrototype", FieldDescription(((char *)&r.numberAnimationPrototype) - ((char *)&r), animationId, true)); + td.AddField("numberAnimationPrototype", FieldDescription(((char *)&r.numberAnimationPrototype) - ((char *)&r), animationId).SetReferenced().SetDescription("animation of an attack's result digit")); - td.AddField("bigNumberSprite", FieldDescription(((char *)&r.bigNumberSprite) - ((char *)&r), spriteId, true)); - td.AddField("greenNumberSprite", FieldDescription(((char *)&r.greenNumberSprite) - ((char *)&r), spriteId, true)); + td.AddField("bigNumberSprite", FieldDescription(((char *)&r.bigNumberSprite) - ((char *)&r), spriteId).SetReferenced().SetDescription("sprite containing the damage numbers")); + td.AddField("greenNumberSprite", FieldDescription(((char *)&r.greenNumberSprite) - ((char *)&r), spriteId).SetReferenced().SetDescription("sprite containing the healing numbers")); - td.AddField("weaponMenuIcon", FieldDescription(((char *)&r.weaponMenuIcon) - ((char *)&r), spriteId, true)); - td.AddField("armorMenuIcon", FieldDescription(((char *)&r.armorMenuIcon) - ((char *)&r), spriteId, true)); - td.AddField("shieldMenuIcon", FieldDescription(((char *)&r.shieldMenuIcon) - ((char *)&r), spriteId, true)); - td.AddField("helmetMenuIcon", FieldDescription(((char *)&r.helmetMenuIcon) - ((char *)&r), spriteId, true)); - td.AddField("ringMenuIcon", FieldDescription(((char *)&r.ringMenuIcon) - ((char *)&r), spriteId, true)); - td.AddField("jewelMenuIcon", FieldDescription(((char *)&r.jewelMenuIcon) - ((char *)&r), spriteId, true)); + td.AddField("weaponMenuIcon", FieldDescription(((char *)&r.weaponMenuIcon) - ((char *)&r), spriteId).SetReferenced().SetDescription("weapon icon for ikari menu")); + td.AddField("armorMenuIcon", FieldDescription(((char *)&r.armorMenuIcon) - ((char *)&r), spriteId).SetReferenced().SetDescription("armor icon for ikari menu")); + td.AddField("shieldMenuIcon", FieldDescription(((char *)&r.shieldMenuIcon) - ((char *)&r), spriteId).SetReferenced().SetDescription("shield icon for ikari menu")); + td.AddField("helmetMenuIcon", FieldDescription(((char *)&r.helmetMenuIcon) - ((char *)&r), spriteId).SetReferenced().SetDescription("helmet icon for ikari menu")); + td.AddField("ringMenuIcon", FieldDescription(((char *)&r.ringMenuIcon) - ((char *)&r), spriteId).SetReferenced().SetDescription("ring icon for ikari menu")); + td.AddField("jewelMenuIcon", FieldDescription(((char *)&r.jewelMenuIcon) - ((char *)&r), spriteId).SetReferenced().SetDescription("jewel icon for ikari menu")); - td.AddField("levelLabelRow", FieldDescription(((char *)&r.levelLabelRow) - ((char *)&r), numberId, false)); - td.AddField("levelLabelCol", FieldDescription(((char *)&r.levelLabelCol) - ((char *)&r), numberId, false)); - td.AddField("healthLabelRow", FieldDescription(((char *)&r.healthLabelRow) - ((char *)&r), numberId, false)); - td.AddField("healthLabelCol", FieldDescription(((char *)&r.healthLabelCol) - ((char *)&r), numberId, false)); - td.AddField("manaLabelRow", FieldDescription(((char *)&r.manaLabelRow) - ((char *)&r), numberId, false)); - td.AddField("manaLabelCol", FieldDescription(((char *)&r.manaLabelCol) - ((char *)&r), numberId, false)); - td.AddField("moveLabelRow", FieldDescription(((char *)&r.moveLabelRow) - ((char *)&r), numberId, false)); - td.AddField("moveLabelCol", FieldDescription(((char *)&r.moveLabelCol) - ((char *)&r), numberId, false)); - td.AddField("ikariLabelRow", FieldDescription(((char *)&r.ikariLabelRow) - ((char *)&r), numberId, false)); - td.AddField("ikariLabelCol", FieldDescription(((char *)&r.ikariLabelCol) - ((char *)&r), numberId, false)); + td.AddField("levelLabelRow", FieldDescription(((char *)&r.levelLabelRow) - ((char *)&r), numberId).SetDescription("column of the level label in heroTagLabels")); + td.AddField("levelLabelCol", FieldDescription(((char *)&r.levelLabelCol) - ((char *)&r), numberId).SetDescription("row of the level label in heroTagLabels")); + td.AddField("healthLabelRow", FieldDescription(((char *)&r.healthLabelRow) - ((char *)&r), numberId).SetDescription("column of the health label in heroTagLabels")); + td.AddField("healthLabelCol", FieldDescription(((char *)&r.healthLabelCol) - ((char *)&r), numberId).SetDescription("row of the health label in heroTagLabels")); + td.AddField("manaLabelRow", FieldDescription(((char *)&r.manaLabelRow) - ((char *)&r), numberId).SetDescription("column of the mana label in heroTagLabels")); + td.AddField("manaLabelCol", FieldDescription(((char *)&r.manaLabelCol) - ((char *)&r), numberId).SetDescription("row of the mana label in heroTagLabels")); + td.AddField("moveLabelRow", FieldDescription(((char *)&r.moveLabelRow) - ((char *)&r), numberId).SetDescription("column of the move label in heroTagLabels")); + td.AddField("moveLabelCol", FieldDescription(((char *)&r.moveLabelCol) - ((char *)&r), numberId).SetDescription("row of the move label in heroTagLabels")); + td.AddField("ikariLabelRow", FieldDescription(((char *)&r.ikariLabelRow) - ((char *)&r), numberId).SetDescription("column of the ikari label in heroTagLabels")); + td.AddField("ikariLabelCol", FieldDescription(((char *)&r.ikariLabelCol) - ((char *)&r), numberId).SetDescription("row of the ikari label in heroTagLabels")); - td.AddField("heroesBgColor", FieldDescription(((char *)&r.heroesBgColor) - ((char *)&r), colorId, false)); + td.AddField("heroesBgColor", FieldDescription(((char *)&r.heroesBgColor) - ((char *)&r), colorId).SetDescription("background color of the small tags during attack animation")); } void Resources::Construct(void *data) { diff --git a/src/common/Hero.cpp b/src/common/Hero.cpp index 1d276e5..bef60a4 100644 --- a/src/common/Hero.cpp +++ b/src/common/Hero.cpp @@ -69,24 +69,24 @@ void Hero::CreateTypeDescription() { td.SetConstructor(&Construct); td.SetSize(sizeof(Hero)); - td.AddField("name", FieldDescription(((char *)&h.name) - ((char *)&h), stringId, true)); + td.AddField("name", FieldDescription(((char *)&h.name) - ((char *)&h), stringId).SetReferenced()); - td.AddField("maxHealth", FieldDescription(((char *)&h.maxHealth) - ((char *)&h), numberId, false)); - td.AddField("health", FieldDescription(((char *)&h.health) - ((char *)&h), numberId, false)); - td.AddField("maxMana", FieldDescription(((char *)&h.maxMana) - ((char *)&h), numberId, false)); - td.AddField("mana", FieldDescription(((char *)&h.mana) - ((char *)&h), numberId, false)); - td.AddField("ip", FieldDescription(((char *)&h.ip) - ((char *)&h), numberId, false)); + td.AddField("maxHealth", FieldDescription(((char *)&h.maxHealth) - ((char *)&h), numberId)); + td.AddField("health", FieldDescription(((char *)&h.health) - ((char *)&h), numberId)); + td.AddField("maxMana", FieldDescription(((char *)&h.maxMana) - ((char *)&h), numberId)); + td.AddField("mana", FieldDescription(((char *)&h.mana) - ((char *)&h), numberId)); + td.AddField("ip", FieldDescription(((char *)&h.ip) - ((char *)&h), numberId)); - td.AddField("stats", FieldDescription(((char *)&h.stats) - ((char *)&h), statsId, false)); + td.AddField("stats", FieldDescription(((char *)&h.stats) - ((char *)&h), statsId)); - td.AddField("level", FieldDescription(((char *)&h.level) - ((char *)&h), numberId, false)); + td.AddField("level", FieldDescription(((char *)&h.level) - ((char *)&h), numberId)); - td.AddField("battleSprite", FieldDescription(((char *)&h.battleSprite) - ((char *)&h), spriteId, true)); - td.AddField("attackAnimation", FieldDescription(((char *)&h.attackAnimation) - ((char *)&h), animationId, true)); - td.AddField("spellAnimation", FieldDescription(((char *)&h.spellAnimation) - ((char *)&h), animationId, true)); - td.AddField("meleeAnimation", FieldDescription(((char *)&h.meleeAnimation) - ((char *)&h), animationId, true)); + td.AddField("battleSprite", FieldDescription(((char *)&h.battleSprite) - ((char *)&h), spriteId).SetReferenced().SetDescription("the sprite used for battle scenes")); + td.AddField("attackAnimation", FieldDescription(((char *)&h.attackAnimation) - ((char *)&h), animationId).SetReferenced().SetDescription("the animation played for physical attacks")); + td.AddField("spellAnimation", FieldDescription(((char *)&h.spellAnimation) - ((char *)&h), animationId).SetReferenced().SetDescription("the animation played for magical attacks")); + td.AddField("meleeAnimation", FieldDescription(((char *)&h.meleeAnimation) - ((char *)&h), animationId).SetReferenced().SetDescription("the animation played on attacked monsters when the hero has no weapon")); - td.AddField("mapEntity", FieldDescription(((char *)&h.mapEntity) - ((char *)&h), entityId, false)); + td.AddField("mapEntity", FieldDescription(((char *)&h.mapEntity) - ((char *)&h), entityId).SetDescription("the entity representing the hero on maps")); } void Hero::Construct(void *data) { diff --git a/src/common/Ikari.cpp b/src/common/Ikari.cpp index 8ed8698..3a02392 100644 --- a/src/common/Ikari.cpp +++ b/src/common/Ikari.cpp @@ -31,13 +31,15 @@ void Ikari::CreateTypeDescription() { int targetsId(TypeDescription::GetTypeId("TargetingMode")); TypeDescription &td(TypeDescription::CreateOrGet("Ikari")); + td.SetDescription( + "Information of a single ikari attack."); td.SetConstructor(&Construct); td.SetSize(sizeof(Ikari)); - td.AddField("name", FieldDescription(((char *)&i.name) - ((char *)&i), stringId, true)); - td.AddField("cost", FieldDescription(((char *)&i.cost) - ((char *)&i), numberId, false)); - td.AddField("targets", FieldDescription(((char *)&i.targetingMode) - ((char *)&i), targetsId, false)); - td.AddField("type", FieldDescription(((char *)&i.isPhysical) - ((char *)&i), boolId, false)); + td.AddField("name", FieldDescription(((char *)&i.name) - ((char *)&i), stringId).SetReferenced().SetDescription("the attack's name")); + td.AddField("cost", FieldDescription(((char *)&i.cost) - ((char *)&i), numberId).SetDescription("amount of ikari points needed and deducted for use")); + td.AddField("targets", FieldDescription(((char *)&i.targetingMode) - ((char *)&i), targetsId).SetDescription("how target selection is to be performed")); + td.AddField("type", FieldDescription(((char *)&i.isPhysical) - ((char *)&i), boolId).SetDescription("if the attack is physical (true) or magical(false)")); } void Ikari::Construct(void *data) { diff --git a/src/common/Item.cpp b/src/common/Item.cpp index 9a1a735..56f083e 100644 --- a/src/common/Item.cpp +++ b/src/common/Item.cpp @@ -48,23 +48,24 @@ void Item::CreateTypeDescription() { int targetsId(TypeDescription::GetTypeId("TargetingMode")); TypeDescription &td(TypeDescription::CreateOrGet("Item")); + td.SetDescription("All data of an item (soon)."); td.SetConstructor(&Construct); td.SetSize(sizeof(Item)); - td.AddField("name", FieldDescription(((char *)&i.name) - ((char *)&i), stringId, true)); - td.AddField("menuicon", FieldDescription(((char *)&i.menuIcon) - ((char *)&i), spriteId, true)); + td.AddField("name", FieldDescription(((char *)&i.name) - ((char *)&i), stringId).SetReferenced().SetDescription("the item's name")); + td.AddField("menuicon", FieldDescription(((char *)&i.menuIcon) - ((char *)&i), spriteId).SetReferenced().SetDescription("icon that is displayed in menus")); - td.AddField("mostUseful", FieldDescription(((char *)&i.mostUseful) - ((char *)&i), boolId, false)); - td.AddField("equipable", FieldDescription(((char *)&i.equipable) - ((char *)&i), boolId, false)); - td.AddField("cursed", FieldDescription(((char *)&i.cursed) - ((char *)&i), boolId, false)); - td.AddField("fruit", FieldDescription(((char *)&i.fruit) - ((char *)&i), boolId, false)); - td.AddField("scenario", FieldDescription(((char *)&i.scenario) - ((char *)&i), boolId, false)); - td.AddField("status", FieldDescription(((char *)&i.status) - ((char *)&i), boolId, false)); - td.AddField("battle", FieldDescription(((char *)&i.battle) - ((char *)&i), boolId, false)); + td.AddField("mostUseful", FieldDescription(((char *)&i.mostUseful) - ((char *)&i), boolId)); + td.AddField("equipable", FieldDescription(((char *)&i.equipable) - ((char *)&i), boolId)); + td.AddField("cursed", FieldDescription(((char *)&i.cursed) - ((char *)&i), boolId)); + td.AddField("fruit", FieldDescription(((char *)&i.fruit) - ((char *)&i), boolId)); + td.AddField("scenario", FieldDescription(((char *)&i.scenario) - ((char *)&i), boolId)); + td.AddField("status", FieldDescription(((char *)&i.status) - ((char *)&i), boolId)); + td.AddField("battle", FieldDescription(((char *)&i.battle) - ((char *)&i), boolId).SetDescription("if the item can be used in battle")); - 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)); + td.AddField("targets", FieldDescription(((char *)&i.targettingMode) - ((char *)&i), targetsId).SetDescription("how target selection is to be performed")); + td.AddField("ikari", FieldDescription(((char *)&i.ikari) - ((char *)&i), ikariId).SetReferenced().SetDescription("ikari attack of the item (sensible only for equipment)")); + td.AddField("attackanimation", FieldDescription(((char *)&i.attackAnimation) - ((char *)&i), animationId).SetReferenced().SetDescription("animation that is run when the item is used for attacking")); } void Item::Construct(void *data) { diff --git a/src/common/Spell.cpp b/src/common/Spell.cpp index 4fce398..bcf7f29 100644 --- a/src/common/Spell.cpp +++ b/src/common/Spell.cpp @@ -29,14 +29,15 @@ void Spell::CreateTypeDescription() { int targetsId(TypeDescription::GetTypeId("TargetingMode")); TypeDescription &td(TypeDescription::CreateOrGet("Spell")); + td.SetDescription("All data about a spell (soon)."); td.SetConstructor(&Construct); td.SetSize(sizeof(Spell)); - td.AddField("name", FieldDescription(((char *)&s.name) - ((char *)&s), stringId, true)); - td.AddField("cost", FieldDescription(((char *)&s.cost) - ((char *)&s), numberId, false)); - td.AddField("targets", FieldDescription(((char *)&s.targetingMode) - ((char *)&s), targetsId, false)); - td.AddField("status", FieldDescription(((char *)&s.status) - ((char *)&s), boolId, false)); - td.AddField("battle", FieldDescription(((char *)&s.battle) - ((char *)&s), boolId, false)); + td.AddField("name", FieldDescription(((char *)&s.name) - ((char *)&s), stringId).SetReferenced().SetDescription("the spell's name")); + td.AddField("cost", FieldDescription(((char *)&s.cost) - ((char *)&s), numberId).SetDescription("Amount of magic points needed and deducted for invocation")); + td.AddField("targets", FieldDescription(((char *)&s.targetingMode) - ((char *)&s), targetsId).SetDescription("how target selection is to be performed")); + td.AddField("status", FieldDescription(((char *)&s.status) - ((char *)&s), boolId).SetDescription("if the spell can be used at the status screen")); + td.AddField("battle", FieldDescription(((char *)&s.battle) - ((char *)&s), boolId).SetDescription("if the spell can be used in battle")); } void Spell::Construct(void *data) { diff --git a/src/common/Stats.cpp b/src/common/Stats.cpp index 58d5db6..a31d7b5 100644 --- a/src/common/Stats.cpp +++ b/src/common/Stats.cpp @@ -43,16 +43,17 @@ void Stats::CreateTypeDescription() { int numberId(TypeDescription::GetTypeId("Number")); TypeDescription &td(TypeDescription::CreateOrGet("Stats")); + td.SetDescription("Attributes of a battle's participant."); td.SetConstructor(&Construct); td.SetSize(sizeof(Stats)); - td.AddField("atp", FieldDescription(((char *)&s.attack) - ((char *)&s), numberId, false)); - td.AddField("dfp", FieldDescription(((char *)&s.defense) - ((char *)&s), numberId, false)); - td.AddField("str", FieldDescription(((char *)&s.strength) - ((char *)&s), numberId, false)); - td.AddField("agl", FieldDescription(((char *)&s.agility) - ((char *)&s), numberId, false)); - td.AddField("int", FieldDescription(((char *)&s.intelligence) - ((char *)&s), numberId, false)); - td.AddField("gut", FieldDescription(((char *)&s.gut) - ((char *)&s), numberId, false)); - td.AddField("mgr", FieldDescription(((char *)&s.magicResistance) - ((char *)&s), numberId, false)); + td.AddField("atp", FieldDescription(((char *)&s.attack) - ((char *)&s), numberId).SetDescription("attack points")); + td.AddField("dfp", FieldDescription(((char *)&s.defense) - ((char *)&s), numberId).SetDescription("defense points")); + td.AddField("str", FieldDescription(((char *)&s.strength) - ((char *)&s), numberId).SetDescription("strength")); + td.AddField("agl", FieldDescription(((char *)&s.agility) - ((char *)&s), numberId).SetDescription("agility")); + td.AddField("int", FieldDescription(((char *)&s.intelligence) - ((char *)&s), numberId).SetDescription("intelligence")); + td.AddField("gut", FieldDescription(((char *)&s.gut) - ((char *)&s), numberId).SetDescription("gut (ikari factor)")); + td.AddField("mgr", FieldDescription(((char *)&s.magicResistance) - ((char *)&s), numberId).SetDescription("magic resistance")); } void Stats::Construct(void *data) { diff --git a/src/common/TargetingMode.cpp b/src/common/TargetingMode.cpp index 0a092e2..9f8972c 100644 --- a/src/common/TargetingMode.cpp +++ b/src/common/TargetingMode.cpp @@ -21,11 +21,12 @@ void TargetingMode::CreateTypeDescription() { int numberId(TypeDescription::GetTypeId("Number")); TypeDescription &td(TypeDescription::CreateOrGet("TargetingMode")); + td.SetDescription("Specifies how selection of a target (e.g. for a spell) is performed."); td.SetConstructor(&Construct); td.SetSize(sizeof(TargetingMode)); - td.AddField("faction", FieldDescription(((char *)&t.ally) - ((char *)&t), boolId, false)); - td.AddField("mode", FieldDescription(((char *)&t.mode) - ((char *)&t), numberId, false)); + td.AddField("faction", FieldDescription(((char *)&t.ally) - ((char *)&t), boolId).SetDescription("targetted faction; true for ally, false for enemy")); + td.AddField("mode", FieldDescription(((char *)&t.mode) - ((char *)&t), numberId).SetDescription("attack mode; 0 = all, 1 = multiple, 2 = single")); } void TargetingMode::Construct(void *data) { diff --git a/src/graphics/Animation.cpp b/src/graphics/Animation.cpp index 9bbfa1a..2534a26 100644 --- a/src/graphics/Animation.cpp +++ b/src/graphics/Animation.cpp @@ -15,9 +15,9 @@ using loader::TypeDescription; namespace graphics { void Animation::AddFields(TypeDescription &td, const Animation &a, std::ptrdiff_t offset, int boolId, int numberId, int spriteId) { - td.AddField("sprite", FieldDescription(((char *)&a.sprite) - ((char *)&a) - offset, spriteId, true)); - td.AddField("frametime", FieldDescription(((char *)&a.frameTime) - ((char *)&a) - offset, numberId, false)); - td.AddField("repeat", FieldDescription(((char *)&a.repeat) - ((char *)&a) - offset, boolId, false)); + td.AddField("sprite", FieldDescription(((char *)&a.sprite) - ((char *)&a) - offset, spriteId).SetReferenced().SetDescription("the sprite used for cutting out frames")); + td.AddField("frametime", FieldDescription(((char *)&a.frameTime) - ((char *)&a) - offset, numberId).SetDescription("duration of a frame in miliseconds")); + td.AddField("repeat", FieldDescription(((char *)&a.repeat) - ((char *)&a) - offset, boolId).SetDescription("whether the animation should start over at the beginning after reaching the last frame")); } } diff --git a/src/graphics/ComplexAnimation.cpp b/src/graphics/ComplexAnimation.cpp index cb125f5..c828e4c 100644 --- a/src/graphics/ComplexAnimation.cpp +++ b/src/graphics/ComplexAnimation.cpp @@ -26,22 +26,24 @@ void ComplexAnimation::CreateTypeDescription() { int vectorId(TypeDescription::GetTypeId("Vector")); TypeDescription &td(TypeDescription::CreateOrGet("ComplexAnimation")); + td.SetDescription("Complex animation type that supports per-frame disposition and non-linear sprite offset selection."); td.SetConstructor(&Construct); td.SetSize(sizeof(ComplexAnimation)); td.AddSupertype(animationId, ((char *)a) - ((char *)&ca)); Animation::AddFields(td, ca, ((char *)a) - ((char *)&ca), boolId, numberId, spriteId); - td.AddField("frames", FieldDescription(((char *)&ca.frames) - ((char *)&ca), frameId, true, true)); + td.AddField("frames", FieldDescription(((char *)&ca.frames) - ((char *)&ca), frameId).SetReferenced().SetAggregate().SetDescription("a variable number of frames")); FrameProp fp; TypeDescription &ftd(TypeDescription::CreateOrGet("ComplexAnimationFrame")); + ftd.SetDescription("Information about how a frame of a complex animation should be rendered."); ftd.SetSize(sizeof(FrameProp)); - ftd.AddField("column", FieldDescription(((char *)&fp.col) - ((char *)&fp), numberId, false)); - ftd.AddField("row", FieldDescription(((char *)&fp.row) - ((char *)&fp), numberId, false)); - ftd.AddField("disposition", FieldDescription(((char *)&fp.disposition) - ((char *)&fp), vectorId, false)); + ftd.AddField("column", FieldDescription(((char *)&fp.col) - ((char *)&fp), numberId).SetDescription("the column of the sprite that will be drawn")); + ftd.AddField("row", FieldDescription(((char *)&fp.row) - ((char *)&fp), numberId).SetDescription("the row of the sprite that will be drawn")); + ftd.AddField("disposition", FieldDescription(((char *)&fp.disposition) - ((char *)&fp), vectorId).SetDescription("offset from the original drawing position")); } void ComplexAnimation::Construct(void *data) { diff --git a/src/graphics/Font.cpp b/src/graphics/Font.cpp index e4e538d..efaad15 100644 --- a/src/graphics/Font.cpp +++ b/src/graphics/Font.cpp @@ -82,12 +82,17 @@ void Font::CreateTypeDescription() { int spriteId(TypeDescription::GetTypeId("Sprite")); TypeDescription &td(TypeDescription::CreateOrGet("Font")); + td.SetDescription( + "Simple font with fixed-width characters using a sprite for rendering.\n" + "Characters from strings are mapped as follows:\n" + "
sprite column = column offset + (character % 16)\n"
+			"sprite row    = row    offset + (character / 16)
"); td.SetConstructor(&Construct); td.SetSize(sizeof(Font)); - td.AddField("sprite", FieldDescription(((char *)&f.sprite) - ((char *)&f), spriteId, true)); - td.AddField("columnoffset", FieldDescription(((char *)&f.colOffset) - ((char *)&f), numberId, false)); - td.AddField("rowoffset", FieldDescription(((char *)&f.rowOffset) - ((char *)&f), numberId, false)); + td.AddField("sprite", FieldDescription(((char *)&f.sprite) - ((char *)&f), spriteId).SetReferenced().SetDescription("a sprite where each tile corresponds to a character")); + td.AddField("columnoffset", FieldDescription(((char *)&f.colOffset) - ((char *)&f), numberId).SetDescription("offset of the column of the first character")); + td.AddField("rowoffset", FieldDescription(((char *)&f.rowOffset) - ((char *)&f), numberId).SetDescription("offset of the row of the first character")); } void Font::Construct(void *data) { diff --git a/src/graphics/Frame.cpp b/src/graphics/Frame.cpp index 683bfcb..01264e8 100644 --- a/src/graphics/Frame.cpp +++ b/src/graphics/Frame.cpp @@ -126,13 +126,16 @@ void Frame::CreateTypeDescription() { int vectorId(TypeDescription::GetTypeId("Vector")); TypeDescription &td(TypeDescription::CreateOrGet("Frame")); + td.SetDescription( + "A frame is basically a border + a background texture.\n" + "It splits an image into 3*3 parts where the edges are kept as is and the sides and the middle part are repeated as needed."); td.SetConstructor(&Construct); td.SetSize(sizeof(Frame)); - td.AddField("image", FieldDescription(((char *)&f.surface) - ((char *)&f), imageId, true)); - td.AddField("border", FieldDescription(((char *)&f.borderSize) - ((char *)&f), vectorId, false)); - td.AddField("repeat", FieldDescription(((char *)&f.repeatSize) - ((char *)&f), vectorId, false)); - td.AddField("offset", FieldDescription(((char *)&f.offset) - ((char *)&f), vectorId, false)); + td.AddField("image", FieldDescription(((char *)&f.surface) - ((char *)&f), imageId).SetReferenced().SetDescription("the underlying graphic from which the frame parts are cut")); + td.AddField("border", FieldDescription(((char *)&f.borderSize) - ((char *)&f), vectorId).SetDescription("size of the border part, dimensions of top-left corner")); + td.AddField("repeat", FieldDescription(((char *)&f.repeatSize) - ((char *)&f), vectorId).SetDescription("size of the repeat part, dimensions of a single tile of the background texture")); + td.AddField("offset", FieldDescription(((char *)&f.offset) - ((char *)&f), vectorId).SetDescription("offset into the image where to start cutting, coordinates of the top-left corner on the image")); } void Frame::Construct(void *data) { diff --git a/src/graphics/Gauge.cpp b/src/graphics/Gauge.cpp index b7023d4..d0e891a 100644 --- a/src/graphics/Gauge.cpp +++ b/src/graphics/Gauge.cpp @@ -91,16 +91,20 @@ void Gauge::CreateTypeDescription() { int vectorId(TypeDescription::GetTypeId("Vector")); TypeDescription &td(TypeDescription::CreateOrGet("Gauge")); + td.SetDescription( + "Gauges display a percentage by filling the left part different than the right.\n" + "The fill level is only mapped with repeat.\n" + "Start is filled if the level in greater than zero, end is filled if the level is at its maximum."); td.SetConstructor(&Construct); td.SetSize(sizeof(Gauge)); - td.AddField("image", FieldDescription(((char *)&g.surface) - ((char *)&g), imageId, true)); - td.AddField("full", FieldDescription(((char *)&g.fullOffset) - ((char *)&g), vectorId, false)); - td.AddField("empty", FieldDescription(((char *)&g.emptyOffset) - ((char *)&g), vectorId, false)); - td.AddField("height", FieldDescription(((char *)&g.height) - ((char *)&g), numberId, false)); - td.AddField("start", FieldDescription(((char *)&g.startWidth) - ((char *)&g), numberId, false)); - td.AddField("repeat", FieldDescription(((char *)&g.repeatWidth) - ((char *)&g), numberId, false)); - td.AddField("end", FieldDescription(((char *)&g.endWidth) - ((char *)&g), numberId, false)); + td.AddField("image", FieldDescription(((char *)&g.surface) - ((char *)&g), imageId).SetReferenced().SetDescription("the underlying graphic from which the gauge parts are cut")); + td.AddField("full", FieldDescription(((char *)&g.fullOffset) - ((char *)&g), vectorId).SetDescription("top-left corner of the filled gauge")); + td.AddField("empty", FieldDescription(((char *)&g.emptyOffset) - ((char *)&g), vectorId).SetDescription("top-left corner of the empty gauge")); + td.AddField("height", FieldDescription(((char *)&g.height) - ((char *)&g), numberId).SetDescription("height of the gauges")); + td.AddField("start", FieldDescription(((char *)&g.startWidth) - ((char *)&g), numberId).SetDescription("width of the start part")); + td.AddField("repeat", FieldDescription(((char *)&g.repeatWidth) - ((char *)&g), numberId).SetDescription("width of the repeat part")); + td.AddField("end", FieldDescription(((char *)&g.endWidth) - ((char *)&g), numberId).SetDescription("width of the end part")); } void Gauge::Construct(void *data) { diff --git a/src/graphics/Menu.cpp b/src/graphics/Menu.cpp index 92fc898..113e415 100644 --- a/src/graphics/Menu.cpp +++ b/src/graphics/Menu.cpp @@ -26,19 +26,19 @@ void MenuProperties::CreateTypeDescription() { td.SetConstructor(&Construct); td.SetSize(sizeof(MenuProperties)); - td.AddField("font", FieldDescription(((char *)&p.font) - ((char *)&p), fontId, true)); - td.AddField("disabledFont", FieldDescription(((char *)&p.disabledFont) - ((char *)&p), fontId, true)); - td.AddField("cursor", FieldDescription(((char *)&p.cursor) - ((char *)&p), spriteId, true)); - td.AddField("charsPerEntry", FieldDescription(((char *)&p.charsPerEntry) - ((char *)&p), numberId, false)); - td.AddField("rows", FieldDescription(((char *)&p.rows) - ((char *)&p), numberId, false)); - td.AddField("rowGap", FieldDescription(((char *)&p.rowGap) - ((char *)&p), numberId, false)); - td.AddField("iconSpace", FieldDescription(((char *)&p.iconSpace) - ((char *)&p), numberId, false)); - td.AddField("cols", FieldDescription(((char *)&p.cols) - ((char *)&p), numberId, false)); - td.AddField("colGap", FieldDescription(((char *)&p.colGap) - ((char *)&p), numberId, false)); - td.AddField("delimiter", FieldDescription(((char *)&p.delimiter) - ((char *)&p), stringId, false)); - td.AddField("charsPerNumber", FieldDescription(((char *)&p.charsPerNumber) - ((char *)&p), numberId, false)); - td.AddField("charsPerAdditionalText", FieldDescription(((char *)&p.charsPerAdditionalText) - ((char *)&p), numberId, false)); - td.AddField("additionalTextGap", FieldDescription(((char *)&p.additionalTextGap) - ((char *)&p), numberId, false)); + td.AddField("font", FieldDescription(((char *)&p.font) - ((char *)&p), fontId).SetReferenced().SetDescription("the font to use for normal/enabled entries")); + td.AddField("disabledFont", FieldDescription(((char *)&p.disabledFont) - ((char *)&p), fontId).SetReferenced().SetDescription("the font for disabled entries")); + td.AddField("cursor", FieldDescription(((char *)&p.cursor) - ((char *)&p), spriteId).SetReferenced().SetDescription("the cursor sprite indicating the current selection")); + td.AddField("charsPerEntry", FieldDescription(((char *)&p.charsPerEntry) - ((char *)&p), numberId).SetDescription("width of an entry in characters")); + td.AddField("rows", FieldDescription(((char *)&p.rows) - ((char *)&p), numberId).SetDescription("number of visible rows")); + td.AddField("rowGap", FieldDescription(((char *)&p.rowGap) - ((char *)&p), numberId).SetDescription("space between rows in pixles")); + td.AddField("iconSpace", FieldDescription(((char *)&p.iconSpace) - ((char *)&p), numberId).SetDescription("space reserved for icons in pixels")); + td.AddField("cols", FieldDescription(((char *)&p.cols) - ((char *)&p), numberId).SetDescription("number of columns")); + td.AddField("colGap", FieldDescription(((char *)&p.colGap) - ((char *)&p), numberId).SetDescription("space between cols in pixels")); + td.AddField("delimiter", FieldDescription(((char *)&p.delimiter) - ((char *)&p), stringId).SetDescription("delimiter between text and number; only first character is used")); + td.AddField("charsPerNumber", FieldDescription(((char *)&p.charsPerNumber) - ((char *)&p), numberId).SetDescription("maximum width of a number in chars")); + td.AddField("charsPerAdditionalText", FieldDescription(((char *)&p.charsPerAdditionalText) - ((char *)&p), numberId).SetDescription("maximum number of additional text characters")); + td.AddField("additionalTextGap", FieldDescription(((char *)&p.additionalTextGap) - ((char *)&p), numberId).SetDescription("space between normal and additional text in pixels")); } void MenuProperties::Construct(void *data) { diff --git a/src/graphics/SimpleAnimation.cpp b/src/graphics/SimpleAnimation.cpp index cdd3a8e..7ed7993 100644 --- a/src/graphics/SimpleAnimation.cpp +++ b/src/graphics/SimpleAnimation.cpp @@ -24,14 +24,15 @@ void SimpleAnimation::CreateTypeDescription() { int spriteId(TypeDescription::GetTypeId("Sprite")); TypeDescription &td(TypeDescription::CreateOrGet("SimpleAnimation")); + td.SetDescription("An animation that uses a fixed column and increasing row of a sprite based on the frame number."); td.SetConstructor(&Construct); td.SetSize(sizeof(SimpleAnimation)); td.AddSupertype(animationId, ((char *)a) - ((char *)&sa)); Animation::AddFields(td, sa, ((char *)a) - ((char *)&sa), boolId, numberId, spriteId); - td.AddField("framecount", FieldDescription(((char *)&sa.numFrames) - ((char *)&sa), numberId, false)); - td.AddField("col", FieldDescription(((char *)&sa.col) - ((char *)&sa), numberId, false)); - td.AddField("row", FieldDescription(((char *)&sa.row) - ((char *)&sa), numberId, false)); + td.AddField("framecount", FieldDescription(((char *)&sa.numFrames) - ((char *)&sa), numberId).SetDescription("number of frames of a single run")); + td.AddField("col", FieldDescription(((char *)&sa.col) - ((char *)&sa), numberId).SetDescription("the column of the sprite to draw from")); + td.AddField("row", FieldDescription(((char *)&sa.row) - ((char *)&sa), numberId).SetDescription("the row of the sprite of the first frame")); } void SimpleAnimation::Construct(void *data) { diff --git a/src/graphics/Sprite.cpp b/src/graphics/Sprite.cpp index 434679c..2495cad 100644 --- a/src/graphics/Sprite.cpp +++ b/src/graphics/Sprite.cpp @@ -48,12 +48,15 @@ void Sprite::CreateTypeDescription() { int vectorId(TypeDescription::GetTypeId("Vector")); TypeDescription &td(TypeDescription::CreateOrGet("Sprite")); + td.SetDescription( + "An image + a size and offset.\n" + "The resulting section or a section offset by a multiple of its size can be drawn."); td.SetConstructor(&Construct); td.SetSize(sizeof(Sprite)); - td.AddField("image", FieldDescription(((char *)&s.surface) - ((char *)&s), imageId, true)); - td.AddField("size", FieldDescription(((char *)&s.size) - ((char *)&s), vectorId, false)); - td.AddField("offset", FieldDescription(((char *)&s.offset) - ((char *)&s), vectorId, false)); + td.AddField("image", FieldDescription(((char *)&s.surface) - ((char *)&s), imageId).SetReferenced().SetDescription("the image to cut this sprite from")); + td.AddField("size", FieldDescription(((char *)&s.size) - ((char *)&s), vectorId).SetDescription("dimensions of the sprite")); + td.AddField("offset", FieldDescription(((char *)&s.offset) - ((char *)&s), vectorId).SetDescription("offset into the image, top-left corner of the sprite's (0,0) clip")); } void Sprite::Construct(void *data) { diff --git a/src/loader/Interpreter.cpp b/src/loader/Interpreter.cpp index 0c17bd5..a3d382c 100644 --- a/src/loader/Interpreter.cpp +++ b/src/loader/Interpreter.cpp @@ -350,32 +350,42 @@ void Interpreter::Postpone(int type, int id, std::ptrdiff_t offset, const std::s void Interpreter::CreateTypeDescriptions() { { TypeDescription &td(TypeDescription::CreateOrGet("Boolean")); + td.SetDescription("Logical value which can be either true or false."); td.SetSize(sizeof(bool)); } { TypeDescription &td(TypeDescription::CreateOrGet("Color")); + td.SetDescription( + "A color in RGB format with an optional alpha channel.\n" + "Components range from 0 to 255.\n" + "Alpha defaults to 255 if omitted."); td.SetSize(sizeof(Color)); } { TypeDescription &td(TypeDescription::CreateOrGet("Image")); + td.SetDescription("Path to a PNG file with image data."); td.SetSize(sizeof(SDL_Surface)); } { TypeDescription &td(TypeDescription::CreateOrGet("Number")); + td.SetDescription("A signed integer."); td.SetSize(sizeof(int)); } { int stringId(TypeDescription::GetTypeId("String")); TypeDescription &td(TypeDescription::CreateOrGet("Path")); + td.SetDescription("A path in the filesystem which is interpreted relative to the source file's location."); td.SetSize(1); td.AddSupertype(stringId, 0); } { TypeDescription &td(TypeDescription::CreateOrGet("String")); + td.SetDescription("Some characters."); td.SetSize(1); } { TypeDescription &td(TypeDescription::CreateOrGet("Vector")); + td.SetDescription("A pair of numbers usually describing a 2D translation or offset."); td.SetSize(sizeof(Vector)); } } diff --git a/src/loader/TypeDescription.cpp b/src/loader/TypeDescription.cpp index 8fd95d7..27906fa 100644 --- a/src/loader/TypeDescription.cpp +++ b/src/loader/TypeDescription.cpp @@ -7,10 +7,13 @@ #include "TypeDescription.h" +#include #include #include +#include #include +using std::endl; using std::map; using std::string; using std::vector; @@ -93,4 +96,52 @@ const TypeDescription &TypeDescription::Get(int id) { return typeDescriptions[id]; } + +void TypeDescription::WriteSourceWiki(std::ostream &out) { + vector types; + for (vector::const_iterator i(typeDescriptions.begin()), end(typeDescriptions.end()); i != end; ++i) { + if (i->name != "Animation") { + types.push_back(i->name); + } + } + std::sort(types.begin(), types.end()); + + out << "h2. Data types" << endl << endl; + + for (vector::const_iterator i(types.begin()), end(types.end()); i != end; ++i) { + out << "* [[LoaderSource#" << *i << "|" << *i << "]]" << endl; + } + out << endl << endl; + + for (vector::const_iterator i(types.begin()), end(types.end()); i != end; ++i) { + const TypeDescription &td(Get(GetTypeId(*i))); + out << "h3. " << td.TypeName() << endl << endl; + + if (td.Description()) { + out << td.Description() << endl << endl; + } + + if (td.FieldsBegin() == td.FieldsEnd()) { + out << "No properties." << endl << endl; + } else { + out << "| *Property* | *Type* | *Description* |" << endl; + for (FieldIterator field(td.FieldsBegin()); field != td.FieldsEnd(); ++field) { + const FieldDescription &fd(field->second); + out << "| " << field->first << " | "; + if (fd.IsAggregate()) { + out << "Array<" << Get(fd.TypeId()).TypeName() << ">"; + } else { + out << Get(fd.TypeId()).TypeName(); + } + out << " | "; + if (fd.Description()) { + out << fd.Description(); + } + out << " |" << endl; + } + out << endl; + } + } +} + } diff --git a/src/loader/TypeDescription.h b/src/loader/TypeDescription.h index edd0177..ab8c1bf 100644 --- a/src/loader/TypeDescription.h +++ b/src/loader/TypeDescription.h @@ -8,6 +8,7 @@ #ifndef LOADER_TYPEDESCRIPTION_H_ #define LOADER_TYPEDESCRIPTION_H_ +#include #include #include #include @@ -18,15 +19,21 @@ namespace loader { class FieldDescription { public: - FieldDescription(std::ptrdiff_t offset, int type, bool reference = true, bool aggregate = false) - : offset(offset), type(type), reference(reference), aggregate(aggregate) { } + FieldDescription(std::ptrdiff_t offset, int type) + : description(0), offset(offset), type(type), reference(false), aggregate(false) { } std::ptrdiff_t Offset() const { return offset; }; int TypeId() const { return type; } bool IsReferenced() const { return reference; } bool IsAggregate() const { return aggregate; } + const char *Description() const { return description; } + + FieldDescription &SetReferenced() { reference = true; return *this; } + FieldDescription &SetAggregate() { aggregate = true; return *this; } + FieldDescription &SetDescription(const char *d) { description = d; return *this; } private: + const char *description; std::ptrdiff_t offset; int type; bool reference; @@ -56,6 +63,9 @@ public: void SetSize(int s) { size = s; } int Size() const { return size; } + void SetDescription(const char *d) { description = d; } + const char *Description() const { return description; } + typedef std::map::const_iterator FieldIterator; FieldIterator FieldsBegin() const { return fields.begin(); } FieldIterator FieldsEnd() const { return fields.end(); } @@ -64,12 +74,15 @@ public: static int GetTypeId(const std::string &); static const TypeDescription &Get(int id); + static void WriteSourceWiki(std::ostream &); + private: - TypeDescription(int id, const std::string &name) : constructor(0), loader(0), name(name), id(id), size(0) { } + TypeDescription(int id, const std::string &name) : constructor(0), loader(0), description(0), name(name), id(id), size(0) { } private: void (*constructor)(void *); void (*loader)(void *); + const char *description; std::string name; std::map fields; std::map supertypes; diff --git a/src/main.cpp b/src/main.cpp index 5be8305..793a76f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -102,7 +102,7 @@ int main(int argc, char **argv) { const int tileSize = 32; const float walkSpeed = 128.0f; - const bool battle(false); + bool battle(false); // std::srand(std::time(0)); @@ -138,7 +138,7 @@ int main(int argc, char **argv) { Parser(*i, source).Parse(); } - switch (args.DetectRunLevel()) { + switch (args.GetRunLevel()) { case Arguments::WRITE: { int length(std::strlen(args.OutfilePath())); @@ -158,7 +158,15 @@ int main(int argc, char **argv) { std::cout << source << std::endl; return 0; } + case Arguments::SOURCE_WIKI: { + TypeDescription::WriteSourceWiki(std::cout); + return 0; + } + case Arguments::BATTLE: + battle = true; + break; case Arguments::PLAY: + case Arguments::MAP: break; } diff --git a/src/map/Entity.cpp b/src/map/Entity.cpp index e1f970b..c951f66 100644 --- a/src/map/Entity.cpp +++ b/src/map/Entity.cpp @@ -125,8 +125,8 @@ void Entity::CreateTypeDescription() { td.SetLoader(&Load); td.SetSize(sizeof(Entity)); - td.AddField("animation", FieldDescription(((char *)&e.animation) - ((char *)&e), animationId, true)); - td.AddField("spriteOffset", FieldDescription(((char *)&e.spriteOffset) - ((char *)&e), vectorId, false)); + td.AddField("animation", FieldDescription(((char *)&e.animation) - ((char *)&e), animationId).SetReferenced()); + td.AddField("spriteOffset", FieldDescription(((char *)&e.spriteOffset) - ((char *)&e), vectorId)); } void Entity::Construct(void *data) {