]> git.localhorst.tv Git - l2e.git/blobdiff - src/loader/TypeDescription.cpp
fixed trigger type switch in Map
[l2e.git] / src / loader / TypeDescription.cpp
index ed88e8ec8eedee6e3d4f83d482ae7008f39e0440..27906fab758b486c247edcc0d86be6b6d03f2591 100644 (file)
@@ -7,10 +7,13 @@
 
 #include "TypeDescription.h"
 
+#include <algorithm>
 #include <cassert>
 #include <cstring>
+#include <ostream>
 #include <stdexcept>
 
+using std::endl;
 using std::map;
 using std::string;
 using std::vector;
@@ -46,6 +49,12 @@ void TypeDescription::Construct(void *data) const {
        }
 }
 
+void TypeDescription::Load(void *data) const {
+       if (loader) {
+               (*loader)(data);
+       }
+}
+
 
 void TypeDescription::AddSupertype(int id, std::ptrdiff_t offset) {
        supertypes[id] = offset;
@@ -87,4 +96,52 @@ const TypeDescription &TypeDescription::Get(int id) {
        return typeDescriptions[id];
 }
 
+
+void TypeDescription::WriteSourceWiki(std::ostream &out) {
+       vector<string> types;
+       for (vector<TypeDescription>::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<string>::const_iterator i(types.begin()), end(types.end()); i != end; ++i) {
+               out << "* [[LoaderSource#" << *i << "|" << *i << "]]" << endl;
+       }
+       out << endl << endl;
+
+       for (vector<string>::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;
+               }
+       }
+}
+
 }