[longomatch] WIP
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] WIP
- Date: Mon, 7 Jul 2014 17:32:30 +0000 (UTC)
commit 3090344d2d455adbf56f0b564db1337561d54bc7
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Mon Jul 7 17:50:46 2014 +0200
WIP
LongoMatch.Core/Common/Enums.cs | 6 ++
LongoMatch.Core/LongoMatch.Core.mdp | 5 +-
LongoMatch.Core/Store/PenaltyCard.cs | 53 ++++++++++++++
LongoMatch.Core/Store/PenaltyCardEvent.cs | 34 +++++++++
LongoMatch.Core/Store/Project.cs | 39 +++++++++++
LongoMatch.Core/Store/Score.cs | 45 ++++++++++++
LongoMatch.Core/Store/ScoreEvent.cs | 35 +++++++++
.../Store/Templates/CategoriesTemplate.cs | 12 +++
LongoMatch.Core/Utils.cs | 73 --------------------
LongoMatch.GUI.Helpers/Misc.cs | 46 ++++++++++++
LongoMatch.mds | 4 -
11 files changed, 274 insertions(+), 78 deletions(-)
---
diff --git a/LongoMatch.Core/Common/Enums.cs b/LongoMatch.Core/Common/Enums.cs
index 04ac254..673327a 100644
--- a/LongoMatch.Core/Common/Enums.cs
+++ b/LongoMatch.Core/Common/Enums.cs
@@ -230,5 +230,11 @@ namespace LongoMatch.Common
HalfField,
Goal
}
+
+ public enum CardShape {
+ Rectangle,
+ Triangle,
+ Circle
+ }
}
diff --git a/LongoMatch.Core/LongoMatch.Core.mdp b/LongoMatch.Core/LongoMatch.Core.mdp
index f5d45f4..975de9c 100644
--- a/LongoMatch.Core/LongoMatch.Core.mdp
+++ b/LongoMatch.Core/LongoMatch.Core.mdp
@@ -101,7 +101,6 @@
<File subtype="Code" buildaction="EmbedAsResource" name="../images/field_background.svg" />
<File subtype="Code" buildaction="EmbedAsResource" name="../images/goal_background.svg" />
<File subtype="Code" buildaction="EmbedAsResource" name="../images/half_field_background.svg" />
- <File subtype="Code" buildaction="Compile" name="Utils.cs" />
<File subtype="Code" buildaction="Compile" name="Interfaces/GUI/IPanel.cs" />
<File subtype="Code" buildaction="Compile" name="Interfaces/Multimedia/ICapturer.cs" />
<File subtype="Code" buildaction="Compile" name="Interfaces/Multimedia/IPlayer.cs" />
@@ -139,6 +138,10 @@
<File subtype="Code" buildaction="Compile" name="Store/Drawables/Counter.cs" />
<File subtype="Directory" buildaction="Compile" name="Interfaces" />
<File subtype="Code" buildaction="Compile" name="Interfaces/IProjectsImporter.cs" />
+ <File subtype="Code" buildaction="Compile" name="Store/Score.cs" />
+ <File subtype="Code" buildaction="Compile" name="Store/ScoreEvent.cs" />
+ <File subtype="Code" buildaction="Compile" name="Store/PenaltyCard.cs" />
+ <File subtype="Code" buildaction="Compile" name="Store/PenaltyCardEvent.cs" />
</Contents>
<References>
<ProjectReference type="Package" localcopy="True" refto="System, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />
diff --git a/LongoMatch.Core/Store/PenaltyCard.cs b/LongoMatch.Core/Store/PenaltyCard.cs
new file mode 100644
index 0000000..623fda5
--- /dev/null
+++ b/LongoMatch.Core/Store/PenaltyCard.cs
@@ -0,0 +1,53 @@
+//
+// Copyright (C) 2014 Andoni Morales Alastruey
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+using System;
+using LongoMatch.Common;
+
+namespace LongoMatch.Store
+{
+ public class PenaltyCard
+ {
+ public PenaltyCard ()
+ {
+ }
+
+ public PenaltyCard (string name, Color color, CardShape shape)
+ {
+ Name = name;
+ Color = color;
+ Shape = shape;
+ }
+
+ public string Name {
+ get;
+ set;
+ }
+
+ public Color Color {
+ get;
+ set;
+ }
+
+ public CardShape Shape {
+ get;
+ set;
+ }
+
+ }
+}
+
diff --git a/LongoMatch.Core/Store/PenaltyCardEvent.cs b/LongoMatch.Core/Store/PenaltyCardEvent.cs
new file mode 100644
index 0000000..a0e8524
--- /dev/null
+++ b/LongoMatch.Core/Store/PenaltyCardEvent.cs
@@ -0,0 +1,34 @@
+//
+// Copyright (C) 2014 Andoni Morales Alastruey
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+using System;
+
+namespace LongoMatch.Store
+{
+ public class PenaltyCardEvent: Play
+ {
+ public PenaltyCardEvent ()
+ {
+ }
+
+ public PenaltyCard PenaltyCard {
+ get;
+ set;
+ }
+ }
+}
+
diff --git a/LongoMatch.Core/Store/Project.cs b/LongoMatch.Core/Store/Project.cs
index 85f28c0..4320b93 100644
--- a/LongoMatch.Core/Store/Project.cs
+++ b/LongoMatch.Core/Store/Project.cs
@@ -58,6 +58,8 @@ namespace LongoMatch.Store
VisitorTeamTemplate = new TeamTemplate();
Timers = new List<Timer> ();
Periods = new List<Period> ();
+ ScoreTimeline = new List<ScoreEvent>();
+ PenaltyCardsTimeline = new List<PenaltyCardEvent> ();
}
#endregion
@@ -76,6 +78,16 @@ namespace LongoMatch.Store
set;
}
+ public List<ScoreEvent> ScoreTimeline {
+ get;
+ set;
+ }
+
+ public List<PenaltyCardEvent> PenaltyCardsTimeline {
+ get;
+ set;
+ }
+
public ProjectDescription Description {
get{
return description;
@@ -235,6 +247,33 @@ namespace LongoMatch.Store
public List<Play> PlaysInCategory(Category category) {
return Timeline.Where(p => p.Category.ID == category.ID).ToList();
}
+
+ public int GetScore (Team team) {
+ return ScoreTimeline.Where (s => PlayTaggedTeam (s) == team).Sum(s =>
s.Score.Points);
+ }
+
+ public Team PlayTaggedTeam (Play play) {
+ bool home=false, away=false;
+
+ if (play.Team == Team.LOCAL || play.Team == Team.BOTH ||
+ play.Players.Count (p => LocalTeamTemplate.List.Contains (p)) > 0) {
+ home = true;
+ }
+ if (play.Team == Team.VISITOR || play.Team == Team.BOTH ||
+ play.Players.Count (p => VisitorTeamTemplate.List.Contains (p)) > 0) {
+ away = true;
+ }
+
+ if (away && home) {
+ return Team.BOTH;
+ } else if (home) {
+ return Team.LOCAL;
+ } else if (away) {
+ return Team.VISITOR;
+ } else {
+ return Team.NONE;
+ }
+ }
public Image GetBackground (FieldPositionType pos) {
switch (pos) {
diff --git a/LongoMatch.Core/Store/Score.cs b/LongoMatch.Core/Store/Score.cs
new file mode 100644
index 0000000..e569971
--- /dev/null
+++ b/LongoMatch.Core/Store/Score.cs
@@ -0,0 +1,45 @@
+//
+// Copyright (C) 2014 Andoni Morales Alastruey
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+using System;
+
+namespace LongoMatch.Store
+{
+ [Serializable]
+ public class Score
+ {
+ public Score ()
+ {
+ }
+
+ public Score (string name, int points)
+ {
+ Name = name;
+ Points = points;
+ }
+
+ public string Name {
+ get;
+ set;
+ }
+
+ public int Points {
+ get;
+ set;
+ }
+ }
+}
diff --git a/LongoMatch.Core/Store/ScoreEvent.cs b/LongoMatch.Core/Store/ScoreEvent.cs
new file mode 100644
index 0000000..b9c6bac
--- /dev/null
+++ b/LongoMatch.Core/Store/ScoreEvent.cs
@@ -0,0 +1,35 @@
+//
+// Copyright (C) 2014 Andoni Morales Alastruey
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+using System;
+
+namespace LongoMatch.Store
+{
+ [Serializable]
+ public class ScoreEvent: Play
+ {
+ public ScoreEvent ()
+ {
+ }
+
+ public Score Score {
+ get;
+ set;
+ }
+ }
+}
+
diff --git a/LongoMatch.Core/Store/Templates/CategoriesTemplate.cs
b/LongoMatch.Core/Store/Templates/CategoriesTemplate.cs
index 21684a4..dca7bf5 100644
--- a/LongoMatch.Core/Store/Templates/CategoriesTemplate.cs
+++ b/LongoMatch.Core/Store/Templates/CategoriesTemplate.cs
@@ -52,6 +52,8 @@ namespace LongoMatch.Store.Templates
GoalBackground = Config.GoalBackground;
ID = Guid.NewGuid ();
List = new List<Category>();
+ Scores = new List<Score> ();
+ PenaltyCards = new List<PenaltyCard> ();
}
public Guid ID {
@@ -74,6 +76,16 @@ namespace LongoMatch.Store.Templates
set;
}
+ public List<Score> Scores {
+ get;
+ set;
+ }
+
+ public List<PenaltyCard> PenaltyCards {
+ get;
+ set;
+ }
+
public Image Image {
get;
set;
diff --git a/LongoMatch.GUI.Helpers/Misc.cs b/LongoMatch.GUI.Helpers/Misc.cs
index c6a82c7..0c9b4e8 100644
--- a/LongoMatch.GUI.Helpers/Misc.cs
+++ b/LongoMatch.GUI.Helpers/Misc.cs
@@ -26,6 +26,9 @@ using LongoMatch.Common;
using LColor = LongoMatch.Common.Color;
using Color = Gdk.Color;
using System.Collections.Generic;
+using LongoMatch.Store;
+using LongoMatch.Interfaces.GUI;
+using LongoMatch.Interfaces.Multimedia;
namespace LongoMatch.Gui.Helpers
{
@@ -207,6 +210,49 @@ namespace LongoMatch.Gui.Helpers
}
}
}
+
+ public static MediaFile OpenFile (object parent) {
+ IBusyDialog busy = null;
+ MediaFile mediaFile = null;
+ IGUIToolkit gui = Config.GUIToolkit;
+ IMultimediaToolkit multimedia = Config.MultimediaToolkit;
+ string folder, filename;
+
+
+ folder = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal);
+ filename = gui.OpenFile (Catalog.GetString("Open file"), null, folder);
+ if (filename == null)
+ return null;
+
+ try {
+ busy = gui.BusyDialog (Catalog.GetString("Analyzing video
file:")+"\n"+filename,
+ parent);
+ busy.Show ();
+ mediaFile = multimedia.DiscoverFile (filename);
+ busy.Destroy ();
+
+ if(!mediaFile.HasVideo || mediaFile.VideoCodec == "")
+ throw new Exception(Catalog.GetString("This file doesn't contain a
video stream."));
+ if(mediaFile.HasVideo && mediaFile.Duration.MSeconds == 0)
+ throw new Exception(Catalog.GetString("This file contains a video
stream but its length is 0."));
+ if (multimedia.FileNeedsRemux (mediaFile)) {
+ string q = Catalog.GetString("The file you are trying to load is not
properly supported. " +
+ "Would you like to convert it
into a more suitable format?");
+ if (gui.QuestionMessage (q, Catalog.GetString ("Convert"), null)) {
+ string newFilename = multimedia.RemuxFile (mediaFile, parent);
+ if (newFilename != null)
+ mediaFile = multimedia.DiscoverFile (newFilename);
+ }
+ }
+ }
+ catch(Exception ex) {
+ busy.Destroy ();
+ gui.ErrorMessage (ex.Message, parent);
+ return null;
+ }
+
+ return mediaFile;
+ }
}
}
diff --git a/LongoMatch.mds b/LongoMatch.mds
index ab004bd..2a8bbf4 100644
--- a/LongoMatch.mds
+++ b/LongoMatch.mds
@@ -32,7 +32,6 @@
<Entry build="True" name="LongoMatch.GUI.Helpers" configuration="Debug" />
<Entry build="True" name="LongoMatch.Drawing" configuration="Debug" />
<Entry build="True" name="LongoMatch.Drawing.Cairo" configuration="Debug" />
- <Entry build="True" name="LongoMatch.Addins.RFEBM" configuration="Debug" />
<Entry build="True" name="LongoMatch.Migration" configuration="Debug" />
</Configuration>
<Configuration name="Release" ctype="CombineConfiguration">
@@ -50,7 +49,6 @@
<Entry build="True" name="LongoMatch.GUI.Helpers" configuration="Release" />
<Entry build="True" name="LongoMatch.Drawing" configuration="Release" />
<Entry build="True" name="LongoMatch.Drawing.Cairo" configuration="Release" />
- <Entry build="True" name="LongoMatch.Addins.RFEBM" configuration="Release" />
<Entry build="True" name="LongoMatch.Migration" configuration="Release" />
</Configuration>
</Configurations>
@@ -69,7 +67,6 @@
<Execute type="None" entry="LongoMatch.GUI.Helpers" />
<Execute type="None" entry="LongoMatch.Drawing" />
<Execute type="None" entry="LongoMatch.Drawing.Cairo" />
- <Execute type="None" entry="LongoMatch.Addins.RFEBM" />
<Execute type="None" entry="LongoMatch.Migration" />
</StartMode>
<Entries>
@@ -87,7 +84,6 @@
<Entry filename="LongoMatch.GUI.Helpers/LongoMatch.GUI.Helpers.mdp" />
<Entry filename="LongoMatch.Drawing/LongoMatch.Drawing.mdp" />
<Entry filename="LongoMatch.Drawing.Cairo/LongoMatch.Drawing.Cairo.mdp" />
- <Entry filename="LongoMatch.Addins.RFEBM/LongoMatch.Addins.RFEBM.mdp" />
<Entry filename="LongoMatch.Migration/LongoMatch.Migration.mdp" />
</Entries>
</Combine>
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]