private void CreatePartAssembler() { // Create the input slot and add a callback when the item changes _inputSlot = new ItemSlotWrapper { Top = new StyleDimension(50, 0), HAlign = 0.5f }; _inputSlot.OnItemChanged += OnInputChanged; _tabPanel.Append(_inputSlot); // Create the "Create" button and add a callback when it is clicked _createBtn = new UITextPanel <string>("Create!") { HAlign = 0.5f, Top = new StyleDimension(5, 0), VAlign = 0.5f }; _createBtn.OnClick += OnCreateClicked; _tabPanel.Append(_createBtn); // Create the output slot, and make it not possible to insert into it _outputSlot = new ItemSlotWrapper(canInsert: false) { Top = new StyleDimension(160, 0), HAlign = 0.5f }; _tabPanel.Append(_outputSlot); }
public override void OnInitialize() { _tabPanel = new TabPanel(500, 250, new Tab("Material Info", this), new Tab("Part Assembler", new PartAssemblerState()), new Tab("Tool Assembler", new ToolAssemblerState())); _tabPanel.Left.Set(DraggableUIPanel.lastPos.X, 0); _tabPanel.Top.Set(DraggableUIPanel.lastPos.Y, 0); _tabPanel.OnCloseBtnClicked += () => TerrarianWeaponry.Instance.UpdateState(null); _materialSlot = new ItemSlotWrapper { VAlign = 0.5f, Left = new StyleDimension(90, 0) }; _materialSlot.OnItemChanged += OnItemChanged; _tabPanel.Append(_materialSlot); #region Create Material Info Panel _infoPanel = new UIPanel { Left = new StyleDimension(230, 0), Width = new StyleDimension(255, 0), Top = new StyleDimension(40, 0), Height = new StyleDimension(195, 0) }; _infoPanel.SetPadding(0); _tabPanel.Append(_infoPanel); // Create a list _infoList = new UIList { Width = new StyleDimension(235, 0), Height = new StyleDimension(0, 1), Left = new StyleDimension(5, 0), Top = new StyleDimension(5, 0) }; _infoPanel.Append(_infoList); // And add a scrollbar UIScrollbar infoScrollbar = new UIScrollbar { Height = new StyleDimension(185, 0), Top = new StyleDimension(5, 0), Width = new StyleDimension(20, 0), Left = new StyleDimension(235, 0) }.WithView(50, 250); _infoPanel.Append(infoScrollbar); _infoList.SetScrollbar(infoScrollbar); #endregion Append(_tabPanel); }
private void DeactivateSlot(ItemSlotWrapper slot) { // If the material slot has no item, return if (slot.Item.IsAir) { return; } // Return the item to the player when the UI is closed/changed Main.LocalPlayer.QuickSpawnClonedItem(slot.Item, slot.Item.stack); slot.Item.TurnToAir(); }