Example #1
0
		/// <summary>
		/// Loads the DoorsData from the Data assembly
		/// </summary>
		private void Load()
		{
			Stream stream = Pandora.DataAssembly.GetManifestResourceStream( "Data.Doors.xml" );
			XmlDocument dom = new XmlDocument();
			dom.Load( stream );
			stream.Close();

			XmlNode root = dom.ChildNodes[ 1 ];

			foreach( XmlNode xNode in root.ChildNodes )
			{
				if ( xNode.ChildNodes.Count == 0 )
				{
					// Portcullis
					m_PortNS = xNode.Attributes[ "itemNS" ].Value;
					m_PortEW = xNode.Attributes[ "itemEW" ].Value;
					m_PortName = xNode.Attributes[ "name" ].Value;
					m_PortEWBase = int.Parse( xNode.Attributes[ "EW" ].Value );
					m_PortNSBase = int.Parse ( xNode.Attributes[ "NS" ].Value );
				}
				else
				{
					GenericNode gNode = new GenericNode( xNode.Attributes[ "name" ].Value );
					m_Structure.Add( gNode );

					foreach( XmlNode doorNode in xNode.ChildNodes )
					{
						gNode.Elements.Add( DoorInfo.FromXmlNode( doorNode ) );
					}
				}
			}
		}
Example #2
0
		/// <summary>
		/// Processes a folder for script files and subfolders
		/// </summary>
		/// <param name="folder">The folder to process</param>
		/// <param name="parent">The GenericNode that will be hosting the information</param>
		private static void DoFolder( string folder, GenericNode parent )
		{
			string[] dirs = Directory.GetDirectories( folder );

			foreach( string dir in dirs )
			{
				string[] path = dir.Split( Path.DirectorySeparatorChar );
				GenericNode dirNode = new GenericNode( path[ path.Length - 1 ] );

				DoFolder( dir, dirNode );

				parent.Elements.Add( dirNode );
			}

			string[] files = Directory.GetFiles( folder );

			foreach ( string file in files )
			{
				string t = file.ToLower();

				if ( t.EndsWith( ".cs" ) || t.EndsWith( ".txt" ) || t.EndsWith( ".xml" ) || t.EndsWith( ".vb" ) )
				{
					System.IO.FileInfo info = new System.IO.FileInfo( file );

					if ( info.Length <= RemoteExplorerConfig.MaxFileSize )
						parent.Elements.Add( Path.GetFileName( file ) );
				}
			}
		}
Example #3
0
		/// <summary>
		/// Updates the spawn groups and saves them to disk
		/// </summary>
		/// <param name="nodes"></param>
		public void Update( TreeNodeCollection nodes )
		{
			m_Structure.Clear();

			foreach ( TreeNode node in nodes )
			{
				GenericNode gNode = new GenericNode( node.Text );
				gNode.Elements = node.Tag as ArrayList;

				m_Structure.Add( gNode );
			}

			Save();
		}
Example #4
0
		/// <summary>
		/// Updates the spawn groups and saves them to disk
		/// </summary>
		/// <param name="nodes"></param>
		public void Update( TreeNodeCollection nodes )
		{
			m_Structure.Clear();

			foreach ( TreeNode node in nodes )
			{
				GenericNode gNode = new GenericNode( node.Text );
				// Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
				gNode.Elements = node.Tag as List<object>;
				// Issue 10 - End

				m_Structure.Add( gNode );
			}

			Save();
		}
Example #5
0
		/// <summary>
		/// Creates a new BoxFolderInfo object
		/// </summary>
		/// <param name="username">The username of the user registered for acess to the explorer</param>
		public FolderInfo( string username )
		{
			m_Structure = new GenericNode();
			m_Folders = new System.Collections.ArrayList( RemoteExplorerConfig.GetExplorerFolder( username ) );
			
			// Create the folders structure
			foreach ( string folder in m_Folders )
			{
				BoxUtil.EnsureFolder( folder );

				GenericNode fNode = new GenericNode( folder );

				DoFolder( Path.Combine( BoxUtil.RunUOFolder, folder ), fNode);

				m_Structure.Elements.Add( fNode );
			}
		}
Example #6
0
		/// <summary>
		/// Reads the lights structure
		/// </summary>
		private void CreateStructure()
		{
			Stream stream = Pandora.DataAssembly.GetManifestResourceStream( "Data.Lights.xml" );
			XmlDocument dom = new XmlDocument();
			dom.Load( stream );
			stream.Close();

			XmlNode root = dom.ChildNodes[ 1 ];
         
			foreach ( XmlNode catNode in root.ChildNodes )
			{
				GenericNode gNode = new GenericNode( catNode.Attributes[ "name" ].Value );
				m_Structure.Add( gNode );

				foreach ( XmlNode lightNode in catNode.ChildNodes )
				{
					gNode.Elements.Add( lightNode.Attributes[ "name" ].Value );
				}
			}
		}
Example #7
0
		/// <summary>
		/// Searches a GenericNode for a class name
		/// </summary>
		/// <param name="text">The string to search for</param>
		/// <param name="results">The List of strings containing the results</param>
		/// <param name="path">The current path on the structure tree</param>
		/// <param name="node">The GenericNode to search</param>
		// Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
		private void SearchNode( string text, List<string> results, string path, GenericNode node )
		// Issue 10 - End
		{
			if ( path == "" )
				path += node.Name;
			else
				path += string.Format( ".{0}", node.Name );

			if ( node.Name.ToLower().IndexOf( text ) > -1 )
			{
				// This is a match
				results.Add( path );
			}

			// Recurse
			foreach ( object obj in node.Elements )
			{
				if ( obj is GenericNode )
				{
					SearchNode( text, results, path, obj as GenericNode );
				}
			}
		}
Example #8
0
		/// <summary>
		/// Creates a node and recurses through all its subnodes
		/// </summary>
		/// <param name="gNode">The starting GenericNode</param>
		/// <returns>A TreeNode</returns>
		private TreeNode DoNode( GenericNode gNode )
		{
			TreeNode node = new TreeNode( gNode.Name );
			// Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
			node.Tag = new List<object>();
			// Issue 10 - End

			for ( int i = 0; i < gNode.Elements.Count; i++ )
			{
				object obj = gNode.Elements[ i ];

				if ( obj is BoxProp )
				{
					// Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
					( node.Tag as List<object> ).Add( obj as BoxProp );
					// Issue 10 - End
				}
				else if ( obj is GenericNode )
				{
					node.Nodes.Add( DoNode( obj as GenericNode ) );
				}
			}

			return node;
		}
Example #9
0
		/// <summary>
		/// Gets a GenericNode corresponding to the provided path
		/// </summary>
		/// <param name="where">The list to search for the node</param>
		/// <param name="path"></param>
		/// <returns></returns>
		private GenericNode GetNode( ArrayList where, StringCollection path )
		{
			ArrayList list = where;
			GenericNode node = null;

			foreach ( string s in path )
			{
				node = FindNode( list, s );

				if ( node == null )
				{
					node = new GenericNode( s );
					list.Add( node );
				}

				list = node.Elements;
			}

			if ( node == null )
			{
				node = FindNode( where, "Uncategorized" );
				
				if ( node == null )
				{
					node = new GenericNode( "Uncategorized" );
					where.Add( node );
				}
			}

			return node;
		}
Example #10
0
		private object DoNode( TreeNode node )
		{
			if ( node.Tag == null )
			{
				GenericNode cat = new GenericNode( node.Text );

				foreach ( TreeNode child in node.Nodes )
				{
					cat.Elements.Add( DoNode ( child ) );
				}

				return cat;
			}
			else
			{
				UOSound snd = new UOSound( node.Text, (int) node.Tag );

				return snd;
			}
		}
Example #11
0
//		/// <summary>
//		/// Creates a BoxData object provided the items and mobiles
//		/// </summary>
//		/// <param name="boxItems">A list of BoxItem objects</param>
//		/// <param name="boxMobiles">A list of BoxMobile objects</param>
//		/// <returns>A BoxData object containing a categories structure</returns>
//		public static BoxData Create( ArrayList boxItems, ArrayList boxMobiles )
//		{
//			BoxData data = new BoxData();
//
//			// Items
//			foreach ( BoxItem item in boxItems )
//			{
//				GenericNode node = data.GetNode( data.m_Items, item.Path );
//				node.Elements.Add( item );
//			}
//
//			// Mobiles
//			foreach ( BoxMobile mobile in boxMobiles )
//			{
//				GenericNode node = data.GetNode( data.m_Mobiles, mobile.Path );
//				node.Elements.Add( mobile );
//			}
//
//			return data;
//		}

		/// <summary>
		/// Gets a GenericNode corresponding to the provided path
		/// </summary>
		/// <param name="where">The list to search for the node</param>
		/// <param name="path"></param>
		/// <returns></returns>
		// Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
		private GenericNode GetNode( List<object> where, StringCollection path )
		{
			List<object> list = where;
			// Issue 10 - End
			GenericNode node = null;

			foreach ( string s in path )
			{
				node = FindNode( list, s );

				if ( node == null )
				{
					node = new GenericNode( s );
					list.Add( node );
				}

				list = node.Elements;
			}

			if ( node == null )
			{
				node = FindNode( where, "Uncategorized" );
				
				if ( node == null )
				{
					node = new GenericNode( "Uncategorized" );
					where.Add( node );
				}
			}

			return node;
		}
Example #12
0
		/// <summary>
		/// Finds the subtypes for a given type
		/// </summary>
		/// <param name="type">The type to search for subtypes</param>
		/// <param name="parent">The parent node that will hold the subtypes</param>
		private void FindSubTypes( string type, GenericNode parent )
		{
			GenericNode sType = new GenericNode( type );

			ArrayList list = m_Constructables[ type ] as ArrayList;
			m_Constructables.Remove( type );

			if ( list != null && list.Count > 0 )
			{
				parent.Elements.AddRange( list );
			}

			ArrayList subTypes = GetSubTypes( type );

			foreach ( string sub in subTypes )
			{
				GenericNode node = new GenericNode( sub );
				FindSubTypes( sub, node );

				parent.Elements.Add( node );
			}
		}
Example #13
0
		/// <summary>
		/// Converts a GenericNode to a TreeNode
		/// </summary>
		/// <param name="from">The GenericNode to examine</param>
		/// <returns>A TreeNode object corresponding to the GenericNode supplied</returns>
		private TreeNode GetNode( GenericNode from )
		{
			TreeNode node = new TreeNode( from.Name );
			// Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
			node.Tag = new List<object>();
			// Issue 10 - End

			foreach ( object o in from.Elements )
			{
				if ( o is GenericNode )
					node.Nodes.Add( GetNode( o as GenericNode ) );
				else
					// Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
					( node.Tag as List<object> ).Add( o );
					// Issue 10 - End
			}

			return node;
		}
Example #14
0
		/// <summary>
		/// Creates a Facet object from a collection of tree nodes
		/// </summary>
		/// <param name="nodes">The TreeNodeCollection used as source for this Facet object</param>
		/// <param name="name">The map file index corresponding to this facet</param>
		/// <returns>A Facet object representing the nodes collection</returns>
		public static Facet FromTreeNodes( TreeNodeCollection nodes, byte name )
		{
			Facet facet = new Facet();

			facet.MapValue = name;

			foreach ( TreeNode CatNode in nodes )
			{
				GenericNode Category = new GenericNode( CatNode.Text );

				foreach ( TreeNode SubNode in CatNode.Nodes )
				{
					GenericNode Subsection = new GenericNode( SubNode.Text );
					// Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
					Subsection.Elements = (List<object>)SubNode.Tag;
					// Issue 10 - End

					Category.Elements.Add( Subsection );
				}

				facet.m_Nodes.Add( Category );
			}

			return facet;
		}
Example #15
0
		/// <summary>
		/// Adds a new location to this facet
		/// </summary>
		/// <param name="loc">The location that should be added</param>
		/// <param name="category">The category name for the new location</param>
		/// <param name="subsection">The subsection name for the new location</param>
		public void AddLocation( Location loc, string category, string subsection )
		{
			GenericNode catNode = null;

			foreach ( GenericNode cat in m_Nodes )
			{
				if ( cat.Name.ToLower() == category.ToLower() )
				{
					catNode = cat;
					break;
				}
			}

			if ( catNode == null )
			{
				catNode = new GenericNode( category );
				m_Nodes.Add( catNode );
			}

			GenericNode subNode = null;

			foreach( GenericNode sub in catNode.Elements )
			{
				if ( sub.Name.ToLower() == subsection.ToLower() )
				{
					subNode = sub;
					break;
				}
			}

			if ( subNode == null )
			{
				subNode = new GenericNode( subsection );
				catNode.Elements.Add( subNode );
			}

			subNode.Elements.Add( loc );
		}
Example #16
0
		private bool Add( string cat, string sub, string name, int ID )
		{
			if ( cat == null || cat == "" || sub == null || sub == "" || name == null || name == "" )
				return false;

			BoxDeco deco = new BoxDeco();
			deco.ID = ID;
			deco.Name = name;

			GenericNode cNode = null;
			GenericNode sNode = null;

			foreach( GenericNode c in m_Deco.Structure )
				if ( c.Name.ToLower() == cat.ToLower() )
				{
					cNode = c;
					break;
				}

			if ( cNode == null )
			{
				cNode = new GenericNode( cat );
				m_Deco.Structure.Add( cNode );
			}

			foreach( GenericNode s in cNode.Elements )
				if ( s.Name.ToLower() == sub.ToLower() )
				{
					sNode = s;
					break;
				}

			if ( sNode == null )
			{
				sNode = new GenericNode( sub );
				cNode.Elements.Add( sNode );
			}

			sNode.Elements.Add( deco );
			return true;
		}
Example #17
0
		/// <summary>
		/// Process and converts a TreeNode
		/// </summary>
		/// <param name="node">The TreeNode to convert</param>
		/// <returns>A GenericNode object corresponding to the TreeNode</returns>
		private GenericNode DoNode( TreeNode node )
		{
			GenericNode gNode = new GenericNode( node.Text );

			// Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
			foreach ( object o in ( node.Tag as List<object> ) )
			// Issue 10 - End
				gNode.Elements.Add( o );

			foreach ( TreeNode subNode in node.Nodes )
				gNode.Elements.Add( DoNode( subNode ) );

			return gNode;
		}
Example #18
0
		/// <summary>
		/// Processes a GenericNode and created the menu items for it
		/// </summary>
		/// <param name="gNode">The GenericNode to evaluate</param>
		/// <returns>A collection of MenuItem objects</returns>
		private MenuItem[] DoNode( GenericNode gNode )
		{
			MenuItem[] mitems = new MenuItem[ gNode.Elements.Count ];

			for ( int i = 0; i < mitems.Length; i++ )
			{
				GenericNode node = gNode.Elements[ i ] as GenericNode;
				UOSound snd = gNode.Elements[ i ] as UOSound;

				if ( node != null )
				{
					mitems[ i ] = new MenuItem( node.Name );
					mitems[ i ].MenuItems.AddRange( DoNode( node ) );
				}
				else if ( snd != null )
				{
					mitems[ i ] = new InternalMenuItem( snd );
					mitems[ i ].Click += new EventHandler(SoundData_Click);
				}
			}

			return mitems;
		}
Example #19
0
		/// <summary>
		/// Creates the classes structure
		/// </summary>
		private void CreateStructure()
		{
			GenericNode items = new GenericNode( "Item" );
			GenericNode mobiles = new GenericNode( "Mobile" );

			items.Elements.AddRange( m_Constructables[ "Item" ] as ArrayList );
			mobiles.Elements.AddRange( m_Constructables[ "Mobile" ] as ArrayList );

			m_Constructables.Remove( "Item" );
			m_Constructables.Remove( "Mobile" );

			FindSubTypes( "Item", items );
			FindSubTypes( "Mobile", mobiles );

			m_Structure.Add( items );
			m_Structure.Add( mobiles );
		}
Example #20
0
		private TreeNode GetNode( GenericNode gNode )
		{
			TreeNode node = new TreeNode( gNode.Name );

			foreach ( object o in gNode.Elements )
			{
				GenericNode child = o as GenericNode;
				UOSound item = o as UOSound;

				if ( child != null )
				{
					node.Nodes.Add( GetNode( child ) );
				}
				else if ( item != null )
				{
					TreeNode itemNode = new TreeNode( item.Name );
					itemNode.Tag = item.Index;
					node.Nodes.Add( itemNode );
				}
			}

			return node;
		}
Example #21
0
		/// <summary>
		/// Reads a tree node and converts its child nodes to data used in menu defs
		/// </summary>
		/// <param name="node">The tree node to examine</param>
		/// <returns>An array list of generic nodes and box menu items</returns>

		// Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
		private List<object> ProcessTreeNode( TreeNode node )
		{
			List<object> list = new List<object>();
			// Issue 10 - End

			foreach ( TreeNode n in node.Nodes )
			{
				if ( n.Tag is MenuCommand )
				{
					list.Add( n.Tag as MenuCommand );
				}
				else if ( n.Nodes.Count > 0 )
				{
					GenericNode gn = new GenericNode( n.Text );

					gn.Elements = ProcessTreeNode( n );

					if ( gn.Elements.Count > 0 )
						list.Add( gn );
				}
			}

			return list;
		}
Example #22
0
		// Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
		private List<object> CloneItems( List<object> items )
		{
			List<object> list = new List<object>();
			// Issue 10 - End

			foreach ( object o in items )
			{
				if ( o is MenuCommand )
				{
					list.Add( ( o as MenuCommand ).Clone() );
				}
				else if ( o is GenericNode )
				{
					GenericNode gn = new GenericNode( ( o as GenericNode ).Name );

					gn.Elements.AddRange( CloneItems( ( o as GenericNode ).Elements ) );

					list.Add( gn );
				}
			}

			return list;
		}