[longomatch] Fix deserialization of 0.18.11 templates



commit 637094cdc477e77b669c63d89df4eff94c2be930
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Mon Aug 5 23:21:59 2013 +0200

    Fix deserialization of 0.18.11 templates

 LongoMatch.Core/Stats/ProjectStats.cs              |    6 +++---
 .../Store/Templates/CategoriesTemplate.cs          |   11 ++++++++---
 .../Gui/Component/CategoriesTemplateEditor.cs      |   18 +++++++++---------
 LongoMatch.GUI/Gui/Dialog/TaggerDialog.cs          |    6 +++---
 LongoMatch.GUI/Gui/MainWindow.cs                   |    6 +++---
 5 files changed, 26 insertions(+), 21 deletions(-)
---
diff --git a/LongoMatch.Core/Stats/ProjectStats.cs b/LongoMatch.Core/Stats/ProjectStats.cs
index 087aaae..a85543a 100644
--- a/LongoMatch.Core/Stats/ProjectStats.cs
+++ b/LongoMatch.Core/Stats/ProjectStats.cs
@@ -115,9 +115,9 @@ namespace LongoMatch.Stats
                                awayPlays =plays.Where(p => p.Team == Team.VISITOR || p.Team == 
Team.BOTH).ToList();
                                stats = new CategoryStats(cat, plays.Count, homePlays.Count(), 
awayPlays.Count());
                                /* Fill zonal tagging stats */
-                               stats.Field = project.Categories.FieldBackgroundImage;
-                               stats.HalfField = project.Categories.HalfFieldBackgroundImage;
-                               stats.Goal = project.Categories.GoalBackgroundImage;
+                               stats.Field = project.Categories.FieldBackground;
+                               stats.HalfField = project.Categories.HalfFieldBackground;
+                               stats.Goal = project.Categories.GoalBackground;
                                stats.FieldCoordinates = plays.Select (p => p.FieldPosition).Where(p =>p != 
null).ToList();
                                stats.HalfFieldCoordinates = plays.Select (p => p.HalfFieldPosition).Where(p 
=>p != null).ToList();
                                stats.GoalCoordinates = plays.Select (p => p.GoalPosition).Where(p =>p != 
null).ToList();
diff --git a/LongoMatch.Core/Store/Templates/CategoriesTemplate.cs 
b/LongoMatch.Core/Store/Templates/CategoriesTemplate.cs
index 7cf42f4..85f2535 100644
--- a/LongoMatch.Core/Store/Templates/CategoriesTemplate.cs
+++ b/LongoMatch.Core/Store/Templates/CategoriesTemplate.cs
@@ -80,7 +80,12 @@ namespace LongoMatch.Store.Templates
                        set;
                }
                
-               public Image FieldBackgroundImage {
+               /* Keep this for backwards compatiblity with 0.18.11 */
+               public Image FieldBackgroundImage {get; set;}
+               public Image HalfFieldBackgroundImage {get; set;}
+               public Image GoalBackgroundImage {get; set;}
+
+               public Image FieldBackground {
                        get {
                                if(fieldImage != null)
                                        return Image.Deserialize(fieldImage);
@@ -92,7 +97,7 @@ namespace LongoMatch.Store.Templates
                        }
                }
                
-               public Image HalfFieldBackgroundImage {
+               public Image HalfFieldBackground {
                        get {
                                if(halfFieldImage != null)
                                        return Image.Deserialize(halfFieldImage);
@@ -104,7 +109,7 @@ namespace LongoMatch.Store.Templates
                        }
                }
                
-               public Image GoalBackgroundImage {
+               public Image GoalBackground {
                        get {
                                if(goalImage != null)
                                        return Image.Deserialize(goalImage);
diff --git a/LongoMatch.GUI/Gui/Component/CategoriesTemplateEditor.cs 
b/LongoMatch.GUI/Gui/Component/CategoriesTemplateEditor.cs
index ebdc8d5..b52fa62 100644
--- a/LongoMatch.GUI/Gui/Component/CategoriesTemplateEditor.cs
+++ b/LongoMatch.GUI/Gui/Component/CategoriesTemplateEditor.cs
@@ -81,24 +81,24 @@ namespace LongoMatch.Gui.Component
                                categoriestreeview.Model = categoriesListStore;
                                ButtonsSensitive = false;
                                gameUnitsEditor.SetRootGameUnit(value.GameUnits);
-                               if (template.GoalBackgroundImage != null) {
-                                       goalImage.Pixbuf = template.GoalBackgroundImage.Value;
+                               if (template.GoalBackground != null) {
+                                       goalImage.Pixbuf = template.GoalBackground.Value;
                                } else {
                                        Image img = new Image (
                                                Gdk.Pixbuf.LoadFromResource (Constants.GOAL_BACKGROUND));
                                        img.Scale();
                                        goalImage.Pixbuf = img.Value; 
                                }
-                               if (template.FieldBackgroundImage != null) {
-                                       fieldImage.Pixbuf = template.FieldBackgroundImage.Value;
+                               if (template.FieldBackground != null) {
+                                       fieldImage.Pixbuf = template.FieldBackground.Value;
                                } else {
                                        Image img = new Image (
                                                Gdk.Pixbuf.LoadFromResource (Constants.FIELD_BACKGROUND));
                                        img.Scale();
                                        fieldImage.Pixbuf = img.Value; 
                                }
-                               if (template.HalfFieldBackgroundImage != null) {
-                                       halffieldImage.Pixbuf = template.HalfFieldBackgroundImage.Value;
+                               if (template.HalfFieldBackground != null) {
+                                       halffieldImage.Pixbuf = template.HalfFieldBackground.Value;
                                } else {
                                        Image img = new Image (
                                                Gdk.Pixbuf.LoadFromResource 
(Constants.HALF_FIELD_BACKGROUND));
@@ -245,7 +245,7 @@ namespace LongoMatch.Gui.Component
                        if (background != null) {
                                Image img = new Image(background);
                                img.Scale();
-                               Template.GoalBackgroundImage = img; 
+                               Template.GoalBackground = img; 
                                goalImage.Pixbuf = img.Value;
                        }
                }
@@ -258,7 +258,7 @@ namespace LongoMatch.Gui.Component
                        if (background != null) {
                                Image img = new Image(background);
                                img.Scale();
-                               Template.HalfFieldBackgroundImage = img;
+                               Template.HalfFieldBackground = img;
                                halffieldImage.Pixbuf = img.Value;
                        }
                }
@@ -271,7 +271,7 @@ namespace LongoMatch.Gui.Component
                        if (background != null) {
                                Image img = new Image(background);
                                img.Scale();
-                               Template.FieldBackgroundImage = img; 
+                               Template.FieldBackground = img; 
                                fieldImage.Pixbuf = img.Value;
                        }
                }
diff --git a/LongoMatch.GUI/Gui/Dialog/TaggerDialog.cs b/LongoMatch.GUI/Gui/Dialog/TaggerDialog.cs
index 79be02f..f4064a2 100644
--- a/LongoMatch.GUI/Gui/Dialog/TaggerDialog.cs
+++ b/LongoMatch.GUI/Gui/Dialog/TaggerDialog.cs
@@ -78,9 +78,9 @@ namespace LongoMatch.Gui.Dialog
                                coordstagger.Visible = false;
                                (mainvbox[hbox] as Gtk.Box.BoxChild).Expand = true;
                        } else {
-                               coordstagger.LoadBackgrounds (categoriesTemplate.FieldBackgroundImage,
-                                                             categoriesTemplate.HalfFieldBackgroundImage,
-                                                             categoriesTemplate.GoalBackgroundImage);
+                               coordstagger.LoadBackgrounds (categoriesTemplate.FieldBackground,
+                                                             categoriesTemplate.HalfFieldBackground,
+                                                             categoriesTemplate.GoalBackground);
                                coordstagger.LoadPlay (play);
                        }
                        
diff --git a/LongoMatch.GUI/Gui/MainWindow.cs b/LongoMatch.GUI/Gui/MainWindow.cs
index 9733dfc..ad27594 100644
--- a/LongoMatch.GUI/Gui/MainWindow.cs
+++ b/LongoMatch.GUI/Gui/MainWindow.cs
@@ -167,9 +167,9 @@ namespace LongoMatch.Gui
                public void UpdateSelectedPlay (Play play) {
                        selectedTimeNode = play;
                        timeline.SelectedTimeNode = play;
-                       postagger.LoadBackgrounds (openedProject.Categories.FieldBackgroundImage,
-                                                  openedProject.Categories.HalfFieldBackgroundImage,
-                                                  openedProject.Categories.GoalBackgroundImage);
+                       postagger.LoadBackgrounds (openedProject.Categories.FieldBackground,
+                                                  openedProject.Categories.HalfFieldBackground,
+                                                  openedProject.Categories.GoalBackground);
                        postagger.LoadPlay (play, false);
                        SetTagsBoxVisibility (true);
                        notes.Play= play;


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