Example #1
0
        /// <summary>
        /// ListView class constructor.
        /// </summary>
        /// <param name="elements">The number of visible elements in ListView.</param>
        /// <param name="position">The top-left corner of the ListView.</param>
        /// <param name="width">The ListView's width.</param>
        /// <param name="height">The ListView's height.</param>
        /// <param name="screen">Reference to the screen on which the ListView exists.</param>
        public ListView(int elements, Point position, int width, int height, GameScreen screen)
            : base(position, width, height, screen)
        {
            // up button initialization
            up = new Button(new Point(base.Position.X + 10 + base.width, position.Y), 50, 50, base.screen);

            this.elements = elements;

            //listview button height
            int buttonHeight = base.height / elements;

            //down button initialization
            down = new Button(new Point(base.Position.X + 10 + base.width, position.Y + buttonHeight * (elements - 1)), 50, 50, base.screen);

            //arrow button callbacks
            up.RegisterCallback(Up_OnClick);
            down.RegisterCallback(Down_OnClick);

            //minimum threshold check for listview buttons height
            if (buttonHeight < 21)
            {
                buttonHeight = 21;
            }

            //initialize listview buttons
            for (int i = 0; i < elements; i++)
            {
                Buttons.Add(new Button(new Point(base.position.X, base.position.Y + (i * buttonHeight)), base.width, buttonHeight, base.screen));
            }
        }
Example #2
0
        /// <summary>
        /// ListView class constructor.
        /// </summary>
        /// <param name="position">The top-left corner of the Selector.</param>
        /// <param name="width">The Selector's width.</param>
        /// <param name="height">The Selector's height.</param>
        /// <param name="screen">Reference to the screen on which the Selector exists.</param>
        public Selector(Point position, int width, int height, GameScreen screen)
            : base(position, width, height, screen)
        {
            // left button initialization
            left = new Button(new Point(base.Position.X - 50, position.Y + (height/2) - 25), 50, 50, base.screen);

            //right button initialization
            right = new Button(new Point(base.Position.X + width, position.Y + (height / 2) - 25), 50, 50, base.screen);

            //arrow button callbacks
            left.RegisterCallback(Left_OnClick);
            right.RegisterCallback(Right_OnClick);
        }
Example #3
0
        public override void Activate( bool instancePreserved )
        {
            if ( !instancePreserved )
            {
                ContentManager content = ScreenManager.Game.Content;

                titleFont = content.Load<SpriteFont>( "Fonts/PageTitle" );
                labelFont = content.Load<SpriteFont>( "Fonts/GUIFontBold" );

                // Set up the Buttons
                Texture2D buttonTex = content.Load<Texture2D>( "UITextures/GUIButton" );
                SpriteFont buttonFont = content.Load<SpriteFont>( "Fonts/GUIFont" );

                // Back Button
                backButton = new Button( BACK_BUTTON_POS, BACK_BUTTON_WIDTH, BACK_BUTTON_HEIGHT, this );
                backButton.Texture = buttonTex;
                backButton.SetFont( buttonFont,
                    BTNTEXT_INERT_COLOUR,
                    BTNTEXT_HOVER_COLOUR,
                    BTNTEXT_PRIMED_COLOUR,
                    BTNTEXT_INACTIVE_COLOUR );
                backButton.Text = "Back";
                backButton.RegisterCallback( backButton_OnClick );

                // Music Selector
                musicSel = new Selector( MUSIC_SEL_POS, MUSIC_SEL_WIDTH, MUSIC_SEL_HEIGHT, this );
                musicSel.ArrowTexture = content.Load<Texture2D>( "UITextures/ArrowLeft" );
                musicSel.Font = labelFont;
                musicSel.AddElement( "On" );
                musicSel.AddElement( "Off" );
                musicSel.TextColour = Color.White;
                if ( MediaPlayer.IsMuted )
                {
                    musicSel.SelectedIndex = 1;
                }
                musicSel.RegisterCallback( musicSel_OnSelectionChanged );
            }
        }
Example #4
0
        public override void Activate( bool instancePreserved )
        {
            if ( !instancePreserved )
            {
                ContentManager content = ScreenManager.Game.Content;

                titleFont = content.Load<SpriteFont>( "Fonts/PageTitle" );
                labelFont = content.Load<SpriteFont>( "Fonts/GUIFontBold" );

                // Set up the Buttons
                Texture2D buttonTex = content.Load<Texture2D>( "UITextures/GUIButton" );
                SpriteFont buttonFont = content.Load<SpriteFont>( "Fonts/GUIFont" );

                // Back Button
                backButton = new Button( BACK_BUTTON_POS, BACK_BUTTON_WIDTH, BACK_BUTTON_HEIGHT, this );
                backButton.Texture = buttonTex;
                backButton.SetFont( buttonFont,
                    BTNTEXT_INERT_COLOUR,
                    BTNTEXT_HOVER_COLOUR,
                    BTNTEXT_PRIMED_COLOUR,
                    BTNTEXT_INACTIVE_COLOUR );
                backButton.Text = "Back";
                backButton.RegisterCallback( backButton_OnClick );

                // Create Button
                createButton = new Button( CREATE_BUTTON_POS, STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT, this );
                createButton.Texture = buttonTex;
                createButton.SetFont( buttonFont,
                    BTNTEXT_INERT_COLOUR,
                    BTNTEXT_HOVER_COLOUR,
                    BTNTEXT_PRIMED_COLOUR,
                    BTNTEXT_INACTIVE_COLOUR );
                createButton.Text = "Create Lobby";
                createButton.RegisterCallback( createButton_OnClick );

                // Match Duration Selector
                matchDurSel = new Selector( MATCH_DUR_SEL_POS, SEL_WIDTH, SEL_HEIGHT, this );
                matchDurSel.ArrowTexture = content.Load<Texture2D>( "UITextures/ArrowLeft" );
                matchDurSel.Font = labelFont;
                matchDurSel.TextColour = Color.White;
                matchDurSel.AddElement( "5" );
                matchDurSel.AddElement( "10" );
                matchDurSel.AddElement( "15" );
                matchDurSel.AddElement( "20" );
                matchDurSel.AddElement( "30" );
                matchDurSel.SelectedIndex = 2;

                // NumPlayers Selector
                numPlayersSel = new Selector( NUMPLAYERS_SEL_POS, SEL_WIDTH, SEL_HEIGHT, this );
                numPlayersSel.ArrowTexture = content.Load<Texture2D>( "UITextures/ArrowLeft" );
                numPlayersSel.Font = labelFont;
                numPlayersSel.TextColour = Color.White;
                numPlayersSel.AddElement( "1" );
                numPlayersSel.AddElement( "2" );
                numPlayersSel.AddElement( "4" );
                numPlayersSel.AddElement( "6" );
                numPlayersSel.AddElement( "8" );
                numPlayersSel.SelectedIndex = 2;

            }
        }
Example #5
0
        /// <summary>
        /// Loads graphics content for this screen. This uses the shared ContentManager
        /// provided by the Game class, so the content will remain loaded forever.
        /// Whenever a subsequent MessageBoxScreen tries to load this same content,
        /// it will just get back another reference to the already loaded data.
        /// </summary>
        public override void Activate(bool instancePreserved)
        {
            if (!instancePreserved)
            {
                ContentManager content = ScreenManager.Game.Content;

                viewport = ScreenManager.GraphicsDevice.Viewport;
                viewportSize = new Vector2(viewport.Width, viewport.Height);
                font = content.Load<SpriteFont>("Fonts/GUIFont");
                textSize = font.MeasureString("Upgrades");
                textPosition = ((viewportSize - textSize) / 2) - new Vector2(0,250);

                typeTextOrigin = font.MeasureString("HEALTH")/2;

                upg1 = new Button(UPG1_BUTTON_POS, UPG_BUTTON_WIDTH, UPG_BUTTON_HEIGHT, this);
                upg2 = new Button(UPG2_BUTTON_POS, UPG_BUTTON_WIDTH, UPG_BUTTON_HEIGHT, this);
                upg3 = new Button(UPG3_BUTTON_POS, UPG_BUTTON_WIDTH, UPG_BUTTON_HEIGHT, this);
                upg4 = new Button(UPG4_BUTTON_POS, UPG_BUTTON_WIDTH, UPG_BUTTON_HEIGHT, this);
                upg5 = new Button(UPG5_BUTTON_POS, UPG_BUTTON_WIDTH, UPG_BUTTON_HEIGHT, this);
                upg6 = new Button(UPG6_BUTTON_POS, UPG_BUTTON_WIDTH, UPG_BUTTON_HEIGHT, this);

                accept = new Button(ACCEPT_BUTTON_POS, STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT, this);
                cancel = new Button(CANCEL_BUTTON_POS, STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT, this);
                accept.Text = "Return";
                cancel.Text = "No";
                upg1.Text = " ";

                backgroundTexture = content.Load<Texture2D>("UITextures/upgradebg");

                upg1.Texture = content.Load<Texture2D>("UITextures/healthbutton");
                upg2.Texture = content.Load<Texture2D>("UITextures/focusbutton");
                upg3.Texture = content.Load<Texture2D>("UITextures/dmgbutton");
                upg4.Texture = content.Load<Texture2D>("UITextures/GUIButton");
                upg5.Texture = content.Load<Texture2D>("UITextures/GUIButton");
                upg6.Texture = content.Load<Texture2D>("UITextures/GUIButton");

                accept.Texture = content.Load<Texture2D>("UITextures/GUIButton");
                cancel.Texture = content.Load<Texture2D>("UITextures/GUIButton");
                accept.SetFont(font,
                    BTNTEXT_INERT_COLOUR,
                    BTNTEXT_HOVER_COLOUR,
                    BTNTEXT_PRIMED_COLOUR,
                    BTNTEXT_INACTIVE_COLOUR);
                cancel.SetFont(font,
                    BTNTEXT_INERT_COLOUR,
                    BTNTEXT_HOVER_COLOUR,
                    BTNTEXT_PRIMED_COLOUR,
                    BTNTEXT_INACTIVE_COLOUR);

                accept.RegisterCallback(acceptButton_OnClick);
                cancel.RegisterCallback(cancelButton_OnClick);
                upg1.RegisterCallback(upg1_OnClick);
                upg2.RegisterCallback(upg2_OnClick);
                upg3.RegisterCallback(upg3_OnClick);
            }
        }
Example #6
0
        public override void Activate( bool instancePreserved )
        {
            if ( !instancePreserved )
            {
                ContentManager content = ScreenManager.Game.Content;

                // Set up the title
                titleFont = content.Load<SpriteFont>( "Fonts/PageTitle" );

                // Set up the Buttons
                Texture2D buttonTex = content.Load<Texture2D>( "UITextures/GUIButton" );
                SpriteFont buttonFont = content.Load<SpriteFont>( "Fonts/GUIFont" );

                // Back Button
                backButton = new Button( BACK_BUTTON_POS, BACK_BUTTON_WIDTH, BACK_BUTTON_HEIGHT, this );
                backButton.Texture = buttonTex;
                backButton.SetFont( buttonFont,
                    BTNTEXT_INERT_COLOUR,
                    BTNTEXT_HOVER_COLOUR,
                    BTNTEXT_PRIMED_COLOUR,
                    BTNTEXT_INACTIVE_COLOUR );
                backButton.Text = "Back";
                backButton.RegisterCallback( backButton_OnClick );

                // Refresh Lobbies List button
                refreshButton = new Button( REFRESH_BUTTON_POS, STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT, this );
                refreshButton.Texture = buttonTex;
                refreshButton.SetFont( buttonFont,
                    BTNTEXT_INERT_COLOUR,
                    BTNTEXT_HOVER_COLOUR,
                    BTNTEXT_PRIMED_COLOUR,
                    BTNTEXT_INACTIVE_COLOUR );
                refreshButton.Text = "Refresh List";
                refreshButton.RegisterCallback( refreshButton_OnClick );

                // Join Selected Lobby Button
                joinButton = new Button( JOIN_LOBBY_BUTTON_POS, STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT, this );
                joinButton.Texture = buttonTex;
                joinButton.SetFont( buttonFont,
                    BTNTEXT_INERT_COLOUR,
                    BTNTEXT_HOVER_COLOUR,
                    BTNTEXT_PRIMED_COLOUR,
                    BTNTEXT_INACTIVE_COLOUR );
                joinButton.Text = "Join Selected Lobby";
                joinButton.RegisterCallback( joinButton_OnClick );
                joinButton.Active = false;

                // New Lobby Button
                newLobbyButton = new Button( NEW_LOBBY_BUTTON_POS, STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT, this );
                newLobbyButton.Texture = buttonTex;
                newLobbyButton.SetFont( buttonFont,
                    BTNTEXT_INERT_COLOUR,
                    BTNTEXT_HOVER_COLOUR,
                    BTNTEXT_PRIMED_COLOUR,
                    BTNTEXT_INACTIVE_COLOUR );
                newLobbyButton.Text = "Create New Lobby";
                newLobbyButton.RegisterCallback( newButton_OnClick );

                // Set up lobby list
                lobbyData = new List<LobbyData>();
                lobbies = new ListView( 8, LOBBY_LIST_POS, LOBBY_LIST_WIDTH, LOBBY_LIST_HEIGHT, this );
                lobbies.Font = content.Load<SpriteFont>( "Fonts/GUIFontBold" ); ;
                lobbies.Texture = content.Load<Texture2D>( "UITextures/ListViewItemTex" );
                lobbies.ArrowTexture = content.Load<Texture2D>( "UITextures/ArrowUp" );
                lobbies.ItemTextColour = LOBBY_LIST_ITEM_COLOUR;

                // Open the network connection
                GameManager.Instance.Client.Start();
                if ( string.IsNullOrEmpty( GameSettings.SERVER_URL ) )
                {
                    //GameManager.Instance.Client.DiscoverLocalPeers( GameSettings.SERVER_PORT_NUM );
                    string s = System.IO.File.ReadAllText( "Content/host.txt" );
                    GameManager.Instance.Client.Connect( s, GameSettings.SERVER_PORT_NUM );
                    //Console.WriteLine( s );
                }
                else
                {
                    GameManager.Instance.Client.Connect( GameSettings.SERVER_URL, GameSettings.SERVER_PORT_NUM );
                }
                GameManager.Instance.RegisterForPackets( this );
            }
        }
Example #7
0
        public override void Activate( bool instancePreserved )
        {
            if ( !instancePreserved )
            {
                ContentManager content = ScreenManager.Game.Content;

                titleFont = content.Load<SpriteFont>( "Fonts/PageTitle" );

                priestImage = content.Load<Texture2D>("Images/priestselect");
                fireWizardImage = content.Load<Texture2D>("Images/wizselect");
                beastMistressImage = content.Load<Texture2D>("Images/bmselect");
                windLasherImage = content.Load<Texture2D>("Images/windselect");

                // Set up the Buttons
                Texture2D buttonTex = content.Load<Texture2D>( "UITextures/GUIButton" );
                SpriteFont buttonFont = content.Load<SpriteFont>( "Fonts/GUIFont" );

                // Back Button
                backButton = new Button( BACK_BUTTON_POS, BACK_BUTTON_WIDTH, BACK_BUTTON_HEIGHT, this );
                backButton.Texture = buttonTex;
                backButton.SetFont( buttonFont,
                    BTNTEXT_INERT_COLOUR,
                    BTNTEXT_HOVER_COLOUR,
                    BTNTEXT_PRIMED_COLOUR,
                    BTNTEXT_INACTIVE_COLOUR );
                backButton.Text = "Back";
                backButton.RegisterCallback( backButton_OnClick );

                // Priest Selection Button
                priestButton = new Button(PRIEST_BUTTON_POS, STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT, this);
                priestButton.Texture = buttonTex;
                priestButton.SetFont(buttonFont,
                    BTNTEXT_INERT_COLOUR,
                    BTNTEXT_HOVER_COLOUR,
                    BTNTEXT_PRIMED_COLOUR,
                    BTNTEXT_INACTIVE_COLOUR);
                priestButton.Text = "Priest";
                priestButton.RegisterCallback(priestButton_OnClick);

                // Fire Wizard Selection Button
                fireButton = new Button(FIRE_BUTTON_POS, STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT, this);
                fireButton.Texture = buttonTex;
                fireButton.SetFont(buttonFont,
                    BTNTEXT_INERT_COLOUR,
                    BTNTEXT_HOVER_COLOUR,
                    BTNTEXT_PRIMED_COLOUR,
                    BTNTEXT_INACTIVE_COLOUR);
                fireButton.Text = "Fire Wizard";
                fireButton.RegisterCallback(fireButton_OnClick);

                // Beast Mistress Selection Button
                bmButton = new Button(BM_BUTTON_POS, STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT, this);
                bmButton.Texture = buttonTex;
                bmButton.SetFont(buttonFont,
                    BTNTEXT_INERT_COLOUR,
                    BTNTEXT_HOVER_COLOUR,
                    BTNTEXT_PRIMED_COLOUR,
                    BTNTEXT_INACTIVE_COLOUR);
                bmButton.Text = "Beast Mistress";
                bmButton.RegisterCallback(bmButton_OnClick);

                // WindLasher Selection Button
                windButton = new Button(WIND_BUTTON_POS, STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT, this);
                windButton.Texture = buttonTex;
                windButton.SetFont(buttonFont,
                    BTNTEXT_INERT_COLOUR,
                    BTNTEXT_HOVER_COLOUR,
                    BTNTEXT_PRIMED_COLOUR,
                    BTNTEXT_INACTIVE_COLOUR);
                windButton.Text = "WindLasher";
                windButton.RegisterCallback(windButton_OnClick);
            }
        }
Example #8
0
        /// <summary>
        /// Screen initialization.
        /// </summary>
        public override void Activate(bool instancePreserved)
        {
            if (!instancePreserved)
            {
                if (content == null)
                    content = new ContentManager(ScreenManager.Game.Services, "Content");

                gameFont = content.Load<SpriteFont>("gamefont");

                // A real game would probably have more content than this sample, so
                // it would take longer to load. We simulate that by delaying for a
                // while, giving you a chance to admire the beautiful loading screen.
                Thread.Sleep(200);

                // once the load has finished, we use ResetElapsedTime to tell the game's
                // timing mechanism that we have just finished a very long frame, and that
                // it should not try to catch up.
                ScreenManager.Game.ResetElapsedTime();

                // Load Controls

                Texture2D buttonTex = content.Load<Texture2D>( "ControlStuff/TestBtn" );
                SpriteFont buttonFont = content.Load<SpriteFont>( "ControlStuff/btnText" );

                testBtn1 = new Button( new Point( 50, 50 ), 100, 100, this );
                testBtn1.Texture = buttonTex;
                testBtn1.SetFont( buttonFont, Color.Black, Color.Red, Color.Yellow, Color.LightGray );
                testBtn1.Text = "TestBtn1";
                testBtn1.RegisterCallback( testBtn1_OnClick );

                testBtn2 = new Button( new Point( 200, 50 ), 150, 75, this );
                testBtn2.Texture = buttonTex;
                testBtn2.Text = "Button 2";
                testBtn2.SetFont( buttonFont, Color.Black, Color.Red, Color.Yellow, Color.LightGray );
                testBtn2.RegisterCallback( testBtn2_OnClick );

                testlistView = new ListView(4, new Point(400, 75), 150, 200, this);
                testlistView.Texture = buttonTex;
                testlistView.Font = buttonFont;
                testlistView.ArrowTexture = buttonTex;
                testlistView.ArrowFont = buttonFont;
                testlistView.AddElement("A");
                testlistView.AddElement("B");
                testlistView.AddElement("C");
                testlistView.AddElement("D");
                testlistView.AddElement("E");
                testlistView.AddElement("F");
                testlistView.AddElement("G");
                testlistView.AddElement("H");
                testlistView.AddElement("A");
                testlistView.RemoveElement("A");
                testlistView.RemoveElement("G");
                testlistView.Clear();
                testlistView.AddElement("A");
                testlistView.AddElement("B");
                testlistView.AddElement("C");
                testlistView.AddElement("D");
                testlistView.AddElement("E");
                testlistView.AddElement("F");
                testlistView.AddElement("G");
                testlistView.AddElement("H");
                testlistView.AddElement("A");

                testSelector = new Selector(new Point(50, 300), 150, 200, this);
                testSelector.Font = buttonFont;
                testSelector.ArrowTexture = buttonTex;
                testSelector.ArrowFont = buttonFont;
                testSelector.AddElement("A");
                testSelector.AddElement("B");
                testSelector.AddElement("C");
                testSelector.AddElement("D");
                testSelector.AddElement("E");
                testSelector.AddElement("F");
                testSelector.AddElement("G");
                testSelector.AddElement("H");
                testSelector.AddElement("A");
                testSelector.RemoveElement("A");
                testSelector.RemoveElement("G");
                testSelector.Clear();
                testSelector.AddElement("A");
                testSelector.AddElement("B");
                testSelector.AddElement("C");
                testSelector.AddElement("D");
                testSelector.AddElement("E");
                testSelector.AddElement("F");
                testSelector.AddElement("G");
                testSelector.AddElement("H");
                testSelector.AddElement("Asds");

            }
        }
Example #9
0
        public override void Activate( bool instancePreserved )
        {
            if ( !instancePreserved )
            {
                ContentManager content = ScreenManager.Game.Content;

                banner = content.Load<Texture2D>( "Images/wizlogo3" );

                // Set up the Buttons
                Texture2D buttonTex = content.Load<Texture2D>( "UITextures/GUIButton" );
                SpriteFont buttonFont = content.Load<SpriteFont>( "Fonts/GUIFont" );

                // Single Player Button
                spButton = new Button( SP_BUTTON_POS, STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT, this );
                spButton.Texture = buttonTex;
                spButton.SetFont( buttonFont,
                    BTNTEXT_INERT_COLOUR,
                    BTNTEXT_HOVER_COLOUR,
                    BTNTEXT_PRIMED_COLOUR,
                    BTNTEXT_INACTIVE_COLOUR );
                spButton.Text = "Single Player";
                spButton.RegisterCallback( spButton_OnClick );

                // Multiplayer Button
                mpButton = new Button( MP_BUTTON_POS, STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT, this );
                mpButton.Texture = buttonTex;
                mpButton.SetFont( buttonFont,
                    BTNTEXT_INERT_COLOUR,
                    BTNTEXT_HOVER_COLOUR,
                    BTNTEXT_PRIMED_COLOUR,
                    BTNTEXT_INACTIVE_COLOUR );
                mpButton.Text = "Multiplayer";
                mpButton.RegisterCallback( mpButton_OnClick );

                // Options Button
                optionsButton = new Button( OPT_BUTTON_POS, STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT, this );
                optionsButton.Texture = buttonTex;
                optionsButton.SetFont( buttonFont,
                    BTNTEXT_INERT_COLOUR,
                    BTNTEXT_HOVER_COLOUR,
                    BTNTEXT_PRIMED_COLOUR,
                    BTNTEXT_INACTIVE_COLOUR );
                optionsButton.Text = "Options";
                optionsButton.RegisterCallback( optionsButton_OnClick );

                // Achievements Button
                achiButton = new Button( ACHI_BUTTON_POS, STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT, this );
                achiButton.Texture = buttonTex;
                achiButton.SetFont( buttonFont,
                    BTNTEXT_INERT_COLOUR,
                    BTNTEXT_HOVER_COLOUR,
                    BTNTEXT_PRIMED_COLOUR,
                    BTNTEXT_INACTIVE_COLOUR );
                achiButton.Text = "Achievements";
                achiButton.Active = false;
                achiButton.RegisterCallback( achiButton_OnClick );

                // Exit Button
                exitButton = new Button( EXIT_BUTTON_POS, EXIT_BUTTON_WIDTH, EXIT_BUTTON_HEIGHT, this );
                exitButton.Texture = buttonTex;
                exitButton.SetFont( buttonFont,
                    BTNTEXT_INERT_COLOUR,
                    BTNTEXT_HOVER_COLOUR,
                    BTNTEXT_PRIMED_COLOUR,
                    BTNTEXT_INACTIVE_COLOUR );
                exitButton.Text = "Exit";
                exitButton.RegisterCallback( exitButton_OnClick );

                altar1 = new Animation(new AnimationTexture(ScreenManager.Game.Content.Load<Texture2D>("Images/altar"), null), 3, 60, 1f, false);
                altar2 = new Animation(new AnimationTexture(ScreenManager.Game.Content.Load<Texture2D>("Images/altar"), null), 3, 60, 1f, false);

                // TODO: Delme (Demo Code)
                demoBGMusic = ScreenManager.Game.Content.Load<Song>( "Audio/Demo_FightingWinds" );
                MediaPlayer.IsRepeating = true;
                MediaPlayer.Play( demoBGMusic );
                MediaPlayer.Volume = 0.4f;
            }
        }
Example #10
0
        /// <summary>
        /// Loads graphics content for this screen. This uses the shared ContentManager
        /// provided by the Game class, so the content will remain loaded forever.
        /// Whenever a subsequent MessageBoxScreen tries to load this same content,
        /// it will just get back another reference to the already loaded data.
        /// </summary>
        public override void Activate(bool instancePreserved)
        {
            if (!instancePreserved)
            {
                ContentManager content = ScreenManager.Game.Content;

                viewport = ScreenManager.GraphicsDevice.Viewport;
                viewportSize = new Vector2(viewport.Width, viewport.Height);
                font = content.Load<SpriteFont>("Fonts/GUIFont");
                textSize = font.MeasureString(message);
                textPosition = (viewportSize - textSize) / 2;

                backgroundRectangle = new Rectangle((int)textPosition.X - HPAD,
                                                    (int)textPosition.Y - VPAD,
                                                    (int)textSize.X + HPAD * 2,
                                                    (int)textSize.Y + VPAD * 2);
                backgroundTexture = content.Load<Texture2D>("UITextures/popbg");

                if ( style == Style.YesNo )
                {
                    accept = new Button(ACCEPT_BUTTON_POS, STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT, this);
                    cancel = new Button(CANCEL_BUTTON_POS, STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT, this);
                    accept.Text = "Yes";
                    cancel.Text = "No";

                    accept.Texture = content.Load<Texture2D>("UITextures/GUIButton");
                    cancel.Texture = content.Load<Texture2D>("UITextures/GUIButton");
                    accept.SetFont(font,
                        BTNTEXT_INERT_COLOUR,
                        BTNTEXT_HOVER_COLOUR,
                        BTNTEXT_PRIMED_COLOUR,
                        BTNTEXT_INACTIVE_COLOUR);
                    cancel.SetFont(font,
                        BTNTEXT_INERT_COLOUR,
                        BTNTEXT_HOVER_COLOUR,
                        BTNTEXT_PRIMED_COLOUR,
                        BTNTEXT_INACTIVE_COLOUR);

                    accept.RegisterCallback(acceptButton_OnClick);
                    cancel.RegisterCallback(cancelButton_OnClick);
                }
                else if ( style == Style.OK )
                {
                    accept = new Button( OK_BUTTON_POS, STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT, this );
                    accept.Texture = content.Load<Texture2D>( "UITextures/GUIButton" );
                    accept.SetFont( font,
                        BTNTEXT_INERT_COLOUR,
                        BTNTEXT_HOVER_COLOUR,
                        BTNTEXT_PRIMED_COLOUR,
                        BTNTEXT_INACTIVE_COLOUR );
                    accept.RegisterCallback( acceptButton_OnClick );
                    accept.Text = "OK";
                }

            }
        }
Example #11
0
        public override void Activate( bool instancePreserved )
        {
            if ( !instancePreserved )
            {
                ContentManager content = ScreenManager.Game.Content;

                titleFont = content.Load<SpriteFont>( "Fonts/PageTitle" );
                listHeadingFont = content.Load<SpriteFont>( "Fonts/ListHeading" );

                // Set up the Buttons
                Texture2D buttonTex = content.Load<Texture2D>( "UITextures/GUIButton" );
                SpriteFont buttonFont = content.Load<SpriteFont>( "Fonts/GUIFont" );

                // Ready Button
                readyButton = new Button( READY_BUTTON_POS, STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT, this );
                readyButton.Texture = buttonTex;
                readyButton.SetFont( buttonFont,
                    BTNTEXT_INERT_COLOUR,
                    BTNTEXT_HOVER_COLOUR,
                    BTNTEXT_PRIMED_COLOUR,
                    BTNTEXT_INACTIVE_COLOUR );
                readyButton.Text = "Ready!";
                readyButton.RegisterCallback( readyButton_OnClick );

                // Back Button
                backButton = new Button( BACK_BUTTON_POS, BACK_BUTTON_WIDTH, BACK_BUTTON_HEIGHT, this );
                backButton.Texture = buttonTex;
                backButton.SetFont( buttonFont,
                    BTNTEXT_INERT_COLOUR,
                    BTNTEXT_HOVER_COLOUR,
                    BTNTEXT_PRIMED_COLOUR,
                    BTNTEXT_INACTIVE_COLOUR );
                backButton.Text = "Back";
                backButton.RegisterCallback( backButton_OnClick );

                // Switch Team Button
                teamButton = new Button( TEAM_BUTTON_POS, STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT, this );
                teamButton.Texture = buttonTex;
                teamButton.SetFont( buttonFont,
                    BTNTEXT_INERT_COLOUR,
                    BTNTEXT_HOVER_COLOUR,
                    BTNTEXT_PRIMED_COLOUR,
                    BTNTEXT_INACTIVE_COLOUR );
                teamButton.Text = "Change Team";
                teamButton.RegisterCallback( teamButton_OnClick );

                // Switch Role Button
                roleButton = new Button( ROLE_BUTTON_POS, STD_BUTTON_WIDTH, STD_BUTTON_HEIGHT, this );
                roleButton.Texture = buttonTex;
                roleButton.SetFont( buttonFont,
                    BTNTEXT_INERT_COLOUR,
                    BTNTEXT_HOVER_COLOUR,
                    BTNTEXT_PRIMED_COLOUR,
                    BTNTEXT_INACTIVE_COLOUR );
                roleButton.Text = "Change Role";
                roleButton.RegisterCallback( roleButton_OnClick );

                // Set up the team lists
                Texture2D listItemTex = content.Load<Texture2D>( "UITextures/ListViewItemTex" );
                SpriteFont listItemFont = content.Load<SpriteFont>( "Fonts/GUIFontBold" );

                // Red team list
                redTeamList = new ListView( 8, RED_LIST_POS, LIST_WIDTH, LIST_HEIGHT, this );
                redTeamList.Texture = listItemTex;
                redTeamList.Font = listItemFont;
                redTeamList.ItemTextColour = TEAM_LIST_TEXT_COLOUR;

                // Blue team list
                blueTeamList = new ListView( 8, BLUE_LIST_POS, LIST_WIDTH, LIST_HEIGHT, this );
                blueTeamList.Texture = listItemTex;
                blueTeamList.Font = listItemFont;
                blueTeamList.ItemTextColour = TEAM_LIST_TEXT_COLOUR;

                GameManager.Instance.RegisterForPackets( this );
            }
        }