Skip to content

Instantly share code, notes, and snippets.

@rorydriscoll
Created April 7, 2014 00:54
Show Gist options
  • Save rorydriscoll/10013303 to your computer and use it in GitHub Desktop.
Save rorydriscoll/10013303 to your computer and use it in GitHub Desktop.
Inspector window setup
As a post-build step, run type database compiler to grab the pdb and convert it to a custom type database format (just a list of types, fields and enumerators).
struct Type
{
// Name of the type
char name[TypeDatabaseBlueprint::Type::kMaxName];
// Unique id for this type
Hash id;
// Size of the type as seen by the compiler
size_t size;
// The fields of this type if it is a user type
Field* fields;
// The enumeration constants of this type if it is an enum
Enumerator* enumerators;
};
struct Field
{
// Name of the field as seen by the owner.
char name[TypeDatabaseBlueprint::Field::kMaxName];
// The type of the field
const Type* type;
// Offset of the field in the owning type
size_t offset;
// Number of instances of this type for arrays
int count;
// Attributes for this field. See FieldAttribute::Type for details.
uint32_t attributes;
};
struct Enumerator
{
// The name of the constant symbol
char name[TypeDatabaseBlueprint::Enumerator::kMaxName];
// The integer value of the constant
int value;
};
In game, load the type database, query it for the root object and pass that type and object into the inspector window.
Inspector::SetContext(FindType<Application>(app.type_database), &app);
Inspector just draws simple widgets, or arrays of widgets. For more complex types, it just pushes the object and type onto the stack of active fields.
Something like this:
Push(contexts, Context(fields[i].type, object + fields[i].offset));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment