[longomatch] Add a menu option to reset players



commit a285f122aa5ce063df088456cc71df85114401fa
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Wed Dec 17 12:26:29 2014 +0100

    Add a menu option to reset players

 LongoMatch.Core/Store/Templates/TeamTemplate.cs |    7 ++++++
 LongoMatch.Drawing/Widgets/TeamTagger.cs        |    2 +-
 LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs     |   27 ++++++++++++++++------
 3 files changed, 27 insertions(+), 9 deletions(-)
---
diff --git a/LongoMatch.Core/Store/Templates/TeamTemplate.cs b/LongoMatch.Core/Store/Templates/TeamTemplate.cs
index 73e7fa8..a2333c1 100644
--- a/LongoMatch.Core/Store/Templates/TeamTemplate.cs
+++ b/LongoMatch.Core/Store/Templates/TeamTemplate.cs
@@ -189,6 +189,13 @@ namespace LongoMatch.Core.Store.Templates
                        }
                }
 
+               public void ResetPlayers()
+               {
+                       foreach (Player p in List) {
+                               p.Playing = true;
+                       }
+               }
+
                public void Save(string filePath) {
                        Serializer.Save(this, filePath);
                }
diff --git a/LongoMatch.Drawing/Widgets/TeamTagger.cs b/LongoMatch.Drawing/Widgets/TeamTagger.cs
index f518aca..7ecfd2b 100644
--- a/LongoMatch.Drawing/Widgets/TeamTagger.cs
+++ b/LongoMatch.Drawing/Widgets/TeamTagger.cs
@@ -156,7 +156,7 @@ namespace LongoMatch.Drawing.Widgets
                                players = tagger.SelectedPlayers;
                        }
                        
-                       if (players.Count > 0 && ShowMenuEvent != null) {
+                       if (ShowMenuEvent != null) {
                                ShowMenuEvent (players);
                        }
                }
diff --git a/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs b/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
index e0ecb71..ccbe8c4 100644
--- a/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
+++ b/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
@@ -499,15 +499,26 @@ namespace LongoMatch.Gui.Panel
                        UpdateTitle ();
                }
 
-               void HandleShowMenuEvent (List<Player> players)
+               void HandleShowMenuEvent(List<Player> players)
                {
-                       Menu menu = new Menu ();
-                       MenuItem item = new MenuItem ("Remove for this match");
-                       item.Activated += (sender, e) => {
-                               hometemplate.RemovePlayers (players, false);
-                               awaytemplate.RemovePlayers (players, false);
-                               teamtagger.Reload ();
-                       };
+                       Menu menu = new Menu();
+                       MenuItem item;
+                       
+                       if (players.Count > 0) {
+                               item = new MenuItem("Remove for this match");
+                               item.Activated += (sender, e) => {
+                                       hometemplate.RemovePlayers(players, false);
+                                       awaytemplate.RemovePlayers(players, false);
+                                       teamtagger.Reload();
+                               };
+                       } else {
+                               item = new MenuItem ("Reset players");
+                               item.Activated += (sender, e) => {
+                                       hometemplate.ResetPlayers ();
+                                       awaytemplate.ResetPlayers ();
+                                       teamtagger.Reload ();
+                               };
+                       }
                        menu.Add (item);
                        menu.ShowAll ();
                        menu.Popup ();


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