/// <summary> /// Display highscores information to the user. Prompt them to enter a username if they haven't already. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void highscoresToolStripMenuItem_Click(object sender, EventArgs e) { string username = Properties.Settings.Default.username; string gamemode = Properties.Settings.Default.gamemode; //Check for username saved in settings if (String.IsNullOrEmpty(username)) { DialogResult promptForUsername = MessageBox.Show(this, "Would you like to enter your username for highscores functionality?", "Warning", MessageBoxButtons.YesNo); if (promptForUsername == DialogResult.Yes) { //Prompt them for the username now TextDialogForm textDialogForm = new TextDialogForm(); if (textDialogForm.ShowDialog(this) == DialogResult.OK) { username = textDialogForm.textInput.Text; textDialogForm.Dispose(); Utility.SaveUsername(username); } else { return; } } else { return; } } //Open up the highscores form HighscoresForm highscoresForm = new HighscoresForm(username, gamemode); highscoresForm.Show(this); }
public static void ShowLeaderboard(IWin32Window invoker) { HighscoresForm leaderboard = new HighscoresForm(); if (invoker != null) { leaderboard.ShowDialog(invoker); } else { leaderboard.ShowDialog(); } }
private static string GetPlayerNameOnNewHighScore(FieldConfiguration activeConfig, int currentScore, IWin32Window invoker) { string result = null; if (NewHighscoreReached(activeConfig, currentScore)) { using (HighscoresForm highscoreSelectionForm = new HighscoresForm(activeConfig, currentScore)) { highscoreSelectionForm.ShowDialog(invoker); result = highscoreSelectionForm.PlayerName; if (string.IsNullOrEmpty(result)) { result = "Anonymous"; } } } return(result); }