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); }
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); }
public ListItemImage AddImage(Texture texture, bool alternate = false, bool secondAlternate = false, bool thirdAlternate = false) { ListItemImage el = new ListItemImage(texture, alternate, secondAlternate, thirdAlternate); this.Add(el); return(el); }
protected static void DrawListControls <V>(StructureControl <List <V> > control, Div container) { container.Clear(); for (int i = 0; i < control.structure.Count; i++) { int index = i; if (control.specifiedFields.Contains(typeof(V))) { FieldControl <V> fieldControl = new FieldControl <V>(control.structure[index], control.name + "list-item", "item", false, control.world); fieldControl.eventManager.AddListener <FieldControlUpdated <V> >(e => { control.structure[index] = e.control.value; control.eventManager.Raise(new StructureControlUpdated <List <V> >(control)); }); ListItemImage delButton = fieldControl.AddImage(AssetDatabase.LoadAssetAtPath <Texture>("Assets/Icons/times.png")).AddToClassList("selectable", "hoverable", "icon"); delButton.eventManager.AddListener <MouseClickEvent>(e => { control.structure.RemoveAt(index); control.eventManager.Raise(new StructureControlUpdated <List <V> >(control)); DrawListControls <V>(control, container); }); container.Add(fieldControl); } else { V structure = control.structure[index]; StructureControl <V> structureControl = new StructureControl <V>(ref structure); structureControl.eventManager.AddListener <StructureControlUpdated <V> >(e => { control.eventManager.Raise(new StructureControlUpdated <List <V> >(control)); }); } } }
protected static void DrawSetControls <V>(StructureControl <HashSet <V> > control, Div container) { container.Clear(); foreach (V item in control.structure) { if (control.specifiedFields.Contains(typeof(V))) { FieldControl <V> fieldControl = new FieldControl <V>(item, control.name + "list-item", "item", false, control.world); fieldControl.eventManager.AddListener <FieldControlUpdated <V> >(e => { control.structure.Remove(item); control.structure.Add(e.control.value); control.eventManager.Raise(new StructureControlUpdated <HashSet <V> >(control)); }); ListItemImage delButton = fieldControl.AddImage(AssetDatabase.LoadAssetAtPath <Texture>("Assets/Icons/times.png")).AddToClassList("selectable", "hoverable", "icon"); delButton.eventManager.AddListener <MouseClickEvent>(e => { control.structure.Remove(item); control.eventManager.Raise(new StructureControlUpdated <HashSet <V> >(control)); DrawSetControls <V>(control, container); }); container.Add(fieldControl); } else { V structure = item; StructureControl <V> structureControl = new StructureControl <V>(ref structure); structureControl.eventManager.AddListener <StructureControlUpdated <V> >(e => { control.eventManager.Raise(new StructureControlUpdated <HashSet <V> >(control)); }); } } }
protected void DrawSystems() { bool alternate = false; foreach (System.Type systemType in collection[chosenKey].systems) { ListItem item = new ListItem(alternate); item.userData = systemType.Name; item.AddToClassList("search-list-item"); item.AddTitle(Regex.Replace(systemType.Name, @"((?<=\p{Ll})\p{Lu})|((?!\A)\p{Lu}(?>\p{Ll}))", " $0")); ListItemImage delButton = item.AddImage(delIcon); delButton.AddToClassList("icon", "selectable", "hoverable"); delButton.eventManager.AddListener <MouseClickEvent>(e => { if (e.button != 0) { return; } collection[chosenKey].systems.Remove(systemType); eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(SceneManager.GetActiveScene())); eventManager.Raise <DrawColumnEventArgs <string> >(new DrawColumnEventArgs <string>(1)); }); entryEditorScroller.Add(item); alternate = !alternate; } }
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; } } }
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); }
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; } }); } } }
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; } }
protected void DrawAnchorList(Div container, GameObject model) { container.Clear(); bool alternate = false; foreach (KeyValuePair <string, ModelAnchorData> kvp in collection[chosenKey].anchors) { ListItem anchorItem = new ListItem(alternate); anchorItem.AddToClassList("search-list-item"); anchorItem.userData = kvp.Key; anchorItem.AddToClassList("anchor-list-item"); KeySelectorElement keyInput = anchorItem.AddKeySelector("Anchor Name", kvp.Key, ModelAnchorKeys.keys); keyInput.eventManager.AddListener <MainframeKeySelection <string> >(e => { string newKey = e.value; if (collection[chosenKey].anchors.ContainsKey(newKey)) { return; } collection[chosenKey].anchors[newKey] = collection[chosenKey].anchors[kvp.Key]; collection[chosenKey].anchors.Remove(kvp.Key); eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(SceneManager.GetActiveScene())); DrawAnchorList(container, model); }); HierarchySelectorElement hierarchyInput = anchorItem.AddHierarchySelector("Object", model, ModelBank.GetChildByHierarhcy(model, kvp.Value.hierarchy.ToArray())); hierarchyInput.eventManager.AddListener <MainframeKeySelection <int[]> >(e => { collection[chosenKey].anchors[kvp.Key] = new ModelAnchorData(hierarchyInput.objectDisplay.value.name, hierarchyInput.value); eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(SceneManager.GetActiveScene())); DrawAnchorList(container, model); }); ListItemImage delButton = anchorItem.AddImage(delIcon); delButton.AddToClassList("selectable", "hoverable", "icon"); delButton.eventManager.AddListener <MouseClickEvent>(e => { collection[chosenKey].anchors.Remove(kvp.Key); eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(SceneManager.GetActiveScene())); DrawAnchorList(container, model); }); container.Add(anchorItem); alternate = !alternate; } }
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)); } }); }
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); }
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 }