Пример #1
0
        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[] { });
            }
        }
        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[] { });
            }
        }