protected virtual void DrawComponent(ProvenceComponent component, VisualElement parent, bool removeable = true, bool hide = false)
        {
            Div container = new Div();

            container.AddToClassList("search-list-item");
            container.userData = component.GetType().Name;
            foreach (Type tag in collection[chosenKey].tags)
            {
                if (((MainframeTag)Activator.CreateInstance(tag)).requiredComponents.Contains(component.GetType()))
                {
                    container.userData += tag.Name;
                }
            }
            ListItem     titleItem = new ListItem(false, true);
            ListItemText title     = titleItem.AddTitle(System.Text.RegularExpressions.Regex.Replace(component.GetType().Name, @"((?<=\p{Ll})\p{Lu})|((?!\A)\p{Lu}(?>\p{Ll}))", " $0"));

            titleItem.name = component.GetType().Name.ToLower() + "-control-title";
            titleItem.AddToClassList("structure-control-title", "spacer");

            Div structContainer = (Div)Helpers.InvokeGenericMethod <ProvenceCollectionEditor <U> >(this, "DrawComponentControl", component.GetType(), component);

            titleItem.eventManager.AddListener <MouseClickEvent>(e => {
                switch (e.button)
                {
                case 0:
                    if (title.ClassListContains("second-alternate"))
                    {
                        title.RemoveFromClassList("second-alternate");
                    }
                    else
                    {
                        title.AddToClassList("second-alternate");
                    }
                    structContainer.Toggle();
                    break;

                case 1:
                    if (removeable)
                    {
                        entryEditorComponentContextMenu.Show(root, e, true);

                        ListItem removeButton = entryEditorComponentContextMenu.Q <ListItem>("entry-editor-component-remove-button");
                        removeButton.eventManager.ClearListeners();
                        removeButton.eventManager.AddListener <MouseClickEvent>(ev => {
                            Helpers.InvokeGenericMethod <ProvenceCollectionEditor <U> >(this, "RemoveComponentFromEntry", component.GetType());
                            entryEditorComponentContextMenu.Toggle();
                        });
                    }
                    break;
                }
            });

            if (hide)
            {
                titleItem.eventManager.Raise <MouseClickEvent>(new MouseClickEvent(titleItem, 0, Vector2.zero));
            }

            container.Add(titleItem, structContainer);
            parent.Add(container);
        }
Beispiel #2
0
 public RemoveComponent(Entity entity, ProvenceComponent component)
 {
     this.entity    = entity;
     this.component = component;
 }
Beispiel #3
0
 public RemoveComponent()
 {
     this.entity    = "";
     this.component = null;
 }
Beispiel #4
0
 public AddComponent()
 {
     this.entity    = "";
     this.component = null;
 }