示例#1
0
 internal GMGraphicsOptionsModel Serialize()
 {
     return(new GMGraphicsOptionsModel
     {
         id = Id,
         textureGroups = TextureGroups.Select(x => (GMTextureGroupModel)x.Serialize()).ToList()
     });
 }
示例#2
0
        internal void Deserialize(GMGraphicsOptionsModel graphicsOptions)
        {
            Id = graphicsOptions.id;

            foreach (var modelTextureGroup in graphicsOptions.textureGroups)
            {
                var textureGroup = new GMTextureGroup();
                textureGroup.Deserialize(modelTextureGroup);
                TextureGroups.Add(textureGroup);
            }
        }
示例#3
0
        public GMTextureGroup CreateTextureGroup(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            // TODO Validate name

            var textureGroup = new GMTextureGroup
            {
                Id   = Guid.NewGuid(),
                Name = name
            };

            TextureGroups.Add(textureGroup);

            return(textureGroup);
        }
示例#4
0
 public void Reset()
 {
     Entries.Clear();
     TextureGroups.Clear();
 }
示例#5
0
        public void Compile()
        {
            IOrderedEnumerable <TexturePageEntry> orderedEnumerable = from e in Entries
                                                                      orderby e.Name, e.HasAlpha, e.W *e.H descending
            select e;

            Entries = orderedEnumerable.ToList();
            int num = -1;

            foreach (TexturePageEntry item in orderedEnumerable)
            {
                num++;
                if (Program.DisplaySortedTextures)
                {
                    Console.WriteLine("entry :: w={0} h={1} hasAlpha={2}", item.W, item.H, item.HasAlpha);
                }
                List <Texture> list = null;
                int            num2 = 0;
                foreach (KeyValuePair <string, List <Texture> > textureGroup in TextureGroups)
                {
                    if (item.Name == textureGroup.Key)
                    {
                        list = textureGroup.Value;
                        break;
                    }
                    num2++;
                }
                if (list == null)
                {
                    list = new List <Texture>();
                    TextureGroups.Add(item.Name, list);
                    num2++;
                }
                int     _X      = 0;
                int     _Y      = 0;
                bool    flag    = false;
                Texture texture = null;
                foreach (Texture item2 in list)
                {
                    flag = item2.Alloc(item, out _X, out _Y);
                    if (flag)
                    {
                        texture = item2;
                        break;
                    }
                }
                if (!flag)
                {
                    Texture texture2 = new Texture(TextureSizeWidth, TextureSizeHeight, GapX, GapY, MarginX, MarginY);
                    texture2.Group = 0;
                    list.Add(texture2);
                    texture2.Alloc(item, out _X, out _Y);
                    texture = texture2;
                }
                item.X  = _X;
                item.Y  = _Y;
                item.TP = texture;
                texture.Entries.Add(item);
                if (item.DebugTag)
                {
                    item.DebugTag = true;
                }
            }
            foreach (Texture texture3 in Textures)
            {
                int  num3  = texture3.Bitmap.Width;
                int  num4  = texture3.Bitmap.Height;
                int  _X2   = 0;
                int  _Y2   = 0;
                bool flag2 = true;
                while (flag2)
                {
                    int num5 = (num3 == num4) ? num3 : (num3 / 2);
                    int num6 = (num3 == num4) ? (num4 / 2) : num4;
                    texture3.Resize(num5, num6);
                    foreach (TexturePageEntry entry in texture3.Entries)
                    {
                        if (!texture3.Alloc(entry, out _X2, out _Y2))
                        {
                            flag2 = false;
                            break;
                        }
                        entry.X = _X2;
                        entry.Y = _Y2;
                    }
                    if (flag2)
                    {
                        num3 = num5;
                        num4 = num6;
                    }
                }
                num = -1;
                texture3.Resize(num3, num4);
                foreach (TexturePageEntry entry2 in texture3.Entries)
                {
                    num++;
                    if (texture3.Alloc(entry2, out _X2, out _Y2))
                    {
                        entry2.X = _X2;
                        entry2.Y = _Y2;
                    }
                    else
                    {
                        Console.WriteLine("This should not happen #2");
                    }
                }
            }
            int num7 = 0;

            foreach (Texture texture4 in Textures)
            {
                texture4.TP = num7;
                texture4.CopyEntries();
                num7++;
            }
        }
示例#6
0
 public GMTextureGroup GetTextureGroup(Guid groupId)
 {
     return(TextureGroups.FirstOrDefault(x => x.Id == groupId));
 }