Example #1
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);
            //}
        }
Example #2
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);
                }
            }
        }
Example #3
0
 /// <summary>
 /// Loads the contents of the given file and bulids the shapes using the specified
 /// shape builder.
 /// </summary>
 /// <param name="builder">The builder to build the shapes with.</param>
 /// <param name="filename">The filename to load the shapes from.</param>
 public abstract void loadShapes(ShapeBuilder builder, String filename, VirtualFileSystem vfs);
Example #4
0
 /// <summary>
 /// Returns true if the file specified can be loaded by this loader.
 /// </summary>
 /// <param name="filename">The file to test.</param>
 /// <returns>True if the file can be loaded using this loader.</returns>
 public abstract bool canLoadShape(String filename, VirtualFileSystem vfs);