Exemple #1
0
 void AddIconEntry(List <Entry> dir, object name, IDictionary icon_list)
 {
     if (null == icon_list)
     {
         return;
     }
     foreach (DictionaryEntry icon in icon_list)
     {
         var layer = icon.Value as IDictionary;
         var pixel = layer["pixel"] as EmChunk;
         if (null == pixel)
         {
             continue;
         }
         var entry = new TexEntry {
             Name    = name.ToString() + '#' + icon.Key.ToString(),
             Type    = "image",
             Offset  = DataOffset + pixel.Offset,
             Size    = (uint)pixel.Length,
             Width   = Convert.ToInt32(layer["width"]),
             Height  = Convert.ToInt32(layer["height"]),
             OffsetX = Convert.ToInt32(layer["originX"]),
             OffsetY = Convert.ToInt32(layer["originY"]),
             TexType = layer.Contains("compress") ? layer["compress"].ToString() : "RGBA8",
         };
         entry.TruncatedWidth  = entry.Width;
         entry.TruncatedHeight = entry.Height;
         dir.Add(entry);
     }
 }
Exemple #2
0
        void AddTextureEntry(List <Entry> dir, object name, IDictionary texture)
        {
            if (null == texture)
            {
                return;
            }
            var pixel = texture["pixel"] as EmChunk;

            if (null == pixel)
            {
                return;
            }
            var entry = new TexEntry {
                Name            = name.ToString(),
                Type            = "image",
                Offset          = DataOffset + pixel.Offset,
                Size            = (uint)pixel.Length,
                TexType         = texture["type"].ToString(),
                Width           = Convert.ToInt32(texture["width"]),
                Height          = Convert.ToInt32(texture["height"]),
                TruncatedWidth  = Convert.ToInt32(texture["truncated_width"]),
                TruncatedHeight = Convert.ToInt32(texture["truncated_height"]),
            };

            dir.Add(entry);
        }
Exemple #3
0
        public List <Entry> GetTextures()
        {
            var source = GetRootKey <IDictionary> ("source");

            if (null == source || 0 == source.Count)
            {
                return(null);
            }
            var dir = new List <Entry> (source.Count);

            foreach (DictionaryEntry item in source)
            {
                var item_value = item.Value as IDictionary;
                if (null == item_value)
                {
                    continue;
                }
                var texture = item_value["texture"] as IDictionary;
                if (null == texture)
                {
                    continue;
                }
                var pixel = texture["pixel"] as EmChunk;
                if (null == pixel)
                {
                    continue;
                }
                var entry = new TexEntry {
                    Name            = item.Key.ToString(),
                    Type            = "image",
                    Offset          = DataOffset + pixel.Offset,
                    Size            = (uint)pixel.Length,
                    TexType         = texture["type"].ToString(),
                    Width           = Convert.ToInt32(texture["width"]),
                    Height          = Convert.ToInt32(texture["height"]),
                    TruncatedWidth  = Convert.ToInt32(texture["truncated_width"]),
                    TruncatedHeight = Convert.ToInt32(texture["truncated_height"]),
                };
                dir.Add(entry);
            }
            return(dir);
        }
Exemple #4
0
        IImageDecoder OpenTlg(ArcFile arc, TexEntry entry)
        {
            var input = arc.File.CreateStream(entry.Offset, entry.Size);

            try
            {
                var info = TlgFormat.ReadMetaData(input);
                if (null == info)
                {
                    throw new InvalidFormatException();
                }
                info.OffsetX = entry.OffsetX;
                info.OffsetY = entry.OffsetY;
                return(new ImageFormatDecoder(input, TlgFormat, info));
            }
            catch
            {
                input.Dispose();
                throw;
            }
        }
Exemple #5
0
        public List <Entry> GetLayers()
        {
            var layers = GetRootKey <IList> ("layers");

            if (null == layers || 0 == layers.Count)
            {
                return(null);
            }
            var dir = new List <Entry> (layers.Count);

            foreach (IDictionary layer in layers)
            {
                var name       = layer["layer_id"].ToString() + ".tlg";
                var layer_data = GetRootKey <EmChunk> (name);
                if (null == layer_data)
                {
                    continue;
                }
                var entry = new TexEntry {
                    Name    = name,
                    Type    = "image",
                    Offset  = DataOffset + layer_data.Offset,
                    Size    = (uint)layer_data.Length,
                    TexType = "TLG",
                    OffsetX = Convert.ToInt32(layer["left"]),
                    OffsetY = Convert.ToInt32(layer["top"]),
                    Width   = Convert.ToInt32(layer["width"]),
                    Height  = Convert.ToInt32(layer["height"]),
                };
                dir.Add(entry);
            }
            if (0 == dir.Count)
            {
                return(null);
            }
            return(dir);
        }