Пример #1
0
 public static PublishGroup GetPublishGroup(string groupName, string path)
 {
     var group = new PublishGroup();
     group.GroupName = groupName;
     group.Path = path;
     group.PublishInfo = PublishInfo.GetPublishInfo(new FileInfo(groupName));
     return group;
 }
Пример #2
0
        private Dictionary<ImageFile, ImageLayouter> LayoutImage(PublishGroup publishGroup, MySortedList<ImageFile> bitmaps,bool isPOT,bool isSquare)
        {
            var result = new Dictionary<ImageFile, ImageLayouter>();
            uint order = 0;
            while (bitmaps.Count > 0)
            {
                var layouter = new ImageLayouter(PublishTarget.Current.DefaultImageSize, PublishTarget.Current.MaxImageSize, isPOT, isSquare);
                var copyList = new MySortedList<ImageFile>();
                copyList.AddRange(bitmaps);

                layouter.Generate(copyList);
                bitmaps.RemoveRange(layouter.UsedImages);

                if (layouter.ResultImageFixedSize != Size.Empty)
                {
                    FileInfo newFile = new FileInfo(publishGroup.GenerateNewFileName(PathManager.OutputImagesPath, order));
                    var resultImage = new ImageFile(newFile,true,true)
                        {
                            TextureRect = new Rectangle(Point.Empty, layouter.ResultImageFixedSize)
                        };

                    resultImage.Order = order;
                    if (PublishTarget.Current.IsPVR)
                    {
                        resultImage.IsPVREnabled = layouter.UsedImages.All(usedImage => usedImage.IsPVREnabled);
                    }
                    else
                    {
                        resultImage.IsPVREnabled = false;
                    }

                    result.Add(resultImage, layouter);
                    Logger.LogInfo("\t\tPack Image:{0}:\r\n", resultImage.FileInfo.Name);

                }
                else
                {
                    foreach (var usedImage in layouter.UsedImages)
                    {
                        Logger.LogInfo("\t\tToo Big Image:{0}:\r\n", usedImage);
                    }
                }
                ++order;
            }

            //foreach (var mergeResult in result)
            //{
            //    Logger.LogInfo("\t{0} {1}=>{2}:\r\n", mergeResult.Key, mergeResult.Value.ResultImageSize,
            //                   mergeResult.Value.ResultImageFixedSize);

            //    foreach (var imageFile in mergeResult.Value.UsedImages)
            //    {
            //        Logger.LogInfo("\t\t{0}:\r\n", imageFile);
            //    }
            //}

            return result;
        }
Пример #3
0
        public static PublishGroup GetPublishGroup(string groupName, string path)
        {
            var group = new PublishGroup();

            group.GroupName   = groupName;
            group.Path        = path;
            group.PublishInfo = PublishInfo.GetPublishInfo(new FileInfo(groupName));
            return(group);
        }
Пример #4
0
 public static PublishGroup GetPublishGroup(FileInfo file)
 {
     var group = new PublishGroup();
     group.GroupName = file.Directory.Name;
     group.SubGroupName = string.Empty;
     group.Path = file.DirectoryName.Replace(PathManager.InputImagesPath.FullName, string.Empty);
     group.Path = group.Path.Replace(PathManager.OutputImagesPath.FullName, string.Empty);
     group.Path = group.Path.TrimStart(new[] { '/', '\\' });
     group.PublishInfo = PublishInfo.GetPublishInfo(file);
     return group;
 }
Пример #5
0
        public static PublishGroup GetPublishGroup(FileInfo file)
        {
            var group = new PublishGroup();

            group.GroupName    = file.Directory.Name;
            group.SubGroupName = string.Empty;
            group.Path         = file.DirectoryName.Replace(PathManager.InputImagesPath.FullName, string.Empty);
            group.Path         = group.Path.Replace(PathManager.OutputImagesPath.FullName, string.Empty);
            group.Path         = group.Path.TrimStart(new[] { '/', '\\' });
            group.PublishInfo  = PublishInfo.GetPublishInfo(file);
            return(group);
        }
Пример #6
0
        public Dictionary<ImageFile, ImageLayouter> Generate(PublishGroup publishGroup, MySortedList<ImageFile> inputFiles)
        {
            bool isPOT = inputFiles.All(inputFile => inputFile.IsPOT);
            bool isSquare = inputFiles.All(inputFile => inputFile.IsSquare);

            var imageLayouts = LayoutImage(publishGroup, inputFiles, isPOT, isSquare);
            foreach (var imageLayouter in imageLayouts)
            {
                MergeImages(imageLayouter.Key, imageLayouter.Value);
            }

            return imageLayouts;
        }
Пример #7
0
        public void UpdateSubPublishGroup(PublishGroup publishGroup)
        {
            if (PublishGroup == null || publishGroup == null)
            {
                PublishGroup = publishGroup;
            }
            else
            {
                if (PublishGroup.SubGroupName != publishGroup.GroupName) //when assign one file to multi group, it means to be a "Common" group.
                {
                    //Logger.LogAllLine("Merge to group Common from {0},{1}", mPublishGroup.GroupName, value.GroupName);
                    if (!PublishGroup.SubGroupName.Contains(publishGroup.GroupName))
                    {
                        PublishGroup.SubGroupName += publishGroup.GroupName;
                    }
                }

                //Don't change path
                //PublishGroup.PublishInfo.Merge(publishGroup.PublishInfo);
            }
        }