private void UpdateDisabledControlsWhileDragging(MyGuiControlInventoryOwner control) { if (m_controlsDisabledWhileDragged.Count == 0) return; var owner = control.InventoryOwner; for (int i = 0; i < owner.InventoryCount; ++i) { var gridControl = control.ContentGrids[i]; if (m_controlsDisabledWhileDragged.Contains(gridControl)) { if (gridControl.Enabled) { gridControl.Enabled = false; } } } }
private void ownerControl_InventoryContentsChanged(MyGuiControlInventoryOwner control) { if (control == m_focusedOwnerControl) RefreshSelectedInventoryItem(); UpdateDisabledControlsWhileDragging(control); }
private void CreateInventoryControlsInList(List<MyEntity> owners, MyGuiControlList listControl, MyInventoryOwnerTypeEnum? filterType = null) { if (listControl.Controls.Contains(m_focusedOwnerControl)) m_focusedOwnerControl = null; List<MyGuiControlBase> inventoryControlList = new List<MyGuiControlBase>(); foreach (var owner in owners) { if (!(owner != null && owner.HasInventory)) continue; if (filterType.HasValue && (owner as MyEntity).InventoryOwnerType() != filterType) continue; Vector4 labelColor = Color.White.ToVector4(); if (owner is MyCubeBlock) { labelColor = m_colorHelper.GetGridColor((owner as MyCubeBlock).CubeGrid).ToVector4(); } var ownerControl = new MyGuiControlInventoryOwner(owner, labelColor); ownerControl.Size = new Vector2(listControl.Size.X - 0.045f, ownerControl.Size.Y); ownerControl.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; foreach (var grid in ownerControl.ContentGrids) { grid.ItemSelected += grid_ItemSelected; grid.ItemDragged += grid_ItemDragged; grid.ItemDoubleClicked += grid_ItemDoubleClicked; grid.ItemClicked += grid_ItemClicked; } ownerControl.SizeChanged += inventoryControl_SizeChanged; ownerControl.InventoryContentsChanged += ownerControl_InventoryContentsChanged; if (owner is MyCubeBlock) ownerControl.Enabled = (owner as MyCubeBlock).IsFunctional; // Put inventory of interacted block or character on first position. if (owner == m_interactedAsOwner || owner == m_userAsOwner) { inventoryControlList.Insert(0, ownerControl); } else { //sort by name (Inventory filters ticket) inventoryControlList.Add(ownerControl); } } listControl.InitControls(inventoryControlList); }
private void grid_ItemSelected(MyGuiControlGrid sender, MyGuiControlGrid.EventArgs eventArgs) { var sourceGrid = (MyGuiControlGrid)sender; if (m_focusedGridControl != null && m_focusedGridControl != sourceGrid) { m_focusedGridControl.SelectedIndex = null; } m_focusedGridControl = sourceGrid; m_focusedOwnerControl = (MyGuiControlInventoryOwner)sourceGrid.Owner; RefreshSelectedInventoryItem(); }
public void Close() { foreach (var system in m_registeredConveyorSystems) { system.BlockAdded -= ConveyorSystem_BlockAdded; system.BlockRemoved -= ConveyorSystem_BlockRemoved; } m_registeredConveyorSystems.Clear(); m_leftTypeGroup.Clear(); m_leftFilterGroup.Clear(); m_rightTypeGroup.Clear(); m_rightFilterGroup.Clear(); m_controlsDisabledWhileDragged.Clear(); m_leftOwnersControl = null; m_leftSuitButton = null; m_leftGridButton = null; m_leftFilterStorageButton = null; m_leftFilterSystemButton = null; m_leftFilterEnergyButton = null; m_leftFilterAllButton = null; m_rightOwnersControl = null; m_rightSuitButton = null; m_rightGridButton = null; m_rightFilterStorageButton = null; m_rightFilterSystemButton = null; m_rightFilterEnergyButton = null; m_rightFilterAllButton = null; m_throwOutButton = null; m_dragAndDrop = null; m_dragAndDropInfo = null; m_focusedOwnerControl = null; m_focusedGridControl = null; m_selectedInventory = null; m_hideEmptyLeft.IsCheckedChanged -= HideEmptyLeft_Checked; m_hideEmptyRight.IsCheckedChanged -= HideEmptyRight_Checked; m_blockSearchLeft.TextChanged -= BlockSearchLeft_TextChanged; m_blockSearchClearLeft.ButtonClicked -= BlockSearchClearLeft_ButtonClicked; m_blockSearchRight.TextChanged -= BlockSearchRight_TextChanged; m_blockSearchClearRight.ButtonClicked -= BlockSearchClearRight_ButtonClicked; m_hideEmptyLeft = null; m_hideEmptyLeftLabel = null; m_hideEmptyRight = null; m_hideEmptyRightLabel = null; m_blockSearchLeft = null; m_blockSearchClearLeft = null; m_blockSearchRight = null; m_blockSearchClearRight = null; }