diff FrmMainWindow.cs @ 5:65279b85446f

Re #1 - LGPL license all code * Add LGPL header to all files * Add COPYING.LGPL and COPYING.GPL with content of license Also * Moved all classes from IBBoard.WarFoundry to IBBoard.WarFoundry.GTK
author IBBoard <dev@ibboard.co.uk>
date Sun, 25 Jan 2009 14:52:18 +0000
parents 1bb28f84d567
children cfc7683e73f9
line wrap: on
line diff
--- a/FrmMainWindow.cs	Fri Dec 26 12:33:04 2008 +0000
+++ b/FrmMainWindow.cs	Sun Jan 25 14:52:18 2009 +0000
@@ -1,22 +1,6 @@
-// FrmMainWindow.cs
-//
-//  Copyright (C) 2007 IBBoard
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License version 2.1 of the License as published by the Free
-// Software Foundation.
+// This file (FrmMainWindow.cs) is a part of the IBBoard.WarFoundry.GTK project and is copyright 2009 IBBoard.
 //
-// This library 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
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
-//
-//
+// The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license.
 
 using System;
 using System.IO;
@@ -42,7 +26,7 @@
 using IBBoard.Xml;
 using log4net;
 
-namespace IBBoard.WarFoundry
+namespace IBBoard.WarFoundry.GTK
 {	
 	public partial class FrmMainWindow: Gtk.Window
 	{
@@ -53,7 +37,6 @@
 		private ILog logger = LogManager.GetLogger(typeof(FrmMainWindow));
 
 		private CommandStack commandStack;
-		private Type factoryType = typeof(WarFoundryXmlFactory);
 		private Dictionary<ToolButton, Category> categoryMap = new Dictionary<ToolButton, Category>();
 		private Dictionary<IBBoard.WarFoundry.API.Objects.Unit, UnitDisplayWidget> unitToWidgetMap = new Dictionary<IBBoard.WarFoundry.API.Objects.Unit,UnitDisplayWidget>();
 
@@ -158,17 +141,25 @@
 				
 				try
 				{
-					//TODO: Try to load files
-					/*if (file.Extension.Equals("."+Factory.GetArmyFileExtension()))
+					ICollection<IWarFoundryObject> objects = WarFoundryLoader.GetDefault().LoadFile(file);
+
+					if (objects.Count == 1)
 					{
-						WarFoundryCore.CurrentArmy = Factory.CreateArmyFromFile(file);
-						logger.InfoFormat("Loaded army from {0}", file.FullName);
+						List<IWarFoundryObject> objectList = new List<IWarFoundryObject>();
+						objectList.AddRange(objects);
+						IWarFoundryObject loadedObject = objectList[0];
+						
+						if (loadedObject is Army)
+						{
+							WarFoundryCore.CurrentArmy = (Army)loadedObject;
+							logger.InfoFormat("Loaded army from {0}", file.FullName);
+						}
+						else if (loadedObject is GameSystem)
+						{
+							WarFoundryCore.CurrentGameSystem = (GameSystem)loadedObject;
+							logger.InfoFormat("Loaded game system from {0}", file.FullName);
+						}
 					}
-					else if (file.Extension.Equals("."+Factory.GetSystemFileExtension()))
-					{
-						WarFoundryCore.CurrentGameSystem = Factory.CreateGameSystemFromFile(file);
-						logger.InfoFormat("Loaded game system from {0}", file.FullName);
-					}*/
 				}
 				catch (InvalidFileException ex)
 				{