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 ); } }
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; } }
/// <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"); } }