Пример #1
0
 protected override void InitializeWindow()
 {
     if (root == null)
     {
         return;
     }
     componentListScroller = root.Q <ColumnScroller>("component-list-scroller");
     editorScroller        = root.Q <ColumnScroller>("editor-scroller");
 }
Пример #2
0
        protected void DrawEntityList()
        {
            ColumnScroller scroller = root.Q <ColumnScroller>("list-scroller");

            if (chosenWorld != null && scroller != null)
            {
                scroller.Clear();
                bool alternate = false;
                foreach (EntityHandle handle in chosenWorld.LookUpAllEntities())
                {
                    ListItem item = new ListItem(alternate, true, true);
                    item.AddIndent();
                    ListItemImage icon = item.AddImage(entityIcon);
                    icon.AddToClassList("icon");

                    ComponentHandle <Name> nameHandle = handle.GetComponent <Name>();
                    if (name != null)
                    {
                        item.AddTextDisplay(nameHandle.component.name);
                    }
                    else
                    {
                        item.AddTextDisplay(handle.entity.ToString());
                    }

                    scroller.Add(item);
                    alternate = !alternate;

                    item.eventManager.AddListener <MouseClickEvent>(e => {
                        if (e.button != 0)
                        {
                            return;
                        }
                        if (item.ClassListContains("selected"))
                        {
                            ReturnSelection();
                        }
                        else
                        {
                            scroller.Query <ListItem>(null, "selected").ForEach(current => {
                                current.RemoveFromClassList("selected");
                            });
                            item.AddToClassList("selected");
                            chosenKey = handle.entity;
                        }
                    });
                }
            }
        }
Пример #3
0
        protected void DrawSystemControl <T>() where T : ProvenceSystem
        {
            ColumnScroller scroller = root.Q <ColumnScroller>("editor-scroller");
            T system = (T)chosenKey;

            if (scroller != null)
            {
                scroller.Clear();
                StructureControl <T> control = new StructureControl <T>(ref system, system.GetType().Name, false, chosenKey.world);
                control.eventManager.AddListener <StructureControlUpdated <T> >(e => {
                    eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(SceneManager.GetActiveScene()));
                });
                scroller.Add(control);
            }
        }
Пример #4
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;
            }
        }
Пример #5
0
        protected void SortListBySearch()
        {
            ColumnScroller scroller = root.Q <ColumnScroller>("list-scroller");

            scroller.Query <ListItem>().ForEach(item => {
                item.style.display = DisplayStyle.Flex;
            });

            if (!searchString.Equals(""))
            {
                scroller.Query <ListItem>().ForEach(item => {
                    if (!item.Q <ListItemText>().text.ToLower().Contains(searchString.ToLower()))
                    {
                        item.style.display = DisplayStyle.None;
                    }
                });
            }
        }
        protected override void InitializeWindow()
        {
            if (root == null)
            {
                return;
            }
            keyListScroller     = root.Q <ColumnScroller>("key-list-scroller");
            entryEditorScroller = root.Q <ColumnScroller>("entry-editor-scroller");
            root.Q <ListItemSearchBar>("entry-editor-search-bar").container = entryEditorScroller;
            tagListScroller = root.Q <ColumnScroller>("entry-editor-tag-scroller");

            keyListContextMenu = root.Q <DropDownMenu>("key-list-context-menu");
            entryEditorComponentContextMenu = root.Q <DropDownMenu>("entry-editor-component-context-menu");
            entryEditorTagContextMenu       = root.Q <DropDownMenu>("entry-editor-tag-context-menu");
            keyIcon         = UnityEditor.AssetDatabase.LoadAssetAtPath <Texture>("Assets/Icons/bookmark-open.png");
            selectedKeyIcon = UnityEditor.AssetDatabase.LoadAssetAtPath <Texture>("Assets/Icons/bookmark.png");
            eventManager.Raise <DrawColumnEventArgs <string> >(new DrawColumnEventArgs <string>(0));
        }
Пример #7
0
        protected void DrawKeyList()
        {
            ColumnScroller scroller = root.Q <ColumnScroller>("list-scroller");

            if (scroller != null)
            {
                scroller.Clear();
                bool alternate = false;
                foreach (string key in set)
                {
                    ListItem item = new ListItem(alternate, true, true);
                    item.AddIndent();

                    /* ListItemImage icon = item.AddImage(entityIcon);
                     * icon.AddToClassList("icon"); */

                    item.AddTitle(key);

                    scroller.Add(item);
                    alternate = !alternate;

                    item.eventManager.AddListener <MouseClickEvent>(e => {
                        if (e.button != 0)
                        {
                            return;
                        }
                        if (item.ClassListContains("selected"))
                        {
                            ReturnSelection();
                        }
                        else
                        {
                            scroller.Query <ListItem>(null, "selected").ForEach(current => {
                                current.RemoveFromClassList("selected");
                            });
                            item.AddToClassList("selected");
                            chosenKey = key;
                        }
                    });
                }
            }
        }
Пример #8
0
        protected void DrawSystemList()
        {
            ColumnScroller scroller = root.Q <ColumnScroller>("world-editor-system-scroller");

            scroller.Clear();
            bool         alternate   = false;
            DropDownMenu contextMenu = root.Q <DropDownMenu>("system-list-context-menu");

            foreach (string package in chosenKey.systemManager.systemPackages)
            {
                ListItem item = new ListItem(alternate, true, true);
                item.AddIndent();
                item.AddImage(packageIcon).AddToClassList("icon");
                item.AddTextDisplay(package);
                scroller.Add(item);

                item.eventManager.AddListener <MouseClickEvent>(e => {
                    switch (e.button)
                    {
                    case 0:
                        ListItem selected = scroller.Q <ListItem>(null, "selected");
                        if (selected != null)
                        {
                            selected.RemoveFromClassList("selected");
                        }
                        item.AddToClassList("selected");
                        break;

                    case 1:
                        contextMenu.Show(root, e, true);
                        ListItemText removeButton = root.Q <ListItemText>("system-list-context-menu-remove-button");
                        removeButton.eventManager.ClearListeners();
                        removeButton.eventManager.AddListener <MouseClickEvent>(ev => {
                            if (ev.button != 0)
                            {
                                return;
                            }
                            chosenKey.systemManager.systemPackages.Remove(package);
                            eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(EditorSceneManager.GetActiveScene()));
                            eventManager.Raise <DrawColumnEventArgs <World> >(new DrawColumnEventArgs <World>(1));
                        });
                        break;
                    }
                });

                alternate = !alternate;
            }

            foreach (System.Type systemType in chosenKey.systemManager.GetCurrentSystemTypes())
            {
                ListItem item = new ListItem(alternate, true, true);
                item.AddIndent();
                item.AddImage(systemIcon).AddToClassList("icon");
                item.AddTextDisplay(Regex.Replace(systemType.Name, @"((?<=\p{Ll})\p{Lu})|((?!\A)\p{Lu}(?>\p{Ll}))", " $0"));

                item.eventManager.AddListener <MouseClickEvent>(e => {
                    switch (e.button)
                    {
                    case 0:
                        if (item.ClassListContains("selected"))
                        {
                            Helpers.InvokeGenericMethod(this, "OpenSystemEditor", systemType);
                        }
                        else
                        {
                            ListItem selected = scroller.Q <ListItem>(null, "selected");
                            if (selected != null)
                            {
                                selected.RemoveFromClassList("selected");
                            }
                            item.AddToClassList("selected");
                        }
                        break;

                    case 1:
                        contextMenu.Show(root, e, true);
                        ListItemText removeButton = root.Q <ListItemText>("system-list-context-menu-remove-button");
                        removeButton.eventManager.ClearListeners();
                        removeButton.eventManager.AddListener <MouseClickEvent>(ev => {
                            if (ev.button != 0)
                            {
                                return;
                            }
                            Helpers.InvokeGenericMethod(this, "RemoveSystem", systemType);
                            contextMenu.style.display = DisplayStyle.None;
                        });
                        break;
                    }
                });

                scroller.Add(item);
                alternate = !alternate;
            }
        }
Пример #9
0
        protected void DrawEntityList()
        {
            ColumnScroller scroller = root.Q <ColumnScroller>("world-editor-entity-scroller");

            scroller.Clear();
            bool         alternate   = false;
            DropDownMenu contextMenu = root.Q <DropDownMenu>("entity-list-context-menu");

            foreach (EntityHandle entityHandle in chosenKey.LookUpAllEntities())
            {
                ListItem item = new ListItem(alternate, true, true);
                item.AddIndent();
                item.AddImage(entityIcon).AddToClassList("icon");

                ComponentHandle <Name> nameHandle = entityHandle.GetComponent <Name>();
                if (nameHandle != null)
                {
                    item.AddTextDisplay(nameHandle.component.name);
                }
                else
                {
                    item.AddTextDisplay(entityHandle.entity.ToString());
                }

                item.eventManager.AddListener <MouseClickEvent>(e => {
                    switch (e.button)
                    {
                    case 0:
                        ComponentHandle <UnityGameObject> objectHandle = entityHandle.GetComponent <UnityGameObject>();
                        GameObject entityGO = objectHandle != null ? objectHandle.component.gameObject : null;
                        if (entityGO != null)
                        {
                            Selection.objects = new Object[] { entityGO };
                        }
                        if (item.ClassListContains("selected"))
                        {
                            EntityEditor.Show(entityHandle);
                        }
                        else
                        {
                            ListItem selected = scroller.Q <ListItem>(null, "selected");
                            if (selected != null)
                            {
                                selected.RemoveFromClassList("selected");
                            }
                            item.AddToClassList("selected");
                        }
                        break;

                    case 1:
                        contextMenu.Show(root, e, true);
                        ListItemText duplicateButton = root.Q <ListItemText>("entity-list-context-menu-duplicate-button");
                        duplicateButton.eventManager.ClearListeners();
                        duplicateButton.eventManager.AddListener <MouseClickEvent>(ev => {
                            if (ev.button != 0)
                            {
                                return;
                            }
                            DuplicateEntity(entityHandle);
                            contextMenu.style.display = DisplayStyle.None;
                        });

                        ListItemText removeButton = root.Q <ListItemText>("entity-list-context-menu-remove-button");
                        removeButton.eventManager.ClearListeners();
                        removeButton.eventManager.AddListener <MouseClickEvent>(ev => {
                            if (ev.button != 0)
                            {
                                return;
                            }
                            RemoveEntity(entityHandle);
                            contextMenu.style.display = DisplayStyle.None;
                        });
                        break;
                    }
                });

                scroller.Add(item);
                alternate = !alternate;
            }
        }