protected override void OnSchemaSetLoaded(XmlSchemaSet schemaSet) { foreach (XmlSchemaTypeCollection typeCollection in GetTypeCollections()) { m_namespace = typeCollection.TargetNamespace; m_typeCollection = typeCollection; Schema.Initialize(typeCollection); GameAdapters.Initialize(this); // the level editor schema defines only one type collection //break; } }
protected override void OnSchemaSetLoaded(XmlSchemaSet schemaSet) { m_typeCollection = null; foreach (XmlSchemaTypeCollection typeCollection in GetTypeCollections()) { m_namespace = typeCollection.TargetNamespace; m_typeCollection = typeCollection; Schema.Initialize(typeCollection); GameAdapters.Initialize(this); // the level editor schema defines only one type collection break; } if (m_typeCollection == null) { return; } Schema.gameObjectComponentType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( "Name".Localize(), Schema.gameObjectComponentType.nameAttribute, null, "Component name".Localize(), false), new AttributePropertyDescriptor( "Active".Localize(), Schema.gameObjectComponentType.activeAttribute, null, "Is this component active".Localize(), false, new BoolEditor()) })); Schema.renderComponentType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( "Visible".Localize(), Schema.renderComponentType.visibleAttribute, null, "Component visiblity".Localize(), false, new BoolEditor()), new AttributePropertyDescriptor( "cast Shadow".Localize(), Schema.renderComponentType.castShadowAttribute, null, "Is component casts shadaw".Localize(), false, new BoolEditor()), new AttributePropertyDescriptor( "Receive Shadow".Localize(), Schema.renderComponentType.receiveShadowAttribute, null, "Is component receive shadow".Localize(), false, new BoolEditor()), new AttributePropertyDescriptor( "Draw Distance".Localize(), Schema.renderComponentType.drawDistanceAttribute, null, "Minimum distance to draw the component".Localize(), false) })); Schema.spinnerComponentType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( "RPS".Localize(), Schema.spinnerComponentType.rpsAttribute, null, "Revolutions per second".Localize(), false, new NumericTupleEditor(typeof(float), new string[] { "x", "y", "z" }) ) })); ResourceInfo resInfo = m_gameEngine.Info.ResourceInfos.GetByType(ResourceTypes.Model); string filter = resInfo != null ? resInfo.Filter : null; var refEdit = new FileUriEditor(filter); Schema.meshComponentType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new AttributePropertyDescriptor( "3d Model".Localize(), Schema.meshComponentType.refAttribute, null, "path to 3d model".Localize(), false, refEdit ) })); var collectionEditor = new EmbeddedCollectionEditor(); // the following lambda's handles (add, remove, move ) items. collectionEditor.GetItemInsertersFunc = (context) => { var list = context.GetValue() as IList <DomNode>; if (list == null) { return(EmptyArray <EmbeddedCollectionEditor.ItemInserter> .Instance); } // create ItemInserter for each component type. var insertors = new EmbeddedCollectionEditor.ItemInserter[2]; insertors[0] = new EmbeddedCollectionEditor.ItemInserter("StaticMeshComponent", delegate { DomNode node = new DomNode(Schema.meshComponentType.Type); node.SetAttribute(Schema.gameObjectComponentType.nameAttribute, node.Type.Name); list.Add(node); return(node); }); insertors[1] = new EmbeddedCollectionEditor.ItemInserter("SpinnerComponent", delegate { DomNode node = new DomNode(Schema.spinnerComponentType.Type); node.SetAttribute(Schema.gameObjectComponentType.nameAttribute, node.Type.Name); list.Add(node); return(node); }); return(insertors); }; collectionEditor.RemoveItemFunc = (context, item) => { var list = context.GetValue() as IList <DomNode>; if (list != null) { list.Remove(item.Cast <DomNode>()); } }; collectionEditor.MoveItemFunc = (context, item, delta) => { var list = context.GetValue() as IList <DomNode>; if (list != null) { DomNode node = item.Cast <DomNode>(); int index = list.IndexOf(node); int insertIndex = index + delta; if (insertIndex < 0 || insertIndex >= list.Count) { return; } list.RemoveAt(index); list.Insert(insertIndex, node); } }; // add child property descriptors gameObjectType Schema.gameObjectWithComponentType.Type.SetTag( new PropertyDescriptorCollection( new PropertyDescriptor[] { new ChildPropertyDescriptor( "Components".Localize(), Schema.gameObjectWithComponentType.componentChild, null, "List of GameObject Components".Localize(), false, collectionEditor) })); LevelEditorXLE.Patches.OnSchemaSetLoaded(schemaSet, GetTypeCollections()); }