Ejemplo n.º 1
0
        private void SetGridItemAt(int slot, MyToolbarItem item, string icon, string subicon, String tooltip, Sandbox.Graphics.GUI.MyGuiControlGrid.ColoredIcon?symbol = null)
        {
            var gridItem = m_toolbarItemsGrid.GetItemAt(slot);

            if (gridItem == null)
            {
                gridItem = new MyGuiControlGrid.Item(
                    icon: icon,
                    subicon: subicon,
                    toolTip: tooltip,
                    userData: item);
                if (DrawNumbers)
                {
                    gridItem.AddText(MyToolbarComponent.GetSlotControlText(slot));
                }
                //Ammo amount in toolbar
                if (item != null)
                {
                    gridItem.AddText(item.IconText, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
                }
                else
                {
                    gridItem.ClearText(MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
                }
                gridItem.Enabled = (item != null) ? item.Enabled : true;
                if (symbol.HasValue)
                {
                    gridItem.AddIcon(symbol.Value, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
                }
                m_toolbarItemsGrid.SetItemAt(slot, gridItem);
            }
            else
            {
                gridItem.UserData = item;
                gridItem.Icon     = icon;
                gridItem.SubIcon  = subicon;
                if (gridItem.ToolTip == null)
                {
                    gridItem.ToolTip = new MyToolTips();
                }
                gridItem.ToolTip.ToolTips.Clear();
                gridItem.ToolTip.AddToolTip(tooltip);
                //Ammo amount in toolbar
                if (item != null)
                {
                    gridItem.AddText(item.IconText, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
                }
                else
                {
                    gridItem.ClearText(MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
                }
                gridItem.Enabled = (item != null) ? item.Enabled : true;
                if (symbol.HasValue)
                {
                    gridItem.AddIcon(symbol.Value, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
                }
            }
        }
Ejemplo n.º 2
0
        protected virtual void SetGridItemAt(int slot, MyToolbarItem item, string[] icons, string subicon, String tooltip, Sandbox.Graphics.GUI.MyGuiControlGrid.ColoredIcon?symbol = null)
        {
            var gridItem = m_toolbarItemsGrid.GetItemAt(slot);

            if (gridItem == null)
            {
                gridItem = new MyGuiControlGrid.Item(
                    icons: icons,
                    subicon: subicon,
                    toolTip: tooltip,
                    userData: item);
                if (DrawNumbers)
                {
                    gridItem.AddText(MyToolbarComponent.GetSlotControlText(slot));
                }
                //By Gregory: Changed to IconText for weapon check MyToolbarItemWeapon IconText override
                if (item != null)
                {
                    gridItem.AddText(item.IconText, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
                }
                else
                {
                    gridItem.ClearText(MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
                }
                gridItem.Enabled = (item != null) ? item.Enabled : true;
                if (symbol.HasValue)
                {
                    gridItem.AddIcon(symbol.Value, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
                }
                m_toolbarItemsGrid.SetItemAt(slot, gridItem);
            }
            else
            {
                gridItem.UserData = item;
                gridItem.Icons    = icons;
                gridItem.SubIcon  = subicon;
                if (gridItem.ToolTip == null)
                {
                    gridItem.ToolTip = new MyToolTips();
                }
                gridItem.ToolTip.ToolTips.Clear();
                gridItem.ToolTip.AddToolTip(tooltip);
                //By Gregory: Changed to IconText for weapon check MyToolbarItemWeapon IconText override
                if (item != null)
                {
                    gridItem.AddText(item.IconText, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
                }
                else
                {
                    gridItem.ClearText(MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
                }
                gridItem.Enabled = (item != null) ? item.Enabled : true;
                if (symbol.HasValue)
                {
                    gridItem.AddIcon(symbol.Value, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
                }
            }
        }
        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);
            }
        }
Ejemplo n.º 4
0
        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);
            }
        }