]> git.r.bdr.sh - rbdr/super-polarity/blobdiff - SuperPolarity/ScoreScreen.cs
Move some files around, relink
[rbdr/super-polarity] / SuperPolarity / ScoreScreen.cs
index bf432752b1eed1563ed3027e2fde76cb21e19ce3..d879db9e2fd6918db308d0096fb94bafda2a1996 100644 (file)
@@ -13,7 +13,7 @@ namespace SuperPolarity
     {
         protected SpriteFont Font;
         protected NameChooserWidget nameChooser;
-        protected Dictionary<string, int> Scores;
+        protected List<Tuple<String, int>> Scores;
 
         public ScoreScreen(SuperPolarity newGame) : base(newGame) { }
 
@@ -23,7 +23,7 @@ namespace SuperPolarity
             nameChooser = new NameChooserWidget(Game, new Vector2(40, Game.GraphicsDevice.Viewport.Height / 4));
             InputController.RegisterEventForButton("OK", Buttons.A);
             InputController.RegisterEventForKey("OK", Keys.Z);
-            Scores = new Dictionary<string, int>();
+                       Scores = new List<Tuple<String, int>>();
             ReadScore();
         }
 
@@ -59,7 +59,8 @@ namespace SuperPolarity
                     while ((line = sreader.ReadLine()) != null)
                     {
                         string[] parts = line.Split(',');
-                        Scores.Add(parts[0], int.Parse(parts[1]));
+                                               var scoreTuple = new Tuple<String, int>(parts[0], int.Parse(parts[1]));
+                                               Scores.Add (scoreTuple);
                     }
                 }
             }
@@ -92,15 +93,15 @@ namespace SuperPolarity
 
         protected void DrawScores(SpriteBatch spriteBatch)
         {
-            var sortedDict = (from entry in Scores orderby entry.Value descending select entry)
-                .Take(5)
-                .ToDictionary(pair => pair.Key, pair => pair.Value);
+                       var sortedList = (from entry in Scores orderby entry.Item2 descending select entry)
+                .Take (5)
+                               .ToList ();
 
             var i = 0;
 
-            foreach (KeyValuePair<string, int> entry in sortedDict) {
+            foreach (Tuple<string, int> entry in sortedList) {
                 i++;
-                spriteBatch.DrawString(Font, entry.Key + " " + entry.Value, new Vector2(40, Game.GraphicsDevice.Viewport.Height / 2 + 100 + (32 * i)), new Color(0, 0, 0, 64));
+                spriteBatch.DrawString(Font, entry.Item1 + " " + entry.Item2, new Vector2(40, Game.GraphicsDevice.Viewport.Height / 2 + 100 + (32 * i)), new Color(0, 0, 0, 64));
             }
 
         }