Exemplo n.º 1
0
        public ExtractString(string fileName, string output)
        {
            WZFile   xz      = new WZFile(fileName, WZVariant.Classic, true, WZReadSelection.EagerParseStrings);
            WZObject consume = xz.MainDirectory["Consume.img"];

            StringBuilder    sb = new StringBuilder();
            StringWriter     sw = new StringWriter(sb);
            HashSet <string> listOfDamageSkins = new HashSet <string>();

            string[] exceptions = new string[] { "30", "Protected", "Permanent", "Box", "Ticket" };

            using (JsonWriter writer = new JsonTextWriter(sw))
            {
                writer.Formatting = Formatting.Indented;

                writer.WriteStartArray();
                foreach (var item in consume)
                {
                    foreach (var child in item)
                    {
                        if (child.Name == "name")
                        {
                            if (child.ValueOrDie <String>().Contains("Damage Skin -"))
                            {
                                string damageSkin = child.ValueOrDie <string>();
                                if (exceptions.Any(damageSkin.Contains))
                                {
                                    break;
                                }

                                string[] split        = damageSkin.Split('-');
                                string   actualString = split[1].Trim();

                                if (listOfDamageSkins.Contains(actualString))
                                {
                                    Console.WriteLine(actualString + " is already in the list");
                                    break;
                                }
                                else
                                {
                                    listOfDamageSkins.Add(actualString);
                                    writer.WriteStartObject();
                                    writer.WritePropertyName("itemId");
                                    writer.WriteValue(item.Name);
                                    writer.WritePropertyName("itemName");
                                    writer.WriteValue(damageSkin);
                                    writer.WriteEndObject();
                                    Console.WriteLine(damageSkin);
                                }
                            }
                        }
                    }
                }
                writer.WriteEndArray();
            }
            File.WriteAllText(output, sb.ToString());
            Console.WriteLine("Number of Damage Skins: " + listOfDamageSkins.Count);
            Console.Write("done");
            Console.ReadKey();
        }
Exemplo n.º 2
0
        internal static WZObject ResolvePath(WZObject start, string path)
        {
            try {
                WZObject result = start;
                string[] nodes  = (path.StartsWith("/") ? path.Substring(1) : path).Split('/');
                foreach (string node in nodes)
                {
                    switch (node)
                    {
                    case ".":
                        continue;

                    case "..":
                        result = result.Parent;
                        continue;
                    }
                    WZUOLProperty uolNode = result as WZUOLProperty;
                    if (uolNode != null)
                    {
                        result = uolNode.FinalTarget;
                    }
                    result = result[node];
                }
                return(result);
            } catch (KeyNotFoundException) {
                return(null);
            }
        }
Exemplo n.º 3
0
        public void Load(WZObject mapNode)
        {
            var footholds = mapNode["foothold"];

            foreach (WZObject wz1 in footholds)
            {
                foreach (WZObject wz2 in wz1)
                {
                    foreach (WZObject fh in wz2)
                    {
                        var f = new Foothold
                        {
                            Id   = Convert.ToInt32(fh.Name),
                            Next = fh["next"].ValueOrDie <int>(),
                            Prev = fh["prev"].ValueOrDie <int>(),
                            X1   = (short)fh["x1"].ValueOrDie <int>(),
                            Y1   = (short)fh["y1"].ValueOrDie <int>(),
                            X2   = (short)fh["x2"].ValueOrDie <int>(),
                            Y2   = (short)fh["y2"].ValueOrDie <int>(),
                        };

                        Footholds.Add(f);
                    }
                }
            }
        }
Exemplo n.º 4
0
        public static List <Frame> InputWz(WZFile wz, string inpath)
        {
            WZObject      iwahz = wz.ResolvePath(inpath);
            WZSubProperty iwah  = iwahz as WZSubProperty;

            if (iwah == null)
            {
                throw new ArgumentException("The path provided did not lead to an animation; check input-wzfile, input-wzpath and input-wzver");
            }
            List <Frame> r = new List <Frame>();

            foreach (WZObject iwzo in iwah)
            {
                WZCanvasProperty iwc = iwzo.ResolveUOL() as WZCanvasProperty;
                if (iwc == null)
                {
                    continue;
                }
                int n;
                if (!int.TryParse(iwzo.Name, out n))
                {
                    continue;
                }
                r.Add(new Frame(n, new Bitmap(iwc.Value), ((WZPointProperty)iwc["origin"]).Value, iwc.HasChild("delay") ? Math.Max(iwc["delay"].ToInt(), 1) : 100));
                iwc.Dispose();
            }
            return(r.OrderBy(f => f.Number).ToList());
        }
Exemplo n.º 5
0
        public WzImageNode(NodeView nodeView, string directoryPath, WZObject wzDirectory)
            : base(nodeView)
        {
            this.DirectoryPath = directoryPath;
            this.Text          = wzDirectory.Name;

            _wzImage = wzDirectory;
        }
Exemplo n.º 6
0
        public WzStringNode(NodeView nodeView, string directoryPath, WZObject wzNode)
            : base(nodeView, directoryPath)
        {
            this.DirectoryPath = directoryPath;
            this.Text          = wzNode.Name;

            this.WzNode = wzNode;
        }
Exemplo n.º 7
0
        public WzSubPropertyNode(NodeView nodeView, string directoryPath, WZObject wzSubProperty)
            : base(nodeView)
        {
            this.DirectoryPath = directoryPath;
            this.Text          = wzSubProperty.Name;

            _wzSubProperty = wzSubProperty;
        }
Exemplo n.º 8
0
        private void Load(WZObject mapNode)//WzManager wzMan)
        {
            Portals.Load(mapNode);
            Footholds.Load(mapNode);
            Npcs.Load(mapNode);

            Mobs.Load(mapNode);
            Mobs.DoMobLogic();
        }
Exemplo n.º 9
0
        public static int ToInt(this WZObject izo)
        {
            WZInt32Property wzInt32Property = izo as WZInt32Property;

            if (wzInt32Property != null)
            {
                return((wzInt32Property).Value);
            }
            WZStringProperty wzStringProperty = izo as WZStringProperty;

            if (wzStringProperty != null)
            {
                return(int.Parse((wzStringProperty).Value));
            }
            throw new FormatException(String.Format("Cannot convert {0} to integer; is not an integer.", izo.GetType().Name));
        }
Exemplo n.º 10
0
        public void Load(WZObject mapNode)
        {
            var life = mapNode["life"];

            foreach (WZObject node in life)
            {
                var type = node["type"].ValueOrDie <string>();

                if (type != "n")
                {
                    continue;
                }

                var id = node["id"].ValueOrDie <string>();

                var fh = node["fh"].ValueOrDie <int>();
                var x  = node["x"].ValueOrDie <int>();
                var y  = node["y"].ValueOrDie <int>();

                var cy = node["cy"].ValueOrDie <int>();
                //var f = node["f"].ValueOrDie<int>();
                //var hide = node["hide"].ValueOrDie<int>();
                var rx0 = node["rx0"].ValueOrDie <int>();
                var rx1 = node["rx1"].ValueOrDie <int>();
                //var mobTime = node["mobTime"].ValueOrDie<int>();

                var uid = GetUniqueId();

                var cl = new CNpc
                {
                    dwNpcId  = uid,
                    Id       = Convert.ToInt32(id),
                    Type     = type,
                    Foothold = fh,
                    X        = x,
                    Y        = y,
                    Cy       = cy,
                    //F = f,
                    //Hide = hide,
                    Rx0 = rx0,
                    Rx1 = rx1,
                    //MobTime = mobTime
                };

                Add(uid, cl);
            }
        }
Exemplo n.º 11
0
        public void Load(WZObject mapNode)
        {
            var life = mapNode["life"];

            foreach (WZObject node in life)
            {
                var type = node["type"].ValueOrDie <string>();

                if (type != "m")
                {
                    continue;
                }

                var id = node["id"].ValueOrDie <string>();

                var fh = node["fh"].ValueOrDie <int>();
                var x  = node["x"].ValueOrDie <int>();
                var y  = node["y"].ValueOrDie <int>();

                var cy      = node["cy"].ValueOrDie <int>();
                var f       = node["f"].ValueOrDie <int>();
                var hide    = node["hide"].ValueOrDie <int>();
                var rx0     = node["rx0"].ValueOrDie <int>();
                var rx1     = node["rx1"].ValueOrDie <int>();
                var mobTime = node["mobTime"].ValueOrDie <int>();

                var cl = new CLife
                {
                    Id       = Convert.ToInt32(id),
                    Type     = type,
                    Foothold = fh,
                    X        = x,
                    Y        = y,
                    Cy       = cy,
                    F        = f,
                    Hide     = hide,
                    Rx0      = rx0,
                    Rx1      = rx1,
                    MobTime  = mobTime
                };

                Spawns.Add(cl);
            }
        }
Exemplo n.º 12
0
        public static int GetInt(this WZObject parentNode, string childName, int def = 0)
        {
            if (!parentNode.HasChild(childName))
            {
                return(def);
            }

            WZObject childNode = parentNode[childName];

            if (childNode is WZInt32Property)
            {
                return((childNode as WZInt32Property).Value);
            }
            if (childNode is WZStringProperty)
            {
                return(int.Parse((childNode as WZStringProperty).Value));
            }

            throw new Exception("unablet o cast");
        }
Exemplo n.º 13
0
        private static Dictionary <int, PortalInfo> ParseMapNode(WZObject map)
        {
            Dictionary <int, PortalInfo> portals = new Dictionary <int, PortalInfo>();
            int id = int.Parse(Path.GetFileNameWithoutExtension(map.Name));

            foreach (var portal in map.ResolvePath("portal") ?? Enumerable.Empty <WZObject>())
            {
                int dst = portal.ResolvePath("tm").ValueOrDefault(999999999);
                if (dst == 999999999 || dst == -1 || dst == id)
                {
                    continue;
                }

                portals[dst] = new PortalInfo {
                    X    = (short)portal.ResolvePath("x").ValueOrDie <int>(),
                    Y    = (short)portal.ResolvePath("y").ValueOrDie <int>(),
                    Name = portal.ResolvePath("pn").ValueOrDie <string>()
                };
            }
            return(portals);
        }
Exemplo n.º 14
0
        public void Load(WZObject mapNode)
        {
            var portals = mapNode["portal"];

            foreach (WZObject x in portals)
            {
                var p = new Portal
                {
                    nIdx   = Convert.ToInt32(x.Name),
                    sName  = x["pn"].ValueOrDie <string>(),
                    nType  = x["pt"].ValueOrDie <int>(),
                    nTMap  = x["tm"].ValueOrDie <int>(),
                    sTName = x["tn"].ValueOrDie <string>(),
                    ptPos  =
                    {
                        X = (short)x["x"].ValueOrDie <int>(),
                        Y = (short)x["y"].ValueOrDie <int>()
                    }
                };

                Portals.Add(p);
            }
        }
Exemplo n.º 15
0
 public static WZObject ResolveUOL(this WZObject iwzo)
 {
     return(iwzo is WZUOLProperty ? ((WZUOLProperty)iwzo).ResolveFully() : iwzo);
 }
Exemplo n.º 16
0
 internal WZDirectory(string name, WZObject parent, WZFile file, WZBinaryReader wzbr, long offset)
     : base(name, parent, file, true, WZObjectType.Directory)
 {
     Parse(wzbr, offset);
 }
Exemplo n.º 17
0
 public static int GetID(this WZObject node)
 {
     return(int.Parse(node.Name.Replace(".img", "")));
 }
Exemplo n.º 18
0
 public static string GetString(this WZObject node, string childName, string def = "")
 {
     return(node.HasChild(childName) ? node[childName].ValueOrDie <string>() : def);
 }
Exemplo n.º 19
0
 public static double GetDouble(this WZObject node, string childName, double def = 0)
 {
     return(node.HasChild(childName) ? node[childName].ValueOrDie <double>() : def);
 }
Exemplo n.º 20
0
        private static void Run(string inWz, string outPath, WZVariant wzVar, bool initialEnc)
        {
            Console.WriteLine("Input .wz: {0}{1}Output .nx: {2}", Path.GetFullPath(inWz),
                              Environment.NewLine, Path.GetFullPath(outPath));

            Stopwatch swOperation = new Stopwatch();
            Stopwatch fullTimer   = new Stopwatch();

            Action <string> reportDone = str => {
                Console.WriteLine("done. E{0} T{1}", swOperation.Elapsed,
                                  fullTimer.Elapsed);
                swOperation.Restart();
                Console.Write(str);
            };

            fullTimer.Start();
            swOperation.Start();
            Console.Write("Parsing input WZ... ".PadRight(31));

            WZReadSelection rFlags = WZReadSelection.EagerParseImage |
                                     WZReadSelection.EagerParseStrings;

            if (!dumpImg)
            {
                rFlags |= WZReadSelection.NeverParseCanvas;
            }

            using (WZFile wzf = new WZFile(inWz, wzVar, initialEnc, rFlags))
                using (
                    FileStream outFs = new FileStream(outPath, FileMode.Create, FileAccess.ReadWrite,
                                                      FileShare.None))
                    using (BinaryWriter bw = new BinaryWriter(outFs)) {
                        DumpState state = new DumpState();

                        reportDone("Writing header... ".PadRight(31));
                        bw.Write(PKG4);
                        bw.Write(new byte[(4 + 8) * 4]);

                        reportDone("Writing nodes... ".PadRight(31));
                        outFs.EnsureMultiple(4);
                        ulong           nodeOffset = (ulong)bw.BaseStream.Position;
                        List <WZObject> nodeLevel  = new List <WZObject> {
                            wzf.MainDirectory
                        };
                        while (nodeLevel.Count > 0)
                        {
                            WriteNodeLevel(ref nodeLevel, state, bw);
                        }

                        ulong stringOffset;
                        uint  stringCount = (uint)state.Strings.Count;
                        {
                            reportDone("Writing string data...".PadRight(31));
                            Dictionary <uint, string> strings = state.Strings.ToDictionary(kvp => kvp.Value,
                                                                                           kvp => kvp.Key);
                            ulong[] offsets = new ulong[stringCount];
                            for (uint idx = 0; idx < stringCount; ++idx)
                            {
                                outFs.EnsureMultiple(2);
                                offsets[idx] = (ulong)bw.BaseStream.Position;
                                WriteString(strings[idx], bw);
                            }

                            outFs.EnsureMultiple(8);
                            stringOffset = (ulong)bw.BaseStream.Position;
                            for (uint idx = 0; idx < stringCount; ++idx)
                            {
                                bw.Write(offsets[idx]);
                            }
                        }

                        ulong bitmapOffset = 0UL;
                        uint  bitmapCount  = 0U;
                        if (dumpImg)
                        {
                            reportDone("Writing canvas data...".PadRight(31));
                            bitmapCount = (uint)state.Canvases.Count;
                            ulong[] offsets = new ulong[bitmapCount];
                            long    cId     = 0;
                            foreach (WZCanvasProperty cNode in state.Canvases)
                            {
                                outFs.EnsureMultiple(8);
                                offsets[cId++] = (ulong)bw.BaseStream.Position;
                                WriteBitmap(cNode, bw);
                            }
                            outFs.EnsureMultiple(8);
                            bitmapOffset = (ulong)bw.BaseStream.Position;
                            for (uint idx = 0; idx < bitmapCount; ++idx)
                            {
                                bw.Write(offsets[idx]);
                            }
                        }

                        ulong soundOffset = 0UL;
                        uint  soundCount  = 0U;
                        if (dumpSnd)
                        {
                            reportDone("Writing MP3 data... ".PadRight(31));
                            soundCount = (uint)state.MP3s.Count;
                            ulong[] offsets = new ulong[soundCount];
                            long    cId     = 0;
                            foreach (WZAudioProperty mNode in state.MP3s)
                            {
                                outFs.EnsureMultiple(8);
                                offsets[cId++] = (ulong)bw.BaseStream.Position;
                                WriteMP3(mNode, bw);
                            }
                            outFs.EnsureMultiple(8);
                            soundOffset = (ulong)bw.BaseStream.Position;
                            for (uint idx = 0; idx < soundCount; ++idx)
                            {
                                bw.Write(offsets[idx]);
                            }
                        }

                        reportDone("Writing linked node data... ".PadRight(31));
                        byte[] uolReplace = new byte[16];
                        foreach (KeyValuePair <WZUOLProperty, Action <BinaryWriter, byte[]> > pair in state.UOLs)
                        {
                            WZObject result = pair.Key.FinalTarget;
                            if (result == null)
                            {
                                continue;
                            }
                            bw.BaseStream.Position = (long)(nodeOffset + state.GetNodeID(result) * 20 + 4);
                            bw.BaseStream.Read(uolReplace, 0, 16);
                            pair.Value(bw, uolReplace);
                        }

                        reportDone("Finalising... ".PadRight(31));

                        bw.Seek(4, SeekOrigin.Begin);
                        bw.Write((uint)state.Nodes.Count);
                        bw.Write(nodeOffset);
                        bw.Write(stringCount);
                        bw.Write(stringOffset);
                        bw.Write(bitmapCount);
                        bw.Write(bitmapOffset);
                        bw.Write(soundCount);
                        bw.Write(soundOffset);

                        reportDone("Completed!");
                    }
        }
Exemplo n.º 21
0
        private static void WriteNode(WZObject node, DumpState ds, BinaryWriter bw, uint nextChildID)
        {
            ds.AddNode(node);
            bw.Write(ds.AddString(node.Name));
            bw.Write(nextChildID);
            bw.Write((ushort)node.ChildCount);
            ushort type;

            if (node is WZDirectory || node is WZImage || node is WZSubProperty || node is WZConvexProperty ||
                node is WZNullProperty)
            {
                type = 0; // no data; children only (8)
            }
            else if (node is WZInt32Property || node is WZUInt16Property || node is WZInt64Property)
            {
                type = 1; // int32 (4)
            }
            else if (node is WZSingleProperty || node is WZDoubleProperty)
            {
                type = 2; // Double (0)
            }
            else if (node is WZStringProperty)
            {
                type = 3; // String (4)
            }
            else if (node is WZPointProperty)
            {
                type = 4; // (0)
            }
            else if (node is WZCanvasProperty)
            {
                type = 5; // (4)
            }
            else if (node is WZAudioProperty)
            {
                type = 6; // (4)
            }
            else
            {
                throw new InvalidOperationException("Unhandled WZ node type [1]");
            }

            bw.Write(type);

            if (node is WZInt32Property)
            {
                bw.Write((long)((WZInt32Property)node).Value);
            }
            else if (node is WZUInt16Property)
            {
                bw.Write((long)((WZUInt16Property)node).Value);
            }
            else if (node is WZInt64Property)
            {
                bw.Write(((WZInt64Property)node).Value);
            }
            else if (node is WZSingleProperty)
            {
                bw.Write((double)((WZSingleProperty)node).Value);
            }
            else if (node is WZDoubleProperty)
            {
                bw.Write(((WZDoubleProperty)node).Value);
            }
            else if (node is WZStringProperty)
            {
                bw.Write(ds.AddString(((WZStringProperty)node).Value));
            }
            else if (node is WZPointProperty)
            {
                Point pNode = ((WZPointProperty)node).Value;
                bw.Write(pNode.X);
                bw.Write(pNode.Y);
            }
            else if (node is WZCanvasProperty)
            {
                WZCanvasProperty wzcp = (WZCanvasProperty)node;
                bw.Write(ds.AddCanvas(wzcp));
                if (dumpImg)
                {
                    bw.Write((ushort)wzcp.Value.Width);
                    bw.Write((ushort)wzcp.Value.Height);
                    wzcp.Dispose();
                }
                else
                {
                    bw.Write(0);
                }
            }
            else if (node is WZAudioProperty)
            {
                WZAudioProperty wzmp = (WZAudioProperty)node;
                bw.Write(ds.AddMP3(wzmp));
                if (dumpSnd)
                {
                    bw.Write((uint)wzmp.Value.Length);
                    wzmp.Dispose();
                }
                else
                {
                    bw.Write(0);
                }
            }
            switch (type)
            {
            case 0:
                bw.Write(0L);
                break;

            case 3:
                bw.Write(0);
                break;
            }
        }
Exemplo n.º 22
0
            public void AddNode(WZObject node)
            {
                uint ret = (uint)Nodes.Count;

                Nodes.Add(node, ret);
            }
Exemplo n.º 23
0
        void Export(WZObject wz, JObject json, bool jsonOnly)
        {
            var folderPath = Path.Combine(Settings.BaseExportPath, wz.Parent.Path.Replace("/", "\\").Replace(":", "_").Trim('\\'));
            var itemPath   = Path.Combine(folderPath, wz.Name);

            if (json != null &&
                wz.Type != WZObjectType.String &&
                wz.Type != WZObjectType.Single &&
                wz.Type != WZObjectType.Double &&
                wz.Type != WZObjectType.UInt16 &&
                wz.Type != WZObjectType.Int32 &&
                wz.Type != WZObjectType.Null)
            {
                var o = new JObject();
                json.Add(wz.Name, o);
                json = o;
            }

            if (wz.Type == WZObjectType.Image)
            {
                json = new JObject();
            }

            switch (wz.Type)
            {
            case WZObjectType.Directory:
            case WZObjectType.SubProperty:
            case WZObjectType.Convex:
            case WZObjectType.Image:
            case WZObjectType.Null:
                break;

            case WZObjectType.UInt16:
                var uint16 = ((WZUInt16Property)wz).Value;
                json.Add(new JProperty(wz.Name, uint16));
                break;

            case WZObjectType.Int32:
                var int32 = ((WZInt32Property)wz).Value;
                json.Add(new JProperty(wz.Name, int32));
                break;

            case WZObjectType.Single:
                var single = ((WZSingleProperty)wz).Value;
                json.Add(new JProperty(wz.Name, single));
                break;

            case WZObjectType.Double:
                var doubl = ((WZDoubleProperty)wz).Value;
                json.Add(new JProperty(wz.Name, doubl));
                break;

            case WZObjectType.String:
                var text = ((WZStringProperty)wz).Value;
                json.Add(new JProperty(wz.Name, text));
                break;

            case WZObjectType.Point:
                var point = ((WZPointProperty)wz).Value;
                json.Add("x", point.X);
                json.Add("y", point.Y);
                break;

            case WZObjectType.Link:
                var link   = ((WZLinkProperty)wz);
                var target = link.FinalTarget ?? link.Target;
                if (target == null)
                {
                    MissingLinksCount++;
                    Settings.WriteToLog("Failed link lookup to: " + link.Value + " from " + wz.Path);
                    Settings.WriteToLog("Failed link lookups: " + MissingLinksCount);
                    break;
                }

                foreach (var wzChild in target)
                {
                    Export(wzChild, json, true);
                }

                break;

            case WZObjectType.Audio:
                if (!Settings.OutputSound || jsonOnly)
                {
                    break;
                }
                try
                {
                    var soundBytes = ((WZAudioProperty)wz).Value;
                    SaveSound(wz.Path, folderPath, itemPath, soundBytes);
                }
                catch (Exception ex)
                {
                    Error("Error saving sound " + wz.Path, ex);
                }
                break;

            case WZObjectType.Canvas:
                if (!Settings.OutputImages || jsonOnly)
                {
                    break;
                }
                try
                {
                    var orgImage = ((WZCanvasProperty)wz).Value;
                    SaveBitmap(wz.Path, folderPath, itemPath, orgImage);
                }
                catch (Exception ex)
                {
                    Error("Error saving image " + wz.Path, ex);
                }
                break;

            default:
                json.Add(wz.Name, "Unknown type: " + wz.Type);
                Error("Unknown type: " + wz.Type);
                break;
            }

            if (wz is IDisposable)
            {
                ((IDisposable)wz).Dispose();
            }

            foreach (var wzChild in wz)
            {
                Export(wzChild, json, false);
            }

            if (json != null && json.Parent == null && Settings.OutputJson)
            {
                SaveJson(wz.Path, json, itemPath);
            }
        }
Exemplo n.º 24
0
 public uint GetNodeID(WZObject node) {
     return Nodes[node];
 }
Exemplo n.º 25
0
 public void AddNode(WZObject node) {
     uint ret = (uint) Nodes.Count;
     Nodes.Add(node, ret);
 }
Exemplo n.º 26
0
        private static void WriteNode(WZObject node, DumpState ds, BinaryWriter bw, uint nextChildID) {
            ds.AddNode(node);
            bw.Write(ds.AddString(node.Name));
            bw.Write(nextChildID);
            bw.Write((ushort) node.ChildCount);
            ushort type;

            if (node is WZDirectory || node is WZImage || node is WZSubProperty || node is WZConvexProperty ||
                node is WZNullProperty)
                type = 0; // no data; children only (8)
            else if (node is WZInt32Property || node is WZUInt16Property || node is WZInt64Property)
                type = 1; // int32 (4)
            else if (node is WZSingleProperty || node is WZDoubleProperty)
                type = 2; // Double (0)
            else if (node is WZStringProperty)
                type = 3; // String (4)
            else if (node is WZPointProperty)
                type = 4; // (0)
            else if (node is WZCanvasProperty)
                type = 5; // (4)
            else if (node is WZAudioProperty)
                type = 6; // (4)
            else
                throw new InvalidOperationException("Unhandled WZ node type [1]");

            bw.Write(type);

            if (node is WZInt32Property)
                bw.Write((long) ((WZInt32Property) node).Value);
            else if (node is WZUInt16Property)
                bw.Write((long) ((WZUInt16Property) node).Value);
            else if (node is WZInt64Property)
                bw.Write(((WZInt64Property) node).Value);
            else if (node is WZSingleProperty)
                bw.Write((double) ((WZSingleProperty) node).Value);
            else if (node is WZDoubleProperty)
                bw.Write(((WZDoubleProperty) node).Value);
            else if (node is WZStringProperty)
                bw.Write(ds.AddString(((WZStringProperty) node).Value));
            else if (node is WZPointProperty) {
                Point pNode = ((WZPointProperty) node).Value;
                bw.Write(pNode.X);
                bw.Write(pNode.Y);
            } else if (node is WZCanvasProperty) {
                WZCanvasProperty wzcp = (WZCanvasProperty) node;
                bw.Write(ds.AddCanvas(wzcp));
                if (dumpImg) {
                    bw.Write((ushort) wzcp.Value.Width);
                    bw.Write((ushort) wzcp.Value.Height);
                    wzcp.Dispose();
                } else
                    bw.Write(0);
            } else if (node is WZAudioProperty) {
                WZAudioProperty wzmp = (WZAudioProperty) node;
                bw.Write(ds.AddMP3(wzmp));
                if (dumpSnd) {
                    bw.Write((uint) wzmp.Value.Length);
                    wzmp.Dispose();
                } else
                    bw.Write(0);
            }
            switch (type) {
                case 0:
                    bw.Write(0L);
                    break;
                case 3:
                    bw.Write(0);
                    break;
            }
        }
Exemplo n.º 27
0
 public uint GetNodeID(WZObject node)
 {
     return(Nodes[node]);
 }
Exemplo n.º 28
0
 internal WZDirectory(string name, WZObject parent, WZFile file, WZBinaryReader wzbr, long offset)
     : base(name, parent, file, true, WZObjectType.Directory)
 {
     Parse(wzbr, offset);
 }
Exemplo n.º 29
0
 public WZDataProperty(WZObject node)
 {
     _node = node;
 }