Forráskód Böngészése

Merge branch 'master' of https://github.com/taylor001/crown

Daniele Bartolini 11 éve
szülő
commit
19bf48d1a1

+ 20 - 0
tools/gui/UnitEditor/UnitEditor.sln

@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitEditor", "UnitEditor\UnitEditor.csproj", "{5F034BDB-0B44-4ED5-A95A-72BF1701F05C}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|x86 = Debug|x86
+		Release|x86 = Release|x86
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{5F034BDB-0B44-4ED5-A95A-72BF1701F05C}.Debug|x86.ActiveCfg = Debug|x86
+		{5F034BDB-0B44-4ED5-A95A-72BF1701F05C}.Debug|x86.Build.0 = Debug|x86
+		{5F034BDB-0B44-4ED5-A95A-72BF1701F05C}.Release|x86.ActiveCfg = Release|x86
+		{5F034BDB-0B44-4ED5-A95A-72BF1701F05C}.Release|x86.Build.0 = Release|x86
+	EndGlobalSection
+	GlobalSection(MonoDevelopProperties) = preSolution
+		StartupItem = UnitEditor\UnitEditor.csproj
+	EndGlobalSection
+EndGlobal

+ 184 - 0
tools/gui/UnitEditor/UnitEditor/MainMenu.cs

@@ -0,0 +1,184 @@
+using System;
+using Gtk;
+using System.Xml;
+using System.Xml.Linq;
+using System.Collections.Generic;
+using Newtonsoft.Json.Linq;
+using System.IO;
+using Newtonsoft.Json;
+using System.Data;
+
+namespace UnitEditor
+{
+	[System.ComponentModel.ToolboxItem (true)]
+	public partial class MainMenu : Gtk.Bin
+	{
+		public Gtk.UIManager uim = null;
+		public Gtk.MenuBar instance;
+		/*
+         The first required piece is the XML definition.
+
+         The following is a hard-coded definition of a Gtk.MenuBar control (widget).
+         However, automation can come into play here by constructing the inner-XElements and building out.
+         Consider using a string formatting function to take a name in a list like "Zoom In", using that as-is
+         for the name of the Gtk.MenuItem, and using it again (after removing spaces) for the action name.
+     	*/
+		private XDocument UI = new XDocument (
+			new XElement ("ui",
+				new XElement ("menubar",
+					new XElement ("menu", new XAttribute ("action", "FileMenu"),
+						new XElement ("menuitem", new XAttribute ("action", "New")),
+						new XElement ("menuitem", new XAttribute ("action", "Open")),
+						new XElement ("separator"),
+						new XElement ("menuitem", new XAttribute ("action", "Save")),
+						new XElement ("menuitem", new XAttribute ("action", "SaveAs")),
+						new XElement ("menuitem", new XAttribute ("action", "SaveAll")),
+						new XElement ("separator"),
+						new XElement ("menuitem", new XAttribute ("action", "Close")),
+						new XElement ("menuitem", new XAttribute ("action", "CloseAll")),
+						new XElement ("menuitem", new XAttribute ("action", "Quit"))
+					),
+					new XElement ("menu", new XAttribute ("action", "EditMenu"),
+						new XElement ("menuitem", new XAttribute ("action", "Undo")),
+						new XElement ("menuitem", new XAttribute ("action", "Redo")),
+						new XElement ("separator"),
+						new XElement ("menuitem", new XAttribute ("action", "Cut")),
+						new XElement ("menuitem", new XAttribute ("action", "Copy")),
+						new XElement ("menuitem", new XAttribute ("action", "Paste")),
+						new XElement ("menuitem", new XAttribute ("action", "Delete")),
+						new XElement ("separator"),
+						new XElement ("menuitem", new XAttribute ("action", "SelectAll"))
+					),
+					new XElement ("menu", new XAttribute ("action", "ViewMenu"),
+						new XElement ("menuitem", new XAttribute ("action", "ZoomIn")),
+						new XElement ("menuitem", new XAttribute ("action", "ZoomOut")),
+						new XElement ("separator"),
+						new XElement ("menuitem", new XAttribute ("action", "Fullscreen"))
+					),
+					new XElement ("menu", new XAttribute ("action", "SearchMenu"),
+						new XElement ("menuitem", new XAttribute ("action", "Find")),
+						new XElement ("menuitem", new XAttribute ("action", "Replace")),
+						new XElement ("separator"),
+						new XElement ("menuitem", new XAttribute ("action", "GoToLine"))
+					)
+				)
+			)
+		);
+
+		private Dictionary<string, string> keys = new Dictionary<string, string> () {
+			{"New", "<Control>n"},
+			{"Open", "<Control>o"},
+			{"Save", "<Control>s"},
+			{"SaveAs", "<Control><Alt>s"},
+			{"SaveAll", "<Control><Shift>s"},
+			{"Close", "<Control>w"},
+			{"CloseAll", "<Control><Shift>w"},
+			{"Quit", "<Alt>F4"},
+
+			{"Undo", "<Control>z"},
+			{"Redo", "<Control>y"},
+			{"Cut", "<Control>x"},
+			{"Copy", "<Control>c"},
+			{"Paste", "<Control>v"},
+			{"SelectAll", "<Control>a"},
+
+			{"ZoomIn", "<Control>KP_Add"},
+			{"ZoomOut", "<Control>KP_Subtract"},
+			{"Fullscreen", "F11"},
+
+			{"Find", "<Control>f"},
+			{"Replace", "<Control>h"},
+			{"GoToLine", "<Control>g"}
+		};
+
+		public Gtk.ActionEntry[] getActionEntries ()
+		{
+			return new Gtk.ActionEntry[] {
+				new Gtk.ActionEntry ("FileMenu", null, "_File", null, null, null),
+				new Gtk.ActionEntry ("New", null, "New", (keys.ContainsKey ("New")) ? keys ["New"] : null, null, null),
+				new Gtk.ActionEntry ("Open", null, "Open...", (keys.ContainsKey ("Open")) ? keys ["Open"] : null, null, (EventHandler)open_cb),
+				new Gtk.ActionEntry ("Save", null, "Save", (keys.ContainsKey ("Save")) ? keys ["Save"] : null, null, null),
+				new Gtk.ActionEntry ("SaveAs", null, "Save As...", (keys.ContainsKey ("SaveAs")) ? keys ["SaveAs"] : null, null, null),
+				new Gtk.ActionEntry ("SaveAll", null, "Save All", (keys.ContainsKey ("SaveAll")) ? keys ["SaveAll"] : null, null, null),
+				new Gtk.ActionEntry ("Close", null, "Close", (keys.ContainsKey ("Close")) ? keys ["Close"] : null, null, null),
+				new Gtk.ActionEntry ("CloseAll", null, "Close All", (keys.ContainsKey ("CloseAll")) ? keys ["CloseAll"] : null, null, null),
+				new Gtk.ActionEntry ("Quit", null, "Quit", (keys.ContainsKey ("Quit")) ? keys ["Quit"] : null, null, null),
+
+				new Gtk.ActionEntry ("EditMenu", null, "_Edit", null, null, null),
+				new Gtk.ActionEntry ("Undo", null, "Undo", (keys.ContainsKey ("Undo")) ? keys ["Undo"] : null, null, null),
+				new Gtk.ActionEntry ("Redo", null, "Redo", (keys.ContainsKey ("Redo")) ? keys ["Redo"] : null, null, null),
+				new Gtk.ActionEntry ("Cut", null, "Cut", (keys.ContainsKey ("Cut")) ? keys ["Cut"] : null, null, null),
+				new Gtk.ActionEntry ("Copy", null, "Copy", (keys.ContainsKey ("Copy")) ? keys ["Copy"] : null, null, null),
+				new Gtk.ActionEntry ("Paste", null, "Paste", (keys.ContainsKey ("Paste")) ? keys ["Paste"] : null, null, null),
+				new Gtk.ActionEntry ("Delete", null, "Delete", (keys.ContainsKey ("Delete")) ? keys ["Delete"] : null, null, null),
+				new Gtk.ActionEntry ("SelectAll", null, "Select All", (keys.ContainsKey ("SelectAll")) ? keys ["SelectAll"] : null, null, null),
+
+				new Gtk.ActionEntry ("ViewMenu", null, "_View", null, null, null),
+				new Gtk.ActionEntry ("ZoomIn", null, "Zoom In", (keys.ContainsKey ("ZoomIn")) ? keys ["ZoomIn"] : null, null, null),
+				new Gtk.ActionEntry ("ZoomOut", null, "Zoom Out", (keys.ContainsKey ("ZoomOut")) ? keys ["ZoomOut"] : null, null, null),
+				new Gtk.ActionEntry ("Fullscreen", null, "Fullscreen", (keys.ContainsKey ("Fullscreen")) ? keys ["Fullscreen"] : null, null, null),
+
+				new Gtk.ActionEntry ("SearchMenu", null, "_Search", null, null, null),
+				new Gtk.ActionEntry ("Find", null, "Find...", (keys.ContainsKey ("Find")) ? keys ["Find"] : null, null, null),
+				new Gtk.ActionEntry ("Replace", null, "Find & Replace...", (keys.ContainsKey ("Replace")) ? keys ["Replace"] : null, null, null),
+				new Gtk.ActionEntry ("GoToLine", null, "Go To Line...", (keys.ContainsKey ("GoToLine")) ? keys ["GoToLine"] : null, null, null)
+			};
+		}
+
+		public MainMenu ()
+		{
+			Build ();
+			// Create a random string to attach to our base action group name (see WARNING).
+			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 ());
+			// Put the action entry definitions into the UIManager's buffer.
+			uim.InsertActionGroup (actions, 0);
+			// Put the XML definition of the controls (widgets) into the UIManager's buffer -and- create controls (widgets).
+			uim.AddUiFromString (UI.ToString ());
+			// Get the menubar created in the previous space.
+			instance = (Gtk.MenuBar)uim.GetWidget ("/menubar");
+			// Mark everything on the menubar to be shown.
+			instance.ShowAll ();
+		}
+
+		// ACTIONS CALLBACKS
+
+		static void exit_cb (object o, EventArgs args)
+		{
+			Application.Quit ();
+		}
+
+		static void open_cb(object sender, System.EventArgs e)
+		{
+			Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Open file", null, FileChooserAction.Open);
+			fc.AddButton(Stock.Cancel, ResponseType.Cancel);
+			fc.AddButton(Stock.Open, ResponseType.Ok);
+			fc.Filter = new FileFilter();
+			fc.Filter.AddPattern("*.unit");
+			fc.Filter.AddPattern("*.material");
+			fc.Filter.AddPattern("*.physics");
+
+			if (fc.Run() == (int)ResponseType.Ok)
+			{
+				UnitFile u = new UnitFile (fc.Filename);
+				u.deserialize ();
+				u.serialize ();
+			}
+
+			//Don't forget to call Destroy() or the FileChooserDialog window won't get closed.
+			fc.Destroy();
+		}
+	}
+}
+

+ 29 - 0
tools/gui/UnitEditor/UnitEditor/MainWindow.cs

@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using Gtk;
+
+public partial class MainWindow: Gtk.Window
+{
+	public MainWindow () : base (Gtk.WindowType.Toplevel)
+	{
+		Build ();
+
+		VBox box = new VBox (false, 2);
+
+		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 ();
+	}
+
+	protected void OnDeleteEvent (object sender, DeleteEventArgs a)
+	{
+		Application.Quit ();
+		a.RetVal = true;
+	}
+}

+ 18 - 0
tools/gui/UnitEditor/UnitEditor/Program.cs

@@ -0,0 +1,18 @@
+using System;
+using Gtk;
+
+namespace UnitEditor
+{
+	class MainClass
+	{
+		public static void Main (string[] args)
+		{
+			Application.Init ();
+			MainWindow win = new MainWindow ();
+
+			win.ShowAll ();
+			Application.Run ();
+		}
+	}
+
+}

+ 22 - 0
tools/gui/UnitEditor/UnitEditor/Properties/AssemblyInfo.cs

@@ -0,0 +1,22 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes.
+// Change them to the values specific to your project.
+[assembly: AssemblyTitle ("UnitEditor")]
+[assembly: AssemblyDescription ("")]
+[assembly: AssemblyConfiguration ("")]
+[assembly: AssemblyCompany ("")]
+[assembly: AssemblyProduct ("")]
+[assembly: AssemblyCopyright ("mikymod")]
+[assembly: AssemblyTrademark ("")]
+[assembly: AssemblyCulture ("")]
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+[assembly: AssemblyVersion ("1.0.*")]
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
+

+ 168 - 0
tools/gui/UnitEditor/UnitEditor/RenderablesList.cs

@@ -0,0 +1,168 @@
+using System;
+using System.Collections.Generic;
+using Gtk;
+
+namespace UnitEditor
+{
+
+	[System.ComponentModel.ToolboxItem (true)]
+	public partial class RenderablesList : Gtk.EventBox
+	{
+		private UnitFile m_unit_file;
+
+		private ListStore m_renderables_store;
+
+		private List<string> m_renderables_names;
+		private List<Renderable> m_renderables;
+
+		public RenderablesList (string file_name)
+		{
+			m_unit_file = new UnitFile (file_name);
+
+			m_renderables_names = new List<string> (m_unit_file.renderables_names());
+			m_renderables = new List<Renderable> (m_unit_file.renderables());
+
+			Console.Write (m_renderables_names[0]);
+			m_renderables_store = new ListStore (typeof (string), typeof (string), typeof (string), typeof(string), typeof(bool));
+
+			TreeView tree = new TreeView ();
+			this.Add (tree);
+
+			TreeViewColumn nameColumn = new TreeViewColumn ();
+			nameColumn.Title = "Name";
+			nameColumn.Alignment = 0.5f;
+
+			TreeViewColumn nodeColumn = new TreeViewColumn ();
+			nodeColumn.Title = "Node";
+			nodeColumn.Alignment = 0.5f;
+
+			TreeViewColumn typeColumn = new TreeViewColumn ();
+			typeColumn.Title = "Type";
+			typeColumn.Alignment = 0.5f;
+
+			TreeViewColumn resourceColumn = new TreeViewColumn ();
+			resourceColumn.Title = "Resource";
+			resourceColumn.Alignment = 0.5f;
+
+			TreeViewColumn visibleColumn = new TreeViewColumn ();
+			visibleColumn.Title = "Visible";
+			visibleColumn.Alignment = 0.5f;
+
+			// Assign the model to the TreeView
+			tree.Model = m_renderables_store;
+
+			CellRendererText nameCell = new CellRendererText ();
+			nameCell.Editable = true;
+			nameCell.Edited += delegate (object o, EditedArgs e) { 
+				TreePath path = new TreePath (e.Path);
+				TreeIter iter;
+				m_renderables_store.GetIter (out iter, path);
+				int i = path.Indices[0];
+
+				string r = e.NewText;
+				m_renderables_names[i] = r;
+				m_renderables_store.SetValue (iter, 0, r);
+			};
+			nameColumn.PackStart (nameCell, true);
+
+			CellRendererText nodeCell = new CellRendererText ();
+			nodeCell.Editable = true;
+			nodeCell.Edited += delegate (object o, EditedArgs e) { 
+				TreePath path = new TreePath (e.Path);
+				TreeIter iter;
+				m_renderables_store.GetIter (out iter, path);
+				int i = path.Indices[0];
+
+				Renderable r = m_renderables[i];
+				r.node = e.NewText;
+				m_renderables_store.SetValue (iter, 1, r.node);
+			};
+			nodeColumn.PackStart (nodeCell, true);
+
+			CellRendererText typeCell = new CellRendererText ();
+			typeCell.Editable = true;
+			typeCell.Edited += delegate (object o, EditedArgs e) { 
+				TreePath path = new TreePath (e.Path);
+				TreeIter iter;
+				m_renderables_store.GetIter (out iter, path);
+				int i = path.Indices[0];
+
+				Renderable r = m_renderables[i];
+				r.type = e.NewText;
+				m_renderables_store.SetValue (iter, 2, r.type);
+			};
+			typeColumn.PackStart (typeCell, true);
+
+			CellRendererText resourceCell = new CellRendererText ();
+			resourceCell.Editable = true;
+			resourceCell.Edited += delegate (object o, EditedArgs e) { 
+				TreePath path = new TreePath (e.Path);
+				TreeIter iter;
+				m_renderables_store.GetIter (out iter, path);
+				int i = path.Indices[0];
+
+				Renderable r = m_renderables[i];
+				r.resource = e.NewText;
+				m_renderables_store.SetValue (iter, 3, r.resource);
+			};
+			resourceColumn.PackStart (resourceCell, true);
+
+			CellRendererToggle visibleCell = new CellRendererToggle ();
+			visibleCell.Activatable = true;
+			visibleCell.Toggled += delegate (object o, ToggledArgs e) {
+				TreePath path = new TreePath (e.Path);
+				TreeIter iter;
+				m_renderables_store.GetIter (out iter, path);
+				int i = path.Indices[0];
+
+				Renderable r = m_renderables[i];
+				bool old = (bool) m_renderables_store.GetValue(iter, 4);
+				r.visible = !old;
+				m_renderables_store.SetValue(iter, 4, !old);
+			};
+			visibleColumn.PackStart (visibleCell, true);
+
+			// Add the columns to the TreeView
+			nameColumn.AddAttribute (nameCell, "text", 0);
+			nodeColumn.AddAttribute (nodeCell, "text", 1);
+			typeColumn.AddAttribute (typeCell, "text", 2);
+			resourceColumn.AddAttribute (resourceCell, "text", 3);
+			visibleColumn.AddAttribute (visibleCell, "active", 4);
+
+			tree.AppendColumn (nameColumn);
+			tree.AppendColumn (nodeColumn);
+			tree.AppendColumn (typeColumn);
+			tree.AppendColumn (resourceColumn);
+			tree.AppendColumn (visibleColumn);
+
+			create_model ();
+
+			// Show the window and everything on it
+			ShowAll ();
+		}
+
+		void create_model()
+		{
+			for (int i = 0; i < m_renderables.Count; i++)
+			{
+				m_renderables_store.AppendValues (
+						m_renderables_names[i],
+						m_renderables[i].node,
+						m_renderables[i].type,
+						m_renderables[i].resource,
+						m_renderables[i].visible);
+			}
+		}
+
+		static void delete_event (object obj, DeleteEventArgs args)
+		{
+			Application.Quit();
+		}
+
+		static void exitbutton_event (object obj, ButtonPressEventArgs args)
+		{
+			Application.Quit();
+		}
+	}
+}
+

+ 36 - 0
tools/gui/UnitEditor/UnitEditor/Types.cs

@@ -0,0 +1,36 @@
+using System.Collections.Generic;
+
+namespace UnitEditor
+{
+	
+//------------------------------------------------------------------------------
+public class Renderable
+{
+	public Renderable(string node, string type, string resource, bool visible)
+	{
+		this.node = node;
+		this.type = type;
+		this.resource = resource;
+		this.visible = visible;
+	}
+
+	public string node { set; get; }
+	public string type { set; get; }
+	public string resource { set; get; }
+	public bool visible { set; get; }
+
+	public override string ToString()
+	{
+		return "node: " + node + ", type: " + type + ", resource: " + resource + ", visible: " + visible + "\n";
+	}
+}
+
+//------------------------------------------------------------------------------
+public class Node
+{
+	public string parent { set; get; }
+	public float[] position = new float[3];
+	public float[] rotation = new float[4];
+}
+
+} // namespace UnitEditor

+ 86 - 0
tools/gui/UnitEditor/UnitEditor/UnitEditor.csproj

@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+    <ProductVersion>10.0.0</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{5F034BDB-0B44-4ED5-A95A-72BF1701F05C}</ProjectGuid>
+    <OutputType>WinExe</OutputType>
+    <RootNamespace>UnitEditor</RootNamespace>
+    <AssemblyName>UnitEditor</AssemblyName>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug</OutputPath>
+    <DefineConstants>DEBUG;</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <ConsolePause>false</ConsolePause>
+    <PlatformTarget>x86</PlatformTarget>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <DebugType>full</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release</OutputPath>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <ConsolePause>false</ConsolePause>
+    <PlatformTarget>x86</PlatformTarget>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="gtk-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+      <SpecificVersion>False</SpecificVersion>
+    </Reference>
+    <Reference Include="gdk-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+      <SpecificVersion>False</SpecificVersion>
+    </Reference>
+    <Reference Include="glib-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+      <SpecificVersion>False</SpecificVersion>
+    </Reference>
+    <Reference Include="glade-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+      <SpecificVersion>False</SpecificVersion>
+    </Reference>
+    <Reference Include="pango-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+      <SpecificVersion>False</SpecificVersion>
+    </Reference>
+    <Reference Include="atk-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+      <SpecificVersion>False</SpecificVersion>
+    </Reference>
+    <Reference Include="Mono.Posix" />
+    <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=c7439020c8fedf87">
+      <Private>False</Private>
+      <Package>monodevelop</Package>
+    </Reference>
+    <Reference Include="System.Xml" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="Newtonsoft.Json">
+      <HintPath>..\..\..\..\..\..\Scaricati\jsondotnet\Bin\Net35\Newtonsoft.Json.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Data" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="gtk-gui\gui.stetic">
+      <LogicalName>gui.stetic</LogicalName>
+    </EmbeddedResource>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="gtk-gui\generated.cs" />
+    <Compile Include="MainWindow.cs" />
+    <Compile Include="gtk-gui\MainWindow.cs" />
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="RenderablesList.cs" />
+    <Compile Include="gtk-gui\UnitEditor.RenderablesList.cs" />
+    <Compile Include="Types.cs" />
+    <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" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+</Project>

+ 82 - 0
tools/gui/UnitEditor/UnitEditor/UnitFile.cs

@@ -0,0 +1,82 @@
+using System;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System.IO;
+using System.Text;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace UnitEditor
+{
+	public class UnitFile
+	{
+		private JObject m_root;
+		private Dictionary<string, Renderable> m_renderables;
+		private Dictionary<string, Node> m_nodes;
+
+		public UnitFile (string file_name)
+		{
+			string json_string = string.Empty;
+
+			using (StreamReader streamReader = new StreamReader(file_name))
+			{            
+				json_string = streamReader.ReadToEnd();
+				m_root = JObject.Parse (json_string);
+			}
+
+			deserialize ();
+		}
+
+		public string[] renderables_names()
+		{
+			return m_renderables.Keys.ToArray ();
+		}
+
+		public Renderable[] renderables()
+		{
+			return m_renderables.Values.ToArray ();
+		}
+
+		public void deserialize()
+		{
+			// Deserialize renderables
+			JToken renderables_token = m_root ["renderables"];
+			m_renderables = JsonConvert.DeserializeObject<Dictionary<string, Renderable>>(renderables_token.ToString());
+
+			// Deserialize Nodes
+			JToken nodes_token = m_root ["nodes"];
+			m_nodes = JsonConvert.DeserializeObject<Dictionary<string, Node>> (nodes_token.ToString ());
+		}
+
+		public void serialize()
+		{
+			string json_string = "{";
+			json_string += "\"renderables\": {";
+			string last = m_renderables.Keys.Last ();
+			foreach (var r in m_renderables)
+			{
+				var k = r.Key;
+				var v = r.Value;
+				string renderables_token = string.Format ("\t\"{0}\" : {1}", k, JsonConvert.SerializeObject(v));
+				if (k != last)
+					json_string += ",";
+				json_string += renderables_token;
+			}
+			json_string += "},\n";
+
+			json_string += "\"nodes\": {";
+			foreach (var n in m_nodes)
+			{
+				var k = n.Key;
+				var v = n.Value;
+				string nodes_token = string.Format ("\t\"{0}\" : {1}", k, JsonConvert.SerializeObject(v));
+				json_string += nodes_token;
+			}
+			json_string += "}";
+			json_string += "}";
+
+			Console.Write (json_string);
+		}
+	}
+}
+

+ 22 - 0
tools/gui/UnitEditor/UnitEditor/UnitNotebook.cs

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

+ 31 - 0
tools/gui/UnitEditor/UnitEditor/gtk-gui/MainWindow.cs

@@ -0,0 +1,31 @@
+
+// This file has been generated by the GUI designer. Do not modify.
+
+public partial class MainWindow
+{
+	private global::Gtk.UIManager UIManager;
+	private global::Gtk.Action FileAction;
+
+	protected virtual void Build ()
+	{
+		global::Stetic.Gui.Initialize (this);
+		// Widget MainWindow
+		this.UIManager = new global::Gtk.UIManager ();
+		global::Gtk.ActionGroup w1 = new global::Gtk.ActionGroup ("Default");
+		this.FileAction = new global::Gtk.Action ("FileAction", global::Mono.Unix.Catalog.GetString ("File"), null, null);
+		this.FileAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("File");
+		w1.Add (this.FileAction, null);
+		this.UIManager.InsertActionGroup (w1, 0);
+		this.AddAccelGroup (this.UIManager.AccelGroup);
+		this.Name = "MainWindow";
+		this.Title = global::Mono.Unix.Catalog.GetString ("MainWindow");
+		this.WindowPosition = ((global::Gtk.WindowPosition)(4));
+		if ((this.Child != null)) {
+			this.Child.ShowAll ();
+		}
+		this.DefaultWidth = 400;
+		this.DefaultHeight = 300;
+		this.Show ();
+		this.DeleteEvent += new global::Gtk.DeleteEventHandler (this.OnDeleteEvent);
+	}
+}

+ 19 - 0
tools/gui/UnitEditor/UnitEditor/gtk-gui/UnitEditor.MainMenu.cs

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

+ 19 - 0
tools/gui/UnitEditor/UnitEditor/gtk-gui/UnitEditor.RenderablesList.cs

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

+ 19 - 0
tools/gui/UnitEditor/UnitEditor/gtk-gui/UnitEditor.UnitNotebook.cs

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

+ 81 - 0
tools/gui/UnitEditor/UnitEditor/gtk-gui/generated.cs

@@ -0,0 +1,81 @@
+
+// This file has been generated by the GUI designer. Do not modify.
+namespace Stetic
+{
+	internal class Gui
+	{
+		private static bool initialized;
+
+		internal static void Initialize (Gtk.Widget iconRenderer)
+		{
+			if ((Stetic.Gui.initialized == false)) {
+				Stetic.Gui.initialized = true;
+			}
+		}
+	}
+
+	internal class BinContainer
+	{
+		private Gtk.Widget child;
+		private Gtk.UIManager uimanager;
+
+		public static BinContainer Attach (Gtk.Bin bin)
+		{
+			BinContainer bc = new BinContainer ();
+			bin.SizeRequested += new Gtk.SizeRequestedHandler (bc.OnSizeRequested);
+			bin.SizeAllocated += new Gtk.SizeAllocatedHandler (bc.OnSizeAllocated);
+			bin.Added += new Gtk.AddedHandler (bc.OnAdded);
+			return bc;
+		}
+
+		private void OnSizeRequested (object sender, Gtk.SizeRequestedArgs args)
+		{
+			if ((this.child != null)) {
+				args.Requisition = this.child.SizeRequest ();
+			}
+		}
+
+		private void OnSizeAllocated (object sender, Gtk.SizeAllocatedArgs args)
+		{
+			if ((this.child != null)) {
+				this.child.Allocation = args.Allocation;
+			}
+		}
+
+		private void OnAdded (object sender, Gtk.AddedArgs args)
+		{
+			this.child = args.Widget;
+		}
+
+		public void SetUiManager (Gtk.UIManager uim)
+		{
+			this.uimanager = uim;
+			this.child.Realized += new System.EventHandler (this.OnRealized);
+		}
+
+		private void OnRealized (object sender, System.EventArgs args)
+		{
+			if ((this.uimanager != null)) {
+				Gtk.Widget w;
+				w = this.child.Toplevel;
+				if (((w != null) && typeof(Gtk.Window).IsInstanceOfType (w))) {
+					((Gtk.Window)(w)).AddAccelGroup (this.uimanager.AccelGroup);
+					this.uimanager = null;
+				}
+			}
+		}
+	}
+
+	internal class ActionGroups
+	{
+		public static Gtk.ActionGroup GetActionGroup (System.Type type)
+		{
+			return Stetic.ActionGroups.GetActionGroup (type.FullName);
+		}
+
+		public static Gtk.ActionGroup GetActionGroup (string name)
+		{
+			return null;
+		}
+	}
+}

+ 47 - 0
tools/gui/UnitEditor/UnitEditor/gtk-gui/gui.stetic

@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<stetic-interface>
+  <configuration>
+    <images-root-path>..</images-root-path>
+  </configuration>
+  <import>
+    <widget-library name="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+    <widget-library name="../bin/Debug/UnitEditor.exe" internal="true" />
+  </import>
+  <widget class="Gtk.Window" id="MainWindow" design-size="400 300">
+    <action-group name="Default">
+      <action id="FileAction">
+        <property name="Type">Action</property>
+        <property name="Label" translatable="yes">File</property>
+        <property name="ShortLabel" translatable="yes">File</property>
+      </action>
+    </action-group>
+    <property name="MemberName" />
+    <property name="Title" translatable="yes">MainWindow</property>
+    <property name="WindowPosition">CenterOnParent</property>
+    <signal name="DeleteEvent" handler="OnDeleteEvent" />
+    <child>
+      <placeholder />
+    </child>
+  </widget>
+  <widget class="Gtk.Bin" id="UnitEditor.RenderablesList" design-size="300 300">
+    <property name="MemberName" />
+    <property name="Visible">False</property>
+    <child>
+      <placeholder />
+    </child>
+  </widget>
+  <widget class="Gtk.Bin" id="UnitEditor.MainMenu" design-size="300 300">
+    <property name="MemberName" />
+    <property name="Visible">False</property>
+    <child>
+      <placeholder />
+    </child>
+  </widget>
+  <widget class="Gtk.Bin" id="UnitEditor.UnitNotebook" design-size="644 503">
+    <property name="MemberName" />
+    <property name="Visible">False</property>
+    <child>
+      <placeholder />
+    </child>
+  </widget>
+</stetic-interface>