changeset 222:4ada3252d1ea

Re #101: Make army names and sizes modifiable after creation * Fix up translations * Correct enabling of menu item * Add translation text * Update army names in tree and app title when edited
author IBBoard <dev@ibboard.co.uk>
date Mon, 29 Aug 2011 20:53:53 +0100
parents 5233147ca7e4
children 4e5f913a472a
files FrmArmyTree.cs FrmEditArmy.cs FrmMain.cs translations/en.translation
diffstat 4 files changed, 37 insertions(+), 10 deletions(-) [+]
line diff
     1.1 --- a/FrmArmyTree.cs	Mon Aug 29 20:06:54 2011 +0100
     1.2 +++ b/FrmArmyTree.cs	Mon Aug 29 20:53:53 2011 +0100
     1.3 @@ -54,7 +54,10 @@
     1.4  			ArmyNameChangedMethod = new StringValChangedDelegate(UpdateArmyName);
     1.5  			TreeNameChangedMethod = new StringValChangedDelegate(FrmArmyTree_TreeNameChanged);
     1.6  			nodes = new Dictionary<string, TreeNode>();
     1.7 -			this.Name = "ArmyTree";			
     1.8 +			this.Name = "ArmyTree";
     1.9 +			miDeleteUnit.Name = "miDeleteUnit";
    1.10 +			miEditUnit.Name = "miEditUnit";
    1.11 +			miEditArmy.Name = "miEditArmy";
    1.12  			WarFoundryCore.ArmyChanged+= new ArmyChangedDelegate(FrmArmyTree_ArmyChanged);
    1.13  			TranslateForm();
    1.14  			Translation.TranslationChanged += new MethodInvoker(TranslateForm);
    1.15 @@ -73,6 +76,7 @@
    1.16  			{
    1.17                  ControlTranslator.TranslateComponent(mi);
    1.18  			}
    1.19 +
    1.20              foreach (TreeNode node in nodes.Values)
    1.21              {
    1.22                  node.Text = CreateNodeName((ICostedWarFoundryObject)node.Tag);
    1.23 @@ -291,6 +295,7 @@
    1.24  		{
    1.25  			if (oldArmy != null)
    1.26  			{
    1.27 +				oldArmy.NameChanged -= ArmyNameChangedMethod;
    1.28  				oldArmy.UnitAdded -= UnitAddedMethod;
    1.29  				oldArmy.UnitRemoved -= UnitRemovedMethod;
    1.30  				oldArmy.PointsValueChanged -= NodePointsValueChanged;
    1.31 @@ -298,6 +303,7 @@
    1.32  
    1.33  			if (newArmy != null)
    1.34  			{
    1.35 +				newArmy.NameChanged += ArmyNameChangedMethod;
    1.36  				newArmy.UnitAdded += UnitAddedMethod;
    1.37  				newArmy.UnitRemoved += UnitRemovedMethod;
    1.38  				newArmy.PointsValueChanged += NodePointsValueChanged;
    1.39 @@ -444,13 +450,7 @@
    1.40  		{
    1.41  			if (obj is Army)
    1.42  			{
    1.43 -				Army army = (Army)obj;
    1.44 -				TreeNode node = treeView.Nodes[0];
    1.45 -				
    1.46 -				if (node!=null)
    1.47 -				{
    1.48 -					node.Text = army.Name;
    1.49 -				}
    1.50 +				SetNodeName((Army)obj);
    1.51  			}
    1.52  		}
    1.53  
     2.1 --- a/FrmEditArmy.cs	Mon Aug 29 20:06:54 2011 +0100
     2.2 +++ b/FrmEditArmy.cs	Mon Aug 29 20:53:53 2011 +0100
     2.3 @@ -8,10 +8,12 @@
     2.4  using IBBoard.Commands;
     2.5  using IBBoard.WarFoundry.API.Commands;
     2.6  using IBBoard.WarFoundry.API.Objects;
     2.7 +using IBBoard.Windows.Forms;
     2.8 +using IBBoard.Windows.Forms.I18N;
     2.9  
    2.10  namespace IBBoard.WarFoundry.GUI.WinForms
    2.11  {
    2.12 -	public partial class FrmEditArmy : Form
    2.13 +	public partial class FrmEditArmy : IBBForm
    2.14  	{
    2.15  		private Army army;
    2.16  		private CommandStack stack;
    2.17 @@ -23,6 +25,7 @@
    2.18  			InitializeComponent();
    2.19  			txtArmyName.Text = army.Name;
    2.20  			armySize.Value = army.MaxPoints;
    2.21 +			ControlTranslator.TranslateControl(this);
    2.22  		}
    2.23  
    2.24  		private void bttnOkay_Click(object sender, EventArgs e)
     3.1 --- a/FrmMain.cs	Mon Aug 29 20:06:54 2011 +0100
     3.2 +++ b/FrmMain.cs	Mon Aug 29 20:53:53 2011 +0100
     3.3 @@ -49,7 +49,9 @@
     3.4  
     3.5  		public ObjectAddDelegate UnitAddedMethod;
     3.6  		public ObjectRemoveDelegate UnitRemovedMethod;
     3.7 +		public StringValChangedDelegate ArmyNameChangedMethod;
     3.8  		public DoubleValChangedDelegate PointsValueChangedMethod;
     3.9 +		public IntValChangedDelegate MaxPointsValueChangedMethod;
    3.10  
    3.11  		private FrmArmyTree armyTree;
    3.12  		private string loadedFilePath;
    3.13 @@ -148,7 +150,9 @@
    3.14  			WarFoundryCore.ArmyChanged += new ArmyChangedDelegate(FrmMain_ArmyChanged);
    3.15  			UnitAddedMethod = new ObjectAddDelegate(FrmMain_UnitAddedMethod);
    3.16  			UnitRemovedMethod = new ObjectRemoveDelegate(FrmMain_UnitRemovedMethod);
    3.17 +			ArmyNameChangedMethod = new StringValChangedDelegate(FrmMain_ArmyNameChangedMethod);
    3.18  			PointsValueChangedMethod = new DoubleValChangedDelegate(FrmMain_PointsValueChangedMethod);
    3.19 +			MaxPointsValueChangedMethod = new IntValChangedDelegate(FrmMain_MaxPointsValueChangedMethod);
    3.20  
    3.21  			sbErrorPanel.Color = Color.Red;
    3.22  			SetPointsPanelToolTipText();
    3.23 @@ -578,6 +582,7 @@
    3.24  			// 
    3.25  			// miEditArmy
    3.26  			// 
    3.27 +			this.miEditArmy.Enabled = false;
    3.28  			this.miEditArmy.Name = "miEditArmy";
    3.29  			this.miEditArmy.Size = new System.Drawing.Size(152, 22);
    3.30  			this.miEditArmy.Text = "&edit army";
    3.31 @@ -913,7 +918,7 @@
    3.32  			loadedFilePath = null;
    3.33  			miSaveArmy.Enabled = false;
    3.34  			bttnSaveArmy.Enabled = false;
    3.35 -			miEditArmy.Enabled = (CurrentArmy == null);
    3.36 +			miEditArmy.Enabled = (CurrentArmy != null);
    3.37              //TODO: Subscribe to an "army changed" event here
    3.38  			SetPointsPanelText();
    3.39  			SetAppTitle();
    3.40 @@ -944,7 +949,9 @@
    3.41  			{
    3.42  				oldArmy.UnitAdded -= UnitAddedMethod;
    3.43  				oldArmy.UnitRemoved -= UnitRemovedMethod;
    3.44 +				oldArmy.NameChanged -= ArmyNameChangedMethod;
    3.45  				oldArmy.PointsValueChanged -= PointsValueChangedMethod;
    3.46 +				oldArmy.MaxPointsValueChanged -= MaxPointsValueChangedMethod;
    3.47  			}
    3.48  		}
    3.49  
    3.50 @@ -966,7 +973,9 @@
    3.51  			{
    3.52  				newArmy.UnitAdded += UnitAddedMethod;
    3.53  				newArmy.UnitRemoved += UnitRemovedMethod;
    3.54 +				newArmy.NameChanged += ArmyNameChangedMethod;
    3.55  				newArmy.PointsValueChanged += PointsValueChangedMethod;
    3.56 +				newArmy.MaxPointsValueChanged += MaxPointsValueChangedMethod;
    3.57  			}
    3.58  		}
    3.59  
    3.60 @@ -1297,6 +1306,11 @@
    3.61  			OpenArmy();
    3.62  		}
    3.63  
    3.64 +		private void FrmMain_ArmyNameChangedMethod(WarFoundryObject obj, string oldString, string newString)
    3.65 +		{
    3.66 +			SetAppTitle();
    3.67 +		}
    3.68 +
    3.69  		private void FrmMain_PointsValueChangedMethod(WarFoundryObject obj, double oldVal, double newVal)
    3.70  		{
    3.71  			if (obj is Army)
    3.72 @@ -1305,6 +1319,14 @@
    3.73  			}
    3.74  		}
    3.75  
    3.76 +		private void FrmMain_MaxPointsValueChangedMethod(WarFoundryObject obj, int oldVal, int newVal)
    3.77 +		{
    3.78 +			if (obj is Army)
    3.79 +			{
    3.80 +				SetPointsPanelText();
    3.81 +			}
    3.82 +		}
    3.83 +
    3.84          private void SetPointsPanelText()
    3.85  		{	
    3.86  			if (CurrentArmy==null)
     4.1 --- a/translations/en.translation	Mon Aug 29 20:06:54 2011 +0100
     4.2 +++ b/translations/en.translation	Mon Aug 29 20:53:53 2011 +0100
     4.3 @@ -15,6 +15,7 @@
     4.4  	<translation id="miExit">E&amp;xit</translation>
     4.5  	<translation id="miUndo">&amp;Undo</translation>
     4.6  	<translation id="miRedo">&amp;Redo</translation>
     4.7 +	<translation id="miEditArmy">&amp;Edit army</translation>
     4.8  	<translation id="miPreferences">&amp;Preferences</translation>
     4.9  	<translation id="miAbout">&amp;About</translation>
    4.10  	<translation id="bttnOkay">OK</translation>
    4.11 @@ -45,6 +46,7 @@
    4.12  	<translation id="bttnSelectRace">Create army</translation>
    4.13  	<translation id="newArmyNoGameSystems">WarFoundry couldn't find any game system data.
    4.14  Please check the logs for errors and ensure you have some game system data files in the "data" folder.</translation>
    4.15 +	<translation id="FrmEditArmy">Edit Army</translation>
    4.16  	<translation id="FrmNewUnit">Add New {0} Choice</translation>
    4.17  	<translation id="lblUnitList">Unit types:</translation>
    4.18  	<translation id="bttnSelectUnit">Create unit</translation>