Пример #1
0
        public JoinNetworkGameScreen(Game game, SpriteBatch spriteBatch, SpriteFont spriteFont, Texture2D background)
            : base(game, spriteBatch)
        {
            this.background = background;
            formBackground = game.Content.Load<Texture2D>("alienmetal");
            Vector2 formSize = new Vector2(350, 350);
            Vector2 center = new Vector2((this.windowSize.Width - formSize.X) / 2, (this.windowSize.Height - formSize.Y) / 2);
            connectionMethodForm = new Form("Connect", "Connection Metod", new Rectangle((int)center.X, (int)center.Y,(int) formSize.X, (int)formSize.Y), formBackground, spriteFont, Color.White);

            buttonTexture = game.Content.Load<Texture2D>("buttonTexture");
            textboxTexture = game.Content.Load<Texture2D>("textboxTexture");

            //figure out the width and heigh of the text on the buttons
            Vector2 lanButtonSize, connectButtonSize;
            lanButtonSize = spriteFont.MeasureString("Scan Lan");
            connectButtonSize = spriteFont.MeasureString("Connect");
            lanButton = new Button("ScanLan", "Scan LAN", new Rectangle(32,30,(int)lanButtonSize.X + 10, (int)lanButtonSize.Y + 10), buttonTexture, spriteFont, Color.White);
            sendButton = new Button("Connect", "Connect", new Rectangle(32,151,(int)connectButtonSize.X + 10, (int)connectButtonSize.Y + 10), buttonTexture, spriteFont, Color.White);
            backButton = new Button("BackButton", @"Back", new Rectangle(32, 192, 95, 23), buttonTexture, spriteFont, Color.White);
            textBoxIP = new TextBox("Address", "",100,new Rectangle(32,110,232,20), textboxTexture, spriteFont, Color.Black);
            textBoxPort = new TextBox("Port", "", 8, new Rectangle(288,110,60,20), textboxTexture, spriteFont, Color.Black);

            connectionMethodForm.AddControl(lanButton);
            connectionMethodForm.AddControl(sendButton);
            connectionMethodForm.AddControl(backButton);
            connectionMethodForm.AddControl(textBoxIP);
            connectionMethodForm.AddControl(textBoxPort);

            lanButton.onClick += new EHandler(ButtonClick);
            sendButton.onClick += new EHandler(ButtonClick);
            backButton.onClick += new EHandler(ButtonClick);

            imageRectangle = new Rectangle(0, 0, Game.Window.ClientBounds.Width, Game.Window.ClientBounds.Height);
        }
Пример #2
0
        /// <summary>
        /// Creates a new DomainLeftRight
        /// </summary>
        /// <param name="name"></param>
        /// <param name="PositionWidthHeight">A rectangle that specifies the position, width , height relative to the control parent</param>
        /// <param name="texture">Texture for the TextBox in the middle</param>
        /// <param name="leftBtnTex">Texture for the left button</param>
        /// <param name="rightBtnTex">Texture for the right button</param>
        /// <param name="font">Font used for displaying text, pass null if there's no text</param>
        /// <param name="foreColor">Color of the displayed text</param>
        /// <param name="viewport">Optional : Viewport used to render the gui, if your game contains only one viewport pass null or don't pass anything at all.</param>
        public DomainLeftRight(String name, Rectangle PositionWidthHeight, Texture2D texture, Texture2D leftBtnTex, Texture2D rightBtnTex, SpriteFont font, Color foreColor, Viewport? viewport = null)
            : base(name, "" ,PositionWidthHeight, texture, font, foreColor, viewport)
        {
            btnLeft = new Button("btnLeft", "", new Rectangle(0, 0, 10, positionWidthHeight.Height), leftBtnTex, font, foreColor, viewport);
            btnRight = new Button("btnRight", "", new Rectangle(positionWidthHeight.Width - 10, 0, 10, positionWidthHeight.Height), rightBtnTex, font, foreColor, viewport);
            txtText = new TextBox("txtText", "", 0, new Rectangle(10, 0, positionWidthHeight.Width - 20, positionWidthHeight.Height), null, font, foreColor, viewport);
            txtText.ReadOnly = true;

            this.AddControl(btnLeft);
            this.AddControl(btnRight);
            this.AddControl(txtText);

            btnLeft.onClick += new EHandler(BtnLeft_Click);
            btnRight.onClick += new EHandler(BtnRight_Click);

            # region Child event should trigger parent event

            btnLeft.onClick += new EHandler(ChildClicked);
            btnRight.onClick += new EHandler(ChildClicked);
            txtText.onClick += new EHandler(ChildClicked);

            btnLeft.onMouseDown += new EHandler(ChildMouseDown);
            btnRight.onMouseDown += new EHandler(ChildMouseDown);
            txtText.onMouseDown += new EHandler(ChildMouseDown);

            btnLeft.onMouseMove+= new EHandler(ChildMouseMove);
            btnRight.onMouseMove += new EHandler(ChildMouseMove);
            txtText.onMouseMove += new EHandler(ChildMouseMove);

            #endregion
        }
Пример #3
0
        public HostNetworkGameScreen(Game game, SpriteBatch spriteBatch, SpriteFont spriteFont, Texture2D background)
            : base(game, spriteBatch)
        {
            this.background = background;
            formBackground = game.Content.Load<Texture2D>("alienmetal");
            buttonTexture = game.Content.Load<Texture2D>("buttonTexture");
            textboxTexture = game.Content.Load<Texture2D>("textboxTexture");

            //center the form ont he screen
            Rectangle center = this.CenterGUIForm(242, 224);
            hostGameForm = new Form("Host", "Host a Game", new Rectangle(center.X, center.Y, center.Width, center.Height), formBackground, spriteFont, Color.White);

            //figure out the width and heigh of the text on the buttons
            Vector2 startButtonSize, backButtonSize;
            startButtonSize = spriteFont.MeasureString("Start Game");
            backButtonSize = spriteFont.MeasureString("Back");

            startButton = new Button("Start", "Start Game", new Rectangle(6, 186, (int)startButtonSize.X + 10, (int)startButtonSize.Y + 10), buttonTexture, spriteFont, Color.White);
            backButton = new Button("BackButton", @"Back", new Rectangle(132, 186,  (int)startButtonSize.X + 10, (int)startButtonSize.Y + 10), buttonTexture, spriteFont, Color.White);

            textBoxMaxConnections = new TextBox("MaxConnections", "10", 100, new Rectangle(11, 42, 60, 20), textboxTexture, spriteFont, Color.Black);
            maxConnectionsLabel = new Label("maxConnectionsLabel", @"Max Connections", new Vector2(8, 26), spriteFont, Color.White, 0, 0);

            textBoxPort = new TextBox("Port", "14242", 8, new Rectangle(11, 116, 60, 20), textboxTexture, spriteFont, Color.Black);
            portLabel = new Label("portLabel", @"Port", new Vector2(8, 91), spriteFont, Color.White, 0, 0);

            hostGameForm.AddControl(startButton);
            hostGameForm.AddControl(backButton);
            hostGameForm.AddControl(textBoxMaxConnections);
            hostGameForm.AddControl(maxConnectionsLabel);
            hostGameForm.AddControl(textBoxPort);
            hostGameForm.AddControl(portLabel);

            startButton.onClick += new EHandler(ButtonClick);
            backButton.onClick += new EHandler(ButtonClick);

            imageRectangle = new Rectangle(0, 0, Game.Window.ClientBounds.Width, Game.Window.ClientBounds.Height);
        }
Пример #4
0
        protected override void LoadContent()
        {
            base.LoadContent();
            Texture2D txtButton = game.Content.Load<Texture2D>(@"GUI\texButton");
            Texture2D txtTextBox = game.Content.Load<Texture2D>(@"GUI\texTextBox");
            Texture2D txtForm = game.Content.Load<Texture2D>(@"GUI\texForm");
            lvlLoadForm = new Form("LoadForm", "levels: 0 - 20 ",
                new Rectangle((Game.Window.ClientBounds.Width / 2 - 75), (Game.Window.ClientBounds.Height / 2 - 45),
                    150, 90), txtForm, spriteFont, Color.Black);
            txtLevelSelect = new TextBox("level", " ", 2, "0123456789-.", new Rectangle(10, 10, 50, 30), txtTextBox, spriteFont, Color.Black);
            exitButton = new Button("Exit", "Exit", new Rectangle(75,60,60,20), txtButton, spriteFont, Color.Black);
            loadButton = new Button("Load", "Load", new Rectangle(10, 60, 60, 20), txtButton, spriteFont, Color.Black);

            lvlLoadForm.AddControl(txtLevelSelect);
            lvlLoadForm.AddControl(exitButton);
            lvlLoadForm.AddControl(loadButton);

            loadButton.onClick += new EHandler(LoadButtonClicked);
        }
Пример #5
0
        public void AddTextBox(String textBoxName = "txt", String value = "", String PanelName = "MainPanel",
            int maxLength = 5, int width = 70, int height = 20)
        {
            if (PanelName == "MainPanel")
            {
                TextBox myText = new TextBox(textBoxName, value, maxLength,
                new Rectangle((int)_TexBoxPosition.X, (int)_TexBoxPosition.Y, width, height),
                TextBoxTexture, Font, Color.Black);
                TextBoxes.Add(myText);
                Frm.AddControl(myText);
                TextBoxes.Last<TextBox>().onChange += new EHandler(Changed);
                TextBoxes.Last<TextBox>().onMouseDown += new EHandler(MouseDown);
            }
            else
            {
                AddTextBox(textBoxName, value, PanelName, maxLength, _TexBoxPosition, width, height);
            }

            _TexBoxPosition.Y += 25;
        }
Пример #6
0
 public void AddTextBox(String textBoxName, String value, String PanelName,
     int maxLength, Vector2 position, int width, int height)
 {
     TextBox myTextBox = new TextBox(textBoxName, value, maxLength,
         new Rectangle((int)position.X, (int)position.Y, width, height),
         TextBoxTexture, Font, Color.Black);
     TextBoxes.Add(myTextBox);
     if (PanelName == "MainPanel")
         Frm.AddControl(myTextBox);
     {
         Form myFrm = null;
         Panels.TryGetValue(PanelName, out myFrm);
         if (myFrm != null)
         {
             myFrm.AddControl(myTextBox);
         }
     }
     TextBoxes.Last<TextBox>().onChange += new EHandler(Changed);
     TextBoxes.Last<TextBox>().onMouseDown += new EHandler(MouseDown);
 }
Пример #7
0
 public void AddTextBox(String textBoxName = "txt", String value = "", String PanelName = "MainPanel",
     int maxLength = 5, int width = 70, int height = 20)
 {
     //Frm.AddControl(TextBoxes.Last<TextBox>());
     if (PanelName == "MainPanel")
     {
         TextBox myText = new TextBox(textBoxName, value, maxLength,
         new Rectangle(_TexBoxPosition.X, _TexBoxPosition.Y, width, height),
         TextBoxTexture, Font, Color.Black);
         TextBoxes.Add(myText);
         Frm.AddControl(myText);
     }
     else
     {
         AddTextBox(textBoxName, value, PanelName, maxLength, _TexBoxPosition, width, height);
     }
     _TexBoxPosition.Y += 25;
 }
Пример #8
0
 public void AddTextBox(String textBoxName, String value, String PanelName,
     int maxLength, Point position, int width, int height)
 {
     TextBox myTextBox = new TextBox(textBoxName, value, maxLength,
         new Rectangle(position.X, position.Y, width, height),
         TextBoxTexture, Font, Color.Black);
     TextBoxes.Add(myTextBox);
     //Frm.AddControl(TextBoxes.Last<TextBox>());
     Form myFrm = null;
     Panels.TryGetValue(PanelName, out myFrm);
     if (myFrm != null)
     {
         myFrm.AddControl(myTextBox);
     }
 }