Exemple #1
0
        public static GMProject Load(string rootDirectory)
        {
            if (rootDirectory == null)
            {
                throw new ArgumentNullException(nameof(rootDirectory));
            }

            rootDirectory = Macros.Expand(rootDirectory);
            var project = new GMProject
            {
                RootDirectory = rootDirectory,
                Parent        = null,
                Resources     = null,
                Configs       = new ConfigTree(),
            };

            project.Parent = new GMProjectParent(project);
            if (rootDirectory != Macros.Expand("${base_project}")) // fix StackOverflowException...
            {
                project.Parent.SetAsBaseProject();
            }

            project.Resources = new GMResourceManager(project); // TODO Ewww

            var projectName = rootDirectory.GetTerminalDirectoryName();
            var path        = Path.Combine(rootDirectory, projectName + ".yyp");
            var model       = Json.Deserialize <GMProjectModel>(path);

            project.Deserialize(model);

            return(project);
        }
Exemple #2
0
        public GMResourceManager(GMProject project)
        {
            if (project == null)
            {
                throw new ArgumentNullException(nameof(project));
            }

            resources    = new SortedDictionary <Guid, GMResource>();
            this.project = project;
        }
Exemple #3
0
        public static GMProject New(string rootDirectory)
        {
            if (rootDirectory == null)
            {
                throw new ArgumentNullException(nameof(rootDirectory));
            }

            var project = new GMProject
            {
                Id            = Guid.NewGuid(),
                RootDirectory = rootDirectory,
                Parent        = null,
                Resources     = null,
                Configs       = new ConfigTree(),
                DragAndDrop   = false,
                JavaScript    = false
            };

            project.Parent    = new GMProjectParent(project);   // TODO Eww
            project.Resources = new GMResourceManager(project); // TODO Ewww

            // TODO Inherit from BaseProject
            project.Resources.Create <GMMainOptions>();
            project.Resources.Create <GMWindowsOptions>();
            project.Resources.Create <GMMacOptions>();
            project.Resources.Create <GMLinuxOptions>();
            project.Resources.Create <GMHtml5Options>();
            project.Resources.Create <GMtvOSOptions>();

            var root = project.Resources.Create <GMFolder>();

            root.IsDefaultView = true;
            root.FolderName    = "Default";
            root.FilterType    = "root";

            root.Children.Add(project.AddResourceFolder("GMSprite", "sprites", "ResourceTree_Sprites"));
            root.Children.Add(project.AddResourceFolder("GMTileSet", "tilesets", "ResourceTree_Tilesets"));
            root.Children.Add(project.AddResourceFolder("GMSound", "sounds", "ResourceTree_Sounds"));
            root.Children.Add(project.AddResourceFolder("GMPath", "paths", "ResourceTree_Paths"));
            root.Children.Add(project.AddResourceFolder("GMScript", "scripts", "ResourceTree_Scripts"));
            root.Children.Add(project.AddResourceFolder("GMShader", "shaders", "ResourceTree_Shaders"));
            root.Children.Add(project.AddResourceFolder("GMFont", "fonts", "ResourceTree_Fonts"));
            root.Children.Add(project.AddResourceFolder("GMTimeline", "timelines", "ResourceTree_Timelines"));
            root.Children.Add(project.AddResourceFolder("GMObject", "objects", "ResourceTree_Objects"));
            root.Children.Add(project.AddResourceFolder("GMRoom", "rooms", "ResourceTree_Rooms"));
            root.Children.Add(project.AddResourceFolder("GMNotes", "notes", "ResourceTree_Notes"));
            root.Children.Add(project.AddResourceFolder("GMIncludedFile", "datafiles", "ResourceTree_IncludedFiles"));
            root.Children.Add(project.AddResourceFolder("GMExtension", "extensions", "ResourceTree_Extensions"));
            root.Children.Add(project.AddResourceFolder("GMOptions", "options", "ResourceTree_Options"));
            root.Children.Add(project.AddResourceFolder("GMConfig", "configs", "ResourceTree_Configs"));

            return(project);
        }