protected void AddPackageButtonPressed(MouseClickEvent e) { if (e.button != 0) { return; } HashSet <string> set = new HashSet <string>(); foreach (string key in ProvenceManager.Collections <SystemPackage>().Keys) { if (!chosenKey.systemManager.systemPackages.Contains(key)) { set.Add(key); } } KeySelector keySelector = KeySelector.Open(); keySelector.eventManager.AddListener <MainframeKeySelection <string> >(ev => { chosenKey.systemManager.systemPackages.Add(ev.value); chosenKey.systemManager.systemPackages = new HashSet <string>(chosenKey.systemManager.systemPackages.OrderBy(p => p)); eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(EditorSceneManager.GetActiveScene())); eventManager.Raise <DrawColumnEventArgs <World> >(new DrawColumnEventArgs <World>(1)); }); keySelector.eventManager.Raise <SetSelectorParameters <HashSet <string> > >(new SetSelectorParameters <HashSet <string> >(set)); }
protected void RemoveWorld(MouseClickEvent e) { if (e.button != 0) { return; } RemoveWorld(); }
protected void CreateEntity(MouseClickEvent e) { if (e.button != 0) { return; } chosenKey.CreateEntity(); eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(EditorSceneManager.GetActiveScene())); eventManager.Raise <DrawColumnEventArgs <World> >(new DrawColumnEventArgs <World>(1)); }
//World Table Methods protected void AddWorld(MouseClickEvent e) { if (e.button != 0) { return; } // ProvenceManager.Instance.AddWorld(new World()); // eventManager.Raise<SetSceneDirtyEvent>(new SetSceneDirtyEvent(EditorSceneManager.GetActiveScene())); // eventManager.Raise<DrawColumnEventArgs<World>>(new DrawColumnEventArgs<World>(0)); }
protected void RemoveGameObject(MouseClickEvent e) { if (e.button != 0 || chosenGameObject == null || chosenKey == null) { return; } chosenKey.RemoveComponent <UnityGameObject>(); chosenGameObject = null; eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(SceneManager.GetActiveScene())); eventManager.Raise <DrawColumnEventArgs <ProvenceComponent> >(new DrawColumnEventArgs <ProvenceComponent>(2)); }
protected void AddGameObject(MouseClickEvent e) { if (e.button != 0 || chosenGameObject != null || chosenKey == null) { return; } chosenGameObject = chosenKey.GetOrCreateComponent <UnityGameObject>().component.gameObject; Selection.objects = new Object[] { chosenGameObject }; eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(SceneManager.GetActiveScene())); eventManager.Raise <DrawColumnEventArgs <ProvenceComponent> >(new DrawColumnEventArgs <ProvenceComponent>(2)); }
//World Editor Methods protected void SetAsActiveWorld(MouseClickEvent e) { if (e.button != 0) { return; } //ProvenceManager.Instance.activeWorld = chosenKey; root.Q <ListItemText>("world-editor-set-active-button").style.display = DisplayStyle.None; root.Q <ListItemText>("world-editor-active-display").style.display = DisplayStyle.Flex; eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(EditorSceneManager.GetActiveScene())); }
protected void AddSystemButtonPressed(MouseClickEvent e) { if (e.button != 0) { return; } List <System.Type> existingTypes = chosenKey.systemManager.GetCurrentSystemTypes(); TypeSelector.TypeSelectorParameters searchParameters = new TypeSelector.TypeSelectorParameters(typeof(ProvenceSystem), false, chosenKey.systemManager.GetCurrentSystemTypes(), typeof(Entity)); TypeSelector.Open(searchParameters, args => { Helpers.InvokeGenericMethod <ProvenceManagerEditor>(this, "AddSystem", args.value); }); }
protected virtual void AddTagButtonClicked(MouseClickEvent e) { if (e.button != 0) { return; } if (collection.ContainsKey(chosenKey)) { List <Type> existingTypes = collection[chosenKey].tags.Select(t => t.GetType()).ToList(); TypeSelector.TypeSelectorParameters searchParameters = new TypeSelector.TypeSelectorParameters(typeof(MainframeTag), false, existingTypes); TypeSelector.Open(searchParameters, args => { AddTagToEntry(args.value); }); } }
protected virtual void AddComponentButtonClicked(MouseClickEvent e) { if (e.button != 0) { return; } if (collection.ContainsKey(chosenKey)) { List <Type> existingTypes = collection[chosenKey].components.Keys.ToList(); TypeSelector.TypeSelectorParameters searchParameters = new TypeSelector.TypeSelectorParameters(typeof(ProvenceComponent), false, existingTypes, typeof(Entity)); TypeSelector.Open(searchParameters, args => { Helpers.InvokeGenericMethod <ProvenceCollectionEditor <U> >(this, "AddComponentToEntry", args.value); }); } }
protected void AddSystemButtonPressed(MouseClickEvent e) { if (e.button != 0) { return; } List <System.Type> existingTypes = collection[chosenKey].systems.ToList(); TypeSelector.TypeSelectorParameters searchParameters = new TypeSelector.TypeSelectorParameters(typeof(ProvenceSystem), false, existingTypes, typeof(Entity)); TypeSelector.Open(searchParameters, args => { collection[chosenKey].systems.Add(args.value); collection[chosenKey].systems = new HashSet <System.Type>(collection[chosenKey].systems.OrderBy(system => system.Name)); eventManager.Raise <SetSceneDirtyEvent>(new SetSceneDirtyEvent(SceneManager.GetActiveScene())); eventManager.Raise <DrawColumnEventArgs <string> >(new DrawColumnEventArgs <string>(1)); }); }
protected void AddComponentButtonClicked(MouseClickEvent e) { if (e.button != 0) { return; } List <System.Type> existingTypes = new List <System.Type>(); foreach (ComponentHandle <ProvenceComponent> handle in chosenKey.GetAllComponents()) { existingTypes.Add(handle.component.GetType()); } TypeSelector.TypeSelectorParameters searchParameters = new TypeSelector.TypeSelectorParameters(typeof(ProvenceComponent), false, existingTypes, typeof(Entity)); TypeSelector.Open(searchParameters, args => { Helpers.InvokeGenericMethod <EntityEditor>(this, "AddComponent", args.value); }); }
public void Show(VisualElement root, MouseClickEvent e = null, bool changePosition = false) { root.Query <DropDownMenu>().ForEach(current => { current.style.display = DisplayStyle.None; }); if (changePosition) { this.style.top = StyleKeyword.Auto; this.style.bottom = StyleKeyword.Auto; this.style.left = StyleKeyword.Auto; this.style.right = StyleKeyword.Auto; bool top = (e.mousePosition.y < (root.contentRect.height / 2)); bool left = (e.mousePosition.x < (root.contentRect.width / 2)); if (left) { this.style.left = e.mousePosition.x - 20 > 0 ? e.mousePosition.x - 20 : 0; } else { float rightX = root.contentRect.width - e.mousePosition.x; this.style.right = rightX - 20 > 0 ? rightX - 20 : 0; } if (top) { this.style.top = e.mousePosition.y - 20; } else { this.style.bottom = e.mousePosition.y * -1; } } this.style.display = DisplayStyle.Flex; }