mikymod 11 anni fa
parent
commit
d127d76c43

+ 5 - 12
tools/gui/UnitEditor/UnitEditor/MainMenu.cs

@@ -132,13 +132,7 @@ namespace UnitEditor
 			Guid guid = Guid.NewGuid ();
 			// Recreate the UIManager that links the action entries with controls (widgets) created from an XML definition.
 			uim = new Gtk.UIManager ();
-			// Create a blank action group.
-			/*			 WARNING:
 
-            You cannot use the same name for a new Gtk.ActionGroup if you intend on pushing changes to keys;
-            it will use your previous keys everytime except where null exists on your Gtk.ActionEntry.
-            Clearly a bug.
-          */
 			Gtk.ActionGroup actions = new Gtk.ActionGroup ("MenuBarActions" + guid.ToString ());
 			// Get all the action entries (that is, actions for menu items, toggled menu items, radio menu items).
 			actions.Add (getActionEntries ());
@@ -150,16 +144,16 @@ namespace UnitEditor
 			instance = (Gtk.MenuBar)uim.GetWidget ("/menubar");
 			// Mark everything on the menubar to be shown.
 			instance.ShowAll ();
-		}
 
-		// ACTIONS CALLBACKS
+			Console.Write (instance.Name);
+		}
 
 		static void exit_cb (object o, EventArgs args)
 		{
 			Application.Quit ();
 		}
 
-		static void open_cb(object sender, System.EventArgs e)
+		static void open_cb(object sender, System.EventArgs args)
 		{
 			Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Open file", null, FileChooserAction.Open);
 			fc.AddButton(Stock.Cancel, ResponseType.Cancel);
@@ -169,11 +163,10 @@ namespace UnitEditor
 			fc.Filter.AddPattern("*.material");
 			fc.Filter.AddPattern("*.physics");
 
+			Console.Write (args.ToString ());
 			if (fc.Run() == (int)ResponseType.Ok)
 			{
-				UnitFile u = new UnitFile (fc.Filename);
-				u.deserialize ();
-				u.serialize ();
+				UnitEditor.MainClass.g_win.open_unit (fc.Filename);
 			}
 
 			//Don't forget to call Destroy() or the FileChooserDialog window won't get closed.

+ 14 - 4
tools/gui/UnitEditor/UnitEditor/MainWindow.cs

@@ -2,25 +2,35 @@ using System;
 using System.Collections.Generic;
 using Gtk;
 
+using UnitEditor;
+
 public partial class MainWindow: Gtk.Window
 {
+	private VBox box;
+	private UnitForm unb = null;
+
 	public MainWindow () : base (Gtk.WindowType.Toplevel)
 	{
 		Build ();
 
-		VBox box = new VBox (false, 2);
+		box = new VBox (false, 2);
+		Add (box);
 
 		UnitEditor.MainMenu mb = new UnitEditor.MainMenu ();
 		this.AddAccelGroup (mb.uim.AccelGroup);
 		box.PackStart(mb.instance, false, false, 0);
 
-		UnitEditor.UnitNotebook unb = new UnitEditor.UnitNotebook ("/home/mikymod/samples/doodles/blue_doodle.unit");
-		box.PackStart (unb.instance, false, false, 0);
-		Add (box);
 
 		ShowAll ();
 	}
 
+	public void open_unit(string file_name)
+	{
+		unb = new UnitEditor.UnitForm (file_name);
+		box.PackStart (unb.instance, false, false, 0);
+		box.ShowAll ();
+	}
+
 	protected void OnDeleteEvent (object sender, DeleteEventArgs a)
 	{
 		Application.Quit ();

+ 4 - 4
tools/gui/UnitEditor/UnitEditor/Program.cs

@@ -5,14 +5,14 @@ namespace UnitEditor
 {
 	class MainClass
 	{
+		public static MainWindow g_win;
+
 		public static void Main (string[] args)
 		{
 			Application.Init ();
-			MainWindow win = new MainWindow ();
-
-			win.ShowAll ();
+			g_win = new MainWindow ();
+			g_win.ShowAll ();
 			Application.Run ();
 		}
 	}
-
 }

+ 2 - 2
tools/gui/UnitEditor/UnitEditor/UnitEditor.csproj

@@ -79,8 +79,8 @@
     <Compile Include="MainMenu.cs" />
     <Compile Include="gtk-gui\UnitEditor.MainMenu.cs" />
     <Compile Include="UnitFile.cs" />
-    <Compile Include="UnitNotebook.cs" />
-    <Compile Include="gtk-gui\UnitEditor.UnitNotebook.cs" />
+    <Compile Include="UnitForm.cs" />
+    <Compile Include="gtk-gui\UnitEditor.UnitForm.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
 </Project>

+ 3 - 3
tools/gui/UnitEditor/UnitEditor/UnitNotebook.cs → tools/gui/UnitEditor/UnitEditor/UnitForm.cs

@@ -5,16 +5,16 @@ using Gtk;
 namespace UnitEditor
 {
 	[System.ComponentModel.ToolboxItem (true)]
-	public partial class UnitNotebook : Gtk.EventBox
+	public partial class UnitForm : Gtk.EventBox
 	{
 		public Notebook instance;
 
 
-		public UnitNotebook (string file_name)
+		public UnitForm (string unit_file_name)
 		{
 			instance = new Notebook ();
 
-			UnitEditor.RenderablesList renderables_list = new UnitEditor.RenderablesList (file_name);
+			UnitEditor.RenderablesList renderables_list = new UnitEditor.RenderablesList (unit_file_name);
 			instance.AppendPage (renderables_list, new Label("Renderables"));
 		}
 	}

+ 3 - 3
tools/gui/UnitEditor/UnitEditor/gtk-gui/UnitEditor.UnitNotebook.cs → tools/gui/UnitEditor/UnitEditor/gtk-gui/UnitEditor.UnitForm.cs

@@ -2,14 +2,14 @@
 // This file has been generated by the GUI designer. Do not modify.
 namespace UnitEditor
 {
-	public partial class UnitNotebook
+	public partial class UnitForm
 	{
 		protected virtual void Build ()
 		{
 			global::Stetic.Gui.Initialize (this);
-			// Widget UnitEditor.UnitNotebook
+			// Widget UnitEditor.UnitForm
 			global::Stetic.BinContainer.Attach (this);
-			this.Name = "UnitEditor.UnitNotebook";
+			this.Name = "UnitEditor.UnitForm";
 			if ((this.Child != null)) {
 				this.Child.ShowAll ();
 			}

+ 1 - 1
tools/gui/UnitEditor/UnitEditor/gtk-gui/gui.stetic

@@ -37,7 +37,7 @@
       <placeholder />
     </child>
   </widget>
-  <widget class="Gtk.Bin" id="UnitEditor.UnitNotebook" design-size="644 503">
+  <widget class="Gtk.Bin" id="UnitEditor.UnitForm" design-size="644 503">
     <property name="MemberName" />
     <property name="Visible">False</property>
     <child>