public override void LoadContent() { ContentManager Content = sceneManager.Game.Content; BackgroundTexture = Content.Load<Texture2D>(@"images\scene\CommonButton\FadeScreen"); Viewport viewport = SceneManager.GraphicsDevice.Viewport; BackgroundRectangle = new Rectangle(viewport.X, viewport.Y, viewport.Width, viewport.Height); Texture2D textbox_texture = Content.Load<Texture2D>(@"images\scene\TextBoxScene\textbox_dialog"); Texture2D caret_texture = Content.Load<Texture2D>(@"images\scene\TextBoxScene\caret"); SpriteFont text_font = Content.Load<SpriteFont>(@"fonts\TextBoxScene\textinput"); textBox = new TextBox(textbox_texture, caret_texture, text_font); textBox.Center = new Vector2(512, 384); textBox.TextOffset = new Vector2(60, 95); textBox.Width = 500; textBox.OnEnterPressed += TextBoxEnter_Pressed; GameManager.keyboard_dispatcher.Subscriber = textBox; Texture2D normalTexture, pressTexture; normalTexture = Content.Load<Texture2D>(@"images\scene\TextBoxScene\b_save_normal"); pressTexture = Content.Load<Texture2D>(@"images\scene\TextBoxScene\b_save_press"); SaveButton = new Button(normalTexture, null, pressTexture, new Vector2(230, 420)); SaveButton.Clicked += SaveButton_Clicked; normalTexture = Content.Load<Texture2D>(@"images\scene\TextBoxScene\b_cancel_normal"); pressTexture = Content.Load<Texture2D>(@"images\scene\TextBoxScene\b_cancel_press"); CancelButton = new Button(normalTexture, null, pressTexture, new Vector2(580, 420)); CancelButton.Clicked += CancelButton_Clicked; }
private void TextBoxEnter_Pressed(TextBox sender) { string player_name = textBox.Text; if (player_name != null && !player_name.Equals("")) { UserData.highscore.AddScore(new Score(player_name, total_points)); DataSerializer.SaveData<HighScore>(UserData.highscore, UserData.HighScoreDirectory, UserData.HighScoreFile); sceneManager.ExitToMainMenu(); sceneManager.AddScene(new ScoreScene()); } }