public static StudioProject OpenProject(String path) { // Deserialize project from file StudioProject project = null; using (var stream = new StreamEx(path)) { project = JsonUtils.Deserialize <StudioProject>(stream); } project.ProjectDirectory = Path.GetDirectoryName(path); // Sync raw lists to models project.assets = new Dictionary <string, AssetBase>(); foreach (var p in project.RawAssets) { var factory = AssetLoaders[p.AssetLoader]; project.assets.Add(p.Name, factory.Create(project, p.Name, p.Filename)); } // Set up cache manager project.CacheManager = new CacheManager(project); // TODO Load up other stuff return(project); }
public static StudioProject CreateProject(String path, String name) { // Check argument if (path == null) { throw new ArgumentNullException("path"); } // Make sure root directory is there if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } // Set up the project var project = new StudioProject { Name = name, Fps = 10 }; project.ProjectDirectory = path; // Set up directories if (!Directory.Exists(project.GetAssetDirectory())) { Directory.CreateDirectory(project.GetAssetDirectory()); } project.SaveProject(); // Create cache project.CacheManager = new CacheManager(project); return(project); }
/// <summary> /// Constructor. /// Creates a cache manager for the specified StudioProject. /// </summary> /// <param name="project"></param> public CacheManager(StudioProject project) : this() { logger.Info("Creating new StudioCacheManager instance..."); Project = project; // Construct paths string indexPath = Path.Combine(project.ProjectDirectory, IndexFile); string dataPath = Path.Combine(project.ProjectDirectory, DataFile); Initialize(indexPath, dataPath); }
/// <summary> /// Constructor. /// </summary> /// <param name="project">The project that this asset is associated with.</param> /// <param name="name">Name of the asset.</param> /// <param name="filename">Name of the asset file in the asset folder.</param> protected AssetBase(StudioProject project, String name, String filename) { try { Project = project; Name = name; Filename = filename; string strID = Path.GetFileNameWithoutExtension(filename); ID = Guid.Parse(strID); if (!File.Exists(Path.Combine(Project.GetAssetDirectory(), Filename))) throw new FileNotFoundException("Asset file not found!"); } catch (Exception x) { Error = x; } }
/// <summary> /// Constructor. /// </summary> /// <param name="project">The project that this asset is associated with.</param> /// <param name="name">Name of the asset.</param> /// <param name="filename">Name of the asset file in the asset folder.</param> protected AssetBase(StudioProject project, String name, String filename) { try { Project = project; Name = name; Filename = filename; string strID = Path.GetFileNameWithoutExtension(filename); ID = Guid.Parse(strID); if (!File.Exists(Path.Combine(Project.GetAssetDirectory(), Filename))) { throw new FileNotFoundException("Asset file not found!"); } } catch (Exception x) { Error = x; } }
/// <summary> /// Pushes a project into the recent projects list. /// Pinned projects will not be removed. /// </summary> /// <param name="project"></param> public void PushRecentProject(StudioProject project) { var existing = RecentProjects.FindIndex(i => i.ID.Equals(project.Guid)); if (existing == -1) { logger.Info("Adding {0} to the recent project list.", project.Name); var info = new RecentProjectInfo { ID = project.Guid, Name = project.Name, Path = Path.Combine(project.ProjectDirectory, StudioProject.PROJECT_FILE), IsPinned = false }; // If the list if at capacity if (RecentProjects.Count >= RecentProjectsListCapacity) { // Remove the last unpinned entry var unpinned = RecentProjects.FindLastIndex(i => !i.IsPinned); if (unpinned != -1) { RecentProjects.RemoveAt(unpinned); RecentProjects.Insert(0, info); FirePropertyChanged("RecentProjects"); logger.Trace("Recent projects list at capacity, removed the last unpinned."); } else logger.Trace("Recent projects list at capacity, no unpinned entries to remove."); } else { RecentProjects.Insert(0, info); FirePropertyChanged("RecentProjects"); } } else { logger.Info("Moving {0} to the top of the RecentProjects list.", project.Name); var info = RecentProjects[existing]; RecentProjects.RemoveAt(existing); RecentProjects.Insert(0, info); } }
public static StudioProject CreateProject(String path, String name) { // Check argument if (path == null) throw new ArgumentNullException("path"); // Make sure root directory is there if (!Directory.Exists(path)) Directory.CreateDirectory(path); // Set up the project var project = new StudioProject { Name = name, Fps = 10 }; project.ProjectDirectory = path; // Set up directories if (!Directory.Exists(project.GetAssetDirectory())) Directory.CreateDirectory(project.GetAssetDirectory()); project.SaveProject(); // Create cache project.CacheManager = new CacheManager(project); return project; }