private void CreateControls()
        {
            Texture2D leftTexture  = Game.Content.Load <Texture2D>(@"GUI\leftarrowUp");
            Texture2D rightTexture = Game.Content.Load <Texture2D>(@"GUI\rightarrowUp");

            stopTexture = Game.Content.Load <Texture2D>(@"GUI\StopBar");

            backgroundImage = new PictureBox(
                Game.Content.Load <Texture2D>(@"Backgrounds\titlescreen"),
                GameRef.ScreenRectangle);
            ControlManager.Add(backgroundImage);

            Label label1 = new Label();

            label1.Text     = "Choose Your Ship";
            label1.Size     = label1.SpriteFont.MeasureString(label1.Text);
            label1.Position = new Vector2((GameRef.Window.ClientBounds.Width - label1.Size.X) / 2, 150);

            ControlManager.Add(label1);

            /*genderSelector = new LeftRightSelector(leftTexture, rightTexture, stopTexture);
             * genderSelector.SetItems(genderItems, 125);
             * genderSelector.Position = new Vector2(label1.Position.X, 200);
             * genderSelector.SelectionChanged += new EventHandler(selectionChanged);
             *
             * ControlManager.Add(genderSelector);*/

            shipSelector = new LeftRightSelector(leftTexture, rightTexture, stopTexture);
            shipSelector.SetItems(shipItems, 125);
            shipSelector.Position          = new Vector2(label1.Position.X, 250);
            shipSelector.SelectionChanged += selectionChanged;

            ControlManager.Add(shipSelector);

            LinkLabel linkLabel1 = new LinkLabel();

            linkLabel1.Text      = "Use this Ship.";
            linkLabel1.Position  = new Vector2(label1.Position.X, 300);
            linkLabel1.Selected += new EventHandler(linkLabel1_Selected);
            ship = shipSelector.getItem();
            //Debug.WriteLine("hgfhfdgdffgs "+ship);

            ControlManager.Add(linkLabel1);

            shipImage = new PictureBox(
                shipImages[0],
                new Rectangle(600, 200, 96, 96));
            ControlManager.Add(shipImage);

            ControlManager.NextControl();

            //Go Back button
            LinkLabel goBack = new LinkLabel();

            goBack.Text      = "Go Back";
            goBack.Position  = new Vector2(label1.Position.X, 450);
            goBack.Selected += new EventHandler(goBackButton);
            ControlManager.Add(goBack);
        }
        private void CreateControls()
        {
            Texture2D leftTexture  = Game.Content.Load <Texture2D>(@"GUI\leftarrowUp");
            Texture2D rightTexture = Game.Content.Load <Texture2D>(@"GUI\rightarrowUp");
            Texture2D stopTexture  = Game.Content.Load <Texture2D>(@"GUI\StopBar");

            backgroundImage = new PictureBox(
                Game.Content.Load <Texture2D>(@"Backgrounds\titlescreen"),
                GameRef.ScreenRectangle);

            ControlManager.Add(backgroundImage);

            Label label1 = new Label
            {
                Text = "Who will search for the Eyes of the Dragon?"
            };

            label1.Size     = label1.SpriteFont.MeasureString(label1.Text);
            label1.Position = new Vector2(
                (GameRef.Window.ClientBounds.Width - label1.Size.X) / 2, 150);

            ControlManager.Add(label1);

            nameSelector = new LeftRightSelector(leftTexture, rightTexture, stopTexture);
            nameSelector.SetItems(maleName, 125);
            nameSelector.Position = new Vector2(label1.Position.X, 200);

            genderSelector = new LeftRightSelector(leftTexture, rightTexture, stopTexture);
            genderSelector.SetItems(genderItems, 125);
            genderSelector.Position          = new Vector2(label1.Position.X, 250);
            genderSelector.SelectionChanged += GenderSelector_SelectionChanged;

            ControlManager.Add(genderSelector);

            classSelector = new LeftRightSelector(leftTexture, rightTexture, stopTexture);
            classSelector.SetItems(classItems, 125);
            classSelector.Position = new Vector2(label1.Position.X, 300);

            ControlManager.Add(classSelector);

            LinkLabel linkLabel1 = new LinkLabel
            {
                Text     = "Accept this character.",
                Position = new Vector2(label1.Position.X, 350)
            };

            linkLabel1.Selected += new EventHandler(LinkLabel1_Selected);

            ControlManager.Add(linkLabel1);
            ControlManager.NextControl();
        }
Example #3
0
        /* CreateControls() initializes every Control object required by the screen. */
        private void CreateControls()
        {
            /* First, the three textures to be used in the LeftRightSelector are loaded using Content.Load<T>(). */
            Texture2D leftTexture  = Game.Content.Load <Texture2D>(@"GUI/leftArrowUp");
            Texture2D rightTexture = Game.Content.Load <Texture2D>(@"GUI/rightArrowUp");
            Texture2D stopTexture  = Game.Content.Load <Texture2D>(@"GUI/stopBar");

            /* The background image is loaded in to a PictureBox object, with the screen rectangle as the destination rectangle.
             * The newly created control is added to the ControlManager (as all the other controls will be). */
            backgroundImage = new PictureBox(Game.Content.Load <Texture2D>(@"Backgrounds/startscreen"), GameRef.ScreenRectangle);
            ControlManager.Add(backgroundImage);

            /* The title label displays the text "Choose your character" on the screen.
             * A label's size is calculated using the SpriteFont.MeasureString() method.
             * Its position is centralized in the window by setting it to half the window width minus the text width. */
            Label title = new Label();

            title.Text     = "Choose your character";
            title.Size     = title.SpriteFont.MeasureString(title.Text);
            title.Position = new Vector2((GameRef.Window.ClientBounds.Width - title.Size.X) / 2, 50);
            ControlManager.Add(title);

            /* The characterSelector is the LeftRightSelector enabling a user to choose a character.
             * Its items are set to the characterItems array, with a maximum width of 125 pixels.
             * Its position is aligned with the title label but placed further down.
             * The selector's SelectionChanged event handler is set to call selectionChanged(). */
            characterSelector = new LeftRightSelector(leftTexture, rightTexture, stopTexture);
            characterSelector.SetItems(characterItems, 125);
            characterSelector.Position          = new Vector2(title.Position.X, 200);
            characterSelector.SelectionChanged += new EventHandler(selectionChanged);
            ControlManager.Add(characterSelector);

            /* This LinkLabel will allow the user to finalize their choice of character and proceed to the next screen.
             * Its text is "Confirm" and its position is aligned to the title, but further down the screen.
             * Its Selected event handler is set to call confirmCharacter_Selected(). */
            LinkLabel confirmCharacter = new LinkLabel();

            confirmCharacter.Text      = "Confirm";
            confirmCharacter.Position  = new Vector2(title.Position.X, 300);
            confirmCharacter.Selected += new EventHandler(confirmCharacter_Selected);
            ControlManager.Add(confirmCharacter);

            /* The characterImage PictureBox is initialized with the first character image.
             * The source rectangle is the entire image, and the destination rectangle is the same size on the screen. */
            characterImage = new PictureBox(characterImages[0], new Rectangle(0, 0, 140, 300), new Rectangle(400, 150, 140, 300));
            ControlManager.Add(characterImage);

            /* NextControl() is called on the ControlManager to make sure it has a valid Control selected. */
            ControlManager.NextControl();
        }
        protected override void LoadContent()
        {
            base.LoadContent();

            resolutions = new LeftRightSelector(
                content.Load <Texture2D>(@"GUI\g22987"),
                content.Load <Texture2D>(@"GUI\g21245"),
                null);

            resolutions.Position = new Vector2(100, 100);

            List <string> items = new List <string>();

            foreach (string s in Game1.Resolutions.Keys)
            {
                items.Add(s);
            }

            resolutions.SetItems(items.ToArray(), 400);

            apply = new Button(content.Load <Texture2D>(@"GUI\g9202"))
            {
                Text     = "Apply",
                Position = new Vector2(700, 100)
            };

            apply.Click += ApplyClick;

            back = new Button(content.Load <Texture2D>(@"GUI\g9202"))
            {
                Text     = "Back",
                Position = new Vector2(100, 300)
            };

            back.Click += BackClick;

            save = new Button(content.Load <Texture2D>(@"GUI\g9202"))
            {
                Text     = "Save",
                Position = new Vector2(100, 200)
            };

            save.Click += SaveClick;
        }
        private void CreateControls()
        {
            AddBackground("Backgrounds\\MainMenu");

            Label label = new Label("Select Character", new Vector2(StateManager.ScreenCentre.X, StateManager.ScreenCentre.Y / 2));

            ControlManager.Add(label);

            genderSelector = new LeftRightSelector(
                Content.Load <Texture2D>("GUI\\leftarrowUp"),
                Content.Load <Texture2D>("GUI\\rightarrowUp"),
                label.Position + new Vector2(0, StateManager.Viewport.Height / 6));
            genderSelector.SetItems(genderItems);
            genderSelector.SelectionChanged += selectionChanged;
            ControlManager.Add(genderSelector);

            classSelector = new LeftRightSelector(
                Content.Load <Texture2D>("GUI\\leftarrowUp"),
                Content.Load <Texture2D>("GUI\\rightarrowUp"),
                genderSelector.Position + new Vector2(0, StateManager.Viewport.Height / 6));
            classSelector.SetItems(classItems);
            classSelector.SelectionChanged += selectionChanged;
            ControlManager.Add(classSelector);

            LinkLabel acceptCharacter = new LinkLabel(
                "Accept this character.",
                classSelector.Position + new Vector2(0, StateManager.Viewport.Height / 6));

            acceptCharacter.Selected += new EventHandler(acceptCharacter_Selected);
            ControlManager.Add(acceptCharacter);

            characterImage = new PictureBox(
                characterImages[0, 0],
                new Vector2(StateManager.Viewport.Width * 0.75f, genderSelector.Position.Y),
                new Rectangle(0, 0, 32, 32));
            characterImage.Size = new Vector2(64, 64);
            ControlManager.Add(characterImage);

            ControlManager.NextControl();
        }
Example #6
0
        /* CreateControls() sets up most of what's visible on the screen. */
        private void CreateControls()
        {
            /* The two PictureBox objects are constructed with textures that are loaded in, then added to the ControlManager. */
            backgroundImage = new PictureBox(Game.Content.Load <Texture2D>(@"Backgrounds/startscreen"), GameRef.ScreenRectangle);
            ControlManager.Add(backgroundImage);
            starterImage = new PictureBox(starterImages[0], new Rectangle(0, 0, 240, 240), new Rectangle(350, 100, 240, 240));
            ControlManager.Add(starterImage);

            /* The title and confirm labels are created and set with the right text, position, and size.
             * The event handler is wired so that when the user chooses "Confirm", confirmStarter_Selected is called. */
            Label title = new Label();

            title.Text     = "Choose your starter";
            title.Size     = title.SpriteFont.MeasureString(title.Text);
            title.Position = new Vector2((GameRef.Window.ClientBounds.Width - title.Size.X) / 2, 50);
            ControlManager.Add(title);
            LinkLabel confirmStarter = new LinkLabel();

            confirmStarter.Text      = "Confirm";
            confirmStarter.Position  = new Vector2(title.Position.X, 300);
            confirmStarter.Selected += new EventHandler(confirmStarter_Selected);
            ControlManager.Add(confirmStarter);

            /* The three textures for the LeftRightSelector are loaded in using Content.Load<Texture2D>().
             * The LeftRightSelector is then initialised using the loaded textures.
             * Its items are set to the array of starter names, and the position is set correctly.
             * Its SelectionChanged is wired to the selectionChanged function, and then it's added to the ControlManager. */
            Texture2D leftTexture  = Game.Content.Load <Texture2D>(@"GUI/leftArrowUp");
            Texture2D rightTexture = Game.Content.Load <Texture2D>(@"GUI/rightArrowUp");
            Texture2D stopTexture  = Game.Content.Load <Texture2D>(@"GUI/stopBar");

            starterSelector = new LeftRightSelector(leftTexture, rightTexture, stopTexture);
            starterSelector.SetItems(starterItems, 175);
            starterSelector.Position          = new Vector2(title.Position.X - 100, 200);
            starterSelector.SelectionChanged += new EventHandler(selectionChanged);
            ControlManager.Add(starterSelector);

            /* NextControl() is called to make sure a valid control is selected when the screen is displayed. */
            ControlManager.NextControl();
        }
        private void CreateControls()
        {
            var leftTexture  = Game.Content.Load <Texture2D>(@"GUI\leftarrowUp");
            var rightTexture = Game.Content.Load <Texture2D>(@"GUI\rightarrowUp");
            var stopTexture  = Game.Content.Load <Texture2D>(@"GUI\StopBar");

            _backgroundImage = new PictureBox(
                Game.Content.Load <Texture2D>(@"Backgrounds\startScreen"),
                GameRef.ScreenRectangle);
            ControlManager.Add(_backgroundImage);

            var label1 = new Label {
                Text = "Who shall Thy be?"
            };

            label1.Size     = label1.SpriteFont.MeasureString(label1.Text);
            label1.Position = new Vector2((GameRef.Window.ClientBounds.Width - label1.Size.X) / 2, 150);
            ControlManager.Add(label1);

            _genderSelector = new LeftRightSelector(leftTexture, rightTexture, stopTexture);
            _genderSelector.SetItems(_genderItems, 125);
            _genderSelector.Position = new Vector2(label1.Position.X, 200);
            ControlManager.Add(_genderSelector);

            _classSelector = new LeftRightSelector(leftTexture, rightTexture, stopTexture);
            _classSelector.SetItems(_classItems, 125);
            _classSelector.Position = new Vector2(label1.Position.X, 250);
            ControlManager.Add(_classSelector);

            var linklabel1 = new LinkLabel {
                Text = "Accept", Position = new Vector2(label1.Position.X, 300)
            };

            linklabel1.Selected += linklabel1_Selected;
            ControlManager.Add(linklabel1);

            ControlManager.NextControl();
        }
Example #8
0
        /* The CreateControls() method for the InventoryScreen is quite long but doesn't require much explanation. */
        private void CreateControls()
        {
            /* The three textures for the LeftRightSelector are loaded in. */
            Texture2D leftTexture  = Game.Content.Load <Texture2D>(@"GUI/leftArrowUp");
            Texture2D rightTexture = Game.Content.Load <Texture2D>(@"GUI/rightArrowUp");
            Texture2D stopTexture  = Game.Content.Load <Texture2D>(@"GUI/stopBar");

            /* The background image is loaded in with Content.Load<T>() and given the window as the destination rectangle.
             * Every Control is added to the ControlManager. */
            backgroundImage = new PictureBox(Game.Content.Load <Texture2D>(@"Backgrounds/startscreen"), GameRef.ScreenRectangle);
            ControlManager.Add(backgroundImage);

            /* Each sprite's PictureBox is constructed using the sprites applying to the first Pokemon in the Player's inventory.
             * In the cases of the Pokemon sprite, the image is obtained by finding it (by its ID) in the DataManager's master list of Pokemon sprites.
             * The type and gender sprites are found by loading in the whole sprite sheet, and setting the source rectangle using the array of source rectangles.
             * The second type sprite is not always used, since Pokemon can be single or dual type.
             * If the first Pokemon in the Player's team is single type, the second type sprite is initialized with a source rectangle of size zero.
             * Effectively, this means nothing will be drawn to the screen for the second type. */
            pkmnSprite = new PictureBox(DataManager.PkmnFrontSprites[WorldScreen.Player.Team[0].PokemonID], new Rectangle(20, 100, 288, 288));
            ControlManager.Add(pkmnSprite);
            typeSprite = new PictureBox(typeSheet, typeRects[(int)WorldScreen.Player.Team[0].Type[0]], new Rectangle(50, 400, 105, 40));
            ControlManager.Add(typeSprite);
            if (WorldScreen.Player.Team[0].Type.Count > 1)
            {
                secondTypeSprite = new PictureBox(typeSheet, typeRects[(int)WorldScreen.Player.Team[0].Type[1]], new Rectangle(175, 400, 105, 40));
            }
            else
            {
                secondTypeSprite = new PictureBox(typeSheet, new Rectangle(), new Rectangle(175, 400, 105, 40));
            }
            ControlManager.Add(secondTypeSprite);
            genderSprite = new PictureBox(genderSheet, genderRects[(int)WorldScreen.Player.Team[0].PokemonGender], new Rectangle(300, 380, 64, 64));
            ControlManager.Add(genderSprite);

            /* The pokemonSelector is created by passing in the three textures loaded in earlier.
             * The items for the pokemonSelector are set to the pokemonNames array with a maximum width of 175.
             * Its SelectionChanged event handler is wired to call pokemonSelector_SelectionChanged(). */
            pokemonSelector = new LeftRightSelector(leftTexture, rightTexture, stopTexture);
            pokemonSelector.SetItems(pokemonNames, 175);
            pokemonSelector.Position          = new Vector2(300, 100);
            pokemonSelector.SelectionChanged += new EventHandler(pokemonSelector_SelectionChanged);
            ControlManager.Add(pokemonSelector);

            /* Each of the labels on the screen are constructed in the same way.
             * After initialization, the Text property is set using the properties of the current Pokemon.
             * Size is calculated using the SpriteFont.MeasureString() method.
             * Finally, the position is set to a Vector2. The last six labels (displaying level and stats) are aligned to x = 400. */
            name          = new Label();
            name.Text     = "Inventory";
            name.Size     = name.SpriteFont.MeasureString(name.Text);
            name.Position = new Vector2((GameRef.Window.ClientBounds.Width - name.Size.X) / 2, 50);
            ControlManager.Add(name);
            level          = new Label();
            level.Text     = "Lv " + WorldScreen.Player.Team[0].Level;
            level.Size     = level.SpriteFont.MeasureString(level.Text);
            level.Position = new Vector2(400, 150);
            ControlManager.Add(level);
            hp          = new Label();
            hp.Text     = "HP: " + WorldScreen.Player.Team[0].Health.CurrentValue + "/" + WorldScreen.Player.Team[0].Health.MaximumValue;
            hp.Size     = hp.SpriteFont.MeasureString(hp.Text);
            hp.Position = new Vector2(400, 250);
            ControlManager.Add(hp);
            atk          = new Label();
            atk.Text     = "ATK: " + WorldScreen.Player.Team[0].Attack;
            atk.Size     = atk.SpriteFont.MeasureString(atk.Text);
            atk.Position = new Vector2(400, 280);
            ControlManager.Add(atk);
            def          = new Label();
            def.Text     = "DEF: " + WorldScreen.Player.Team[0].Defence;
            def.Size     = def.SpriteFont.MeasureString(def.Text);
            def.Position = new Vector2(400, 310);
            ControlManager.Add(def);
            spatk          = new Label();
            spatk.Text     = "SP. ATK: " + WorldScreen.Player.Team[0].SpecialAttack;
            spatk.Size     = spatk.SpriteFont.MeasureString(spatk.Text);
            spatk.Position = new Vector2(400, 340);
            ControlManager.Add(spatk);
            spdef          = new Label();
            spdef.Text     = "SP. DEF: " + WorldScreen.Player.Team[0].SpecialDefence;
            spdef.Size     = spdef.SpriteFont.MeasureString(spdef.Text);
            spdef.Position = new Vector2(400, 370);
            ControlManager.Add(spdef);
            spd          = new Label();
            spd.Text     = "SPD: " + WorldScreen.Player.Team[0].Speed;
            spd.Size     = spd.SpriteFont.MeasureString(spd.Text);
            spd.Position = new Vector2(400, 400);
            ControlManager.Add(spd);
            xp          = new Label();
            xp.Text     = "XP: " + WorldScreen.Player.Team[0].XP + "/" + PkmnUtils.NextLevel(DataManager.PokemonSpecies[WorldScreen.Player.Team[0].PokemonID].GrowthRate, WorldScreen.Player.Team[0].Level);
            xp.Size     = xp.SpriteFont.MeasureString(xp.Text);
            xp.Position = new Vector2(200, 430);
            ControlManager.Add(xp);

            /* The saveLabel is constructed and set with its text, size, and position. It is set with the saveLabel_Selected() function as its Selected event. */
            saveLabel           = new LinkLabel();
            saveLabel.Text      = "Save";
            saveLabel.Size      = saveLabel.SpriteFont.MeasureString(saveLabel.Text);
            saveLabel.Position  = new Vector2(400, 430);
            saveLabel.Selected += new EventHandler(saveLabel_Selected);
            ControlManager.Add(saveLabel);

            /* ControlManager.NextControl() is called to have a control already selected when the user enters the screen. */
            ControlManager.NextControl();
        }
        private void CreateControls()
        {
            Texture2D leftTexture  = Game.Content.Load <Texture2D>(@"GUI\leftarrowUp");
            Texture2D rightTexture = Game.Content.Load <Texture2D>(@"GUI\rightarrowUp");

            stopTexture = Game.Content.Load <Texture2D>(@"GUI\StopBar");

            backgroundImage = new PictureBox(
                Game.Content.Load <Texture2D>(@"Backgrounds\titlescreen"),
                GameRef.ScreenRectangle);
            ControlManager.Add(backgroundImage);

            Label label1 = new Label();

            label1.Text     = "Choose Your Ship";
            label1.Size     = label1.SpriteFont.MeasureString(label1.Text);
            label1.Position = new Vector2((GameRef.Window.ClientBounds.Width - label1.Size.X) / 2, 150);

            ControlManager.Add(label1);

            /*genderSelector = new LeftRightSelector(leftTexture, rightTexture, stopTexture);
             * genderSelector.SetItems(genderItems, 125);
             * genderSelector.Position = new Vector2(label1.Position.X, 200);
             * genderSelector.SelectionChanged += new EventHandler(selectionChanged);
             *
             * ControlManager.Add(genderSelector);*/

            shipSelector = new LeftRightSelector(leftTexture, rightTexture, stopTexture);
            shipSelector.SetItems(shipItems, 125);
            shipSelector.Position          = new Vector2(label1.Position.X, 250);
            shipSelector.SelectionChanged += selectionChanged;

            ControlManager.Add(shipSelector);
            LinkLabel linkLabel1 = new LinkLabel();

            linkLabel1.Text     = "Use this Ship.";
            linkLabel1.Position = new Vector2(label1.Position.X, 300);

            /*LinkLabel linkLabel1 = new LinkLabel();
             * linkLabel1.Text = "Accept This Ship and Your Hero";
             * linkLabel1.Position = new Vector2(label1.Position.X-150, 500);
             *
             * linkLabel1.Selected += new EventHandler(linkLabel1_Selected);
             * //Debug.WriteLine("hgfhfdgdffgs "+ship);*/



            shipImage = new PictureBox(
                shipImages[0],
                new Rectangle(600, 200, 96, 96));
            ControlManager.Add(shipImage);

            ControlManager.NextControl();


            //Hero Selection
            Label selectYourHero = new Label();

            selectYourHero.Text     = "Please select Your Hero Name";
            selectYourHero.Position = new Vector2(label1.Position.X - 100, 350);
            ControlManager.Add(selectYourHero);

            ControlManager.NextControl();



            //heroes
            hero1          = new LinkLabel();
            hero1.Text     = "Sam";
            hero1.Position = new Vector2(label1.Position.X + 50, 400);
            ControlManager.Add(hero1);
            hero1Txt        = hero1.ToString();
            hero1.Selected += new EventHandler(hero1Selected);

            ControlManager.NextControl();

            hero2          = new LinkLabel();
            hero2.Text     = "Dan";
            hero2.Position = new Vector2(label1.Position.X + 50, 430);
            ControlManager.Add(hero2);
            hero2.Selected += new EventHandler(hero2Selected);

            ControlManager.NextControl();

            hero3          = new LinkLabel();
            hero3.Text     = "Truong";
            hero3.Position = new Vector2(label1.Position.X + 50, 460);
            ControlManager.Add(hero3);
            hero3.Selected += new EventHandler(hero3Selected);

            ControlManager.NextControl();

            hero4          = new LinkLabel();
            hero4.Text     = "Rfnker";
            hero4.Position = new Vector2(label1.Position.X + 50, 490);
            ControlManager.Add(hero4);
            hero4.Selected += new EventHandler(hero4Selected);

            ControlManager.NextControl();
            //

            //Go Back button
            LinkLabel goBack = new LinkLabel();

            goBack.Text      = "Go Back";
            goBack.Position  = new Vector2(label1.Position.X + 40, 550);
            goBack.Selected += new EventHandler(goBackButton);

            //ControlManager.Add(linkLabel1);
            ControlManager.Add(goBack);


            //Keyboard name handling
            name          = new Label();
            name.Position = new Vector2(xPos, yPos);
        }
Example #10
0
        private void CreateControls()
        {
            Texture2D leftTexture  = Game.Content.Load <Texture2D>(@"Graphics\GUI\leftarrowUp");
            Texture2D rightTexture = Game.Content.Load <Texture2D>(@"Graphics\GUI\rightarrowUp");
            Texture2D stopTexture  = Game.Content.Load <Texture2D>(@"Graphics\GUI\StopBar");

            Label label1 = new Label {
                text = Constants.WHO_WILL_FIGHT
            };

            label1.size     = label1.spriteFont.MeasureString(label1.text);
            label1.position = new Vector2((int)(Game1.systemOptions.resolutionWidth - label1.size.X) >> 1,
                                          Game1.systemOptions.resolutionHeight >> 1);

            selectGender = new LeftRightSelector(leftTexture, rightTexture, stopTexture);
            selectGender.SetItems(genderItems, 125);
            selectGender.position = new Vector2((Game1.systemOptions.resolutionWidth - 125 - 96) >> 1,
                                                label1.position.Y + 50);
            selectGender.selectionChanged += selectionChanged;

            selectClass = new LeftRightSelector(leftTexture, rightTexture, stopTexture);
            selectClass.SetItems(classItems, 125);
            selectClass.position = new Vector2((Game1.systemOptions.resolutionWidth - 125 - 96) >> 1,
                                               selectGender.position.Y + 50);
            selectClass.selectionChanged += selectionChanged;

            LinkLabel linkLabel1 = new LinkLabel {
                text = Constants.CREATE_LOBBY
            };

            linkLabel1.size     = linkLabel1.spriteFont.MeasureString(linkLabel1.text);
            linkLabel1.position = new Vector2((int)(Game1.systemOptions.resolutionWidth - linkLabel1.size.X) >> 1,
                                              selectClass.position.Y + 75);
            linkLabel1.selected += linkLabel1_Selected;

            LinkLabel joinLobby = new LinkLabel {
                text = Constants.JOIN_LOBBY
            };

            joinLobby.size     = linkLabel1.spriteFont.MeasureString(joinLobby.text);
            joinLobby.position = new Vector2((int)(Game1.systemOptions.resolutionWidth - joinLobby.size.X) >> 1,
                                             linkLabel1.position.Y + 50);
            joinLobby.selected += joinLobby_Selected;

            LinkLabel linkLabel2 = new LinkLabel {
                text = Constants.BACK
            };

            linkLabel2.size     = linkLabel2.spriteFont.MeasureString(linkLabel2.text);
            linkLabel2.position = new Vector2((int)(Game1.systemOptions.resolutionWidth - linkLabel2.size.X) >> 1,
                                              joinLobby.position.Y + 75);
            linkLabel2.selected += linkLabel2_Selected;

            characterImage = new PictureBox(characterImages[0, 0],
                                            new Rectangle(((Game1.systemOptions.resolutionWidth - 96) >> 1),
                                                          ((Game1.systemOptions.resolutionHeight + 120) >> 2), 96, 96), new Rectangle(0, 0, 32, 32));

            controlManager.Add(label1);
            controlManager.Add(selectGender);
            controlManager.Add(selectClass);
            controlManager.Add(linkLabel1);
            controlManager.Add(joinLobby);
            controlManager.Add(linkLabel2);
            controlManager.Add(characterImage);
            controlManager.NextControl();
        }
Example #11
0
        private void CreateControls()
        {
            Texture2D leftTexture  = Game.Content.Load <Texture2D>(@"Graphics\GUI\leftarrowUp");
            Texture2D rightTexture = Game.Content.Load <Texture2D>(@"Graphics\GUI\rightarrowUp");
            Texture2D stopTexture  = Game.Content.Load <Texture2D>(@"Graphics\GUI\StopBar");

            Label label1 = new Label {
                text = "Changes will take effect after restarting the game"
            };

            label1.size     = label1.spriteFont.MeasureString(label1.text);
            label1.position = new Vector2((int)(Game1.systemOptions.resolutionWidth - label1.size.X) >> 1, Game1.systemOptions.resolutionHeight >> 1);

            selectFullScreen = new LeftRightSelector(leftTexture, rightTexture, stopTexture);
            selectFullScreen.SetItems(fullScreenItems, 125);
            selectFullScreen.position      = new Vector2((Game1.systemOptions.resolutionWidth - 125 - 96) >> 1, label1.position.Y + 50);
            selectFullScreen.SelectedIndex = Game1.systemOptions.fullScreen ? 0 : 1;

            selectDifficulty = new LeftRightSelector(leftTexture, rightTexture, stopTexture);
            selectDifficulty.SetItems(difficultyItems, 125);
            selectDifficulty.position      = new Vector2((Game1.systemOptions.resolutionWidth - 125 - 96) >> 1, selectFullScreen.position.Y + 50);
            selectDifficulty.SelectedIndex = (int)Game1.systemOptions.difficultyLevel;

            selectSoundLevel = new LeftRightSelector(leftTexture, rightTexture, stopTexture);
            selectSoundLevel.SetItems(soundLevelItems, 125);
            selectSoundLevel.position      = new Vector2((Game1.systemOptions.resolutionWidth - 125 - 96) >> 1, selectDifficulty.position.Y + 50);
            selectSoundLevel.SelectedIndex = (int)Game1.systemOptions.soundLevel;

            selectMusicLevel = new LeftRightSelector(leftTexture, rightTexture, stopTexture);
            selectMusicLevel.SetItems(musicLevelItems, 125);
            selectMusicLevel.position      = new Vector2((Game1.systemOptions.resolutionWidth - 125 - 96) >> 1, selectSoundLevel.position.Y + 50);
            selectMusicLevel.SelectedIndex = (int)Game1.systemOptions.musicLevel;

            selectResolution = new LeftRightSelector(leftTexture, rightTexture, stopTexture);
            selectResolution.SetItems(resolutionItems, 125);
            selectResolution.position      = new Vector2((Game1.systemOptions.resolutionWidth - 125 - 96) >> 1, selectMusicLevel.position.Y + 50);
            selectResolution.SelectedIndex = Array.IndexOf(resolutionItems, Game1.systemOptions.resolutionWidth + "x" + Game1.systemOptions.resolutionHeight);

            LinkLabel linkLabel1 = new LinkLabel
            {
                text = Constants.ACCEPT_CHANGES
            };

            linkLabel1.size     = linkLabel1.spriteFont.MeasureString(linkLabel1.text);
            linkLabel1.position = new Vector2((int)(Game1.systemOptions.resolutionWidth - linkLabel1.size.X) >> 1,
                                              selectResolution.position.Y + 75);
            linkLabel1.selected += linkLabel1_Selected;

            LinkLabel linkLabel2 = new LinkLabel
            {
                text = Constants.DISMISS_CHANGES
            };

            linkLabel2.size     = linkLabel2.spriteFont.MeasureString(linkLabel2.text);
            linkLabel2.position = new Vector2((int)(Game1.systemOptions.resolutionWidth - linkLabel2.size.X) >> 1,
                                              linkLabel1.position.Y + 50);
            linkLabel2.selected += linkLabel2_Selected;

            controlManager.Add(label1);
            controlManager.Add(selectFullScreen);
            controlManager.Add(selectDifficulty);
            controlManager.Add(selectSoundLevel);
            controlManager.Add(selectMusicLevel);
            controlManager.Add(selectResolution);
            controlManager.Add(linkLabel1);
            controlManager.Add(linkLabel2);
            controlManager.NextControl();
        }