void inventoryGrid_ItemClicked(MyGuiControlGrid control, MyGuiControlGrid.EventArgs args) { Debug.Assert(control == m_inventoryGrid); if (CurrentAssemblerMode == AssemblerMode.Assembling) { return; } var gridItem = control.GetItemAt(args.ItemIndex); if (gridItem == null) { return; } var item = (MyPhysicalInventoryItem)gridItem.UserData; var blueprint = MyDefinitionManager.Static.TryGetBlueprintDefinitionByResultId(item.Content.GetId()); if (blueprint != null) { var amount = MyInput.Static.IsAnyShiftKeyPressed() ? 100 : MyInput.Static.IsAnyCtrlKeyPressed() ? 10 : 1; EnqueueBlueprint(blueprint, amount); } }
private void grid_ItemDoubleClicked(MyGuiControlGrid sender, MyGuiControlGrid.EventArgs eventArgs) { RemoveToolbarItem(eventArgs.ColumnIndex); if (m_shownToolbar.IsValidIndex(eventArgs.ColumnIndex)) { m_shownToolbar.ActivateItemAtSlot(eventArgs.ColumnIndex); } }
private void OnGridMouseOverIndexChanged(MyGuiControlGrid myGuiControlGrid, MyGuiControlGrid.EventArgs eventArgs) { if (m_gridBlocks.Visible) { MyGuiControlGrid.Item gridItem = m_gridBlocks.MouseOverItem ?? m_gridBlocks.SelectedItem; if (gridItem == null) { m_blockInfoList.InitControls(new MyGuiControlBase[] { }); return; } GridItemUserData userData = gridItem.UserData as GridItemUserData; if (userData == null) { return; } MyObjectBuilder_ToolbarItemCubeBlock itemData = userData.ItemData as MyObjectBuilder_ToolbarItemCubeBlock; if (itemData == null) { return; } MyDefinitionBase definition; if (MyDefinitionManager.Static.TryGetDefinition(itemData.DefinitionId, out definition)) { var group = MyDefinitionManager.Static.GetDefinitionGroup((definition as MyCubeBlockDefinition).BlockPairName); if (MyCubeBuilder.Static.CubeBuilderState.CubeSizeMode == MyCubeSize.Small && MyCubeBuilder.Static.IsCubeSizeAvailable(group.Small)) { m_blockInfoList.InitControls(GenerateBlockInfos(group.Small, ref m_blockInfoStyle)); } else if (MyCubeBuilder.Static.CubeBuilderState.CubeSizeMode == MyCubeSize.Large && MyCubeBuilder.Static.IsCubeSizeAvailable(group.Large)) { m_blockInfoList.InitControls(GenerateBlockInfos(group.Large, ref m_blockInfoStyle)); } else { bool blockSizeLarge = MyCubeBuilder.Static.CubeBuilderState.CubeSizeMode == MyCubeSize.Large; m_blockInfoList.InitControls(new MyGuiControlBase[] { GenerateSizeInfoLabel(blockSizeLarge), GenerateSizeNotAvailableText(blockSizeLarge) }); } } } else { m_blockInfoList.InitControls(new MyGuiControlBase[] { }); } }
void inventoryGrid_MouseOverIndexChanged(MyGuiControlGrid control, MyGuiControlGrid.EventArgs args) { Debug.Assert(control == m_inventoryGrid); if (CurrentAssemblerMode == AssemblerMode.Assembling) { return; } RefreshMaterialsPreview(); }
void queueGrid_ItemClicked(MyGuiControlGrid control, MyGuiControlGrid.EventArgs args) { Debug.Assert(control == m_queueGrid); // Changing queue in auto-disassembling mode is forbidden. if (CurrentAssemblerMode == AssemblerMode.Disassembling && m_selectedAssembler.RepeatEnabled) { return; } if (args.Button == MySharedButtonsEnum.Secondary) { m_selectedAssembler.RemoveQueueItemRequest(args.ItemIndex); } }
void blueprintsGrid_ItemClicked(MyGuiControlGrid control, MyGuiControlGrid.EventArgs args) { Debug.Assert(control == m_blueprintsGrid); //if(CurrentAssemblerMode == AssemblerMode.Assembling) { var item = control.GetItemAt(args.ItemIndex); if (item == null) { return; } var blueprint = (MyBlueprintDefinitionBase)item.UserData; var amount = MyInput.Static.IsAnyShiftKeyPressed() ? 100 : MyInput.Static.IsAnyCtrlKeyPressed() ? 10 : 1; EnqueueBlueprint(blueprint, amount); } }
private void grid_ItemClicked(MyGuiControlGrid sender, MyGuiControlGrid.EventArgs eventArgs) { if (eventArgs.Button == MySharedButtonsEnum.Secondary) { int slot = eventArgs.ColumnIndex; var toolbar = MyToolbarComponent.CurrentToolbar; MyToolbarItem item = toolbar.GetSlotItem(slot); if (item == null) { return; } //right clicks in multifunctional items should trigger their menus (if they have more than 0 options) if (item is MyToolbarItemActions) { var actionList = (item as MyToolbarItemActions).PossibleActions(ShownToolbar.ToolbarType); if (UseContextMenu && actionList.Count > 0) { m_contextMenu.CreateNewContextMenu(); foreach (var action in actionList) { m_contextMenu.AddItem(action.Name, icon: action.Icon, userData: action.Id); } m_contextMenu.AddItem(MyTexts.Get(MySpaceTexts.BlockAction_RemoveFromToolbar)); m_contextMenu.Enabled = true; m_contextMenuItemIndex = toolbar.SlotToIndex(slot); } else { RemoveToolbarItem(eventArgs.ColumnIndex); } } else { RemoveToolbarItem(eventArgs.ColumnIndex); } } if (m_shownToolbar.IsValidIndex(eventArgs.ColumnIndex)) { m_shownToolbar.ActivateItemAtSlot(eventArgs.ColumnIndex, true); } }
void queueGrid_MouseOverIndexChanged(MyGuiControlGrid control, MyGuiControlGrid.EventArgs args) { Debug.Assert(control == m_queueGrid); RefreshMaterialsPreview(); }
void queueGrid_ItemDragged(MyGuiControlGrid control, MyGuiControlGrid.EventArgs args) { StartDragging(MyDropHandleType.MouseRelease, control, ref args); }
private void StartDragging(MyDropHandleType dropHandlingType, MyGuiControlGrid gridControl, ref MyGuiControlGrid.EventArgs args) { m_dragAndDropInfo = new MyDragAndDropInfo(); m_dragAndDropInfo.Grid = gridControl; m_dragAndDropInfo.ItemIndex = args.ItemIndex; var draggingItem = m_dragAndDropInfo.Grid.GetItemAt(m_dragAndDropInfo.ItemIndex); m_dragAndDrop.StartDragging(dropHandlingType, args.Button, draggingItem, m_dragAndDropInfo, includeTooltip: false); }
private void OnSelectedItemChanged(MyGuiControlGrid arg1, MyGuiControlGrid.EventArgs arg2) { OnGridMouseOverIndexChanged(arg1, arg2); }
private void OnGridMouseOverIndexChanged(MyGuiControlGrid myGuiControlGrid, MyGuiControlGrid.EventArgs eventArgs) { if (m_gridBlocks.Visible) { MyGuiControlGrid.Item gridItem = m_gridBlocks.MouseOverItem ?? m_gridBlocks.SelectedItem; if (gridItem == null) { m_blockInfoList.InitControls(new MyGuiControlBase[] { }); return; } GridItemUserData userData = gridItem.UserData as GridItemUserData; if (userData == null) { return; } MyObjectBuilder_ToolbarItemCubeBlock itemData = userData.ItemData as MyObjectBuilder_ToolbarItemCubeBlock; if (itemData == null) { return; } MyDefinitionBase definition; if (MyDefinitionManager.Static.TryGetDefinition(itemData.DefinitionId, out definition)) { var group = MyDefinitionManager.Static.GetDefinitionGroup((definition as MyCubeBlockDefinition).BlockPairName); List <MyGuiControlBase> blockInfos = null; if (group.Small != null) { var blockInfosSmall = GenerateBlockInfos(group.Small, ref m_blockInfoStyle); if (blockInfosSmall != null) { if (blockInfos == null) { blockInfos = new List <MyGuiControlBase>(); } blockInfos.AddArray(blockInfosSmall); } } if (group.Large != null) { var blockInfosLarge = GenerateBlockInfos(group.Large, ref m_blockInfoStyle); if (blockInfosLarge != null) { if (blockInfos == null) { blockInfos = new List <MyGuiControlBase>(); } blockInfos.AddArray(blockInfosLarge); } } if (blockInfos != null) { m_blockInfoList.InitControls(blockInfos); } else { m_blockInfoList.InitControls(new MyGuiControlBase[] { }); } //else //{ // bool blockSizeLarge = MyCubeBuilder.Static.CubeBuilderState.CubeSizeMode == MyCubeSize.Large; // m_blockInfoList.InitControls(new MyGuiControlBase[] // { // GenerateSizeInfoLabel(blockSizeLarge), // GenerateSizeNotAvailableText(blockSizeLarge) // }); //} } } else { m_blockInfoList.InitControls(new MyGuiControlBase[] { }); } }