changeset 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 d8f82945a6ab
children bbf40d66dfe4
files IBBoard.WarFoundry.GUI.QtSharp.csproj Main.cs MainWindow.cs lib/log4net.dll
diffstat 4 files changed, 42 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/IBBoard.WarFoundry.GUI.QtSharp.csproj	Mon Jan 25 20:44:39 2010 +0000
+++ b/IBBoard.WarFoundry.GUI.QtSharp.csproj	Mon Jan 25 20:54:33 2010 +0000
@@ -76,11 +76,15 @@
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
     <None Include="qt-gui\CreateNewArmyLayout.ui" />
+    <None Include="lib\log4net.dll">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <Folder Include="qt-gui\" />
     <Folder Include="icons\" />
     <Folder Include="icons\ui\" />
+    <Folder Include="lib\" />
   </ItemGroup>
   <ItemGroup>
     <Content Include="icons\App.png">
@@ -90,6 +94,10 @@
   <ItemGroup>
     <Reference Include="System" />
     <Reference Include="qt-dotnet, Version=4.5.0.0, Culture=neutral, PublicKeyToken=194a23ba31c08164" />
+    <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>lib\log4net.dll</HintPath>
+    </Reference>
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <ItemGroup>
@@ -97,5 +105,9 @@
       <Project>{951E6C7A-7FBA-4F68-9D9E-F48618BB9626}</Project>
       <Name>IBBoard.WarFoundry.API</Name>
     </ProjectReference>
+    <ProjectReference Include="..\IBBoard\IBBoard.csproj">
+      <Project>{5DFD64F6-FC2B-4B4F-B92E-483BAC468105}</Project>
+      <Name>IBBoard</Name>
+    </ProjectReference>
   </ItemGroup>
 </Project>
\ No newline at end of file
--- a/Main.cs	Mon Jan 25 20:44:39 2010 +0000
+++ b/Main.cs	Mon Jan 25 20:54:33 2010 +0000
@@ -2,19 +2,48 @@
 // 
 // 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);
+			}
+		}
 	}
 }
--- a/MainWindow.cs	Mon Jan 25 20:44:39 2010 +0000
+++ b/MainWindow.cs	Mon Jan 25 20:54:33 2010 +0000
@@ -38,7 +38,7 @@
 		
 		private void ConnectMenuActions()
 		{
-			QObject.Connect(layout.actionCreateArmy, Qt.SIGNAL("triggered()"), CreateNewArmy);
+			QObject.Connect(layout.actionCreateArmy, "triggered()", CreateNewArmy);
 		}
 		
 		private void CreateNewArmy()
Binary file lib/log4net.dll has changed