Пример #1
0
 /// <summary>
 /// Stops dragging item
 /// </summary>
 public void Stop()
 {
     m_draggingFrom          = null;
     m_draggingGridItem      = null;
     m_currentDropHandleType = null;
     m_dragButton            = null;
 }
Пример #2
0
 /// <summary>
 /// Starts dragging item
 /// </summary>
 /// <param name="dropHandleType">On which action released drop event</param>
 /// <param name="draggingItem">Item which is dragging</param>
 /// <param name="draggingFrom">Information about item's origin</param>
 public void StartDragging(MyDropHandleType dropHandleType, MySharedButtonsEnum dragButton, MyGuiControlGrid.Item draggingItem, MyDragAndDropInfo draggingFrom, bool includeTooltip = true)
 {
     m_currentDropHandleType = dropHandleType;
     m_dragButton            = dragButton;
     m_draggingGridItem      = draggingItem;
     m_draggingFrom          = draggingFrom;
     m_toolTip = (includeTooltip) ? draggingItem.ToolTip : null;
 }
        public static MyGuiControlGrid.Item CreateInventoryGridItem(MyPhysicalInventoryItem item)
        {
            var definition = MyDefinitionManager.Static.GetPhysicalItemDefinition(item.Content);

            var itemMass = definition.Mass * (double)item.Amount;
            var itemVolume = definition.Volume * 1000 * (double)item.Amount;

            var gridItem = new MyGuiControlGrid.Item(
                icon: definition.Icon,
                userData: item,
                toolTip: new StringBuilder().AppendFormat(MyTexts.GetString(MySpaceTexts.ToolTipTerminalInventory_ItemInfo),
                    definition.DisplayNameText,
                    (itemMass < 0.01) ? "<0.01" : itemMass.ToString(MyInventoryConstants.GUI_DISPLAY_FORMAT, CultureInfo.InvariantCulture),
                    (itemVolume < 0.01) ? "<0.01" : itemVolume.ToString(MyInventoryConstants.GUI_DISPLAY_FORMAT, CultureInfo.InvariantCulture),
                    (item.Content.Flags == MyItemFlags.Damaged ? MyTexts.Get(MySpaceTexts.ItemDamagedDescription) : MyTexts.Get(MySpaceTexts.Blank))).ToString());
            if (MyFakes.SHOW_INVENTORY_ITEM_IDS)
            {
                gridItem.ToolTip.AddToolTip(new StringBuilder().AppendFormat("ItemID: {0}", item.ItemId).ToString());
            }
            FormatItemAmount(item, m_textCache);
            gridItem.AddText(m_textCache, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);
            m_textCache.Clear();

            if (definition.IconSymbol.HasValue)
                gridItem.AddText(MyTexts.Get(definition.IconSymbol.Value), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            return gridItem;
        }
        private void RefreshBlueprints()
        {
            if (m_blueprintButtonGroup.SelectedButton == null) return;

            var blueprintClass = m_blueprintButtonGroup.SelectedButton.UserData as MyBlueprintClassDefinition;
            Debug.Assert(blueprintClass != null);
            if (blueprintClass == null) return;

            m_blueprintsGrid.Clear();
            int i = 0;
            foreach (var blueprint in blueprintClass)
            {
                var item = new MyGuiControlGrid.Item(
                    icon: blueprint.Icon,
                    toolTip: blueprint.DisplayNameText,
                    userData: blueprint);
                m_blueprintsGrid.Add(item);
                ++i;
            }

            m_blueprintsGrid.RowsCount = Math.Max(1 + (i / m_blueprintsGrid.ColumnsCount), BLUEPRINT_GRID_ROWS);
            RefreshBlueprintGridColors();
        }
        private void RefreshQueue()
        {
            m_queueGrid.Clear();
            int i = 0;
            foreach (var queueItem in m_selectedAssembler.Queue)
            {
                m_textCache.Clear()
                    .Append((int)queueItem.Amount)
                    .Append('x');

                var item = new MyGuiControlGrid.Item(
                    icon: queueItem.Blueprint.Icon,
                    toolTip: queueItem.Blueprint.DisplayNameText,
                    userData: queueItem);
                item.AddText(text: m_textCache, textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);

                if (MyFakes.SHOW_PRODUCTION_QUEUE_ITEM_IDS)
                {
                    m_textCache.Clear()
                        .Append((int)queueItem.ItemId);

                    item.AddText(text: m_textCache, textAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP);
                }

                m_queueGrid.Add(item);
                ++i;
            }

            m_queueGrid.RowsCount = Math.Max(1 + (i / m_queueGrid.ColumnsCount), QUEUE_GRID_ROWS);
            RefreshProgress();
        }
Пример #6
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);
     }
 }
 /// <summary>
 /// Stops dragging item
 /// </summary>
 public void Stop()
 {
     m_draggingFrom = null;
     m_draggingGridItem = null;
     m_currentDropHandleType = null;
     m_dragButton = null;
 }
 /// <summary>
 /// Starts dragging item
 /// </summary>
 /// <param name="dropHandleType">On which action released drop event</param>
 /// <param name="draggingItem">Item which is dragging</param>
 /// <param name="draggingFrom">Information about item's origin</param>
 public void StartDragging(MyDropHandleType dropHandleType, MySharedButtonsEnum dragButton, MyGuiControlGrid.Item draggingItem, MyDragAndDropInfo draggingFrom, bool includeTooltip = true)
 {
     m_currentDropHandleType = dropHandleType;
     m_dragButton = dragButton;
     m_draggingGridItem = draggingItem;
     m_draggingFrom = draggingFrom;
     m_toolTip = (includeTooltip) ? draggingItem.ToolTip : null;
 }
Пример #9
0
        protected virtual void SetGridItemAt(int slot, MyToolbarItem item, string[] icons, string subicon, String tooltip, MyGuiControlGrid.ColoredIcon? symbol = null, bool clear = false)
        {
            var gridItem = m_toolbarItemsGrid.GetItemAt(slot);

            if (gridItem == null)
            {
                gridItem = new MyGuiControlGrid.Item(
                    icons: icons,
                    subicon: subicon,
                    toolTip: tooltip,
                    userData: item);
                //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);
            }

            if (item == null || clear)
                gridItem.ClearAllText();

            if (DrawNumbers)
                gridItem.AddText(MyToolbarComponent.GetSlotControlText(slot));

            if (item != null)
                item.FillGridItem(gridItem);

            gridItem.Enabled = (item != null) ? item.Enabled : true;
            if (symbol.HasValue)
                gridItem.AddIcon(symbol.Value, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);

        }