[longomatch] Update score when score events are added/removed
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Update score when score events are added/removed
- Date: Wed, 24 Sep 2014 20:30:53 +0000 (UTC)
commit 14905712a66f436370979594789f43e0adbf3912
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Mon Sep 15 17:56:51 2014 +0200
Update score when score events are added/removed
LongoMatch.Core/Store/Project.cs | 34 ++++++++++++++++++++----
LongoMatch.Services/Services/EventsManager.cs | 2 +-
2 files changed, 29 insertions(+), 7 deletions(-)
---
diff --git a/LongoMatch.Core/Store/Project.cs b/LongoMatch.Core/Store/Project.cs
index 2fe04c2..4925fd4 100644
--- a/LongoMatch.Core/Store/Project.cs
+++ b/LongoMatch.Core/Store/Project.cs
@@ -175,6 +175,11 @@ namespace LongoMatch.Core.Store
Timers.Clear();
}
+ public void UpdateScore () {
+ Description.LocalGoals = GetScore (Team.LOCAL);
+ Description.VisitorGoals = GetScore (Team.VISITOR);
+ }
+
public TimelineEvent AddEvent (EventType type, Time start, Time stop, Time eventTime, Image
miniature,
Score score, PenaltyCard card, bool addToTimeline=true)
{
@@ -203,13 +208,20 @@ namespace LongoMatch.Core.Store
evt.Miniature = miniature;
if (addToTimeline) {
- Timeline.Add(evt);
+ Timeline.Add (evt);
+ if (evt is ScoreEvent) {
+ UpdateScore ();
+ }
}
return evt;
}
- public void AddEvent (TimelineEvent play) {
- Timeline.Add(play);
+ public void AddEvent (TimelineEvent play)
+ {
+ Timeline.Add (play);
+ if (play is ScoreEvent) {
+ UpdateScore ();
+ }
}
/// <summary>
@@ -221,9 +233,19 @@ namespace LongoMatch.Core.Store
/// <param name="section">
/// A <see cref="System.Int32"/>: category the play belongs to
/// </param>
- public void RemovePlays(List<TimelineEvent> plays) {
- foreach(TimelineEvent play in plays)
- Timeline.Remove(play);
+ public void RemovePlays (List<TimelineEvent> plays)
+ {
+ bool updateScore = false;
+
+ foreach (TimelineEvent play in plays) {
+ Timeline.Remove (play);
+ if (play is ScoreEvent) {
+ updateScore = true;
+ }
+ }
+ if (updateScore) {
+ UpdateScore ();
+ }
}
public void UpdateEventTypes ()
diff --git a/LongoMatch.Services/Services/EventsManager.cs b/LongoMatch.Services/Services/EventsManager.cs
index ac8c03c..e41be47 100644
--- a/LongoMatch.Services/Services/EventsManager.cs
+++ b/LongoMatch.Services/Services/EventsManager.cs
@@ -277,7 +277,7 @@ namespace LongoMatch.Services
Log.Debug (String.Format ("New play created start:{0} stop:{1} category:{2}",
play.Start.ToMSecondsString(), play.Stop.ToMSecondsString(),
play.EventType.Name));
- openedProject.Timeline.Add (play);
+ openedProject.AddEvent (play);
AddNewPlay (play);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]