Example #1
0
        //Inputs

        public ListItemText AddButton(string text, bool alternate = false, bool secondAlternate = false, bool thirdAlternate = false)
        {
            ListItemText el = new ListItemText(text, alternate, secondAlternate, thirdAlternate);

            el.AddToClassList("list-item-button");
            el.AddToClassList("selectable");
            this.Add(el);
            return(el);
        }
Example #2
0
        protected override void DrawTagList()
        {
            tagListScroller.Clear();
            if (chosenKey != null)
            {
                foreach (System.Type tag in collection[chosenKey].tags)
                {
                    ListItemText tagElement = new ListItemText(tag.Name);
                    tagElement.userData = tag;
                    tagElement.AddToClassList("entry-editor-tag");

                    tagElement.eventManager.AddListener <MouseClickEvent>(e => {
                        switch (e.button)
                        {
                        case 0:
                            ListItemSearchBar compSearchBar = root.Q <ListItemSearchBar>("entry-editor-search-bar");
                            compSearchBar.searchInput.value = compSearchBar.searchInput.value.Replace(" ", "");
                            if (tagElement.ClassListContains("selected"))
                            {
                                tagElement.RemoveFromClassList("selected");
                                compSearchBar.searchInput.value = compSearchBar.searchInput.text.ToLower().Replace(tag.Name.ToLower() + "/", "");
                            }
                            else
                            {
                                tagElement.AddToClassList("selected");
                                if (compSearchBar.searchInput.value == "")
                                {
                                    compSearchBar.searchInput.value = tag.Name.ToLower() + "/";
                                }
                                else
                                {
                                    if (compSearchBar.searchInput.value[compSearchBar.searchInput.value.Length - 1] != '/')
                                    {
                                        compSearchBar.searchInput.value += "/";
                                    }
                                    compSearchBar.searchInput.value += tag.Name.ToLower() + "/";
                                }
                            }
                            break;

                        case 1:
                            entryEditorTagContextMenu.Show(root, e, true);
                            ListItem removeButton = entryEditorTagContextMenu.Q <ListItem>("entry-editor-tag-remove-button");
                            removeButton.eventManager.ClearListeners();
                            removeButton.eventManager.AddListener <MouseClickEvent>(ev => {
                                RemoveTagFromEntry((dynamic)tagElement.userData);
                                entryEditorTagContextMenu.Toggle();
                            });
                            break;
                        }
                    });

                    tagListScroller.Add(tagElement);
                }
            }
        }
Example #3
0
        protected void InitializeElement(string labelText)
        {
            label = new ListItemText(labelText);
            label.AddToClassList("list-item-label");

            objectDisplay = new ObjectField();
            objectDisplay.allowSceneObjects = false;
            objectDisplay.objectType        = typeof(GameObject);
            objectDisplay.value             = objectValue;
            objectDisplay.AddToClassList("list-item-input", "list-item-object-input", "second-alternate");

            button = new ListItemImage(caretIcon);
            button.AddToClassList("selectable", "hoverable");

            button.eventManager.AddListener <MouseClickEvent>(e => {
                if (e.button != 0)
                {
                    return;
                }
                HierarchySelector hierarchySelector = HierarchySelector.Open();
                hierarchySelector.eventManager.Raise <SetSelectorParameters <GameObject> >(new SetSelectorParameters <GameObject>(root));
                hierarchySelector.eventManager.AddListener <MainframeKeySelection <int[]> >(ev => {
                    this.value = ev.value;
                    this.objectDisplay.value = HierarchySelector.GetChildByHierarhcy(root, ev.value);
                    this.eventManager.Raise <MainframeKeySelection <int[]> >(ev);
                });
            });

            this.Add(label, objectDisplay, button);
        }
Example #4
0
        protected void InitializeElement(string labelText, string value)
        {
            label = new ListItemText(labelText);
            label.AddToClassList("list-item-label", "alternate");

            keyDisplay = new ListItemText(value);
            keyDisplay.AddToClassList("list-item-text-display");

            button = new ListItemImage(caretIcon);
            button.AddToClassList("selectable", "hoverable");

            button.eventManager.AddListener <MouseClickEvent>(e => {
                if (e.button != 0)
                {
                    return;
                }
                KeySelector keySelector = KeySelector.Open();
                keySelector.eventManager.Raise <SetSelectorParameters <HashSet <string> > >(new SetSelectorParameters <HashSet <string> >(keys));
                keySelector.eventManager.AddListener <MainframeKeySelection <string> >(ev => {
                    keyDisplay.text = ev.value;
                    value           = ev.value;
                    this.eventManager.Raise <MainframeKeySelection <string> >(ev);
                });
            });

            this.Add(label, keyDisplay, button);
        }
        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);
        }
        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);
        }
Example #7
0
        public ListItemText AddLabel(string text, bool alternate = false, bool secondAlternate = false, bool thirdAlternate = false)
        {
            ListItemText el = new ListItemText(text, alternate, secondAlternate, thirdAlternate);

            el.AddToClassList("list-item-label");
            this.Add(el);
            return(el);
        }
Example #8
0
        protected void DrawWorldList()
        {
            root.Q <MenuBar>("world-table-menu-bar").style.display = DisplayStyle.Flex;
            root.Q <PageColumn>("world-table").style.display       = DisplayStyle.Flex;

            ColumnScroller scroller = root.Q <ColumnScroller>("world-table-scroller");

            scroller.Clear();
            bool alternate = false;

            foreach (World world in ProvenceManager.Instance.worlds.Values)
            {
                ListItem item = new ListItem(alternate, true, true);
                item.name = world.id;
                item.AddIndent();
                ListItemImage icon = item.AddImage(worldTableItemIcon);
                icon.AddToClassList("icon");

                ListItemText nameDisplay = item.AddTextDisplay(world.worldName);
                nameDisplay.AddToClassList("selectable");
                nameDisplay.AddToClassList("world-table-item-name");

                item.eventManager.AddListener <MouseClickEvent>(e => {
                    if (e.button != 0)
                    {
                        return;
                    }
                    if (item.ClassListContains("selected"))
                    {
                        eventManager.Raise <SelectKey <World> >(new SelectKey <World>(world));
                    }
                    else
                    {
                        VisualElement selected = root.Q <VisualElement>(null, "selected");
                        if (selected != null)
                        {
                            selected.RemoveFromClassList("selected");
                        }
                        item.AddToClassList("selected");
                    }
                });

                scroller.Add(item);
                alternate = !alternate;
            }
        }
Example #9
0
        public ListItemText AddTextDisplay(string text, bool alternate = false, bool secondAlternate = false, bool thirdAlternate = false)
        {
            ListItemText el = new ListItemText(text, alternate, secondAlternate, thirdAlternate);

            el.AddToClassList("list-item-text-display");
            AddAlternates(el, alternate, secondAlternate, thirdAlternate);
            this.Add(el);
            return(el);
        }
Example #10
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);
        }
Example #11
0
        public ListItemText AddEntitySelector(World world, Entity value = null)
        {
            ListItemText el = new ListItemText();

            el.AddToClassList("list-item-text-display");
            el.AddToClassList("hoverable");
            el.AddToClassList("selectable");
            if (value != null)
            {
                el.text = value.ToString();
            }

            EntityHandle handle = world.LookUpEntity((Entity)el.text);

            if (handle == null)
            {
                el.text = "";
                eventManager.Raise <ListItemInputChange>(new ListItemInputChange(el));
            }
            el.eventManager.AddListener <MouseClickEvent>(e => {
                handle = world.LookUpEntity((Entity)el.text);
                if (handle != null)
                {
                    ComponentHandle <UnityGameObject> objectHandle = handle.GetComponent <UnityGameObject>();
                    GameObject go = objectHandle != null ? objectHandle.component.gameObject : null;
                    if (go != null)
                    {
                        Selection.objects = new UnityEngine.Object[] { go }
                    }
                    ;
                }
            });

            ListItemImage button = new ListItemImage("Assets/Icons/caret-down.png");

            button.AddToClassList("hoverable");
            button.AddToClassList("selectable");
            button.eventManager.AddListener <MouseClickEvent>(e => {
                EntitySelector.Open(world, args => {
                    el.text = args.value.ToString();
                    eventManager.Raise <ListItemInputChange>(new ListItemInputChange(el));
                });
            });

            ListItemImage clearButton = new ListItemImage("Assets/Icons/times.png");

            clearButton.AddToClassList("hoverable");
            clearButton.AddToClassList("selectable");
            clearButton.eventManager.AddListener <MouseClickEvent>(e => {
                if (el.text.Equals(""))
                {
                    return;
                }
                el.text = "";
                eventManager.Raise <ListItemInputChange>(new ListItemInputChange(el));
            });

            this.Add(el);
            this.Add(button);
            this.Add(clearButton);
            return(el);
        }