24
|
1 // This file (FrmUnit.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2009 IBBoard.
|
|
2 //
|
|
3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license.
|
|
4
|
|
5 using System;
|
|
6 using System.Drawing;
|
|
7 using System.Data;
|
|
8 using System.Collections.Generic;
|
|
9 using System.ComponentModel;
|
|
10 using System.Windows.Forms;
|
|
11 using IBBoard.Commands;
|
|
12 using IBBoard.Windows.Forms;
|
|
13 using IBBoard.WarFoundry.API;
|
|
14 using IBBoard.WarFoundry.API.Commands;
|
|
15 using IBBoard.WarFoundry.API.Objects;
|
|
16 using IBBoard.WarFoundry.GUI.WinForms.Util;
|
|
17
|
|
18 namespace IBBoard.WarFoundry
|
|
19 {
|
|
20 ///TODO: Separate weapons out into optional and required, where required only has button for replacing
|
|
21
|
|
22 /// <summary>
|
|
23 /// Summary description for FrmUnit.
|
|
24 /// </summary>
|
|
25 public class FrmUnit : IBBoard.Windows.Forms.IBBForm
|
|
26 {
|
|
27 private Unit unit;
|
|
28 private Dictionary<UnitEquipmentItem, UnitEquipmentChoice> equipmentChoices = new Dictionary<UnitEquipmentItem, UnitEquipmentChoice>();
|
|
29 private CommandStack commandStack;
|
|
30 private System.Windows.Forms.DataGrid statsGrid;
|
|
31 private System.Windows.Forms.TextBox tbUnitName;
|
|
32 private System.Windows.Forms.NumericUpDown unitSize;
|
|
33 private System.Windows.Forms.Label lblUnitSize;
|
|
34 private System.Windows.Forms.Button bttnAddWeapon;
|
|
35 private System.Windows.Forms.Button bttnRemoveWeapon;
|
|
36 private System.Windows.Forms.Button bttnEditWeapon;
|
|
37 private System.Windows.Forms.Label lblRequiredEquip;
|
|
38 private System.Windows.Forms.ListBox reqdList;
|
|
39 private System.Windows.Forms.ListBox optList;
|
|
40 private System.Windows.Forms.Label lblOptionalEquip;
|
|
41 private System.Windows.Forms.Button bttnReplaceWeapon;
|
|
42 private System.Windows.Forms.Button bttnEditReqdWeapon;
|
|
43 /// <summary>
|
|
44 /// Required designer variable.
|
|
45 /// </summary>
|
|
46 private System.ComponentModel.Container components = null;
|
|
47
|
|
48 public FrmUnit(Unit toDisplay, CommandStack cmdStack)
|
|
49 {
|
|
50 unit = toDisplay;
|
|
51 commandStack = cmdStack;
|
|
52 //
|
|
53 // Required for Windows Form Designer support
|
|
54 //
|
|
55 InitializeComponent();
|
|
56
|
|
57 tbUnitName.Text = unit.Name;
|
|
58 Text = unit.Name;
|
|
59 unit.NameChanged+=new StringValChangedDelegate(unit_NameChanged);
|
|
60 unit.UnitSizeChanged+= new IntValChangedDelegate(unit_UnitSizeChanged);
|
|
61 unit.UnitEquipmentAmountChanged+=new DoubleValChangedDelegate(unit_UnitEquipmentAmountChanged);
|
|
62
|
|
63 if (unit.UnitType.MaxSize==unit.UnitType.MinSize)
|
|
64 {
|
|
65 unitSize.Value = unit.UnitType.MaxSize;
|
|
66 unitSize.Visible = false;
|
|
67 lblUnitSize.Visible = false;
|
|
68 }
|
|
69 else
|
|
70 {
|
|
71 unitSize.Value = unit.Size;
|
|
72 unitSize.Maximum = (unit.UnitType.MaxSize == WarFoundryCore.INFINITY ? int.MaxValue : unit.UnitType.MaxSize);
|
|
73 unitSize.Minimum = unit.UnitType.MinSize;
|
|
74 }
|
|
75
|
|
76 SetStats();
|
|
77 SetWeapons();
|
|
78 }
|
|
79
|
|
80 private void SetStats()
|
|
81 {
|
|
82 DataTable dt = new DataTable();
|
|
83 Stat[] stats = unit.UnitStatsArrayWithName;
|
|
84 DataColumn[] dc = new DataColumn[stats.Length+1];
|
|
85 dc[0] = new DataColumn("name");
|
|
86
|
|
87 DataGridTableStyle dgStyle = new DataGridTableStyle();
|
|
88 dgStyle.RowHeadersVisible = false;
|
|
89
|
|
90 DataGridTextBoxColumn colStyle = new DataGridTextBoxColumn();
|
|
91 colStyle.Width = statsGrid.ClientSize.Width - (stats.Length * 40) - 4;
|
|
92 colStyle.MappingName = "name";
|
|
93 colStyle.HeaderText = "name";
|
|
94 colStyle.ReadOnly = true;
|
|
95 dgStyle.GridColumnStyles.Add(colStyle);
|
|
96
|
|
97 DataColumn tempCol;
|
|
98 int i = 1;
|
|
99
|
|
100 foreach (Stat stat in stats)
|
|
101 {
|
|
102 tempCol = new DataColumn(stat.ParentSlotName);
|
|
103 dc[i] = tempCol;
|
|
104 colStyle = new DataGridTextBoxColumn();
|
|
105 colStyle.Alignment = HorizontalAlignment.Center;
|
|
106 colStyle.Width = 40;
|
|
107 colStyle.MappingName = stat.ParentSlotName;
|
|
108 colStyle.HeaderText = stat.ParentSlotName;
|
|
109 colStyle.ReadOnly = true;
|
|
110 dgStyle.GridColumnStyles.Add(colStyle);
|
|
111 i++;
|
|
112 }
|
|
113
|
|
114 dt.Columns.AddRange(dc);
|
|
115
|
|
116 DataRow dr = dt.NewRow();
|
|
117 dr.ItemArray = unit.UnitStatsArrayWithName;
|
|
118 dt.Rows.Add(dr);
|
|
119 statsGrid.DataSource = dt;
|
|
120 statsGrid.TableStyles.Add(dgStyle);
|
|
121 }
|
|
122
|
|
123 private void SetWeapons()
|
|
124 {
|
|
125 foreach(UnitEquipmentItem item in unit.GetEquipment())
|
|
126 {
|
|
127 if (item.IsRequired)
|
|
128 {
|
|
129 reqdList.Items.Add(GetEquipmentChoice(item));
|
|
130 }
|
|
131 else
|
|
132 {
|
|
133 optList.Items.Add(GetEquipmentChoice(item));
|
|
134 }
|
|
135 }
|
|
136 }
|
|
137
|
|
138 private UnitEquipmentChoice GetEquipmentChoice(UnitEquipmentItem item)
|
|
139 {
|
|
140 UnitEquipmentChoice choice = null;
|
|
141 equipmentChoices.TryGetValue(item, out choice);
|
|
142
|
|
143 if (choice == null)
|
|
144 {
|
|
145 choice = new UnitEquipmentChoice(Unit, item);
|
|
146 equipmentChoices[item] = choice;
|
|
147 }
|
|
148
|
|
149 return choice;
|
|
150 }
|
|
151
|
|
152 /// <summary>
|
|
153 /// Clean up any resources being used.
|
|
154 /// </summary>
|
|
155 protected override void Dispose( bool disposing )
|
|
156 {
|
|
157 //remove our leave events so that disposing doesn't trigger them
|
|
158 tbUnitName.Leave-= new System.EventHandler(this.tbUnitName_Leave);
|
|
159 unitSize.Leave-= new System.EventHandler(this.unitSize_Leave);
|
|
160
|
|
161 if( disposing )
|
|
162 {
|
|
163 if(components != null)
|
|
164 {
|
|
165 components.Dispose();
|
|
166 }
|
|
167 }
|
|
168 base.Dispose( disposing );
|
|
169 }
|
|
170
|
|
171 #region Windows Form Designer generated code
|
|
172 /// <summary>
|
|
173 /// Required method for Designer support - do not modify
|
|
174 /// the contents of this method with the code editor.
|
|
175 /// </summary>
|
|
176 private void InitializeComponent()
|
|
177 {
|
|
178 this.statsGrid = new System.Windows.Forms.DataGrid();
|
|
179 this.tbUnitName = new System.Windows.Forms.TextBox();
|
|
180 this.unitSize = new System.Windows.Forms.NumericUpDown();
|
|
181 this.lblUnitSize = new System.Windows.Forms.Label();
|
|
182 this.lblRequiredEquip = new System.Windows.Forms.Label();
|
|
183 this.bttnAddWeapon = new System.Windows.Forms.Button();
|
|
184 this.bttnRemoveWeapon = new System.Windows.Forms.Button();
|
|
185 this.reqdList = new System.Windows.Forms.ListBox();
|
|
186 this.bttnEditWeapon = new System.Windows.Forms.Button();
|
|
187 this.optList = new System.Windows.Forms.ListBox();
|
|
188 this.lblOptionalEquip = new System.Windows.Forms.Label();
|
|
189 this.bttnReplaceWeapon = new System.Windows.Forms.Button();
|
|
190 this.bttnEditReqdWeapon = new System.Windows.Forms.Button();
|
|
191 ((System.ComponentModel.ISupportInitialize)(this.statsGrid)).BeginInit();
|
|
192 ((System.ComponentModel.ISupportInitialize)(this.unitSize)).BeginInit();
|
|
193 this.SuspendLayout();
|
|
194 //
|
|
195 // statsGrid
|
|
196 //
|
|
197 this.statsGrid.AllowNavigation = false;
|
|
198 this.statsGrid.AllowSorting = false;
|
|
199 this.statsGrid.AlternatingBackColor = System.Drawing.SystemColors.Control;
|
|
200 this.statsGrid.BackgroundColor = System.Drawing.SystemColors.Control;
|
|
201 this.statsGrid.CaptionVisible = false;
|
|
202 this.statsGrid.DataMember = "";
|
|
203 this.statsGrid.GridLineColor = System.Drawing.SystemColors.ControlDarkDark;
|
|
204 this.statsGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText;
|
|
205 this.statsGrid.Location = new System.Drawing.Point(8, 32);
|
|
206 this.statsGrid.Name = "statsGrid";
|
|
207 this.statsGrid.PreferredColumnWidth = 40;
|
|
208 this.statsGrid.ReadOnly = true;
|
|
209 this.statsGrid.RowHeadersVisible = false;
|
|
210 this.statsGrid.SelectionBackColor = System.Drawing.SystemColors.Control;
|
|
211 this.statsGrid.SelectionForeColor = System.Drawing.SystemColors.WindowText;
|
|
212 this.statsGrid.Size = new System.Drawing.Size(600, 88);
|
|
213 this.statsGrid.TabIndex = 0;
|
|
214 this.statsGrid.TabStop = false;
|
|
215 //
|
|
216 // tbUnitName
|
|
217 //
|
|
218 this.tbUnitName.Location = new System.Drawing.Point(8, 8);
|
|
219 this.tbUnitName.Name = "tbUnitName";
|
|
220 this.tbUnitName.Size = new System.Drawing.Size(344, 20);
|
|
221 this.tbUnitName.TabIndex = 1;
|
|
222 this.tbUnitName.Text = "";
|
|
223 this.tbUnitName.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbUnitName_KeyDown);
|
|
224 this.tbUnitName.Leave += new System.EventHandler(this.tbUnitName_Leave);
|
|
225 //
|
|
226 // unitSize
|
|
227 //
|
|
228 this.unitSize.Location = new System.Drawing.Point(528, 8);
|
|
229 this.unitSize.Name = "unitSize";
|
|
230 this.unitSize.Size = new System.Drawing.Size(80, 20);
|
|
231 this.unitSize.TabIndex = 1;
|
|
232 this.unitSize.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
|
233 this.unitSize.Value = new System.Decimal(new int[] {
|
|
234 1,
|
|
235 0,
|
|
236 0,
|
|
237 0});
|
|
238 this.unitSize.KeyDown += new System.Windows.Forms.KeyEventHandler(this.unitSize_KeyDown);
|
|
239 this.unitSize.Leave += new System.EventHandler(this.unitSize_Leave);
|
|
240 //
|
|
241 // lblUnitSize
|
|
242 //
|
|
243 this.lblUnitSize.Location = new System.Drawing.Point(424, 8);
|
|
244 this.lblUnitSize.Name = "lblUnitSize";
|
|
245 this.lblUnitSize.TabIndex = 0;
|
|
246 this.lblUnitSize.Text = "unit size";
|
|
247 this.lblUnitSize.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
|
248 //
|
|
249 // lblRequiredEquip
|
|
250 //
|
|
251 this.lblRequiredEquip.Location = new System.Drawing.Point(8, 128);
|
|
252 this.lblRequiredEquip.Name = "lblRequiredEquip";
|
|
253 this.lblRequiredEquip.Size = new System.Drawing.Size(88, 32);
|
|
254 this.lblRequiredEquip.TabIndex = 3;
|
|
255 this.lblRequiredEquip.Text = "reqd equipment";
|
|
256 this.lblRequiredEquip.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
|
257 //
|
|
258 // bttnAddWeapon
|
|
259 //
|
|
260 this.bttnAddWeapon.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
|
261 this.bttnAddWeapon.Location = new System.Drawing.Point(520, 200);
|
|
262 this.bttnAddWeapon.Name = "bttnAddWeapon";
|
|
263 this.bttnAddWeapon.Size = new System.Drawing.Size(88, 22);
|
|
264 this.bttnAddWeapon.TabIndex = 4;
|
|
265 this.bttnAddWeapon.Text = "add";
|
|
266 this.bttnAddWeapon.Click += new System.EventHandler(this.bttnAddWeapon_Click);
|
|
267 //
|
|
268 // bttnRemoveWeapon
|
|
269 //
|
|
270 this.bttnRemoveWeapon.Enabled = false;
|
|
271 this.bttnRemoveWeapon.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
|
272 this.bttnRemoveWeapon.Location = new System.Drawing.Point(520, 248);
|
|
273 this.bttnRemoveWeapon.Name = "bttnRemoveWeapon";
|
|
274 this.bttnRemoveWeapon.Size = new System.Drawing.Size(88, 22);
|
|
275 this.bttnRemoveWeapon.TabIndex = 5;
|
|
276 this.bttnRemoveWeapon.Text = "remove";
|
|
277 this.bttnRemoveWeapon.Click += new System.EventHandler(this.bttnRemoveWeapon_Click);
|
|
278 //
|
|
279 // reqdList
|
|
280 //
|
|
281 this.reqdList.Location = new System.Drawing.Point(104, 128);
|
|
282 this.reqdList.Name = "reqdList";
|
|
283 this.reqdList.Size = new System.Drawing.Size(408, 69);
|
|
284 this.reqdList.TabIndex = 6;
|
|
285 this.reqdList.DoubleClick += new System.EventHandler(this.reqdList_DoubleClick);
|
|
286 this.reqdList.SelectedIndexChanged += new System.EventHandler(this.reqdList_SelectedIndexChanged);
|
|
287 //
|
|
288 // bttnEditWeapon
|
|
289 //
|
|
290 this.bttnEditWeapon.Enabled = false;
|
|
291 this.bttnEditWeapon.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
|
292 this.bttnEditWeapon.Location = new System.Drawing.Point(520, 224);
|
|
293 this.bttnEditWeapon.Name = "bttnEditWeapon";
|
|
294 this.bttnEditWeapon.Size = new System.Drawing.Size(88, 22);
|
|
295 this.bttnEditWeapon.TabIndex = 7;
|
|
296 this.bttnEditWeapon.Text = "edit";
|
|
297 this.bttnEditWeapon.Click += new System.EventHandler(this.bttnEditWeapon_Click);
|
|
298 //
|
|
299 // optList
|
|
300 //
|
|
301 this.optList.Location = new System.Drawing.Point(104, 200);
|
|
302 this.optList.Name = "optList";
|
|
303 this.optList.Size = new System.Drawing.Size(408, 69);
|
|
304 this.optList.TabIndex = 9;
|
|
305 this.optList.DoubleClick += new System.EventHandler(this.optList_DoubleClick);
|
|
306 this.optList.SelectedIndexChanged += new System.EventHandler(this.optList_SelectedIndexChanged);
|
|
307 //
|
|
308 // lblOptionalEquip
|
|
309 //
|
|
310 this.lblOptionalEquip.Location = new System.Drawing.Point(8, 200);
|
|
311 this.lblOptionalEquip.Name = "lblOptionalEquip";
|
|
312 this.lblOptionalEquip.Size = new System.Drawing.Size(88, 32);
|
|
313 this.lblOptionalEquip.TabIndex = 8;
|
|
314 this.lblOptionalEquip.Text = "opt equipment";
|
|
315 this.lblOptionalEquip.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
|
316 //
|
|
317 // bttnReplaceWeapon
|
|
318 //
|
|
319 this.bttnReplaceWeapon.Enabled = false;
|
|
320 this.bttnReplaceWeapon.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
|
321 this.bttnReplaceWeapon.Location = new System.Drawing.Point(520, 128);
|
|
322 this.bttnReplaceWeapon.Name = "bttnReplaceWeapon";
|
|
323 this.bttnReplaceWeapon.Size = new System.Drawing.Size(88, 22);
|
|
324 this.bttnReplaceWeapon.TabIndex = 10;
|
|
325 this.bttnReplaceWeapon.Text = "replace";
|
|
326 this.bttnReplaceWeapon.Click += new System.EventHandler(this.bttnReplaceWeapon_Click);
|
|
327 //
|
|
328 // bttnEditReqdWeapon
|
|
329 //
|
|
330 this.bttnEditReqdWeapon.Enabled = false;
|
|
331 this.bttnEditReqdWeapon.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
|
332 this.bttnEditReqdWeapon.Location = new System.Drawing.Point(520, 152);
|
|
333 this.bttnEditReqdWeapon.Name = "bttnEditReqdWeapon";
|
|
334 this.bttnEditReqdWeapon.Size = new System.Drawing.Size(88, 22);
|
|
335 this.bttnEditReqdWeapon.TabIndex = 11;
|
|
336 this.bttnEditReqdWeapon.Text = "edit";
|
|
337 this.bttnEditReqdWeapon.Click += new System.EventHandler(this.bttnEditReqdWeapon_Click);
|
|
338 //
|
|
339 // FrmUnit
|
|
340 //
|
|
341 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
|
|
342 this.ClientSize = new System.Drawing.Size(616, 314);
|
|
343 this.Controls.Add(this.bttnEditReqdWeapon);
|
|
344 this.Controls.Add(this.bttnReplaceWeapon);
|
|
345 this.Controls.Add(this.optList);
|
|
346 this.Controls.Add(this.lblOptionalEquip);
|
|
347 this.Controls.Add(this.bttnEditWeapon);
|
|
348 this.Controls.Add(this.reqdList);
|
|
349 this.Controls.Add(this.bttnRemoveWeapon);
|
|
350 this.Controls.Add(this.bttnAddWeapon);
|
|
351 this.Controls.Add(this.lblRequiredEquip);
|
|
352 this.Controls.Add(this.lblUnitSize);
|
|
353 this.Controls.Add(this.unitSize);
|
|
354 this.Controls.Add(this.tbUnitName);
|
|
355 this.Controls.Add(this.statsGrid);
|
|
356 this.Name = "FrmUnit";
|
|
357 this.ShowInTaskbar = false;
|
|
358 this.Text = "FrmUnit";
|
|
359 ((System.ComponentModel.ISupportInitialize)(this.statsGrid)).EndInit();
|
|
360 ((System.ComponentModel.ISupportInitialize)(this.unitSize)).EndInit();
|
|
361 this.ResumeLayout(false);
|
|
362
|
|
363 }
|
|
364 #endregion
|
|
365
|
|
366 public Unit Unit
|
|
367 {
|
|
368 get { return unit; }
|
|
369 }
|
|
370
|
|
371 private void tbUnitName_Leave(object sender, System.EventArgs e)
|
|
372 {
|
|
373 updateUnitName();
|
|
374 }
|
|
375
|
|
376 private void tbUnitName_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
|
|
377 {
|
|
378 if (e.KeyCode == Keys.Enter)
|
|
379 {
|
|
380 updateUnitName();
|
|
381 }
|
|
382 }
|
|
383
|
|
384 private void updateUnitName()
|
|
385 {
|
|
386 if (unit.Name!=tbUnitName.Text)
|
|
387 {
|
|
388 commandStack.Execute(new SetNameCommand(unit, tbUnitName.Text));
|
|
389 }
|
|
390 }
|
|
391
|
|
392 private void unitSize_Leave(object sender, System.EventArgs e)
|
|
393 {
|
|
394 updateUnitSize();
|
|
395 }
|
|
396
|
|
397 private void unitSize_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
|
|
398 {
|
|
399 if (e.KeyCode == Keys.Enter)
|
|
400 {
|
|
401 updateUnitSize();
|
|
402 }
|
|
403 }
|
|
404
|
|
405 private void updateUnitSize()
|
|
406 {
|
|
407 if (unit.Size!=unitSize.Value)
|
|
408 {
|
|
409 commandStack.Execute(new SetUnitSizeCommand(unit, (int)unitSize.Value));
|
|
410 }
|
|
411 }
|
|
412
|
|
413 private void unit_NameChanged(WarFoundryObject obj, string oldValue, string newValue)
|
|
414 {
|
|
415 if (obj is Unit && obj.Equals(unit))
|
|
416 {
|
|
417 Unit u = (Unit)obj;
|
|
418 tbUnitName.Text = obj.Name;
|
|
419 Text = obj.Name;
|
|
420 }
|
|
421 }
|
|
422
|
|
423 private void unit_UnitSizeChanged(WarFoundryObject obj, int oldValue, int newValue)
|
|
424 {
|
|
425 if (obj is Unit && obj.Equals(unit))
|
|
426 {
|
|
427 unitSize.Value = newValue;
|
|
428 }
|
|
429 }
|
|
430
|
|
431 private void reqdList_SelectedIndexChanged(object sender, System.EventArgs e)
|
|
432 {
|
|
433 bttnReplaceWeapon.Enabled = (reqdList.SelectedIndex>-1 && ((UnitEquipmentChoice)reqdList.SelectedItem).Item.HasAlternatives());
|
|
434 bttnEditReqdWeapon.Enabled = (reqdList.SelectedIndex>-1);
|
|
435 }
|
|
436
|
|
437 private void optList_SelectedIndexChanged(object sender, System.EventArgs e)
|
|
438 {
|
|
439 bttnEditWeapon.Enabled = optList.SelectedIndex>-1;
|
|
440 bttnRemoveWeapon.Enabled = bttnEditWeapon.Enabled;
|
|
441 }
|
|
442
|
|
443 private void unit_UnitEquipmentAmountChanged(WarFoundryObject obj, double oldValue, double newValue)
|
|
444 {
|
|
445 if (obj is UnitEquipmentItem)
|
|
446 {
|
|
447 UnitEquipmentItem equip = (UnitEquipmentItem)obj;
|
|
448 ListBox weaponList = (equip.IsRequired ? reqdList : optList);
|
|
449
|
|
450 if (newValue==0)
|
|
451 {
|
|
452 weaponList.Items.Remove(GetEquipmentChoice(equip));
|
|
453 }
|
|
454 else
|
|
455 {
|
|
456 UnitEquipmentChoice equipObj = GetEquipmentChoice(equip);
|
|
457 int idx = weaponList.Items.IndexOf(equipObj);
|
|
458
|
|
459 if (idx>-1)
|
|
460 {
|
|
461 weaponList.Items[idx] = equipObj;
|
|
462 }
|
|
463 else
|
|
464 {
|
|
465 weaponList.Items.Add(equipObj);
|
|
466 }
|
|
467 }
|
|
468 }
|
|
469 }
|
|
470
|
|
471 private void editWeapon(ListBox list)
|
|
472 {
|
|
473 FrmEditUnitEquipment editEquip = new FrmEditUnitEquipment(Unit, ((UnitEquipmentChoice)list.SelectedItem).Item, commandStack);
|
|
474 editEquip.ShowDialog(this);
|
|
475 }
|
|
476
|
|
477 private void bttnEditWeapon_Click(object sender, System.EventArgs e)
|
|
478 {
|
|
479 editWeapon(optList);
|
|
480 }
|
|
481
|
|
482 private void optList_DoubleClick(object sender, System.EventArgs e)
|
|
483 {
|
|
484 editWeapon(optList);
|
|
485 }
|
|
486
|
|
487 private void reqdList_DoubleClick(object sender, System.EventArgs e)
|
|
488 {
|
|
489 editWeapon(reqdList);
|
|
490 }
|
|
491
|
|
492 private void addWeapon()
|
|
493 {
|
|
494 FrmNewUnitEquipment newEquip = new FrmNewUnitEquipment(Unit, commandStack);
|
|
495 newEquip.ShowDialog(this);
|
|
496 }
|
|
497
|
|
498 private void bttnAddWeapon_Click(object sender, System.EventArgs e)
|
|
499 {
|
|
500 addWeapon();
|
|
501 }
|
|
502
|
|
503 private void removeWeapon()
|
|
504 {
|
|
505 commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, ((UnitEquipmentChoice)optList.SelectedItem).Item, 0));
|
|
506 }
|
|
507
|
|
508 private void bttnRemoveWeapon_Click(object sender, System.EventArgs e)
|
|
509 {
|
|
510 removeWeapon();
|
|
511 }
|
|
512
|
|
513 private void bttnEditReqdWeapon_Click(object sender, System.EventArgs e)
|
|
514 {
|
|
515 editWeapon(reqdList);
|
|
516 }
|
|
517
|
|
518 private void bttnReplaceWeapon_Click(object sender, System.EventArgs e)
|
|
519 {
|
|
520 FrmReplaceUnitEquipment replace = new FrmReplaceUnitEquipment(unit, ((UnitEquipmentChoice)reqdList.SelectedItem).Item, commandStack);
|
|
521 replace.ShowDialog(this);
|
|
522 }
|
|
523 }
|
|
524 }
|