protected static void CreateControl <V>(StructureControl <ProvenceCollectionInstance <V> > control) where V : ProvenceCollectionEntry { //Change to picker ListItem item = new ListItem(); KeySelectorElement keySelector = item.AddKeySelector("Entry Name:", control.structure.key, ProvenceManager.Collections <V>().Keys.ToSet()); keySelector.eventManager.AddListener <MainframeKeySelection <string> >(e => { control.structure.key = e.value; control.eventManager.Raise <MainframeKeySelection <string> >(new MainframeKeySelection <string>(e.value)); control.eventManager.Raise(new StructureControlUpdated <ProvenceCollectionInstance <V> >(control)); }); item.AddButton("Set to Entry").eventManager.AddListener <MouseClickEvent>(e => { if (e.button != 0) { return; } if (control.world != null && control.entity != null) { control.world.eventManager.Raise(new SetEntityToManualEntry <V>(control.entity, keySelector.value)); control.eventManager.Raise(new StructureControlUpdated <ProvenceCollectionInstance <V> >(control)); control.eventManager.Raise(new StructureControlRefreshRequest(100)); } }); control.Add(item); }
public KeySelectorElement AddKeySelector(string labelText, string value, HashSet <string> keys, bool alternate = false, bool secondAlternate = false, bool thirdAlternate = false) { KeySelectorElement keySelector = new KeySelectorElement(labelText, value, keys); keySelector.eventManager.AddListener <MainframeKeySelection <string> >(e => { this.eventManager.Raise <MainframeKeySelection <string> >(e); }); AddAlternates(keySelector, alternate, secondAlternate, thirdAlternate); this.Add(keySelector); return(keySelector); }
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 static void CreateControl(StructureControl <Model> control) { ListItem keySelectorItem = new ListItem(); KeySelectorElement keySelector = keySelectorItem.AddKeySelector("Model Bank Key", control.structure.manualKey, new HashSet <string>(ProvenceManager.ModelBank.Keys)); keySelector.eventManager.AddListener <MainframeKeySelection <string> >(e => { control.structure.manualKey = e.value; control.eventManager.Raise <MainframeKeySelection <string> >(new MainframeKeySelection <string>(e.value)); control.eventManager.Raise <StructureControlUpdated <Model> >(new StructureControlUpdated <Model>(control)); }); keySelector.eventManager.AddListener <ListItemInputCancel>(e => { control.structure.manualKey = ""; control.eventManager.Raise <ListItemInputCancel>(new ListItemInputCancel(control)); control.eventManager.Raise <StructureControlUpdated <Model> >(new StructureControlUpdated <Model>(control)); }); control.Add(keySelectorItem); }
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; } }