[longomatch] Fix players selection due to wrong indexing



commit ec4fde6e7d84f7fecebbbe006932c420c3b60d46
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Sun Apr 10 18:37:18 2011 +0200

    Fix players selection due to wrong indexing

 LongoMatch/Gui/Dialog/PlayersSelectionDialog.cs |   17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)
---
diff --git a/LongoMatch/Gui/Dialog/PlayersSelectionDialog.cs b/LongoMatch/Gui/Dialog/PlayersSelectionDialog.cs
index 84eab28..e3abc01 100644
--- a/LongoMatch/Gui/Dialog/PlayersSelectionDialog.cs
+++ b/LongoMatch/Gui/Dialog/PlayersSelectionDialog.cs
@@ -29,12 +29,12 @@ namespace LongoMatch.Gui.Dialog
 	public partial class PlayersSelectionDialog : Gtk.Dialog
 	{
 		TeamTemplate template;
-		List<CheckButton> checkButtonsList;
+		Dictionary<int, CheckButton> checkButtonsDict;
 
 		public PlayersSelectionDialog()
 		{
 			this.Build();
-			checkButtonsList = new List<CheckButton>();
+			checkButtonsDict = new Dictionary<int, CheckButton>();
 		}
 
 		public void SetPlayersInfo(TeamTemplate template) {
@@ -66,22 +66,21 @@ namespace LongoMatch.Gui.Dialog
 				uint col_right = (uint) col_left+1 ;
 
 				table1.Attach(button,col_left,col_right,row_top,row_bottom);
-				checkButtonsList.Add(button);
+				checkButtonsDict.Add(i, button);
 				playersCount++;
 			}
 		}
 
 		public List<int> PlayersChecked {
 			set {
-				for (int i=0; i<checkButtonsList.Count; i++)
-					checkButtonsList[i].Active = value.Contains(i);
+				foreach (int player in checkButtonsDict.Keys)
+					checkButtonsDict[player].Active = value.Contains(player);
 			}
 			get {
 				List<int> playersList = new List<int>();
-				for (int i=0; i<checkButtonsList.Count; i++) {
-					if (checkButtonsList[i].Active) {
-						playersList.Add(i);
-					}
+				foreach (int player in checkButtonsDict.Keys) {
+					if (checkButtonsDict[player].Active)
+						playersList.Add (player);
 				}
 				return playersList;
 			}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]