[longomatch] Add players hotkeys tagging



commit 5272255c2040752c875361c621bf4d7a208b2cbf
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Thu Oct 30 20:09:19 2014 +0100

    Add players hotkeys tagging

 LongoMatch.Core/Interfaces/GUI/IAnalysisWindow.cs  |    1 +
 LongoMatch.GUI/Gui/Component/AnalysisComponent.cs  |    5 +
 LongoMatch.GUI/Gui/Component/CodingWidget.cs       |    5 +
 .../Gui/Component/FakeAnalysisComponent.cs         |    5 +
 LongoMatch.Services/Services/HotKeysManager.cs     |   80 ++++++++++++++++----
 5 files changed, 80 insertions(+), 16 deletions(-)
---
diff --git a/LongoMatch.Core/Interfaces/GUI/IAnalysisWindow.cs 
b/LongoMatch.Core/Interfaces/GUI/IAnalysisWindow.cs
index 7ad8eb2..1ae3fc5 100644
--- a/LongoMatch.Core/Interfaces/GUI/IAnalysisWindow.cs
+++ b/LongoMatch.Core/Interfaces/GUI/IAnalysisWindow.cs
@@ -41,6 +41,7 @@ namespace LongoMatch.Core.Interfaces.GUI
                void ShowTimeline ();
                void ShowZonalTags ();
                void ClickButton (DashboardButton button);
+               void TagPlayer (Player player);
                
                IPlayerBin Player{get;}
                ICapturerBin Capturer{get;}
diff --git a/LongoMatch.GUI/Gui/Component/AnalysisComponent.cs 
b/LongoMatch.GUI/Gui/Component/AnalysisComponent.cs
index 8868aa6..585af34 100644
--- a/LongoMatch.GUI/Gui/Component/AnalysisComponent.cs
+++ b/LongoMatch.GUI/Gui/Component/AnalysisComponent.cs
@@ -109,6 +109,11 @@ namespace LongoMatch.Gui.Component
                        codingwidget.ClickButton (button);
                }
 
+               public void TagPlayer (Player player)
+               {
+                       codingwidget.TagPlayer (player);
+               }
+
                public void DetachPlayer ()
                {
                        bool isPlaying = playercapturer.Playing;
diff --git a/LongoMatch.GUI/Gui/Component/CodingWidget.cs b/LongoMatch.GUI/Gui/Component/CodingWidget.cs
index 87a8beb..73e66bc 100644
--- a/LongoMatch.GUI/Gui/Component/CodingWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/CodingWidget.cs
@@ -145,6 +145,11 @@ namespace LongoMatch.Gui.Component
                        buttonswidget.ClickButton (button);
                }
 
+               public void TagPlayer (Player player)
+               {
+                       teamtagger.Select (player);
+               }
+
                public void SetProject (Project project, ProjectType projectType, EventsFilter filter)
                {
                        this.projectType = projectType;
diff --git a/LongoMatch.GUI/Gui/Component/FakeAnalysisComponent.cs 
b/LongoMatch.GUI/Gui/Component/FakeAnalysisComponent.cs
index 5fe0af0..a04cacd 100644
--- a/LongoMatch.GUI/Gui/Component/FakeAnalysisComponent.cs
+++ b/LongoMatch.GUI/Gui/Component/FakeAnalysisComponent.cs
@@ -97,6 +97,11 @@ namespace LongoMatch.Gui.Component
                        codingwidget1.ClickButton (button);
                }
 
+               public void TagPlayer (Player player)
+               {
+                       codingwidget1.TagPlayer (player);
+               }
+
                public IPlayerBin Player {
                        get {
                                return null;
diff --git a/LongoMatch.Services/Services/HotKeysManager.cs b/LongoMatch.Services/Services/HotKeysManager.cs
index d3881f3..a32dded 100644
--- a/LongoMatch.Services/Services/HotKeysManager.cs
+++ b/LongoMatch.Services/Services/HotKeysManager.cs
@@ -18,11 +18,12 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 //
 //
+using System;
 using System.Collections.Generic;
+using System.Linq;
 using LongoMatch.Core.Common;
 using LongoMatch.Core.Interfaces.GUI;
 using LongoMatch.Core.Store;
-using System;
 using LongoMatch.Core.Store.Templates;
 
 namespace LongoMatch.Services
@@ -34,7 +35,11 @@ namespace LongoMatch.Services
                ProjectType projectType;
                ICapturerBin capturer;
                Dashboard dashboard;
+               Project openedProject;
                AnalysisEventButton pendingButton;
+               bool inPlayerTagging;
+               string playerNumber;
+               Team taggedTeam;
                System.Threading.Timer timer;
                const int TIMEOUT_MS = 1000;
 
@@ -48,6 +53,22 @@ namespace LongoMatch.Services
                        timer = new System.Threading.Timer (HandleTimeout);
                }
 
+               void TagPlayer ()
+               {
+                       int playerNumber;
+                       
+                       if (int.TryParse (this.playerNumber, out playerNumber)) {
+                               TeamTemplate team = taggedTeam == Team.LOCAL ? 
openedProject.LocalTeamTemplate :
+                                       openedProject.VisitorTeamTemplate;
+                               Player player = team.List.FirstOrDefault (p => p.Number == playerNumber);
+                               if (player != null) {
+                                       analysisWindow.TagPlayer (player);
+                               }
+                       }
+                       inPlayerTagging = false;
+                       this.playerNumber = "";
+               }
+               
                void ReloadHotkeys ()
                {
                        dashboardHotkeys.Clear ();
@@ -66,6 +87,8 @@ namespace LongoMatch.Services
                                if (pendingButton != null) {
                                        analysisWindow.ClickButton (pendingButton);
                                        pendingButton = null;
+                               } else if (inPlayerTagging) {
+                                       TagPlayer ();
                                }
                        });
                }
@@ -80,6 +103,7 @@ namespace LongoMatch.Services
                {
                        this.analysisWindow = analysisWindow;
                        this.capturer = analysisWindow.Capturer;
+                       openedProject = project;
                        if (project == null) {
                                dashboard = null;
                        } else {
@@ -149,31 +173,55 @@ namespace LongoMatch.Services
                        KeyAction action;
                        DashboardButton button;
 
+                       if (openedProject == null) {
+                               return;
+                       }
+
                        try {
                                action = Config.Hotkeys.ActionsHotkeys.GetKeyByValue (key);
                        } catch {
                                return;
                        }
-                       if (action != KeyAction.None) {
-                               /* Keep prevalence of general hotkeys over the dashboard ones */
-                               return;
-                       }
                        
-                       if (dashboardHotkeys.TryGetValue (key, out button)) {
-                               if (button is AnalysisEventButton) {
-                                       AnalysisEventButton evButton = button as AnalysisEventButton;
-                                       /* Finish tagging for the pending button */
-                                       if (pendingButton != null) {
-                                               analysisWindow.ClickButton (button);
+                       if (action == KeyAction.LocalPlayer || action == KeyAction.VisitorPlayer) {
+                               if (inPlayerTagging) {
+                                       TagPlayer ();
+                               }
+                               if (pendingButton != null) {
+                                       analysisWindow.ClickButton (pendingButton);
+                               }
+                               inPlayerTagging = true;
+                               taggedTeam = action == KeyAction.LocalPlayer ? Team.LOCAL : Team.VISITOR;
+                               playerNumber = "";
+                               timer.Change (TIMEOUT_MS, 0);
+                       } else if (action == KeyAction.None) {
+                               if (dashboardHotkeys.TryGetValue (key, out button)) {
+                                       if (inPlayerTagging) {
+                                               TagPlayer ();
                                        }
-                                       if (evButton.AnalysisEventType.Tags.Count == 0) {
-                                               analysisWindow.ClickButton (button);
+                                       if (button is AnalysisEventButton) {
+                                               AnalysisEventButton evButton = button as AnalysisEventButton;
+                                               /* Finish tagging for the pending button */
+                                               if (pendingButton != null) {
+                                                       analysisWindow.ClickButton (pendingButton);
+                                               }
+                                               if (evButton.AnalysisEventType.Tags.Count == 0) {
+                                                       analysisWindow.ClickButton (button);
+                                               } else {
+                                                       pendingButton = evButton;
+                                                       timer.Change (TIMEOUT_MS, 0);
+                                               }
                                        } else {
-                                               pendingButton = evButton;
+                                               analysisWindow.ClickButton (button);
+                                       }
+                               } else if (inPlayerTagging) {
+                                       int number;
+                                       string name = Keyboard.NameFromKeyval ((uint)key.Key);
+                                       if (int.TryParse (name, out number)) {
+                                               playerNumber += number.ToString ();
                                                timer.Change (TIMEOUT_MS, 0);
                                        }
-                               } else {
-                                       analysisWindow.ClickButton (button);
+                                       return;
                                }
                        }
                }


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