# HG changeset patch # User IBBoard # Date 1337112029 -3600 # Node ID 2d1dd73a3289541697eed076f2c56cc263bb1a48 # Parent 08b30dc56af4cb0c9e154be447d44900173c0a3f Re #417: Improve install experience * Add a "Add data file" action (currently has no error checking) diff -r 08b30dc56af4 -r 2d1dd73a3289 FrmMainWindow.cs --- 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(); + } + } } } diff -r 08b30dc56af4 -r 2d1dd73a3289 gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmMainWindow.cs --- 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 (""); + this.UIManager.AddUiFromString (""); 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); diff -r 08b30dc56af4 -r 2d1dd73a3289 gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmNewArmy.cs --- 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 ("Get more"); + this.lblGetMore.Ypad = 10; + this.lblGetMore.LabelProp = global::Mono.Unix.Catalog.GetString ("get more"); this.lblGetMore.UseMarkup = true; this.vbox2.Add (this.lblGetMore); global::Gtk.Box.BoxChild w12 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.lblGetMore])); diff -r 08b30dc56af4 -r 2d1dd73a3289 gtk-gui/gui.stetic --- 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 @@  - ../../IBBoard.WarFoundry.GUI.GTK + .. 2.12 @@ -179,6 +179,12 @@ gtk-edit + + Action + Add data file + Add data file + + MainWindow @@ -201,6 +207,7 @@ +