changeset 71:91354245218a

Fixes #305: Add abilities to GTK# UI * Add Abilities section to UnitDisplayWidget that shows list of required abilities
author IBBoard <dev@ibboard.co.uk>
date Sat, 06 Nov 2010 20:22:19 +0000
parents 4b82515586ac
children f0cc295e883c
files Widgets/UnitDisplayWidget.cs gtk-gui/IBBoard.WarFoundry.GTK.Widgets.UnitDisplayWidget.cs gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs gtk-gui/gui.stetic
diffstat 4 files changed, 147 insertions(+), 41 deletions(-) [+]
line diff
     1.1 --- a/Widgets/UnitDisplayWidget.cs	Sat Nov 06 17:03:13 2010 +0000
     1.2 +++ b/Widgets/UnitDisplayWidget.cs	Sat Nov 06 20:22:19 2010 +0000
     1.3 @@ -5,15 +5,15 @@
     1.4  using System;
     1.5  using Gtk;
     1.6  using IBBoard.Commands;
     1.7 +using IBBoard.GtkSharp;
     1.8  using IBBoard.Lang;
     1.9  using IBBoard.WarFoundry.API;
    1.10 -using WFObjects = IBBoard.WarFoundry.API.Objects;
    1.11  using IBBoard.WarFoundry.API.Commands;
    1.12 -using IBBoard.WarFoundry.GUI.GTK.UIControl;
    1.13  using IBBoard.WarFoundry.API.Objects;
    1.14  using IBBoard.WarFoundry.API.Util;
    1.15 -using IBBoard.GtkSharp;
    1.16 +using IBBoard.WarFoundry.GUI.GTK.UIControl;
    1.17  using log4net;
    1.18 +using WFObjects = IBBoard.WarFoundry.API.Objects;
    1.19  
    1.20  namespace IBBoard.WarFoundry.GTK.Widgets
    1.21  {
    1.22 @@ -41,6 +41,7 @@
    1.23  			unit.UnitSizeChanged += UnitSizeChanged;
    1.24  			unit.UnitEquipmentAmountChanged += HandleUnitUnitEquipmentAmountChanged;
    1.25  			equipmentList.Selection.Changed += HandleEquipmentListSelectionChanged;
    1.26 +			SetAbilities();
    1.27  			SetStats();
    1.28  			SetWeapons();
    1.29  		}
    1.30 @@ -62,6 +63,33 @@
    1.31  		{
    1.32  			return (UnitEquipmentItem)TreeUtils.GetSelectedItem(equipmentList);
    1.33  		}
    1.34 +		
    1.35 +		private void SetAbilities()
    1.36 +		{
    1.37 +			CellRendererText renderer = new CellRendererText();
    1.38 +			abilitiesList.AppendColumn("", renderer, new TreeCellDataFunc(RenderAbility));
    1.39 +			
    1.40 +			ListStore model = new ListStore(typeof(Ability));
    1.41 +			
    1.42 +			foreach (Ability ability in unit.UnitType.GetRequiredAbilities())
    1.43 +			{
    1.44 +				model.AppendValues(ability);
    1.45 +			}
    1.46 +			
    1.47 +			abilitiesList.Model = model;
    1.48 +		}
    1.49 +		
    1.50 +		public void RenderAbility(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter)
    1.51 +		{
    1.52 +			object o = model.GetValue(iter, 0);
    1.53 +			
    1.54 +			if (o is Ability)
    1.55 +			{
    1.56 +				Ability ability = (Ability)o;
    1.57 +				(cell as CellRendererText).Text = ability.Name;
    1.58 +			}			
    1.59 +						
    1.60 +		}
    1.61  
    1.62  		private void SetStats()
    1.63  		{
     2.1 --- a/gtk-gui/IBBoard.WarFoundry.GTK.Widgets.UnitDisplayWidget.cs	Sat Nov 06 17:03:13 2010 +0000
     2.2 +++ b/gtk-gui/IBBoard.WarFoundry.GTK.Widgets.UnitDisplayWidget.cs	Sat Nov 06 20:22:19 2010 +0000
     2.3 @@ -18,6 +18,9 @@
     2.4  				private global::Gtk.NodeView equipmentList;
     2.5  				private global::Gtk.ScrolledWindow GtkScrolledWindow3;
     2.6  				private global::Gtk.TextView notesView;
     2.7 +				private global::Gtk.ScrolledWindow GtkScrolledWindow4;
     2.8 +				private global::Gtk.NodeView abilitiesList;
     2.9 +				private global::Gtk.Label lblAbilities;
    2.10  				private global::Gtk.Label lblNotes;
    2.11  				private global::Gtk.VBox vbox3;
    2.12  				private global::Gtk.Button bttnAddEquipment;
    2.13 @@ -91,7 +94,7 @@
    2.14  			this.hbox2.Name = "hbox2";
    2.15  			this.hbox2.Spacing = 6;
    2.16  			// Container child hbox2.Gtk.Box+BoxChild
    2.17 -			this.table1 = new global::Gtk.Table(((uint)(2)), ((uint)(2)), false);
    2.18 +			this.table1 = new global::Gtk.Table(((uint)(3)), ((uint)(2)), false);
    2.19  			this.table1.Name = "table1";
    2.20  			this.table1.RowSpacing = ((uint)(6));
    2.21  			this.table1.ColumnSpacing = ((uint)(6));
    2.22 @@ -130,24 +133,51 @@
    2.23  			this.GtkScrolledWindow3.Add(this.notesView);
    2.24  			this.table1.Add(this.GtkScrolledWindow3);
    2.25  			global::Gtk.Table.TableChild w11 = ((global::Gtk.Table.TableChild)(this.table1[this.GtkScrolledWindow3]));
    2.26 -			w11.TopAttach = ((uint)(1));
    2.27 -			w11.BottomAttach = ((uint)(2));
    2.28 +			w11.TopAttach = ((uint)(2));
    2.29 +			w11.BottomAttach = ((uint)(3));
    2.30  			w11.LeftAttach = ((uint)(1));
    2.31  			w11.RightAttach = ((uint)(2));
    2.32  			w11.YOptions = ((global::Gtk.AttachOptions)(4));
    2.33  			// Container child table1.Gtk.Table+TableChild
    2.34 +			this.GtkScrolledWindow4 = new global::Gtk.ScrolledWindow();
    2.35 +			this.GtkScrolledWindow4.Name = "GtkScrolledWindow4";
    2.36 +			this.GtkScrolledWindow4.ShadowType = ((global::Gtk.ShadowType)(1));
    2.37 +			// Container child GtkScrolledWindow4.Gtk.Container+ContainerChild
    2.38 +			this.abilitiesList = new global::Gtk.NodeView();
    2.39 +			this.abilitiesList.CanFocus = true;
    2.40 +			this.abilitiesList.Name = "abilitiesList";
    2.41 +			this.abilitiesList.HeadersVisible = false;
    2.42 +			this.GtkScrolledWindow4.Add(this.abilitiesList);
    2.43 +			this.table1.Add(this.GtkScrolledWindow4);
    2.44 +			global::Gtk.Table.TableChild w13 = ((global::Gtk.Table.TableChild)(this.table1[this.GtkScrolledWindow4]));
    2.45 +			w13.TopAttach = ((uint)(1));
    2.46 +			w13.BottomAttach = ((uint)(2));
    2.47 +			w13.LeftAttach = ((uint)(1));
    2.48 +			w13.RightAttach = ((uint)(2));
    2.49 +			w13.YOptions = ((global::Gtk.AttachOptions)(4));
    2.50 +			// Container child table1.Gtk.Table+TableChild
    2.51 +			this.lblAbilities = new global::Gtk.Label();
    2.52 +			this.lblAbilities.Name = "lblAbilities";
    2.53 +			this.lblAbilities.LabelProp = global::Mono.Unix.Catalog.GetString("abilities:");
    2.54 +			this.table1.Add(this.lblAbilities);
    2.55 +			global::Gtk.Table.TableChild w14 = ((global::Gtk.Table.TableChild)(this.table1[this.lblAbilities]));
    2.56 +			w14.TopAttach = ((uint)(1));
    2.57 +			w14.BottomAttach = ((uint)(2));
    2.58 +			w14.XOptions = ((global::Gtk.AttachOptions)(4));
    2.59 +			w14.YOptions = ((global::Gtk.AttachOptions)(4));
    2.60 +			// Container child table1.Gtk.Table+TableChild
    2.61  			this.lblNotes = new global::Gtk.Label();
    2.62  			this.lblNotes.Name = "lblNotes";
    2.63  			this.lblNotes.LabelProp = global::Mono.Unix.Catalog.GetString("notes:");
    2.64  			this.table1.Add(this.lblNotes);
    2.65 -			global::Gtk.Table.TableChild w12 = ((global::Gtk.Table.TableChild)(this.table1[this.lblNotes]));
    2.66 -			w12.TopAttach = ((uint)(1));
    2.67 -			w12.BottomAttach = ((uint)(2));
    2.68 -			w12.XOptions = ((global::Gtk.AttachOptions)(4));
    2.69 -			w12.YOptions = ((global::Gtk.AttachOptions)(4));
    2.70 +			global::Gtk.Table.TableChild w15 = ((global::Gtk.Table.TableChild)(this.table1[this.lblNotes]));
    2.71 +			w15.TopAttach = ((uint)(2));
    2.72 +			w15.BottomAttach = ((uint)(3));
    2.73 +			w15.XOptions = ((global::Gtk.AttachOptions)(4));
    2.74 +			w15.YOptions = ((global::Gtk.AttachOptions)(4));
    2.75  			this.hbox2.Add(this.table1);
    2.76 -			global::Gtk.Box.BoxChild w13 = ((global::Gtk.Box.BoxChild)(this.hbox2[this.table1]));
    2.77 -			w13.Position = 0;
    2.78 +			global::Gtk.Box.BoxChild w16 = ((global::Gtk.Box.BoxChild)(this.hbox2[this.table1]));
    2.79 +			w16.Position = 0;
    2.80  			// Container child hbox2.Gtk.Box+BoxChild
    2.81  			this.vbox3 = new global::Gtk.VBox();
    2.82  			this.vbox3.Name = "vbox3";
    2.83 @@ -159,10 +189,10 @@
    2.84  			this.bttnAddEquipment.UseUnderline = true;
    2.85  			this.bttnAddEquipment.Label = global::Mono.Unix.Catalog.GetString("Add");
    2.86  			this.vbox3.Add(this.bttnAddEquipment);
    2.87 -			global::Gtk.Box.BoxChild w14 = ((global::Gtk.Box.BoxChild)(this.vbox3[this.bttnAddEquipment]));
    2.88 -			w14.Position = 0;
    2.89 -			w14.Expand = false;
    2.90 -			w14.Fill = false;
    2.91 +			global::Gtk.Box.BoxChild w17 = ((global::Gtk.Box.BoxChild)(this.vbox3[this.bttnAddEquipment]));
    2.92 +			w17.Position = 0;
    2.93 +			w17.Expand = false;
    2.94 +			w17.Fill = false;
    2.95  			// Container child vbox3.Gtk.Box+BoxChild
    2.96  			this.bttnEditEquipment = new global::Gtk.Button();
    2.97  			this.bttnEditEquipment.Sensitive = false;
    2.98 @@ -171,10 +201,10 @@
    2.99  			this.bttnEditEquipment.UseUnderline = true;
   2.100  			this.bttnEditEquipment.Label = global::Mono.Unix.Catalog.GetString("Edit");
   2.101  			this.vbox3.Add(this.bttnEditEquipment);
   2.102 -			global::Gtk.Box.BoxChild w15 = ((global::Gtk.Box.BoxChild)(this.vbox3[this.bttnEditEquipment]));
   2.103 -			w15.Position = 1;
   2.104 -			w15.Expand = false;
   2.105 -			w15.Fill = false;
   2.106 +			global::Gtk.Box.BoxChild w18 = ((global::Gtk.Box.BoxChild)(this.vbox3[this.bttnEditEquipment]));
   2.107 +			w18.Position = 1;
   2.108 +			w18.Expand = false;
   2.109 +			w18.Fill = false;
   2.110  			// Container child vbox3.Gtk.Box+BoxChild
   2.111  			this.bttnReplaceEquipment = new global::Gtk.Button();
   2.112  			this.bttnReplaceEquipment.Sensitive = false;
   2.113 @@ -183,10 +213,10 @@
   2.114  			this.bttnReplaceEquipment.UseUnderline = true;
   2.115  			this.bttnReplaceEquipment.Label = global::Mono.Unix.Catalog.GetString("Replace");
   2.116  			this.vbox3.Add(this.bttnReplaceEquipment);
   2.117 -			global::Gtk.Box.BoxChild w16 = ((global::Gtk.Box.BoxChild)(this.vbox3[this.bttnReplaceEquipment]));
   2.118 -			w16.Position = 2;
   2.119 -			w16.Expand = false;
   2.120 -			w16.Fill = false;
   2.121 +			global::Gtk.Box.BoxChild w19 = ((global::Gtk.Box.BoxChild)(this.vbox3[this.bttnReplaceEquipment]));
   2.122 +			w19.Position = 2;
   2.123 +			w19.Expand = false;
   2.124 +			w19.Fill = false;
   2.125  			// Container child vbox3.Gtk.Box+BoxChild
   2.126  			this.bttnRemoveEquipment = new global::Gtk.Button();
   2.127  			this.bttnRemoveEquipment.Sensitive = false;
   2.128 @@ -195,20 +225,20 @@
   2.129  			this.bttnRemoveEquipment.UseUnderline = true;
   2.130  			this.bttnRemoveEquipment.Label = global::Mono.Unix.Catalog.GetString("Remove");
   2.131  			this.vbox3.Add(this.bttnRemoveEquipment);
   2.132 -			global::Gtk.Box.BoxChild w17 = ((global::Gtk.Box.BoxChild)(this.vbox3[this.bttnRemoveEquipment]));
   2.133 -			w17.Position = 3;
   2.134 -			w17.Expand = false;
   2.135 -			w17.Fill = false;
   2.136 +			global::Gtk.Box.BoxChild w20 = ((global::Gtk.Box.BoxChild)(this.vbox3[this.bttnRemoveEquipment]));
   2.137 +			w20.Position = 3;
   2.138 +			w20.Expand = false;
   2.139 +			w20.Fill = false;
   2.140  			this.hbox2.Add(this.vbox3);
   2.141 -			global::Gtk.Box.BoxChild w18 = ((global::Gtk.Box.BoxChild)(this.hbox2[this.vbox3]));
   2.142 -			w18.Position = 1;
   2.143 -			w18.Expand = false;
   2.144 -			w18.Fill = false;
   2.145 +			global::Gtk.Box.BoxChild w21 = ((global::Gtk.Box.BoxChild)(this.hbox2[this.vbox3]));
   2.146 +			w21.Position = 1;
   2.147 +			w21.Expand = false;
   2.148 +			w21.Fill = false;
   2.149  			this.vbox1.Add(this.hbox2);
   2.150 -			global::Gtk.Box.BoxChild w19 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.hbox2]));
   2.151 -			w19.Position = 3;
   2.152 -			w19.Expand = false;
   2.153 -			w19.Fill = false;
   2.154 +			global::Gtk.Box.BoxChild w22 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.hbox2]));
   2.155 +			w22.Position = 3;
   2.156 +			w22.Expand = false;
   2.157 +			w22.Fill = false;
   2.158  			this.Add(this.vbox1);
   2.159  			if ((this.Child != null))
   2.160  			{
     3.1 --- a/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs	Sat Nov 06 17:03:13 2010 +0000
     3.2 +++ b/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs	Sat Nov 06 20:22:19 2010 +0000
     3.3 @@ -120,6 +120,7 @@
     3.4  			this.rbEquipAll = new global::Gtk.RadioButton("");
     3.5  			this.rbEquipAll.CanFocus = true;
     3.6  			this.rbEquipAll.Name = "rbEquipAll";
     3.7 +			this.rbEquipAll.Active = true;
     3.8  			this.rbEquipAll.DrawIndicator = true;
     3.9  			this.rbEquipAll.UseUnderline = true;
    3.10  			this.rbEquipAll.Group = new global::GLib.SList(global::System.IntPtr.Zero);
     4.1 --- a/gtk-gui/gui.stetic	Sat Nov 06 17:03:13 2010 +0000
     4.2 +++ b/gtk-gui/gui.stetic	Sat Nov 06 20:22:19 2010 +0000
     4.3 @@ -770,7 +770,7 @@
     4.4              <child>
     4.5                <widget class="Gtk.Table" id="table1">
     4.6                  <property name="MemberName" />
     4.7 -                <property name="NRows">2</property>
     4.8 +                <property name="NRows">3</property>
     4.9                  <property name="NColumns">2</property>
    4.10                  <property name="RowSpacing">6</property>
    4.11                  <property name="ColumnSpacing">6</property>
    4.12 @@ -832,6 +832,34 @@
    4.13                      </child>
    4.14                    </widget>
    4.15                    <packing>
    4.16 +                    <property name="TopAttach">2</property>
    4.17 +                    <property name="BottomAttach">3</property>
    4.18 +                    <property name="LeftAttach">1</property>
    4.19 +                    <property name="RightAttach">2</property>
    4.20 +                    <property name="AutoSize">True</property>
    4.21 +                    <property name="YOptions">Fill</property>
    4.22 +                    <property name="XExpand">True</property>
    4.23 +                    <property name="XFill">True</property>
    4.24 +                    <property name="XShrink">False</property>
    4.25 +                    <property name="YExpand">False</property>
    4.26 +                    <property name="YFill">True</property>
    4.27 +                    <property name="YShrink">False</property>
    4.28 +                  </packing>
    4.29 +                </child>
    4.30 +                <child>
    4.31 +                  <widget class="Gtk.ScrolledWindow" id="GtkScrolledWindow4">
    4.32 +                    <property name="MemberName" />
    4.33 +                    <property name="ShadowType">In</property>
    4.34 +                    <child>
    4.35 +                      <widget class="Gtk.NodeView" id="abilitiesList">
    4.36 +                        <property name="MemberName" />
    4.37 +                        <property name="CanFocus">True</property>
    4.38 +                        <property name="ShowScrollbars">True</property>
    4.39 +                        <property name="HeadersVisible">False</property>
    4.40 +                      </widget>
    4.41 +                    </child>
    4.42 +                  </widget>
    4.43 +                  <packing>
    4.44                      <property name="TopAttach">1</property>
    4.45                      <property name="BottomAttach">2</property>
    4.46                      <property name="LeftAttach">1</property>
    4.47 @@ -847,13 +875,32 @@
    4.48                    </packing>
    4.49                  </child>
    4.50                  <child>
    4.51 +                  <widget class="Gtk.Label" id="lblAbilities">
    4.52 +                    <property name="MemberName" />
    4.53 +                    <property name="LabelProp" translatable="yes">abilities:</property>
    4.54 +                  </widget>
    4.55 +                  <packing>
    4.56 +                    <property name="TopAttach">1</property>
    4.57 +                    <property name="BottomAttach">2</property>
    4.58 +                    <property name="AutoSize">True</property>
    4.59 +                    <property name="XOptions">Fill</property>
    4.60 +                    <property name="YOptions">Fill</property>
    4.61 +                    <property name="XExpand">False</property>
    4.62 +                    <property name="XFill">True</property>
    4.63 +                    <property name="XShrink">False</property>
    4.64 +                    <property name="YExpand">False</property>
    4.65 +                    <property name="YFill">True</property>
    4.66 +                    <property name="YShrink">False</property>
    4.67 +                  </packing>
    4.68 +                </child>
    4.69 +                <child>
    4.70                    <widget class="Gtk.Label" id="lblNotes">
    4.71                      <property name="MemberName" />
    4.72                      <property name="LabelProp" translatable="yes">notes:</property>
    4.73                    </widget>
    4.74                    <packing>
    4.75 -                    <property name="TopAttach">1</property>
    4.76 -                    <property name="BottomAttach">2</property>
    4.77 +                    <property name="TopAttach">2</property>
    4.78 +                    <property name="BottomAttach">3</property>
    4.79                      <property name="AutoSize">True</property>
    4.80                      <property name="XOptions">Fill</property>
    4.81                      <property name="YOptions">Fill</property>
    4.82 @@ -1129,6 +1176,7 @@
    4.83                          <property name="MemberName" />
    4.84                          <property name="CanFocus">True</property>
    4.85                          <property name="Label" translatable="yes" />
    4.86 +                        <property name="Active">True</property>
    4.87                          <property name="DrawIndicator">True</property>
    4.88                          <property name="HasLabel">True</property>
    4.89                          <property name="UseUnderline">True</property>
    4.90 @@ -1448,7 +1496,6 @@
    4.91                          <property name="MemberName" />
    4.92                          <property name="CanFocus">True</property>
    4.93                          <property name="Label" translatable="yes" />
    4.94 -                        <property name="Active">True</property>
    4.95                          <property name="DrawIndicator">True</property>
    4.96                          <property name="HasLabel">True</property>
    4.97                          <property name="UseUnderline">True</property>