]> git.r.bdr.sh - rbdr/super-polarity/blobdiff - SuperPolarity/ScoreScreen.cs
Update project to work on VS Code mac
[rbdr/super-polarity] / SuperPolarity / ScoreScreen.cs
index bf432752b1eed1563ed3027e2fde76cb21e19ce3..63418d87b6793cb4d5a75547062f1efc4206aa9d 100644 (file)
@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -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));
             }
 
         }