Пример #1
0
        public CInspectorEntityComponentViewModel(IInspectorViewModel viewModel, string name, SEntityComponentId componentId)
            : base(viewModel, name)
        {
            ComponentId = componentId;

            DeleteComponentCommand = new CRelayCommand(arg =>
            {
                EditorEntityUtility.DestroyComponent(ComponentId);

                m_viewModel.QueueEntityInformationUpdate(ComponentId.EntityId, true);
            });
        }
Пример #2
0
        private void OnKeyDown(object e)
        {
            KeyEventArgs args = (KeyEventArgs)e;

            if (IsActive && args.Key == Key.Delete)
            {
                var outliner = CWorkspace.Instance.GetTool <CWorldOutlinerViewModel>();
                if (outliner.SelectedEntityViewModel != null)
                {
                    EditorEntityUtility.DestroyEntity(outliner.SelectedEntityViewModel.EntityId);
                }
            }
        }
Пример #3
0
        public CInspectorViewModel()
            : base("Inspector")
        {
            SetIconSourcePath("Resources/Images/Tabs/inspector.png");

            Content = new Inspector();
            m_view  = Content as IInspectorView;

            InitializeEntityMenues();

            RenameEntityCommand             = new CRelayCommand(InternalRenameEntity);
            AddComponentCommand             = new CRelayCommand(InternalAddComponent);
            ToggleAddComponentMenuCommand   = new CRelayCommand((obj) => AddComponentMenuOpen = !AddComponentMenuOpen);
            ToggleEntityCommandsMenuCommand = new CRelayCommand((obj) => EntityCommandsMenuOpen = !EntityCommandsMenuOpen);

            CWorkspace.Instance.OnSelectedEditableObjectChanged += (oldObj, newObj) =>
            {
                m_view?.ClearInspector();
                m_view?.LockInspector(true);

                if (newObj != null)
                {
                    m_view.SetInspectorVisible(true);

                    switch (newObj.Type)
                    {
                    case CEditableObject.EObjectType.Entity:
                        InspectEntity(newObj.EntityId);
                        if (oldObj?.GetTargetEntityId() != newObj?.GetTargetEntityId())
                        {
                            QueueEntityInformationUpdate(newObj.GetTargetEntityId(), true);
                        }

                        EditorEntityUtility.PickRootComponent(newObj.EntityId);
                        break;

                    case CEditableObject.EObjectType.Component:
                        InspectComponent(newObj.ComponentId);
                        break;
                    }
                }
                else
                {
                    m_view?.SetInspectorVisible(false);
                    Reset();
                    EditorEntityUtility.PickComponent(SEntityComponentId.Invalid);
                }
            };
        }
        public CWorldOutlinerViewModel()
            : base("World Outliner")
        {
            SetIconSourcePath("Resources/Images/Tabs/outliner.png");

            Content = new WorldOutliner();
            m_view  = Content as IOutlinerView;

            CWorkspace.Instance.OnSelectedEditableObjectChanged += (oldObj, newObj) =>
            {
                if (newObj != null)
                {
                    switch (newObj.Type)
                    {
                    case CEditableObject.EObjectType.Entity:
                        HighlightEntity(newObj.EntityId);
                        break;

                    case CEditableObject.EObjectType.Component:
                        HighlightEntity(newObj.ComponentId.EntityId);
                        break;
                    }
                }
                else
                {
                    SelectedEntityViewModel?.MarkInOutliner(false);
                }
            };

            KeyDownCommand = new CRelayCommand(param =>
            {
                KeyEventArgs args = (KeyEventArgs)param;
                if (IsActive && args.Key == Key.Delete)
                {
                    if (SelectedEntityViewModel != null)
                    {
                        EditorEntityUtility.DestroyEntity(SelectedEntityViewModel.EntityId);
                    }
                }
            });
        }
 private void OnDeleteCommand(object arg)
 {
     EditorEntityUtility.DestroyEntity(EntityId);
 }
 private void OnDetachCommand(object argument)
 {
     EditorEntityUtility.DetachEntityFromAllParents(EntityId);
 }
Пример #7
0
        protected virtual void OnMakeRoot(object argument)
        {
            EditorEntityUtility.MakeComponentRoot(ComponentId);

            m_viewModel.QueueEntityInformationUpdate(ComponentId.EntityId, true);
        }
Пример #8
0
        protected virtual void OnDeleteComponent(object argument)
        {
            EditorEntityUtility.DestroyComponent(ComponentId);

            m_viewModel.QueueEntityInformationUpdate(ComponentId.EntityId, true);
        }