예제 #1
0
        public PresserWidget(IInventory inventory, T component, string path)
        {
            m_componentFurnace = component;
            WidgetsManager.LoadWidgetContents(this, this, ContentManager.Get <XElement>(path));
            m_inventoryGrid = Children.Find <GridPanelWidget>("InventoryGrid");
            m_furnaceGrid   = Children.Find <GridPanelWidget>("FurnaceGrid");
            m_fire          = Children.Find <FireWidget>("Fire");
            m_progress      = Children.Find <ValueBarWidget>("Progress");
            m_resultSlot    = Children.Find <InventorySlotWidget>("ResultSlot");
            int num = 6, y, x;
            InventorySlotWidget inventorySlotWidget;

            for (y = 0; y < m_inventoryGrid.RowsCount; y++)
            {
                for (x = 0; x < m_inventoryGrid.ColumnsCount; x++)
                {
                    inventorySlotWidget = new InventorySlotWidget();
                    inventorySlotWidget.AssignInventorySlot(inventory, num++);
                    m_inventoryGrid.Children.Add(inventorySlotWidget);
                    m_inventoryGrid.SetWidgetCell(inventorySlotWidget, new Point2(x, y));
                }
            }
            num = 0;
            for (y = 0; y < m_furnaceGrid.RowsCount; y++)
            {
                for (x = 0; x < m_furnaceGrid.ColumnsCount; x++)
                {
                    inventorySlotWidget = new InventorySlotWidget();
                    inventorySlotWidget.AssignInventorySlot(component, num++);
                    m_furnaceGrid.Children.Add(inventorySlotWidget);
                    m_furnaceGrid.SetWidgetCell(inventorySlotWidget, new Point2(x, y));
                }
            }
            m_resultSlot.AssignInventorySlot(component, component.ResultSlotIndex);
        }
예제 #2
0
        public ChestWidget(IInventory inventory, ComponentChest componentChest)
        {
            m_componentChest = componentChest;
            XElement node = ContentManager.Get <XElement>("Widgets/ChestWidget");

            LoadContents(this, node);
            m_inventoryGrid = Children.Find <GridPanelWidget>("InventoryGrid");
            m_chestGrid     = Children.Find <GridPanelWidget>("ChestGrid");
            int num = 0;

            for (int i = 0; i < m_chestGrid.RowsCount; i++)
            {
                for (int j = 0; j < m_chestGrid.ColumnsCount; j++)
                {
                    InventorySlotWidget inventorySlotWidget = new InventorySlotWidget();
                    inventorySlotWidget.AssignInventorySlot(componentChest, num++);
                    m_chestGrid.Children.Add(inventorySlotWidget);
                    m_chestGrid.SetWidgetCell(inventorySlotWidget, new Point2(j, i));
                }
            }
            num = 10;
            for (int k = 0; k < m_inventoryGrid.RowsCount; k++)
            {
                for (int l = 0; l < m_inventoryGrid.ColumnsCount; l++)
                {
                    InventorySlotWidget inventorySlotWidget2 = new InventorySlotWidget();
                    inventorySlotWidget2.AssignInventorySlot(inventory, num++);
                    m_inventoryGrid.Children.Add(inventorySlotWidget2);
                    m_inventoryGrid.SetWidgetCell(inventorySlotWidget2, new Point2(l, k));
                }
            }
        }
예제 #3
0
        public NewChestWidget(IInventory inventory, ComponentInventoryBase component, string text = null)
        {
            Component = component;
            WidgetsManager.LoadWidgetContents(this, this, ContentManager.Get <XElement>("Widgets/NewChestWidget"));
            if (text != null)
            {
                Children.Find <LabelWidget>("ChestLabel").Text = text;
            }
            m_inventoryGrid = Children.Find <GridPanelWidget>("InventoryGrid");
            m_chestNewGrid  = Children.Find <GridPanelWidget>("ChestGrid");
            int num = 0, y, x;
            InventorySlotWidget inventorySlotWidget;

            for (y = 0; y < m_chestNewGrid.RowsCount; y++)
            {
                for (x = 0; x < m_chestNewGrid.ColumnsCount; x++)
                {
                    inventorySlotWidget = new InventorySlotWidget();
                    inventorySlotWidget.AssignInventorySlot(component, num++);
                    m_chestNewGrid.Children.Add(inventorySlotWidget);
                    m_chestNewGrid.SetWidgetCell(inventorySlotWidget, new Point2(x, y));
                }
            }
            num = 6;
            for (y = 0; y < m_inventoryGrid.RowsCount; y++)
            {
                for (x = 0; x < m_inventoryGrid.ColumnsCount; x++)
                {
                    inventorySlotWidget = new InventorySlotWidget();
                    inventorySlotWidget.AssignInventorySlot(inventory, num++);
                    m_inventoryGrid.Children.Add(inventorySlotWidget);
                    m_inventoryGrid.SetWidgetCell(inventorySlotWidget, new Point2(x, y));
                }
            }
        }
예제 #4
0
        public FullInventoryWidget(IInventory inventory, ComponentCraftingTable componentCraftingTable)
        {
            XElement node = ContentManager.Get <XElement>("Widgets/FullInventoryWidget");

            LoadContents(this, node);
            m_inventoryGrid       = Children.Find <GridPanelWidget>("InventoryGrid");
            m_craftingGrid        = Children.Find <GridPanelWidget>("CraftingGrid");
            m_craftingResultSlot  = Children.Find <InventorySlotWidget>("CraftingResultSlot");
            m_craftingRemainsSlot = Children.Find <InventorySlotWidget>("CraftingRemainsSlot");
            int num = 10;

            for (int i = 0; i < m_inventoryGrid.RowsCount; i++)
            {
                for (int j = 0; j < m_inventoryGrid.ColumnsCount; j++)
                {
                    InventorySlotWidget inventorySlotWidget = new InventorySlotWidget();
                    inventorySlotWidget.AssignInventorySlot(inventory, num++);
                    m_inventoryGrid.Children.Add(inventorySlotWidget);
                    m_inventoryGrid.SetWidgetCell(inventorySlotWidget, new Point2(j, i));
                }
            }
            num = 0;
            for (int k = 0; k < m_craftingGrid.RowsCount; k++)
            {
                for (int l = 0; l < m_craftingGrid.ColumnsCount; l++)
                {
                    InventorySlotWidget inventorySlotWidget2 = new InventorySlotWidget();
                    inventorySlotWidget2.AssignInventorySlot(componentCraftingTable, num++);
                    m_craftingGrid.Children.Add(inventorySlotWidget2);
                    m_craftingGrid.SetWidgetCell(inventorySlotWidget2, new Point2(l, k));
                }
            }
            m_craftingResultSlot.AssignInventorySlot(componentCraftingTable, componentCraftingTable.ResultSlotIndex);
            m_craftingRemainsSlot.AssignInventorySlot(componentCraftingTable, componentCraftingTable.RemainsSlotIndex);
        }
예제 #5
0
        public CrossbowWidget(IInventory inventory, int slotIndex)
        {
            m_inventory = inventory;
            m_slotIndex = slotIndex;
            XElement node = ContentManager.Get <XElement>("Widgets/CrossbowWidget");

            LoadContents(this, node);
            m_inventoryGrid       = Children.Find <GridPanelWidget>("InventoryGrid");
            m_inventorySlotWidget = Children.Find <InventorySlotWidget>("InventorySlot");
            m_instructionsLabel   = Children.Find <LabelWidget>("InstructionsLabel");
            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));
                }
            }
            int num = 10;

            foreach (Widget child in m_inventoryGrid.Children)
            {
                (child as InventorySlotWidget)?.AssignInventorySlot(inventory, num++);
            }
            m_inventorySlotWidget.AssignInventorySlot(inventory, slotIndex);
            m_inventorySlotWidget.CustomViewMatrix = Matrix.CreateLookAt(new Vector3(0f, 1f, 0.2f), new Vector3(0f, 0f, 0.2f), -Vector3.UnitZ);
        }
예제 #6
0
        public Musket2Widget(IInventory inventory, int slotIndex)
        {
            m_inventory = inventory;
            m_slotIndex = slotIndex;
            WidgetsManager.LoadWidgetContents(this, this, ContentManager.Get <XElement>("Widgets/Musket2Widget"));
            m_inventoryGrid       = Children.Find <GridPanelWidget>("InventoryGrid");
            m_inventorySlotWidget = Children.Find <InventorySlotWidget>("InventorySlot");
            m_instructionsLabel   = Children.Find <LabelWidget>("InstructionsLabel");
            int i = 0, num;

            for (; i < m_inventoryGrid.RowsCount; i++)
            {
                for (num = 0; num < m_inventoryGrid.ColumnsCount; num++)
                {
                    var widget = new InventorySlotWidget();
                    m_inventoryGrid.Children.Add(widget);
                    m_inventoryGrid.SetWidgetCell(widget, new Point2(num, i));
                }
            }
            num = 6;
            i   = 0;
            for (int count = m_inventoryGrid.Children.Count; i < count; i++)
            {
                if (m_inventoryGrid.Children[i] is InventorySlotWidget inventorySlotWidget)
                {
                    inventorySlotWidget.AssignInventorySlot(inventory, num++);
                }
            }
            m_inventorySlotWidget.AssignInventorySlot(inventory, slotIndex);
            m_inventorySlotWidget.CustomViewMatrix = Matrix.CreateLookAt(new Vector3(1f, 0f, 0f), new Vector3(0f, 0f, 0f), -Vector3.UnitZ);
        }
예제 #7
0
        public ClothingWidget(ComponentPlayer componentPlayer)
        {
            m_componentPlayer = componentPlayer;
            XElement node = ContentManager.Get <XElement>("Widgets/ClothingWidget");

            LoadContents(this, node);
            m_clothingStack            = Children.Find <StackPanelWidget>("ClothingStack");
            m_inventoryGrid            = Children.Find <GridPanelWidget>("InventoryGrid");
            m_vitalStatsButton         = Children.Find <ButtonWidget>("VitalStatsButton");
            m_sleepButton              = Children.Find <ButtonWidget>("SleepButton");
            m_innerClothingModelWidget = Children.Find <PlayerModelWidget>("InnerClothingModel");
            m_outerClothingModelWidget = Children.Find <PlayerModelWidget>("OuterClothingModel");
            for (int i = 0; i < 4; i++)
            {
                InventorySlotWidget inventorySlotWidget = new InventorySlotWidget();
                float y = float.PositiveInfinity;
                if (i == 0)
                {
                    y = 68f;
                }
                if (i == 3)
                {
                    y = 54f;
                }
                inventorySlotWidget.Size        = new Vector2(float.PositiveInfinity, y);
                inventorySlotWidget.BevelColor  = Color.Transparent;
                inventorySlotWidget.CenterColor = Color.Transparent;
                inventorySlotWidget.AssignInventorySlot(m_componentPlayer.ComponentClothing, i);
                inventorySlotWidget.HideEditOverlay        = true;
                inventorySlotWidget.HideInteractiveOverlay = true;
                inventorySlotWidget.HideFoodOverlay        = true;
                inventorySlotWidget.HideHighlightRectangle = true;
                inventorySlotWidget.HideBlockIcon          = true;
                inventorySlotWidget.HideHealthBar          = (m_componentPlayer.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true).WorldSettings.GameMode == GameMode.Creative);
                m_clothingStack.Children.Add(inventorySlotWidget);
            }
            int num = 10;

            for (int j = 0; j < m_inventoryGrid.RowsCount; j++)
            {
                for (int k = 0; k < m_inventoryGrid.ColumnsCount; k++)
                {
                    InventorySlotWidget inventorySlotWidget2 = new InventorySlotWidget();
                    inventorySlotWidget2.AssignInventorySlot(componentPlayer.ComponentMiner.Inventory, num++);
                    m_inventoryGrid.Children.Add(inventorySlotWidget2);
                    m_inventoryGrid.SetWidgetCell(inventorySlotWidget2, new Point2(k, j));
                }
            }
            m_innerClothingModelWidget.PlayerClass          = componentPlayer.PlayerData.PlayerClass;
            m_innerClothingModelWidget.CharacterSkinTexture = m_componentPlayer.ComponentClothing.InnerClothedTexture;
            m_outerClothingModelWidget.PlayerClass          = componentPlayer.PlayerData.PlayerClass;
            m_outerClothingModelWidget.OuterClothingTexture = m_componentPlayer.ComponentClothing.OuterClothedTexture;
        }
예제 #8
0
        public LiquidPumpWidget(IInventory inventory, ComponentInventoryBase componentDispenser)
        {
            m_componentDispenser   = componentDispenser;
            m_componentBlockEntity = componentDispenser.Entity.FindComponent <ComponentBlockEntity>(true);
            m_subsystemTerrain     = componentDispenser.Project.FindSubsystem <SubsystemTerrain>(true);
            WidgetsManager.LoadWidgetContents(this, this, ContentManager.Get <XElement>("Widgets/LiquidPumpWidget"));
            m_inventoryGrid  = Children.Find <GridPanelWidget>("InventoryGrid");
            m_dispenserGrid  = Children.Find <GridPanelWidget>("DispenserGrid");
            m_dispenserGrid2 = Children.Find <GridPanelWidget>("DispenserGrid2");
            m_drillSlot      = Children.Find <InventorySlotWidget>("DrillSlot");
            int num = 0, y, x;

            for (y = 0; y < m_dispenserGrid.RowsCount; y++)
            {
                for (x = 0; x < m_dispenserGrid.ColumnsCount; x++)
                {
                    var inventorySlotWidget = new InventorySlotWidget();
                    inventorySlotWidget.AssignInventorySlot(componentDispenser, num++);
                    m_dispenserGrid.Children.Add(inventorySlotWidget);
                    m_dispenserGrid.SetWidgetCell(inventorySlotWidget, new Point2(x, y));
                }
            }
            for (y = 0; y < m_dispenserGrid2.RowsCount; y++)
            {
                for (x = 0; x < m_dispenserGrid2.ColumnsCount; x++)
                {
                    var inventorySlotWidget2 = new InventorySlotWidget();
                    inventorySlotWidget2.AssignInventorySlot(componentDispenser, num++);
                    m_dispenserGrid2.Children.Add(inventorySlotWidget2);
                    m_dispenserGrid2.SetWidgetCell(inventorySlotWidget2, new Point2(x, y));
                }
            }
            num = 6;
            for (y = 0; y < m_inventoryGrid.RowsCount; y++)
            {
                for (x = 0; x < m_inventoryGrid.ColumnsCount; x++)
                {
                    var inventorySlotWidget3 = new InventorySlotWidget();
                    inventorySlotWidget3.AssignInventorySlot(inventory, num++);
                    m_inventoryGrid.Children.Add(inventorySlotWidget3);
                    m_inventoryGrid.SetWidgetCell(inventorySlotWidget3, new Point2(x, y));
                }
            }
            m_drillSlot.AssignInventorySlot(componentDispenser, 8);
        }
예제 #9
0
        public FractionalTowerWidget(IInventory inventory, ComponentMachine componentFurnace)
        {
            m_componentFurnace = componentFurnace;
            WidgetsManager.LoadWidgetContents(this, this, ContentManager.Get <XElement>("Widgets/FractionalTowerWidget"));
            m_inventoryGrid   = Children.Find <GridPanelWidget>("InventoryGrid");
            m_furnaceGrid     = Children.Find <GridPanelWidget>("FurnaceGrid");
            m_result1         = Children.Find <InventorySlotWidget>("ResultSlot1");
            m_result2         = Children.Find <InventorySlotWidget>("ResultSlot2");
            m_result3         = Children.Find <InventorySlotWidget>("ResultSlot3");
            m_cir1            = Children.Find <InventorySlotWidget>("CircuitSlot1");
            m_cir2            = Children.Find <InventorySlotWidget>("CircuitSlot2");
            m_acceptsDropsBox = Children.Find <CheckboxWidget>("AcceptsElectBox");
            m_progress        = Children.Find <ValueBarWidget>("Progress");

            int num = 6, y, x;
            InventorySlotWidget inventorySlotWidget;

            for (y = 0; y < m_inventoryGrid.RowsCount; y++)
            {
                for (x = 0; x < m_inventoryGrid.ColumnsCount; x++)
                {
                    inventorySlotWidget = new InventorySlotWidget();
                    inventorySlotWidget.AssignInventorySlot(inventory, num++);
                    m_inventoryGrid.Children.Add(inventorySlotWidget);
                    m_inventoryGrid.SetWidgetCell(inventorySlotWidget, new Point2(x, y));
                }
            }

            num = 0;
            for (y = 0; y < m_furnaceGrid.RowsCount; y++)
            {
                for (x = 0; x < m_furnaceGrid.ColumnsCount; x++)
                {
                    inventorySlotWidget = new InventorySlotWidget();
                    inventorySlotWidget.AssignInventorySlot(componentFurnace, num++);
                    m_furnaceGrid.Children.Add(inventorySlotWidget);
                    m_furnaceGrid.SetWidgetCell(inventorySlotWidget, new Point2(x, y));
                }
            }
            m_result1.AssignInventorySlot(componentFurnace, num++);
            m_result2.AssignInventorySlot(componentFurnace, num++);
            m_result3.AssignInventorySlot(componentFurnace, num++);
            m_cir1.AssignInventorySlot(componentFurnace, num++);
            m_cir2.AssignInventorySlot(componentFurnace, num++);
        }
예제 #10
0
        public ElectricFurnaceWidget(IInventory inventory, ComponentElectricFurnace componentFurnace)
        {
            m_componentFurnace = componentFurnace;
            WidgetsManager.LoadWidgetContents(this, this, ContentManager.Get <XElement>("Widgets/ElectricFurnaceWidget"));
            m_inventoryGrid   = Children.Find <GridPanelWidget>("InventoryGrid");
            m_furnaceGrid     = Children.Find <GridPanelWidget>("FurnaceGrid");
            m_fire            = Children.Find <FireWidget>("Fire");
            m_progress        = Children.Find <ValueBarWidget>("Progress");
            m_resultSlot      = Children.Find <InventorySlotWidget>("ResultSlot");
            m_remainsSlot     = Children.Find <InventorySlotWidget>("RemainsSlot");
            m_circuitSlot     = Children.Find <InventorySlotWidget>("CircuitSlot");
            m_acceptsDropsBox = Children.Find <CheckboxWidget>("AcceptsElectBox");
            m_circuit2Slot    = Children.Find <InventorySlotWidget>("Circuit2Slot");
            int num = 6, y, x;
            InventorySlotWidget inventorySlotWidget;

            for (y = 0; y < m_inventoryGrid.RowsCount; y++)
            {
                for (x = 0; x < m_inventoryGrid.ColumnsCount; x++)
                {
                    inventorySlotWidget = new InventorySlotWidget();
                    inventorySlotWidget.AssignInventorySlot(inventory, num++);
                    m_inventoryGrid.Children.Add(inventorySlotWidget);
                    m_inventoryGrid.SetWidgetCell(inventorySlotWidget, new Point2(x, y));
                }
            }
            num = 0;
            for (y = 0; y < m_furnaceGrid.RowsCount; y++)
            {
                for (x = 0; x < m_furnaceGrid.ColumnsCount; x++)
                {
                    inventorySlotWidget = new InventorySlotWidget();
                    inventorySlotWidget.AssignInventorySlot(componentFurnace, num++);
                    m_furnaceGrid.Children.Add(inventorySlotWidget);
                    m_furnaceGrid.SetWidgetCell(inventorySlotWidget, new Point2(x, y));
                }
            }
            m_resultSlot.AssignInventorySlot(componentFurnace, componentFurnace.ResultSlotIndex);
            m_remainsSlot.AssignInventorySlot(componentFurnace, componentFurnace.RemainsSlotIndex);
            m_circuitSlot.AssignInventorySlot(componentFurnace, componentFurnace.Cir1SlotIndex);
            m_circuit2Slot.AssignInventorySlot(componentFurnace, componentFurnace.Cir2SlotIndex);
        }
예제 #11
0
        public BlastFurnaceWidget(IInventory inventory, ComponentBlastFurnace componentFurnace)
        {
            m_componentFurnace = componentFurnace;
            WidgetsManager.LoadWidgetContents(this, this, ContentManager.Get <XElement>("Widgets/BlastFurnaceWidget"));
            m_inventoryGrid = Children.Find <GridPanelWidget>("InventoryGrid");
            m_furnaceGrid   = Children.Find <GridPanelWidget>("FurnaceGrid");
            m_fire          = Children.Find <FireWidget>("Fire");
            m_progress      = Children.Find <ValueBarWidget>("Progress");
            m_resultSlot    = Children.Find <InventorySlotWidget>("ResultSlot");
            m_remainsSlot   = Children.Find <InventorySlotWidget>("RemainsSlot");
            m_remainsSlot2  = Children.Find <InventorySlotWidget>("RemainsSlot2");
            m_remainsSlot3  = Children.Find <InventorySlotWidget>("RemainsSlot3");
            int num = 6, y, x;
            InventorySlotWidget inventorySlotWidget;

            for (y = 0; y < m_inventoryGrid.RowsCount; y++)
            {
                for (x = 0; x < m_inventoryGrid.ColumnsCount; x++)
                {
                    inventorySlotWidget = new InventorySlotWidget();
                    inventorySlotWidget.AssignInventorySlot(inventory, num++);
                    m_inventoryGrid.Children.Add(inventorySlotWidget);
                    m_inventoryGrid.SetWidgetCell(inventorySlotWidget, new Point2(x, y));
                }
            }
            num = 0;
            for (y = 0; y < m_furnaceGrid.RowsCount; y++)
            {
                for (x = 0; x < m_furnaceGrid.ColumnsCount; x++)
                {
                    inventorySlotWidget = new InventorySlotWidget();
                    inventorySlotWidget.AssignInventorySlot(componentFurnace, num++);
                    m_furnaceGrid.Children.Add(inventorySlotWidget);
                    m_furnaceGrid.SetWidgetCell(inventorySlotWidget, new Point2(x, y));
                }
            }
            m_resultSlot.AssignInventorySlot(componentFurnace, 8);
            m_remainsSlot.AssignInventorySlot(componentFurnace, 9);
            m_remainsSlot2.AssignInventorySlot(componentFurnace, 10);
            m_remainsSlot3.AssignInventorySlot(componentFurnace, 11);
        }
예제 #12
0
        public FurnaceWidget(IInventory inventory, ComponentFurnace componentFurnace)
        {
            m_componentFurnace = componentFurnace;
            XElement node = ContentManager.Get <XElement>("Widgets/FurnaceWidget");

            LoadContents(this, node);
            m_inventoryGrid = Children.Find <GridPanelWidget>("InventoryGrid");
            m_furnaceGrid   = Children.Find <GridPanelWidget>("FurnaceGrid");
            m_fire          = Children.Find <FireWidget>("Fire");
            m_progress      = Children.Find <ValueBarWidget>("Progress");
            m_resultSlot    = Children.Find <InventorySlotWidget>("ResultSlot");
            m_remainsSlot   = Children.Find <InventorySlotWidget>("RemainsSlot");
            m_fuelSlot      = Children.Find <InventorySlotWidget>("FuelSlot");
            int num = 10;

            for (int i = 0; i < m_inventoryGrid.RowsCount; i++)
            {
                for (int j = 0; j < m_inventoryGrid.ColumnsCount; j++)
                {
                    InventorySlotWidget inventorySlotWidget = new InventorySlotWidget();
                    inventorySlotWidget.AssignInventorySlot(inventory, num++);
                    m_inventoryGrid.Children.Add(inventorySlotWidget);
                    m_inventoryGrid.SetWidgetCell(inventorySlotWidget, new Point2(j, i));
                }
            }
            num = 0;
            for (int k = 0; k < m_furnaceGrid.RowsCount; k++)
            {
                for (int l = 0; l < m_furnaceGrid.ColumnsCount; l++)
                {
                    InventorySlotWidget inventorySlotWidget2 = new InventorySlotWidget();
                    inventorySlotWidget2.AssignInventorySlot(componentFurnace, num++);
                    m_furnaceGrid.Children.Add(inventorySlotWidget2);
                    m_furnaceGrid.SetWidgetCell(inventorySlotWidget2, new Point2(l, k));
                }
            }
            m_fuelSlot.AssignInventorySlot(componentFurnace, componentFurnace.FuelSlotIndex);
            m_resultSlot.AssignInventorySlot(componentFurnace, componentFurnace.ResultSlotIndex);
            m_remainsSlot.AssignInventorySlot(componentFurnace, componentFurnace.RemainsSlotIndex);
        }
예제 #13
0
        //protected readonly InventorySlotWidget m_remainsSlot;

        //protected readonly InventorySlotWidget m_resultSlot;

        public FireBoxWidget(IInventory inventory, T component, string path)
        {
            m_componentFurnace = component;
            WidgetsManager.LoadWidgetContents(this, this, ContentManager.Get <XElement>(path));
            m_inventoryGrid = Children.Find <GridPanelWidget>("InventoryGrid");
            m_fire          = Children.Find <FireWidget>("Fire");
            m_progress      = Children.Find <ValueBarWidget>("Progress");
            m_fuelSlot      = Children.Find <InventorySlotWidget>("FuelSlot");
            int num = 6;

            for (int i = 0; i < m_inventoryGrid.RowsCount; i++)
            {
                for (int j = 0; j < m_inventoryGrid.ColumnsCount; j++)
                {
                    var inventorySlotWidget = new InventorySlotWidget();
                    inventorySlotWidget.AssignInventorySlot(inventory, num++);
                    m_inventoryGrid.Children.Add(inventorySlotWidget);
                    m_inventoryGrid.SetWidgetCell(inventorySlotWidget, new Point2(j, i));
                }
            }
            m_fuelSlot.AssignInventorySlot(component, component.FuelSlotIndex);
        }
예제 #14
0
        public override void MeasureOverride(Vector2 parentAvailableSize)
        {
            int max = (m_inventory is ComponentCreativeInventory) ? 10 : 7;

            m_inventory.VisibleSlotsCount = MathUtils.Clamp((int)((parentAvailableSize.X - 320f - 25f) / 72f), 7, max);
            if (m_inventory.VisibleSlotsCount != m_inventoryGrid.Children.Count)
            {
                m_inventoryGrid.Children.Clear();
                m_inventoryGrid.RowsCount    = 1;
                m_inventoryGrid.ColumnsCount = m_inventory.VisibleSlotsCount;
                for (int i = 0; i < m_inventoryGrid.ColumnsCount; i++)
                {
                    InventorySlotWidget inventorySlotWidget = new InventorySlotWidget();
                    inventorySlotWidget.AssignInventorySlot(m_inventory, i);
                    inventorySlotWidget.BevelColor  = new Color(181, 172, 154) * 0.6f;
                    inventorySlotWidget.CenterColor = new Color(181, 172, 154) * 0.33f;
                    m_inventoryGrid.Children.Add(inventorySlotWidget);
                    m_inventoryGrid.SetWidgetCell(inventorySlotWidget, new Point2(i, 0));
                }
            }
            base.MeasureOverride(parentAvailableSize);
        }
예제 #15
0
        public MachineToolWidget(IInventory inventory, ComponentLargeCraftingTable componentCraftingTable)
        {
            m_componentCraftingTable = componentCraftingTable;
            WidgetsManager.LoadWidgetContents(this, this, ContentManager.Get <XElement>("Widgets/MachineToolWidget"));
            m_inventoryGrid       = Children.Find <GridPanelWidget>("InventoryGrid");
            m_craftingGrid        = Children.Find <GridPanelWidget>("CraftingGrid");
            m_craftingResultSlot  = Children.Find <InventorySlotWidget>("CraftingResultSlot");
            m_craftingRemainsSlot = Children.Find <InventorySlotWidget>("CraftingRemainsSlot");
            int num = 6, y, x;
            InventorySlotWidget inventorySlotWidget;

            for (y = 0; y < m_inventoryGrid.RowsCount; y++)
            {
                for (x = 0; x < m_inventoryGrid.ColumnsCount; x++)
                {
                    inventorySlotWidget = new InventorySlotWidget();
                    inventorySlotWidget.AssignInventorySlot(inventory, num++);
                    m_inventoryGrid.Children.Add(inventorySlotWidget);
                    m_inventoryGrid.SetWidgetCell(inventorySlotWidget, new Point2(x, y));
                }
            }
            num = 0;
            for (y = 0; y < m_craftingGrid.RowsCount; y++)
            {
                for (x = 0; x < m_craftingGrid.ColumnsCount; x++)
                {
                    inventorySlotWidget = new InventorySlotWidget();                    /*
                                                                                         * {
                                                                                         * Size = new Vector2(48f)
                                                                                         * };*/
                    inventorySlotWidget.AssignInventorySlot(m_componentCraftingTable, num++);
                    m_craftingGrid.Children.Add(inventorySlotWidget);
                    m_craftingGrid.SetWidgetCell(inventorySlotWidget, new Point2(x, y));
                }
            }
            m_craftingResultSlot.AssignInventorySlot(m_componentCraftingTable, m_componentCraftingTable.ResultSlotIndex);
            m_craftingRemainsSlot.AssignInventorySlot(m_componentCraftingTable, m_componentCraftingTable.RemainsSlotIndex);
        }
예제 #16
0
        public DrillerWidget(IInventory inventory, ComponentInventoryBase componentDispenser)
        {
            m_componentDispenser   = componentDispenser;
            m_componentBlockEntity = componentDispenser.Entity.FindComponent <ComponentBlockEntity>(true);
            m_subsystemTerrain     = componentDispenser.Project.FindSubsystem <SubsystemTerrain>(true);
            WidgetsManager.LoadWidgetContents(this, this, ContentManager.Get <XElement>("Widgets/DrillerWidget"));
            m_inventoryGrid   = Children.Find <GridPanelWidget>("InventoryGrid");
            m_dispenserGrid   = Children.Find <GridPanelWidget>("DispenserGrid");
            m_dispenseButton  = Children.Find <ButtonWidget>("DispenseButton");
            m_shootButton     = Children.Find <ButtonWidget>("ShootButton");
            m_acceptsDropsBox = Children.Find <CheckboxWidget>("AcceptsDropsBox");
            m_drillSlot       = Children.Find <InventorySlotWidget>("DrillSlot");
            int num = 6, y, x;
            InventorySlotWidget inventorySlotWidget;

            for (y = 0; y < m_inventoryGrid.RowsCount; y++)
            {
                for (x = 0; x < m_inventoryGrid.ColumnsCount; x++)
                {
                    inventorySlotWidget = new InventorySlotWidget();
                    inventorySlotWidget.AssignInventorySlot(inventory, num++);
                    m_inventoryGrid.Children.Add(inventorySlotWidget);
                    m_inventoryGrid.SetWidgetCell(inventorySlotWidget, new Point2(x, y));
                }
            }
            num = 0;
            for (y = 0; y < m_dispenserGrid.RowsCount; y++)
            {
                for (x = 0; x < m_dispenserGrid.ColumnsCount; x++)
                {
                    inventorySlotWidget = new InventorySlotWidget();
                    inventorySlotWidget.AssignInventorySlot(componentDispenser, num++);
                    m_dispenserGrid.Children.Add(inventorySlotWidget);
                    m_dispenserGrid.SetWidgetCell(inventorySlotWidget, new Point2(x, y));
                }
            }
            m_drillSlot.AssignInventorySlot(componentDispenser, 8);
        }
예제 #17
0
        public DispenserWidget(IInventory inventory, ComponentDispenser componentDispenser)
        {
            m_componentDispenser   = componentDispenser;
            m_componentBlockEntity = componentDispenser.Entity.FindComponent <ComponentBlockEntity>(throwOnError: true);
            m_subsystemTerrain     = componentDispenser.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
            XElement node = ContentManager.Get <XElement>("Widgets/DispenserWidget");

            LoadContents(this, node);
            m_inventoryGrid   = Children.Find <GridPanelWidget>("InventoryGrid");
            m_dispenserGrid   = Children.Find <GridPanelWidget>("DispenserGrid");
            m_dispenseButton  = Children.Find <ButtonWidget>("DispenseButton");
            m_shootButton     = Children.Find <ButtonWidget>("ShootButton");
            m_acceptsDropsBox = Children.Find <CheckboxWidget>("AcceptsDropsBox");
            int num = 0;

            for (int i = 0; i < m_dispenserGrid.RowsCount; i++)
            {
                for (int j = 0; j < m_dispenserGrid.ColumnsCount; j++)
                {
                    InventorySlotWidget inventorySlotWidget = new InventorySlotWidget();
                    inventorySlotWidget.AssignInventorySlot(componentDispenser, num++);
                    m_dispenserGrid.Children.Add(inventorySlotWidget);
                    m_dispenserGrid.SetWidgetCell(inventorySlotWidget, new Point2(j, i));
                }
            }
            num = 10;
            for (int k = 0; k < m_inventoryGrid.RowsCount; k++)
            {
                for (int l = 0; l < m_inventoryGrid.ColumnsCount; l++)
                {
                    InventorySlotWidget inventorySlotWidget2 = new InventorySlotWidget();
                    inventorySlotWidget2.AssignInventorySlot(inventory, num++);
                    m_inventoryGrid.Children.Add(inventorySlotWidget2);
                    m_inventoryGrid.SetWidgetCell(inventorySlotWidget2, new Point2(l, k));
                }
            }
        }
예제 #18
0
 public StoveWidget(IInventory inventory, ComponentMachine component, string path) : base(inventory, component, path)
 {
     m_fuelSlot = Children.Find <InventorySlotWidget>("FuelSlot");
     m_fuelSlot.AssignInventorySlot(component, component.FuelSlotIndex);
 }
 public override void Update()
 {
     if (m_assignedCategoryIndex >= 0)
     {
         if (base.Input.Scroll.HasValue)
         {
             Widget widget = HitTestGlobal(base.Input.Scroll.Value.XY);
             if (widget != null && widget.IsChildWidgetOf(m_inventoryGrid))
             {
                 m_componentCreativeInventory.PageIndex -= (int)base.Input.Scroll.Value.Z;
             }
         }
         if (m_creativeInventoryWidget.PageDownButton.IsClicked)
         {
             int num = ++m_componentCreativeInventory.PageIndex;
         }
         if (m_creativeInventoryWidget.PageUpButton.IsClicked)
         {
             int num = --m_componentCreativeInventory.PageIndex;
         }
         m_componentCreativeInventory.PageIndex = ((m_pagesCount > 0) ? MathUtils.Clamp(m_componentCreativeInventory.PageIndex, 0, m_pagesCount - 1) : 0);
     }
     if (m_componentCreativeInventory.CategoryIndex != m_assignedCategoryIndex)
     {
         if (m_creativeInventoryWidget.GetCategoryName(m_componentCreativeInventory.CategoryIndex) == LanguageControl.Get("CreativeInventoryWidget", 2))
         {
             m_slotIndices = new List <int>(Enumerable.Range(10, m_componentCreativeInventory.OpenSlotsCount - 10));
         }
         else
         {
             m_slotIndices.Clear();
             for (int i = m_componentCreativeInventory.OpenSlotsCount; i < m_componentCreativeInventory.SlotsCount; i++)
             {
                 int slotValue = m_componentCreativeInventory.GetSlotValue(i);
                 int num2      = Terrain.ExtractContents(slotValue);
                 if (BlocksManager.Blocks[num2].GetCategory(slotValue) == m_creativeInventoryWidget.GetCategoryName(m_componentCreativeInventory.CategoryIndex))
                 {
                     m_slotIndices.Add(i);
                 }
             }
         }
         int num3 = m_inventoryGrid.ColumnsCount * m_inventoryGrid.RowsCount;
         m_pagesCount            = (m_slotIndices.Count + num3 - 1) / num3;
         m_assignedCategoryIndex = m_componentCreativeInventory.CategoryIndex;
         m_assignedPageIndex     = -1;
         m_componentCreativeInventory.PageIndex = 0;
     }
     if (m_componentCreativeInventory.PageIndex != m_assignedPageIndex)
     {
         int num4 = m_inventoryGrid.ColumnsCount * m_inventoryGrid.RowsCount;
         int num5 = m_componentCreativeInventory.PageIndex * num4;
         foreach (Widget child in m_inventoryGrid.Children)
         {
             InventorySlotWidget inventorySlotWidget = child as InventorySlotWidget;
             if (inventorySlotWidget != null)
             {
                 if (num5 < m_slotIndices.Count)
                 {
                     inventorySlotWidget.AssignInventorySlot(m_componentCreativeInventory, m_slotIndices[num5++]);
                 }
                 else
                 {
                     inventorySlotWidget.AssignInventorySlot(null, 0);
                 }
             }
         }
         m_assignedPageIndex = m_componentCreativeInventory.PageIndex;
     }
     m_creativeInventoryWidget.PageLabel.Text           = ((m_pagesCount > 0) ? $"{m_componentCreativeInventory.PageIndex + 1}/{m_pagesCount}" : string.Empty);
     m_creativeInventoryWidget.PageDownButton.IsEnabled = (m_componentCreativeInventory.PageIndex < m_pagesCount - 1);
     m_creativeInventoryWidget.PageUpButton.IsEnabled   = (m_componentCreativeInventory.PageIndex > 0);
 }