예제 #1
0
        /// <summary>
        /// Reads a resource database from an XML document, and returns it
        /// </summary>
        /// <param name="xml"></param>
        /// <returns></returns>
        public static ResourceDatabase Read( XmlDocument xml )
        {
            ResourceDatabase database = new ResourceDatabase();

            // Populate the attributions database

            // Process all of the resource files being referenced in the art database
            XmlNode resourcesRoot = xml.SelectSingleNode( "resourcedatabase/resources" );

            // Process all of the resources files included within
            foreach ( XmlNode resourceNode in resourcesRoot.ChildNodes )
            {
                // What kind of resource is this? It will dictate how we load it
                switch ( resourceNode.Name )
                {
                    case "image":
                        database.Images.Add( ImageResource.Read( resourceNode ) );
                        break;

                    case "art":
                        database.ArtFiles.Add( ArtFileResource.Read( resourceNode ) );
                        break;

                    default:
                        throw new ResourceDatabaseImportException( "Unsupported resource type " + resourceNode.Name, "", "" );
                }
            }

            // Find all of the bundles listed in the resource database
            XmlNode bundleRootNode  = xml.SelectSingleNode( "resourcedatabase/bundles" );
            XmlNodeList bundleNodes = bundleRootNode.SelectNodes( "bundle" );

            foreach ( XmlNode bundleNode in bundleNodes )
            {
                database.Bundles.Add( BundleBuilderInfo.Read( bundleNode ) );
            }

            return database;
        }
예제 #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 public MainWindow()
 {
     InitializeComponent();
     mInstance = this;
     mResourceDatabase = new ResourceDatabase();
 }