changeset 65:77448375d2f9

Re #60: Add UI to add/remove/edit weapons in GTK * Add titles and make dialogs not appear on task list * Capture ratio amounts in Control object's local variable, otherwise we get 0s * Set initial values when editing equipment * Only enable the Edit button when we can edit
author IBBoard <dev@ibboard.co.uk>
date Sat, 04 Sep 2010 10:25:39 +0000
parents e3fe48c4d794
children 100626381159
files UIControl/AddEquipmentUIControl.cs UIControl/EditEquipmentUIControl.cs Widgets/UnitDisplayWidget.cs gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmEditEquipment.cs gtk-gui/gui.stetic
diffstat 6 files changed, 34 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/UIControl/AddEquipmentUIControl.cs	Thu Sep 02 20:12:21 2010 +0000
+++ b/UIControl/AddEquipmentUIControl.cs	Sat Sep 04 10:25:39 2010 +0000
@@ -49,7 +49,7 @@
 			
 			if (isRatioAmount)
 			{
-				double equipmentAmount = ui.EquipmentPercentageAmount;
+				equipmentAmount = ui.EquipmentPercentageAmount;
 				SetEquipmentAmountsFromPercentage(equipmentAmount);
 			}
 			else
--- a/UIControl/EditEquipmentUIControl.cs	Thu Sep 02 20:12:21 2010 +0000
+++ b/UIControl/EditEquipmentUIControl.cs	Sat Sep 04 10:25:39 2010 +0000
@@ -44,10 +44,17 @@
 			
 			ui.SetUnitEquipmentLimits(isRatioAmount, minPercentage, maxPercentage, minNumber, maxNumber);
 			ui.SetUnitEquipmentLimitsEnabled(true);
-			ui.SetOkayEnabledState(HasNonZeroEquipmentAmount());
+			ui.SetOkayEnabledState(false);
 			SetEquipmentAmountControlEnabledStates();
 			
-			//TODO: Set initial values
+			if (UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equipItem))
+			{
+				SetEquipmentAmountsFromPercentage(UnitEquipmentUtil.GetEquipmentAmount(unit, equipItem));
+			}
+			else
+			{
+				SetEquipmentAmountsFromNumber((int)UnitEquipmentUtil.GetEquipmentAmount(unit, equipItem));
+			}
 			
 			ui.UnitEquipmentAmountChanged += HandleUnitEquipmentAmountChanged;
 			ui.UnitEquipmentAmountTypeChanged += HandleUnitEquipmentAmountChanged;
@@ -55,12 +62,12 @@
 
 		private void HandleUnitEquipmentAmountChanged()
 		{
-			ui.SetOkayEnabledState(equipItem != null && HasNonZeroEquipmentAmount());
+			ui.SetOkayEnabledState(HasNonZeroEquipmentAmount());
 			isRatioAmount = ui.IsRatioEquipmentAmount;
 			
 			if (isRatioAmount)
 			{
-				double equipmentAmount = ui.EquipmentPercentageAmount;
+				equipmentAmount = ui.EquipmentPercentageAmount;
 				SetEquipmentAmountsFromPercentage(equipmentAmount);
 			}
 			else
--- a/Widgets/UnitDisplayWidget.cs	Thu Sep 02 20:12:21 2010 +0000
+++ b/Widgets/UnitDisplayWidget.cs	Sat Sep 04 10:25:39 2010 +0000
@@ -54,7 +54,7 @@
 		{			
 			UnitEquipmentItem equipItem = GetSelectedEquipmentItem();
 			bttnReplaceEquipment.Sensitive = (equipItem != null && equipItem.HasAlternatives());
-			bttnEditEquipment.Sensitive = (equipItem != null);
+			bttnEditEquipment.Sensitive = (UnitEquipmentUtil.CanEditEquipmentAmount(unit, equipItem));
 			bttnRemoveEquipment.Sensitive = (equipItem != null && !equipItem.IsRequired);
 		}
 		private UnitEquipmentItem GetSelectedEquipmentItem()
--- a/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs	Thu Sep 02 20:12:21 2010 +0000
+++ b/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs	Sat Sep 04 10:25:39 2010 +0000
@@ -41,7 +41,11 @@
 			global::Stetic.Gui.Initialize(this);
 			// Widget IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment
 			this.Name = "IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment";
+			this.Title = global::Mono.Unix.Catalog.GetString("Add equipment");
 			this.WindowPosition = ((global::Gtk.WindowPosition)(4));
+			this.Modal = true;
+			this.SkipPagerHint = true;
+			this.SkipTaskbarHint = true;
 			// Internal child IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.VBox
 			global::Gtk.VBox w1 = this.VBox;
 			w1.Name = "dialog1_VBox";
--- a/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmEditEquipment.cs	Thu Sep 02 20:12:21 2010 +0000
+++ b/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmEditEquipment.cs	Sat Sep 04 10:25:39 2010 +0000
@@ -35,7 +35,11 @@
 			global::Stetic.Gui.Initialize(this);
 			// Widget IBBoard.WarFoundry.GUI.GTK.FrmEditEquipment
 			this.Name = "IBBoard.WarFoundry.GUI.GTK.FrmEditEquipment";
+			this.Title = global::Mono.Unix.Catalog.GetString("Edit equipment");
 			this.WindowPosition = ((global::Gtk.WindowPosition)(4));
+			this.Modal = true;
+			this.SkipPagerHint = true;
+			this.SkipTaskbarHint = true;
 			// Internal child IBBoard.WarFoundry.GUI.GTK.FrmEditEquipment.VBox
 			global::Gtk.VBox w1 = this.VBox;
 			w1.Name = "dialog1_VBox";
@@ -157,9 +161,9 @@
 			this.lblEquipAmount = new global::Gtk.Label();
 			this.lblEquipAmount.Name = "lblEquipAmount";
 			this.lblEquipAmount.LabelProp = global::Mono.Unix.Catalog.GetString("amount:");
+			this.lblEquipAmount.Justify = ((global::Gtk.Justification)(1));
 			this.table1.Add(this.lblEquipAmount);
 			global::Gtk.Table.TableChild w11 = ((global::Gtk.Table.TableChild)(this.table1[this.lblEquipAmount]));
-			w11.XOptions = ((global::Gtk.AttachOptions)(4));
 			w11.YOptions = ((global::Gtk.AttachOptions)(4));
 			w1.Add(this.table1);
 			global::Gtk.Box.BoxChild w12 = ((global::Gtk.Box.BoxChild)(w1[this.table1]));
--- a/gtk-gui/gui.stetic	Thu Sep 02 20:12:21 2010 +0000
+++ b/gtk-gui/gui.stetic	Sat Sep 04 10:25:39 2010 +0000
@@ -968,7 +968,11 @@
   </widget>
   <widget class="Gtk.Dialog" id="IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment" design-size="400 300">
     <property name="MemberName" />
+    <property name="Title" translatable="yes">Add equipment</property>
     <property name="WindowPosition">CenterOnParent</property>
+    <property name="Modal">True</property>
+    <property name="SkipPagerHint">True</property>
+    <property name="SkipTaskbarHint">True</property>
     <property name="Buttons">2</property>
     <property name="HelpButton">False</property>
     <child internal-child="VBox">
@@ -1124,6 +1128,7 @@
                         <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>
@@ -1310,7 +1315,11 @@
   </widget>
   <widget class="Gtk.Dialog" id="IBBoard.WarFoundry.GUI.GTK.FrmEditEquipment" design-size="280 175">
     <property name="MemberName" />
+    <property name="Title" translatable="yes">Edit equipment</property>
     <property name="WindowPosition">CenterOnParent</property>
+    <property name="Modal">True</property>
+    <property name="SkipPagerHint">True</property>
+    <property name="SkipTaskbarHint">True</property>
     <property name="Buttons">2</property>
     <property name="HelpButton">False</property>
     <child internal-child="VBox">
@@ -1534,12 +1543,12 @@
               <widget class="Gtk.Label" id="lblEquipAmount">
                 <property name="MemberName" />
                 <property name="LabelProp" translatable="yes">amount:</property>
+                <property name="Justify">Right</property>
               </widget>
               <packing>
-                <property name="AutoSize">True</property>
-                <property name="XOptions">Fill</property>
+                <property name="AutoSize">False</property>
                 <property name="YOptions">Fill</property>
-                <property name="XExpand">False</property>
+                <property name="XExpand">True</property>
                 <property name="XFill">True</property>
                 <property name="XShrink">False</property>
                 <property name="YExpand">False</property>