changeset 157:2d1dd73a3289

Re #417: Improve install experience * Add a "Add data file" action (currently has no error checking)
author IBBoard <dev@ibboard.co.uk>
date Tue, 15 May 2012 21:00:29 +0100
parents 08b30dc56af4
children 6b4cc1fc3f42
files FrmMainWindow.cs gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmMainWindow.cs gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmNewArmy.cs gtk-gui/gui.stetic
diffstat 4 files changed, 59 insertions(+), 3 deletions(-) [+]
line diff
     1.1 --- a/FrmMainWindow.cs	Sat May 12 20:11:33 2012 +0100
     1.2 +++ b/FrmMainWindow.cs	Tue May 15 21:00:29 2012 +0100
     1.3 @@ -1291,5 +1291,33 @@
     1.4  				dialog.Dispose();
     1.5  			}
     1.6  		}
     1.7 +
     1.8 +		protected void OnAddNewFileActionActivated(object sender, EventArgs e)
     1.9 +		{
    1.10 +			string cancelText = Translation.GetTranslation("bttnCancel", "cancel");
    1.11 +			string openText = Translation.GetTranslation("bttnOpen", "open");
    1.12 +			FileChooserDialog fileDialog = new FileChooserDialog("Add data file", this, FileChooserAction.Open, cancelText, ResponseType.Cancel, openText, ResponseType.Accept);
    1.13 +			fileDialog.SelectMultiple = true;
    1.14 +			FileFilter filter = new FileFilter();
    1.15 +			filter.AddPattern("*.race");
    1.16 +			filter.AddPattern("*.system");
    1.17 +			filter.Name = "WarFoundry data files";
    1.18 +			fileDialog.AddFilter(filter);
    1.19 +			int response = fileDialog.Run();
    1.20 +			string[] filePaths = fileDialog.Filenames;
    1.21 +			fileDialog.Hide();
    1.22 +			fileDialog.Dispose();
    1.23 +
    1.24 +			if (response == (int)ResponseType.Accept)
    1.25 +			{
    1.26 +				foreach (string filePath in filePaths)
    1.27 +				{
    1.28 +					string newFilePath = System.IO.Path.Combine(WarFoundryHacks.dataPath, System.IO.Path.GetFileName(filePath));
    1.29 +					File.Copy(filePath, newFilePath);
    1.30 +				}
    1.31 +
    1.32 +				WarFoundryLoader.GetDefault().LoadFiles();
    1.33 +			}
    1.34 +		}
    1.35  	}
    1.36  }
     2.1 --- a/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmMainWindow.cs	Sat May 12 20:11:33 2012 +0100
     2.2 +++ b/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmMainWindow.cs	Tue May 15 21:00:29 2012 +0100
     2.3 @@ -31,6 +31,8 @@
     2.4  		private global::Gtk.Action miPreferences;
     2.5  		private global::Gtk.Action miExportArmyAsTransformedXml;
     2.6  		private global::Gtk.Action miEditArmy;
     2.7 +		private global::Gtk.Action AddNewFileAction;
     2.8 +		private global::Gtk.Action miAddDataFile;
     2.9  		private global::Gtk.VBox vbox1;
    2.10  		private global::Gtk.MenuBar menubar1;
    2.11  		private global::Gtk.Toolbar toolbar;
    2.12 @@ -238,6 +240,22 @@
    2.13  			this.miEditArmy.Sensitive = false;
    2.14  			this.miEditArmy.ShortLabel = global::Mono.Unix.Catalog.GetString ("_edit army");
    2.15  			w1.Add (this.miEditArmy, null);
    2.16 +			this.AddNewFileAction = new global::Gtk.Action (
    2.17 +				"AddNewFileAction",
    2.18 +				global::Mono.Unix.Catalog.GetString("Add new file"),
    2.19 +				null,
    2.20 +				null
    2.21 +			);
    2.22 +			this.AddNewFileAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Add new file");
    2.23 +			w1.Add (this.AddNewFileAction, null);
    2.24 +			this.miAddDataFile = new global::Gtk.Action (
    2.25 +				"miAddDataFile",
    2.26 +				global::Mono.Unix.Catalog.GetString("Add data file"),
    2.27 +				null,
    2.28 +				null
    2.29 +			);
    2.30 +			this.miAddDataFile.ShortLabel = global::Mono.Unix.Catalog.GetString ("Add data file");
    2.31 +			w1.Add (this.miAddDataFile, null);
    2.32  			this.UIManager.InsertActionGroup (w1, 0);
    2.33  			this.AddAccelGroup (this.UIManager.AccelGroup);
    2.34  			this.Name = "IBBoard.WarFoundry.GUI.GTK.FrmMainWindow";
    2.35 @@ -247,7 +265,7 @@
    2.36  			this.vbox1 = new global::Gtk.VBox ();
    2.37  			this.vbox1.Name = "vbox1";
    2.38  			// Container child vbox1.Gtk.Box+BoxChild
    2.39 -			this.UIManager.AddUiFromString ("<ui><menubar name='menubar1'><menu name='menuFile' action='menuFile'><menuitem name='miNewArmy' action='miNewArmy'/><menuitem name='miOpenArmy' action='miOpenArmy'/><menuitem name='miSaveArmy' action='miSaveArmy'/><menuitem name='miSaveArmyAs' action='miSaveArmyAs'/><menu name='miExportArmyAs' action='miExportArmyAs'><menuitem name='miExportArmyAsBasicHTML' action='miExportArmyAsBasicHTML'/><menuitem name='miExportArmyAsTransformedXml' action='miExportArmyAsTransformedXml'/></menu><menuitem name='miCloseArmy' action='miCloseArmy'/><separator/><menuitem name='miReloadFiles' action='miReloadFiles'/><separator/><menuitem name='miExit' action='miExit'/></menu><menu name='menuEdit' action='menuEdit'><menuitem name='miUndo' action='miUndo'/><menuitem name='miRedo' action='miRedo'/><separator/><menuitem name='miEditArmy' action='miEditArmy'/><separator/><menuitem name='miPreferences' action='miPreferences'/></menu><menu name='menuHelp' action='menuHelp'><menuitem name='miAbout' action='miAbout'/></menu></menubar></ui>");
    2.40 +			this.UIManager.AddUiFromString ("<ui><menubar name='menubar1'><menu name='menuFile' action='menuFile'><menuitem name='miNewArmy' action='miNewArmy'/><menuitem name='miOpenArmy' action='miOpenArmy'/><menuitem name='miSaveArmy' action='miSaveArmy'/><menuitem name='miSaveArmyAs' action='miSaveArmyAs'/><menu name='miExportArmyAs' action='miExportArmyAs'><menuitem name='miExportArmyAsBasicHTML' action='miExportArmyAsBasicHTML'/><menuitem name='miExportArmyAsTransformedXml' action='miExportArmyAsTransformedXml'/></menu><menuitem name='miCloseArmy' action='miCloseArmy'/><separator/><menuitem name='miAddDataFile' action='miAddDataFile'/><menuitem name='miReloadFiles' action='miReloadFiles'/><separator/><menuitem name='miExit' action='miExit'/></menu><menu name='menuEdit' action='menuEdit'><menuitem name='miUndo' action='miUndo'/><menuitem name='miRedo' action='miRedo'/><separator/><menuitem name='miEditArmy' action='miEditArmy'/><separator/><menuitem name='miPreferences' action='miPreferences'/></menu><menu name='menuHelp' action='menuHelp'><menuitem name='miAbout' action='miAbout'/></menu></menubar></ui>");
    2.41  			this.menubar1 = ((global::Gtk.MenuBar)(this.UIManager.GetWidget ("/menubar1")));
    2.42  			this.menubar1.Name = "menubar1";
    2.43  			this.vbox1.Add (this.menubar1);
    2.44 @@ -341,6 +359,8 @@
    2.45  			this.miPreferences.Activated += new global::System.EventHandler (this.miPreferencesClicked);
    2.46  			this.miExportArmyAsTransformedXml.Activated += new global::System.EventHandler (this.OnTransformedXmlActionActivated);
    2.47  			this.miEditArmy.Activated += new global::System.EventHandler (this.OnMiEditArmyActivated);
    2.48 +			this.AddNewFileAction.Activated += new global::System.EventHandler (this.OnAddNewFileActionActivated);
    2.49 +			this.miAddDataFile.Activated += new global::System.EventHandler (this.OnAddNewFileActionActivated);
    2.50  			this.treeUnits.RowActivated += new global::Gtk.RowActivatedHandler (this.ArmyRowActivated);
    2.51  			this.treeUnits.PopupMenu += new global::Gtk.PopupMenuHandler (this.OnTreeUnitsPopupMenu);
    2.52  			this.treeUnits.ButtonPressEvent += new global::Gtk.ButtonPressEventHandler (this.UnitTreeButtonPressed);
     3.1 --- a/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmNewArmy.cs	Sat May 12 20:11:33 2012 +0100
     3.2 +++ b/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmNewArmy.cs	Tue May 15 21:00:29 2012 +0100
     3.3 @@ -156,7 +156,8 @@
     3.4  			// Container child vbox2.Gtk.Box+BoxChild
     3.5  			this.lblGetMore = new global::Gtk.Label ();
     3.6  			this.lblGetMore.Name = "lblGetMore";
     3.7 -			this.lblGetMore.LabelProp = global::Mono.Unix.Catalog.GetString ("<a href=\"http://warfoundry.co.uk/Downloads/datafiles/\">Get more</a>");
     3.8 +			this.lblGetMore.Ypad = 10;
     3.9 +			this.lblGetMore.LabelProp = global::Mono.Unix.Catalog.GetString ("<a href=\"http://warfoundry.co.uk/Downloads/datafiles/\">get more</a>");
    3.10  			this.lblGetMore.UseMarkup = true;
    3.11  			this.vbox2.Add (this.lblGetMore);
    3.12  			global::Gtk.Box.BoxChild w12 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.lblGetMore]));
     4.1 --- a/gtk-gui/gui.stetic	Sat May 12 20:11:33 2012 +0100
     4.2 +++ b/gtk-gui/gui.stetic	Tue May 15 21:00:29 2012 +0100
     4.3 @@ -1,7 +1,7 @@
     4.4  <?xml version="1.0" encoding="utf-8"?>
     4.5  <stetic-interface>
     4.6    <configuration>
     4.7 -    <images-root-path>../../IBBoard.WarFoundry.GUI.GTK</images-root-path>
     4.8 +    <images-root-path>..</images-root-path>
     4.9      <target-gtk-version>2.12</target-gtk-version>
    4.10    </configuration>
    4.11    <import>
    4.12 @@ -179,6 +179,12 @@
    4.13          <property name="StockId">gtk-edit</property>
    4.14          <signal name="Activated" handler="OnMiEditArmyActivated" />
    4.15        </action>
    4.16 +      <action id="miAddDataFile">
    4.17 +        <property name="Type">Action</property>
    4.18 +        <property name="Label" translatable="yes">Add data file</property>
    4.19 +        <property name="ShortLabel" translatable="yes">Add data file</property>
    4.20 +        <signal name="Activated" handler="OnAddNewFileActionActivated" />
    4.21 +      </action>
    4.22      </action-group>
    4.23      <property name="MemberName" />
    4.24      <property name="Title" translatable="yes">MainWindow</property>
    4.25 @@ -201,6 +207,7 @@
    4.26                  </node>
    4.27                  <node type="Menuitem" action="miCloseArmy" />
    4.28                  <node type="Separator" />
    4.29 +                <node type="Menuitem" action="miAddDataFile" />
    4.30                  <node type="Menuitem" action="miReloadFiles" />
    4.31                  <node type="Separator" />
    4.32                  <node type="Menuitem" action="miExit" />