private void OnSearchingDistanceChanged(MyGuiControlBase sender)
 {
     foreach (MyPrefabLargeWeapon prefabLargeWeapon in m_prefabLargeWeapons)
     {
         prefabLargeWeapon.SearchingDistance = m_searchingDistance.GetValue();
     }
 }
Example #2
0
        public void Add(MyGuiControlBase item)
        {
            item.OnVisibilityChanged -= OnVisibilityChanged;
            item.OnVisibilityChanged += OnVisibilityChanged;

            TrySetCollecionChangeEvent(item, true);

            m_allControls.Add(item);

            if (item.Visible)
            {
                m_visibleControls.Add(item);
            }
        }
        private void OnAttachClick(MyGuiControlBase button)
        {
            if (MyEditorVoxelHand.DetachedVoxelHand == null)
            {
                foreach (MyEntity e in MyEntities.GetEntities())
                {
                    if (e is MyDummyPoint && ((int)(((MyDummyPoint)e).DummyFlags & CommonLIB.AppCode.ObjectBuilders.SubObjects.MyDummyPointFlags.VOXEL_HAND)) > 0)
                    {
                        e.WorldMatrix = MyEditorVoxelHand.UpdateShapePosition();
                        MyEditorVoxelHand.DetachedVoxelHand = (MyDummyPoint)e;                        
                    }
                }

                if (MyEditorVoxelHand.DetachedVoxelHand == null)
                {
                    var ob = MinerWars.CommonLIB.AppCode.ObjectBuilders.MyMwcObjectBuilder_Base.CreateNewObject(MinerWars.CommonLIB.AppCode.ObjectBuilders.MyMwcObjectBuilderTypeEnum.DummyPoint, null) as MinerWars.CommonLIB.AppCode.ObjectBuilders.SubObjects.MyMwcObjectBuilder_DummyPoint;
                    MyDummyPoint voxelHand = new MyDummyPoint();
                    voxelHand.Init(null, ob, Matrix.Identity);
                    voxelHand.DummyFlags |= CommonLIB.AppCode.ObjectBuilders.SubObjects.MyDummyPointFlags.VOXEL_HAND;
                    voxelHand.Size = new Vector3(20, 20, 20);
                    voxelHand.Save = false;
                    voxelHand.WorldMatrix = MyEditorVoxelHand.UpdateShapePosition();
                    MyEntities.Add(voxelHand);
                    MyEditorVoxelHand.DetachedVoxelHand = voxelHand;
                }

                
                MyEditorVoxelHand.DetachedVoxelHand.Enabled = true;
                MyEditorGizmo.SelectedEntities.Clear();
                MyEditorGizmo.SelectedEntities.Add(MyEditorVoxelHand.DetachedVoxelHand);

                m_detachLabel.Text = MyTextsWrapperEnum.AttachVoxelHand;
            }
            else
            {
                if (MyEditorVoxelHand.DetachedVoxelHand != null)
                    MyEditorVoxelHand.DetachedVoxelHand.MarkForClose();
                MyEditorVoxelHand.DetachedVoxelHand = null;
                MyEditorGizmo.SelectedEntities.Clear();
                m_detachLabel.Text = MyTextsWrapperEnum.DetachVoxelHand;
            }
        }
 void OnScanningSpeedChange(MyGuiControlBase sender) 
 {
     float scanningSpeed = ((MyGuiControlSize)sender).GetValue();
     Scanner.ScanningSpeed = scanningSpeed;            
 }
 void OnDepthChange(MyGuiControlBase sender)
 {
     float depth = ((MyGuiControlSize)sender).GetValue();
     Vector3 size = Scanner.Size;
     Scanner.Size = new Vector3(size.X, size.Y, depth);
 }
 void OnHeightChange(MyGuiControlBase sender)
 {
     float height = ((MyGuiControlSize)sender).GetValue();
     Vector3 size = Scanner.Size;
     Scanner.Size = new Vector3(size.X, height, size.Z);
 }
        private void AddControl(bool point, MyGuiControlBase control)
        {
            if (point)
	        {
                m_pointLightControls.Add(control);
	        }
            else
	        {
                m_spotLightControls.Add(control);
	        }

            m_controls.Add(control);
        }
Example #8
0
        private bool IsControlUnderCursor(MyGuiControlBase control)
        {
            Vector2? size = control.GetSize();
            if (size != null)
            {
                Vector2 min = control.GetPosition() - size.Value / 2;
                Vector2 max = control.GetPosition() + size.Value / 2;
                Vector2 mousePosition = MyGuiManager.MouseCursorPosition - GetPosition();

                return (mousePosition.X >= min.X && mousePosition.X <= max.X &&
                        mousePosition.Y >= min.Y && mousePosition.Y <= max.Y);
            }
            else
            {
                return false;
            }
        }
Example #9
0
 private void OnVisibilityChanged(MyGuiControlBase control, bool isVisible)
 {
     NotifyCollectionChanged();
     m_refreshVisibleControls = true;
 }
Example #10
0
 private void TrySetCollecionChangeEvent(MyGuiControlBase control, bool addDelegate) 
 {
     if (control is IMyGuiControlsParent) 
     {
         SetParentCollectionChangeEvent(control as IMyGuiControlsParent, addDelegate);
     }
 }
Example #11
0
        public void Insert(int index, MyGuiControlBase item)
        {
            item.OnVisibilityChanged -= OnVisibilityChanged;
            item.OnVisibilityChanged += OnVisibilityChanged;
            TrySetCollecionChangeEvent(item, true);
            m_allControls.Insert(index, item);

            m_refreshVisibleControls = true;
        }
Example #12
0
 public int IndexOf(MyGuiControlBase item)
 {
     return m_allControls.IndexOf(item);
 }
Example #13
0
        public bool Remove(MyGuiControlBase item)
        {
            bool itemRemove = m_allControls.Remove(item);

            if (itemRemove)
            {
                m_visibleControls.Remove(item);
                item.OnVisibilityChanged -= OnVisibilityChanged;
                TrySetCollecionChangeEvent(item, false);
            }

            return itemRemove;
        }
Example #14
0
 public void CopyTo(MyGuiControlBase[] array, int arrayIndex)
 {
     m_allControls.CopyTo(array, arrayIndex);
 }
Example #15
0
 public bool Contains(MyGuiControlBase item)
 {
     return m_allControls.Contains(item);
 }
Example #16
0
        //StringBuilder m_drawPositionSb = new StringBuilder();
        private void DrawControlDebugPosition(MyGuiControlBase control)
        {
            m_drawPositionSb.Clear();
            m_drawPositionSb.Append("[");
            m_drawPositionSb.Append(control.GetPosition().X.ToString("0.0000"));
            m_drawPositionSb.Append(",");
            m_drawPositionSb.Append(control.GetPosition().Y.ToString("0.0000"));
            m_drawPositionSb.Append("]");
            float scale = 0.7f;
            Vector2 size = MyGuiManager.GetNormalizedSizeFromScreenSize(MyGuiManager.GetFontMinerWarsBlue().MeasureString(m_drawPositionSb, scale));
            Vector4 color = new Vector4(0f, 0f, 0f, 0.5f);

            MyGuiManager.DrawSpriteBatch(MyGuiManager.GetBlankTexture(), control.GetPosition() + control.GetParent().GetPositionAbsolute(),
                                         size, new Color(color),
                                         MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);

            MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(),
                                                m_drawPositionSb,
                                                control.GetPosition() + control.GetParent().GetPositionAbsolute(), scale,
                                                Color.Green,
                                                MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
        }
Example #17
0
        private bool HandleControlMoving(MyGuiInput input)
        {
            bool dragging = false;
            
            if (input.IsLeftMousePressed())
            {
                // if we dragging control, then we set it new position by mouse
                if (m_draggingControl != null)
                {
                    m_draggingControl.SetPosition(MyGuiManager.MouseCursorPosition - m_draggingControl.GetParent().GetPositionAbsolute() - m_draggingControlOffset);
                    dragging = true;
                }
                // if we are not dragging control, then we try find it
                else
                {
                    MyGuiControlBase controlToDrag = null;
                    // first we try find control, which has mouse over
                    controlToDrag = GetMouseOverControl();                    
                    // if there is no control which has mouse over, then we try find control, which is under mouse cursor (because some controls has no mouse over all time)
                    if (controlToDrag == null)
                    {
                        controlToDrag = GetControlUnderMouseCursor();
                    }

                    // if we found any contorl to drag, then we set it to dragging control
                    if(controlToDrag != null)
                    {
                        m_draggingControl = controlToDrag;
                        m_draggingControlOffset = MyGuiManager.MouseCursorPosition - m_draggingControl.GetParent().GetPositionAbsolute() - controlToDrag.GetPosition();
                        dragging = true;
                    }
                }
            }
            else
            {
                m_draggingControl = null;
                if (input.IsNewLeftMouseReleased())
                {
                    dragging = true;
                }
            }            

            return dragging;
        }
 void OnWidthChange(MyGuiControlBase sender)
 {
     float width = ((MyGuiControlSize)sender).GetValue();
     Vector3 size = Scanner.Size;
     Scanner.Size = new Vector3(width, size.Y, size.Z);            
 }
Example #19
0
        private bool HandleControlsInput(MyGuiInput input, bool receivedFocusInThisUpdate)
        {
            MyGuiControlBase inputHandledBySomeControl = null;

            if (m_lastHandlingControl != null && m_lastHandlingControl.Visible) 
            {
                if (m_lastHandlingControl.HandleInput(input, m_controlsAll.IndexOf(m_lastHandlingControl) == m_keyboardControlIndex, m_controlsAll.IndexOf(m_lastHandlingControl) == m_keyboardControlIndexPrevious, receivedFocusInThisUpdate) == true) 
                {
                    inputHandledBySomeControl = m_lastHandlingControl;
                }
            }

            if (inputHandledBySomeControl == null && m_listboxDragAndDropHandlingNow != null)
            {
                if (m_listboxDragAndDropHandlingNow.HandleInput(input, m_controlsAll.IndexOf(m_listboxDragAndDropHandlingNow) == m_keyboardControlIndex, m_controlsAll.IndexOf(m_listboxDragAndDropHandlingNow) == m_keyboardControlIndexPrevious, receivedFocusInThisUpdate) == true)
                {
                    inputHandledBySomeControl = m_listboxDragAndDropHandlingNow;
                }
            }

            if (inputHandledBySomeControl == null && m_comboboxHandlingNow != null)
            {                
                if (m_comboboxHandlingNow.HandleInput(input, m_controlsAll.IndexOf(m_comboboxHandlingNow) == m_keyboardControlIndex, m_controlsAll.IndexOf(m_comboboxHandlingNow) == m_keyboardControlIndexPrevious, receivedFocusInThisUpdate) == true)
                {
                    inputHandledBySomeControl = m_comboboxHandlingNow;
                }                
            }

            //  If opened combobox didn't capture the input, we will try to handle it in remaining controls
            if (inputHandledBySomeControl == null)
            {
                for (int i = 0; i < m_controlsAll.Count; i++)
                {
                    MyGuiControlBase control = m_controlsAll[i];
                    if (control != m_comboboxHandlingNow && control != m_listboxDragAndDropHandlingNow && control.Visible)
                    {
                        if (control.HandleInput(input, i == m_keyboardControlIndex, i == m_keyboardControlIndexPrevious, receivedFocusInThisUpdate) == true)
                        {
                            inputHandledBySomeControl = control;
                            break;
                        }
                    }
                }
            }

            m_keyboardControlIndexPrevious = m_keyboardControlIndex;

            if (inputHandledBySomeControl != null)
            {
                m_keyboardControlIndex = m_controlsAll.IndexOf(inputHandledBySomeControl);
                m_keyboardControlIndexPrevious = m_keyboardControlIndex;    //  We need to reset it, otherwise we will hear two mouseover sounds!!!
            }

            m_lastHandlingControl = inputHandledBySomeControl;

            return inputHandledBySomeControl != null;
        }
 void OnWidthChange(MyGuiControlBase sender)
 {
     float width = ((MyGuiControlSize)sender).GetValue();
     if (DummyPoint.Type == MyDummyPointType.Box)
     {
         Vector3 size = DummyPoint.Size;
         DummyPoint.Size = new Vector3(width, size.Y, size.Z);
     }
     else
     {
         DummyPoint.Radius = width / 2.0f;
     }
 }