changeset 32:eab45344cd56

Re #172: Add GTK# UI for showing debugging messages * Add starts of an implementation by subscribing to event and logging out for now Also: * Add file logger to logging config * Tidy up some code
author IBBoard <dev@ibboard.co.uk>
date Mon, 21 Sep 2009 19:17:27 +0000
parents ca863c693550
children 441cfc410987
files FrmMainWindow.cs IBBoard.WarFoundry.GUI.GTK.csproj WarFoundryGTK.exe.log4net gtk-gui/gui.stetic
diffstat 4 files changed, 36 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/FrmMainWindow.cs	Tue Sep 15 19:34:17 2009 +0000
+++ b/FrmMainWindow.cs	Mon Sep 21 19:17:27 2009 +0000
@@ -134,6 +134,7 @@
 			WarFoundryLoader.GetDefault().AddLoadDirectory(new DirectoryInfo(Constants.ExecutablePath + Constants.DirectoryString + "data"));
 			WarFoundryLoader.GetDefault().RegisterFactory(WarFoundryXmlFactory.GetFactory());
 			WarFoundryLoader.GetDefault().RegisterNonNativeFactory(RollcallFactory.GetFactory());
+			WarFoundryLoader.GetDefault().FileLoadingFinished += FileLoadingFinished;
 			WarFoundrySaver.SetFileSaver(new WarFoundryXmlSaver());
 
 			logger.Debug("Initialising complete - seeing if we can load default army or system");
@@ -189,6 +190,14 @@
 			}
 		}
 
+		private void FileLoadingFinished (List<FileLoadFailure> failures)
+		{
+			foreach(FileLoadFailure failure in failures)
+			{
+				logger.Warn("Failed to load " + failure.FailedFile.FullName + ": " + failure.Message);
+			}
+		}
+
 		private void RenderCategoryTreeObjectName(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter)
 		{
 			object o = model.GetValue(iter, 0);
@@ -198,13 +207,13 @@
 				ArmyCategory c = (ArmyCategory)o;
 				string name = "";
 
-				if (Preferences.GetBooleanProperty("ShowCatPercentage"))
+				if (!Preferences.GetBooleanProperty("ShowCatPercentage"))
 				{
-					name = Translation.GetTranslation("categoryTreeCatName", "{0} - {1}pts", c.Name, c.PointsTotal);
+					name = Translation.GetTranslation("categoryTreeCatName", "{0} - {1}pts", c.Name, c.Points);
 				}
 				else
 				{
-					name = Translation.GetTranslation("categoryTreeCatNamePercentage", "{0} - {1}pts ({2}%)", c.Name, c.PointsTotal, (c.ParentArmy.PointsTotal > 0 ? Math.Round((c.PointsTotal / c.ParentArmy.PointsTotal) * 100) : 0));
+					name = Translation.GetTranslation("categoryTreeCatNamePercentage", "{0} - {1}pts ({2}%)", c.Name, c.Points, (c.ParentArmy.Points > 0 ? Math.Round((c.Points / c.ParentArmy.Points) * 100) : 0));
 				}
 
 				(cell as CellRendererText).Text = name;
@@ -212,7 +221,7 @@
 			else if (o is IBBoard.WarFoundry.API.Objects.Unit)
 			{
 				IBBoard.WarFoundry.API.Objects.Unit u = (IBBoard.WarFoundry.API.Objects.Unit)o;
-				string name = Translation.GetTranslation("categoryTreeCatName", "{0} - {1}pts", u.Name, u.PointsValue);
+				string name = Translation.GetTranslation("unitTreeCatName", "{0} - {1}pts", u.Name, u.Points);
 				(cell as CellRendererText).Text = name;
 			}
 		}
--- a/IBBoard.WarFoundry.GUI.GTK.csproj	Tue Sep 15 19:34:17 2009 +0000
+++ b/IBBoard.WarFoundry.GUI.GTK.csproj	Mon Sep 21 19:17:27 2009 +0000
@@ -61,7 +61,9 @@
     <None Include="translations\en.translation">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
-    <None Include="WarFoundryGTK.exe.log4net" />
+    <None Include="WarFoundryGTK.exe.log4net">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
     <None Include="gtk-gui\gui.stetic" />
     <None Include="gtk-gui\objects.xml" />
     <None Include="COPYING" />
--- a/WarFoundryGTK.exe.log4net	Tue Sep 15 19:34:17 2009 +0000
+++ b/WarFoundryGTK.exe.log4net	Mon Sep 21 19:17:27 2009 +0000
@@ -1,15 +1,23 @@
 <?xml version="1.0" encoding="utf-8" ?>
-<!-- This section contains the log4net configuration settings -->
 <log4net>
-    <!-- Define some output appenders -->	
-    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" >
-        <layout type="log4net.Layout.PatternLayout">
-            <param name="ConversionPattern" value="%-5p [%d{HH:MM:ss}]: %C{1}.%M() - Line: %L - %m%n" />
-        </layout>
-    </appender>
-    <!-- Setup the root category, add the appenders and set the default priority -->
-    <root>
-        <level value="DEBUG" />
-        <appender-ref ref="ConsoleAppender" />
-    </root>
+	<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" >
+		<layout type="log4net.Layout.PatternLayout">
+			<conversionPattern value="%-5p [%d{HH:MM:ss}]: %C{1}.%M() - Line: %L - %m%n" />
+		</layout>
+	</appender>
+	<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
+		<file value="logs/WarFoundry.log" />
+		<appendToFile value="false" />
+		<rollingStyle value="Size" />
+		<maxSizeRollBackups value="-1" />
+		<maximumFileSize value="100MB" />
+		<layout type="log4net.Layout.PatternLayout">
+			<conversionPattern value="%-5p [%d{HH:MM:ss}]: %C{1}.%M() - Line: %L - %m%n" />
+		</layout>
+	</appender>
+	<root>
+		<level value="DEBUG" />
+		<appender-ref ref="ConsoleAppender" />
+		<appender-ref ref="RollingLogFileAppender" />
+	</root>
 </log4net>
--- a/gtk-gui/gui.stetic	Tue Sep 15 19:34:17 2009 +0000
+++ b/gtk-gui/gui.stetic	Mon Sep 21 19:17:27 2009 +0000
@@ -294,7 +294,6 @@
     <property name="SkipTaskbarHint">True</property>
     <property name="Buttons">2</property>
     <property name="HelpButton">False</property>
-    <property name="HasSeparator">False</property>
     <child internal-child="VBox">
       <widget class="Gtk.VBox" id="dialog_VBox">
         <property name="MemberName" />
@@ -531,7 +530,6 @@
     <property name="SkipTaskbarHint">True</property>
     <property name="Buttons">2</property>
     <property name="HelpButton">False</property>
-    <property name="HasSeparator">False</property>
     <child internal-child="VBox">
       <widget class="Gtk.VBox" id="dialog1_VBox">
         <property name="MemberName" />
@@ -638,7 +636,6 @@
     <property name="SkipTaskbarHint">True</property>
     <property name="Buttons">2</property>
     <property name="HelpButton">False</property>
-    <property name="HasSeparator">False</property>
     <child internal-child="VBox">
       <widget class="Gtk.VBox" id="dialog1_VBox">
         <property name="MemberName" />