Ejemplo n.º 1
0
        public ListItemTextInput AddTextField(string text = "", bool alternate = false, bool secondAlternate = false, bool thirdAlternate = false)
        {
            ListItemTextInput el = new ListItemTextInput(text);

            AddAlternates(el, alternate, secondAlternate, thirdAlternate);
            el.eventManager.AddListener <ListItemInputChange>(e => {
                eventManager.Raise <ListItemInputChange>(new ListItemInputChange(el));
            });
            this.Add(el);
            return(el);
        }
Ejemplo n.º 2
0
        protected void DrawAnimationDrawer(Div container, GameObject model)
        {
            container.Clear();
            bool     alternate     = false;
            Animator animComponent = model.GetComponent <Animator>();

            if (animComponent != null)
            {
                foreach (KeyValuePair <string, ModelAnimationData> kvp in collection[chosenKey].animationData)
                {
                    ListItem item = new ListItem(alternate);

                    KeySelectorElement keyButton = item.AddKeySelector("Animation Key", kvp.Key, Helpers.GetAllTypesFromBaseType(typeof(AnimationKey)).Select(key => key.Name).ToSet());
                    keyButton.eventManager.AddListener <MainframeKeySelection <string> >(e => {
                        if (!collection[chosenKey].animationData.ContainsKey(e.value))
                        {
                            string newKey = e.value;
                            collection[chosenKey].animationData[newKey] = collection[chosenKey].animationData[kvp.Key];
                            collection[chosenKey].animationData.Remove(kvp.Key);
                            eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(SceneManager.GetActiveScene()));
                            DrawAnimationDrawer(container, model);
                        }
                    });

                    item.AddLabel("State Name");
                    ListItemTextInput stateInput = item.AddTextField(kvp.Value.stateName);
                    stateInput.AddToClassList("animation-data-state-input");
                    stateInput.eventManager.AddListener <ListItemInputChange>(e => {
                        collection[chosenKey].animationData[kvp.Key].stateName = stateInput.text;
                        eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(SceneManager.GetActiveScene()));
                    });

                    ListItemIntInput layerInput = item.AddIntField(collection[chosenKey].animationData[kvp.Key].layer);
                    layerInput.AddToClassList("animation-data-layer-input");
                    layerInput.eventManager.AddListener <ListItemInputChange>(e => {
                        collection[chosenKey].animationData[kvp.Key].layer = layerInput.value;
                        eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(SceneManager.GetActiveScene()));
                    });

                    ListItemImage delButton = item.AddImage(delIcon);
                    delButton.AddToClassList("selectable", "hoverable", "icon");

                    delButton.eventManager.AddListener <MouseClickEvent>(e => {
                        collection[chosenKey].animationData.Remove(kvp.Key);
                        eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(SceneManager.GetActiveScene()));
                        DrawAnimationDrawer(container, model);
                    });

                    container.Add(item);
                    alternate = !alternate;
                }
            }
        }
Ejemplo n.º 3
0
        protected void RemoveWorld()
        {
            ListItemTextInput deleteInput = root.Q <ListItemTextInput>("world-editor-delete-input");

            if (deleteInput.text.Equals("DELETE"))
            {
                deleteInput.SetToPlaceholder();
                ProvenceManager.Instance.RemoveWorld(chosenKey);
                eventManager.Raise <SelectKey <World> >(new SelectKey <World>(null));
                eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(EditorSceneManager.GetActiveScene()));
                eventManager.Raise <DrawColumnEventArgs <World> >(new DrawColumnEventArgs <World>(0));
            }
        }
Ejemplo n.º 4
0
        protected void RegisterWorldEditorEventListeners()
        {
            ListItemTextInput deleteInput = root.Q <ListItemTextInput>("world-editor-delete-input");

            deleteInput.eventManager.AddListener <ListItemInputChange>(e => {
                if (deleteInput.text.Equals(""))
                {
                    deleteInput.SetToPlaceholder();
                }
            });
            deleteInput.eventManager.AddListener <ListItemInputCommit>(RemoveWorld);
            root.Q <ListItemImage>("world-editor-back-button").eventManager.AddListener <MouseClickEvent>(e => {
                if (e.button != 0)
                {
                    return;
                }
                deleteInput.SetToPlaceholder();
                eventManager.Raise <SelectKey <World> >(new SelectKey <World>(null));
                eventManager.Raise <DrawColumnEventArgs <World> >(new DrawColumnEventArgs <World>(0));
            });

            root.Q <ListItemTextInput>("world-editor-name-input").eventManager.AddListener <ListItemInputChange>(e => {
                if (!((ListItemTextInput)e.input).text.Equals(chosenKey.worldName))
                {
                    eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(EditorSceneManager.GetActiveScene()));
                }
                if (chosenKey != null)
                {
                    chosenKey.worldName = ((ListItemTextInput)e.input).text;
                }
            });

            root.Q <ListItemText>("world-editor-set-active-button").eventManager.AddListener <MouseClickEvent>(SetAsActiveWorld);

            root.Q <ListItemImage>("add-entity-button").eventManager.AddListener <MouseClickEvent>(CreateEntity);

            root.Q <ListItemImage>("world-editor-delete-button").eventManager.AddListener <MouseClickEvent>(RemoveWorld);

            root.Q <ListItemImage>("world-editor-entity-toggle").eventManager.AddListener <MouseClickEvent>(e => {
                root.Q <ColumnScroller>("world-editor-entity-scroller").Toggle();
            });

            root.Q <ListItemImage>("world-editor-system-toggle").eventManager.AddListener <MouseClickEvent>(e => {
                root.Q <ColumnScroller>("world-editor-system-scroller").Toggle();
            });

            root.Q <Div>("add-package-button").eventManager.AddListener <MouseClickEvent>(AddPackageButtonPressed);
            root.Q <Div>("add-system-button").eventManager.AddListener <MouseClickEvent>(AddSystemButtonPressed);
        }
        protected virtual void RegisterKeyListEvents()
        {
            ListItemTextInput keyInput = root.Q <ListItemTextInput>("new-entry-key-input");

            keyInput.eventManager.AddListener <ListItemInputCommit>(e => {
                AddManualEntry(keyInput.value);
                keyInput.value = "";
            });
            root.Q <ListItemImage>("new-entry-add-button").eventManager.AddListener <MouseClickEvent>(e => {
                if (e.button != 0)
                {
                    return;
                }
                AddManualEntry(keyInput.value);
                keyInput.value = "";
            });
            root.Q <ListItemImage>("new-entry-key-input-clear").eventManager.AddListener <MouseClickEvent>(e => {
                if (e.button != 0)
                {
                    return;
                }
                keyInput.value = "";
            });

            ListItemTextInput searchInput = root.Q <ListItemTextInput>("key-list-search-input");

            searchInput.eventManager.AddListener <ListItemInputChange>(e => {
                SearchKeyList(searchInput.text);
            });

            root.Q <ListItemImage>("key-list-search-clear").eventManager.AddListener <MouseClickEvent>(e => {
                if (e.button != 0)
                {
                    return;
                }
                searchInput.value = "";
                SearchKeyList(searchInput.text);
            });
        }
Ejemplo n.º 6
0
        protected void DrawWorldEditor()
        {
            root.Q <MenuBar>("world-editor-menu-bar").style.display               = DisplayStyle.Flex;
            root.Q <PageColumn>("world-editor").style.display                     = DisplayStyle.Flex;
            root.Q <ListItemText>("world-editor-active-display").style.display    = DisplayStyle.None;
            root.Q <ListItemText>("world-editor-set-active-button").style.display = DisplayStyle.None;

            /* if(ProvenceManager.Instance.activeWorld == chosenKey)
             *  root.Q<ListItemText>("world-editor-active-display").style.display = DisplayStyle.Flex;
             * else
             *  root.Q<ListItemText>("world-editor-set-active-button").style.display = DisplayStyle.Flex; */

            ListItemTextInput nameInput = root.Q <ListItemTextInput>("world-editor-name-input");

            if (nameInput != null)
            {
                nameInput.value = chosenKey.worldName;
            }

            DrawEntityList();
            DrawSystemList();
        }
Ejemplo n.º 7
0
        protected void InitializeSearchBar()
        {
            this.AddToClassList("spacer", "alternate");
            this.searchInput = this.AddTextField();
            this.AddImage(searchIcon).AddToClassList("icon", "selectable", "hoverable");
            ListItemImage searchClearButton = this.AddImage(delIcon);

            searchClearButton.AddToClassList("icon", "selectable", "hoverable");

            searchInput.eventManager.AddListener <ListItemInputChange>(e => {
                string[] queries = searchInput.value.Replace(" ", "").Split('/');
                container.Query("", "search-list-item").ForEach(item => {
                    item.style.display = DisplayStyle.Flex;
                });

                if (!searchInput.value.Equals(""))
                {
                    container.Query("", "search-list-item").ForEach(item => {
                        string itemKey = ((string)item.userData);
                        if (itemKey == null || !ValueContainsQueries(itemKey, queries))
                        {
                            item.style.display = DisplayStyle.None;
                        }
                    });
                }
            });
            searchInput.eventManager.AddListener <ListItemInputCancel>(e => {
                searchInput.value = "";
            });
            searchClearButton.eventManager.AddListener <MouseClickEvent>(e => {
                if (e.button == 0)
                {
                    searchInput.eventManager.Raise <ListItemInputCancel>(new ListItemInputCancel(searchInput));
                }
            });
        }
        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
        }