本文整理汇总了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!");
}
}