[longomatch] Fix conversion of old templates with empty backgrounds



commit e55cc41a4a4c51f02cb83eec047abb987c447790
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Tue Oct 21 17:52:04 2014 +0200

    Fix conversion of old templates with empty backgrounds

 LongoMatch.Migration/Common/Constants.cs         |    6 ++--
 LongoMatch.Migration/Converter.cs                |   24 ++++++++++++++++-----
 LongoMatch.Migration/LongoMatch.Migration.csproj |   10 +++++++++
 LongoMatch.Migration/Makefile.am                 |    5 +++-
 LongoMatch.Migration/Program.cs                  |    3 ++
 5 files changed, 38 insertions(+), 10 deletions(-)
---
diff --git a/LongoMatch.Migration/Common/Constants.cs b/LongoMatch.Migration/Common/Constants.cs
index f51aa74..29930e7 100644
--- a/LongoMatch.Migration/Common/Constants.cs
+++ b/LongoMatch.Migration/Common/Constants.cs
@@ -97,9 +97,9 @@ Xavier Queralt Mateu (ca)";
                public const string PROJECT_EXT = ".lgm";
                
                public const string BACKGROUND = "background.png";
-               public const string FIELD_BACKGROUND = "field_background.svg";
-               public const string HALF_FIELD_BACKGROUND = "half_field_background.svg";
-               public const string GOAL_BACKGROUND = "goal_background.svg";
+               public const string FIELD_BACKGROUND = "field-full.svg";
+               public const string HALF_FIELD_BACKGROUND = "field-half.svg";
+               public const string GOAL_BACKGROUND = "field-goal.svg";
                
                public const int DB_MAYOR_VERSION = 3;
                public const int DB_MINOR_VERSION = 1;
diff --git a/LongoMatch.Migration/Converter.cs b/LongoMatch.Migration/Converter.cs
index a07da9b..b2ddf1a 100644
--- a/LongoMatch.Migration/Converter.cs
+++ b/LongoMatch.Migration/Converter.cs
@@ -126,18 +126,30 @@ namespace LongoMatch.Migration
                }
 
                public static LongoMatch.Core.Store.Templates.Dashboard ConvertCategories (Categories cats,
-                                                                                          out Dictionary 
<TagSubCategory, List<LongoMatch.Core.Store.Tag>> dict,
-                                                                                          out Dictionary 
<Category, LongoMatch.Core.Store.EventType > eventTypesDict)
+                                                                                        out Dictionary 
<TagSubCategory, List<LongoMatch.Core.Store.Tag>> dict,
+                                                                                        out Dictionary 
<Category, LongoMatch.Core.Store.EventType > eventTypesDict)
                {
                        dict = new Dictionary<TagSubCategory, List<LongoMatch.Core.Store.Tag>> ();
-                       eventTypesDict = new Dictionary<Category, LongoMatch.Core.Store.EventType>();
+                       eventTypesDict = new Dictionary<Category, LongoMatch.Core.Store.EventType> ();
                        int i = 0;
                        var dashboard = new LongoMatch.Core.Store.Templates.Dashboard ();
                        dashboard.Name = cats.Name;
                        dashboard.Image = ConvertImage (cats.Image);
-                       dashboard.FieldBackground = ConvertImage (cats.FieldBackground);
-                       dashboard.HalfFieldBackground = ConvertImage (cats.HalfFieldBackground);
-                       dashboard.GoalBackground = ConvertImage (cats.GoalBackground);
+                       if (cats.FieldBackground != null) {
+                               dashboard.FieldBackground = ConvertImage (cats.FieldBackground);
+                       } else {
+                               dashboard.FieldBackground = Config.FieldBackground;
+                       }
+                       if (cats.HalfFieldBackground != null) {
+                               dashboard.HalfFieldBackground = ConvertImage (cats.HalfFieldBackground);
+                       } else {
+                               dashboard.HalfFieldBackground = Config.HalfFieldBackground;
+                       }
+                       if (cats.GoalBackground != null) {
+                               dashboard.GoalBackground = ConvertImage (cats.GoalBackground);
+                       } else {
+                               dashboard.HalfFieldBackground = Config.GoalBackground;
+                       }
                        dashboard.ID = cats.ID;
                        dashboard.GamePeriods = new List<string> { "1", "2" };
                        
diff --git a/LongoMatch.Migration/LongoMatch.Migration.csproj 
b/LongoMatch.Migration/LongoMatch.Migration.csproj
index 915bcfb..4308ed6 100644
--- a/LongoMatch.Migration/LongoMatch.Migration.csproj
+++ b/LongoMatch.Migration/LongoMatch.Migration.csproj
@@ -79,6 +79,16 @@
     <EmbeddedResource Include="Data\project.lgm">
       <LogicalName>project.lgm</LogicalName>
     </EmbeddedResource>
+    <EmbeddedResource Include="..\data\images\fields\field-half.svg">
+      <Link>field-half.svg</Link>
+    </EmbeddedResource>
+    <EmbeddedResource Include="..\data\images\fields\field-goal.svg">
+      <Link>field-goal.svg</Link>
+    </EmbeddedResource>
+    <EmbeddedResource Include="..\data\images\fields\field-full.svg">
+      <Link>field-full.svg</Link>
+      <LogicalName>field-full.svg</LogicalName>
+    </EmbeddedResource>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="gtk-gui\generated.cs" />
diff --git a/LongoMatch.Migration/Makefile.am b/LongoMatch.Migration/Makefile.am
index 1e0928b..047f023 100644
--- a/LongoMatch.Migration/Makefile.am
+++ b/LongoMatch.Migration/Makefile.am
@@ -53,6 +53,9 @@ SOURCES = Common/Color.cs \
 RESOURCES = gtk-gui/gui.stetic \
        Data/default.lct \
        Data/default.ltt \
-       Data/project.lgm
+       Data/project.lgm \
+       $(top_srcdir)/data/images/fields/field-half.svg \
+       $(top_srcdir)/data/images/fields/field-goal.svg \
+       $(top_srcdir)/data/images/fields/field-full.svg
 
 include $(top_srcdir)/build/build.mk
diff --git a/LongoMatch.Migration/Program.cs b/LongoMatch.Migration/Program.cs
index 7019880..e8b705b 100644
--- a/LongoMatch.Migration/Program.cs
+++ b/LongoMatch.Migration/Program.cs
@@ -54,6 +54,9 @@ namespace LongoMatch.Migration
                                LongoMatch.Config.baseDirectory = baseDirectory;
                                LongoMatch.Config.dataDir = System.IO.Path.Combine 
(LongoMatch.Config.baseDirectory, "share", "longomatch");
                        }
+                       LongoMatch.Config.Load ();
+                       var styleConf = Path.Combine (Config.dataDir, "theme", "longomatch-dark.json");
+                       LongoMatch.Config.Style = LongoMatch.Core.Common.StyleConf.Load (styleConf);
                }
        
                static  void InitGtk ()


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