Exemplo n.º 1
0
        private void EditorForm_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if ((e.AffectedCategories & ObjectSelection.Category.GameObjCmp) == ObjectSelection.Category.None)
            {
                ClearContextMenu();
                return;
            }
            if (e.SameObjects) return;

            // Update object selection
            this.allObjSel = e.Current.GameObjects.Select(g => new SelGameObj(g) as SelObj).ToList();

            // Update indirect object selection
            {
                var selectedGameObj = e.Current.GameObjects;
                var indirectViaCmpQuery = e.Current.Components.GameObject();
                var indirectViaChildQuery = selectedGameObj.ChildrenDeep();
                var indirectQuery = indirectViaCmpQuery.Concat(indirectViaChildQuery).Except(selectedGameObj).Distinct();
                this.indirectObjSel = indirectQuery.Select(g => new SelGameObj(g) as SelObj).ToList();
            }

            // Update (parent-free) action object selection
            {
                // Remove removed objects
                foreach (SelObj s in e.Removed.GameObjects.Select(g => new SelGameObj(g) as SelObj)) this.actionObjSel.Remove(s);
                // Remove objects whichs parents are now added
                this.actionObjSel.RemoveAll(s => e.Added.GameObjects.Any(o => this.IsAffectedByParent(s.ActualObject as GameObject, o)));
                // Add objects whichs parents are not located in the current selection
                var addedParentFreeGameObj = e.Added.GameObjects.Where(o => !this.allObjSel.Any(s => this.IsAffectedByParent(o, s.ActualObject as GameObject)));
                this.actionObjSel.AddRange(addedParentFreeGameObj.Select(g => new SelGameObj(g) as SelObj).Where(s => s.HasTransform));
            }

            this.InvalidateSelectionStats();
            this.UpdateAction();
            this.Invalidate();
        }
		private void EditorForm_SelectionChanged(object sender, SelectionChangedEventArgs e)
		{
			if (e.SameObjects) return;
			if (!e.AffectedCategories.HasFlag(ObjectSelection.Category.GameObjCmp) &&
				!e.AffectedCategories.HasFlag(ObjectSelection.Category.Other))
				return;

			// Collider selection changed
			if ((e.AffectedCategories & ObjectSelection.Category.GameObjCmp) != ObjectSelection.Category.None)
			{
				RigidBody newBody = this.QuerySelectedCollider();
				if (newBody != this.selectedBody)
					this.LeaveCursorState();

				DualityEditorApp.Deselect(this, ObjectSelection.Category.Other);
				this.selectedBody = newBody;
			}
			// Other selection changed
			if ((e.AffectedCategories & ObjectSelection.Category.Other) != ObjectSelection.Category.None)
			{
				if (e.Current.OfType<ShapeInfo>().Any())
					this.allObjSel = e.Current.OfType<ShapeInfo>().Select(s => SelShape.Create(s) as SelObj).ToList();
				else
					this.allObjSel = new List<SelObj>();

				// Update indirect object selection
				this.indirectObjSel.Clear();
				// Update (parent-free) action object selection
				this.actionObjSel = this.allObjSel.ToList();
			}

			this.InvalidateSelectionStats();
			this.UpdateToolbar();
			this.Invalidate();
		}
Exemplo n.º 3
0
		private void EditorForm_SelectionChanged(object sender, SelectionChangedEventArgs e)
		{
			if (sender == this) return;
			if ((e.AffectedCategories & ObjectSelection.Category.GameObjCmp) == ObjectSelection.Category.None) return;
			if (e.SameObjects) return;

			IEnumerable<NodeBase> removedObjQuery;
			removedObjQuery = e.Removed.GameObjects.Select(o => this.FindNode(o));
			removedObjQuery = removedObjQuery.Concat(e.Removed.Components.Select(o => this.FindNode(o)));

			IEnumerable<NodeBase> addedObjQuery;
			addedObjQuery = e.Added.GameObjects.Select(o => this.FindNode(o));
			addedObjQuery = addedObjQuery.Concat(e.Added.Components.Select(o => this.FindNode(o)));

			this.SelectNodes(removedObjQuery, false);
			this.SelectNodes(addedObjQuery, true);
		}
Exemplo n.º 4
0
		private static void GlobalUpdateSelection(object sender, SelectionChangedEventArgs e)
		{
			ObjectInspector target = null;
			
			foreach (ObjectSelection.Category cat in ObjectSelection.EnumerateCategories(e.AffectedCategories))
			{
				var objViews = 
					from v in EditorBasePlugin.Instance.ObjViews
					where v.AcceptsSelection(e.Current)
					select new { 
						View = v, 
						Empty = v.EmptySelection,
						PerfectFit = v.EmptySelection || (cat & v.DisplayedCategory) != ObjectSelection.Category.None,
						TypeShare = ObjectSelection.GetTypeShareLevel(e.Current.Exclusive(cat), v.DisplayedSelection),
						NumSameCatViews = EditorBasePlugin.Instance.ObjViews.Count(o => o.AcceptsSelection(e.Current) && o.DisplayedCategory == v.DisplayedCategory) };
				var sortedQuery = 
					from o in objViews
					orderby o.PerfectFit descending, o.Empty ascending, o.NumSameCatViews descending, o.TypeShare ascending
					select o;
				var targetItem = sortedQuery.FirstOrDefault();
				if (targetItem == null) return;
				target = targetItem.View;

				// If a mouse button is pressed, reschedule the selection for later - there might be a drag in progress
				if (Control.MouseButtons != System.Windows.Forms.MouseButtons.None)
				{
					target.selSchedMouse = e.Current;
					target.selSchedMouseCat = cat;
					target.timerSelectSched.Enabled = true;
				}
				else
				{
					target.UpdateSelection(e.Current, cat);
				}
			}
			
			//  Make sure disposed objects are deselected in non-target views (locked, etc.)
			foreach (ObjectInspector v in EditorBasePlugin.Instance.ObjViews)
			{
				if (v.EmptySelection) continue;
				if (v == target) continue;

				var disposedObj = e.Removed.OfType<IManageableObject>().Where(o => o.Disposed);
				if (disposedObj.Any())
				{
					ObjectSelection disposedSel = new ObjectSelection(disposedObj);
					v.UpdateSelection(v.DisplayedSelection - disposedSel, v.DisplayedCategory);
				}
			}
		}
Exemplo n.º 5
0
		private void EditorForm_SelectionChanged(object sender, SelectionChangedEventArgs e)
		{
			if (sender == this) return;
			if ((e.AffectedCategories & ObjectSelection.Category.Resource) == ObjectSelection.Category.None) return;
			if (e.SameObjects) return;

			foreach (Resource r in e.Removed.Resources)	this.SelectNode(this.NodeFromPath(r.Path), false);
			foreach (Resource r in e.Added.Resources)
			{
				if (!this.SelectNode(this.NodeFromPath(r.Path)))
					this.ScheduleSelect(r.Path);
			}
		}