Пример #1
0
 private int GetMaxListboxItems(MyGuiControlListbox listbox)
 {
     if (listbox == m_shipInventoryListBox)
     {
         return GetMaxInventoryItems(m_smallShipsBuilders[m_currentShipBuilderIndex].Builder.Inventory);
     }
     else if (listbox == m_otherSideInventoryListBox)
     {
         return GetMaxInventoryItems(m_otherSideInventoryBuilder);
     }
     else
     {
         return listbox.GetRowsCount() * listbox.GetColumsCount();
     }
 }
Пример #2
0
        private void DropItem(MyGuiControlListbox listbox, MyGuiControlListboxItem item, int rowIndex, int itemIndex)
        {
            // in god editor and other side listbox, we don't want put this item to this listbox, so we remove it
            if (m_inventoryScreenType == MyGuiScreenInventoryType.GodEditor && listbox == m_otherSideInventoryListBox)
            {
                m_itemsRepository.RemoveItem(item.Key);
            }
            else
            {
                if (listbox.GetItem(rowIndex, itemIndex) != null || listbox.GetRowsCount() <= rowIndex)
                {
                    listbox.AddItem(item);
                }
                else
                {
                    listbox.AddItem(item, rowIndex, itemIndex);
                }

                // if there are no empty row, we try add new row
                if (listbox.GetEmptyRowsCount() == 0)
                {
                    AddFreeRowsIfCan(listbox, 1);
                }                
            }
            StopDragging();
        }
Пример #3
0
 private void AddFreeRowsIfCan(MyGuiControlListbox listbox, int rowCount)
 {
     int maxRows = (int)Math.Ceiling((double)GetMaxListboxItems(listbox) / INVENTORY_COLUMNS);
     if (listbox.GetRowsCount() + rowCount <= maxRows)
     {
         listbox.AddRows(rowCount);
     }
 }