Ejemplo n.º 1
0
        /// <summary>
        /// Helper function to scan a directory for all shape files present.
        /// </summary>
        /// <param name="location"></param>
        /// <param name="loader"></param>
        /// <param name="builder"></param>
        private void scanDirectory(ShapeLocation location, ShapeLoader loader, ShapeBuilder builder, VirtualFileSystem vfs)
        {
            IEnumerable <String> files = vfs.listFiles(location.LocName, location.Recursive);

            foreach (String path in files)
            {
                if (loader.canLoadShape(path, vfs))
                {
                    loader.loadShapes(builder, path, vfs);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Helper function to load the shapes at the specified location.
        /// </summary>
        /// <param name="location">The location to load.</param>
        /// <param name="loader">The loader to use.</param>
        /// <param name="builder">The builder to use.</param>
        private void loadShape(ShapeLocation location, ShapeLoader loader, ShapeBuilder builder)
        {
            VirtualFileSystem vfs = VirtualFileSystem.Instance;

            builder.setCurrentShapeLocation(location);
            if (vfs.isDirectory(location.LocName))
            {
                scanDirectory(location, loader, builder, vfs);
            }
            else
            {
                if (loader.canLoadShape(location.LocName, vfs))
                {
                    loader.loadShapes(builder, location.LocName, vfs);
                }
                else
                {
                    Logging.Log.Default.sendMessage("Cannot load collision file {0}.", LogLevel.Error, "ShapeLoading", location.LocName);
                }
            }
            location.Loaded = true;
            //catch (FileNotFoundException)
            //{
            //    Logging.Log.Default.sendMessage("Cannot load collision file {0}.  Location does not exist.", LogLevel.Error, "ShapeLoading", location.LocName);
            //}
            //catch (DirectoryNotFoundException)
            //{
            //    Logging.Log.Default.sendMessage("Cannot load collision directory {0}.  Location does not exist.", LogLevel.Error, "ShapeLoading", location.LocName);
            //}
            //catch (NotSupportedException)
            //{
            //    Logging.Log.Default.sendMessage("The given path format is not supported {0}.", LogLevel.Error, "ShapeLoading", location.LocName);
            //}
            //catch (IOException e)
            //{
            //    Logging.Log.Default.sendMessage("General IO error loading collision {0}.\n{1}", LogLevel.Error, "ShapeLoading", location.LocName, e.Message);
            //}
        }