Exemple #1
0
 private void TryLoad()
 {
     if (Loaded)
     {
         return;
     }
     _actualObject = new T();
     lazyReader.JumpAndReturn(OffsetInFile, () => _actualObject.Read(lazyReader));
     lazyReader = null;
     Loaded     = true;
 }
Exemple #2
0
        public override void Read(ArchiveReader reader)
        {
            var childCount = reader.ReadCompressedInt();
            var data       = new PcomObject[childCount];

            ChildCount = childCount;

            for (int i = 0; i < childCount; i++)
            {
                var po = LoadFromBlob(reader);
                po.Parent = this;
                data[i]   = po;
            }

            _obj = data;
        }
        public WzCanvas GetActualImage()
        {
            // 1-by-1 pixel image should be loaded from somewhere else
            if (!(Width == 1 && Height == 1))
            {
                return(this);
            }

            if (_linkedTile != null)
            {
                return(_linkedTile);
            }

            if (HasChild("_outlink"))
            {
                // This one is absolute in whole data storage
                var uol = new WzUOL
                {
                    Path     = GetString("_outlink"),
                    Parent   = Parent,
                    Name     = Name,
                    Absolute = true
                };

                _linkedTile = uol.ActualObject() as WzCanvas;

                if (_linkedTile == null)
                {
                    Console.WriteLine("Unable to load {0} image. Cur path: {1}", uol.Path, GetFullPath());
                }
                else
                {
                    return(_linkedTile);
                }
            }

            if (HasChild("_inlink"))
            {
                // This one is relative to this img
                PcomObject imgNode = this;
                while (!imgNode.Name.EndsWith(".img"))
                {
                    imgNode = imgNode.Parent;
                }

                var uol = new WzUOL
                {
                    Path     = GetString("_inlink"),
                    Parent   = imgNode,
                    Name     = Name,
                    Absolute = false
                };

                _linkedTile = uol.ActualObject() as WzCanvas;
                if (_linkedTile == null)
                {
                    Console.WriteLine("Unable to load {0} image. Cur path: {1}", uol.Path, GetFullPath());
                }
                else
                {
                    return(_linkedTile);
                }
            }


            return(_linkedTile ?? this);
        }