// '' <summary> // '' Read the user's name for their highsSwinGame. // '' </summary> // '' <param name="value">the player's sSwinGame.</param> // '' <remarks> // '' This verifies if the score is a highsSwinGame. // '' </remarks> public static void ReadHighScore(int value) { const int ENTRY_TOP = 550; if ((_Scores.Count == 0)) { HighScoreController.LoadScores(); } // is it a high score if ((value > _Scores[(_Scores.Count - 1)].Value)) { Score s = new Score(); s.Value = value; GameController.AddNewState(GameState.ViewingHighScores); int x; x = (SCORES_LEFT + SwinGame.TextWidth(GameResources.GameFont("Courier"), "Name: ")); SwinGame.StartReadingText(Color.Black, NAME_WIDTH, GameResources.GameFont("Courier"), x, ENTRY_TOP); // Read the text from the user while (SwinGame.ReadingText()) { SwinGame.ProcessEvents(); UtilityFunctions.DrawBackground(); HighScoreController.DrawHighScores(); SwinGame.DrawText("Name: ", Color.Black, GameResources.GameFont("Courier"), SCORES_LEFT, ENTRY_TOP); SwinGame.RefreshScreen(); } s.Name = SwinGame.TextReadAsASCII(); if ((s.Name.Length < 3)) { s.Name = (s.Name + new string(((char)(' ')), (3 - s.Name.Length))); } _Scores.RemoveAt((_Scores.Count - 1)); _Scores.Add(s); _Scores.Sort(); SaveScores(); GameController.EndCurrentState(); } }
// '' <summary> // '' Draws the high scores to the screen. // '' </summary> public static void DrawHighScores() { const int SCORES_HEADING = 200; const int SCORES_TOP = 250; const int SCORE_GAP = 30; if ((_Scores.Count == 0)) { HighScoreController.LoadScores(); } SwinGame.DrawText(" High Scores ", Color.Black, GameResources.GameFont("Courier"), SCORES_LEFT, SCORES_HEADING); // For all of the scores int i; for (i = 0; (i <= (_Scores.Count - 1)); i++) { Score s; s = _Scores[i]; // for scores 1 - 9 use 01 - 09 if ((i < 9)) { SwinGame.DrawText((" " + ((i + 1) + (": " + (s.Name + (" " + s.Value))))), Color.Black, GameResources.GameFont("Courier"), SCORES_LEFT, (SCORES_TOP + (i * SCORE_GAP))); } else { SwinGame.DrawText(((i + 1) + (": " + (s.Name + (" " + s.Value)))), Color.Black, GameResources.GameFont("Courier"), SCORES_LEFT, (SCORES_TOP + (i * SCORE_GAP))); } } }