public WorkbenchPanel(GameState state, int workbenchID) : base(((int)MessagePanel.Instance.GetBodySize().X / 2) - 300, ((int)Renderer.GetResoultion().Y / 2) - 325, 600, 400, BarMode.Close, state) { if (Instance != null) { Instance.Close(); } Instance = this; _gameState = state; _workbenchID = workbenchID; this.SetPanelLabel(CraftableData.GetWorkbench(workbenchID)); _craftableIDs = new List <int>(); for (int i = 0; i < CraftableData.GetCraftableDataCount(); i++) { if (CraftableData.GetCraftableData(i).WorkbenchID == workbenchID) { _craftableIDs.Add(i); } } _craftingSelectionPanel = new ScrollPanel(0, 0, GetContentWidth() / 2, GetContentHeight(), BarMode.Empty, state); _craftingInfoPanel = new ScrollPanel(GetContentWidth() / 2, 0, GetContentWidth() / 2, GetContentHeight(), BarMode.Empty, state); _craftingSelectionPanel.OnTrigger += SelectCraftable; _craftingSelectionPanel.OnRenderContent += RenderCraftables; _craftingInfoPanel.OnRenderContent += RenderCraftableInfo; _craftingSelectionPanel.DisableHorizontalScroll(); _craftingInfoPanel.DisableHorizontalScroll(); _countControl = new NumberControl(10, 10, state); _countControl.SetMinimum(1); _craftButton = new Button("Craft", 20 + (int)_countControl.GetBodySize().X, 10, _craftingInfoPanel.GetContentWidth() - 30 - (int)_countControl.GetBodySize().X, 40, state); _craftButton.OnTrigger += CraftTrigger; _craftingInfoPanel.AddControl(_countControl); _craftingInfoPanel.AddControl(_craftButton); this.AddControl(_craftingSelectionPanel); this.AddControl(_craftingInfoPanel); int slotSize = _craftingSelectionPanel.GetContentWidth() / 5; int rows = (int)Math.Ceiling(_craftableIDs.Count / 5f); _craftingSelectionPanel.SetScrollableHeight(slotSize * rows); }
public TestState() : base() { //* ScrollPanel scrollPanel = new ScrollPanel(10, 400, 400, 400, Panel.BarMode.Close_Drag, this); scrollPanel.SetScrollDimensions(1000, 1000); TextBox textBox = new TextBox(10, 10, 290, 310, this); scrollPanel.AddControl(textBox); Button button = new Button("Button", 420, 10, 80, 32, this); button.OnTrigger += ButtonPress; scrollPanel.AddControl(button); TextField textField = new TextField(420, 52, 100, 32, this); scrollPanel.AddControl(textField); NumberControl numberControl = new NumberControl(420, 94, this); numberControl.SetMinimum(10); numberControl.SetMaximum(20); scrollPanel.AddControl(numberControl); RadioButton radioButton = new RadioButton(520, 100, this); scrollPanel.AddControl(radioButton); string[] items = new string[] { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6", "Item 7", "Item 8", "Item 9", "Item 10", "Item 11" }; DropDownBox dropDownBox = new DropDownBox(420, 146, 120, items, this); scrollPanel.AddControl(dropDownBox); string[] menuOptions = new string[] { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6", "Item 7", "Item 8", "Item 9", "Item 10" }; DropDownMenu dropDownMenu = new DropDownMenu(560, 146, 120, "Test Menu", menuOptions, this); scrollPanel.AddControl(dropDownMenu); ListBox listBox = new ListBox(310, 10, 100, 200, 10, this); scrollPanel.AddControl(listBox); string[] radioItems = new string[] { "option 1", "option 2", "option 3" }; RadioControl radioControl = new RadioControl(550, 10, radioItems, this); scrollPanel.AddControl(radioControl); Label label = new Label(550, 80, 100, 60, this); label.SetText("A label." + '\n' + "Line 2."); scrollPanel.AddControl(label); this.AddControl(scrollPanel); string message = ""; for (int i = 0; i < 20; i++) { message += "this is a message box" + '\n'; } MessageBox messageBox = new MessageBox(message, this); this.AddControl(messageBox); Entity entity = Entity.CreateInstance(this.EntityManager, Vector3.Zero); this.EntityManager.AddEntity(entity); Entity entity2 = Entity.CreateInstance(this.EntityManager, new Vector3(400, 600, 0)); spriteComponent = new SpriteComponent(entity2); spriteComponent.SetXFrames(3); spriteComponent.Transform.Parent = entity.GetTransform(); //spriteComponent.SetTexture(Assets.GetTexture("sprite.png")); //spriteComponent.SetSpriteCenter(SpriteComponent.SpriteCenter.Top); //*/ Entity particleEntity = Entity.CreateInstance(this.EntityManager, new Vector3(400, 400, 0)); ParticleEmitterData particleData = new ParticleEmitterData(); particleData.EmitterShape = PaticleEmitterShape.Rectangle; particleData.ParticleTexture = "smoke.png"; particleData.EmissionRate = 1000; particleData.AngleMin = 0; particleData.AngleMax = 360; particleData.OffsetMin = 10; particleData.OffsetMax = 120; particleData.StartVelocity = 10; particleData.EndVelocity = 100; particleData.StartScale = 3; particleData.EndScale = 50; particleData.RotationSpeed = 45f; particleData.StartColour = Color4.White; particleData.EndColour = Color4.Transparent; //particleData.EndColour.A = 0f; particleData.MaxLife = 5; new ParticleEmitterComponent(particleEntity, particleData); this.EntityManager.AddEntity(particleEntity); }