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);
        }
Esempio n. 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
        }
        public NetworkGameSelectScreen(Game game, SpriteBatch spriteBatch, SpriteFont spriteFont, Texture2D backgorund)
            : base(game, spriteBatch)
        {
            Vector2 formSize = new Vector2(150, 200);
            Vector2 center = new Vector2((this.windowSize.Width - formSize.X) / 2, (this.windowSize.Height - formSize.Y) / 2);
            formBackground = game.Content.Load<Texture2D>("alienmetal");
            buttonTexture = game.Content.Load<Texture2D>("buttonTexture");

            networkGameTypeSelectForm = new Form("GameTypeMenu", "Network Game", new Rectangle((int)center.X, (int)center.Y, (int)formSize.X, (int)formSize.Y), formBackground, spriteFont, Color.White);
            backButton = new Button("BackButton", @"Back", new Rectangle(27, 132, 95, 23), buttonTexture, spriteFont, Color.White);
            joinGameButton = new Button("JoinGame", @"Join Game", new Rectangle(27, 90, 95, 23), buttonTexture, spriteFont, Color.White);
            hostGameButton = new Button("HostGame", @"Host Game", new Rectangle(27, 42, 95, 23), buttonTexture, spriteFont, Color.White);

            networkGameTypeSelectForm.AddControl(hostGameButton);
            networkGameTypeSelectForm.AddControl(joinGameButton);
            networkGameTypeSelectForm.AddControl(backButton);

            hostGameButton.onClick  += new EHandler(ButtonClick);
            joinGameButton.onClick  += new EHandler(ButtonClick);
            backButton.onClick      += new EHandler(ButtonClick);
        }
        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);
        }
Esempio n. 5
0
        public StartScreen(Game game, SpriteBatch spriteBatch, SpriteFont spriteFont)
            : base(game, spriteBatch)
        {
            //screenSize = game.GraphicsDevice.Viewport.Bounds;
            //TAKE THE WIDTH AND HEIGHT MINUS THE MAIN FORM WIDTH AND HEIGHT DIVEDED BY 2 TO GET CENTER ON X AND Y
            Vector2 formSize = new Vector2(150, 200);
            Vector2 center = new Vector2((this.windowSize.Width - formSize.X) / 2, (this.windowSize.Height - formSize.Y) / 2);

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

            mainMenuForm = new Form("MainMenu", "Main Menu", new Rectangle((int)center.X, (int)center.Y, (int)formSize.X, (int)formSize.Y), formBackground, spriteFont, Color.White);
            quitGameButton = new Button("QuitGame", @"Quit Game", new Rectangle(27, 132, 95, 23), buttonTexture, spriteFont, Color.White);
            networkGameButton = new Button("NetworkGame", @"Network Game",new Rectangle(27, 90, 95, 23), buttonTexture, spriteFont, Color.White);
            startGameButton = new Button("StartGame", @"Start Game", new Rectangle(27, 42, 95, 23), buttonTexture, spriteFont, Color.White);

            mainMenuForm.AddControl(startGameButton);
            mainMenuForm.AddControl(networkGameButton);
            mainMenuForm.AddControl(quitGameButton);

            startGameButton.onClick += new EHandler(ButtonClick);
            networkGameButton.onClick += new EHandler(ButtonClick);
            quitGameButton.onClick += new EHandler(ButtonClick);
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
 public void AddButton(String buttonName = "Btn", String buttonText = "Button",
     String PanelName = "MainPanel", int width = 70, int height = 20)
 {
     if (PanelName == "MainPanel")
     {
         Button myButton = new Button(buttonName, buttonText,
         new Rectangle((int)_ButtonPosition.X, (int)_ButtonPosition.Y, width, height),
         ButtonTexture, Font, Color.Black);
         Buttons.Add(myButton);
         Frm.AddControl(myButton);
         if (buttonName.Contains("Spring"))
             myButton.onClick += new EHandler(SpringClicked);
     }
     else
     {
         AddButton(buttonName, buttonText, PanelName, _ButtonPosition, width, height);
     }
     _ButtonPosition.Y += 25;
 }
Esempio n. 8
0
 public void AddButton(String buttonName, String buttonText, String panelName,
     Vector2 position, int width, int height)
 {
     Button myButton = new Button(buttonName, buttonText,
         new Rectangle((int)position.X, (int)position.Y, width, height), ButtonTexture, Font, Color.Black);
     Buttons.Add(myButton);
     if (panelName == "MainPanel")
         Frm.AddControl(myButton);
     else
     {
         Form myFrm = null;
         Panels.TryGetValue(panelName, out myFrm);
         if (myFrm != null)
         {
             myFrm.AddControl(myButton);
         }
     }
     if (buttonName.Contains("String"))
         myButton.onClick += new EHandler(SpringClicked);
 }