protected virtual void DrawEntryEditor()
 {
     entryEditorScroller.Clear();
     DrawEntryTitle();
     DrawComponentList();
     DrawTagList();
     VerifyTagComponents();
     DrawModelViewer();
 }
Exemplo n.º 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;
                        }
                    });
                }
            }
        }
Exemplo n.º 3
0
        protected void DrawComponentList()
        {
            if (componentListScroller == null)
            {
                return;
            }
            componentListScroller.Clear();
            editorScroller.Clear();

            if (chosenKey != null)
            {
                DropDownMenu contextMenu = root.Q <DropDownMenu>("component-list-context-menu");
                bool         alternate   = false;
                foreach (ComponentHandle <ProvenceComponent> handle in chosenKey.GetAllComponents())
                {
                    if (handle == null || handle.component == null || handle.component.GetType().IsDefined(typeof(DontDisplayInEditor), false))
                    {
                        continue;
                    }
                    DrawComponentListItem(handle, contextMenu, alternate);
                    alternate = !alternate;
                }
            }
        }
Exemplo n.º 4
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);
            }
        }
Exemplo n.º 5
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;
            }
        }
Exemplo n.º 6
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;
                        }
                    });
                }
            }
        }
        protected virtual 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();
                            });
                            ListItem removeAllButton = entryEditorTagContextMenu.Q <ListItem>("entry-editor-tag-remove-all-button");
                            removeAllButton.eventManager.ClearListeners();
                            removeAllButton.eventManager.AddListener <MouseClickEvent>(ev => {
                                RemoveTagCompleteFromEntry((dynamic)tagElement.userData);
                                entryEditorTagContextMenu.Toggle();
                            });
                            break;
                        }
                    });

                    tagListScroller.Add(tagElement);
                }
            }
        }
        protected virtual void DrawKeyList()
        {
            keyListScroller.Clear();
            bool alternate = false;

            collection.Sort();
            foreach (string key in collection.Keys)
            {
                ListItem item = new ListItem(alternate, true, true);
                item.userData = key;
                item.AddIndent(true);

                ListItemImage icon = item.AddImage(keyIcon);
                icon.AddToClassList("icon");
                ListItemTextInput nameInput = item.AddTextField(key);
                nameInput.AddToClassList("key-list-name-input");
                ListItemText nameDisplay = item.AddTextDisplay(key);

                if (chosenKey == key)
                {
                    item.AddToClassList("selected");
                    item.Q <ListItemImage>().SetImage(selectedKeyIcon);
                }

                item.eventManager.AddListener <MouseClickEvent>(e => {
                    switch (e.button)
                    {
                    case 0:
                        if (!item.ClassListContains("selected"))
                        {
                            ListItem selected = keyListScroller.Q <ListItem>(null, "selected");
                            if (selected != null)
                            {
                                selected.RemoveFromClassList("selected");
                                selected.Q <ListItemImage>().SetImage(keyIcon);
                            }
                            item.AddToClassList("selected");
                            icon.SetImage(selectedKeyIcon);

                            eventManager.Raise <SelectKey <string> >(new SelectKey <string>(key));
                        }
                        break;

                    case 1:
                        keyListContextMenu.Show(root, e, true);
                        ListItem editButton = keyListContextMenu.Q <ListItem>("key-list-context-menu-edit-button");
                        editButton.eventManager.ClearListeners();
                        editButton.eventManager.AddListener <MouseClickEvent>(ev => {
                            if (ev.button != 0)
                            {
                                return;
                            }
                            nameInput.style.display          = DisplayStyle.Flex;
                            nameDisplay.style.display        = DisplayStyle.None;
                            keyListContextMenu.style.display = DisplayStyle.None;
                        });

                        ListItem removeButton = keyListContextMenu.Q <ListItem>("key-list-context-menu-remove-button");
                        removeButton.eventManager.ClearListeners();
                        removeButton.eventManager.AddListener <MouseClickEvent>(ev => {
                            if (ev.button != 0)
                            {
                                return;
                            }
                            RemoveManualEntry(key);
                            keyListContextMenu.style.display = DisplayStyle.None;
                        });
                        break;
                    }
                });

                nameInput.eventManager.AddListener <ListItemInputCommit>(e => {
                    EditManualEntryKey(key, nameInput.value);
                });

                nameInput.eventManager.AddListener <ListItemInputCancel>(e => {
                    nameInput.value           = key;
                    nameInput.style.display   = DisplayStyle.None;
                    nameDisplay.style.display = DisplayStyle.Flex;
                });

                keyListScroller.Add(item);
                alternate = !alternate;
            }
            //Scroll to selected if exists
        }
Exemplo n.º 9
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;
            }
        }
Exemplo n.º 10
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;
            }
        }