view Main.cs @ 10:3d0c9cf1b924

Fixes #243: Create "New Army" dialog in Qt# app * Make dialog not show in task bar (add parent to constructor) * Add methods to retrieve values Re #242: Create Qt# UI for WarFoundry * Copy lots of implementation from the WinForms app to get some core army loading working (looks like we need to investigate refactoring commonality)
author IBBoard <dev@ibboard.co.uk>
date Tue, 02 Feb 2010 20:56:39 +0000
parents 1bd8febee385
children 61bc9b44a695
line wrap: on
line source

// This file (Main.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard
// 
// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
using System;
using System.IO;
using System.Collections.Generic;
using Qyoto;
using log4net;
using IBBoard;
using IBBoard.WarFoundry.API;
using IBBoard.WarFoundry.API.Factories.Xml;
using IBBoard.WarFoundry.API.Savers;

namespace IBBoard.WarFoundry.GUI.QtSharp
{
	class MainClass
	{
		private static ILog logger = LogManager.GetLogger(typeof(MainClass));
		
		public static void Main (string[] args)
		{
			new QApplication (args);
			
			SetUpWarFoundryEnvironment ();
			
			MainWindow win = new MainWindow ();
			win.Show ();
			
			QApplication.Exec ();
		}
		
		private static void SetUpWarFoundryEnvironment ()
		{
			//FIXME: Temporary hack to add paths and factories before we get preferences and plugins
			WarFoundryLoader.GetDefault().AddLoadDirectory(new DirectoryInfo(Path.Combine(Constants.ExecutablePath, "data")));
			WarFoundryLoader.GetDefault().RegisterFactory(WarFoundryXmlFactory.GetFactory());
			WarFoundryLoader.GetDefault().FileLoadingFinished += FileLoadingFinished;
			WarFoundrySaver.SetFileSaver(new WarFoundryXmlSaver());
		}		

		private static void FileLoadingFinished (List<FileLoadFailure> failures)
		{
			foreach(FileLoadFailure failure in failures)
			{
				logger.Warn("Failed to load " + failure.FailedFile.FullName + ": " + failure.Message);
			}
		}
	}
}