Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.GTK
comparison Widgets/UnitDisplayWidget.cs @ 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 | 7028e24b67ec |
children | f0cc295e883c |
comparison
equal
deleted
inserted
replaced
70:4b82515586ac | 71:91354245218a |
---|---|
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. | 3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. |
4 | 4 |
5 using System; | 5 using System; |
6 using Gtk; | 6 using Gtk; |
7 using IBBoard.Commands; | 7 using IBBoard.Commands; |
8 using IBBoard.GtkSharp; | |
8 using IBBoard.Lang; | 9 using IBBoard.Lang; |
9 using IBBoard.WarFoundry.API; | 10 using IBBoard.WarFoundry.API; |
10 using WFObjects = IBBoard.WarFoundry.API.Objects; | |
11 using IBBoard.WarFoundry.API.Commands; | 11 using IBBoard.WarFoundry.API.Commands; |
12 using IBBoard.WarFoundry.GUI.GTK.UIControl; | |
13 using IBBoard.WarFoundry.API.Objects; | 12 using IBBoard.WarFoundry.API.Objects; |
14 using IBBoard.WarFoundry.API.Util; | 13 using IBBoard.WarFoundry.API.Util; |
15 using IBBoard.GtkSharp; | 14 using IBBoard.WarFoundry.GUI.GTK.UIControl; |
16 using log4net; | 15 using log4net; |
16 using WFObjects = IBBoard.WarFoundry.API.Objects; | |
17 | 17 |
18 namespace IBBoard.WarFoundry.GTK.Widgets | 18 namespace IBBoard.WarFoundry.GTK.Widgets |
19 { | 19 { |
20 [System.ComponentModel.Category("WarFoundry GTK# GUI")] | 20 [System.ComponentModel.Category("WarFoundry GTK# GUI")] |
21 [System.ComponentModel.ToolboxItem(true)] | 21 [System.ComponentModel.ToolboxItem(true)] |
39 notesView.Buffer.Text = unit.UnitType.Notes; | 39 notesView.Buffer.Text = unit.UnitType.Notes; |
40 unit.NameChanged += UnitNameChanged; | 40 unit.NameChanged += UnitNameChanged; |
41 unit.UnitSizeChanged += UnitSizeChanged; | 41 unit.UnitSizeChanged += UnitSizeChanged; |
42 unit.UnitEquipmentAmountChanged += HandleUnitUnitEquipmentAmountChanged; | 42 unit.UnitEquipmentAmountChanged += HandleUnitUnitEquipmentAmountChanged; |
43 equipmentList.Selection.Changed += HandleEquipmentListSelectionChanged; | 43 equipmentList.Selection.Changed += HandleEquipmentListSelectionChanged; |
44 SetAbilities(); | |
44 SetStats(); | 45 SetStats(); |
45 SetWeapons(); | 46 SetWeapons(); |
46 } | 47 } |
47 | 48 |
48 private void HandleEquipmentListSelectionChanged(object sender, EventArgs e) | 49 private void HandleEquipmentListSelectionChanged(object sender, EventArgs e) |
59 } | 60 } |
60 | 61 |
61 private UnitEquipmentItem GetSelectedEquipmentItem() | 62 private UnitEquipmentItem GetSelectedEquipmentItem() |
62 { | 63 { |
63 return (UnitEquipmentItem)TreeUtils.GetSelectedItem(equipmentList); | 64 return (UnitEquipmentItem)TreeUtils.GetSelectedItem(equipmentList); |
65 } | |
66 | |
67 private void SetAbilities() | |
68 { | |
69 CellRendererText renderer = new CellRendererText(); | |
70 abilitiesList.AppendColumn("", renderer, new TreeCellDataFunc(RenderAbility)); | |
71 | |
72 ListStore model = new ListStore(typeof(Ability)); | |
73 | |
74 foreach (Ability ability in unit.UnitType.GetRequiredAbilities()) | |
75 { | |
76 model.AppendValues(ability); | |
77 } | |
78 | |
79 abilitiesList.Model = model; | |
80 } | |
81 | |
82 public void RenderAbility(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) | |
83 { | |
84 object o = model.GetValue(iter, 0); | |
85 | |
86 if (o is Ability) | |
87 { | |
88 Ability ability = (Ability)o; | |
89 (cell as CellRendererText).Text = ability.Name; | |
90 } | |
91 | |
64 } | 92 } |
65 | 93 |
66 private void SetStats() | 94 private void SetStats() |
67 { | 95 { |
68 CellRendererText renderer = new CellRendererText(); | 96 CellRendererText renderer = new CellRendererText(); |