예제 #1
0
        public Div AddIndent(bool alternate = false)
        {
            Div el = new Div();

            el.AddToClassList("list-item-indent");
            if (alternate)
            {
                el.AddToClassList("alternate");
            }
            this.Add(el);
            return(el);
        }
        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);
        }
예제 #3
0
        protected ListItem DrawShelf(string titleText, out Div container)
        {
            ListItem titleItem = new ListItem();

            titleItem.AddToClassList("spacer", "selectable", "container-title");
            ListItemText title = titleItem.AddTitle(titleText);

            container = new Div();
            container.AddToClassList("category-container");

            Div containerRef = container;

            titleItem.eventManager.AddListener <MouseClickEvent>(e => {
                if (e.button != 0)
                {
                    return;
                }
                if (title.ClassListContains("second-alternate"))
                {
                    title.RemoveFromClassList("second-alternate");
                }
                else
                {
                    title.AddToClassList("second-alternate");
                }
                containerRef.Toggle();
            });
            return(titleItem);
        }
예제 #4
0
        public Div AddDiv(bool alternate = false)
        {
            Div el = new Div();

            if (alternate)
            {
                el.AddToClassList("alternate");
            }
            this.Add(el);
            return(el);
        }
예제 #5
0
        protected void DrawAnimationControls(GameObject model)
        {
            Div animationDrawer = new Div();

            ListItem titleItem = new ListItem();

            titleItem.AddToClassList("spacer", "selectable", "container-title");
            titleItem.AddImage(null);
            ListItemText  title     = titleItem.AddTitle("Animation Keys");
            ListItemImage addButton = titleItem.AddImage(addIcon);

            addButton.AddToClassList("hoverable", "selectable");

            addButton.eventManager.AddListener <MouseClickEvent>(e => {
                if (e.button != 0)
                {
                    return;
                }
                collection[chosenKey].animationData[""] = new ModelAnimationData();
                eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(SceneManager.GetActiveScene()));
                DrawAnimationDrawer(animationDrawer, model);
            });

            Div container = new Div();

            container.AddToClassList("category-container");

            title.eventManager.AddListener <MouseClickEvent>(e => {
                if (e.button != 0)
                {
                    return;
                }
                if (title.ClassListContains("second-alternate"))
                {
                    title.RemoveFromClassList("second-alternate");
                }
                else
                {
                    title.AddToClassList("second-alternate");
                }
                container.Toggle();
            });

            ListItem searchBar = new ListItemSearchBar(animationDrawer);

            DrawAnimationDrawer(animationDrawer, model);

            container.Add(searchBar, animationDrawer);
            entryEditorScroller.Add(titleItem, container);
        }