changeset 55:eb7db8495bb5

Re #60: Add UI to add/remove/edit weapons in GTK * Make some manual changes to the Steic-generated file until MonoDevelop bug 634447 is resolved * Add logging to UI * Make control close once we're done with it * Set values for equipment controls
author IBBoard <dev@ibboard.co.uk>
date Wed, 25 Aug 2010 19:51:23 +0000
parents f9f6e9db5350
children 0c5fbb54bfb0
files FrmAddEquipment.cs UIControl/AddEquipmentUIControl.cs gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs gtk-gui/gui.stetic
diffstat 4 files changed, 92 insertions(+), 76 deletions(-) [+]
line wrap: on
line diff
--- a/FrmAddEquipment.cs	Wed Aug 25 16:01:12 2010 +0000
+++ b/FrmAddEquipment.cs	Wed Aug 25 19:51:23 2010 +0000
@@ -7,10 +7,14 @@
 using Gtk;
 using IBBoard.WarFoundry.GUI.GTK.Util;
 using IBBoard.GtkSharp;
+using log4net.Repository.Hierarchy;
+using log4net;
 namespace IBBoard.WarFoundry.GUI.GTK
 {
-	public partial class FrmAddEquipment : Gtk.Dialog, IAddEquipmentUI
+	public partial class FrmAddEquipment : Dialog, IAddEquipmentUI
 	{
+		private static ILog log = LogManager.GetLogger(typeof(FrmAddEquipment));
+		
 		public event SingleArgMethodInvoker<UnitEquipmentItem> UnitEquipmentItemChoiceChanged;
 		
 		public FrmAddEquipment()
@@ -47,21 +51,29 @@
 
 		public void SetUnitEquipmentLimits(bool isRatioLimit, double minPercent, double maxPercent, int minNumber, int maxNumber)
 		{
-			
+			log.DebugFormat("IsRatio? {0}. Limits: {1}->{2}, {3}%->{4}%", isRatioLimit, minNumber, maxNumber, minPercent, maxPercent);
+			rbEquipNumeric.Sensitive = isRatioLimit;
+			numericAmount.Sensitive = isRatioLimit;
+			numericAmount.SetRange(minNumber, maxNumber);
+			percentageAmount.SetRange(minPercent, maxPercent);
 		}
 
 		public void SetUnitEquipmentLimitsEnabled(bool isEnabled)
 		{
-			
 		}
 
 		public bool ShowControl()
 		{
-			return Run() == (int)ResponseType.Ok;
+			int result = Run();
+			bool okayClicked = (result == (int)ResponseType.Ok);
+			this.Hide();
+			this.Dispose();
+			return okayClicked;
 		}
 		
-		protected virtual void CancelButtonClicked (object sender, System.EventArgs e)
+		protected virtual void CancelButtonClicked(object sender, System.EventArgs e)
 		{
+			log.Debug("Cancel clicked");
 			Respond(ResponseType.Cancel);
 		}		
 	}
--- a/UIControl/AddEquipmentUIControl.cs	Wed Aug 25 16:01:12 2010 +0000
+++ b/UIControl/AddEquipmentUIControl.cs	Wed Aug 25 19:51:23 2010 +0000
@@ -47,6 +47,8 @@
 			int minNumber = UnitEquipmentUtil.GetMinEquipmentCount(unit, equip);
 			minNumber = Math.Max(0, minNumber);
 			
+			ui.SetUnitEquipmentLimits(equipIsRatioLimit, minPercent, maxPercent, minNumber, maxNumber);
+			
 		}
 		
 		private double RoundPercentage(double percent)
@@ -54,7 +56,6 @@
 			return Math.Round(percent, 1);
 		}
 		
-		//TODO Make abstract
 		public void Show()
 		{
 			ui.ShowControl();
--- a/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs	Wed Aug 25 16:01:12 2010 +0000
+++ b/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs	Wed Aug 25 19:51:23 2010 +0000
@@ -24,9 +24,9 @@
 
 		private global::Gtk.RadioButton rbEquipPercent;
 
-		private global::Gtk.SpinButton spinbutton1;
+		private global::Gtk.SpinButton numericAmount;
 
-		private global::Gtk.SpinButton spinbutton2;
+		private global::Gtk.SpinButton percentageAmount;
 
 		private global::Gtk.Label lblEquipAmount;
 
@@ -59,6 +59,7 @@
 			this.lstEquipment = new global::Gtk.TreeView();
 			this.lstEquipment.CanFocus = true;
 			this.lstEquipment.Name = "lstEquipment";
+			this.lstEquipment.HeadersVisible = false;
 			this.GtkScrolledWindow.Add(this.lstEquipment);
 			this.table1.Add(this.GtkScrolledWindow);
 			global::Gtk.Table.TableChild w3 = ((global::Gtk.Table.TableChild)(this.table1[this.GtkScrolledWindow]));
@@ -135,28 +136,28 @@
 			w8.XOptions = ((global::Gtk.AttachOptions)(4));
 			w8.YOptions = ((global::Gtk.AttachOptions)(4));
 			// Container child table2.Gtk.Table+TableChild
-			this.spinbutton1 = new global::Gtk.SpinButton(0, 100, 1);
-			this.spinbutton1.CanFocus = true;
-			this.spinbutton1.Name = "spinbutton1";
-			this.spinbutton1.Adjustment.PageIncrement = 10;
-			this.spinbutton1.ClimbRate = 1;
-			this.spinbutton1.Numeric = true;
-			this.table2.Add(this.spinbutton1);
-			global::Gtk.Table.TableChild w9 = ((global::Gtk.Table.TableChild)(this.table2[this.spinbutton1]));
+			this.numericAmount = new global::Gtk.SpinButton(0, 100, 1);
+			this.numericAmount.CanFocus = true;
+			this.numericAmount.Name = "numericAmount";
+			this.numericAmount.Adjustment.PageIncrement = 10;
+			this.numericAmount.ClimbRate = 1;
+			this.numericAmount.Numeric = true;
+			this.table2.Add(this.numericAmount);
+			global::Gtk.Table.TableChild w9 = ((global::Gtk.Table.TableChild)(this.table2[this.numericAmount]));
 			w9.LeftAttach = ((uint)(1));
 			w9.RightAttach = ((uint)(2));
 			w9.XOptions = ((global::Gtk.AttachOptions)(0));
 			w9.YOptions = ((global::Gtk.AttachOptions)(4));
 			// Container child table2.Gtk.Table+TableChild
-			this.spinbutton2 = new global::Gtk.SpinButton(0, 100, 1);
-			this.spinbutton2.CanFocus = true;
-			this.spinbutton2.Name = "spinbutton2";
-			this.spinbutton2.Adjustment.PageIncrement = 10;
-			this.spinbutton2.ClimbRate = 1;
-			this.spinbutton2.Digits = ((uint)(1));
-			this.spinbutton2.Numeric = true;
-			this.table2.Add(this.spinbutton2);
-			global::Gtk.Table.TableChild w10 = ((global::Gtk.Table.TableChild)(this.table2[this.spinbutton2]));
+			this.percentageAmount = new global::Gtk.SpinButton(0, 100, 1);
+			this.percentageAmount.CanFocus = true;
+			this.percentageAmount.Name = "percentageAmount";
+			this.percentageAmount.Adjustment.PageIncrement = 10;
+			this.percentageAmount.ClimbRate = 1;
+			this.percentageAmount.Digits = ((uint)(1));
+			this.percentageAmount.Numeric = true;
+			this.table2.Add(this.percentageAmount);
+			global::Gtk.Table.TableChild w10 = ((global::Gtk.Table.TableChild)(this.table2[this.percentageAmount]));
 			w10.TopAttach = ((uint)(1));
 			w10.BottomAttach = ((uint)(2));
 			w10.LeftAttach = ((uint)(1));
@@ -212,6 +213,7 @@
 			this.buttonCancel.UseStock = true;
 			this.buttonCancel.UseUnderline = true;
 			this.buttonCancel.Label = "gtk-cancel";
+			this.buttonCancel.Clicked+= CancelButtonClicked;
 			this.AddActionWidget(this.buttonCancel, -6);
 			global::Gtk.ButtonBox.ButtonBoxChild w17 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w16[this.buttonCancel]));
 			w17.Expand = false;
--- a/gtk-gui/gui.stetic	Wed Aug 25 16:01:12 2010 +0000
+++ b/gtk-gui/gui.stetic	Wed Aug 25 19:51:23 2010 +0000
@@ -1062,10 +1062,62 @@
                       </packing>
                     </child>
                     <child>
+                      <widget class="Gtk.SpinButton" id="numericAmount">
+                        <property name="MemberName" />
+                        <property name="CanFocus">True</property>
+                        <property name="Upper">100</property>
+                        <property name="PageIncrement">10</property>
+                        <property name="StepIncrement">1</property>
+                        <property name="ClimbRate">1</property>
+                        <property name="Numeric">True</property>
+                      </widget>
+                      <packing>
+                        <property name="LeftAttach">1</property>
+                        <property name="RightAttach">2</property>
+                        <property name="AutoSize">False</property>
+                        <property name="XOptions">0</property>
+                        <property name="YOptions">Fill</property>
+                        <property name="XExpand">False</property>
+                        <property name="XFill">False</property>
+                        <property name="XShrink">False</property>
+                        <property name="YExpand">False</property>
+                        <property name="YFill">True</property>
+                        <property name="YShrink">False</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="Gtk.SpinButton" id="percentageAmount">
+                        <property name="MemberName" />
+                        <property name="CanFocus">True</property>
+                        <property name="Upper">100</property>
+                        <property name="PageIncrement">10</property>
+                        <property name="StepIncrement">1</property>
+                        <property name="ClimbRate">1</property>
+                        <property name="Digits">1</property>
+                        <property name="Numeric">True</property>
+                      </widget>
+                      <packing>
+                        <property name="TopAttach">1</property>
+                        <property name="BottomAttach">2</property>
+                        <property name="LeftAttach">1</property>
+                        <property name="RightAttach">2</property>
+                        <property name="AutoSize">False</property>
+                        <property name="XOptions">0</property>
+                        <property name="YOptions">Fill</property>
+                        <property name="XExpand">False</property>
+                        <property name="XFill">False</property>
+                        <property name="XShrink">False</property>
+                        <property name="YExpand">False</property>
+                        <property name="YFill">True</property>
+                        <property name="YShrink">False</property>
+                      </packing>
+                    </child>
+                    <child>
                       <widget class="Gtk.RadioButton" id="rbEquipAll">
                         <property name="MemberName" />
                         <property name="CanFocus">True</property>
                         <property name="Label" translatable="yes" />
+                        <property name="Active">True</property>
                         <property name="DrawIndicator">True</property>
                         <property name="HasLabel">True</property>
                         <property name="UseUnderline">True</property>
@@ -1131,57 +1183,6 @@
                         <property name="YShrink">False</property>
                       </packing>
                     </child>
-                    <child>
-                      <widget class="Gtk.SpinButton" id="spinbutton1">
-                        <property name="MemberName" />
-                        <property name="CanFocus">True</property>
-                        <property name="Upper">100</property>
-                        <property name="PageIncrement">10</property>
-                        <property name="StepIncrement">1</property>
-                        <property name="ClimbRate">1</property>
-                        <property name="Numeric">True</property>
-                      </widget>
-                      <packing>
-                        <property name="LeftAttach">1</property>
-                        <property name="RightAttach">2</property>
-                        <property name="AutoSize">False</property>
-                        <property name="XOptions">0</property>
-                        <property name="YOptions">Fill</property>
-                        <property name="XExpand">False</property>
-                        <property name="XFill">False</property>
-                        <property name="XShrink">False</property>
-                        <property name="YExpand">False</property>
-                        <property name="YFill">True</property>
-                        <property name="YShrink">False</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <widget class="Gtk.SpinButton" id="spinbutton2">
-                        <property name="MemberName" />
-                        <property name="CanFocus">True</property>
-                        <property name="Upper">100</property>
-                        <property name="PageIncrement">10</property>
-                        <property name="StepIncrement">1</property>
-                        <property name="ClimbRate">1</property>
-                        <property name="Digits">1</property>
-                        <property name="Numeric">True</property>
-                      </widget>
-                      <packing>
-                        <property name="TopAttach">1</property>
-                        <property name="BottomAttach">2</property>
-                        <property name="LeftAttach">1</property>
-                        <property name="RightAttach">2</property>
-                        <property name="AutoSize">False</property>
-                        <property name="XOptions">0</property>
-                        <property name="YOptions">Fill</property>
-                        <property name="XExpand">False</property>
-                        <property name="XFill">False</property>
-                        <property name="XShrink">False</property>
-                        <property name="YExpand">False</property>
-                        <property name="YFill">True</property>
-                        <property name="YShrink">False</property>
-                      </packing>
-                    </child>
                   </widget>
                   <packing>
                     <property name="Position">0</property>