# HG changeset patch # User IBBoard # Date 1289074939 0 # Node ID 91354245218a077b4b8681c084b3aa308116d8db # Parent 4b82515586ace2635155168479f66826402f4e10 Fixes #305: Add abilities to GTK# UI * Add Abilities section to UnitDisplayWidget that shows list of required abilities diff -r 4b82515586ac -r 91354245218a Widgets/UnitDisplayWidget.cs --- a/Widgets/UnitDisplayWidget.cs Sat Nov 06 17:03:13 2010 +0000 +++ b/Widgets/UnitDisplayWidget.cs Sat Nov 06 20:22:19 2010 +0000 @@ -5,15 +5,15 @@ using System; using Gtk; using IBBoard.Commands; +using IBBoard.GtkSharp; using IBBoard.Lang; using IBBoard.WarFoundry.API; -using WFObjects = IBBoard.WarFoundry.API.Objects; using IBBoard.WarFoundry.API.Commands; -using IBBoard.WarFoundry.GUI.GTK.UIControl; using IBBoard.WarFoundry.API.Objects; using IBBoard.WarFoundry.API.Util; -using IBBoard.GtkSharp; +using IBBoard.WarFoundry.GUI.GTK.UIControl; using log4net; +using WFObjects = IBBoard.WarFoundry.API.Objects; namespace IBBoard.WarFoundry.GTK.Widgets { @@ -41,6 +41,7 @@ unit.UnitSizeChanged += UnitSizeChanged; unit.UnitEquipmentAmountChanged += HandleUnitUnitEquipmentAmountChanged; equipmentList.Selection.Changed += HandleEquipmentListSelectionChanged; + SetAbilities(); SetStats(); SetWeapons(); } @@ -62,6 +63,33 @@ { return (UnitEquipmentItem)TreeUtils.GetSelectedItem(equipmentList); } + + private void SetAbilities() + { + CellRendererText renderer = new CellRendererText(); + abilitiesList.AppendColumn("", renderer, new TreeCellDataFunc(RenderAbility)); + + ListStore model = new ListStore(typeof(Ability)); + + foreach (Ability ability in unit.UnitType.GetRequiredAbilities()) + { + model.AppendValues(ability); + } + + abilitiesList.Model = model; + } + + public void RenderAbility(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) + { + object o = model.GetValue(iter, 0); + + if (o is Ability) + { + Ability ability = (Ability)o; + (cell as CellRendererText).Text = ability.Name; + } + + } private void SetStats() { diff -r 4b82515586ac -r 91354245218a gtk-gui/IBBoard.WarFoundry.GTK.Widgets.UnitDisplayWidget.cs --- a/gtk-gui/IBBoard.WarFoundry.GTK.Widgets.UnitDisplayWidget.cs Sat Nov 06 17:03:13 2010 +0000 +++ b/gtk-gui/IBBoard.WarFoundry.GTK.Widgets.UnitDisplayWidget.cs Sat Nov 06 20:22:19 2010 +0000 @@ -18,6 +18,9 @@ private global::Gtk.NodeView equipmentList; private global::Gtk.ScrolledWindow GtkScrolledWindow3; private global::Gtk.TextView notesView; + private global::Gtk.ScrolledWindow GtkScrolledWindow4; + private global::Gtk.NodeView abilitiesList; + private global::Gtk.Label lblAbilities; private global::Gtk.Label lblNotes; private global::Gtk.VBox vbox3; private global::Gtk.Button bttnAddEquipment; @@ -91,7 +94,7 @@ this.hbox2.Name = "hbox2"; this.hbox2.Spacing = 6; // Container child hbox2.Gtk.Box+BoxChild - this.table1 = new global::Gtk.Table(((uint)(2)), ((uint)(2)), false); + this.table1 = new global::Gtk.Table(((uint)(3)), ((uint)(2)), false); this.table1.Name = "table1"; this.table1.RowSpacing = ((uint)(6)); this.table1.ColumnSpacing = ((uint)(6)); @@ -130,24 +133,51 @@ this.GtkScrolledWindow3.Add(this.notesView); this.table1.Add(this.GtkScrolledWindow3); global::Gtk.Table.TableChild w11 = ((global::Gtk.Table.TableChild)(this.table1[this.GtkScrolledWindow3])); - w11.TopAttach = ((uint)(1)); - w11.BottomAttach = ((uint)(2)); + w11.TopAttach = ((uint)(2)); + w11.BottomAttach = ((uint)(3)); w11.LeftAttach = ((uint)(1)); w11.RightAttach = ((uint)(2)); w11.YOptions = ((global::Gtk.AttachOptions)(4)); // Container child table1.Gtk.Table+TableChild + this.GtkScrolledWindow4 = new global::Gtk.ScrolledWindow(); + this.GtkScrolledWindow4.Name = "GtkScrolledWindow4"; + this.GtkScrolledWindow4.ShadowType = ((global::Gtk.ShadowType)(1)); + // Container child GtkScrolledWindow4.Gtk.Container+ContainerChild + this.abilitiesList = new global::Gtk.NodeView(); + this.abilitiesList.CanFocus = true; + this.abilitiesList.Name = "abilitiesList"; + this.abilitiesList.HeadersVisible = false; + this.GtkScrolledWindow4.Add(this.abilitiesList); + this.table1.Add(this.GtkScrolledWindow4); + global::Gtk.Table.TableChild w13 = ((global::Gtk.Table.TableChild)(this.table1[this.GtkScrolledWindow4])); + w13.TopAttach = ((uint)(1)); + w13.BottomAttach = ((uint)(2)); + w13.LeftAttach = ((uint)(1)); + w13.RightAttach = ((uint)(2)); + w13.YOptions = ((global::Gtk.AttachOptions)(4)); + // Container child table1.Gtk.Table+TableChild + this.lblAbilities = new global::Gtk.Label(); + this.lblAbilities.Name = "lblAbilities"; + this.lblAbilities.LabelProp = global::Mono.Unix.Catalog.GetString("abilities:"); + this.table1.Add(this.lblAbilities); + global::Gtk.Table.TableChild w14 = ((global::Gtk.Table.TableChild)(this.table1[this.lblAbilities])); + w14.TopAttach = ((uint)(1)); + w14.BottomAttach = ((uint)(2)); + w14.XOptions = ((global::Gtk.AttachOptions)(4)); + w14.YOptions = ((global::Gtk.AttachOptions)(4)); + // Container child table1.Gtk.Table+TableChild this.lblNotes = new global::Gtk.Label(); this.lblNotes.Name = "lblNotes"; this.lblNotes.LabelProp = global::Mono.Unix.Catalog.GetString("notes:"); this.table1.Add(this.lblNotes); - global::Gtk.Table.TableChild w12 = ((global::Gtk.Table.TableChild)(this.table1[this.lblNotes])); - w12.TopAttach = ((uint)(1)); - w12.BottomAttach = ((uint)(2)); - w12.XOptions = ((global::Gtk.AttachOptions)(4)); - w12.YOptions = ((global::Gtk.AttachOptions)(4)); + global::Gtk.Table.TableChild w15 = ((global::Gtk.Table.TableChild)(this.table1[this.lblNotes])); + w15.TopAttach = ((uint)(2)); + w15.BottomAttach = ((uint)(3)); + w15.XOptions = ((global::Gtk.AttachOptions)(4)); + w15.YOptions = ((global::Gtk.AttachOptions)(4)); this.hbox2.Add(this.table1); - global::Gtk.Box.BoxChild w13 = ((global::Gtk.Box.BoxChild)(this.hbox2[this.table1])); - w13.Position = 0; + global::Gtk.Box.BoxChild w16 = ((global::Gtk.Box.BoxChild)(this.hbox2[this.table1])); + w16.Position = 0; // Container child hbox2.Gtk.Box+BoxChild this.vbox3 = new global::Gtk.VBox(); this.vbox3.Name = "vbox3"; @@ -159,10 +189,10 @@ this.bttnAddEquipment.UseUnderline = true; this.bttnAddEquipment.Label = global::Mono.Unix.Catalog.GetString("Add"); this.vbox3.Add(this.bttnAddEquipment); - global::Gtk.Box.BoxChild w14 = ((global::Gtk.Box.BoxChild)(this.vbox3[this.bttnAddEquipment])); - w14.Position = 0; - w14.Expand = false; - w14.Fill = false; + global::Gtk.Box.BoxChild w17 = ((global::Gtk.Box.BoxChild)(this.vbox3[this.bttnAddEquipment])); + w17.Position = 0; + w17.Expand = false; + w17.Fill = false; // Container child vbox3.Gtk.Box+BoxChild this.bttnEditEquipment = new global::Gtk.Button(); this.bttnEditEquipment.Sensitive = false; @@ -171,10 +201,10 @@ this.bttnEditEquipment.UseUnderline = true; this.bttnEditEquipment.Label = global::Mono.Unix.Catalog.GetString("Edit"); this.vbox3.Add(this.bttnEditEquipment); - global::Gtk.Box.BoxChild w15 = ((global::Gtk.Box.BoxChild)(this.vbox3[this.bttnEditEquipment])); - w15.Position = 1; - w15.Expand = false; - w15.Fill = false; + global::Gtk.Box.BoxChild w18 = ((global::Gtk.Box.BoxChild)(this.vbox3[this.bttnEditEquipment])); + w18.Position = 1; + w18.Expand = false; + w18.Fill = false; // Container child vbox3.Gtk.Box+BoxChild this.bttnReplaceEquipment = new global::Gtk.Button(); this.bttnReplaceEquipment.Sensitive = false; @@ -183,10 +213,10 @@ this.bttnReplaceEquipment.UseUnderline = true; this.bttnReplaceEquipment.Label = global::Mono.Unix.Catalog.GetString("Replace"); this.vbox3.Add(this.bttnReplaceEquipment); - global::Gtk.Box.BoxChild w16 = ((global::Gtk.Box.BoxChild)(this.vbox3[this.bttnReplaceEquipment])); - w16.Position = 2; - w16.Expand = false; - w16.Fill = false; + global::Gtk.Box.BoxChild w19 = ((global::Gtk.Box.BoxChild)(this.vbox3[this.bttnReplaceEquipment])); + w19.Position = 2; + w19.Expand = false; + w19.Fill = false; // Container child vbox3.Gtk.Box+BoxChild this.bttnRemoveEquipment = new global::Gtk.Button(); this.bttnRemoveEquipment.Sensitive = false; @@ -195,20 +225,20 @@ this.bttnRemoveEquipment.UseUnderline = true; this.bttnRemoveEquipment.Label = global::Mono.Unix.Catalog.GetString("Remove"); this.vbox3.Add(this.bttnRemoveEquipment); - global::Gtk.Box.BoxChild w17 = ((global::Gtk.Box.BoxChild)(this.vbox3[this.bttnRemoveEquipment])); - w17.Position = 3; - w17.Expand = false; - w17.Fill = false; + global::Gtk.Box.BoxChild w20 = ((global::Gtk.Box.BoxChild)(this.vbox3[this.bttnRemoveEquipment])); + w20.Position = 3; + w20.Expand = false; + w20.Fill = false; this.hbox2.Add(this.vbox3); - global::Gtk.Box.BoxChild w18 = ((global::Gtk.Box.BoxChild)(this.hbox2[this.vbox3])); - w18.Position = 1; - w18.Expand = false; - w18.Fill = false; + global::Gtk.Box.BoxChild w21 = ((global::Gtk.Box.BoxChild)(this.hbox2[this.vbox3])); + w21.Position = 1; + w21.Expand = false; + w21.Fill = false; this.vbox1.Add(this.hbox2); - global::Gtk.Box.BoxChild w19 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.hbox2])); - w19.Position = 3; - w19.Expand = false; - w19.Fill = false; + global::Gtk.Box.BoxChild w22 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.hbox2])); + w22.Position = 3; + w22.Expand = false; + w22.Fill = false; this.Add(this.vbox1); if ((this.Child != null)) { diff -r 4b82515586ac -r 91354245218a gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs --- a/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs Sat Nov 06 17:03:13 2010 +0000 +++ b/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs Sat Nov 06 20:22:19 2010 +0000 @@ -120,6 +120,7 @@ this.rbEquipAll = new global::Gtk.RadioButton(""); this.rbEquipAll.CanFocus = true; this.rbEquipAll.Name = "rbEquipAll"; + this.rbEquipAll.Active = true; this.rbEquipAll.DrawIndicator = true; this.rbEquipAll.UseUnderline = true; this.rbEquipAll.Group = new global::GLib.SList(global::System.IntPtr.Zero); diff -r 4b82515586ac -r 91354245218a gtk-gui/gui.stetic --- a/gtk-gui/gui.stetic Sat Nov 06 17:03:13 2010 +0000 +++ b/gtk-gui/gui.stetic Sat Nov 06 20:22:19 2010 +0000 @@ -770,7 +770,7 @@ - 2 + 3 2 6 6 @@ -832,6 +832,34 @@ + 2 + 3 + 1 + 2 + True + Fill + True + True + False + False + True + False + + + + + + In + + + + True + True + False + + + + 1 2 1 @@ -847,13 +875,32 @@ + + + abilities: + + + 1 + 2 + True + Fill + Fill + False + True + False + False + True + False + + + notes: - 1 - 2 + 2 + 3 True Fill Fill @@ -1129,6 +1176,7 @@ True + True True True True @@ -1448,7 +1496,6 @@ True - True True True True