Esempio n. 1
0
        public FurnitureInventoryPanel(CreativeInventoryWidget creativeInventoryWidget)
        {
            m_creativeInventoryWidget       = creativeInventoryWidget;
            ComponentFurnitureInventory     = creativeInventoryWidget.Entity.FindComponent <ComponentFurnitureInventory>(throwOnError: true);
            m_componentPlayer               = creativeInventoryWidget.Entity.FindComponent <ComponentPlayer>(throwOnError: true);
            SubsystemFurnitureBlockBehavior = ComponentFurnitureInventory.Project.FindSubsystem <SubsystemFurnitureBlockBehavior>(throwOnError: true);
            SubsystemTerrain = ComponentFurnitureInventory.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
            XElement node = ContentManager.Get <XElement>("Widgets/FurnitureInventoryPanel");

            LoadContents(this, node);
            m_furnitureSetList = Children.Find <ListPanelWidget>("FurnitureSetList");
            m_inventoryGrid    = Children.Find <GridPanelWidget>("InventoryGrid");
            m_addButton        = Children.Find <ButtonWidget>("AddButton");
            m_moreButton       = Children.Find <ButtonWidget>("MoreButton");
            for (int i = 0; i < m_inventoryGrid.RowsCount; i++)
            {
                for (int j = 0; j < m_inventoryGrid.ColumnsCount; j++)
                {
                    InventorySlotWidget widget = new InventorySlotWidget();
                    m_inventoryGrid.Children.Add(widget);
                    m_inventoryGrid.SetWidgetCell(widget, new Point2(j, i));
                }
            }
            ListPanelWidget furnitureSetList = m_furnitureSetList;

            furnitureSetList.ItemWidgetFactory   = (Func <object, Widget>)Delegate.Combine(furnitureSetList.ItemWidgetFactory, (Func <object, Widget>)((object item) => new FurnitureSetItemWidget(this, (FurnitureSet)item)));
            m_furnitureSetList.SelectionChanged += delegate
            {
                if (!m_ignoreSelectionChanged && ComponentFurnitureInventory.FurnitureSet != m_furnitureSetList.SelectedItem as FurnitureSet)
                {
                    ComponentFurnitureInventory.PageIndex    = 0;
                    ComponentFurnitureInventory.FurnitureSet = (m_furnitureSetList.SelectedItem as FurnitureSet);
                    if (ComponentFurnitureInventory.FurnitureSet == null)
                    {
                        m_furnitureSetList.SelectedIndex = 0;
                    }
                    AssignInventorySlots();
                }
            };
            m_populateNeeded = true;
        }
        public CreativeInventoryPanel(CreativeInventoryWidget creativeInventoryWidget)
        {
            m_creativeInventoryWidget    = creativeInventoryWidget;
            m_componentCreativeInventory = creativeInventoryWidget.Entity.FindComponent <ComponentCreativeInventory>(throwOnError: true);
            XElement node = ContentManager.Get <XElement>("Widgets/CreativeInventoryPanel");

            LoadContents(this, node);
            m_inventoryGrid = Children.Find <GridPanelWidget>("InventoryGrid");
            for (int i = 0; i < m_inventoryGrid.RowsCount; i++)
            {
                for (int j = 0; j < m_inventoryGrid.ColumnsCount; j++)
                {
                    InventorySlotWidget widget = new InventorySlotWidget
                    {
                        HideEditOverlay        = true,
                        HideInteractiveOverlay = true,
                        HideFoodOverlay        = true
                    };
                    m_inventoryGrid.Children.Add(widget);
                    m_inventoryGrid.SetWidgetCell(widget, new Point2(j, i));
                }
            }
        }