Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public MessagePanel(GameState state)
            : base(0, (int)Renderer.GetResoultion().Y - 200, (int)Renderer.GetResoultion().X - 400, 200, BarMode.Empty, state)
        {
            Instance   = this;
            _gameState = state;

            _textPanel = new ScrollPanel(0, 0, GetContentWidth(), GetContentHeight() - 50, BarMode.Empty, state);
            _textPanel.DisableHorizontalScroll();
            this.AddControl(_textPanel);

            _textLabel = new Label(0, 0, _textPanel.GetContentWidth(), 0, state);
            _textLabel.SetText("");
            _textPanel.AddControl(_textLabel);

            _messageField = new TextField(10, GetContentHeight() - 45, GetContentWidth() - 120, 40, state);
            this.AddControl(_messageField);

            _sendMessageButton            = new Button("Send", GetContentWidth() - 90, GetContentHeight() - 45, 80, 40, state);
            _sendMessageButton.OnTrigger += SendMessage;
            this.AddControl(_sendMessageButton);
        }
Esempio n. 3
0
        /// <summary>
        /// Constructs about window object.
        /// </summary>
        /// <param name="desktop">desktop it belongs to</param>
        public AboutWindow(Desktop desktop) : base(desktop, CreationFlag.FlagsNone, "")
        {
            this.Text          = "About...";
            this.Modal         = true;
            this.CenterDesktop = true;
            this.Sizeable      = false;
            this.HasShadow     = true;
            this.MinSize       = new Size2d(490, 390);
            this.Bounds        = new Rectangle((desktop.Width - this.MinSize.Width) / 2, (desktop.Height - this.MinSize.Height) / 2, this.MinSize.Width, this.MinSize.Height);

            Button closeButton = CreateControl <Button>();

            closeButton.Text         = "Ok";
            closeButton.Bounds       = new Rectangle(410, 342, 75, 23);
            closeButton.DialogResult = DialogResult.DialogResultOK;

            Picture picture = CreateControl <Picture>();

            picture.Bounds    = new Rectangle(3, 1, 155, 334);
            picture.BackImage = "ui/design/about";
            picture.Border    = BorderStyle.Flat;

            Label titleLabel = CreateControl <Label>();

            titleLabel.Text   = "ThW::UI";
            titleLabel.Bounds = new Rectangle(165, 5, 321, 16);

            Label VersionLabel = CreateControl <Label>();

            VersionLabel.Text   = "Version " + VersionInfo.Version;
            VersionLabel.Bounds = new Rectangle(165, 25, 321, 16);

            Label buildLabel = CreateControl <Label>();

            buildLabel.Text   = "Build " + VersionInfo.Build;
            buildLabel.Bounds = new Rectangle(165, 45, 321, 16);

            Label urlLabel = CreateControl <Label>();

            urlLabel.Text      = VersionInfo.Url;
            urlLabel.Bounds    = new Rectangle(165, 65, 321, 16);
            urlLabel.TextColor = Colors.Blue;

            ScrollPanel scrollPanel = CreateControl <ScrollPanel>();

            scrollPanel.Bounds = new Rectangle(165, 88, 320, 247);
            scrollPanel.Border = BorderStyle.Lowered;

            TextBox licenseTextBox = CreateControl <TextBox>();

            licenseTextBox.Bounds    = new Rectangle(3, 3, 10, 10);
            licenseTextBox.Border    = BorderStyle.None;
            licenseTextBox.BackColor = Colors.None;
            licenseTextBox.AutoSize  = true;
            licenseTextBox.MultiLine = true;
            scrollPanel.AddControl(licenseTextBox);

            byte[] fileBytes  = null;
            uint   fileSize   = 0;
            Object fileHandle = null;

            this.Engine.OpenFile("ui/design/eula-utf8.txt", out fileBytes, out fileSize, out fileHandle);

            if ((null != fileHandle) && (null != fileBytes) && (fileBytes.Length > 0))
            {
                licenseTextBox.Text = UTF8Encoding.UTF8.GetString(fileBytes, 0, fileBytes.Length);

                this.Engine.CloseFile(ref fileHandle);
            }

            AddControl(titleLabel);
            AddControl(VersionLabel);
            AddControl(buildLabel);
            AddControl(urlLabel);
            AddControl(scrollPanel);
            AddControl(closeButton);
            AddControl(picture);
        }
Esempio n. 4
0
        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);
        }