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 diff
     1.1 --- a/IBBoard.WarFoundry.GUI.QtSharp.csproj	Mon Jan 25 20:44:39 2010 +0000
     1.2 +++ b/IBBoard.WarFoundry.GUI.QtSharp.csproj	Mon Jan 25 20:54:33 2010 +0000
     1.3 @@ -76,11 +76,15 @@
     1.4        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     1.5      </None>
     1.6      <None Include="qt-gui\CreateNewArmyLayout.ui" />
     1.7 +    <None Include="lib\log4net.dll">
     1.8 +      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     1.9 +    </None>
    1.10    </ItemGroup>
    1.11    <ItemGroup>
    1.12      <Folder Include="qt-gui\" />
    1.13      <Folder Include="icons\" />
    1.14      <Folder Include="icons\ui\" />
    1.15 +    <Folder Include="lib\" />
    1.16    </ItemGroup>
    1.17    <ItemGroup>
    1.18      <Content Include="icons\App.png">
    1.19 @@ -90,6 +94,10 @@
    1.20    <ItemGroup>
    1.21      <Reference Include="System" />
    1.22      <Reference Include="qt-dotnet, Version=4.5.0.0, Culture=neutral, PublicKeyToken=194a23ba31c08164" />
    1.23 +    <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821">
    1.24 +      <SpecificVersion>False</SpecificVersion>
    1.25 +      <HintPath>lib\log4net.dll</HintPath>
    1.26 +    </Reference>
    1.27    </ItemGroup>
    1.28    <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
    1.29    <ItemGroup>
    1.30 @@ -97,5 +105,9 @@
    1.31        <Project>{951E6C7A-7FBA-4F68-9D9E-F48618BB9626}</Project>
    1.32        <Name>IBBoard.WarFoundry.API</Name>
    1.33      </ProjectReference>
    1.34 +    <ProjectReference Include="..\IBBoard\IBBoard.csproj">
    1.35 +      <Project>{5DFD64F6-FC2B-4B4F-B92E-483BAC468105}</Project>
    1.36 +      <Name>IBBoard</Name>
    1.37 +    </ProjectReference>
    1.38    </ItemGroup>
    1.39  </Project>
    1.40 \ No newline at end of file
     2.1 --- a/Main.cs	Mon Jan 25 20:44:39 2010 +0000
     2.2 +++ b/Main.cs	Mon Jan 25 20:54:33 2010 +0000
     2.3 @@ -2,19 +2,48 @@
     2.4  // 
     2.5  // 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.
     2.6  using System;
     2.7 +using System.IO;
     2.8 +using System.Collections.Generic;
     2.9  using Qyoto;
    2.10 +using log4net;
    2.11 +using IBBoard;
    2.12 +using IBBoard.WarFoundry.API;
    2.13 +using IBBoard.WarFoundry.API.Factories.Xml;
    2.14 +using IBBoard.WarFoundry.API.Savers;
    2.15 +
    2.16  namespace IBBoard.WarFoundry.GUI.QtSharp
    2.17  {
    2.18  	class MainClass
    2.19  	{
    2.20 +		private static ILog logger = LogManager.GetLogger(typeof(MainClass));
    2.21 +		
    2.22  		public static void Main (string[] args)
    2.23  		{
    2.24  			new QApplication (args);
    2.25  			
    2.26 +			SetUpWarFoundryEnvironment ();
    2.27 +			
    2.28  			MainWindow win = new MainWindow ();
    2.29  			win.Show ();
    2.30  			
    2.31  			QApplication.Exec ();
    2.32  		}
    2.33 +		
    2.34 +		private static void SetUpWarFoundryEnvironment ()
    2.35 +		{
    2.36 +			//FIXME: Temporary hack to add paths and factories before we get preferences and plugins
    2.37 +			WarFoundryLoader.GetDefault().AddLoadDirectory(new DirectoryInfo(Path.Combine(Constants.ExecutablePath, "data")));
    2.38 +			WarFoundryLoader.GetDefault().RegisterFactory(WarFoundryXmlFactory.GetFactory());
    2.39 +			WarFoundryLoader.GetDefault().FileLoadingFinished += FileLoadingFinished;
    2.40 +			WarFoundrySaver.SetFileSaver(new WarFoundryXmlSaver());
    2.41 +		}		
    2.42 +
    2.43 +		private static void FileLoadingFinished (List<FileLoadFailure> failures)
    2.44 +		{
    2.45 +			foreach(FileLoadFailure failure in failures)
    2.46 +			{
    2.47 +				logger.Warn("Failed to load " + failure.FailedFile.FullName + ": " + failure.Message);
    2.48 +			}
    2.49 +		}
    2.50  	}
    2.51  }
     3.1 --- a/MainWindow.cs	Mon Jan 25 20:44:39 2010 +0000
     3.2 +++ b/MainWindow.cs	Mon Jan 25 20:54:33 2010 +0000
     3.3 @@ -38,7 +38,7 @@
     3.4  		
     3.5  		private void ConnectMenuActions()
     3.6  		{
     3.7 -			QObject.Connect(layout.actionCreateArmy, Qt.SIGNAL("triggered()"), CreateNewArmy);
     3.8 +			QObject.Connect(layout.actionCreateArmy, "triggered()", CreateNewArmy);
     3.9  		}
    3.10  		
    3.11  		private void CreateNewArmy()
     4.1 Binary file lib/log4net.dll has changed