[longomatch] Add buttons to tag teams
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add buttons to tag teams
- Date: Wed, 8 Oct 2014 00:13:29 +0000 (UTC)
commit c2c27a1d523fa41cd4952f30401b0e704747cdee
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Wed Oct 8 02:10:24 2014 +0200
Add buttons to tag teams
LongoMatch.Core/Common/EventsBroker.cs | 4 +-
LongoMatch.Core/Handlers/Handlers.cs | 5 +-
LongoMatch.Drawing/CanvasObjects/ButtonObject.cs | 1 +
.../CanvasObjects/PlayersTaggerObject.cs | 101 ++++++++++++++++----
LongoMatch.Drawing/Widgets/DashboardCanvas.cs | 2 +-
LongoMatch.Drawing/Widgets/TeamTagger.cs | 25 +++++-
LongoMatch.GUI/Gui/Component/CodingWidget.cs | 4 +-
LongoMatch.GUI/Gui/Component/DashboardWidget.cs | 4 +-
LongoMatch.GUI/Gui/Dialog/PlayEditor.cs | 9 ++-
LongoMatch.Services/Services/EventsManager.cs | 3 +-
10 files changed, 128 insertions(+), 30 deletions(-)
---
diff --git a/LongoMatch.Core/Common/EventsBroker.cs b/LongoMatch.Core/Common/EventsBroker.cs
index 627aeba..ae06bee 100644
--- a/LongoMatch.Core/Common/EventsBroker.cs
+++ b/LongoMatch.Core/Common/EventsBroker.cs
@@ -89,11 +89,11 @@ namespace LongoMatch.Core.Common
public event DetachPlayerHandler Detach;
public event PlaybackRateChangedHandler PlaybackRateChanged;
- public void EmitNewTag (EventType eventType, List<Player> players = null,
+ public void EmitNewTag (EventType eventType, List<Player> players = null, Team team =
Team.NONE,
List<Tag> tags = null, Time start = null, Time stop = null,
Time eventTime = null, Score score = null, PenaltyCard card = null) {
if (NewTagEvent != null)
- NewTagEvent (eventType, players, tags, start, stop, eventTime, score, card);
+ NewTagEvent (eventType, players, team, tags, start, stop, eventTime, score,
card);
}
public void EmitNewEvent (TimelineEvent evt) {
diff --git a/LongoMatch.Core/Handlers/Handlers.cs b/LongoMatch.Core/Handlers/Handlers.cs
index fa0961b..26ad4e0 100644
--- a/LongoMatch.Core/Handlers/Handlers.cs
+++ b/LongoMatch.Core/Handlers/Handlers.cs
@@ -34,9 +34,9 @@ namespace LongoMatch.Core.Handlers
/* An event was loaded */
public delegate void EventLoadedHandler (TimelineEvent evt);
/* A new play needs to be create for a specific category at the current play time */
- public delegate void NewEventHandler (EventType eventType,List<Player> players,
+ public delegate void NewEventHandler (EventType eventType,List<Player> players, Team team,
List<Tag> tags,Time start,Time stop, Time EventTime,
- Score score, PenaltyCard card);
+ Score score, PenaltyCard card);
/* Add a new play to the current project */
public delegate void NewTimelineEventHandler (TimelineEvent evt);
/* An event was edited */
@@ -110,6 +110,7 @@ namespace LongoMatch.Core.Handlers
/* Players selection */
public delegate void PlayersSubstitutionHandler (TeamTemplate team, Player p1, Player p2,
SubstitutionReason reason, Time time);
public delegate void PlayersSelectionChangedHandler (List<Player> players);
+ public delegate void TeamSelectionChangedHandler (Team team);
/* A list of projects have been selected */
public delegate void ProjectsSelectedHandler (List<ProjectDescription> projects);
public delegate void ProjectSelectedHandler (ProjectDescription project);
diff --git a/LongoMatch.Drawing/CanvasObjects/ButtonObject.cs
b/LongoMatch.Drawing/CanvasObjects/ButtonObject.cs
index 157eb10..8c9c779 100644
--- a/LongoMatch.Drawing/CanvasObjects/ButtonObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/ButtonObject.cs
@@ -196,6 +196,7 @@ namespace LongoMatch.Drawing.CanvasObjects
if (Text != null) {
tk.FillColor = TextColor;
tk.StrokeColor = TextColor;
+ tk.FontAlignment = FontAlignment.Center;
tk.DrawText (DrawPosition, Width, Height, Text);
}
}
diff --git a/LongoMatch.Drawing/CanvasObjects/PlayersTaggerObject.cs
b/LongoMatch.Drawing/CanvasObjects/PlayersTaggerObject.cs
index c07485c..9faaa6a 100644
--- a/LongoMatch.Drawing/CanvasObjects/PlayersTaggerObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/PlayersTaggerObject.cs
@@ -38,9 +38,10 @@ namespace LongoMatch.Drawing.CanvasObjects
*/
public event PlayersSubstitutionHandler PlayersSubstitutionEvent;
public event PlayersSelectionChangedHandler PlayersSelectionChangedEvent;
+ public event TeamSelectionChangedHandler TeamSelectionChangedEvent;
const int SUBSTITUTION_BUTTONS_HEIGHT = 40;
const int SUBSTITUTION_BUTTONS_WIDTH = 60;
- ButtonObject subPlayers, subInjury;
+ ButtonObject subPlayers, subInjury, homeButton, awayButton;
TeamTemplate homeTeam, awayTeam;
Image background;
Dictionary<Player, PlayerObject> playerToPlayerObject;
@@ -53,7 +54,7 @@ namespace LongoMatch.Drawing.CanvasObjects
FieldObject field;
int NTeams;
Point offset;
- bool substitutionMode;
+ bool substitutionMode, showSubsitutionButtons, showTeamsButtons;
double scaleX, scaleY;
Time lastTime, currentTime;
@@ -69,6 +70,9 @@ namespace LongoMatch.Drawing.CanvasObjects
SelectedPlayers = new List<Player> ();
lastTime = null;
LoadSubsButtons ();
+ LoadTeamsButtons ();
+ ShowSubsitutionButtons = false;
+ ShowTeamsButtons = false;
}
protected override void Dispose (bool disposing)
@@ -148,13 +152,26 @@ namespace LongoMatch.Drawing.CanvasObjects
}
public bool ShowSubsitutionButtons {
- get;
- set;
+ get {
+ return showSubsitutionButtons;
+ }
+ set {
+ subPlayers.Visible = value;
+ /* FIXME: Not displayed for now */
+ subInjury.Visible = false;
+ showSubsitutionButtons = value;
+ }
}
- public bool ShowInjurySubsitutionButton {
- get;
- set;
+ public bool ShowTeamsButtons {
+ get {
+ return showTeamsButtons;
+ }
+ set {
+ showTeamsButtons = value;
+ homeButton.Visible = value;
+ awayButton.Visible = value;
+ }
}
public List<Player> SelectedPlayers {
@@ -162,6 +179,20 @@ namespace LongoMatch.Drawing.CanvasObjects
set;
}
+ public Team SelectedTeam {
+ get {
+ if (homeButton.Active && awayButton.Active) {
+ return Team.BOTH;
+ } else if (homeButton.Active) {
+ return Team.LOCAL;
+ } else if (awayButton.Active) {
+ return Team.VISITOR;
+ } else {
+ return Team.NONE;
+ }
+ }
+ }
+
public void Reload ()
{
LoadTeams (homeTeam, awayTeam, background);
@@ -174,12 +205,14 @@ namespace LongoMatch.Drawing.CanvasObjects
field.Update ();
}
- public void Select (List<Player> players)
+ public void Select (List<Player> players, Team team)
{
ResetSelection ();
foreach (Player p in players) {
Select (p, true);
}
+ homeButton.Active = team == Team.BOTH || team == Team.LOCAL;
+ awayButton.Active = team == Team.BOTH || team == Team.VISITOR;
if (PlayersSelectionChangedEvent != null) {
PlayersSelectionChangedEvent (SelectedPlayers);
}
@@ -219,6 +252,8 @@ namespace LongoMatch.Drawing.CanvasObjects
player.Active = false;
}
}
+ homeButton.Active = false;
+ awayButton.Active = false;
}
public void Substitute (Player p1, Player p2, TeamTemplate team)
@@ -264,6 +299,7 @@ namespace LongoMatch.Drawing.CanvasObjects
homePlayers.AddRange (homePlayingPlayers);
homePlayers.AddRange (homeBenchPlayers);
homeF = homeTeam.Formation;
+ homeButton.BackgroundImage = homeTeam.Shield;
NTeams ++;
}
if (awayTeam != null) {
@@ -272,6 +308,7 @@ namespace LongoMatch.Drawing.CanvasObjects
awayPlayers.AddRange (awayPlayingPlayers);
awayPlayers.AddRange (awayBenchPlayers);
awayF = awayTeam.Formation;
+ awayButton.BackgroundImage = awayTeam.Shield;
NTeams ++;
}
@@ -361,16 +398,33 @@ namespace LongoMatch.Drawing.CanvasObjects
subPlayers = new ButtonObject ();
string path = Path.Combine (Config.IconsDir, StyleConf.SubsUnlock);
subPlayers.BackgroundImageActive = Image.LoadFromFile (path);
+ subPlayers.BackgroundColorActive = Config.Style.PaletteBackground;
path = Path.Combine (Config.IconsDir, StyleConf.SubsLock);
subPlayers.BackgroundImage = Image.LoadFromFile (path);
subPlayers.Toggle = true;
subPlayers.ClickedEvent += HandleSubsClicked;
subInjury = new ButtonObject ();
+ subInjury.BackgroundColorActive = Config.Style.PaletteBackground;
subInjury.Toggle = true;
subInjury.ClickedEvent += HandleSubsClicked;
subInjury.Visible = false;
}
+ void LoadTeamsButtons () {
+ homeButton = new ButtonObject ();
+ homeButton.Toggle = true;
+ homeButton.ClickedEvent += HandleTeamClickedEvent;
+ homeButton.Width = SUBSTITUTION_BUTTONS_WIDTH * 2 - 2;
+ homeButton.Height = SUBSTITUTION_BUTTONS_HEIGHT - 1;
+ homeButton.RedrawEvent += (co, area) => {EmitRedrawEvent (homeButton, area);};
+ awayButton = new ButtonObject ();
+ awayButton.Toggle = true;
+ awayButton.Width = SUBSTITUTION_BUTTONS_WIDTH * 2 - 2;
+ awayButton.Height = SUBSTITUTION_BUTTONS_HEIGHT - 1;
+ awayButton.ClickedEvent += HandleTeamClickedEvent;
+ awayButton.RedrawEvent += (co, area) => {EmitRedrawEvent (awayButton, area);};
+ }
+
void Substitute (PlayerObject p1, PlayerObject p2,
List<PlayerObject> playingPlayers,
List<PlayerObject> benchPlayers)
@@ -449,7 +503,7 @@ namespace LongoMatch.Drawing.CanvasObjects
Team = team,
};
po.ClickedEvent += HandlePlayerClickedEvent;
- po.RedrawEvent += (co, area) => {EmitRedrawEvent (this, area);};
+ po.RedrawEvent += (co, area) => {EmitRedrawEvent (po, area);};
playerObjects.Add (po);
playerToPlayerObject.Add (p, po);
}
@@ -516,7 +570,7 @@ namespace LongoMatch.Drawing.CanvasObjects
{
Selection sel;
- if (!ShowSubsitutionButtons) {
+ if (!ShowSubsitutionButtons && !ShowTeamsButtons) {
return false;
}
@@ -542,11 +596,18 @@ namespace LongoMatch.Drawing.CanvasObjects
SubstitutionMode = !SubstitutionMode;
}
+ void HandleTeamClickedEvent (ICanvasObject co)
+ {
+ if (TeamSelectionChangedEvent != null)
+ TeamSelectionChangedEvent (SelectedTeam);
+ }
+
public override void ClickPressed (Point point, ButtonModifier modif)
{
Selection selection = null;
- if (ButtonClickPressed (point, modif, subPlayers, subInjury)) {
+ if (ButtonClickPressed (point, modif, subPlayers, subInjury,
+ homeButton, awayButton)) {
return;
}
@@ -609,20 +670,24 @@ namespace LongoMatch.Drawing.CanvasObjects
tk.Clear (Config.Style.PaletteBackground);
/* Draw substitution buttons */
- if (ShowSubsitutionButtons) {
+ if (subPlayers.Visible) {
subPlayers.Position = new Point (Width / 2 - SUBSTITUTION_BUTTONS_WIDTH / 2,
offset.Y - SUBSTITUTION_BUTTONS_HEIGHT);
subPlayers.Width = SUBSTITUTION_BUTTONS_WIDTH;
subPlayers.Height = SUBSTITUTION_BUTTONS_HEIGHT;
subPlayers.Draw (tk, area);
-
- //subInjury.Position = new Point (100, 0);
- //subInjury.Width = 100;
- //subInjury.Height = SUBSTITUTION_BUTTONS_HEIGHT;
- //subInjury.Draw (tk, area);
+ }
+ if (homeButton.Visible) {
+ /* Draw local team button */
+ homeButton.Position = new Point (Position.X + offset.X, offset.Y -
homeButton.Height);
+ homeButton.Draw (tk, area);
+ }
+ if (awayButton.Visible) {
+ awayButton.Position = new Point ((Position.X + Width - offset.X) -
awayButton.Width,
+ offset.Y - awayButton.Height);
+ awayButton.Draw (tk, area);
}
-
tk.TranslateAndScale (Position + offset, new Point (scaleX, scaleY));
homeBench.Draw (tk, area);
awayBench.Draw (tk, area);
diff --git a/LongoMatch.Drawing/Widgets/DashboardCanvas.cs b/LongoMatch.Drawing/Widgets/DashboardCanvas.cs
index 517bef6..2ed8a15 100644
--- a/LongoMatch.Drawing/Widgets/DashboardCanvas.cs
+++ b/LongoMatch.Drawing/Widgets/DashboardCanvas.cs
@@ -334,7 +334,7 @@ namespace LongoMatch.Drawing.Widgets
score = (button as ScoreButton).Score;
}
- NewTagEvent (button.EventType, null, tags, start, stop, eventTime, score, card);
+ NewTagEvent (button.EventType, null, Team.NONE, tags, start, stop, eventTime, score,
card);
}
}
}
diff --git a/LongoMatch.Drawing/Widgets/TeamTagger.cs b/LongoMatch.Drawing/Widgets/TeamTagger.cs
index e183177..0118141 100644
--- a/LongoMatch.Drawing/Widgets/TeamTagger.cs
+++ b/LongoMatch.Drawing/Widgets/TeamTagger.cs
@@ -33,6 +33,7 @@ namespace LongoMatch.Drawing.Widgets
{
public event PlayersSelectionChangedHandler PlayersSelectionChangedEvent;
+ public event TeamSelectionChangedHandler TeamSelectionChangedEvent;
public event PlayersSubstitutionHandler PlayersSubstitutionEvent;
public event PlayersPropertiesHandler ShowMenuEvent;
PlayersTaggerObject tagger;
@@ -45,6 +46,7 @@ namespace LongoMatch.Drawing.Widgets
tagger.SelectionMode = MultiSelectionMode.Single;
tagger.PlayersSubstitutionEvent += HandlePlayersSubstitutionEvent;
tagger.PlayersSelectionChangedEvent += HandlePlayersSelectionChangedEvent;
+ tagger.TeamSelectionChangedEvent += HandleTeamSelectionChangedEvent;
ShowSubstitutionButtons = true;
ObjectsCanMove = false;
AddObject (tagger);
@@ -97,6 +99,12 @@ namespace LongoMatch.Drawing.Widgets
tagger.ShowSubsitutionButtons = value;
}
}
+
+ public bool ShowTeamsButtons {
+ set {
+ tagger.ShowTeamsButtons = value;
+ }
+ }
public new MultiSelectionMode SelectionMode {
set {
@@ -104,14 +112,20 @@ namespace LongoMatch.Drawing.Widgets
}
}
+ public Team SelectedTeam {
+ get {
+ return tagger.SelectedTeam;
+ }
+ }
+
public void ResetSelection ()
{
tagger.ResetSelection ();
}
- public void Select (List<Player> players)
+ public void Select (List<Player> players, Team team)
{
- tagger.Select (players);
+ tagger.Select (players, team);
}
public void Select (Player p)
@@ -162,6 +176,13 @@ namespace LongoMatch.Drawing.Widgets
PlayersSelectionChangedEvent (players);
}
}
+
+ void HandleTeamSelectionChangedEvent (Team team)
+ {
+ if (TeamSelectionChangedEvent != null) {
+ TeamSelectionChangedEvent (team);
+ }
+ }
}
}
diff --git a/LongoMatch.GUI/Gui/Component/CodingWidget.cs b/LongoMatch.GUI/Gui/Component/CodingWidget.cs
index 91c33c2..354e984 100644
--- a/LongoMatch.GUI/Gui/Component/CodingWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/CodingWidget.cs
@@ -66,6 +66,7 @@ namespace LongoMatch.Gui.Component
teamtagger.PlayersSelectionChangedEvent += HandlePlayersSelectionChangedEvent;
teamtagger.PlayersSubstitutionEvent += HandlePlayersSubstitutionEvent;
teamtagger.Compact = true;
+ teamtagger.ShowTeamsButtons = true;
teamsdrawingarea.HeightRequest = 200;
teamsdrawingarea.WidthRequest = 300;
@@ -253,10 +254,11 @@ namespace LongoMatch.Gui.Component
selectedPlayers = players.ToList();
}
- void HandleNewTagEvent (EventType eventType, List<Player> players, List<Tag> tags,
+ void HandleNewTagEvent (EventType eventType, List<Player> players, Team team, List<Tag> tags,
Time start, Time stop, Time eventTime, Score score, PenaltyCard card)
{
TimelineEvent play = project.AddEvent (eventType, start, stop, eventTime, null,
score, card, false);
+ play.Team = teamtagger.SelectedTeam;
play.Players = selectedPlayers ?? new List<Player> ();
play.Tags = tags ?? new List<Tag> ();
if (eventType.TagFieldPosition || eventType.TagGoalPosition ||
eventType.TagHalfFieldPosition) {
diff --git a/LongoMatch.GUI/Gui/Component/DashboardWidget.cs b/LongoMatch.GUI/Gui/Component/DashboardWidget.cs
index 8025792..111ad2b 100644
--- a/LongoMatch.GUI/Gui/Component/DashboardWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/DashboardWidget.cs
@@ -389,12 +389,12 @@ namespace LongoMatch.Gui.Component
}
}
- void HandleNewTagEvent (EventType evntType, List<Player> players, List<Tag> tags,
+ void HandleNewTagEvent (EventType evntType, List<Player> players, Team team, List<Tag> tags,
Time start, Time stop, Time eventTime, Score score, PenaltyCard card)
{
/* Forward event until we have players integrted in the dashboard layout */
if (NewTagEvent != null) {
- NewTagEvent (evntType , players, tags, start, stop, eventTime, score, card);
+ NewTagEvent (evntType , players, team, tags, start, stop, eventTime, score,
card);
}
//Config.EventsBroker.EmitNewTag (button, players, tags, start, stop);
}
diff --git a/LongoMatch.GUI/Gui/Dialog/PlayEditor.cs b/LongoMatch.GUI/Gui/Dialog/PlayEditor.cs
index 58c5b34..902b882 100644
--- a/LongoMatch.GUI/Gui/Dialog/PlayEditor.cs
+++ b/LongoMatch.GUI/Gui/Dialog/PlayEditor.cs
@@ -40,6 +40,8 @@ namespace LongoMatch.Gui.Dialog
teamtagger.ShowSubstitutionButtons = false;
teamtagger.SelectionMode = MultiSelectionMode.Multiple;
teamtagger.PlayersSelectionChangedEvent += HandlePlayersSelectionChangedEvent;
+ teamtagger.TeamSelectionChangedEvent += HandleTeamSelectionChangedEvent;
+ teamtagger.ShowTeamsButtons = true;
nameentry.Changed += HandleChanged;
}
@@ -73,7 +75,7 @@ namespace LongoMatch.Gui.Dialog
if (editPlayers) {
teamtagger.LoadTeams (project.LocalTeamTemplate, project.VisitorTeamTemplate,
project.Dashboard.FieldBackground);
- teamtagger.Select (play.Players);
+ teamtagger.Select (play.Players, play.Team);
}
if (editTags) {
@@ -127,5 +129,10 @@ namespace LongoMatch.Gui.Dialog
{
play.Players = players.ToList ();
}
+
+ void HandleTeamSelectionChangedEvent (Team team)
+ {
+ play.Team = team;
+ }
}
}
diff --git a/LongoMatch.Services/Services/EventsManager.cs b/LongoMatch.Services/Services/EventsManager.cs
index a67fad9..fa09382 100644
--- a/LongoMatch.Services/Services/EventsManager.cs
+++ b/LongoMatch.Services/Services/EventsManager.cs
@@ -253,7 +253,7 @@ namespace LongoMatch.Services
}
}
- public void OnNewTag (EventType evType, List<Player> players, List<Tag> tags,
+ public void OnNewTag (EventType evType, List<Player> players, Team team, List<Tag> tags,
Time start, Time stop, Time eventTime, Score score, PenaltyCard card)
{
if (player == null || openedProject == null)
@@ -271,6 +271,7 @@ namespace LongoMatch.Services
evType.Name));
/* Add the new created play to the project and update the GUI*/
var play = openedProject.AddEvent (evType, start, stop, eventTime, null, score, card);
+ play.Team = team;
if (players != null) {
play.Players = players;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]