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 wrap: on
line diff
--- a/FrmMainWindow.cs	Sat May 12 20:11:33 2012 +0100
+++ b/FrmMainWindow.cs	Tue May 15 21:00:29 2012 +0100
@@ -1291,5 +1291,33 @@
 				dialog.Dispose();
 			}
 		}
+
+		protected void OnAddNewFileActionActivated(object sender, EventArgs e)
+		{
+			string cancelText = Translation.GetTranslation("bttnCancel", "cancel");
+			string openText = Translation.GetTranslation("bttnOpen", "open");
+			FileChooserDialog fileDialog = new FileChooserDialog("Add data file", this, FileChooserAction.Open, cancelText, ResponseType.Cancel, openText, ResponseType.Accept);
+			fileDialog.SelectMultiple = true;
+			FileFilter filter = new FileFilter();
+			filter.AddPattern("*.race");
+			filter.AddPattern("*.system");
+			filter.Name = "WarFoundry data files";
+			fileDialog.AddFilter(filter);
+			int response = fileDialog.Run();
+			string[] filePaths = fileDialog.Filenames;
+			fileDialog.Hide();
+			fileDialog.Dispose();
+
+			if (response == (int)ResponseType.Accept)
+			{
+				foreach (string filePath in filePaths)
+				{
+					string newFilePath = System.IO.Path.Combine(WarFoundryHacks.dataPath, System.IO.Path.GetFileName(filePath));
+					File.Copy(filePath, newFilePath);
+				}
+
+				WarFoundryLoader.GetDefault().LoadFiles();
+			}
+		}
 	}
 }
--- a/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmMainWindow.cs	Sat May 12 20:11:33 2012 +0100
+++ b/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmMainWindow.cs	Tue May 15 21:00:29 2012 +0100
@@ -31,6 +31,8 @@
 		private global::Gtk.Action miPreferences;
 		private global::Gtk.Action miExportArmyAsTransformedXml;
 		private global::Gtk.Action miEditArmy;
+		private global::Gtk.Action AddNewFileAction;
+		private global::Gtk.Action miAddDataFile;
 		private global::Gtk.VBox vbox1;
 		private global::Gtk.MenuBar menubar1;
 		private global::Gtk.Toolbar toolbar;
@@ -238,6 +240,22 @@
 			this.miEditArmy.Sensitive = false;
 			this.miEditArmy.ShortLabel = global::Mono.Unix.Catalog.GetString ("_edit army");
 			w1.Add (this.miEditArmy, null);
+			this.AddNewFileAction = new global::Gtk.Action (
+				"AddNewFileAction",
+				global::Mono.Unix.Catalog.GetString("Add new file"),
+				null,
+				null
+			);
+			this.AddNewFileAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Add new file");
+			w1.Add (this.AddNewFileAction, null);
+			this.miAddDataFile = new global::Gtk.Action (
+				"miAddDataFile",
+				global::Mono.Unix.Catalog.GetString("Add data file"),
+				null,
+				null
+			);
+			this.miAddDataFile.ShortLabel = global::Mono.Unix.Catalog.GetString ("Add data file");
+			w1.Add (this.miAddDataFile, null);
 			this.UIManager.InsertActionGroup (w1, 0);
 			this.AddAccelGroup (this.UIManager.AccelGroup);
 			this.Name = "IBBoard.WarFoundry.GUI.GTK.FrmMainWindow";
@@ -247,7 +265,7 @@
 			this.vbox1 = new global::Gtk.VBox ();
 			this.vbox1.Name = "vbox1";
 			// Container child vbox1.Gtk.Box+BoxChild
-			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>");
+			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>");
 			this.menubar1 = ((global::Gtk.MenuBar)(this.UIManager.GetWidget ("/menubar1")));
 			this.menubar1.Name = "menubar1";
 			this.vbox1.Add (this.menubar1);
@@ -341,6 +359,8 @@
 			this.miPreferences.Activated += new global::System.EventHandler (this.miPreferencesClicked);
 			this.miExportArmyAsTransformedXml.Activated += new global::System.EventHandler (this.OnTransformedXmlActionActivated);
 			this.miEditArmy.Activated += new global::System.EventHandler (this.OnMiEditArmyActivated);
+			this.AddNewFileAction.Activated += new global::System.EventHandler (this.OnAddNewFileActionActivated);
+			this.miAddDataFile.Activated += new global::System.EventHandler (this.OnAddNewFileActionActivated);
 			this.treeUnits.RowActivated += new global::Gtk.RowActivatedHandler (this.ArmyRowActivated);
 			this.treeUnits.PopupMenu += new global::Gtk.PopupMenuHandler (this.OnTreeUnitsPopupMenu);
 			this.treeUnits.ButtonPressEvent += new global::Gtk.ButtonPressEventHandler (this.UnitTreeButtonPressed);
--- a/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmNewArmy.cs	Sat May 12 20:11:33 2012 +0100
+++ b/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmNewArmy.cs	Tue May 15 21:00:29 2012 +0100
@@ -156,7 +156,8 @@
 			// Container child vbox2.Gtk.Box+BoxChild
 			this.lblGetMore = new global::Gtk.Label ();
 			this.lblGetMore.Name = "lblGetMore";
-			this.lblGetMore.LabelProp = global::Mono.Unix.Catalog.GetString ("<a href=\"http://warfoundry.co.uk/Downloads/datafiles/\">Get more</a>");
+			this.lblGetMore.Ypad = 10;
+			this.lblGetMore.LabelProp = global::Mono.Unix.Catalog.GetString ("<a href=\"http://warfoundry.co.uk/Downloads/datafiles/\">get more</a>");
 			this.lblGetMore.UseMarkup = true;
 			this.vbox2.Add (this.lblGetMore);
 			global::Gtk.Box.BoxChild w12 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.lblGetMore]));
--- a/gtk-gui/gui.stetic	Sat May 12 20:11:33 2012 +0100
+++ b/gtk-gui/gui.stetic	Tue May 15 21:00:29 2012 +0100
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <stetic-interface>
   <configuration>
-    <images-root-path>../../IBBoard.WarFoundry.GUI.GTK</images-root-path>
+    <images-root-path>..</images-root-path>
     <target-gtk-version>2.12</target-gtk-version>
   </configuration>
   <import>
@@ -179,6 +179,12 @@
         <property name="StockId">gtk-edit</property>
         <signal name="Activated" handler="OnMiEditArmyActivated" />
       </action>
+      <action id="miAddDataFile">
+        <property name="Type">Action</property>
+        <property name="Label" translatable="yes">Add data file</property>
+        <property name="ShortLabel" translatable="yes">Add data file</property>
+        <signal name="Activated" handler="OnAddNewFileActionActivated" />
+      </action>
     </action-group>
     <property name="MemberName" />
     <property name="Title" translatable="yes">MainWindow</property>
@@ -201,6 +207,7 @@
                 </node>
                 <node type="Menuitem" action="miCloseArmy" />
                 <node type="Separator" />
+                <node type="Menuitem" action="miAddDataFile" />
                 <node type="Menuitem" action="miReloadFiles" />
                 <node type="Separator" />
                 <node type="Menuitem" action="miExit" />