Beispiel #1
0
        public string GetAsset(string path, AssetFormat format)
        {
            var fullPath      = this.fileSystem.GetFullPath(path.ToLowerInvariant());
            var filesContents = this.ReadFiles(fullPath, format);

            return(filesContents);
        }
Beispiel #2
0
        string ReadFiles(string fullPath, AssetFormat format)
        {
            if (File.Exists(fullPath))
            {
                return(ReadSingleFile(fullPath));
            }

            return(this.ReadMultipleFiles(fullPath, format));
        }
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>	Constructor. </summary>
 ///
 /// <param name="parentNode">	The parent node. </param>
 public ExtractorColladaSettings(PropertyNode parentNode)
     : base(parentNode)
 {
     if (!parentNode.Has("Overwrite"))
     {
         Overwrite = false;
     }
     if (!parentNode.Has("BitmapFormat"))
     {
         BitmapFormat = AssetFormat.tga;
     }
 }
Beispiel #4
0
        string ReadMultipleFiles(string fullPath, AssetFormat format)
        {
            var fileBuilder = new StringBuilder();

            var files = ListFiles(fullPath, format);

            foreach (var file in files)
            {
                var singleFile = ReadSingleFile(file);
                fileBuilder.AppendLine(singleFile);
            }

            return(fileBuilder.ToString());
        }
Beispiel #5
0
        static IEnumerable <string> ListFiles(string folder, AssetFormat format, List <string> files = null)
        {
            if (files == null)
            {
                files = new List <string>();
            }

            if (!Directory.Exists(folder))
            {
                return(files);
            }

            var directories = Directory.GetDirectories(folder).OrderBy(n => n);

            foreach (var dir in directories)
            {
                ListFiles(dir, format, files);
            }

            var dirFiles = Directory.GetFiles(folder).Where(f =>
            {
                if (format == AssetFormat.Js)
                {
                    return(!f.EndsWith(".test.js") && f.EndsWith(".js"));
                }

                if (format == AssetFormat.Css)
                {
                    return(f.EndsWith(".css") || f.EndsWith(".less"));
                }

                return(false);
            }).OrderBy(n => n);

            files.AddRange(dirFiles);

            return(files);
        }
				////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>	Constructor. </summary>
				///
				/// <param name="parentNode">	The parent node. </param>
				public ExtractorColladaSettings(PropertyNode parentNode)
					: base(parentNode)
				{
					if (!parentNode.Has("Overwrite"))
					{
						Overwrite = false;
					}
					if (!parentNode.Has("BitmapFormat"))
					{
						BitmapFormat = AssetFormat.tga;
					}
				}
Beispiel #7
0
        void Open(string path)
        {
            FileManager  fileManager = FileManager.System;
            Stream       stream      = fileManager.OpenRead(path);
            BinaryReader reader      = new BinaryReader(stream);
            AssetLoader  loader      = new AssetLoader(Manager, reader, path, fileManager);

            Manager.AddBackgroundOperation("Loading '" + path + "'", null, (updateProgress) => {
                loader.PropertyChanged += (sender, args) => {
                    if (args.Property != AssetLoader.ProgressProperty)
                    {
                        return;
                    }
                    if (updateProgress != null)
                    {
                        updateProgress(loader.Progress);
                    }
                };

                Asset asset = null;

                try {
                    asset = AssetFormat.LoadAsset(loader, Manager.AllEnabledFormats);
                } catch (Exception exception) {
                    MessageBox.Show("Load failed: " + exception, "Load failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                if (asset == null)
                {
                    return;
                }

                Manager.AddBackgroundOperation("Browsing '" + path + "'.", null, (subUpdateProgress) => {
                    Control control = asset.Browse(subUpdateProgress);


                    var window = new Form()
                    {
                        MdiParent = this,
                        Text      = Path.GetFileName(path),
                    };

                    control.Dock = DockStyle.Fill;
                    window.Controls.Add(control);
                    window.BringToFront();
                    window.Show();

                    if (MdiChildren.Length == 1)
                    {
                        window.WindowState = FormWindowState.Maximized;
                    }

                    if (Settings.Default.RecentFiles == null)
                    {
                        Settings.Default.RecentFiles = new System.Collections.Specialized.StringCollection();
                    }
                    Settings.Default.RecentFiles.Remove(path);
                    Settings.Default.RecentFiles.Add(path);
                    if (Settings.Default.RecentFiles.Count > 20)
                    {
                        Settings.Default.RecentFiles.RemoveAt(0);
                    }
                    Settings.Default.Save();
                    BuildRecentFilesList();
                });
            });
        }
Beispiel #8
0
			public TestColladaSettings(bool overwrite, string root, AssetFormat format)
			{
				Overwrite = overwrite;
				RootDirectory = root;
				BitmapFormat = format;
			}
Beispiel #9
0
 public FormatTreeNode(AssetFormat format)
     : base(format)
 {
 }
Beispiel #10
0
 public static string GetAssetExtension(AssetFormat format)
 {
     return(kAssetExtensions[format]);
 }
Beispiel #11
0
		public static string GetAssetExtension(AssetFormat format)
		{
			return kAssetExtensions[format];
		}
Beispiel #12
0
 public TestColladaSettings(bool overwrite, string root, AssetFormat format)
 {
     Overwrite     = overwrite;
     RootDirectory = root;
     BitmapFormat  = format;
 }