# HG changeset patch # User IBBoard # Date 1318363510 -3600 # Node ID 33962c2ef55037ef2408d3240ba58417ec66b5eb # Parent 5b92d2be69d8d800144dadf660a073f8a735a604 Re #326: Make army names and sizes modifiable after creation * Add army editing form * Hook up to events to update main window * Add edit army option to Edit menu diff -r 5b92d2be69d8 -r 33962c2ef550 FrmEditArmy.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FrmEditArmy.cs Tue Oct 11 21:05:10 2011 +0100 @@ -0,0 +1,46 @@ +// This file (FrmEditArmy.cs) is a part of the IBBoard.WarFoundry.GUI.GTK project and is copyright 2011 IBBoard +// +// 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. +using System; +using IBBoard.WarFoundry.API.Objects; +using IBBoard.Commands; +using IBBoard.WarFoundry.API.Commands; + +namespace IBBoard.WarFoundry.GUI.GTK +{ + public partial class FrmEditArmy : IBBoard.GtkSharp.Translatable.TranslatableDialog + { + private Army army; + private CommandStack stack; + + public FrmEditArmy(CommandStack cmdStack, Army toEdit) + { + stack = cmdStack; + army = toEdit; + this.Build(); + txtArmyName.Text = army.Name; + sbPointsValue.Value = army.MaxPoints; + Translate(); + } + + private void DoUpdate() + { + EditArmyCommand command = new EditArmyCommand(army); + command.NewName = txtArmyName.Text; + command.NewSize = (int)sbPointsValue.Value; + stack.Execute(command); + } + + protected void OnButtonOkClicked (object sender, System.EventArgs e) + { + DoUpdate(); + Respond(Gtk.ResponseType.Ok); + } + + protected void OnButtonCancelClicked (object sender, System.EventArgs e) + { + Respond(Gtk.ResponseType.Cancel); + } + } +} + diff -r 5b92d2be69d8 -r 33962c2ef550 FrmMainWindow.cs --- a/FrmMainWindow.cs Tue Oct 11 20:24:11 2011 +0100 +++ b/FrmMainWindow.cs Tue Oct 11 21:05:10 2011 +0100 @@ -520,6 +520,8 @@ oldArmy.UnitAdded -= UnitAddedMethod; oldArmy.UnitRemoved -= UnitRemovedMethod; oldArmy.PointsValueChanged -= PointsValueChangedMethod; + oldArmy.NameChanged -= OnArmyNameChanged; + oldArmy.MaxPointsValueChanged -= OnMaxPointsValueChanged; } unitToWidgetMap.Clear(); @@ -538,6 +540,8 @@ newArmy.UnitAdded += UnitAddedMethod; newArmy.UnitRemoved += UnitRemovedMethod; newArmy.PointsValueChanged += PointsValueChangedMethod; + newArmy.NameChanged += OnArmyNameChanged; + newArmy.MaxPointsValueChanged += OnMaxPointsValueChanged; //TODO: Clear all buttons EnableCategoryButtons(); @@ -552,6 +556,7 @@ miCloseArmy.Sensitive = nonNullNewArmy; miSaveArmyAs.Sensitive = nonNullNewArmy; miExportArmyAs.Sensitive = nonNullNewArmy; + miEditArmy.Sensitive = nonNullNewArmy; hpaned2.Visible = nonNullNewArmy; loadedArmyPath = null; //New army has no changes, so we can't save it @@ -562,6 +567,16 @@ SetPointsPanelText(); } + private void OnArmyNameChanged (WarFoundryObject obj, string oldValue, string newValue) + { + SetAppTitle(); + } + + private void OnMaxPointsValueChanged (WarFoundryObject obj, int oldValue, int newValue) + { + SetPointsPanelText(); + } + private void SetArmyTree(Army army) { logger.Debug("Resetting tree"); @@ -1175,12 +1190,20 @@ } } - protected void OnTransformedXmlActionActivated (object sender, System.EventArgs e) + protected void OnTransformedXmlActionActivated(object sender, System.EventArgs e) { FrmExportXml form = new FrmExportXml(WarFoundryCore.CurrentArmy); form.Run(); form.Hide(); form.Dispose(); } + + protected void OnMiEditArmyActivated(object sender, System.EventArgs e) + { + FrmEditArmy form = new FrmEditArmy(commandStack, WarFoundryCore.CurrentArmy); + form.Run(); + form.Hide(); + form.Dispose(); + } } } diff -r 5b92d2be69d8 -r 33962c2ef550 IBBoard.WarFoundry.GUI.GTK.csproj --- a/IBBoard.WarFoundry.GUI.GTK.csproj Tue Oct 11 20:24:11 2011 +0100 +++ b/IBBoard.WarFoundry.GUI.GTK.csproj Tue Oct 11 21:05:10 2011 +0100 @@ -75,6 +75,8 @@ + + diff -r 5b92d2be69d8 -r 33962c2ef550 gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmEditArmy.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmEditArmy.cs Tue Oct 11 21:05:10 2011 +0100 @@ -0,0 +1,130 @@ + +// This file has been generated by the GUI designer. Do not modify. +namespace IBBoard.WarFoundry.GUI.GTK +{ + public partial class FrmEditArmy + { + private global::Gtk.Table table1; + private global::Gtk.HBox hbox2; + private global::Gtk.SpinButton sbPointsValue; + private global::IBBoard.GtkSharp.Translatable.TranslatableLabel lblArmyName; + private global::IBBoard.GtkSharp.Translatable.TranslatableLabel lblArmySize; + private global::Gtk.Entry txtArmyName; + private global::Gtk.Button buttonCancel; + private global::Gtk.Button buttonOk; + + protected virtual void Build () + { + global::Stetic.Gui.Initialize (this); + // Widget IBBoard.WarFoundry.GUI.GTK.FrmEditArmy + this.Name = "IBBoard.WarFoundry.GUI.GTK.FrmEditArmy"; + this.WindowPosition = ((global::Gtk.WindowPosition)(4)); + // Internal child IBBoard.WarFoundry.GUI.GTK.FrmEditArmy.VBox + global::Gtk.VBox w1 = this.VBox; + w1.Name = "dialog1_VBox"; + w1.BorderWidth = ((uint)(2)); + // Container child dialog1_VBox.Gtk.Box+BoxChild + this.table1 = new global::Gtk.Table (((uint)(2)), ((uint)(2)), false); + this.table1.Name = "table1"; + this.table1.RowSpacing = ((uint)(6)); + this.table1.ColumnSpacing = ((uint)(6)); + // Container child table1.Gtk.Table+TableChild + this.hbox2 = new global::Gtk.HBox (); + this.hbox2.Name = "hbox2"; + // Container child hbox2.Gtk.Box+BoxChild + this.sbPointsValue = new global::Gtk.SpinButton (0, 2000000000, 100); + this.sbPointsValue.WidthRequest = 150; + this.sbPointsValue.CanFocus = true; + this.sbPointsValue.Name = "sbPointsValue"; + this.sbPointsValue.Adjustment.PageIncrement = 1000; + this.sbPointsValue.ClimbRate = 100; + this.sbPointsValue.Numeric = true; + this.sbPointsValue.Value = 1000; + this.hbox2.Add (this.sbPointsValue); + global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.sbPointsValue])); + w2.Position = 0; + w2.Expand = false; + w2.Fill = false; + this.table1.Add (this.hbox2); + global::Gtk.Table.TableChild w3 = ((global::Gtk.Table.TableChild)(this.table1 [this.hbox2])); + w3.TopAttach = ((uint)(1)); + w3.BottomAttach = ((uint)(2)); + w3.LeftAttach = ((uint)(1)); + w3.RightAttach = ((uint)(2)); + w3.YOptions = ((global::Gtk.AttachOptions)(4)); + // Container child table1.Gtk.Table+TableChild + this.lblArmyName = new global::IBBoard.GtkSharp.Translatable.TranslatableLabel (); + this.lblArmyName.Name = "lblArmyName"; + this.lblArmyName.LabelProp = global::Mono.Unix.Catalog.GetString ("army name:"); + this.table1.Add (this.lblArmyName); + global::Gtk.Table.TableChild w4 = ((global::Gtk.Table.TableChild)(this.table1 [this.lblArmyName])); + w4.XOptions = ((global::Gtk.AttachOptions)(4)); + w4.YOptions = ((global::Gtk.AttachOptions)(4)); + // Container child table1.Gtk.Table+TableChild + this.lblArmySize = new global::IBBoard.GtkSharp.Translatable.TranslatableLabel (); + this.lblArmySize.Name = "lblArmySize"; + this.lblArmySize.LabelProp = global::Mono.Unix.Catalog.GetString ("army size:"); + this.table1.Add (this.lblArmySize); + global::Gtk.Table.TableChild w5 = ((global::Gtk.Table.TableChild)(this.table1 [this.lblArmySize])); + w5.TopAttach = ((uint)(1)); + w5.BottomAttach = ((uint)(2)); + w5.XOptions = ((global::Gtk.AttachOptions)(4)); + w5.YOptions = ((global::Gtk.AttachOptions)(4)); + // Container child table1.Gtk.Table+TableChild + this.txtArmyName = new global::Gtk.Entry (); + this.txtArmyName.CanFocus = true; + this.txtArmyName.Name = "txtArmyName"; + this.txtArmyName.IsEditable = true; + this.txtArmyName.InvisibleChar = '●'; + this.table1.Add (this.txtArmyName); + global::Gtk.Table.TableChild w6 = ((global::Gtk.Table.TableChild)(this.table1 [this.txtArmyName])); + w6.LeftAttach = ((uint)(1)); + w6.RightAttach = ((uint)(2)); + w6.YOptions = ((global::Gtk.AttachOptions)(4)); + w1.Add (this.table1); + global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(w1 [this.table1])); + w7.Position = 0; + w7.Expand = false; + w7.Fill = false; + // Internal child IBBoard.WarFoundry.GUI.GTK.FrmEditArmy.ActionArea + global::Gtk.HButtonBox w8 = this.ActionArea; + w8.Name = "dialog1_ActionArea"; + w8.Spacing = 10; + w8.BorderWidth = ((uint)(5)); + w8.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4)); + // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.buttonCancel = new global::Gtk.Button (); + this.buttonCancel.CanDefault = true; + this.buttonCancel.CanFocus = true; + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.UseStock = true; + this.buttonCancel.UseUnderline = true; + this.buttonCancel.Label = "gtk-cancel"; + this.AddActionWidget (this.buttonCancel, -6); + global::Gtk.ButtonBox.ButtonBoxChild w9 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w8 [this.buttonCancel])); + w9.Expand = false; + w9.Fill = false; + // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.buttonOk = new global::Gtk.Button (); + this.buttonOk.CanDefault = true; + this.buttonOk.CanFocus = true; + this.buttonOk.Name = "buttonOk"; + this.buttonOk.UseStock = true; + this.buttonOk.UseUnderline = true; + this.buttonOk.Label = "gtk-ok"; + this.AddActionWidget (this.buttonOk, -5); + global::Gtk.ButtonBox.ButtonBoxChild w10 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w8 [this.buttonOk])); + w10.Position = 1; + w10.Expand = false; + w10.Fill = false; + if ((this.Child != null)) { + this.Child.ShowAll (); + } + this.DefaultWidth = 400; + this.DefaultHeight = 135; + this.Show (); + this.buttonCancel.Clicked += new global::System.EventHandler (this.OnButtonCancelClicked); + this.buttonOk.Clicked += new global::System.EventHandler (this.OnButtonOkClicked); + } + } +} diff -r 5b92d2be69d8 -r 33962c2ef550 gtk-gui/gui.stetic --- a/gtk-gui/gui.stetic Tue Oct 11 20:24:11 2011 +0100 +++ b/gtk-gui/gui.stetic Tue Oct 11 21:05:10 2011 +0100 @@ -171,6 +171,14 @@ transformed xml + + Action + _edit army + False + _edit army + gtk-edit + + MainWindow @@ -201,6 +209,8 @@ + + @@ -2610,4 +2620,172 @@ + + + CenterOnParent + 2 + False + + + + 2 + + + + 2 + 2 + 6 + 6 + + + + + + + 150 + True + 2000000000 + 1000 + 100 + 100 + True + 1000 + + + 0 + True + False + False + + + + + + + + 1 + 2 + 1 + 2 + True + Fill + True + True + False + False + True + False + + + + + + army name: + + + True + Fill + Fill + False + True + False + False + True + False + + + + + + army size: + + + 1 + 2 + True + Fill + Fill + False + True + False + False + True + False + + + + + + True + True + + + + 1 + 2 + True + Fill + True + True + False + False + True + False + + + + + 0 + True + False + False + + + + + + + + 10 + 5 + 2 + End + + + + True + True + True + StockItem + gtk-cancel + -6 + + gtk-cancel + + + False + False + + + + + + True + True + True + StockItem + gtk-ok + -5 + + gtk-ok + + + 1 + False + False + + + + + \ No newline at end of file diff -r 5b92d2be69d8 -r 33962c2ef550 translations/en.translation --- a/translations/en.translation Tue Oct 11 20:24:11 2011 +0100 +++ b/translations/en.translation Tue Oct 11 21:05:10 2011 +0100 @@ -25,6 +25,7 @@ _Undo _Redo +_Edit Army _Preferences _About @@ -126,6 +127,8 @@ Transformation: Transform Output + +Edit Army Unit of {0} {1} Set {0} amount for {1} to {2}