当前位置: 首页>>代码示例>>C#>>正文


C# DumpState.GetNodeID方法代码示例

本文整理汇总了C#中DumpState.GetNodeID方法的典型用法代码示例。如果您正苦于以下问题:C# DumpState.GetNodeID方法的具体用法?C# DumpState.GetNodeID怎么用?C# DumpState.GetNodeID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DumpState的用法示例。


在下文中一共展示了DumpState.GetNodeID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run


//.........这里部分代码省略.........

            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!");
            }
        }
开发者ID:mspencer92,项目名称:ms-wz2nx,代码行数:101,代码来源:Program.cs


注:本文中的DumpState.GetNodeID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。