예제 #1
0
        private void AddUserBlueprint(string path)
        {
            var blueprint = IOUtils.JsonDeserializeFromPath <Blueprint>(path);

            if (blueprint == null)
            {
                throw new ArgumentNullException("blueprint");
            }

            if (ContainsName(blueprint.name))
            {
                throw new ArgumentException($"Blueprint named \"{blueprint.name}\" is duplicate");
            }

            var args = new BlueprintContainerArgs(blueprint)
            {
                generateBlueprintFileHandle = true,
                generateBlueprintFileName   = false
            };

            var observableBlueprint = new BlueprintContainer(args);

            observableBlueprint.BlueprintFileHandle.CurrentPath = path;
            observableBlueprint.LoadThumbnail();
            userBlueprints.Add(observableBlueprint);
        }
예제 #2
0
        public BlueprintContainer ToContainer()
        {
            var blueprint = IOUtils.JsonDeserializeWithSettings <Blueprint>(blueprintJson, SerializationMode.Readable);

            var args = new BlueprintContainerArgs(blueprint)
            {
                generateBlueprintFileHandle = false,
                useDefaultThumbnailFolder   = true
            };

            var container = new BlueprintContainer(args);

            container.LoadThumbnail();
            return(container);
        }
예제 #3
0
        public BlueprintContainer(BlueprintContainerArgs args)
            : base(args.blueprint)
        {
            if (args.generateBlueprintFileHandle)
            {
                BlueprintFileHandle = new FileHandle(this,
                                                     name => DirectoryTree.Blueprints.CombineWith($"{name}.json"),
                                                     path => IOUtils.JsonSerializeToPath(Data, path),
                                                     args.generateBlueprintFileName);
            }

            var thumbnailDirectory = args.useDefaultThumbnailFolder
                ? DirectoryTree.DefaultThumbnails
                : DirectoryTree.Thumbnails;

            ThumbnailFileHandle = new FileHandle(this,
                                                 name => thumbnailDirectory.CombineWith($"{name}.png"),
                                                 path => IOUtils.SaveTexture2D(Data.Thumbnail, path));
        }