comparison Main.cs @ 5:1bd8febee385

Re #242: Create Qt# UI for WarFoundry * Add logging library * Set up WarFoundry environment * Log load errors
author IBBoard <dev@ibboard.co.uk>
date Mon, 25 Jan 2010 20:54:33 +0000
parents 620c62ba4d07
children 61bc9b44a695
comparison
equal deleted inserted replaced
4:d8f82945a6ab 5:1bd8febee385
1 // This file (Main.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard 1 // This file (Main.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard
2 // 2 //
3 // 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. 3 // 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.
4 using System; 4 using System;
5 using System.IO;
6 using System.Collections.Generic;
5 using Qyoto; 7 using Qyoto;
8 using log4net;
9 using IBBoard;
10 using IBBoard.WarFoundry.API;
11 using IBBoard.WarFoundry.API.Factories.Xml;
12 using IBBoard.WarFoundry.API.Savers;
13
6 namespace IBBoard.WarFoundry.GUI.QtSharp 14 namespace IBBoard.WarFoundry.GUI.QtSharp
7 { 15 {
8 class MainClass 16 class MainClass
9 { 17 {
18 private static ILog logger = LogManager.GetLogger(typeof(MainClass));
19
10 public static void Main (string[] args) 20 public static void Main (string[] args)
11 { 21 {
12 new QApplication (args); 22 new QApplication (args);
23
24 SetUpWarFoundryEnvironment ();
13 25
14 MainWindow win = new MainWindow (); 26 MainWindow win = new MainWindow ();
15 win.Show (); 27 win.Show ();
16 28
17 QApplication.Exec (); 29 QApplication.Exec ();
18 } 30 }
31
32 private static void SetUpWarFoundryEnvironment ()
33 {
34 //FIXME: Temporary hack to add paths and factories before we get preferences and plugins
35 WarFoundryLoader.GetDefault().AddLoadDirectory(new DirectoryInfo(Path.Combine(Constants.ExecutablePath, "data")));
36 WarFoundryLoader.GetDefault().RegisterFactory(WarFoundryXmlFactory.GetFactory());
37 WarFoundryLoader.GetDefault().FileLoadingFinished += FileLoadingFinished;
38 WarFoundrySaver.SetFileSaver(new WarFoundryXmlSaver());
39 }
40
41 private static void FileLoadingFinished (List<FileLoadFailure> failures)
42 {
43 foreach(FileLoadFailure failure in failures)
44 {
45 logger.Warn("Failed to load " + failure.FailedFile.FullName + ": " + failure.Message);
46 }
47 }
19 } 48 }
20 } 49 }